Difference between revisions of "Widgets"

From uGFX Wiki
Jump to: navigation, search
Line 7: Line 7:
 
A list with descriptions of the common container API can be found [http://ugfx.org/images/resources/doxygen/master/group___widget.html here].
 
A list with descriptions of the common container API can be found [http://ugfx.org/images/resources/doxygen/master/group___widget.html here].
  
== Widget Implementations ==
+
== Custom render interface ==
 +
Every window provided by the GWIN module comes with a custom render interface. The default style in which a widget is drawn is very basic and minimalistic in order to make it run on the even lowest performance systems. However, the custom render interface allows you to submit your own rendering routines. This does not only provide a very flexible way to render a widget matching to your systems performance, but it gives you also the possibility to render a widget matching your applications style.
 +
 
 +
Every widget provides an API call like the the following:
 +
 
 +
<syntaxhighlight lang=c>void gwinSetCustomDraw(GHandle gh, CustomWidgetDrawFunction fn, void *param);</syntaxhighlight>
 +
The CustomWidgetDrawFunction is a typedef'ed function pointer:
 +
 
 +
<syntaxhighlight lang=c>typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param);</syntaxhighlight>
 +
The param parameter can be used to pass a custom parameter such as a file pointer. However, in most of the cases, this parameter will be '''NULL'''.
 +
 
 +
All the information required to write a custom render function for a widget, such as the position, size, state, text, fonts etc. can be obtained from the GHandle.
 +
 
 +
== Widget implementations ==
 
These are the currently implemented widgets:
 
These are the currently implemented widgets:
 
* [[Label]]
 
* [[Label]]

Revision as of 16:19, 1 July 2014

The widget class is based on the window. In addition to the window functionalities, it implements the following features:

  • Widgets can always redraw themselves
  • Widgets are able to accept user input such as from a touchscreen/toggle/dial/keyboard
  • Widgets can have their drawing routine overwritten to provide fancier versions of the object. For example, their are predefined drawing routines for round buttons, image buttons, arrow buttons etc. along with the normal button drawing routine.
  • Widgets support a "style". By changing the style you can affect the colors used to draw the widget similar to the way you can apply color schemes in Windows and Linux.

A list with descriptions of the common container API can be found here.

Custom render interface

Every window provided by the GWIN module comes with a custom render interface. The default style in which a widget is drawn is very basic and minimalistic in order to make it run on the even lowest performance systems. However, the custom render interface allows you to submit your own rendering routines. This does not only provide a very flexible way to render a widget matching to your systems performance, but it gives you also the possibility to render a widget matching your applications style.

Every widget provides an API call like the the following:

void gwinSetCustomDraw(GHandle gh, CustomWidgetDrawFunction fn, void *param);

The CustomWidgetDrawFunction is a typedef'ed function pointer:

typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param);

The param parameter can be used to pass a custom parameter such as a file pointer. However, in most of the cases, this parameter will be NULL.

All the information required to write a custom render function for a widget, such as the position, size, state, text, fonts etc. can be obtained from the GHandle.

Widget implementations

These are the currently implemented widgets: