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 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); }
int main(int argc, char **argv) { Ihandle *dlg, *list1, *list2, *list3, *list4, *box1, *box2, *box3, *box4, *lbl, *bt1, *bt2, *bt3, *bt4, *btok, *btcancel, *txt1, *txt2; IupOpen(&argc, &argv); bt1 = IupButton("(1)Drop+Edit", NULL); IupSetCallback(bt1, "ACTION", (Icallback)bt_cb); bt2 = IupButton("(2)Drop", NULL); IupSetCallback(bt2, "ACTION", (Icallback)bt_cb); bt3 = IupButton("(3)List+Edit", NULL); IupSetCallback(bt3, "ACTION", (Icallback)bt_cb); bt4 = IupButton("(4)List", NULL); IupSetCallback(bt4, "ACTION", (Icallback)bt_cb); list1 = IupList(NULL); IupSetCallback(list1, "ACTION", (Icallback)list_cb); list2 = IupList(NULL); IupSetCallback(list2, "ACTION", (Icallback)list_cb); list3 = IupList(NULL); IupSetCallback(list3, "ACTION", (Icallback)list_cb); list4 = IupList(NULL); IupSetCallback(list4, "ACTION", (Icallback)list_cb); IupSetAttributes(list1, "1=\"US$ 1000\", 2=\"US$ 2000\", 3=\"US$ 30000000\", 4=\"US$ 4000\", 5=\"US$ 5000\", 6=\"US$ 6000\", 7=\"US$ 7000\"," "EXPAND=HORIZONTAL, EDITBOX=YES, DROPDOWN=YES, VISIBLEITEMS=5, SHOWIMAGE=YES"); IupSetAttributeHandle(list1, "IMAGE1", load_image_LogoTecgraf()); IupSetAttributeHandle(list1, "IMAGE2", load_image_LogoTecgraf()); IupSetAttributeHandle(list1, "IMAGE3", load_image_Tecgraf()); IupSetAttributeHandle(list1, "IMAGE4", load_image_LogoTecgraf()); IupSetAttributes(list2, "1=\"R$ 1000\", 2=\"R$ 2000\", 3=\"R$ 3000\", 4=\"R$ 4000\", 5=\"R$ 5000\", 6=\"R$ 6000\", 7=\"R$ 7000\"," "EXPAND=HORIZONTAL, DROPDOWN=YES, VISIBLEITEMS=5, SHOWIMAGE=YES"); IupSetAttributeHandle(list2, "IMAGE1", load_image_LogoTecgraf()); IupSetAttributeHandle(list2, "IMAGE2", load_image_LogoTecgraf()); IupSetAttributeHandle(list2, "IMAGE3", load_image_Tecgraf()); IupSetAttributeHandle(list2, "IMAGE4", load_image_LogoTecgraf()); IupSetAttributes(list3, "1=\"Char A\", 2=\"Char B\", 3=\"Char CCCCC\", 4=\"Char D\", 5=\"Char F\", 6=\"Char G\", 7=\"Char H\"," "EXPAND=YES, EDITBOX=YES, XXX_SPACING=4, SHOWIMAGE=YES"); IupSetAttributeHandle(list3, "IMAGE1", load_image_Test()); //IupSetAttributeHandle(list3, "IMAGE3", load_image_Test()); IupSetAttributeHandle(list3, "IMAGE5", load_image_Test()); IupSetAttributeHandle(list3, "IMAGE7", load_image_Test()); IupSetAttributeHandle(list1, "IMAGE3", load_image_Tecgraf()); IupSetAttributes(list4, "1=\"Number 1\", 2=\"Number 2\", 3=\"Number 3\", 4=\"Number 4\", 5=\"Number 5\", 6=\"Number 6\", 7=\"Number 7\"," "EXPAND=YES"); /* DRAG AND DROP TESTS ////////////////////////////////////*/ IupSetAttribute(list1, "DROPTARGET", "YES"); IupSetAttribute(list1, "DROPTYPES", "TEXT,STRING"); IupSetCallback (list1, "DROPDATA_CB", (Icallback)testDropData_cb); IupSetCallback (list1, "DROPMOTION_CB", (Icallback)testDropMotion_cb); IupSetAttribute(list1, "NAME", "list1"); IupSetAttribute(list2, "DROPTARGET", "YES"); IupSetAttribute(list2, "DROPTYPES", "TEXT,STRING"); IupSetCallback (list2, "DROPDATA_CB", (Icallback)testDropData_cb); IupSetCallback (list2, "DROPMOTION_CB", (Icallback)testDropMotion_cb); IupSetAttribute(list2, "NAME", "list2"); IupSetAttribute(list3, "DROPTARGET", "YES"); IupSetAttribute(list3, "DROPTYPES", "STRING"); IupSetCallback (list3, "DROPDATA_CB", (Icallback)testDropData_cb); IupSetCallback (list3, "DROPMOTION_CB", (Icallback)testDropMotion_cb); IupSetAttribute(list3, "NAME", "list3"); IupSetAttribute(list4, "DRAGSOURCE", "YES"); IupSetAttribute(list4, "DRAGTYPES", "TEXT"); IupSetCallback (list4, "DRAGBEGIN_CB", (Icallback)testDragBegin_cb); IupSetCallback (list4, "DRAGDATASIZE_CB", (Icallback)testDragDataSize_cb); IupSetCallback (list4, "DRAGDATA_CB", (Icallback)testDragData_cb); IupSetCallback (list4, "DRAGEND_CB", (Icallback)testDragEnd_cb); IupSetAttribute(list4, "DRAGCURSOR", "Tecgraf"); IupSetAttribute(list4, "NAME", "list4"); txt1 = IupText(NULL); IupSetAttribute(txt1, "MULTILINE", "YES"); IupSetAttribute(txt1, "RASTERSIZE", "150x90"); IupSetAttribute(txt1, "VALUE", "Drop Text Here"); IupSetAttribute(txt1, "DROPTARGET", "YES"); IupSetAttribute(txt1, "DROPTYPES", "TEXT"); IupSetCallback (txt1, "DROPDATA_CB", (Icallback)testDropData_cb); IupSetCallback (txt1, "DROPMOTION_CB", (Icallback)testDropMotion_cb); IupSetAttribute(txt1, "NAME", "txt1"); txt2 = IupText(NULL); IupSetAttribute(txt2, "MULTILINE", "YES"); IupSetAttribute(txt2, "RASTERSIZE", "150x90"); IupSetAttribute(txt2, "VALUE", "Drag Text From Here"); IupSetAttribute(txt2, "DRAGSOURCE", "YES"); IupSetAttribute(txt2, "DRAGTYPES", "TEXT,STRING"); IupSetAttribute(txt2, "DRAGSOURCEMOVE", "Yes"); IupSetCallback (txt2, "DRAGBEGIN_CB", (Icallback)testDragBegin_cb); IupSetCallback (txt2, "DRAGDATASIZE_CB", (Icallback)testDragDataSize_cb); IupSetCallback (txt2, "DRAGDATA_CB", (Icallback)testDragData_cb); IupSetCallback (txt2, "DRAGEND_CB", (Icallback)testDragEnd_cb); IupSetAttribute(txt2, "NAME", "txt2"); /*////////////////////////////////////////////////////////*/ IupSetAttribute(bt1, "_LIST", (char*)list1); IupSetAttribute(bt2, "_LIST", (char*)list2); IupSetAttribute(bt3, "_LIST", (char*)list3); IupSetAttribute(bt4, "_LIST", (char*)list4); IupSetAttribute(list1, "_BUTTON", (char*)bt1); IupSetAttribute(list2, "_BUTTON", (char*)bt2); IupSetAttribute(list3, "_BUTTON", (char*)bt3); IupSetAttribute(list4, "_BUTTON", (char*)bt4); IupSetAttribute(bt1, "BGCOLOR", "192 192 192"); IupSetAttribute(bt2, "BGCOLOR", "192 192 192"); IupSetAttribute(bt3, "BGCOLOR", "192 192 192"); IupSetAttribute(bt4, "BGCOLOR", "192 192 192"); IupSetCallback(list1, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(list1, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(list2, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(list2, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(list3, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(list3, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(list4, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(list4, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(list1, "EDIT_CB", (Icallback)edit_cb); IupSetCallback(list3, "EDIT_CB", (Icallback)edit_cb); /* IupSetAttribute(list3, "READONLY", "YES"); */ box1 = IupVbox(list1, bt1, txt1, txt2, NULL); box2 = IupVbox(list2, bt2, NULL); box3 = IupVbox(list3, bt3, NULL); box4 = IupVbox(list4, bt4, NULL); lbl = IupLabel(""); IupSetAttribute(lbl, "EXPAND", "HORIZONTAL"); btok = IupButton("OK", NULL); IupSetCallback(btok, "ACTION", (Icallback)btclose_cb); IupSetHandle("btok", btok); btcancel = IupButton("Cancel", "btclose_cb"); IupSetCallback(btcancel, "ACTION", (Icallback)btclose_cb); IupSetHandle("btcancel", btcancel); IupSetAttribute(btok, "_LIST1", (char*)list1); IupSetAttribute(btok, "_LIST2", (char*)list2); IupSetAttribute(btok, "_LIST3", (char*)list3); IupSetAttribute(btok, "_LIST4", (char*)list4); dlg = IupDialog(IupSetAttributes(IupVbox(IupHbox(box1, box2, box3, box4, NULL), lbl, btok, btcancel, NULL),"MARGIN=10x10, GAP=10")); IupSetAttribute(dlg, "TITLE", "IupList Example"); IupSetAttribute(dlg, "_LABEL", (char*)lbl); IupSetAttribute(dlg, "DEFAULTENTER", "btok"); IupSetAttribute(dlg, "DEFAULTESC", "btcancel"); // IupSetAttribute(IupGetChild(dlg, 0), "BGCOLOR", "92 92 255"); // IupSetAttribute(dlg, "BACKGROUND", "200 10 80"); // IupSetAttribute(dlg, "BGCOLOR", "92 92 255"); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupMainLoop(); IupClose(); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { Ihandle *dlg, *canvas, *menu, *menu_file, *menu_edit, *menu_help, *menu_create; /* Initializes IUP */ IupOpen(&argc, &argv); IupSetHandle("image_tec", load_image_LogoTecgraf()); IupSetHandle("image_test", load_image_Test()); IupSetHandle("image_test_pressed", load_image_Test_pressed()); /* Creates menu create */ menu_create = IupMenu( IupItem("Line", "item_cb"), IupItem("Circle", "item_cb"), IupSetCallbacks(IupSubmenu("Triangle", IupSetAttributes(IupMenu( IupSetCallbacks(IupSetAttributes(IupItem("Equilateral", "item_cb"), "VALUE=ON"), "HIGHLIGHT_CB", highlight_cb, NULL), IupSetCallbacks(IupItem("Isoceles", "item_cb"), "HIGHLIGHT_CB", highlight_cb, NULL), IupSetCallbacks(IupItem("Scalenus", "item_cb"), "HIGHLIGHT_CB", highlight_cb, NULL), NULL), "RADIO=YES")), "HIGHLIGHT_CB", highlight_cb, NULL), NULL); IupSetCallbacks(menu_create, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL); // IupSetAttribute(menu_create, "BGCOLOR", "92 92 255"); /* Creates three menus that will be inside submenus */ menu_file = IupMenu( IupSetAttributes(IupItem("Item with Image \tCtrl+M", "item_cb"), "IMAGE=image_tec"), IupSetCallbacks(IupSetAttributes(IupItem("Toggle using &VALUE", NULL), "VALUE=ON, KEY=KcV"), "ACTION", item_toggle_cb, NULL), IupSetAttributes(IupItem("Auto &Toggle Text", "item_cb"), "AUTOTOGGLE=YES"), IupSetAttributes(IupItem("Auto &Toggle Image", "item_cb"), "AUTOTOGGLE=YES, IMAGE=image_test, IMPRESS=image_test_pressed"), IupItem("Big Image", "item_cb"), IupSeparator(), IupSetCallbacks(IupItem("Exit (Destroy)", NULL), "ACTION", item_destroy_cb, NULL), IupSetCallbacks(IupItem("E&xit (Close)", NULL), "ACTION", item_close_cb, NULL), NULL); menu_edit = IupMenu( IupSetCallbacks(IupItem("Active Next", NULL), "ACTION", item_active_cb, NULL), IupSetCallbacks(IupItem("Rename Next", NULL), "ACTION", item_rename_cb, NULL), IupSetCallbacks(IupItem("Set Next Image", NULL), "ACTION", item_image_cb, NULL), IupSetAttributes(IupItem("Item w/ Acc\tCtrl+A", "item_cb"), "IMAGE=dummy"), IupSeparator(), IupSetAttributes(IupSubmenu("Create", menu_create), "IMAGE=image_tec"), NULL); menu_help = IupMenu( IupSetCallbacks(IupItem("Append", NULL), "ACTION", item_add_cb, "HELP_CB", item_help_cb, NULL), IupSetCallbacks(IupItem("Insert", NULL), "ACTION", item_insert_cb, "HELP_CB", item_help_cb, NULL), IupSetCallbacks(IupItem("Remove", NULL), "ACTION", item_remove_cb, "HELP_CB", item_help_cb, NULL), IupSeparator(), NULL); IupSetAttributeHandle(IupGetChild(menu_file, 4), "TITLEIMAGE", load_image_Tecgraf()); IupSetCallbacks(menu_edit, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL); /* Creates main menu with file menu */ menu = IupMenu( IupSetCallbacks(IupSetAttributes(IupSubmenu("Submenu", menu_file), "KEY=K_S, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL), IupSetCallbacks(IupSubmenu("&Edit", menu_edit), "HIGHLIGHT_CB", highlight_cb, NULL), IupSubmenu("Help", menu_help), IupSetCallbacks(IupSetAttributes(IupItem("Item", "item_cb"), "KEY=K_I, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL), NULL); /* Registers callbacks */ IupSetFunction("item_cb", item_cb); //IupSetAttribute(menu, "BGCOLOR", "92 92 255"); //IupSetAttribute(menu, "BGCOLOR", "173 177 194"); // Motif BGCOLOR for documentation canvas = IupCanvas(NULL); IupSetCallback(canvas, "BUTTON_CB", (Icallback)button); IupSetCallback(canvas, "K_m", (Icallback)k_m); // IupSetCallback(canvas, "KILLFOCUS_CB", killfocus); // IupSetCallback(canvas, "GETFOCUS_CB", getfocus); dlg = IupDialog(canvas); IupSetAttributeHandle(dlg, "MENU", menu); IupSetAttributes(dlg, "TITLE=\"IupMenu Test\", SIZE=QUARTERxQUARTER"); /* Shows dlg in the center of the screen */ IupShowXY(dlg, IUP_CENTER, IUP_CENTER); /* Initializes IUP main loop */ IupMainLoop(); /* Finishes IUP */ IupClose (); /* Program finished sucessfully */ return 0; }
void GLCanvasCubeTest(void) { Ihandle *dlg, *canvas, *box, *gtoggle, *gtoggle1, *gtoggle2, *hbox, *vbox, *glabel, *gsep1, *gsep2, *gbutton1, *gbutton2, *pbar1, *pbar2, *glink, *gval1, *gval2, *gframe1, *gframe2, *gexp1, *gexp2, *image_open, *image_close, *image_high, *gframe3, *vbox2, *gtoggle3, *gtoggle4, *gtoggle5, *gsbox, *text, *vbox3, *matrix, *image_val; IupGLCanvasOpen(); IupGLControlsOpen(); IupControlsOpen(); glabel = IupGLLabel("Label"); // IupSetAttribute(glabel, "FGCOLOR", "255 255 255"); IupSetAttribute(glabel, "FONT", "Helvetica, 24"); IupSetAttributeHandle(glabel, "IMAGE", load_image_Tecgraf()); gbutton1 = IupGLButton("Button"); IupSetAttribute(gbutton1, "PADDING", "5x5"); //IupSetAttribute(gbutton1, "BGCOLOR", "245 0 245 92"); IupSetCallback(gbutton1, "ACTION", button_action_cb); IupSetAttribute(gbutton1, "NAME", "button1"); IupSetAttribute(gbutton1, "TIP", "Button Tip"); // IupSetAttribute(gbutton1, "RASTERSIZE", "x100"); if (0) { Ihandle* pressed_back = IupLoadImage("../test/pressed_back.png"); Ihandle* enabled_back = IupLoadImage("../test/enabled_back.png"); Ihandle* highlighted_back = IupLoadImage("../test/highlighted_back.png"); IupSetAttributeHandle(gbutton1, "BACKIMAGE", enabled_back); IupSetAttributeHandle(gbutton1, "BACKIMAGEPRESS", pressed_back); IupSetAttributeHandle(gbutton1, "BACKIMAGEHIGHLIGHT", highlighted_back); IupSetAttribute(gbutton1, "BORDERCOLOR", "0 0 0 0"); } gbutton2 = IupGLButton(NULL); IupSetAttribute(gbutton2, "PADDING", "5x5"); IupSetAttributeHandle(gbutton2, "IMAGE", load_image_FileSave()); IupSetCallback(gbutton2, "ACTION", button_action_cb); IupSetAttribute(gbutton2, "NAME", "button2"); gtoggle = IupGLToggle("Toggle"); IupSetAttribute(gtoggle, "PADDING", "5x5"); IupSetCallback(gtoggle, "ACTION", (Icallback)toggle_action_cb); IupSetAttribute(gtoggle, "NAME", "toggle"); gtoggle1 = IupGLToggle(NULL); IupSetAttribute(gtoggle1, "PADDING", "5x5"); IupSetAttributeHandle(gtoggle1, "IMAGE", load_image_Test()); IupSetCallback(gtoggle1, "ACTION", (Icallback)toggle_action_cb); IupSetAttribute(gtoggle1, "NAME", "toggle1"); gtoggle2 = IupGLToggle(NULL); IupSetAttribute(gtoggle2, "PADDING", "5x5"); IupSetAttributeHandle(gtoggle2, "IMAGE", load_image_Test()); IupSetCallback(gtoggle2, "ACTION", (Icallback)toggle_action_cb); IupSetAttribute(gtoggle2, "NAME", "toggle2"); gsep1 = IupGLSeparator(); glink = IupGLLink("http://www.tecgraf.puc-rio.br/iup", "IUP Toolkit"); IupSetCallback(glink, "ACTION", (Icallback)link_action_cb); pbar1 = IupGLProgressBar(); IupSetAttribute(pbar1, "VALUE", "0.3"); IupSetAttribute(pbar1, "SHOWTEXT", "Yes"); //image_val = IupLoadImage("../test/slider_handler.png"); gval1 = IupGLVal(); IupSetAttribute(gval1, "VALUE", "0.3"); IupSetCallback(gval1, "VALUECHANGED_CB", val_action_cb); IupSetAttribute(gval1, "PROGRESSBAR", (char*)pbar1); IupSetAttribute(gval1, "NAME", "val1"); IupSetAttribute(gval1, "TIP", "Val Tip"); //IupSetAttributeHandle(gval1, "IMAGE", image_val); hbox = IupHbox(glabel, gsep1, gbutton1, gtoggle, glink, pbar1, gval1, NULL); IupSetAttribute(hbox, "ALIGNMENT", "ACENTER"); IupSetAttribute(hbox, "MARGIN", "5x5"); IupSetAttribute(hbox, "GAP", "5"); pbar2 = IupGLProgressBar(); IupSetAttribute(pbar2, "VALUE", "0.3"); IupSetAttribute(pbar2, "ORIENTATION", "VERTICAL"); gval2 = IupGLVal(); IupSetAttribute(gval2, "VALUE", "0.3"); IupSetAttribute(gval2, "ORIENTATION", "VERTICAL"); IupSetCallback(gval2, "VALUECHANGED_CB", val_action_cb); IupSetAttribute(gval2, "PROGRESSBAR", (char*)pbar2); IupSetAttribute(gval2, "NAME", "val2"); gsep2 = IupGLSeparator(); IupSetAttribute(gsep2, "ORIENTATION", "HORIZONTAL"); vbox = IupVbox(gbutton2, gsep2, IupRadio(IupSetAttributes(IupVbox(gtoggle1, gtoggle2, NULL), "MARGIN=0x0")), pbar2, gval2, NULL); IupSetAttribute(vbox, "ALIGNMENT", "ACENTER"); IupSetAttribute(vbox, "MARGIN", "5x5"); IupSetAttribute(vbox, "GAP", "5"); gtoggle5 = IupGLToggle("Toggle"); IupSetAttribute(gtoggle5, "PADDING", "5x5"); IupSetCallback(gtoggle5, "ACTION", (Icallback)toggle_action_cb); IupSetAttribute(gtoggle5, "NAME", "toggle5"); IupSetAttribute(gtoggle5, "CHECKMARK", "Yes"); // IupSetAttribute(gtoggle5, "RIGHTBUTTON", "Yes"); gtoggle3 = IupGLToggle("Radio Toggle"); IupSetAttribute(gtoggle3, "PADDING", "5x5"); IupSetCallback(gtoggle3, "ACTION", (Icallback)toggle_action_cb); IupSetAttribute(gtoggle3, "NAME", "toggle3"); IupSetAttribute(gtoggle3, "CHECKMARK", "Yes"); gtoggle4 = IupGLToggle("Radio Toggle"); IupSetAttribute(gtoggle4, "PADDING", "5x5"); IupSetAttributeHandle(gtoggle4, "IMAGE", load_image_Test()); IupSetCallback(gtoggle4, "ACTION", (Icallback)toggle_action_cb); IupSetAttribute(gtoggle4, "NAME", "toggle4"); IupSetAttribute(gtoggle4, "CHECKMARK", "Yes"); // IupSetAttribute(gtoggle4, "RIGHTBUTTON", "Yes"); vbox2 = IupVbox( IupRadio(IupSetAttributes(IupVbox(gtoggle3, gtoggle4, NULL), "MARGIN=0x0")), gtoggle5, NULL); gsbox = IupSetAttributes(IupGLScrollBox(vbox2), "RASTERSIZE=90x90"); gsbox = IupGLSizeBox(gsbox); gframe1 = IupSetAttributes(IupGLFrame(hbox), "TITLE=Frame1"); gframe2 = IupSetAttributes(IupGLFrame(vbox), "BACKCOLOR=\"250 250 160 128\", FRAMECOLOR=\"250 250 160\""); gframe3 = IupSetAttributes(IupGLFrame(gsbox), "TITLE=Frame3, TITLEBOX=Yes"); // IupSetAttributeHandle(gframe3, "TITLEBACKIMAGE", load_image_Tecgraf()); gexp1 = IupSetAttributes(IupGLExpander(gframe1), "TITLE=Expander"); gexp2 = IupSetAttributes(IupGLExpander(gframe2), "BARPOSITION=LEFT"); text = IupText(NULL); IupSetAttribute(text, "VALUE", "Text"); matrix = IupMatrix(NULL); IupSetAttribute(matrix, "NUMLIN", "3"); IupSetAttribute(matrix, "NUMCOL", "2"); IupSetAttribute(matrix, "NUMLIN_VISIBLE", "3"); IupSetAttribute(matrix, "NUMCOL_VISIBLE", "2"); IupSetAttribute(matrix, "0:0", "Inflation"); IupSetAttribute(matrix, "1:0", "Medicine"); IupSetAttribute(matrix, "2:0", "Food"); IupSetAttribute(matrix, "3:0", "Energy"); IupSetAttribute(matrix, "0:1", "January 2000"); IupSetAttribute(matrix, "0:2", "February 2000"); IupSetAttribute(matrix, "1:1", "5.6"); IupSetAttribute(matrix, "2:1", "2.2"); IupSetAttribute(matrix, "3:1", "4.1"); IupSetAttribute(matrix, "1:2", "10"); IupSetAttribute(matrix, "2:2", "1"); IupSetAttribute(matrix, "3:2", "0.5"); // IupSetAttribute(matrix, "EXPAND", "No"); IupSetAttribute(matrix, "SCROLLBAR", "No"); vbox3 = IupVbox( text, matrix, NULL); vbox3 = IupSetAttributes(IupGLFrame(vbox3), "TITLE=Frame4"); canvas = IupGLCanvasBox( IupSetAttributes(gexp1, "HORIZONTALALIGN=ACENTER, VERTICALALIGN=ATOP, MOVEABLE=Yes, MOVETOTOP=Yes"), IupSetAttributes(gexp2, "HORIZONTALALIGN=ALEFT, VERTICALALIGN=ACENTER"), IupSetAttributes(gframe3, "MOVEABLE=Yes, POSITION=\"550,200\", MOVETOTOP=Yes"), IupSetAttributes(vbox3, "MOVEABLE=Yes, POSITION=\"250,350\""), NULL); IupSetAttribute(canvas, "DEPTH_SIZE", "16"); image_open = IupImage(16, 16, img_open); image_close = IupImage(16, 16, img_close); image_high = IupImage(16, 16, img_close); IupSetAttribute(image_open, "0", "BGCOLOR"); IupSetAttribute(image_open, "1", "192 192 192"); IupSetAttribute(image_close, "0", "BGCOLOR"); IupSetAttribute(image_close, "1", "192 192 192"); IupSetAttribute(image_high, "1", "192 192 192"); // IupSetAttribute(gexp1, "BARSIZE", "50"); // IupSetAttributeHandle(gexp1, "IMAGE", image_close); // IupSetAttributeHandle(gexp1, "IMOPEN", image_open); // IupSetAttribute(gexp1, "IMAGE", "img1"); IupSetCallback(gexp1, "ACTION", (Icallback)expand_cb); IupSetAttribute(gexp1, "EXTRABUTTONS", "3"); IupSetCallback(gexp1, "EXTRABUTTON_CB", (Icallback)extrabutton_cb); IupSetAttributeHandle(gexp1, "IMAGEEXTRA1", image_close); IupSetAttributeHandle(gexp1, "IMAGEEXTRAPRESS1", image_open); IupSetAttributeHandle(gexp1, "IMAGEEXTRAHIGHLIGHT1", image_high); IupSetAttributeHandle(gexp1, "IMAGEEXTRA2", image_close); IupSetAttributeHandle(gexp1, "IMAGEEXTRAPRESS2", image_open); IupSetAttributeHandle(gexp1, "IMAGEEXTRAHIGHLIGHT2", image_high); IupSetAttributeHandle(gexp1, "IMAGEEXTRA3", image_close); IupSetAttributeHandle(gexp1, "IMAGEEXTRAPRESS3", image_open); IupSetAttributeHandle(gexp1, "IMAGEEXTRAHIGHLIGHT3", image_high); //IupSetAttribute(gexp1, "REDRAWALL", "No"); IupSetCallback(canvas, "ACTION", action); IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb); IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb); IupSetAttribute(canvas, "BUFFER", "DOUBLE"); IupSetAttribute(canvas, "MARGIN", "10x10"); box = IupVbox(canvas, NULL); IupSetAttribute(box, "MARGIN", "25x25"); dlg = IupDialog(box); IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test"); IupSetAttribute(dlg, "RASTERSIZE", "800x600"); IupMap(dlg); IupGLMakeCurrent(canvas); printf("Vendor: %s\n", glGetString(GL_VENDOR)); printf("Renderer: %s\n", glGetString(GL_RENDERER)); printf("Version: %s\n", glGetString(GL_VERSION)); IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetAttribute(dlg, "RASTERSIZE", NULL); }