void TabsTest(void) { Ihandle *box, *frm1, *frm2, *dlg, *tabs; tabs = CreateTabs(1); box = IupHbox(tabs, frm1 = IupFrame(IupRadio(IupVbox(IupToggle("TOP", "cbType"), IupToggle("LEFT", "cbType"), IupToggle("BOTTOM", "cbType"), IupToggle("RIGHT", "cbType"), NULL))), frm2 = IupFrame(IupRadio(IupVbox(IupToggle("HORIZONTAL", "cbOrientation"), IupToggle("VERTICAL", "cbOrientation"), NULL))), IupVbox(IupSetAttributes(IupButton("Add Tab", "cbAddTab"), "TIP=\"Button Tip\""), IupButton("Insert Tab", "cbInsertTab"), IupButton("Remove Tab", "cbRemoveTab"), IupToggle("Inactive", "cbInactive"), IupButton("VALUEPOS=0", "cbValuePos"), NULL), NULL); IupSetAttribute(frm1, "MARGIN", "5x5"); IupSetAttribute(frm2, "MARGIN", "5x5"); IupSetAttribute(frm1, "GAP", "0"); IupSetAttribute(frm2, "GAP", "0"); IupSetAttribute(frm1, "TITLE", "Type"); IupSetAttribute(frm2, "TITLE", "Orientation"); IupSetAttribute(box, "MARGIN", "10x10"); IupSetAttribute(box, "GAP", "10"); dlg = IupDialog(box); IupSetAttribute(dlg, "TITLE", "IupTabs Test"); IupSetAttribute(dlg, "APP_TABS", (char*)tabs); // IupSetAttribute(box, "BGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); // IupSetAttributeHandle(dlg, "BACKGROUND", load_image_LogoTecgraf()); // IupSetAttribute(dlg, "FGCOLOR", "10 200 80"); // IupSetAttribute(dlg, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation // IupSetAttribute(dlg,"COMPOSITED","NO"); IupMap(dlg); IupSetAttribute(dlg, "SIZE", NULL); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetFunction("cbOrientation", (Icallback)cbOrientation); IupSetFunction("cbType", (Icallback)cbType); IupSetFunction("cbAddTab", (Icallback)cbAddTab); IupSetFunction("cbInsertTab", (Icallback)cbInsertTab); IupSetFunction("cbRemoveTab", (Icallback)cbRemoveTab); IupSetFunction("cbInactive", (Icallback)cbInactive); IupSetFunction("cbChildButton", (Icallback)cbChildButton); IupSetFunction("cbValuePos", (Icallback)cbValuePos); }
int main(int argc, char **argv) { Ihandle *dlg; Ihandle *list, *list_multiple, *list_dropdown; Ihandle *frm_medal, *frm_sport, *frm_prize; IupOpen(&argc, &argv); list = IupList ("list_act"); IupSetAttributes (list, "1=Gold, 2=Silver, 3=Bronze, 4=Tecgraf, 5=None," "SHOWIMAGE=YES, SHOWDRAGDROP=YES, XXX_SPACING=4, VALUE=4"); load_medal_images(); IupSetAttribute(list, "IMAGE1", "IMGGOLD"); IupSetAttribute(list, "IMAGE2", "IMGSILVER"); IupSetAttribute(list, "IMAGE3", "IMGBRONZE"); IupSetAttributeHandle(list, "IMAGE4", load_image_Tecgraf()); IupSetCallback(list, "DRAGDROP_CB", (Icallback)dragdrop_cb); // IupSetAttribute(list, "FONT", "Helvetica, Bold 40"); // IupSetAttribute(list, "AUTOHIDE", "NO"); frm_medal = IupFrame (list); IupSetAttribute (frm_medal, "TITLE", "Best medal"); list_multiple = IupList(NULL); IupSetAttributes (list_multiple, "1=\"100m dash\", 2=\"Long jump\", 3=\"Javelin throw\", 4=\"110m hurdlers\", 5=\"Hammer throw\",6=\"High jump\"," "MULTIPLE=YES, VALUE=\"+--+--\", SIZE=EIGHTHxEIGHTH"); IupSetCallback(list_multiple, "ACTION", (Icallback)list_multiple_cb); frm_sport = IupFrame (list_multiple); IupSetAttribute (frm_sport, "TITLE", "Competed in"); list_dropdown = IupList (NULL); IupSetAttributes (list_dropdown, "1=\"Less than US$ 1000\", 2=\"US$ 2000\", 3=\"US$ 5000\", 4=\"US$ 10000\", 5=\"US$ 20000\", 6=\"US$ 50000\", 7=\"More than US$ 100000\"," "SHOWIMAGE=YES, DROPDOWN=YES, VISIBLE_ITEMS=3"); IupSetAttributeHandle(list_dropdown, "IMAGE1", IupImageRGB(20, 20, image_data_24)); IupSetAttributeHandle(list_dropdown, "IMAGE2", IupImageRGB(20, 20, image_data_24)); IupSetAttributeHandle(list_dropdown, "IMAGE3", load_image_Tecgraf()); frm_prize = IupFrame (list_dropdown); IupSetAttribute (frm_prize, "TITLE", "Prizes won"); dlg = IupDialog (IupHbox (frm_medal, frm_sport, frm_prize, NULL)); IupSetAttribute (dlg, "TITLE", "IupList Example"); IupShowXY (dlg, IUP_CENTER, IUP_CENTER); // IupSetAttribute(IupGetChild(dlg, 0), "BGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); // IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); IupMainLoop (); IupClose (); return EXIT_SUCCESS; }
void guiVal_OnInit( void ) { guiVal->tbValue = IupText( NULL ); guiVal->hlType = IupHList( NULL ); IupSetStrAttribute( guiVal->hlType, "1", "schar" ); IupSetStrAttribute( guiVal->hlType, "2", "uchar" ); IupSetStrAttribute( guiVal->hlType, "3", "short" ); IupSetStrAttribute( guiVal->hlType, "4", "ushort" ); IupSetStrAttribute( guiVal->hlType, "5", "int" ); IupSetStrAttribute( guiVal->hlType, "6", "uint" ); IupSetStrAttribute( guiVal->hlType, "7", "long" ); IupSetStrAttribute( guiVal->hlType, "8", "ulong" ); IupSetStrAttribute( guiVal->hlType, "9", "lint" ); IupSetStrAttribute( guiVal->hlType, "10", "ulint" ); IupSetStrAttribute( guiVal->hlType, "11", "fpn" ); IupSetStrAttribute( guiVal->hlType, "12", "dpn" ); IupSetStrAttribute( guiVal->hlType, "13", "lpn" ); guiVal->value.vb = IupVbox( guiVal->tbValue, guiVal->hlType, NULL ); guiVal->value.fset = IupFrame( guiVal->value.vb ); IupSetAttribute( guiVal->value.fset, IUP_SIZE, "100x30" ); IupSetAttribute( guiVal->value.fset, IUP_EXPAND, IUP_HORIZONTAL ); IupAppend( guiVal->main.vb, guiVal->value.fset ); IupMap( guiVal->value.fset ); guiVal_OnLang(); }
void iupwinVersion(void) { Ihandle* dial, *ok; dial = IupDialog(IupVbox(IupFrame(IupVbox( IupLabel(IupVersion()), IupLabel(IUP_VERSION_DATE), IupLabel(IUP_COPYRIGHT), NULL)), ok = IupButton("Ok", NULL), NULL)); IupSetCallback(ok, "ACTION", (Icallback)ok_cb); IupSetAttribute(dial,IUP_TITLE,"IUP"); IupSetAttribute(dial,IUP_MENUBOX,IUP_NO); IupSetAttribute(dial,IUP_MINBOX,IUP_NO); IupSetAttribute(dial,IUP_MAXBOX,IUP_NO); IupSetAttribute(dial,IUP_RESIZE,IUP_NO); IupSetAttribute(dial,"GAP","5"); IupSetAttribute(dial,"MARGIN","5"); IupPopup(dial, IUP_CENTER, IUP_CENTER); IupDestroy(dial); }
int main(int argc, char **argv) { IupOpen(&argc, &argv); IupControlsOpen(); bt = IupButton("Test", ""); IupSetAttribute(bt, "EXPAND", "YES"); box = IupSbox(bt); IupSetAttribute(box, "DIRECTION", "SOUTH"); ml = IupMultiLine(NULL); IupSetAttribute(ml, IUP_EXPAND, "YES"); vbox = IupVbox(box, ml, NULL); lb = IupLabel("Label"); IupSetAttribute(lb, IUP_EXPAND, "YES"); dg = IupDialog(IupHbox(vbox, IupFrame(lb), NULL)); IupSetAttribute(dg, IUP_MARGIN, "10x20"); //IupSetAttribute(dg,"COMPOSITED", "YES"); //IupSetAttribute(dg,"LAYERED", "YES"); //IupSetAttribute(dg,"LAYERALPHA", "192"); IupShow(dg); IupMainLoop(); IupDestroy(dg); IupControlsClose(); IupClose(); return 1; }
void GLCanvasCubeTest(void) { Ihandle *dlg, *canvas, *box; IupGLCanvasOpen(); box = IupVbox(NULL); IupSetAttribute(box, "MARGIN", "5x5"); canvas = IupGLCanvas(NULL); IupSetCallback(canvas, "ACTION", action); IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb); IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb); // IupSetAttribute(canvas, "BUFFER", "DOUBLE"); IupSetAttribute(canvas, "RASTERSIZE", "300x300"); IupAppend(box, canvas); dlg = IupDialog(IupSetAttributes(IupFrame(box), "TITLE=Test")); IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test"); // IupSetAttribute(dlg, "COMPOSITED", "YES"); IupMap(dlg); IupGLMakeCurrent(canvas); // init(); printf("Vendor: %s\n", glGetString(GL_VENDOR)); printf("Renderer: %s\n", glGetString(GL_RENDERER)); printf("Version: %s\n", glGetString(GL_VERSION)); IupSetAttribute(canvas, "RASTERSIZE", NULL); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); }
void ClassInfo(void) { Ihandle *dialog, *box, *lists, *listClasses, *listAttributes, *listCallbacks, *labelInfo; listClasses = IupList(NULL); /* list of registered classes */ listAttributes = IupList(NULL); /* list of attributes of the selected class */ listCallbacks = IupList(NULL); /* list of callbacks of the selected class */ IupSetAttributes(listClasses, "NAME=listClasses, SIZE= 70x85, EXPAND=VERTICAL"); IupSetAttributes(listAttributes, "NAME=listAttributes, SIZE=120x85, EXPAND=VERTICAL"); IupSetAttributes(listCallbacks, "NAME=listCallbacks, SIZE=120x85, EXPAND=VERTICAL"); IupSetCallback(listClasses, "ACTION", (Icallback) classesList_ActionCB); IupSetCallback(listAttributes, "ACTION", (Icallback) attributesList_ActionCB); IupSetCallback(listCallbacks, "ACTION", (Icallback) callbacksList_ActionCB); labelInfo = IupLabel(NULL); IupSetAttribute(labelInfo, "SIZE", "x50"); IupSetAttribute(labelInfo, "EXPAND", "HORIZONTAL"); IupSetAttribute(labelInfo, "NAME", "labelInfo"); lists = IupVbox( IupHbox( IupSetAttributes(IupFrame(IupVbox(listClasses, NULL)), "TITLE=Classes"), IupSetAttributes(IupFrame(IupVbox(listAttributes, NULL)), "TITLE=Attributes"), IupSetAttributes(IupFrame(IupVbox(listCallbacks, NULL)), "TITLE=Callbacks"), NULL), IupHbox( IupSetAttributes(IupFrame(IupHbox(labelInfo, NULL)), "TITLE=Info, MARGIN=3x3"), NULL), NULL); box = IupHbox(lists, NULL); IupSetAttributes(lists,"MARGIN=10x10, GAP=10"); dialog = IupDialog(box); IupSetAttribute(dialog, "TITLE", "Iup Classes Information"); IupShowXY(dialog, IUP_CENTER, IUP_CENTER); PopulateListOfClasses(dialog); }
void MatrixCbsTest(void) { Ihandle *dlg, *bt; IupMatrixExOpen(); IupSetFunction("removeline", (Icallback)removeline); IupSetFunction("addline", (Icallback)addline); IupSetFunction("removecol", (Icallback)removecol); IupSetFunction("addcol", (Icallback)addcol); IupSetFunction("redraw", (Icallback)redraw); createmenu(); bt = IupButton("Button", NULL); IupSetCallback(bt, "ACTION", bt_cb); IupSetAttribute(bt, "CANFOCUS", "NO"); dlg = IupDialog( // IupZbox( IupTabs( IupSetAttributes( IupVbox((create_mat(1)), bt, IupText(""), IupLabel("Label Text"), IupFrame(IupVal("HORIZONTAL")), NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"), IupSetAttributes( IupVbox(IupFrame(create_mat(2)), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), // NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), // NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), NULL)); IupSetAttribute(dlg,"TITLE", "IupMatrix"); IupSetAttribute(dlg,"MENU", "mymenu"); IupSetAttributeHandle(dlg,"DEFAULTENTER", bt); // IupSetAttribute(dlg,"BGCOLOR", "255 0 255"); //IupSetAttribute(dlg,"COMPOSITED", "YES"); //IupSetAttribute(dlg,"OPACITY", "192"); IupShowXY(dlg,IUP_CENTER,IUP_CENTER); }
int main(int argc, char **argv) { Ihandle *dlg; Ihandle *list1, *list2; Ihandle *frm_medal1, *frm_medal2; IupOpen(&argc, &argv); list1 = IupList (NULL); IupSetAttributes(list1, "1=Gold, 2=Silver, 3=Bronze, 4=Latão, 5=None," "SHOWIMAGE=YES, DRAGDROPLIST=YES, XXX_SPACING=4, VALUE=4"); load_medal_images(); IupSetAttribute(list1, "IMAGE1", "IMGGOLD"); IupSetAttribute(list1, "IMAGE2", "IMGSILVER"); IupSetAttribute(list1, "IMAGE3", "IMGBRONZE"); //IupSetAttribute(list1, "MULTIPLE", "YES"); IupSetAttribute(list1, "DRAGSOURCE", "YES"); //IupSetAttribute(list1, "DRAGSOURCEMOVE", "YES"); IupSetAttribute(list1, "DRAGTYPES", "ITEMLIST"); frm_medal1 = IupFrame (list1); IupSetAttribute (frm_medal1, "TITLE", "List 1"); list2 = IupList (NULL); IupSetAttributes(list2, "1=Açaí, 2=Cajá, 3=Pêssego, 4=Limão, 5=Morango, 6=Coco," "SHOWIMAGE=YES, DRAGDROPLIST=YES, XXX_SPACING=4, VALUE=4"); IupSetAttribute(list2, "DROPTARGET", "YES"); IupSetAttribute(list2, "DROPTYPES", "ITEMLIST"); frm_medal2 = IupFrame (list2); IupSetAttribute (frm_medal2, "TITLE", "List 2"); dlg = IupDialog (IupHbox (frm_medal1, frm_medal2, NULL)); IupSetAttribute (dlg, "TITLE", "IupList Example"); IupShowXY (dlg, IUP_CENTER, IUP_CENTER); IupMainLoop (); IupClose (); return EXIT_SUCCESS; }
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 int cbAddTab(Ihandle* ih) { Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); Ihandle *vbox; vbox = IupFrame(IupVbox(IupLabel("Label XXX"), IupButton("Button XXX", "cbChildButton"), NULL)); IupSetAttribute(vbox, "TABTITLE", "XXX"); IupSetAttribute(vbox, "TITLE", "TABS XXX"); IupAppend(tabs, vbox); IupMap(vbox); IupRefresh(tabs); /* update children layout */ return IUP_DEFAULT; }
static int cbInsertTab(Ihandle* ih) { Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS"); Ihandle* ref_vbox = IupGetHandle(IupGetAttribute(tabs, "VALUE")); Ihandle *vbox; vbox = IupFrame(IupVbox(IupLabel("Label YYY"), IupButton("Button YYY", "cbChildButton"), NULL)); IupSetAttribute(vbox, "TABTITLE", "YYY"); IupSetAttribute(vbox, "TITLE", "TABS YYY"); IupInsert(tabs, ref_vbox, vbox); IupMap(vbox); IupRefresh(tabs); /* update children layout */ return IUP_DEFAULT; }
/* Main program */ int main(int argc, char **argv) { Ihandle *dlg; IupOpen(&argc, &argv); IupControlsOpen(); IupSetFunction("removeline", (Icallback)removeline); IupSetFunction("addline", (Icallback)addline); IupSetFunction("removecol", (Icallback)removecol); IupSetFunction("addcol", (Icallback)addcol); IupSetFunction("redraw", (Icallback)redraw); createmenu(); dlg = IupDialog( IupTabs( IupSetAttributes( IupVbox((create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"), IupSetAttributes( IupVbox(IupFrame(create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), // NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), NULL)); IupSetAttribute(dlg,IUP_TITLE, "IupMatrix"); IupSetAttribute(dlg,IUP_MENU, "mymenu"); // IupSetAttribute(dlg,"BGCOLOR", "255 0 255"); //IupSetAttribute(dlg,"COMPOSITED", "YES"); //IupSetAttribute(dlg,"LAYERED", "YES"); //IupSetAttribute(dlg,"LAYERALPHA", "192"); IupShowXY(dlg,IUP_CENTER,IUP_CENTER) ; IupMainLoop(); iupmaskMatRemove(IupGetHandle("mat1"), 2, 1) ; iupmaskMatRemove(IupGetHandle("mat2"), 2, 1) ; IupDestroy(dlg); IupControlsClose(); IupClose(); return 0; }
void iupVersionDlg(void) { Ihandle* dlg; dlg = IupDialog(IupVbox(IupFrame(IupVbox( IupLabel(IupVersion()), IupLabel(IUP_VERSION_DATE), IupLabel(IUP_COPYRIGHT), NULL)), IupButton("OK", NULL), NULL)); IupSetAttribute(dlg,"TITLE","IUP Version"); IupSetAttribute(dlg,"DIALOGFRAME","YES"); IupSetAttribute(dlg,"DIALOGHINT","YES"); IupSetAttribute(dlg,"GAP","10"); IupSetAttribute(dlg,"MARGIN","10x10"); IupPopup(dlg, IUP_CENTER, IUP_CENTER); IupDestroy(dlg); }
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 */ }
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; }
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; }
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"); } }
void ScrollBoxTest(void) { Ihandle *mnu, *_hbox_1, *_cnv_1, *_vbox_1, *dlg, *img, *_vbox_2, *_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, 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("Tab0"), NULL), IupVbox(IupLabel("Tab1"), NULL), IupVbox(IupLabel("Tab2"), 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","300x150"); IupSetAttribute(tree,"TIP","Tree TIP"); IupSetAttribute(tree,"EXPAND","NO"); 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,"EXPAND","NO"); IupSetAttribute(_cnv_1,"RASTERSIZE","200x100"); 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), IupHbox(IupSetAttributes(IupFrame(IupHbox(create_matrix(), NULL)), "TITLE=IupMatrix"), NULL), NULL); IupSetAttribute(_vbox_1,"MARGIN","5x5"); IupSetAttribute(_vbox_1,"GAP","5"); // _vbox_2 = IupVbox(IupSetAttributes(IupScrollBox(_vbox_1), "RASTERSIZE=400x300"), NULL); _vbox_2 = IupVbox(IupScrollBox(_vbox_1), NULL); IupSetAttribute(_vbox_2,"MARGIN","20x20"); dlg = IupDialog(_vbox_2); IupSetHandle("dlg",dlg); IupSetAttribute(dlg,"MENU","mnu"); IupSetAttribute(dlg,"TITLE","IupDialog Title"); // IupSetAttribute(dlg,"COMPOSITED","YES"); /* Windows Only */ // IupSetAttribute(dlg, "OPACITY", "192"); // IupSetAttribute(dlg, "RESIZE", "NO"); // 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"); IupSetAttribute(dlg,"RASTERSIZE","400x300"); IupSetCallback(dlg, "RESIZE_CB", (Icallback)resize_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); }
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", NULL), "CINDEX=1"), IupSetAttributes(IupButton("", NULL), "IMAGE=img1,CINDEX=2"), IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2,CINDEX=3"), NULL)); IupSetAttribute(_frm_1,"TITLE","IupButton"); IupSetAttribute(_frm_1,"CX","10"); IupSetAttribute(_frm_1,"CY","180"); _frm_2 = IupFrame( IupVbox( IupSetAttributes(IupLabel("Label Text"), "CINDEX=1"), IupSetAttributes(IupLabel(""), "SEPARATOR=HORIZONTAL,CINDEX=2"), IupSetAttributes(IupLabel(""), "IMAGE=img1,CINDEX=3"), NULL)); IupSetAttribute(_frm_2,"TITLE","IupLabel"); IupSetAttribute(_frm_2,"CX","200"); IupSetAttribute(_frm_2,"CY","250"); _frm_3 = IupFrame( IupVbox( IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON,CINDEX=1"), IupSetAttributes(IupToggle("", NULL), "IMAGE=img1,IMPRESS=img2,CINDEX=2"), IupSetAttributes(IupFrame(IupRadio(IupVbox( IupSetAttributes(IupToggle("Toggle Text", NULL), "CINDEX=3"), IupSetAttributes(IupToggle("Toggle Text", NULL), "CINDEX=4"), NULL))), "TITLE=IupRadio"), NULL)); IupSetAttribute(_frm_3,"TITLE","IupToggle"); IupSetAttribute(_frm_3,"CX","400"); IupSetAttribute(_frm_3,"CY","250"); _text_1 = IupText( NULL); IupSetAttribute(_text_1,"VALUE","IupText Text"); IupSetAttribute(_text_1,"SIZE","80x"); IupSetAttribute(_text_1,"CINDEX","1"); IupSetAttribute(_text_1,"CX","10"); IupSetAttribute(_text_1,"CY","100"); _ml_1 = IupMultiLine( NULL); IupSetAttribute(_ml_1,"VALUE","IupMultiline Text\nSecond Line\nThird Line"); IupSetAttribute(_ml_1,"SIZE","80x60"); IupSetAttribute(_ml_1,"CINDEX","1"); IupSetAttribute(_ml_1,"CX","200"); IupSetAttribute(_ml_1,"CY","100"); _list_1 = IupList( NULL); 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,"CINDEX","1"); IupSetAttribute(_list_1,"CX","10"); IupSetAttribute(_list_1,"CY","10"); _list_2 = IupList( NULL); IupSetAttribute(_list_2,"DROPDOWN","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,"CINDEX","2"); IupSetAttribute(_list_2,"CX","200"); IupSetAttribute(_list_2,"CY","10"); _list_3 = IupList( NULL); IupSetAttribute(_list_3,"EDITBOX","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,"CINDEX","3"); IupSetAttribute(_list_3,"CX","400"); IupSetAttribute(_list_3,"CY","10"); _cnv_1 = IupCanvas( NULL); IupSetAttribute(_cnv_1,"RASTERSIZE","100x100"); IupSetAttribute(_cnv_1,"POSX","0"); IupSetAttribute(_cnv_1,"POSY","0"); IupSetAttribute(_cnv_1,"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( _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,"SIZE","480x200"); hbox = IupSetAttributes(IupHbox(_cbox, NULL), "MARGIN=10x10"); dlg = IupDialog(hbox); IupSetHandle("dlg",dlg); IupSetAttribute(dlg,"TITLE","Cbox Test"); }
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; //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( IupSetAttributes(IupButton("Button Text", NULL), "PADDING=5x5"), IupSetAttributes(IupButton("Text", NULL), "IMAGE=img1, PADDING=5x5"), IupSetAttributes(IupButton(NULL, NULL), "IMAGE=img1"), IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2"), NULL)); IupSetAttribute(_frm_1,"TITLE","IupButton"); _frm_2 = IupFrame( IupVbox( IupLabel("Label Text"), IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), IupSetAttributes(IupLabel(NULL), "IMAGE=img1"), NULL)); IupSetAttribute(_frm_2,"TITLE","IupLabel"); _frm_3 = IupFrame( IupVbox( IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON"), // IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1,IMPRESS=img2"), IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1"), IupSetAttributes(IupFrame(IupRadio(IupVbox( IupToggle("Toggle Text", NULL), 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"); _ml_1 = IupMultiLine( NULL); IupSetAttribute(_ml_1,"VALUE","Multiline Text\nSecond Line\nThird Line"); IupSetAttribute(_ml_1,"EXPAND","YES"); IupSetAttribute(_ml_1,"SIZE","80x40"); _frm_4 = IupFrame(IupVbox( _text_1, _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"); _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"); _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"); _frm_5 = IupFrame(IupVbox( _list_1, _list_2, _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); pbar = IupGauge(); IupSetAttribute(pbar, "VALUE", "0.5"); tabs = IupTabs(IupVbox(NULL), IupVbox(NULL), IupVbox(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,"PADDING","5x5"); _cnv_1 = IupCanvas(NULL); IupSetAttribute(_cnv_1,"BGCOLOR","128 255 0"); IupSetAttribute(_cnv_1,"SCROLLBAR","HORIZONTAL"); IupSetAttribute(_cnv_1,"EXPAND","HORIZONTAL"); IupSetAttribute(_cnv_1,"RASTERSIZE","x100"); _vbox_1 = IupVbox( _hbox_1, IupHbox(IupSetAttributes(IupFrame(IupHbox(val, NULL)), "TITLE=IupVal"), IupSetAttributes(IupFrame(IupHbox(pbar, NULL)), "TITLE=IupGauge"), IupSetAttributes(IupFrame(IupHbox(tabs, NULL)), "TITLE=IupTabs"), NULL), IupSetAttributes(IupFrame(IupHbox(_cnv_1, NULL)), "TITLE=IupCanvas"), 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","NO"); /* Windows Only */ // 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"); // IupSetAttribute(dlg, "FONT", "Helvetica, 24"); // IupSetAttribute(dlg, "FONT", "-*-helvetica-*-r-*-*-18-*-*-*-*-*-*-*"); // IupSetAttribute(box, "FGCOLOR", "255 0 0"); IupShow(dlg); }
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; }
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; }
void GridBoxTest(void) { Ihandle *dlg; Ihandle *fr1; Ihandle *gbox; fr1 = IupFrame ( gbox = IupGridBox ( IupSetAttributes(IupLabel(""), ""), IupSetAttributes(IupLabel("col1"), "FONTSTYLE=Bold"), IupSetAttributes(IupLabel("col2"), "FONTSTYLE=Bold"), IupSetAttributes(IupLabel("lin1"), "FONTSTYLE=Bold"), IupSetAttributes(IupLabel("lbl"), "XSIZE=50x12"), IupSetAttributes(IupButton("but", NULL), "XSIZE=50"), IupSetAttributes(IupLabel("lin2"), "FONTSTYLE=Bold"), IupSetAttributes(IupLabel("label"), "XSIZE=x12"), IupSetAttributes(IupButton("button", NULL), "XEXPAND=Horizontal"), IupSetAttributes(IupLabel("lin3"), "FONTSTYLE=Bold"), IupSetAttributes(IupLabel("label large"), "XSIZE=x12"), IupSetAttributes(IupButton("button large", NULL), ""), NULL ) ); IupSetAttribute(gbox, "SIZECOL", "2"); IupSetAttribute(gbox, "SIZELIN", "3"); // IupSetAttribute(gbox, "HOMOGENEOUSLIN", "Yes"); // IupSetAttribute(gbox, "HOMOGENEOUSCOL", "Yes"); // IupSetAttribute(gbox, "EXPANDCHILDREN", "HORIZONTAL"); // IupSetAttribute(gbox, "NORMALIZESIZE", "BOTH"); // IupSetAttribute(gbox, "NORMALIZESIZE", "HORIZONTAL"); IupSetAttribute(gbox, "NUMDIV", "3"); // IupSetAttribute(gbox, "NUMDIV", "2"); // IupSetAttribute(gbox, "ORIENTATION", "VERTICAL"); // IupSetAttribute(gbox, "SIZECOL", "3"); // IupSetAttribute(gbox, "SIZELIN", "2"); // IupSetAttribute(gbox, "SIZE", "70x"); // IupSetAttribute(gbox, "NUMDIV", "AUTO"); // IupSetAttribute(gbox, "NORMALIZESIZE", "BOTH"); IupSetAttribute(gbox, "ALIGNMENTLIN", "ACENTER"); IupSetAttribute(gbox, "MARGIN", "10x10"); IupSetAttribute(gbox, "GAPLIN", "5"); IupSetAttribute(gbox, "GAPCOL", "5"); dlg = IupDialog ( IupHbox ( fr1, NULL ) ); IupSetAttribute(dlg, "TITLE", "IupGridBox Test"); IupSetAttribute(dlg, "MARGIN", "10x10"); IupSetAttribute(fr1, "MARGIN", "0x0"); /* avoid attribute propagation */ /* Shows dlg in the center of the screen */ IupShowXY(dlg, IUP_CENTER, IUP_CENTER); }
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; }
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"); }
static void CreateFrame(void) { lua_pushusertag(IupFrame(iuplua_checkihandle(1)), iuplua_tag); }
/* 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 ; }
/* 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; }
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); }