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:
GTK2_GUI_DIALOG *xdlg;
}
GWEN_DIALOG_GETINTPROPERTY_FN GWEN_Dialog_SetGetIntPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_GETINTPROPERTY_FN fn)
GWEN_DIALOG_SETINTPROPERTY_FN GWEN_Dialog_SetSetIntPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_SETINTPROPERTY_FN fn)
GWEN_DIALOG_GETCHARPROPERTY_FN GWEN_Dialog_SetGetCharPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_GETCHARPROPERTY_FN fn)
GWEN_DIALOG_SETCHARPROPERTY_FN GWEN_Dialog_SetSetCharPropertyFn(GWEN_DIALOG *dlg, GWEN_DIALOG_SETCHARPROPERTY_FN fn)
struct GWEN_DIALOG GWEN_DIALOG
GWENHYWFAR_CB const char * Gtk2Gui_Dialog_GetCharProperty(GWEN_UNUSED GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
GWENHYWFAR_CB int Gtk2Gui_Dialog_SetIntProperty(GWEN_UNUSED GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
GWENHYWFAR_CB int Gtk2Gui_Dialog_GetIntProperty(GWEN_UNUSED GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
void Gtk2Gui_Dialog_Extend(GWEN_DIALOG *dlg)
GWENHYWFAR_CB int Gtk2Gui_Dialog_SetCharProperty(GWEN_UNUSED GWEN_DIALOG *dlg, GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
void GWENHYWFAR_CB Gtk2Gui_Dialog_FreeData(GWEN_UNUSED void *bp, void *p)
#define GWEN_INHERIT_SETDATA(bt, t, element, data, fn)
#define GWEN_INHERIT(bt, t)
#define GWEN_NEW_OBJECT(typ, varname)
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
GtkWidget *g;
const char *s;
uint32_t flags;
wParent=GWEN_Widget_Tree_GetParent(w);
g=gtk_label_new(s);
if (wParent)
return 0;
}
int Gtk2Gui_WLabel_Setup(GWEN_WIDGET *w)
static GWENHYWFAR_CB int Gtk2Gui_WLabel_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *value, GWEN_UNUSED int doSignal)
static GWENHYWFAR_CB int Gtk2Gui_WLabel_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int value, GWEN_UNUSED int doSignal)
static GWENHYWFAR_CB int Gtk2Gui_WLabel_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, int defaultValue)
static GWENHYWFAR_CB const char * Gtk2Gui_WLabel_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, GWEN_UNUSED int index, const char *defaultValue)
#define GTK2_DIALOG_WIDGET_REAL
#define GTK2_DIALOG_WIDGET_CONTENT