Widget Tutorial - EdgarReynaldo/EagleGUI GitHub Wiki
Widget Tutorial
Here we learn first how to use widgets Using Widgets and next how to Create Widgets.
Using Widgets
First we should look at the public methods in the WidgetBase class. These are the mainstay of functions available for WidgetBase derived objects, of which all widgets are derived from. There is a lot of functionality and a diverse set of functions for all your widget needs. First let's go over the main interface of a widget. From WidgetBase.hpp we have the following 3 functions :
int HandleEvent(EagleEvent ee);///< Handles the event passed to it, and returns a bitfield composed of
///< flags specified by @ref DIALOG_RETURN_VALUE
int Update(double dt);///< Updates the widget based on the delta time, and returns a bitfield composed of
///< flags specified by @ref DIALOG_RETURN_VALUE
void Display(EagleGraphicsContext* win , int xpos , int ypos);///< Displays the specified widget on the graphics window at x,y
These 3 functions are common to all widgets, and since a WidgetHandler and a LayoutBase inherit from WidgetBase, they have these functions as well. Generally you only call these functions on the top level WidgetHandler object and it will handle the details of passing the event, updating, and drawing all the widgets it holds.
HandleEvent is how the widget reacts to events in the system. Pass the event into the widget and it will change it's state accordingly. See the EventHandler Tutorial for details on events.
Update passes time in your widget so that it may be animated.
Display draws the widget at the specified position on the window. The widget's stored position will be added to the coordinates passed.