Skinning

Skinning is a method of changing the appearance of one or multiple widgets. It allows changing the look by using a dedicated skin which defines how the widgets are rendered. This makes it easy to change the appearance of a complete group of widgets in a similar way by changing only the skin.

Without skinning, widget member functions have to be used to change the look for each single widget or the callback function has to be overwritten.

What is a ’skin’?

A skin is just a simple callback function which is available for drawing all details of a widget. It works by exactly same way as a ’user draw function’ of a widget, an older method of widget customization which was available before ’skinning’ was implemented.

From using API functions to skinning

There are different methods to change the appearance of a widget. Widget API functions, user draw functions, skinning and overwriting the callback function can be used to modify the appearance of a widget. The decision of the method to be used depends on what should be changed. The following explains what can be achieved with each method.

Using widget API functions

The default API functions can be used to change attributes like size, color, font or bitmaps used to draw a widget using the classical design. The following screenshot shows a typical sample of what can be done:

Before After
   

Some attributes can be changed but the basic appearance stays the same.

User draw functions

Some widgets like LISTBOX, FRAMEWIN, GRAPH or BUTTON widgets offer user draw functions. These functions can be used to draw some additional details or to replace the default drawing method for some items. The following screenshot shows a user drawn title area of a frame window. The user draw function renders the gradient in the title area, which can’t be achieved with the widget API functions:

Before After
   

Skinning

Contrary to the methods mentioned above skinning covers the drawing of the whole widget and not only some details. We also used this opportunity to lift the appearance of the skinnable widgets which look much more up-to-date as the classical widget design. The following table shows the look of the about box from above in comparison with the new default skin:

Classical design Default skin
   

Overwriting the callback function of a widget

Before skinning was implemented, the only method of changing the complete appearance of a widget was overwriting the callback function of a widget. This gives full control over the complete message processing of the widget. It can be used in combination with the other methods. The main disadvantages of overwriting the callback function is that lots of code needs to be written by the user. This process is errorprone.

Skinnable widgets

Skinning makes only sense if a widget consists of several widget specific details. It does not make sense for each kind of widget. A TEXT widget for example does not require a separate skin, because it consists only of the text itself.

Currently the following widgets support skinning:

  • BUTTON
  • CHECKBOX
  • DROPDOWN
  • FRAMEWIN
  • HEADER
  • PROGBAR
  • RADIO
  • SCROLLBAR
  • SLIDER

Using a skin

The shipment of emWin contains a ready-to-use default skin for all above listed skinnable widgets. They have been named <WIDGET>_SKIN_FLEX.

The following table shows the available default skins for all skinnable widgets:

Widget Default skin
BUTTON BUTTON_SKIN_FLEX
CHECKBOX CHECKBOX_SKIN_FLEX
DROPDOWN DROPDOWN_SKIN_FLEX
FRAMEWIN FRAMEWIN_SKIN_FLEX
HEADER HEADER_SKIN_FLEX
PROGBAR PROGBAR_SKIN_FLEX
RADIO RADIO_SKIN_FLEX
SCROLLBAR SCROLLBAR_SKIN_FLEX
SLIDER SLIDER_SKIN_FLEX