13.12.2012 Views

emWin - SEGGER Microcontroller

emWin - SEGGER Microcontroller

emWin - SEGGER Microcontroller

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Screenshot<br />

Before After<br />

19.6 Major changes to the look of the ’Flex’ skin<br />

The drawing mechanism of the default design without skinning is a ’black box’ for the<br />

application designer. The same is true for skinning if no major changes of the default<br />

look are required. If changing the attributes of the default skin is not sufficient to<br />

realize the required look, it is required to understand the details of the drawing<br />

mechanism of skinning.<br />

19.6.1 The skinning callback mechanism<br />

The drawing mechanism for all skinnable widgets is very similar and looks as follows:<br />

int _DrawSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) {<br />

switch (pDrawItemInfo->Cmd) {<br />

case WIDGET_ITEM_DRAW_BACKGROUND:<br />

/* Draw the background */<br />

break;<br />

case WIDGET_ITEM_DRAW_TEXT:<br />

/* Draw the text */<br />

break;<br />

case WIDGET_ITEM_CREATE:<br />

/* Additional function calls required to create the widget */<br />

break;<br />

...<br />

}<br />

Elements of WIDGET_ITEM_DRAW_INFO<br />

Data type Element Description<br />

WM_HWIN hWin Handle to the widget.<br />

int Cmd Command to be processed.<br />

int ItemIndex Index of item to be drawn.<br />

int x0 Leftmost coordinate in window coordinates.<br />

int y0 Topmost coordinate in window coordinates.<br />

int x1 Rightmost coordinate in window coordinates.<br />

int y1 Bottommost coordinate in window coordinates.<br />

void * p Data pointer to widget specific information.<br />

This scheme is identical to all skinnable widgets. The callback function receives a<br />

pointer to a WIDGET_ITEM_DRAW_INFO structure. The structure pointed by pDrawItem-<br />

Info contains a command which has to be processed, a handle to the widget and further<br />

information whose meaning may vary by widget. The skinning callback function<br />

has to react with drawing a dedicated detail or with returning a dedicated value.<br />

How to use the drawing information in detail is explained later in this chapter.<br />

19.6.2 Changing the look of the default skin<br />

Understanding the above callback mechanism is important because changing a skin<br />

can easily be done by deriving a new skin from an existing one. A small example<br />

should show how the look of the default skin of a widget can be changed.<br />

UM03001 User & Reference Guide for <strong>emWin</strong> V5.18 © 1997 - 2012 <strong>SEGGER</strong> <strong>Microcontroller</strong> GmbH & Co. KG<br />

767

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!