int main(int argc, char **argv) { Ihandle *canvas, *finale, *dg; IupOpen(&argc, &argv); IupGLCanvasOpen(); canvas = IupGLCanvas(NULL); IupSetCallback(canvas, "ACTION", (Icallback) redraw); IupSetAttribute(canvas, IUP_BUFFER, IUP_DOUBLE); IupSetAttribute(canvas, "RASTERSIZE", "123x200"); finale = IupHbox(IupFill(), canvas, IupFill(), NULL); dg = IupDialog(finale); IupSetAttribute(dg, "TITLE", "IupGLCanvas"); IupShow(dg); IupMainLoop(); IupClose(); return EXIT_SUCCESS; }
int IupGetText(const char* title, char* text) { Ihandle *ok, *cancel, *multi_text, *button_box, *dlg_box, *dialog; int bt; multi_text = IupMultiLine("do_nothing"); IupSetAttribute(multi_text,IUP_EXPAND, IUP_YES); IupSetAttribute(multi_text, IUP_SIZE, "200x80"); IupSetAttribute(multi_text,IUP_VALUE, text); IupSetAttribute(multi_text,IUP_FONT, IUP_COURIER_NORMAL_12); ok = IupButton(strok, NULL); IupSetAttribute (ok ,IUP_SIZE ,"50x"); IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK); IupSetHandle( "IupGetTextOkButton", ok ); cancel = IupButton(strcancel, NULL); IupSetAttribute (cancel,IUP_SIZE ,"50x"); IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL); IupSetHandle( "IupGetTextCancelButton", cancel ); button_box = IupHbox( IupSetAttributes(IupFill(), "EXPAND=HORIZONTAL"), ok, IupSetAttributes(IupFill(), "SIZE=1x"), cancel, NULL); IupSetAttribute(button_box,IUP_MARGIN,"0x0"); dlg_box = IupVbox( multi_text, IupSetAttributes(IupFill(), "SIZE=1x"), button_box, NULL); IupSetAttribute(dlg_box,IUP_MARGIN,"10x10"); IupSetAttribute(dlg_box,IUP_GAP,"5"); dialog = IupDialog (dlg_box); IupSetAttribute (dialog,IUP_TITLE,title); IupSetAttribute (dialog,IUP_MINBOX,IUP_NO); IupSetAttribute (dialog,IUP_MAXBOX,IUP_NO); IupSetAttribute (dialog,IUP_DEFAULTENTER,"IupGetTextOkButton"); IupSetAttribute (dialog,IUP_DEFAULTESC,"IupGetTextCancelButton"); IupSetAttribute (dialog,IUP_PARENTDIALOG, IupGetGlobal(IUP_PARENTDIALOG)); IupSetAttribute (dialog, IUP_ICON, IupGetGlobal(IUP_ICON)); IupPopup(dialog, IUP_CENTER, IUP_CENTER); bt = IupGetInt(dialog, IUP_STATUS); if (bt==1) strcpy(text, IupGetAttribute(multi_text, IUP_VALUE)); else bt = 0; /* return 0 instead of -1 */ IupDestroy(dialog); return bt; }
int main(int argc, char **argv) { Ihandle *win,*tabs,*buttons; IupOpen(&argc, &argv); tabs = IupTabs( IupQuakeBindingLayout(), IupQuakeMouseLayout(), IupFill(), IupFill(), IupFill(), NULL ); IupStoreAttribute(tabs, "TABTITLE0", "Keyboard"); IupStoreAttribute(tabs, "TABTITLE1", "Mouse"); IupStoreAttribute(tabs, "TABTITLE2", "Audio"); IupStoreAttribute(tabs, "TABTITLE3", "Video"); IupStoreAttribute(tabs, "TABTITLE4", "Multiplayer"); IupStoreAttribute(tabs, "MARGIN", "2x2"); buttons = IupHbox( IupSetCallbacks(IupButton("&Quit", "ACTION"), "ACTION", (Icallback)IupExitLoop, NULL), IupFill(), IupButton("&Save", NULL), IupFill(), IupButton("&Launch game", NULL), NULL ); win = IupDialog( IupSetAttributes( IupVbox( IupSetAttributes( IupLabel("Action Quake 2 Configuration"), "EXPAND=YES, ALIGNMENT=ACENTER:ACENTER, FONT=\"sans-serif, Bold 18\"" ), tabs, //buttons, NULL ), "GAP=5, MARGIN=3x3" ) ); IupStoreAttribute(win, "TITLE", "Action Quake 2 Configuration"); IupStoreAttribute(win, "RESIZE", "NO"); IupShow(win); /* bug? */ IupStoreAttribute(win, "SIZE", NULL); IupRefresh(win); IupMainLoop(); }
int main(int argc, char **argv) { Ihandle *male, *female, *exclusive, *frame, *dialog; IupOpen(&argc, &argv); male = IupToggle ("Male", ""); female = IupToggle ("Female", ""); exclusive = IupRadio ( IupVbox ( male, female, NULL ) ); IupSetHandle("male", male); IupSetHandle("female", female); IupSetAttribute(exclusive, IUP_VALUE, "female"); IupSetAttribute(exclusive, IUP_TIP, "Two state button - Exclusive - RADIO"); frame = IupFrame ( exclusive ); IupSetAttribute (frame, IUP_TITLE, "Gender"); dialog = IupDialog ( IupHbox ( IupFill(), frame, IupFill(), NULL ) ); IupSetAttributes(dialog, "SIZE=140, TITLE=IupRadio, RESIZE=NO, MINBOX=NO, MAXBOX=NO"); IupShow(dialog); IupMainLoop(); IupDestroy(dialog); IupClose(); return 0; }
static void uiSetupModule(Module *module, Ihandle *parent) { Ihandle *groupBox, *toggle, *controls, *icon; groupBox = IupHbox( icon = IupLabel(NULL), toggle = IupToggle(module->displayName, NULL), IupFill(), controls = module->setupUIFunc(), NULL ); IupSetAttribute(groupBox, "EXPAND", "HORIZONTAL"); IupSetAttribute(groupBox, "ALIGNMENT", "ACENTER"); IupSetAttribute(controls, "ALIGNMENT", "ACENTER"); IupAppend(parent, groupBox); // set controls as attribute to toggle and enable toggle callback IupSetCallback(toggle, "ACTION", (Icallback)uiToggleControls); IupSetAttribute(toggle, CONTROLS_HANDLE, (char*)controls); IupSetAttribute(toggle, SYNCED_VALUE, (char*)module->enabledFlag); IupSetAttribute(controls, "ACTIVE", "NO"); // startup as inactive IupSetAttribute(controls, "NCGAP", "4"); // startup as inactive // set default icon IupSetAttribute(icon, "IMAGE", "none_icon"); IupSetAttribute(icon, "PADDING", "4x"); module->iconHandle = icon; // parameterize toggle if (parameterized) { setFromParameter(toggle, "VALUE", module->shortName); } }
static int Fill(lua_State *L) { Ihandle *ih = IupFill(); iuplua_plugstate(L, ih); iuplua_pushihandle_raw(L, ih); return 1; }
int item_goto_action_cb(Ihandle* item_goto) { Ihandle* multitext = IupGetDialogChild(item_goto, "MULTITEXT"); Ihandle *dlg, *box, *bt_ok, *bt_cancel, *txt, *lbl; int line_count = IupGetInt(multitext, "LINECOUNT"); lbl = IupLabel(NULL); IupSetfAttribute(lbl, "TITLE", "Line Number [1-%d]:", line_count); txt = IupText(NULL); IupSetAttribute(txt, "MASK", IUP_MASK_UINT); /* unsigned integer numbers only */ IupSetAttribute(txt, "NAME", "LINE_TEXT"); IupSetAttribute(txt, "VISIBLECOLUMNS", "20"); bt_ok = IupButton("OK", NULL); IupSetInt(bt_ok, "TEXT_LINECOUNT", line_count); IupSetAttribute(bt_ok, "PADDING", "10x2"); IupSetCallback(bt_ok, "ACTION", (Icallback)goto_ok_action_cb); bt_cancel = IupButton("Cancel", NULL); IupSetCallback(bt_cancel, "ACTION", (Icallback)goto_cancel_action_cb); IupSetAttribute(bt_cancel, "PADDING", "10x2"); box = IupVbox( lbl, txt, IupSetAttributes(IupHbox( IupFill(), bt_ok, bt_cancel, NULL), "NORMALIZESIZE=HORIZONTAL"), NULL); IupSetAttribute(box, "MARGIN", "10x10"); IupSetAttribute(box, "GAP", "5"); dlg = IupDialog(box); IupSetAttribute(dlg, "TITLE", "Go To Line"); IupSetAttribute(dlg, "DIALOGFRAME", "Yes"); IupSetAttributeHandle(dlg, "DEFAULTENTER", bt_ok); IupSetAttributeHandle(dlg, "DEFAULTESC", bt_cancel); IupSetAttributeHandle(dlg, "PARENTDIALOG", IupGetDialog(item_goto)); IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(dlg, "STATUS") == 1) { int line = IupGetInt(txt, "VALUE"); int pos; IupTextConvertLinColToPos(multitext, line, 0, &pos); IupSetInt(multitext, "CARETPOS", pos); IupSetInt(multitext, "SCROLLTOPOS", pos); } IupDestroy(dlg); return IUP_DEFAULT; }
int item_find_action_cb(Ihandle* item_find) { Ihandle* dlg = (Ihandle*)IupGetAttribute(item_find, "FIND_DIALOG"); if (!dlg) { Ihandle* multitext = IupGetDialogChild(item_find, "MULTITEXT"); Ihandle *box, *bt_next, *bt_close, *txt, *find_case; txt = IupText(NULL); IupSetAttribute(txt, "NAME", "FIND_TEXT"); IupSetAttribute(txt, "VISIBLECOLUMNS", "20"); find_case = IupToggle("Case Sensitive", NULL); IupSetAttribute(find_case, "NAME", "FIND_CASE"); bt_next = IupButton("Find Next", NULL); IupSetAttribute(bt_next, "PADDING", "10x2"); IupSetCallback(bt_next, "ACTION", (Icallback)find_next_action_cb); bt_close = IupButton("Close", NULL); IupSetCallback(bt_close, "ACTION", (Icallback)find_close_action_cb); IupSetAttribute(bt_close, "PADDING", "10x2"); box = IupVbox( IupLabel("Find What:"), txt, find_case, IupSetAttributes(IupHbox( IupFill(), bt_next, bt_close, NULL), "NORMALIZESIZE=HORIZONTAL"), NULL); IupSetAttribute(box, "MARGIN", "10x10"); IupSetAttribute(box, "GAP", "5"); dlg = IupDialog(box); IupSetAttribute(dlg, "TITLE", "Find"); IupSetAttribute(dlg, "DIALOGFRAME", "Yes"); IupSetAttributeHandle(dlg, "DEFAULTENTER", bt_next); IupSetAttributeHandle(dlg, "DEFAULTESC", bt_close); IupSetAttributeHandle(dlg, "PARENTDIALOG", IupGetDialog(item_find)); /* Save the multiline to acess it from the callbacks */ IupSetAttribute(dlg, "MULTITEXT", (char*)multitext); /* Save the dialog to reuse it */ IupSetAttribute(item_find, "FIND_DIALOG", (char*)dlg); } /* centerparent first time, next time reuse the last position */ IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT); return IUP_DEFAULT; }
Ihandle * createMainWindow(void) { Ihandle *bottomHbox, *mainVbox; Ihandle *lblTitle, *glCanvas; Ihandle *btnRandomLine, *btnClearLines, *btnClose; Ihandle *dialog; lblTitle = IupLabel(labTitle); IupSetAttribute(lblTitle, "EXPAND", "HORIZONTAL"); IupSetAttribute(lblTitle, "ALIGNMENT", "ALEFT:ACENTER"); IupSetAttribute(lblTitle, "FONTSIZE", "10"); glCanvas = IupGLCanvas(0); IupSetAttribute(glCanvas, "EXPAND", "YES"); IupSetAttribute(glCanvas, "BORDER", "NO"); IupSetAttribute(glCanvas, "CANFOCUS", "NO"); IupSetCallback(glCanvas, "ACTION", (Icallback) repaint_cb); btnRandomLine = IupButton("Generate Random Lines", 0); IupSetAttribute(btnRandomLine, "RASTERSIZE", "150x33"); IupSetCallback(btnRandomLine, "ACTION", (Icallback) btnRandLine_cb); btnClearLines = IupButton("Clear All Lines", 0); IupSetAttribute(btnClearLines, "RASTERSIZE", "100x33"); IupSetCallback(btnClearLines, "ACTION", (Icallback) btnClearLines_cb); btnClose = IupButton("Close", 0); IupSetAttribute(btnClose, "RASTERSIZE", "80x33"); IupSetCallback(btnClose, "ACTION", (Icallback) exit_cb); bottomHbox = IupHbox(btnRandomLine, btnClearLines, IupFill(), btnClose, 0); IupSetAttribute(bottomHbox, "EXPAND", "HORIZONTAL"); IupSetAttribute(bottomHbox, "NGAP", "5"); IupSetAttribute(bottomHbox, "NMARGIN", "0x5"); mainVbox = IupVbox(lblTitle, glCanvas, bottomHbox, 0); IupSetAttribute(mainVbox, "NMARGIN", "10x10"); IupSetAttribute(mainVbox, "NGAP", "10"); IupSetHandle(BTN_CLOSE, btnClose); IupSetHandle(GL_CANVAS, glCanvas); dialog = IupDialog(mainVbox); IupSetAttribute(dialog, "TITLE", "GL Labwork"); IupSetAttribute(dialog, "RASTERSIZE", "425x550"); IupSetAttribute(dialog, "SHRINK", "YES"); IupSetAttribute(dialog, "DEFAULTESC", BTN_CLOSE); IupSetHandle(MAIN_WINDOW, dialog); return dialog; }
Ihandle *IupQuakeMouseLayout() { Ihandle *tab; tab = IupSetAttributes( IupHbox( IupVbox( IupQuakeSetToggle("Reverse mouse", "m_pitch", "-0.022", "0.022", 0), IupQuakeSetToggle("Use automatic sensitivity scaling", "m_autosens", "1", "0", 1), IupQuakeScale("Mouse sensitivity", 1.00, 20.00, 0.1, "sensitivity", 3.00), NULL ), IupFill(), NULL ), "HOMOGENEOUS=YES" ); IupSetAttributes(tab, "GAP=5"); return tab; }
void LabelTest(void) { Ihandle *dlg, *label, *image1, *image2, *image3, *box1, *box2, *fill; box1 = IupVbox(NULL); IupSetAttribute(box1, "MARGIN", "5x5"); IupSetAttribute(box1, "GAP", "5"); IupSetAttribute(box1, "BGCOLOR", "75 150 170"); /* label must be transparent for BGCOLOR */ IupSetAttribute(box1, "PADDING", "5x5"); label = IupLabel(NULL); if (IupGetInt(NULL, "UTF8MODE")) IupSetAttribute(label, "TITLE", "Text Labels (çãõáóé)"); else IupSetAttribute(label, "TITLE", "Text Labels (ηγυασι)"); //IupSetAttribute(label, "BGCOLOR", IupGetGlobal("DLGBGCOLOR")); IupSetAttribute(label, "PADDING", "0x0"); IupSetAttribute(label, "TIP", "Text Label"); IupAppend(box1, label); label = IupLabel(NULL); IupSetAttribute(label, "SEPARATOR", "HORIZONTAL"); IupAppend(box1, label); label = IupLabel(NULL); IupSetAttribute(label, "TITLE", "Text &Label\nSecond Line"); IupSetAttribute(label, "FGCOLOR", "0 0 255"); IupSetAttribute(label, "RASTERSIZE", "150x70"); // IupSetAttribute(label, "RASTERSIZE", "30x70"); // IupSetAttribute(label, "WORDWRAP", "YES"); // IupSetAttribute(label, "ELLIPSIS", "YES"); IupSetAttribute(label, "ALIGNMENT", "ALEFT:ATOP"); IupAppend(box1, label); label = IupLabel(NULL); IupSetAttribute(label, "TITLE", "Text\nSecond Line"); IupSetAttribute(label, "RASTERSIZE", "150x70"); IupSetAttribute(label, "ALIGNMENT", "ACENTER:ACENTER"); IupSetAttribute(label, "FONT", "Helvetica, Underline 14"); // IupSetAttribute(label, "FONTSIZE", "14"); // IupSetAttribute(label, "FONTSTYLE", "Italic"); // IupSetAttribute(label, "FONTSTYLE", "Bold"); IupAppend(box1, label); label = IupLabel(NULL); IupSetAttribute(label, "TITLE", "Text\n<b>Second Line</b>"); IupSetAttribute(label, "RASTERSIZE", "150x70"); IupSetAttribute(label, "ALIGNMENT", "ARIGHT:ABOTTOM"); IupSetAttribute(label, "MARKUP", "YES"); IupAppend(box1, label); box2 = IupVbox(NULL); IupSetAttribute(box2, "MARGIN", "5x5"); IupSetAttribute(box2, "GAP", "5"); IupSetAttribute(box2, "BGCOLOR", "75 150 170"); IupSetAttribute(box2, "PADDING", "5x5"); image1 = IupImage(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_8); IupSetAttribute(image1, "0", "BGCOLOR"); IupSetAttribute(image1, "1", "255 0 0"); IupSetAttribute(image1, "2", "0 255 0"); IupSetAttribute(image1, "3", "0 0 255"); IupSetAttribute(image1, "4", "255 255 255"); IupSetAttribute(image1, "5", "0 0 0"); label = IupLabel(NULL); IupSetAttributeHandle(label, "IMAGE", image1); //IupSetAttribute(label, "IMAGE", "TECGRAF_BITMAP"); //IupSetAttribute(label, "IMAGE", "../test/tecgraf.bmp"); //IupSetAttribute(label, "IMAGE", "../test/file_large.xbm"); //IupSetAttribute(label, "IMAGE", "gtk-open"); //IupSetAttribute(label, "BGCOLOR", IupGetGlobal("DLGBGCOLOR")); IupSetAttribute(label, "PADDING", "0x0"); IupSetAttribute(label, "TIP", "Image Label"); IupAppend(box2, label); label = IupLabel(NULL); IupSetAttribute(label, "SEPARATOR", "HORIZONTAL"); IupAppend(box2, label); fill = IupFill(); IupSetAttribute(fill, "SIZE", "20"); IupAppend(box2, fill); label = IupLabel(NULL); IupSetAttributeHandle(label, "IMAGE", image1); IupSetAttribute(label, "RASTERSIZE", "150x50"); IupAppend(box2, label); image2 = IupImageRGB(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_24); label = IupLabel(NULL); IupSetAttributeHandle(label, "IMAGE", image2); IupSetAttribute(label, "RASTERSIZE", "150x50"); IupSetAttribute(label, "ALIGNMENT", "ACENTER"); IupAppend(box2, label); image3 = IupImageRGBA(TEST_IMAGE_SIZE, TEST_IMAGE_SIZE, image_data_32); label = IupLabel(NULL); IupSetAttributeHandle(label, "IMAGE", image3); IupSetAttribute(label, "RASTERSIZE", "150x50"); IupSetAttribute(label, "ALIGNMENT", "ARIGHT"); IupAppend(box2, label); label = IupLabel(NULL); IupSetAttribute(label, "SEPARATOR", "VERTICAL"); dlg = IupDialog(IupHbox(box1, label, box2, NULL)); IupSetAttribute(dlg, "TITLE", "IupLabel Test"); // IupSetAttribute(dlg, "BACKGROUND", "0 0 128"); // IupSetAttributeHandle(dlg, "BACKGROUND", image2); IupSetCallback(dlg, "ENTERWINDOW_CB", enter_cb); IupShow(dlg); // IupShowXY(dlg,IUP_LEFT,IUP_BOTTOM); }
int IupAlarm(const char *title, const char *msg, const char *b1, const char *b2, const char *b3) { Ihandle *dlg, *dlg_box, *button_box, *button, *default_esc, *default_enter; int bt, len; char* padding; msg = msg? msg: ""; if (b1 == NULL) return 0; len = strlen(b1); if (b2) { int len2 = strlen(b2); if (len2 > len) len = len2; } if (b3) { int len3 = strlen(b3); if (len3 > len) len = len3; } if (len > 7) padding = "12x2"; else padding = "18x5"; button_box = IupHbox(NULL); IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL"); IupSetAttribute(button_box,"MARGIN","0x0"); IupAppend(button_box, IupFill()); /* to center the buttons */ button = IupButton(b1, NULL); iupAttribSetStrf(button, "_IUP_BUTTON_NUMBER", "1"); IupSetAttribute(button, "PADDING", padding); IupAppend(button_box, button); IupSetCallback (button, "ACTION", (Icallback)iAlarmButtonAction_CB); default_enter = button; default_esc = button; if (b2 != NULL) { button = IupButton(b2, NULL); iupAttribSetStr(button, "_IUP_BUTTON_NUMBER", "2"); IupSetAttribute(button, "PADDING", padding); IupAppend(button_box, button); IupSetCallback (button, "ACTION", (Icallback)iAlarmButtonAction_CB); default_esc = button; } if (b3 != NULL) { button = IupButton(b3, NULL); iupAttribSetStr(button, "_IUP_BUTTON_NUMBER", "3"); IupSetAttribute(button, "PADDING", padding); IupAppend(button_box, button); IupSetCallback (button, "ACTION", (Icallback)iAlarmButtonAction_CB); default_esc = button; } IupAppend(button_box, IupFill()); /* to center the buttons */ dlg_box = IupVbox( IupLabel(msg), IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), button_box, NULL); IupSetAttribute(dlg_box,"MARGIN","10x10"); IupSetAttribute(dlg_box,"GAP","10"); dlg = IupDialog(dlg_box); IupSetAttribute(dlg,"TITLE", title); IupSetAttribute(dlg,"DIALOGFRAME","YES"); IupSetAttribute(dlg,"DIALOGHINT","YES"); IupSetAttributeHandle(dlg,"DEFAULTENTER", default_enter); IupSetAttributeHandle(dlg,"DEFAULTESC", default_esc); IupSetAttribute(dlg,"PARENTDIALOG", IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON")); IupPopup(dlg,IUP_CENTERPARENT,IUP_CENTERPARENT); bt = iupAttribGetInt(dlg, "_IUP_BUTTON_NUMBER"); IupDestroy(dlg); return bt; }
void HboxTest(void) { /* IUP identifiers */ Ihandle *fr1, *fr2, *fr3, *dlg; Ihandle *b11, *b12, *b13; Ihandle *b21, *b22, *b23; Ihandle *b31, *b32, *b33; Ihandle *h1, *h2, *h3; /* Creates frame with three top aligned buttons */ fr1 = IupFrame ( h1 = IupHbox ( // IupFill(), b11=IupButton("1", NULL), b12=IupButton("2", NULL), b13=IupButton("3", NULL), // IupFill(), NULL ) ); // IupSetAttribute(fr1, "TITLE", "ALIGNMENT=ATOP"); IupSetAttribute(fr1, "TITLE", "IupHbox"); IupSetAttribute(b11, "SIZE", "10x10"); IupSetAttribute(b12, "SIZE", "20x16"); IupSetAttribute(b13, "SIZE", "30x20"); IupSetAttributes(h1, "ALIGNMENT=ATOP"); /* Sets hbox's alignment, gap and size */ // IupSetAttribute(h1, "HOMOGENEOUS", "YES"); // IupSetAttribute(h1, "EXPANDCHILDREN", "YES"); // IupSetAttribute(b12, "VISIBLE", "NO"); // IupSetAttribute(b12, "FLOATING", "YES"); /* Creates frame with three buttons */ fr2 = IupFrame ( h2=IupHbox ( // IupFill(), b21=IupButton("1", NULL), b22=IupButton("2", NULL), b23=IupButton("3", NULL), // IupFill(), NULL ) ); IupSetAttribute(fr2, "TITLE", "ALIGNMENT=ACENTER, GAP=20"); IupSetAttribute(b21, "SIZE", "30x30"); IupSetAttribute(b22, "SIZE", "30x40"); IupSetAttribute(b23, "SIZE", "30x50"); IupSetAttributes(h2, "ALIGNMENT=ACENTER, GAP=20"); /* Sets hbox's alignment and gap */ /* Creates frame with three bottom aligned buttons */ fr3 = IupFrame ( h3=IupHbox ( IupFill(), b31=IupButton ("1", NULL), b32=IupButton ("2", NULL), b33=IupButton ("3", NULL), IupFill(), NULL ) ); IupSetAttribute(fr3, "TITLE", "ALIGNMENT=ABOTTOM, MARGIN=10x10"); IupSetAttribute(b31, "SIZE", "30x30"); //IupSetAttribute(b31, "EXPAND", "HORIZONTAL"); //IupSetAttribute(b31, "EXPAND", "YES"); IupSetAttribute(b32, "SIZE", "30x40"); IupSetAttribute(b33, "SIZE", "30x50"); IupSetAttributes(h3, "ALIGNMENT=ABOTTOM, MARGIN=10x10"); /* Sets hbox's alignment and size */ /* Creates dlg with the three frames */ dlg = IupDialog ( IupVbox ( fr1, fr2, fr3, NULL ) ); IupSetAttribute(dlg, "TITLE", "IupHbox Test"); /* Sets dlg's title */ IupSetAttribute(dlg, "NMARGIN", "10x10"); IupSetAttribute(dlg, "NGAP", "10"); // IupSetAttribute(fr1, "MARGIN", "0x0"); /* avoid attribute propagation */ // IupSetAttribute(fr2, "MARGIN", "0x0"); // IupSetAttribute(fr3, "MARGIN", "0x0"); // IupSetAttribute(fr1, "GAP", "0"); // IupSetAttribute(fr2, "GAP", "0"); // IupSetAttribute(fr3, "GAP", "0"); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); /* Shows dlg in the center of the screen */ }
/* main */ int main(int argc, char **argv) { Ihandle *vboxr[MAXPLOT+1]; /* tabs containing the plots */ Ihandle *dlg, *vboxl, *hbox, *lbl1, *lbl2, *lbl3, *bt1, *boxinfo, *boxdial1, *boxdial2, *f1, *f2; int ii; IupOpen(&argc, &argv); // init IUP IupControlsOpen(); // init the addicional controls library (we use IupTabs) IupPPlotOpen(); // init IupPPlot library // cdInitGdiPlus(); // create plots for (ii=0; ii<MAXPLOT; ii++) plot[ii] = IupPPlot(); // left panel: plot control // Y zooming dial1 = IupDial("VERTICAL"); lbl1 = IupLabel("+"); lbl2 = IupLabel("-"); boxinfo = IupVbox(lbl1, IupFill(), lbl2, NULL); boxdial1 = IupHbox(boxinfo, dial1, NULL); IupSetAttribute(boxdial1, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "SIZE", "20x52"); IupSetAttribute(boxinfo, "GAP", "2"); IupSetAttribute(boxinfo, "MARGIN", "4"); IupSetAttribute(boxinfo, "EXPAND", "YES"); IupSetAttribute(lbl1, "EXPAND", "NO"); IupSetAttribute(lbl2, "EXPAND", "NO"); IupSetAttribute(dial1, "ACTIVE", "NO"); IupSetAttribute(dial1, "SIZE", "20x52"); IupSetCallback(dial1, "BUTTON_PRESS_CB", (Icallback)dial1_btndown_cb); IupSetCallback(dial1, "MOUSEMOVE_CB", (Icallback)dial1_btnup_cb); IupSetCallback(dial1, "BUTTON_RELEASE_CB", (Icallback)dial1_btnup_cb); tgg1 = IupToggle("Y Autoscale", NULL); IupSetCallback(tgg1, "ACTION", (Icallback)tgg1_cb); IupSetAttribute(tgg1, "VALUE", "ON"); f1 = IupFrame( IupVbox(boxdial1, tgg1, NULL) ); IupSetAttribute(f1, "TITLE", "Y Zoom"); // X zooming dial2 = IupDial("HORIZONTAL"); lbl1 = IupLabel("-"); lbl2 = IupLabel("+"); boxinfo = IupHbox(lbl1, IupFill(), lbl2, NULL); boxdial2 = IupVbox(dial2, boxinfo, NULL); IupSetAttribute(boxdial2, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "SIZE", "64x16"); IupSetAttribute(boxinfo, "GAP", "2"); IupSetAttribute(boxinfo, "MARGIN", "4"); IupSetAttribute(boxinfo, "EXPAND", "HORIZONTAL"); IupSetAttribute(lbl1, "EXPAND", "NO"); IupSetAttribute(lbl2, "EXPAND", "NO"); IupSetAttribute(dial2, "ACTIVE", "NO"); IupSetAttribute(dial2, "SIZE", "64x16"); IupSetCallback(dial2, "BUTTON_PRESS_CB", (Icallback)dial2_btndown_cb); IupSetCallback(dial2, "MOUSEMOVE_CB", (Icallback)dial2_btnup_cb); IupSetCallback(dial2, "BUTTON_RELEASE_CB", (Icallback)dial2_btnup_cb); tgg2 = IupToggle("X Autoscale", NULL); IupSetCallback(tgg2, "ACTION", (Icallback)tgg2_cb); f2 = IupFrame( IupVbox(boxdial2, tgg2, NULL) ); IupSetAttribute(f2, "TITLE", "X Zoom"); lbl1 = IupLabel(""); IupSetAttribute(lbl1, "SEPARATOR", "HORIZONTAL"); tgg3 = IupToggle("Vertical Grid", NULL); IupSetCallback(tgg3, "ACTION", (Icallback)tgg3_cb); tgg4 = IupToggle("Horizontal Grid", NULL); IupSetCallback(tgg4, "ACTION", (Icallback)tgg4_cb); lbl2 = IupLabel(""); IupSetAttribute(lbl2, "SEPARATOR", "HORIZONTAL"); tgg5 = IupToggle("Legend", NULL); IupSetCallback(tgg5, "ACTION", (Icallback)tgg5_cb); lbl3 = IupLabel(""); IupSetAttribute(lbl3, "SEPARATOR", "HORIZONTAL"); bt1 = IupButton("Export PDF", NULL); IupSetCallback(bt1, "ACTION", (Icallback)bt1_cb); vboxl = IupVbox(f1, f2, lbl1, tgg3, tgg4, lbl2, tgg5, lbl3, bt1, NULL); IupSetAttribute(vboxl, "GAP", "4"); IupSetAttribute(vboxl, "EXPAND", "NO"); // right panel: tabs with plots for (ii=0; ii<MAXPLOT; ii++) { vboxr[ii] = IupVbox(plot[ii], NULL); // each plot a tab IupSetfAttribute(vboxr[ii], "TABTITLE", "Plot %d", ii); // name each tab } vboxr[MAXPLOT] = NULL; // mark end of vector tabs = IupTabsv(vboxr); // create tabs IupSetCallback(tabs, "TABCHANGE_CB", (Icallback)tabs_tabchange_cb); // dialog hbox = IupHbox(vboxl, tabs, NULL); IupSetAttribute(hbox, "MARGIN", "4x4"); IupSetAttribute(hbox, "GAP", "10"); dlg = IupDialog(hbox); IupSetAttributes(dlg, "SIZE=500x240" ); IupSetAttribute(dlg, "TITLE", "IupPPlot Example"); InitPlots(); // It must be able to be done independent of dialog Mapping tabs_tabchange_cb(tabs, vboxr[0]); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetAttribute(dlg, "SIZE", NULL); IupMainLoop(); IupClose(); return EXIT_SUCCESS; }
int IupListDialog (int type, const char *title, int size, const char** list_str, int op, int max_col, int max_lin, int* marks) { Ihandle *lst, *ok, *dlg, *cancel, *dlg_box, *button_box; int i, bt; char attrib_str[20]; char *m=NULL; if (size > 999) size = 999; lst = IupList(NULL); for (i=0;i<size;i++) { sprintf(attrib_str,"%d",i+1); IupSetAttribute(lst,attrib_str,list_str[i]); } sprintf(attrib_str,"%d",i+1); IupSetAttribute(lst,attrib_str,NULL); IupSetAttribute(lst,"EXPAND","YES"); ok = IupButton("OK", NULL); IupSetAttribute(ok,"PADDING" ,"20x5"); IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK); cancel = IupButton(iupStrMessageGet("IUP_CANCEL"), NULL); IupSetAttribute(cancel,"PADDING" ,"20x5"); IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL); button_box = IupHbox( IupFill(), ok, cancel, NULL); IupSetAttribute(button_box,"MARGIN","0x0"); IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL"); dlg_box = IupVbox( lst, button_box, NULL); IupSetAttribute(dlg_box,"MARGIN","10x10"); IupSetAttribute(dlg_box,"GAP","10"); dlg = IupDialog(dlg_box); if (type == 1) { if (op<1 || op>size) op=1; iupAttribSetStrf(dlg, "_IUP_LIST_NUMBER", "%d", op-1); IupSetfAttribute(lst,"VALUE","%d",op); IupSetCallback(lst, "ACTION", (Icallback)CB_lista); } else if ((type == 2) && (marks != NULL)) { m=(char *)marks; for (i=0;i<size;i++) m[i] = marks[i] ? '+' : '-'; m[i]='\0'; IupSetAttribute(lst,"MULTIPLE","YES"); IupSetAttribute(lst,"VALUE",m); } if (max_lin < 4) max_lin = 4; IupSetfAttribute(lst, "VISIBLELINES", "%d", max_lin); IupSetfAttribute(lst, "VISIBLECOLUMNS", "%d", max_col); IupSetAttribute(dlg,"TITLE", title); IupSetAttribute(dlg,"MINBOX","NO"); IupSetAttribute(dlg,"MAXBOX","NO"); IupSetAttributeHandle(dlg,"DEFAULTENTER", ok); IupSetAttributeHandle(dlg,"DEFAULTESC", cancel); IupSetAttribute(dlg,"PARENTDIALOG", IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON")); IupPopup(dlg,IUP_CENTER,IUP_CENTER); if ((type == 2) && (marks != NULL)) { m=IupGetAttribute(lst,"VALUE"); for (i=0;i<size;i++) marks[i] = (m[i] == '+'); } bt = IupGetInt(dlg, "STATUS"); if (type == 1) { if (bt == 1) bt = iupAttribGetInt(dlg, "_IUP_LIST_NUMBER"); else bt = -1; } else { if (bt != 1) bt = -1; } IupDestroy(dlg); return bt; }
int iupDataEntry(int maxlin, int* maxcol, int* maxscr, char* title, char** text, char** data) { int i, bt; Ihandle *ok, *cancel, *dlg, *vb, *hb, **txt, **lbl, *button_box, *dlg_box; txt = (Ihandle **)calloc(maxlin, sizeof(Ihandle*)); if (txt == NULL) return -2; lbl = (Ihandle **)calloc(maxlin+1, sizeof(Ihandle*)); vb = IupVbox(NULL); for (i=0; i<maxlin; i++) { txt[i] = IupText(NULL); IupSetAttribute(txt[i],"VALUE",data[i]); IupSetfAttribute(txt[i],"VISIBLECOLUMNS","%dx", maxscr[i]); IupSetfAttribute(txt[i],"NC", "%d", maxcol[i]); IupSetAttribute(txt[i],"EXPAND","HORIZONTAL"); hb = IupHbox(lbl[i] = IupLabel(text[i]), txt[i], NULL); IupSetAttribute(hb,"MARGIN","0x0"); IupSetAttribute(hb,"ALIGNMENT","ACENTER"); IupAppend(vb, hb); } lbl[i] = NULL; IupInsert(vb, NULL, IupNormalizerv(lbl)); ok = IupButton("OK", NULL); IupSetAttribute(ok, "PADDING", "20x0"); IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK); cancel = IupButton(iupStrMessageGet("IUP_CANCEL"), NULL); IupSetAttribute(cancel, "PADDING", "20x0"); IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL); button_box = IupHbox( IupFill(), ok, cancel, NULL); IupSetAttribute(button_box,"MARGIN","0x0"); IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL"); dlg_box = IupVbox( IupFrame(vb), button_box, NULL); IupSetAttribute(dlg_box,"MARGIN","10x10"); IupSetAttribute(dlg_box,"GAP","5"); dlg = IupDialog(dlg_box); IupSetAttribute(dlg,"TITLE",title); IupSetAttribute(dlg,"MINBOX","NO"); IupSetAttribute(dlg,"MAXBOX","NO"); IupSetAttributeHandle(dlg,"DEFAULTENTER", ok); IupSetAttributeHandle(dlg,"DEFAULTESC", cancel); IupSetAttribute(dlg,"PARENTDIALOG",IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON")); IupMap(dlg); IupSetfAttribute(dlg,"MAXSIZE", "65535x%d", IupGetInt2(dlg, "RASTERSIZE")); IupSetAttribute(dlg,"MINSIZE", IupGetAttribute(dlg, "RASTERSIZE")); IupPopup(dlg,IUP_CENTER,IUP_CENTER); for (i=0; i<maxlin; i++) { data[i] = (char *)iupStrDup(IupGetAttribute(txt[i], "VALUE")); } free(txt); bt = IupGetInt(dlg, "STATUS"); IupDestroy(dlg); return bt; }
int main(int argc, char **argv) { char string_size [ 45 ]; Ihandle *dlg; Ihandle *img_x, *img_cursor; Ihandle *lbl, *lbl_size; Ihandle *btn; Ihandle *tgl, *tgl_radio_1, *tgl_radio_2; Ihandle *frm_lbl, *frm_btn, *frm_tgl, *frm_tgl_radio; IupOpen(&argc, &argv); img_x = IupImage ( 11, 11, pixmap_x ); IupSetAttribute ( img_x, "1", "0 1 0"); IupSetAttribute ( img_x, "2", "255 0 0"); IupSetAttribute ( img_x, "3", "255 255 0"); IupSetHandle ( "img_x", img_x ); img_cursor = IupImage ( 32, 32, pixmap_cursor ); IupSetAttribute ( img_cursor, "1", "255 0 0" ); IupSetAttribute ( img_cursor, "2", "128 0 0" ); IupSetAttribute ( img_cursor, "HOTSPOT", "21:10" ); IupSetHandle ( "img_cursor", img_cursor ); btn = IupButton ( "Dummy", "" ); IupSetAttribute ( btn, "IMAGE", "img_x" ); lbl = IupLabel ( "Dummy" ); IupSetAttribute ( lbl, "IMAGE", "img_x" ); tgl = IupToggle ( "Dummy", NULL ); IupSetAttribute ( tgl, "IMAGE", "img_x" ); tgl_radio_1 = IupToggle ( "Dummy", NULL ); tgl_radio_2 = IupToggle ( "Dummy", NULL ); IupSetAttribute ( tgl_radio_1, "IMAGE", "img_x" ); IupSetAttribute ( tgl_radio_2, "IMAGE", "img_x" ); sprintf ( string_size, "\"X\" image width = %s; \"X\" image height = %s", IupGetAttribute ( img_x, "WIDTH" ), IupGetAttribute ( img_x, "HEIGHT" ) ); lbl_size = IupLabel ( string_size ); frm_btn = IupFrame ( btn ); frm_lbl = IupFrame ( lbl ); frm_tgl = IupFrame ( tgl ); frm_tgl_radio = IupFrame ( IupRadio ( IupVbox ( tgl_radio_1, tgl_radio_2, NULL ) ) ); IupSetAttributes ( frm_btn, "TITLE=button, SIZE=EIGHTHxEIGHTH" ); IupSetAttributes ( frm_lbl, "TITLE=label , SIZE=EIGHTHxEIGHTH" ); IupSetAttributes ( frm_tgl, "TITLE=toggle, SIZE=EIGHTHxEIGHTH" ); IupSetAttributes ( frm_tgl_radio, "TITLE=radio, SIZE=EIGHTHxEIGHTH" ); dlg = IupDialog ( IupVbox ( IupHbox ( frm_btn, frm_lbl, frm_tgl, frm_tgl_radio, NULL ), IupFill(), IupHbox ( IupFill(), lbl_size, IupFill(), NULL ), NULL ) ); IupSetAttributes ( dlg, "TITLE=\"IupImage Example\", SIZE=HALFxQUARTER, CURSOR=img_cursor" ); IupShowXY ( dlg, IUP_CENTER, IUP_CENTER ); IupMainLoop(); IupClose(); return EXIT_SUCCESS; }
static int motFontDlgCreateMethod(Ihandle* ih, void** params) { Ihandle *ok_bt, *cancel_bt, *help_bt; Ihandle *lin1, *lin2, *list1, *list2, *list3; ok_bt = IupButton(iupStrMessageGet("IUP_OK"), NULL); IupSetAttribute(ok_bt, "PADDING", "20x0"); IupSetCallback (ok_bt, "ACTION", (Icallback)motFontDlgButtonOK_CB); IupSetAttributeHandle(ih, "DEFAULTENTER", ok_bt); cancel_bt = IupButton(iupStrMessageGet("IUP_CANCEL"), NULL); IupSetAttribute(cancel_bt, "PADDING", "20x0"); IupSetCallback (cancel_bt, "ACTION", (Icallback)motFontDlgButtonCancel_CB); IupSetAttributeHandle(ih, "DEFAULTESC", cancel_bt); help_bt = IupButton(iupStrMessageGet("IUP_HELP"), NULL); /* Help Button */ IupSetAttribute(help_bt, "PADDING", "20x0"); IupSetAttribute(help_bt, "NAME", "HELPBUT"); IupSetCallback (help_bt, "ACTION", (Icallback)motFontDlgButtonHelp_CB); list1 = IupList(NULL); IupSetAttribute(list1, "EXPAND", "YES"); IupSetCallback(list1, "ACTION", (Icallback)motFontDlgList1_CB); IupSetAttribute(list1, "VISIBLELINES", "8"); IupSetAttribute(list1, "VISIBLECOLUMNS", "20"); IupSetAttribute(list1, "NAME", "LIST1"); IupSetAttribute(list1, "SORT", "YES"); list2 = IupList(NULL); IupSetAttribute(list2, "EXPAND", "VERTICAL"); IupSetCallback(list2, "ACTION", (Icallback)motFontDlgList2_CB); IupSetAttribute(list2, "VISIBLELINES", "8"); IupSetAttribute(list2, "VISIBLECOLUMNS", "11"); IupSetAttribute(list2, "NAME", "LIST2"); IupSetAttribute(list2, "1", "Normal"); IupSetAttribute(list2, "2", "Bold"); IupSetAttribute(list2, "3", "Italic"); IupSetAttribute(list2, "4", "Bold Italic"); IupSetAttribute(list2, "5", NULL); list3 = IupList(NULL); IupSetAttribute(list3, "EXPAND", "VERTICAL"); IupSetCallback(list3, "ACTION", (Icallback)motFontDlgList3_CB); IupSetAttribute(list3, "VISIBLELINES", "8"); IupSetAttribute(list3, "VISIBLECOLUMNS", "11"); IupSetAttribute(list3, "NAME", "LIST3"); lin1 = IupHbox( IupSetAttributes(IupVbox(IupLabel(iupStrMessageGet("IUP_FAMILY")), list1, NULL), "GAP=0"), IupSetAttributes(IupVbox(IupLabel(iupStrMessageGet("IUP_STYLE")), list2, NULL), "GAP=0"), IupSetAttributes(IupVbox(IupLabel(iupStrMessageGet("IUP_SIZE")), list3, NULL), "GAP=0"), NULL); IupSetAttribute(lin1, "GAP", "10"); IupSetAttribute(lin1, "MARGIN", "0x0"); lin2 = IupHbox(IupFill(), ok_bt, cancel_bt, help_bt, NULL); IupSetAttribute(lin2, "GAP", "5"); IupSetAttribute(lin2, "MARGIN", "0x0"); IupSetAttribute(lin2, "NORMALIZESIZE", "HORIZONTAL"); /* Do not use IupAppend because we set childtype=IUP_CHILDNONE */ iupChildTreeAppend(ih, IupSetAttributes(IupVbox(lin1, IupSetAttributes(IupVbox( IupLabel(iupStrMessageGet("IUP_SAMPLE")), IupFrame(IupSetAttributes(IupLabel(NULL), "NAME=SAMPLE, TITLE=\"abcdefghijk ABCDEFGHIJK\", EXPAND=HORIZONTAL, RASTERSIZE=x40")), NULL), "MARGIN=0x0, GAP=0"), IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), lin2, NULL), "MARGIN=10x10, GAP=10")); IupSetCallback(ih, "SHOW_CB", (Icallback)motFontDlgShow_CB); (void)params; return IUP_NOERROR; }
static int iColorDlgCreateMethod(Ihandle* ih, void** params) { Ihandle *ok_bt, *cancel_bt; Ihandle *rgb_vb, *hsi_vb, *clr_vb; Ihandle *lin1, *lin2, *col1, *col2; IcolorDlgData* colordlg_data = (IcolorDlgData*)malloc(sizeof(IcolorDlgData)); memset(colordlg_data, 0, sizeof(IcolorDlgData)); iupAttribSet(ih, "_IUP_GC_DATA", (char*)colordlg_data); /* ======================================================================= */ /* BUTTONS ============================================================= */ /* ======================================================================= */ ok_bt = IupButton("_@IUP_OK", NULL); /* Ok Button */ IupSetStrAttribute(ok_bt, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback (ok_bt, "ACTION", (Icallback)iColorDlgButtonOK_CB); IupSetAttributeHandle(ih, "DEFAULTENTER", ok_bt); cancel_bt = IupButton("_@IUP_CANCEL", NULL); /* Cancel Button */ IupSetStrAttribute(cancel_bt, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback (cancel_bt, "ACTION", (Icallback)iColorDlgButtonCancel_CB); IupSetAttributeHandle(ih, "DEFAULTESC", cancel_bt); colordlg_data->help_bt = IupButton("_@IUP_HELP", NULL); /* Help Button */ IupSetStrAttribute(colordlg_data->help_bt, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback (colordlg_data->help_bt, "ACTION", (Icallback)iColorDlgButtonHelp_CB); /* ======================================================================= */ /* COLOR =============================================================== */ /* ======================================================================= */ colordlg_data->color_browser = IupColorBrowser(); IupSetAttribute(colordlg_data->color_browser, "EXPAND", "YES"); IupSetCallback(colordlg_data->color_browser, "DRAG_CB", (Icallback)iColorDlgColorSelDrag_CB); IupSetCallback(colordlg_data->color_browser, "CHANGE_CB", (Icallback)iColorDlgColorSelDrag_CB); IupSetAttribute(colordlg_data->color_browser, "MINSIZE", "200x200"); colordlg_data->color_cnv = IupCanvas(NULL); /* Canvas of the color */ IupSetAttribute(colordlg_data->color_cnv, "SIZE", "x12"); IupSetAttribute(colordlg_data->color_cnv, "CANFOCUS", "NO"); IupSetAttribute(colordlg_data->color_cnv, "EXPAND", "HORIZONTAL"); IupSetCallback (colordlg_data->color_cnv, "ACTION", (Icallback)iColorDlgColorCnvAction_CB); IupSetCallback (colordlg_data->color_cnv, "BUTTON_CB", (Icallback)iColorDlgColorCnvButton_CB); colordlg_data->colorhex_txt = IupText(NULL); /* Hex of the color */ IupSetAttribute(colordlg_data->colorhex_txt, "VISIBLECOLUMNS", "7"); IupSetCallback (colordlg_data->colorhex_txt, "ACTION", (Icallback)iColorDlgHexAction_CB); IupSetAttribute(colordlg_data->colorhex_txt, "MASK", "#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"); /* ======================================================================= */ /* ALPHA TRANSPARENCY ================================================== */ /* ======================================================================= */ colordlg_data->alpha_val = IupVal("HORIZONTAL"); IupSetAttribute(colordlg_data->alpha_val, "EXPAND", "HORIZONTAL"); IupSetAttribute(colordlg_data->alpha_val, "MIN", "0"); IupSetAttribute(colordlg_data->alpha_val, "MAX", "255"); IupSetAttribute(colordlg_data->alpha_val, "VALUE", "255"); IupSetAttribute(colordlg_data->alpha_val, "SIZE", "80x12"); IupSetCallback (colordlg_data->alpha_val, "MOUSEMOVE_CB", (Icallback)iColorDlgAlphaVal_CB); IupSetCallback (colordlg_data->alpha_val, "BUTTON_PRESS_CB", (Icallback)iColorDlgAlphaVal_CB); IupSetCallback (colordlg_data->alpha_val, "BUTTON_RELEASE_CB", (Icallback)iColorDlgAlphaVal_CB); colordlg_data->alpha_txt = IupText(NULL); /* Alpha value */ IupSetAttribute(colordlg_data->alpha_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->alpha_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->alpha_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->alpha_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->alpha_txt, "SPININC", "1"); IupSetCallback (colordlg_data->alpha_txt, "ACTION", (Icallback)iColorDlgAlphaAction_CB); IupSetCallback (colordlg_data->alpha_txt, "SPIN_CB", (Icallback)iColorDlgAlphaSpin_CB); IupSetAttribute(colordlg_data->alpha_txt, "MASKINT", "0:255"); /* ======================================================================= */ /* COLOR TABLE ========================================================= */ /* ======================================================================= */ colordlg_data->colortable_cbar = IupColorbar(); IupSetAttribute(colordlg_data->colortable_cbar, "ORIENTATION", "HORIZONTAL"); IupSetAttribute(colordlg_data->colortable_cbar, "NUM_PARTS", "2"); IupSetInt(colordlg_data->colortable_cbar, "NUM_CELLS", COLORTABLE_MAX); IupSetAttribute(colordlg_data->colortable_cbar, "SHOW_PREVIEW", "NO"); IupSetAttribute(colordlg_data->colortable_cbar, "SIZE", "138x22"); IupSetAttribute(colordlg_data->colortable_cbar, "SQUARED", "NO"); IupSetCallback (colordlg_data->colortable_cbar, "SELECT_CB", (Icallback)iColorDlgColorTableSelect_CB); /* ======================================================================= */ /* RGB TEXT FIELDS ===================================================== */ /* ======================================================================= */ colordlg_data->red_txt = IupText(NULL); /* Red value */ IupSetAttribute(colordlg_data->red_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->red_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->red_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->red_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->red_txt, "SPININC", "1"); IupSetCallback (colordlg_data->red_txt, "ACTION", (Icallback)iColorDlgRedAction_CB); IupSetCallback (colordlg_data->red_txt, "SPIN_CB", (Icallback)iColorDlgRedSpin_CB); IupSetAttribute(colordlg_data->red_txt, "MASKINT", "0:255"); colordlg_data->green_txt = IupText(NULL); /* Green value */ IupSetAttribute(colordlg_data->green_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->green_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->green_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->green_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->green_txt, "SPININC", "1"); IupSetCallback (colordlg_data->green_txt, "ACTION", (Icallback)iColorDlgGreenAction_CB); IupSetCallback (colordlg_data->green_txt, "SPIN_CB", (Icallback)iColorDlgGreenSpin_CB); IupSetAttribute(colordlg_data->green_txt, "MASKINT", "0:255"); colordlg_data->blue_txt = IupText(NULL); /* Blue value */ IupSetAttribute(colordlg_data->blue_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->blue_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->blue_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->blue_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->blue_txt, "SPININC", "1"); IupSetCallback (colordlg_data->blue_txt, "ACTION", (Icallback)iColorDlgBlueAction_CB); IupSetCallback (colordlg_data->blue_txt, "SPIN_CB", (Icallback)iColorDlgBlueSpin_CB); IupSetAttribute(colordlg_data->blue_txt, "MASKINT", "0:255"); /* ======================================================================= */ /* HSI TEXT FIELDS ===================================================== */ /* ======================================================================= */ colordlg_data->hue_txt = IupText(NULL); /* Hue value */ IupSetAttribute(colordlg_data->hue_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->hue_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->hue_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->hue_txt, "SPINMAX", "359"); IupSetAttribute(colordlg_data->hue_txt, "SPINWRAP", "YES"); IupSetAttribute(colordlg_data->hue_txt, "SPININC", "1"); IupSetCallback(colordlg_data->hue_txt, "ACTION", (Icallback)iColorDlgHueAction_CB); IupSetCallback(colordlg_data->hue_txt, "SPIN_CB", (Icallback)iColorDlgHueSpin_CB); IupSetAttribute(colordlg_data->hue_txt, "MASKINT", "0:359"); colordlg_data->saturation_txt = IupText(NULL); /* Saturation value */ IupSetAttribute(colordlg_data->saturation_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->saturation_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->saturation_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->saturation_txt, "SPINMAX", "100"); IupSetAttribute(colordlg_data->saturation_txt, "SPININC", "1"); IupSetCallback(colordlg_data->saturation_txt, "ACTION", (Icallback)iColorDlgSaturationAction_CB); IupSetCallback(colordlg_data->saturation_txt, "SPIN_CB", (Icallback)iColorDlgSaturationSpin_CB); IupSetAttribute(colordlg_data->saturation_txt, "MASKINT", "0:100"); colordlg_data->intensity_txt = IupText(NULL); /* Intensity value */ IupSetAttribute(colordlg_data->intensity_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->intensity_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->intensity_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->intensity_txt, "SPINMAX", "100"); IupSetAttribute(colordlg_data->intensity_txt, "SPININC", "1"); IupSetCallback(colordlg_data->intensity_txt, "ACTION", (Icallback)iColorDlgIntensityAction_CB); IupSetCallback(colordlg_data->intensity_txt, "SPIN_CB", (Icallback)iColorDlgIntensitySpin_CB); IupSetAttribute(colordlg_data->intensity_txt, "MASKINT", "0:100"); /* =================== */ /* 1st line = Controls */ /* =================== */ col1 = IupVbox(colordlg_data->color_browser, IupSetAttributes(IupHbox(colordlg_data->color_cnv, NULL), "MARGIN=30x0"),NULL); hsi_vb = IupVbox(IupSetAttributes(IupHbox(IupLabel("_@IUP_HUE"), colordlg_data->hue_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_SATURATION"), colordlg_data->saturation_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_INTENSITY"), colordlg_data->intensity_txt, NULL), "ALIGNMENT=ACENTER"), NULL); IupSetAttribute(hsi_vb, "GAP", "5"); rgb_vb = IupVbox(IupSetAttributes(IupHbox(IupLabel("_@IUP_RED"), colordlg_data->red_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_GREEN"), colordlg_data->green_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_BLUE"), colordlg_data->blue_txt, NULL), "ALIGNMENT=ACENTER"), NULL); IupSetAttribute(rgb_vb, "GAP", "5"); clr_vb = IupVbox(IupSetAttributes(IupHbox(IupLabel("_@IUP_OPACITY"), colordlg_data->alpha_txt, colordlg_data->alpha_val, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("He&xa:"), colordlg_data->colorhex_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupVbox(IupLabel("_@IUP_PALETTE"), colordlg_data->colortable_cbar, NULL), "GAP=3"), NULL); IupSetAttribute(clr_vb, "GAP", "5"); IupSetAttribute(clr_vb, "EXPAND", "YES"); IupDestroy(IupSetAttributes(IupNormalizer(IupGetChild(IupGetChild(hsi_vb, 0), 0), /* Hue Label */ IupGetChild(IupGetChild(hsi_vb, 1), 0), /* Saturation Label */ IupGetChild(IupGetChild(hsi_vb, 2), 0), /* Intensity Label */ IupGetChild(IupGetChild(clr_vb, 0), 0), /* Opacity Label */ IupGetChild(IupGetChild(clr_vb, 1), 0), /* Hexa Label */ NULL), "NORMALIZE=HORIZONTAL")); IupDestroy(IupSetAttributes(IupNormalizer(IupGetChild(IupGetChild(rgb_vb, 0), 0), /* Red Label */ IupGetChild(IupGetChild(rgb_vb, 1), 0), /* Green Label */ IupGetChild(IupGetChild(rgb_vb, 2), 0), /* Blue Label */ NULL), "NORMALIZE=HORIZONTAL")); col2 = IupVbox(IupSetAttributes(IupHbox(hsi_vb, IupFill(), rgb_vb, NULL), "EXPAND=YES"), IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), clr_vb, NULL); IupSetAttributes(col2, "EXPAND=NO, GAP=10"); lin1 = IupHbox(col1, col2, NULL); IupSetAttribute(lin1, "GAP", "10"); IupSetAttribute(lin1, "MARGIN", "0x0"); /* ================== */ /* 2nd line = Buttons */ /* ================== */ lin2 = IupHbox(IupFill(), ok_bt, cancel_bt, colordlg_data->help_bt, NULL); IupSetAttribute(lin2, "GAP", "5"); IupSetAttribute(lin2, "MARGIN", "0x0"); IupSetAttribute(lin2, "NORMALIZESIZE", "HORIZONTAL"); /* Do not use IupAppend because we set childtype=IUP_CHILDNONE */ iupChildTreeAppend(ih, IupSetAttributes(IupVbox(lin1, IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), lin2, NULL), "MARGIN=10x10, GAP=10")); IupRefresh(ih); if (colordlg_data->color_browser->currentwidth < colordlg_data->color_browser->currentheight) { IupSetStrf(colordlg_data->color_browser, "RASTERSIZE", "%dx", colordlg_data->color_browser->currentheight); IupSetAttribute(ih, "RASTERSIZE", NULL); } IupSetAttribute(ih, "RESIZE", "NO"); iColorDlgInit_Defaults(colordlg_data); (void)params; return IUP_NOERROR; }
void func_1 (void) { Ihandle *_cbox, *_cnv_1, *dlg, *img, *_frm_1, *_frm_2, *_frm_3, *hbox, *_ctrl_1, *_list_1, *_list_2, *_list_3, *_text_1, *_ml_1; img = IupImage(32,32, img_bits1); IupSetHandle ("img1", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "BGCOLOR"); IupSetAttribute (img, "2", "255 0 0"); img = IupImage(32,32, img_bits2); IupSetHandle ("img2", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "0 255 0"); IupSetAttribute (img, "2", "BGCOLOR"); IupSetAttribute (img, "3", "255 0 0"); _frm_1 = IupFrame( IupVbox( IupSetAttributes(IupButton("Button Text", "action"), "BGCOLOR=\"255 128 0\", CINDEX=1"), IupSetAttributes(IupButton("", "action"), "BGCOLOR=\"255 128 0\", CINDEX=1"), IupSetAttributes(IupButton("", "action"), "IMAGE=img1,BGCOLOR=\"255 128 0\", CINDEX=2"), IupSetAttributes(IupButton("", "action"), "IMAGE=img1,BGCOLOR=\"255 128 0\", IMPRESS=img2,CINDEX=3"), NULL)); IupSetAttribute(_frm_1,IUP_TITLE,"IupButton"); IupSetAttribute(_frm_1,"CX","10"); IupSetAttribute(_frm_1,"CY","180"); _frm_2 = IupFrame( IupVbox( IupSetAttributes(IupLabel("Label Text"), "CINDEX=1,FONT=HELVETICA_ITALIC_14"), IupSetAttributes(IupLabel(""), "SEPARATOR=HORIZONTAL,CINDEX=2"), IupSetAttributes(IupLabel(""), "IMAGE=img1,CINDEX=3"), NULL)); IupSetAttribute(_frm_2,IUP_TITLE,"IupLabel"); IupSetAttribute(_frm_2,"CX","200"); IupSetAttribute(_frm_2,"CY","250"); _frm_3 = IupFrame( IupVbox( IupSetAttributes(IupToggle("Toggle Text", "action"), "VALUE=ON,CINDEX=1,FONT=HELVETICA_ITALIC_14"), IupSetAttributes(IupToggle("", "action"), "IMAGE=img1,IMPRESS=img2,CINDEX=2"), IupSetAttributes(IupFrame(IupRadio(IupVbox( IupSetAttributes(IupToggle("Toggle Text", "action"), "CINDEX=3"), IupSetAttributes(IupToggle("Toggle Text", "action"), "CINDEX=4"), NULL))), "TITLE=IupRadio"), NULL)); IupSetAttribute(_frm_3,IUP_TITLE,"IupToggle"); IupSetAttribute(_frm_3,"CX","400"); IupSetAttribute(_frm_3,"CY","250"); IupSetAttribute(_frm_3,"RASTERSIZE","150x150"); _text_1 = IupText( "action"); IupSetAttribute(_text_1,IUP_VALUE,"IupText Text"); IupSetAttribute(_text_1,IUP_SIZE,"80x"); IupSetAttribute(_text_1,"CINDEX","1"); IupSetAttribute(_text_1,"CX","10"); IupSetAttribute(_text_1,"CY","100"); _ml_1 = IupMultiLine( "action"); IupSetAttribute(_ml_1,IUP_VALUE,"IupMultiline Text\nSecond Line\nThird Line"); IupSetAttribute(_ml_1,IUP_SIZE,"80x60"); IupSetAttribute(_ml_1,"CINDEX","1"); IupSetAttribute(_ml_1,"CX","200"); IupSetAttribute(_ml_1,"CY","100"); _list_1 = IupList( "action"); IupSetAttribute(_list_1,IUP_VALUE,"1"); IupSetAttribute(_list_1,"1","Item 1 Text"); IupSetAttribute(_list_1,"2","Item 2 Text"); IupSetAttribute(_list_1,"3","Item 3 Text"); IupSetAttribute(_list_1,"CINDEX","1"); IupSetAttribute(_list_1,"CX","10"); IupSetAttribute(_list_1,"CY","10"); _list_2 = IupList( "action"); IupSetAttribute(_list_2,IUP_DROPDOWN,"YES"); IupSetAttribute(_list_2,IUP_VALUE,"2"); IupSetAttribute(_list_2,"1","Item 1 Text"); IupSetAttribute(_list_2,"2","Item 2 Text"); IupSetAttribute(_list_2,"3","Item 3 Text"); IupSetAttribute(_list_2,"CINDEX","2"); IupSetAttribute(_list_2,"CX","200"); IupSetAttribute(_list_2,"CY","10"); _list_3 = IupList( "action"); IupSetAttribute(_list_3,"EDITBOX","YES"); IupSetAttribute(_list_3,IUP_VALUE,"3"); IupSetAttribute(_list_3,"1","Item 1 Text"); IupSetAttribute(_list_3,"2","Item 2 Text"); IupSetAttribute(_list_3,"3","Item 3 Text"); IupSetAttribute(_list_3,"CINDEX","3"); IupSetAttribute(_list_3,"CX","400"); IupSetAttribute(_list_3,"CY","10"); _cnv_1 = IupCanvas( "do_nothing"); IupSetAttribute(_cnv_1,IUP_RASTERSIZE,"100x100"); IupSetAttribute(_cnv_1,IUP_POSX,"0.0"); IupSetAttribute(_cnv_1,IUP_POSY,"0.0"); IupSetAttribute(_cnv_1,IUP_BGCOLOR,"128 255 0"); IupSetAttribute(_cnv_1,"CX","400"); IupSetAttribute(_cnv_1,"CY","150"); _ctrl_1 = IupVal(NULL); IupSetAttribute(_ctrl_1,"CX","600"); IupSetAttribute(_ctrl_1,"CY","200"); // _cbox = IupCbox( _cbox = IupCboxBuilder( _text_1, _ml_1, _list_1, _list_2, _list_3, _cnv_1, _ctrl_1, createtree(), create_mat(), _frm_1, _frm_2, _frm_3, NULL); IupSetAttribute(_cbox,IUP_SIZE,"560x200"); hbox = IupHbox( IupSetAttributes(IupFill(), "SIZE=10"), IupVbox( IupSetAttributes(IupFill(), "SIZE=10"), IupFrame(_cbox), IupSetAttributes(IupLabel("Label Text"), "FONT=HELVETICA_ITALIC_14"), NULL), NULL); dlg = IupDialog(hbox); IupSetHandle("dlg",dlg); IupSetAttribute(dlg,IUP_TITLE,"Cbox Test"); IupSetAttribute(dlg,"COMPOSITED","YES"); /* improves a lot the redrawing */ // IupSetAttribute(dlg,"FONT","HELVETICA_ITALIC_14"); }
void MglPlotTest(void) { static Ihandle *dlg = NULL; if (!dlg) { Ihandle *vboxr[MAXPLOT+1]; /* tabs containing the plots */ Ihandle *vboxl, *hbox, *lbl1, *lbl2, *lbl3, *bt1, *boxinfo, *boxdial1, *boxdial2, *f1, *f2; int ii; IupControlsOpen(); IupMglPlotOpen(); /* init IupMGLPlot library */ IupSetGlobal("MGLFONTS", "../etc/mglfonts"); /* create plots */ for (ii=0; ii<MAXPLOT; ii++) { plot[ii] = IupMglPlot(); IupSetAttribute(plot[ii], "OPENGL", "Yes"); } /* left panel: plot control Y zooming */ dial1 = IupDial("VERTICAL"); lbl1 = IupLabel("+"); lbl2 = IupLabel("-"); boxinfo = IupVbox(lbl1, IupFill(), lbl2, NULL); boxdial1 = IupHbox(boxinfo, dial1, NULL); IupSetAttribute(boxdial1, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "SIZE", "20x52"); IupSetAttribute(boxinfo, "GAP", "2"); IupSetAttribute(boxinfo, "MARGIN", "4"); IupSetAttribute(boxinfo, "EXPAND", "YES"); IupSetAttribute(lbl1, "EXPAND", "NO"); IupSetAttribute(lbl2, "EXPAND", "NO"); IupSetAttribute(dial1, "ACTIVE", "NO"); IupSetAttribute(dial1, "SIZE", "20x52"); IupSetCallback(dial1, "BUTTON_PRESS_CB", (Icallback)dial1_btndown_cb); IupSetCallback(dial1, "MOUSEMOVE_CB", (Icallback)dial1_btnup_cb); IupSetCallback(dial1, "BUTTON_RELEASE_CB", (Icallback)dial1_btnup_cb); tgg1 = IupToggle("Y Autoscale", NULL); IupSetCallback(tgg1, "ACTION", (Icallback)tgg1_cb); IupSetAttribute(tgg1, "VALUE", "ON"); f1 = IupFrame( IupVbox(boxdial1, tgg1, NULL) ); IupSetAttribute(f1, "TITLE", "Y Zoom"); /* X zooming */ dial2 = IupDial("HORIZONTAL"); lbl1 = IupLabel("-"); lbl2 = IupLabel("+"); boxinfo = IupHbox(lbl1, IupFill(), lbl2, NULL); boxdial2 = IupVbox(dial2, boxinfo, NULL); IupSetAttribute(boxdial2, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "ALIGNMENT", "ACENTER"); IupSetAttribute(boxinfo, "SIZE", "64x16"); IupSetAttribute(boxinfo, "GAP", "2"); IupSetAttribute(boxinfo, "MARGIN", "4"); IupSetAttribute(boxinfo, "EXPAND", "HORIZONTAL"); IupSetAttribute(lbl1, "EXPAND", "NO"); IupSetAttribute(lbl2, "EXPAND", "NO"); IupSetAttribute(dial2, "ACTIVE", "NO"); IupSetAttribute(dial2, "SIZE", "64x16"); IupSetCallback(dial2, "BUTTON_PRESS_CB", (Icallback)dial2_btndown_cb); IupSetCallback(dial2, "MOUSEMOVE_CB", (Icallback)dial2_btnup_cb); IupSetCallback(dial2, "BUTTON_RELEASE_CB", (Icallback)dial2_btnup_cb); tgg2 = IupToggle("X Autoscale", NULL); IupSetCallback(tgg2, "ACTION", (Icallback)tgg2_cb); f2 = IupFrame( IupVbox(boxdial2, tgg2, NULL) ); IupSetAttribute(f2, "TITLE", "X Zoom"); lbl1 = IupLabel(""); IupSetAttribute(lbl1, "SEPARATOR", "HORIZONTAL"); tgg3 = IupToggle("Vertical Grid", NULL); IupSetCallback(tgg3, "ACTION", (Icallback)tgg3_cb); tgg4 = IupToggle("Horizontal Grid", NULL); IupSetCallback(tgg4, "ACTION", (Icallback)tgg4_cb); tgg6 = IupToggle("Box", NULL); IupSetCallback(tgg6, "ACTION", (Icallback)tgg6_cb); lbl2 = IupLabel(""); IupSetAttribute(lbl2, "SEPARATOR", "HORIZONTAL"); tgg5 = IupToggle("Legend", NULL); IupSetCallback(tgg5, "ACTION", (Icallback)tgg5_cb); lbl3 = IupLabel(""); IupSetAttribute(lbl3, "SEPARATOR", "HORIZONTAL"); bt1 = IupButton("Export", NULL); IupSetCallback(bt1, "ACTION", (Icallback)bt1_cb); vboxl = IupVbox(f1, f2, lbl1, tgg3, tgg4, tgg6, lbl2, tgg5, lbl3, bt1, NULL); IupSetAttribute(vboxl, "GAP", "4"); IupSetAttribute(vboxl, "EXPAND", "NO"); /* right panel: tabs with plots */ for (ii=0; ii<MAXPLOT; ii++) { vboxr[ii] = IupVbox(plot[ii], NULL); /* each plot a tab */ IupSetfAttribute(vboxr[ii], "TABTITLE", "Plot %d", ii); /* name each tab */ IupSetHandle(IupGetAttribute(vboxr[ii], "TABTITLE"), vboxr[ii]); } vboxr[MAXPLOT] = NULL; /* mark end of vector */ tabs = IupTabsv(vboxr); IupSetCallback(tabs, "TABCHANGE_CB", (Icallback)tabs_tabchange_cb); hbox = IupHbox(vboxl, tabs, NULL); IupSetAttribute(hbox, "MARGIN", "4x4"); IupSetAttribute(hbox, "GAP", "10"); dlg = IupDialog(hbox); IupSetAttribute(dlg, "TITLE", "IupMglPlot Example"); InitPlots(); /* It must be able to be done independent of dlg Mapping */ tabs_tabchange_cb(tabs, vboxr[0]); } IupSetAttribute(dlg, "SIZE", "300x"); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetAttribute(dlg, "SIZE", NULL); }
static void CreateFill(void) { lua_pushusertag(IupFill(), iuplua_tag); }
int init(void) { Ihandle *dialog, *statusbar, *box; Ihandle *toolbar, *load, *save; /* creates the toolbar and its buttons */ load = IupButton("Load", "load_cb"); IupSetAttribute(load,"TIP","Carrega uma imagem."); //IupSetAttribute(load,"IMAGE","icon_lib_open"); IupSetFunction("load_cb", (Icallback)load_cb); save = IupButton("Save", "save_cb"); IupSetAttribute(save,"TIP","Salva no formato GIF."); //IupSetAttribute(save,"IMAGE","icon_lib_save"); toolbar = IupHbox( load, save, IupFill(), NULL); IupSetAttribute(toolbar, "ALIGNMENT", "ACENTER"); /* cria um canvas */ canvas = IupGLCanvas("repaint_cb"); IupSetAttribute(canvas,IUP_RASTERSIZE,"400x400"); IupSetAttribute(canvas, "RESIZE_CB", "resize_cb"); /* associa o evento de repaint a funccao repaint_cb */ IupSetFunction("repaint_cb", (Icallback) repaint_cb); IupSetFunction("save_cb", (Icallback)save_cb); IupSetFunction("resize_cb", (Icallback) resize_cb); IupSetFunction (IUP_IDLE_ACTION, (Icallback) NULL); /* the status bar is just a label to put some usefull information in run time */ label = IupLabel("status"); IupSetAttribute(label, "EXPAND", "HORIZONTAL"); IupSetAttribute(label, "FONT", "COURIER_NORMAL_10"); statusbar = IupSetAttributes(IupHbox( IupFrame(IupHbox(label, NULL)), NULL), "MARGIN=5x5"); /* this is the most external box that puts together the toolbar, the two canvas and the status bar */ box = IupVbox( toolbar, canvas, statusbar, NULL); /* create the dialog and set its attributes */ dialog = IupDialog(box); IupSetAttribute(dialog, "CLOSE_CB", "app_exit_cb"); IupSetAttribute(dialog, "TITLE", "CG2004: Trab. 2"); IupShowXY(dialog, IUP_CENTER, IUP_CENTER); return 1; }
void init(int argc, char* argv[]) { UINT ix; Ihandle *topVbox, *bottomVbox, *dialogVBox, *controlHbox; Ihandle *noneIcon, *doingIcon, *errorIcon; char* arg_value = NULL; // fill in config loadConfig(); // iup inits IupOpen(&argc, &argv); // this is so easy to get wrong so it's pretty worth noting in the program statusLabel = IupLabel("NOTICE: When capturing localhost (loopback) packets, you CAN'T include inbound criteria.\n" "Filters like 'udp' need to be 'udp and outbound' to work. See readme for more info."); IupSetAttribute(statusLabel, "EXPAND", "HORIZONTAL"); IupSetAttribute(statusLabel, "PADDING", "8x8"); topFrame = IupFrame( topVbox = IupVbox( filterText = IupText(NULL), controlHbox = IupHbox( stateIcon = IupLabel(NULL), filterButton = IupButton("Start", NULL), IupFill(), IupLabel("Presets: "), filterSelectList = IupList(NULL), NULL ), NULL ) ); // parse arguments and set globals *before* setting up UI. // arguments can be read and set after callbacks are setup // FIXME as Release is built as WindowedApp, stdout/stderr won't show LOG("argc: %d", argc); if (argc > 1) { if (!parseArgs(argc, argv)) { fprintf(stderr, "invalid argument count. ensure you're using options as \"--drop on\""); exit(-1); // fail fast. } parameterized = 1; } IupSetAttribute(topFrame, "TITLE", "Filtering"); IupSetAttribute(topFrame, "EXPAND", "HORIZONTAL"); IupSetAttribute(filterText, "EXPAND", "HORIZONTAL"); IupSetCallback(filterText, "VALUECHANGED_CB", (Icallback)uiFilterTextCb); IupSetAttribute(filterButton, "PADDING", "8x"); IupSetCallback(filterButton, "ACTION", uiStartCb); IupSetAttribute(topVbox, "NCMARGIN", "4x4"); IupSetAttribute(topVbox, "NCGAP", "4x2"); IupSetAttribute(controlHbox, "ALIGNMENT", "ACENTER"); // setup state icon IupSetAttribute(stateIcon, "IMAGE", "none_icon"); IupSetAttribute(stateIcon, "PADDING", "4x"); // fill in options and setup callback IupSetAttribute(filterSelectList, "VISIBLECOLUMNS", "24"); IupSetAttribute(filterSelectList, "DROPDOWN", "YES"); for (ix = 0; ix < filtersSize; ++ix) { char ixBuf[4]; sprintf(ixBuf, "%d", ix+1); // ! staring from 1, following lua indexing IupStoreAttribute(filterSelectList, ixBuf, filters[ix].filterName); } IupSetAttribute(filterSelectList, "VALUE", "1"); IupSetCallback(filterSelectList, "ACTION", (Icallback)uiListSelectCb); // set filter text value since the callback won't take effect before main loop starts IupSetAttribute(filterText, "VALUE", filters[0].filterValue); // functionalities frame bottomFrame = IupFrame( bottomVbox = IupVbox( NULL ) ); IupSetAttribute(bottomFrame, "TITLE", "Functions"); IupSetAttribute(bottomVbox, "NCMARGIN", "4x4"); IupSetAttribute(bottomVbox, "NCGAP", "4x2"); // create icons noneIcon = IupImage(8, 8, icon8x8); doingIcon = IupImage(8, 8, icon8x8); errorIcon = IupImage(8, 8, icon8x8); IupSetAttribute(noneIcon, "0", "BGCOLOR"); IupSetAttribute(noneIcon, "1", "224 224 224"); IupSetAttribute(doingIcon, "0", "BGCOLOR"); IupSetAttribute(doingIcon, "1", "109 170 44"); IupSetAttribute(errorIcon, "0", "BGCOLOR"); IupSetAttribute(errorIcon, "1", "208 70 72"); IupSetHandle("none_icon", noneIcon); IupSetHandle("doing_icon", doingIcon); IupSetHandle("error_icon", errorIcon); // setup module uis for (ix = 0; ix < MODULE_CNT; ++ix) { uiSetupModule(*(modules+ix), bottomVbox); } // dialog dialog = IupDialog( dialogVBox = IupVbox( topFrame, bottomFrame, statusLabel, NULL ) ); IupSetAttribute(dialog, "TITLE", "clumsy " CLUMSY_VERSION); IupSetAttribute(dialog, "SIZE", "400x"); // add padding manually to width IupSetAttribute(dialog, "RESIZE", "NO"); IupSetCallback(dialog, "SHOW_CB", (Icallback)uiOnDialogShow); // global layout settings to affect childrens IupSetAttribute(dialogVBox, "ALIGNMENT", "ACENTER"); IupSetAttribute(dialogVBox, "NCMARGIN", "4x4"); IupSetAttribute(dialogVBox, "NCGAP", "4x2"); // setup timer timer = IupTimer(); IupSetAttribute(timer, "TIME", STR(ICON_UPDATE_MS)); IupSetCallback(timer, "ACTION_CB", uiTimerCb); // setup timeout of program arg_value = IupGetGlobal("timeout"); if(arg_value != NULL) { char valueBuf[16]; sprintf(valueBuf, "%s000", arg_value); // convert from seconds to milliseconds timeout = IupTimer(); IupStoreAttribute(timeout, "TIME", valueBuf); IupSetCallback(timeout, "ACTION_CB", uiTimeoutCb); IupSetAttribute(timeout, "RUN", "YES"); } }
int IupGetText(const char* title, char* text) { Ihandle *ok, *cancel, *multi_text, *button_box, *dlg_box, *dlg; int bt; multi_text = IupMultiLine(NULL); IupSetAttribute(multi_text,"EXPAND", "YES"); IupSetAttribute(multi_text,"VALUE", text); IupSetAttribute(multi_text,"FONT", "Courier, 12"); IupSetAttribute(multi_text, "VISIBLELINES", "10"); IupSetAttribute(multi_text, "VISIBLECOLUMNS", "50"); ok = IupButton("OK", NULL); IupSetAttribute(ok, "PADDING", "20x5"); IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK); cancel = IupButton(iupStrMessageGet("IUP_CANCEL"), NULL); IupSetAttribute(cancel, "PADDING", "20x5"); IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL); button_box = IupHbox( IupFill(), ok, cancel, NULL); IupSetAttribute(button_box,"MARGIN","0x0"); IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL"); dlg_box = IupVbox( multi_text, button_box, NULL); IupSetAttribute(dlg_box,"MARGIN","10x10"); IupSetAttribute(dlg_box,"GAP","10"); dlg = IupDialog (dlg_box); IupSetAttribute(dlg,"TITLE", title); IupSetAttribute(dlg,"MINBOX","NO"); IupSetAttribute(dlg,"MAXBOX","NO"); IupSetAttributeHandle(dlg,"DEFAULTENTER", ok); IupSetAttributeHandle(dlg,"DEFAULTESC", cancel); IupSetAttribute(dlg,"PARENTDIALOG", IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON")); IupMap(dlg); IupSetAttribute(multi_text, "VISIBLELINES", NULL); IupSetAttribute(multi_text, "VISIBLECOLUMNS", NULL); IupPopup(dlg, IUP_CENTER, IUP_CENTER); bt = IupGetInt(dlg, "STATUS"); if (bt==1) strcpy(text, IupGetAttribute(multi_text, "VALUE")); else bt = 0; /* return 0 instead of -1 */ IupDestroy(dlg); return bt; }
int main(int argc, char **argv) { /* IUP identifiers */ Ihandle *fr1, *fr2, *fr3, *dialog; Ihandle *b11, *b12, *b13; Ihandle *b21, *b22, *b23; Ihandle *b31, *b32, *b33; Ihandle *h1, *h2, *h3; /* Initializes IUP */ IupOpen(&argc, &argv); /* Creates frame with three top aligned buttons */ fr1 = IupFrame ( h1=IupHbox ( IupFill(), b11=IupButton ("1", ""), b12=IupButton ("2", ""), b13=IupButton ("3", ""), IupFill(), NULL ) ); IupSetAttribute(fr1, "TITLE", "ALIGNMENT=ATOP, GAP=10, SIZE=200"); IupSetAttribute(b11, "SIZE", "30x30"); IupSetAttribute(b12, "SIZE", "30x40"); IupSetAttribute(b13, "SIZE", "30x50"); IupSetAttributes(h1, "ALIGNMENT=ATOP, GAP=10, SIZE=200"); /* Sets hbox's alignment, gap and size */ /* Creates frame with three buttons */ fr2 = IupFrame ( h2=IupHbox ( IupFill(), b21=IupButton("1", ""), b22=IupButton("2", ""), b23=IupButton("3", ""), IupFill(), NULL ) ); IupSetAttribute(fr2, "TITLE", "ALIGNMENT=ACENTER, GAP=20"); IupSetAttribute(b21, "SIZE", "30x30"); IupSetAttribute(b22, "SIZE", "30x40"); IupSetAttribute(b23, "SIZE", "30x50"); IupSetAttributes(h2, "ALIGNMENT=ACENTER, GAP=20"); /* Sets hbox's alignment and gap */ /* Creates frame with three bottom aligned buttons */ fr3 = IupFrame ( h3=IupHbox ( IupFill(), b31=IupButton ("1", ""), b32=IupButton ("2", ""), b33=IupButton ("3", ""), IupFill(), NULL ) ); IupSetAttribute(fr3, "TITLE", "ALIGNMENT = ABOTTOM, SIZE = 150"); IupSetAttribute(b31, "SIZE", "30x30"); IupSetAttribute(b32, "SIZE", "30x40"); IupSetAttribute(b33, "SIZE", "30x50"); IupSetAttributes(h3, "ALIGNMENT = ABOTTOM, SIZE = 150"); /* Sets hbox's alignment and size */ /* Creates dialog with the three frames */ dialog = IupDialog ( IupVbox ( fr1, fr2, fr3, NULL ) ); IupSetAttribute(dialog, "TITLE", "IupHbox"); /* Sets dialog's title */ IupShowXY( dialog, IUP_CENTER, IUP_CENTER ); /* Shows dialog in the center of the screen */ IupMainLoop(); /* Initializes IUP main loop */ IupClose(); /* Finishes IUP */ return EXIT_SUCCESS; }
/* Main program */ int main(int argc, char **argv) { /* IUP identifiers */ Ihandle *dlg ; Ihandle *frm_1, *frm_2, *frm_3 ; Ihandle *btn_11, *btn_12, *btn_13 ; Ihandle *btn_21, *btn_22, *btn_23 ; Ihandle *btn_31, *btn_32, *btn_33 ; Ihandle *vbox_1, *vbox_2, *vbox_3 ; /* Initializes IUP */ IupOpen(&argc, &argv); /* Program begin */ /* Creates frame 1 */ frm_1 = IupFrame ( IupHbox ( IupFill(), vbox_1 = IupVbox ( btn_11=IupButton ("1", ""), btn_12=IupButton ("2", ""), btn_13=IupButton ("3", ""), NULL ), IupFill(), NULL ) ) ; /* Sets title of frame 1 */ IupSetAttribute (frm_1, "TITLE", "ALIGNMENT = ALEFT, GAP = 10") ; /* Sets attributes of buttons inside frame 1 */ IupSetAttribute (btn_11, "SIZE", "20x30") ; IupSetAttribute (btn_12, "SIZE", "30x30") ; IupSetAttribute (btn_13, "SIZE", "40x30") ; /* Sets attributes of vbox 1 */ IupSetAttributes (vbox_1, "ALIGNMENT = ALEFT, GAP = 10") ; /* Creates frame 2 */ frm_2 = IupFrame ( IupHbox ( IupFill(), vbox_2 = IupVbox ( btn_21 = IupButton ("1", ""), btn_22 = IupButton ("2", ""), btn_23 = IupButton ("3", ""), NULL ), IupFill (), NULL ) ); /* Sets title of frame 1 */ IupSetAttribute (frm_2, "TITLE", "ALIGNMENT = ACENTER, MARGIN = 15") ; /* Sets attributes of buttons inside frame 2 */ IupSetAttribute (btn_21, "SIZE", "20x30") ; IupSetAttribute (btn_22, "SIZE", "30x30") ; IupSetAttribute (btn_23, "SIZE", "40x30") ; /* Sets attributes of vbox 2 */ IupSetAttributes (vbox_2, "ALIGNMENT = ACENTER, MARGIN = 15") ; /* Creates frame 3 */ frm_3 = IupFrame ( IupHbox ( IupFill (), vbox_3 = IupVbox ( btn_31=IupButton ("1", ""), btn_32=IupButton ("2", ""), btn_33=IupButton ("3", ""), NULL ), IupFill (), NULL ) ) ; /* Sets title of frame 3 */ IupSetAttribute (frm_3, "TITLE", "ALIGNMENT = ARIGHT, SIZE = 20") ; /* Sets attributes of buttons inside frame 3 */ IupSetAttribute (btn_31, "SIZE", "20x30") ; IupSetAttribute (btn_32, "SIZE", "30x30") ; IupSetAttribute (btn_33, "SIZE", "40x30") ; /* Sets attributes of vbox 3 */ IupSetAttributes (vbox_3, "ALIGNMENT = ARIGHT, SIZE = 20") ; /* Creates dialog with three frames inside a vbo_ */ dlg = IupDialog ( IupVbox ( frm_1, frm_2, frm_3, NULL ) ) ; /* Sets title and size of the dialog */ IupSetAttributes (dlg, "TITLE = \"IupVbox Example\", SIZE = QUARTER"); /* Shows dialog in the center of the screen */ IupShowXY (dlg, IUP_CENTER, IUP_CENTER) ; /* Initializes IUP main loop */ IupMainLoop () ; IupDestroy(dlg); /* Finishes IUP */ IupClose () ; /* Program finished successfully */ return 0 ; }
void SampleTest(void) { Ihandle *mnu, *_hbox_1, *_cnv_1, *_vbox_1, *dlg, *img, *_frm_1, *_frm_2, *_frm_3, *_frm_4, *_frm_5, *pbar, *val, *tabs, *_list_1, *_list_2, *_list_3, *_text_1, *_ml_1, *tree; //img = IupImage(32,32, img_bits1); //IupSetHandle ("img1", img); //IupSetAttribute (img, "0", "0 0 0"); //IupSetAttribute (img, "1", "BGCOLOR"); //IupSetAttribute (img, "2", "255 0 0"); img = load_image_Tecgraf(); IupSetHandle ("img1", img); img = IupImage(32,32, img_bits2); IupSetHandle ("img2", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "0 255 0"); IupSetAttribute (img, "2", "BGCOLOR"); IupSetAttribute (img, "3", "255 0 0"); mnu = IupMenu( IupSubmenu("IupSubmenu 1", IupMenu( IupSetAttributes(IupItem("IupItem 1 Checked", NULL), "VALUE=ON"), IupSeparator(), IupSetAttributes(IupItem("IupItem 2 Disabled", NULL), "ACTIVE=NO"), NULL)), IupItem("IupItem 3", NULL), IupItem("IupItem 4", NULL), NULL); IupSetHandle("mnu",mnu); _frm_1 = IupFrame( IupVbox( set_callbacks(IupSetAttributes(IupButton("Button Text", NULL), "PADDING=5x5, TIP=\"Button TIP\"")), IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton("Text", NULL), "IMAGE=img1, PADDING=5x5")),"ACTION", action1_cb, NULL), IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton(NULL, NULL), "IMAGE=img1")),"ACTION", action2_cb, NULL), IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2")),"ACTION", action3_cb, NULL), IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton(NULL, NULL), "BGCOLOR=\"255 0 128\", SIZE=20x10")),"ACTION", action3_cb, NULL), NULL)); IupSetAttribute(_frm_1,"TITLE","IupButton"); _frm_2 = IupFrame( IupVbox( IupSetAttributes(IupLabel("Label Text"), "TIP=\"Label TIP\""), IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL, MAXSIZE=150, NAME=SAMP_SEP"), IupSetAttributes(IupLabel(NULL), "IMAGE=img1"), NULL)); IupSetAttribute(_frm_2,"TITLE","IupLabel"); _frm_3 = IupFrame( IupVbox( set_callbacks(IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON, TIP=\"Toggle TIP\"")), set_callbacks(IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1,IMPRESS=img2")), set_callbacks(IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1")), IupSetAttributes(IupFrame(IupRadio(IupVbox( set_callbacks(IupToggle("Toggle Text", NULL)), set_callbacks(IupToggle("Toggle Text", NULL)), NULL))), "TITLE=IupRadio"), NULL)); IupSetAttribute(_frm_3,"TITLE","IupToggle"); _text_1 = IupText( NULL); IupSetAttribute(_text_1,"VALUE","Single Line Text"); IupSetAttribute(_text_1,"SIZE","80x"); IupSetAttribute(_text_1,"TIP","Text TIP"); _ml_1 = IupMultiLine( NULL); IupSetAttribute(_ml_1,"VALUE","Multiline Text\nSecond Line\nThird Line"); IupSetAttribute(_ml_1,"EXPAND","YES"); IupSetAttribute(_ml_1,"SIZE","80x40"); IupSetAttribute(_ml_1,"TIP","Multiline TIP"); _frm_4 = IupFrame(IupVbox( set_callbacks(_text_1), set_callbacks(_ml_1), NULL)); IupSetAttribute(_frm_4,"TITLE","IupText"); _list_1 = IupList( NULL); // IupSetAttribute(_list_1,"EXPAND","YES"); IupSetAttribute(_list_1,"VALUE","1"); IupSetAttribute(_list_1,"1","Item 1 Text"); IupSetAttribute(_list_1,"2","Item 2 Text"); IupSetAttribute(_list_1,"3","Item 3 Text"); IupSetAttribute(_list_1,"TIP","List 1"); _list_2 = IupList( NULL); IupSetAttribute(_list_2,"DROPDOWN","YES"); // IupSetAttribute(_list_2,"EXPAND","YES"); IupSetAttribute(_list_2,"VALUE","2"); IupSetAttribute(_list_2,"1","Item 1 Text"); IupSetAttribute(_list_2,"2","Item 2 Text"); IupSetAttribute(_list_2,"3","Item 3 Text"); IupSetAttribute(_list_2,"TIP","List 2"); _list_3 = IupList( NULL); IupSetAttribute(_list_3,"EDITBOX","YES"); // IupSetAttribute(_list_3,"EXPAND","YES"); IupSetAttribute(_list_3,"VALUE","3"); IupSetAttribute(_list_3,"1","Item 1 Text"); IupSetAttribute(_list_3,"2","Item 2 Text"); IupSetAttribute(_list_3,"3","Item 3 Text"); IupSetAttribute(_list_3,"TIP","List 3"); _frm_5 = IupFrame(IupVbox( set_callbacks(_list_1), set_callbacks(_list_2), set_callbacks(_list_3), NULL)); IupSetAttribute(_frm_5,"TITLE","IupList"); _hbox_1 = IupHbox( _frm_1, _frm_2, _frm_3, _frm_4, _frm_5, NULL); val = IupVal(NULL); IupSetAttribute(val,"TIP","Valuator TIP"); set_callbacks(val); pbar = IupProgressBar(); IupSetAttribute(pbar, "VALUE", "0.5"); IupSetAttribute(pbar,"TIP","ProgressBar TIP"); set_callbacks(pbar); tabs = IupTabs(IupVbox(IupLabel(""), NULL), IupVbox(IupFill(), NULL), IupVbox(IupFill(), NULL), NULL); IupSetAttribute(tabs,"TABTITLE0","Tab Title 0"); IupSetAttribute(tabs,"TABTITLE1","Tab Title 1"); IupSetAttributeHandle(tabs,"TABIMAGE1", load_image_LogoTecgraf()); IupSetAttribute(tabs,"TABTITLE2","Tab Title 2"); IupSetAttribute(tabs,"RASTERSIZE","300x50"); IupSetAttribute(tabs,"TIP","Tabs TIP"); // IupSetAttribute(tabs,"PADDING","5x5"); set_callbacks(tabs); tree = IupTree(); IupSetAttribute(tree, "SHOWRENAME", "YES"); IupSetAttribute(tree,"RASTERSIZE","100x150"); IupSetAttribute(tree,"TIP","Treee TIP"); set_callbacks(tree); _cnv_1 = IupCanvas(NULL); IupSetAttribute(_cnv_1,"BGCOLOR","128 255 0"); IupSetAttribute(_cnv_1,"SCROLLBAR","YES"); IupSetAttribute(_cnv_1,"EXPAND","HORIZONTAL"); IupSetAttribute(_cnv_1,"RASTERSIZE","x100"); IupSetAttribute(_cnv_1,"TIP","Canvas TIP"); // IupSetAttribute(_cnv_1,"CANFOCUS","NO"); set_callbacks(_cnv_1); _vbox_1 = IupVbox( _hbox_1, IupHbox(IupSetAttributes(IupFrame(IupHbox(val, NULL)), "TITLE=IupVal"), IupSetAttributes(IupFrame(IupHbox(pbar, NULL)), "TITLE=IupProgressBar"), IupSetAttributes(IupFrame(IupHbox(tabs, NULL)), "TITLE=IupTabs"), NULL), IupHbox(IupSetAttributes(IupFrame(IupHbox(_cnv_1, NULL)), "TITLE=IupCanvas"), IupSetAttributes(IupFrame(IupHbox(tree, NULL)), "TITLE=IupTree"), NULL), NULL); IupSetAttribute(_vbox_1,"MARGIN","5x5"); IupSetAttribute(_vbox_1,"GAP","5"); dlg = IupDialog(_vbox_1); IupSetHandle("dlg",dlg); IupSetAttribute(dlg,"MENU","mnu"); IupSetAttribute(dlg,"TITLE","IupDialog Title"); // IupSetAttribute(dlg,"COMPOSITED","YES"); /* Windows Only */ // IupSetAttribute(dlg, "OPACITY", "192"); // IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation // IupSetAttribute(_vbox_1, "BGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); //IupSetGlobal("DLGBGCOLOR", "92 92 255"); //IupSetGlobal("TXTFGCOLOR", "255 92 92"); //IupSetGlobal("TXTBGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "FONT", "Helvetica, 24"); // IupSetAttribute(dlg, "FONT", "-*-helvetica-*-r-*-*-18-*-*-*-*-*-*-*"); // IupSetAttribute(box, "FGCOLOR", "255 0 0"); // IupSetAttribute(dlg,"RASTERSIZE","1000x800"); IupSetCallback(dlg, "COPYDATA_CB", (Icallback)copydata_cb); //IupSetGlobal("INPUTCALLBACKS", "Yes"); //IupSetFunction("GLOBALKEYPRESS_CB", (Icallback)globalkeypress_cb); //IupSetFunction("GLOBALMOTION_CB", (Icallback)globalmotion_cb); //IupSetFunction("GLOBALBUTTON_CB", (Icallback)globalbutton_cb); //IupSetFunction("GLOBALWHEEL_CB", (Icallback)globalwheel_cb); IupMap(dlg); IupSetAttribute(tree, "TITLE0", "Figures"); IupSetAttribute(tree, "ADDLEAF0", "Other"); /* new id=1 */ IupSetAttribute(tree, "ADDBRANCH1", "triangle"); /* new id=2 */ IupSetAttribute(tree, "ADDLEAF2", "equilateral"); /* ... */ IupSetAttribute(tree, "ADDLEAF3", "isoceles"); IupSetAttribute(tree, "ADDLEAF4", "scalenus"); IupShow(dlg); // IupSetAttribute(dlg,"RASTERSIZE", NULL); }
int main(int argc, char* argv[]) { Ihandle *dlg, *vbox, *hbox; Ihandle *btn_restart, *btn_accelerate, *btn_decelerate, *btn_show1, *btn_show2; IupOpen(&argc, &argv); /* IUP initialization */ timer = IupTimer(); IupSetCallback(timer, "ACTION_CB", (Icallback)time_cb); IupSetAttribute(timer, "TIME", "100"); progressbar1 = IupProgressBar(); progressbar2 = IupProgressBar(); IupSetAttribute(progressbar1, "EXPAND", "YES"); IupSetAttribute(progressbar1, "DASHED", "YES"); IupSetAttribute(progressbar2, "ORIENTATION", "VERTICAL"); IupSetAttribute(progressbar2, "BGCOLOR", "255 0 128"); IupSetAttribute(progressbar2, "FGCOLOR", "0 128 0"); IupSetAttribute(progressbar2, "RASTERSIZE", "30x100"); IupSetAttribute(progressbar2, "MAX", "50"); IupSetAttribute(progressbar2, "VALUE", "25"); btn_restart = IupButton(NULL, NULL); btn_pause = IupButton(NULL, NULL); btn_accelerate = IupButton(NULL, NULL); btn_decelerate = IupButton(NULL, NULL); btn_show1 = IupButton("Dashed", NULL); btn_show2 = IupButton("Marquee", NULL); createimg_s(); IupSetAttribute(btn_restart, "IMAGE", "img_restart"); IupSetAttribute(btn_restart, "TIP", "Restart" ); IupSetAttribute(btn_pause, "IMAGE", "img_pause"); IupSetAttribute(btn_pause, "TIP", "Play/Pause"); IupSetAttribute(btn_accelerate, "IMAGE", "img_forward"); IupSetAttribute(btn_accelerate, "TIP", "Accelerate"); IupSetAttribute(btn_decelerate, "IMAGE", "img_rewind"); IupSetAttribute(btn_decelerate, "TIP", "Decelerate"); IupSetAttribute(btn_show1, "TIP", "Dashed or Continuous"); IupSetAttribute(btn_show2, "TIP", "Marquee or Defined"); hbox = IupHbox ( IupFill(), btn_pause, btn_restart, btn_decelerate, btn_accelerate, btn_show1, btn_show2, IupFill(), NULL ); vbox = IupHbox(IupVbox(progressbar1, hbox, NULL), progressbar2, NULL); IupSetAttribute(vbox, "MARGIN", "10x10"); IupSetAttribute(vbox, "GAP", "5"); dlg = IupDialog(vbox); IupSetAttribute(dlg, "TITLE", "IupProgressBar Test"); IupSetCallback(btn_pause, "ACTION", (Icallback) btn_pause_cb); IupSetCallback(btn_restart, "ACTION", (Icallback) btn_restart_cb); IupSetCallback(btn_accelerate, "ACTION", (Icallback) btn_accelerate_cb); IupSetCallback(btn_decelerate, "ACTION", (Icallback) btn_decelerate_cb); IupSetCallback(btn_show1, "ACTION", (Icallback) btn_show1_cb); IupSetCallback(btn_show2, "ACTION", (Icallback) btn_show2_cb); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetAttribute(timer, "RUN", "YES"); IupMainLoop(); IupClose(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Ihandle *dlg; Ihandle *vbox; Ihandle *hbox; Ihandle *btn_start, *btn_pause, *btn_accelerate, *btn_decelerate, *btn_show; IupOpen(&argc, &argv); IupControlsOpen(); gauge = IupGauge(); IupSetAttribute(gauge,"EXPAND","YES"); // IupSetAttribute(gauge,"MAX","3.5"); // IupSetAttribute(gauge,"MIN","0.7"); btn_start = IupButton ( "start", "btn_start_act" ); btn_pause = IupButton ( "pause", "btn_pause_act" ); btn_accelerate = IupButton ( "accelerate", "btn_accelerate_act" ); btn_decelerate = IupButton ( "decelerate", "btn_decelerate_act" ); btn_show = IupButton ( "show", "btn_show_act" ); createimg_s(); IupSetAttributes( btn_start, "IMAGE = img_start, TIP = Start" ); IupSetAttributes( btn_pause, "IMAGE = img_play, TIP = Pause" ); IupSetAttributes( btn_accelerate, "IMAGE = img_forward, TIP = Accelerate" ); IupSetAttributes( btn_decelerate, "IMAGE = img_rewind, TIP = Decelerate" ); IupSetAttributes( btn_show, "IMAGE = img_show, TIP = Show" ); hbox = IupHbox ( IupFill(), btn_pause, btn_start, btn_decelerate, btn_accelerate, btn_show, IupFill(), NULL ); vbox = IupVbox ( gauge , hbox, NULL ); IupSetAttribute(vbox, "MARGIN", "10x10"); IupSetAttribute(vbox, "GAP", "5"); dlg = IupDialog(vbox); IupSetAttributes(dlg, "TITLE=IupGauge"); IupSetCallback(btn_pause, "ACTION", (Icallback) btn_pause_cb ); IupSetCallback(btn_start, "ACTION", (Icallback) btn_start_cb ); IupSetCallback(btn_accelerate, "ACTION", (Icallback) btn_accelerate_cb ); IupSetCallback(btn_decelerate, "ACTION", (Icallback) btn_decelerate_cb ); IupSetCallback(btn_show, "ACTION", (Icallback) btn_show_cb ); IupSetFunction( "IDLE_ACTION", (Icallback) idle_cb); IupShowXY(dlg,IUP_CENTER,IUP_CENTER); IupMainLoop (); IupClose (); return EXIT_SUCCESS; }