gwenhywfar  5.11.1beta

Implementation hints.

Implementation hints.

The dialog framework is part of the GWEN_GUI framework (Graphical User Interface). To make your implementation available to the application you will have to set the following callbacks in GWEN_GUI:

The function GWEN_Gui_ExecDialog can be implemented by just calling the other functions (first GWEN_Gui_OpenDialog followed by GWEN_Gui_RunDialog and GWEN_Gui_CloseDialog).

Your implementation of GWEN_Gui_OpenDialog must set the follwing callbacks in the object pointed to by the first argument (GWEN_DIALOG):

The GKT2 implementation does it like this:

GWEN_INHERIT(GWEN_DIALOG, GTK2_GUI_DIALOG)
void Gtk2Gui_Dialog_Extend(GWEN_DIALOG *dlg) {
GTK2_GUI_DIALOG *xdlg;
GWEN_NEW_OBJECT(GTK2_GUI_DIALOG, xdlg);
GWEN_INHERIT_SETDATA(GWEN_DIALOG, GTK2_GUI_DIALOG, dlg, xdlg, Gtk2Gui_Dialog_FreeData);
GWEN_Dialog_SetSetIntPropertyFn(dlg, Gtk2Gui_Dialog_SetIntProperty);
GWEN_Dialog_SetGetIntPropertyFn(dlg, Gtk2Gui_Dialog_GetIntProperty);
GWEN_Dialog_SetSetCharPropertyFn(dlg, Gtk2Gui_Dialog_SetCharProperty);
GWEN_Dialog_SetGetCharPropertyFn(dlg, Gtk2Gui_Dialog_GetCharProperty);
}
struct GWEN_DIALOG GWEN_DIALOG
Definition: dialog.h:54
GWENHYWFAR_API GWEN_DIALOG_GETCHARPROPERTY_FN GWEN_Dialog_SetGetCharPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_GETCHARPROPERTY_FN fn)
GWENHYWFAR_API GWEN_DIALOG_SETCHARPROPERTY_FN GWEN_Dialog_SetSetCharPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_SETCHARPROPERTY_FN fn)
GWENHYWFAR_API GWEN_DIALOG_GETINTPROPERTY_FN GWEN_Dialog_SetGetIntPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_GETINTPROPERTY_FN fn)
GWENHYWFAR_API GWEN_DIALOG_SETINTPROPERTY_FN GWEN_Dialog_SetSetIntPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_SETINTPROPERTY_FN fn)
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
Definition: inherit.h:300
#define GWEN_INHERIT(bt, t)
Definition: inherit.h:264
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55

It must also create the actual widgets used by your GUI toolkit (e.g. QLabel for label widgets with QT). To do that you should call GWEN_Dialog_GetWidgets to get the tree of widget descriptions. The most important information about a widget is its type (GWEN_Widget_GetType). The implementation of GWEN_Gui_OpenDialog can use that information to decide what GUI widget should be created to represent that widget description.

For example the QT implementation creates a QLabel object for the widget type GWEN_Widget_TypeLabel.

You can call the function GWEN_Widget_SetImplData to store a pointer to the GUI widget created (e.g. the QT implementation stores a pointer to the created QLabel object for widgets of type GWEN_Widget_TypeLabel). To retrieve that pointer later call GWEN_Widget_GetImplData. Currently up to 4 pointers can be stored per GWEN_WIDGET object (in the case that there are multiple GUI objects required to represent a given GWEN_WIDGET).

Another important hint comes from the widget flags (get them with GWEN_Widget_GetFlags). Those flag tell the implementation about some layout options and other things.

For widgets using media like icons or images the implementation can call GWEN_Dialog_GetMediaPaths to get a list of paths where those icons can be found. This information is provided by the dialog itself. You can use functions like GWEN_Directory_FindFileInPaths to actually find the icon or image file using the media paths.

This example shows how the GTK2 implementation creates a GUI representation of type GWEN_Widget_TypeLabel:

#define GTK2_DIALOG_WIDGET_REAL 0
#define GTK2_DIALOG_WIDGET_CONTENT 1
int Gtk2Gui_WLabel_Setup(GWEN_WIDGET *w) {
GtkWidget *g;
const char *s;
uint32_t flags;
GWEN_WIDGET *wParent;
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_label_new(s);
GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_REAL, (void*) g);
GWEN_Widget_SetImplData(w, GTK2_DIALOG_WIDGET_CONTENT, (void*) g);
GWEN_Widget_SetSetIntPropertyFn(w, Gtk2Gui_WLabel_SetIntProperty);
GWEN_Widget_SetGetIntPropertyFn(w, Gtk2Gui_WLabel_GetIntProperty);
GWEN_Widget_SetSetCharPropertyFn(w, Gtk2Gui_WLabel_SetCharProperty);
GWEN_Widget_SetGetCharPropertyFn(w, Gtk2Gui_WLabel_GetCharProperty);
if (wParent)
return 0;
}
GWENHYWFAR_API GWEN_WIDGET_SETCHARPROPERTY_FN GWEN_Widget_SetSetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETCHARPROPERTY_FN fn)
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34
GWENHYWFAR_API uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
GWENHYWFAR_API void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
GWENHYWFAR_API int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
GWENHYWFAR_API const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
GWENHYWFAR_API GWEN_WIDGET_GETCHARPROPERTY_FN GWEN_Widget_SetGetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETCHARPROPERTY_FN fn)
GWENHYWFAR_API GWEN_WIDGET_SETINTPROPERTY_FN GWEN_Widget_SetSetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETINTPROPERTY_FN fn)
GWENHYWFAR_API GWEN_WIDGET_GETINTPROPERTY_FN GWEN_Widget_SetGetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETINTPROPERTY_FN fn)