XPCWidget::XPCWidget( int inLeft, int inTop, int inRight, int inBottom, bool inVisible, const char * inDescriptor, bool inIsRoot, XPWidgetID inParent, XPWidgetClass inClass) : mWidget(NULL), mOwnsChildren(false), mOwnsWidget(true) { mWidget = XPCreateWidget( inLeft, inTop, inRight, inBottom, inVisible ? 1 : 0, inDescriptor, inIsRoot ? 1 : 0, inIsRoot ? NULL : inParent, inClass); XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast<long>(this)); XPAddWidgetCallback(mWidget, WidgetCallback); }
/* Create the Widget dialog */ void CreateAboutWidget(int x, int y, int w, int h) { int Index; int x2 = x + w; int y2 = y - h; /* Create the Main Widget window */ AboutWidget = XPCreateWidget(x, y, x2, y2, 1, /* Visible */ "XPUDPng " VERSION, /* Description */ 1, /* root */ NULL, /* No container */ xpWidgetClass_MainWindow); /* Add Close Box to the Main Widget. Other options are available */ XPSetWidgetProperty(AboutWidget, xpProperty_MainWindowHasCloseBoxes, 1); /* Print each line of the About Text */ for (Index=0;Index < 50; Index++) { if(strcmp(AboutText[Index],"end") == 0) break; /* Create a text widget */ AboutTextWidget[Index] = XPCreateWidget(x+10, y-(30+(Index*20)), x2-10, y-(42+(Index*20)), 1, /* Visible */ AboutText[Index], /* Description */ 0, /* root */ AboutWidget, xpWidgetClass_Caption); } /* Register our widget handler */ XPAddWidgetCallback(AboutWidget, AboutHandler); }
XPCWidget::XPCWidget( XPWidgetID inWidget, bool inOwnsWidget) : mWidget(inWidget), mOwnsChildren(false), mOwnsWidget(inOwnsWidget) { XPSetWidgetProperty(mWidget, xpProperty_Object, reinterpret_cast<long>(this)); XPAddWidgetCallback(mWidget, WidgetCallback); }
void create_dialog() { int x1, y1, x2, y2; if (ui_dialog_x == UI_POSITION_DEFAULT || ui_dialog_y == UI_POSITION_DEFAULT) { x1 = 0; y1 = ui_dialog_h - 1; x2 = ui_dialog_w - 1; y2 = 0; } else { // (x0, y0) top left dialog x1 = ui_dialog_x; y1 = ui_dialog_y + ui_dialog_h - 1; // (x2, y2) bottom right dialog x2 = x1 + ui_dialog_w - 1; y2 = ui_dialog_y; } ui_dialog_wid = XPCreateWidget(x1, y1, x2, y2, // dialog coordinates 0, // initially hide "EZPushback", // window title 1, // root NULL, // no container xpWidgetClass_MainWindow); if (ui_dialog_wid == NULL) { debug("could not create UI dialog"); return; } XPSetWidgetProperty(ui_dialog_wid, xpProperty_MainWindowType, xpMainWindowStyle_Translucent); XPSetWidgetProperty(ui_dialog_wid, xpProperty_MainWindowHasCloseBoxes, 0); // dialog text subwindow ui_dlg_text_wid = XPCreateWidget(x1, y1, x2, y2, 1, // show "", // text (set by set_dialog_text) 0, // not root ui_dialog_wid, // parent is dialog window xpWidgetClass_Caption); if (ui_dlg_text_wid == NULL) { debug("could not create UI text widget"); return; } XPSetWidgetProperty(ui_dlg_text_wid, xpProperty_CaptionLit, 1); int button_width = 100; int bx1 = x1 + ((ui_dialog_w - button_width) / 2); int bx2 = bx1 + button_width; ui_button_wid = XPCreateWidget(bx1, y2+20, bx2, y2+10, 0, // initially hide "", // button text (set by set_button_text) 0, // not root ui_dialog_wid, // parent is dialog window xpWidgetClass_Button); if (ui_button_wid == NULL) { debug("could not create UI button widget"); return; } XPSetWidgetProperty(ui_button_wid, xpProperty_ButtonType, xpPushButton); XPAddWidgetCallback(ui_dialog_wid, ui_dialog_handler); }