Exemple #1
0
int main(int argc, char **argv)
{
    Ihandle *win,*tabs,*buttons;

    IupOpen(&argc, &argv);      

    tabs = IupTabs(
        IupQuakeBindingLayout(),
        IupQuakeMouseLayout(),
        IupFill(),
        IupFill(),
        IupFill(),
        NULL
    );
    IupStoreAttribute(tabs, "TABTITLE0", "Keyboard");
    IupStoreAttribute(tabs, "TABTITLE1", "Mouse");
    IupStoreAttribute(tabs, "TABTITLE2", "Audio");
    IupStoreAttribute(tabs, "TABTITLE3", "Video");
    IupStoreAttribute(tabs, "TABTITLE4", "Multiplayer");

    IupStoreAttribute(tabs, "MARGIN", "2x2");

    buttons = IupHbox(
        IupSetCallbacks(IupButton("&Quit", "ACTION"), "ACTION", (Icallback)IupExitLoop, NULL),
        IupFill(),
        IupButton("&Save", NULL),
        IupFill(),
        IupButton("&Launch game", NULL),
        NULL
    );

    win = IupDialog(
            IupSetAttributes(
                IupVbox(
                    IupSetAttributes(
                        IupLabel("Action Quake 2 Configuration"),
                        "EXPAND=YES, ALIGNMENT=ACENTER:ACENTER, FONT=\"sans-serif, Bold 18\""
                    ),
                    tabs,
                    //buttons,
                    NULL
                ),
                "GAP=5, MARGIN=3x3"
            )
    );

    IupStoreAttribute(win, "TITLE", "Action Quake 2 Configuration");
    IupStoreAttribute(win, "RESIZE", "NO");

    IupShow(win);

    /* bug? */
    IupStoreAttribute(win, "SIZE", NULL);
    IupRefresh(win);

    IupMainLoop();
}
Exemple #2
0
void show_popup(void)
{
  Ihandle* menu_file = IupMenu(
    IupSetAttributes(IupItem("Item with Image", "item_cb"), "IMAGE=image_tec"),
    IupSetCallbacks(IupSetAttributes(IupItem("Toggle using VALUE", NULL), "VALUE=ON, KEY=K_V"), "ACTION", item_toggle_cb, "HIGHLIGHT_CB", highlight_cb, NULL), 
    IupSetAttributes(IupItem("Auto &Toggle", "item_cb"), "AUTOTOGGLE=YES, IMAGE=image_test, IMPRESS=image_test_pressed"), 
    IupSeparator(), 
    IupSetCallbacks(IupItem("E&xit (Close)", NULL), "ACTION", item_close_cb, NULL), 
    NULL);
  Ihandle* menu = IupMenu(
    IupSetCallbacks(IupSetAttributes(IupSubmenu("Submenu", menu_file), "KEY=K_S, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL),
    IupSetCallbacks(IupItem("Item", "item_cb"), "HIGHLIGHT_CB", highlight_cb, NULL),
    IupSetCallbacks(IupSetAttributes(IupItem("Item", "item_cb"), "VALUE=ON"), "HIGHLIGHT_CB", highlight_cb, NULL),
    IupSetCallbacks(IupSetAttributes(IupItem("Item", "item_cb"), "KEY=K_I, IMAGE=image_tec"), "HIGHLIGHT_CB", highlight_cb, NULL),
    NULL);
  IupSetCallbacks(menu_file, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL);
  IupSetCallbacks(menu, "OPEN_CB", open_cb, "MENUCLOSE_CB", menuclose_cb, NULL);
  IupPopup(menu, IUP_MOUSEPOS, IUP_MOUSEPOS);
  IupDestroy(menu);
}
Exemple #3
0
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);
}
Exemple #4
0
Ihandle* create_main_dialog(Ihandle *config)
{
  Ihandle *dlg, *vbox, *canvas, *menu;
  Ihandle *sub_menu_file, *file_menu, *item_exit, *item_new, *item_open, *item_save, *item_saveas, *item_revert;
  Ihandle *sub_menu_edit, *edit_menu, *item_copy, *item_paste, *item_print, *item_pagesetup;
  Ihandle *btn_copy, *btn_paste, *btn_new, *btn_open, *btn_save;
  Ihandle *sub_menu_help, *help_menu, *item_help, *item_about;
  Ihandle *sub_menu_view, *view_menu, *item_toolbar, *item_statusbar;
  Ihandle *item_zoomin, *item_zoomout, *item_actualsize;
  Ihandle *statusbar, *toolbar, *recent_menu, *item_background;

  canvas = IupCanvas(NULL);
  IupSetAttribute(canvas, "NAME", "CANVAS");
  IupSetAttribute(canvas, "SCROLLBAR", "Yes");
  IupSetAttribute(canvas, "DIRTY", "NO");  /* custom attribute */
  IupSetAttribute(canvas, "ZOOMFACTOR", "1");  /* custom attribute */
  IupSetCallback(canvas, "ACTION", (Icallback)canvas_action_cb);
  IupSetCallback(canvas, "DROPFILES_CB", (Icallback)dropfiles_cb);
  IupSetCallback(canvas, "MAP_CB", (Icallback)canvas_map_cb);
  IupSetCallback(canvas, "UNMAP_CB", (Icallback)canvas_unmap_cb);
  IupSetCallback(canvas, "WHEEL_CB", (Icallback)canvas_wheel_cb);
  IupSetCallback(canvas, "RESIZE_CB", (Icallback)canvas_resize_cb);

  statusbar = IupHbox(
    IupSetAttributes(IupLabel("(0, 0) = 0   0   0"), "EXPAND=HORIZONTAL, PADDING=10x5"),
    IupSetAttributes(IupLabel(NULL), "SEPARATOR=VERTICAL"),
    IupSetAttributes(IupLabel("0 x 0"), "SIZE=70x, PADDING=10x5, NAME=SIZELABEL, ALIGNMENT=ACENTER"),
    IupSetAttributes(IupLabel(NULL), "SEPARATOR=VERTICAL"),
    IupSetAttributes(IupLabel("100%"), "SIZE=30x, PADDING=10x5, NAME=ZOOMLABEL, ALIGNMENT=ARIGHT"),
    IupSetCallbacks(IupSetAttributes(IupButton(NULL, NULL), "IMAGE=IUP_ZoomOut, FLAT=Yes, TIP=\"Zoom Out (Ctrl+-)\""), "ACTION", zoomout_action_cb, NULL),
    IupSetCallbacks(IupSetAttributes(IupVal(NULL), "VALUE=0, MIN=-6, MAX=6, RASTERSIZE=150x25, NAME=ZOOMVAL"), "VALUECHANGED_CB", zoom_valuechanged_cb, NULL),
    IupSetCallbacks(IupSetAttributes(IupButton(NULL, NULL), "IMAGE=IUP_ZoomIn, FLAT=Yes, TIP=\"Zoom In (Ctrl++)\""), "ACTION", zoomin_action_cb, NULL),
    IupSetCallbacks(IupSetAttributes(IupButton(NULL, NULL), "IMAGE=IUP_ZoomActualSize, FLAT=Yes, TIP=\"Actual Size (Ctrl+0)\""), "ACTION", actualsize_action_cb, NULL),
    NULL);
  IupSetAttribute(statusbar, "NAME", "STATUSBAR");
  IupSetAttribute(statusbar, "ALIGNMENT", "ACENTER");

  item_new = IupItem("&New\tCtrl+N", NULL);
  IupSetAttribute(item_new, "IMAGE", "IUP_FileNew");
  IupSetCallback(item_new, "ACTION", (Icallback)item_new_action_cb);
  btn_new = IupButton(NULL, NULL);
  IupSetAttribute(btn_new, "IMAGE", "IUP_FileNew");
  IupSetAttribute(btn_new, "FLAT", "Yes");
  IupSetCallback(btn_new, "ACTION", (Icallback)item_new_action_cb);
  IupSetAttribute(btn_new, "TIP", "New (Ctrl+N)");
  IupSetAttribute(btn_new, "CANFOCUS", "No");

  item_open = IupItem("&Open...\tCtrl+O", NULL);
  IupSetAttribute(item_open, "IMAGE", "IUP_FileOpen");
  IupSetCallback(item_open, "ACTION", (Icallback)item_open_action_cb);
  btn_open = IupButton(NULL, NULL);
  IupSetAttribute(btn_open, "IMAGE", "IUP_FileOpen");
  IupSetAttribute(btn_open, "FLAT", "Yes");
  IupSetCallback(btn_open, "ACTION", (Icallback)item_open_action_cb);
  IupSetAttribute(btn_open, "TIP", "Open (Ctrl+O)");
  IupSetAttribute(btn_open, "CANFOCUS", "No");

  item_save = IupItem("&Save\tCtrl+S", NULL);
  IupSetAttribute(item_save, "NAME", "ITEM_SAVE");
  IupSetAttribute(item_save, "IMAGE", "IUP_FileSave");
  IupSetCallback(item_save, "ACTION", (Icallback)item_save_action_cb);
  btn_save = IupButton(NULL, NULL);
  IupSetAttribute(btn_save, "IMAGE", "IUP_FileSave");
  IupSetAttribute(btn_save, "FLAT", "Yes");
  IupSetCallback(btn_save, "ACTION", (Icallback)item_save_action_cb);
  IupSetAttribute(btn_save, "TIP", "Save (Ctrl+S)");
  IupSetAttribute(btn_save, "CANFOCUS", "No");

  item_saveas = IupItem("Save &As...", NULL);
  IupSetAttribute(item_saveas, "NAME", "ITEM_SAVEAS");
  IupSetCallback(item_saveas, "ACTION", (Icallback)item_saveas_action_cb);

  item_revert = IupItem("&Revert", NULL);
  IupSetAttribute(item_revert, "NAME", "ITEM_REVERT");
  IupSetCallback(item_revert, "ACTION", (Icallback)item_revert_action_cb);

  item_pagesetup = IupItem("Page Set&up...", NULL);
  IupSetCallback(item_pagesetup, "ACTION", (Icallback)item_pagesetup_action_cb);

  item_print = IupItem("&Print...\tCtrl+P", NULL);
  IupSetCallback(item_print, "ACTION", (Icallback)item_print_action_cb);

  item_exit = IupItem("E&xit", NULL);
  IupSetCallback(item_exit, "ACTION", (Icallback)item_exit_action_cb);

  item_copy = IupItem("&Copy\tCtrl+C", NULL);
  IupSetAttribute(item_copy, "NAME", "ITEM_COPY");
  IupSetAttribute(item_copy, "IMAGE", "IUP_EditCopy");
  IupSetCallback(item_copy, "ACTION", (Icallback)item_copy_action_cb);
  btn_copy = IupButton(NULL, NULL);
  IupSetAttribute(btn_copy, "IMAGE", "IUP_EditCopy");
  IupSetAttribute(btn_copy, "FLAT", "Yes");
  IupSetCallback(btn_copy, "ACTION", (Icallback)item_copy_action_cb);
  IupSetAttribute(btn_copy, "TIP", "Copy (Ctrl+C)");
  IupSetAttribute(btn_copy, "CANFOCUS", "No");

  item_paste = IupItem("&Paste\tCtrl+V", NULL);
  IupSetAttribute(item_paste, "NAME", "ITEM_PASTE");
  IupSetAttribute(item_paste, "IMAGE", "IUP_EditPaste");
  IupSetCallback(item_paste, "ACTION", (Icallback)item_paste_action_cb);
  btn_paste = IupButton(NULL, NULL);
  IupSetAttribute(btn_paste, "IMAGE", "IUP_EditPaste");
  IupSetAttribute(btn_paste, "FLAT", "Yes");
  IupSetCallback(btn_paste, "ACTION", (Icallback)item_paste_action_cb);
  IupSetAttribute(btn_paste, "TIP", "Paste (Ctrl+V)");
  IupSetAttribute(btn_paste, "CANFOCUS", "No");

  item_zoomin = IupItem("Zoom &In\tCtrl++", NULL);
  IupSetAttribute(item_zoomin, "IMAGE", "IUP_ZoomIn");
  IupSetCallback(item_zoomin, "ACTION", (Icallback)zoomin_action_cb);

  item_zoomout = IupItem("Zoom &Out\tCtrl+-", NULL);
  IupSetAttribute(item_zoomout, "IMAGE", "IUP_ZoomOut");
  IupSetCallback(item_zoomout, "ACTION", (Icallback)zoomout_action_cb);

  item_actualsize = IupItem("&Actual Size\tCtrl+0", NULL);
  IupSetAttribute(item_actualsize, "IMAGE", "IUP_ZoomActualSize");
  IupSetCallback(item_actualsize, "ACTION", (Icallback)actualsize_action_cb);

  item_background = IupItem("&Background...", NULL);
  IupSetCallback(item_background, "ACTION", (Icallback)item_background_action_cb);

  item_toolbar = IupItem("&Toobar", NULL);
  IupSetCallback(item_toolbar, "ACTION", (Icallback)item_toolbar_action_cb);
  IupSetAttribute(item_toolbar, "VALUE", "ON");

  item_statusbar = IupItem("&Statusbar", NULL);
  IupSetCallback(item_statusbar, "ACTION", (Icallback)item_statusbar_action_cb);
  IupSetAttribute(item_statusbar, "VALUE", "ON");

  item_help = IupItem("&Help...", NULL);
  IupSetCallback(item_help, "ACTION", (Icallback)item_help_action_cb);

  item_about = IupItem("&About...", NULL);
  IupSetCallback(item_about, "ACTION", (Icallback)item_about_action_cb);

  recent_menu = IupMenu(NULL);

  file_menu = IupMenu(
    item_new,
    item_open,
    item_save,
    item_saveas,
    item_revert,
    IupSeparator(),
    item_pagesetup,
    item_print,
    IupSeparator(),
    IupSubmenu("Recent &Files", recent_menu),
    IupSeparator(),
    item_exit,
    NULL);
  edit_menu = IupMenu(
    item_copy,
    item_paste,
    NULL);
  view_menu = IupMenu(
    item_zoomin, 
    item_zoomout, 
    item_actualsize,
    IupSeparator(),
    item_background,
    IupSeparator(),
    item_toolbar,
    item_statusbar,
    NULL);
  help_menu = IupMenu(
    item_help,
    item_about,
    NULL);

  IupSetCallback(file_menu, "OPEN_CB", (Icallback)file_menu_open_cb);
  IupSetCallback(edit_menu, "OPEN_CB", (Icallback)edit_menu_open_cb);

  sub_menu_file = IupSubmenu("&File", file_menu);
  sub_menu_edit = IupSubmenu("&Edit", edit_menu);
  sub_menu_view = IupSubmenu("&View", view_menu);
  sub_menu_help = IupSubmenu("&Help", help_menu);

  menu = IupMenu(
    sub_menu_file,
    sub_menu_edit,
    sub_menu_view,
    sub_menu_help,
    NULL);

  toolbar = IupHbox(
    btn_new,
    btn_open,
    btn_save,
    IupSetAttributes(IupLabel(NULL), "SEPARATOR=VERTICAL"),
    btn_copy,
    btn_paste,
    NULL);
  IupSetAttribute(toolbar, "MARGIN", "5x5");
  IupSetAttribute(toolbar, "GAP", "2");


  vbox = IupVbox(
    toolbar,
    canvas,
    statusbar,
    NULL);

  dlg = IupDialog(vbox);
  IupSetAttributeHandle(dlg, "MENU", menu);
  IupSetAttribute(dlg, "SIZE", "HALFxHALF");
  IupSetCallback(dlg, "CLOSE_CB", (Icallback)item_exit_action_cb);
  IupSetCallback(dlg, "DROPFILES_CB", (Icallback)dropfiles_cb);

  IupSetCallback(dlg, "K_cN", (Icallback)item_new_action_cb);
  IupSetCallback(dlg, "K_cO", (Icallback)item_open_action_cb);
  IupSetCallback(dlg, "K_cS", (Icallback)item_save_action_cb);
  IupSetCallback(dlg, "K_cV", (Icallback)item_paste_action_cb);
  IupSetCallback(dlg, "K_cC", (Icallback)item_copy_action_cb);
  IupSetCallback(dlg, "K_cP", (Icallback)item_print_action_cb);
  IupSetCallback(dlg, "K_cMinus", (Icallback)zoomout_action_cb);
  IupSetCallback(dlg, "K_cPlus", (Icallback)zoomin_action_cb);
  IupSetCallback(dlg, "K_cEqual", (Icallback)zoomin_action_cb);
  IupSetCallback(dlg, "K_c0", (Icallback)actualsize_action_cb);

  /* parent for pre-defined dialogs in closed functions (IupMessage and IupAlarm) */
  IupSetAttributeHandle(NULL, "PARENTDIALOG", dlg);

  /* Initialize variables from the configuration file */

  IupConfigRecentInit(config, recent_menu, config_recent_cb, 10);

  if (!IupConfigGetVariableIntDef(config, "MainWindow", "Toolbar", 1))
  {
    IupSetAttribute(item_toolbar, "VALUE", "OFF");

    IupSetAttribute(toolbar, "FLOATING", "YES");
    IupSetAttribute(toolbar, "VISIBLE", "NO");
  }

  if (!IupConfigGetVariableIntDef(config, "MainWindow", "Statusbar", 1))
  {
    IupSetAttribute(item_statusbar, "VALUE", "OFF");

    IupSetAttribute(statusbar, "FLOATING", "YES");
    IupSetAttribute(statusbar, "VISIBLE", "NO");
  }

  IupSetAttribute(dlg, "CONFIG", (char*)config);

  return dlg;
}
Exemple #5
0
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;
}
Exemple #6
0
void ListTest(void)
{
  Ihandle *dlg, *list1, *list2, *list3, *list4, *text, *btok, *btcancel,
          *box, *lists, *buttons1, *buttons2, *buttons3, *label;

  list1 = IupList(NULL);
  list2 = IupList(NULL);
  list3 = IupList(NULL);
  list4 = IupList(NULL);                              

  IupSetAttributes(list1, "1=\"US$ 1000\", 2=\"US$ 2000\", 3=\"US$ 300.000.000\", 4=\"US$ 4000\","
                          "EDITBOX=YES, DROPDOWN=YES, TIP=Edit+Drop, VALUE=\"Edit Here\", NAME=list1");
  IupSetAttributes(list2, "1=\"R$ 1000\", 2=\"R$ 2000\", 3=\"R$ 123456789\", 4=\"R$ 4000\", 5=\"R$ 5000\","
                          "DROPDOWN=YES, NAME=list2, TIP=Drop, VALUE=2");
  IupSetAttributes(list3, "1=\"Char A\", 2=\"Char B\", 3=\"Char CCCCC\", 4=\"Char D\", 5=\"Char E\", 6=\"Char F\","
                          "EDITBOX=YES, NAME=list3, TIP=Edit+List, VALUE=\"Edit Here\"");
  IupSetAttributes(list4, "1=\"Number 1\", 2=\"Number 2\", 3=\"Number 3\", 4=\"Number 4\", 5=\"Number 5\", 6=\"Number 6\", 7=\"Number 7\","
                          "MULTIPLE=YES, NAME=list4, TIP=List, VALUE=+--++--");

  set_callbacks(list1);
  set_callbacks(list2);
  set_callbacks(list3);
  set_callbacks(list4);

  //IupSetAttributes(list2, "6=\"R$ 1000\", 7=\"R$ 2000\", 8=\"R$ 123456789\", 9=\"R$ 4000\", 10=\"R$ 5000\",");
  //IupSetAttributes(list2, "11=\"R$ 1000\", 12=\"R$ 2000\", 13=\"R$ 123456789\", 14=\"R$ 4000\", 15=\"R$ 5000\",");
  //IupSetAttributes(list2, "16=\"R$ 1000\", 17=\"R$ 2000\", 18=\"R$ 123456789\", 19=\"R$ 4000\", 20=\"R$ 5000\",");
  
  IupSetCallback(list4, "MULTISELECT_CB", (Icallback)multilist_cb);

//  IupSetAttribute(list1, "READONLY", "YES");
//  IupSetAttribute(list3, "READONLY", "YES");
//  IupSetAttribute(list1, "PADDING", "10x10");
//  IupSetAttribute(list3, "PADDING", "10x10");

//  IupSetAttribute(list3, "SPACING", "10");
//  IupSetAttribute(list4, "SPACING", "10");

  printf("COUNT(list1)=%s\n", IupGetAttribute(list1, "COUNT"));
  printf("COUNT(list2)=%s\n", IupGetAttribute(list2, "COUNT"));
  printf("COUNT(list3)=%s\n", IupGetAttribute(list3, "COUNT"));
  printf("COUNT(list4)=%s\n", IupGetAttribute(list4, "COUNT"));

  lists = IupHbox(
    IupVbox(
      IupSetAttributes(IupFrame(IupVbox(list1, NULL)), "TITLE=EDITBOX+DROPDOWN"),
      IupSetAttributes(IupFrame(IupVbox(list2, NULL)), "TITLE=DROPDOWN"),
      NULL), 
    IupSetAttributes(IupFrame(IupVbox(list3, NULL)), "TITLE=EDITBOX"),
    IupSetAttributes(IupFrame(IupVbox(list4, NULL)), "TITLE=MULTIPLE"),
    IupVbox(
      btok = IupSetCallbacks(IupButton("Default Enter", NULL), "ACTION", btok_cb, NULL),
      btcancel = IupSetCallbacks(IupButton("Default Esc", NULL), "ACTION", btcancel_cb, NULL),
      NULL),
    NULL);

  text = IupText(NULL);
  IupSetAttribute(text, "EXPAND", "HORIZONTAL");
  IupSetAttribute(text, "NAME", "text");

  buttons1 = IupHbox(
    IupSetCallbacks(IupButton("Get(VALUE)", NULL), "ACTION", getvalue_cb, NULL),
    IupSetCallbacks(IupButton("Set(VALUE)", NULL), "ACTION", setvalue_cb, NULL),
    IupSetCallbacks(IupButton("Get(COUNT)", NULL), "ACTION", getcount_cb, NULL),
    NULL);
  buttons2 = IupHbox(
    IupSetCallbacks(IupButton("INSERTITEM3", NULL), "ACTION", insertitem_cb, NULL),
    IupSetCallbacks(IupButton("APPENDITEM", NULL), "ACTION", appenditem_cb, NULL),
    IupSetCallbacks(IupButton("REMOVEITEM", NULL), "ACTION", removeitem_cb, NULL),
    IupSetCallbacks(IupButton("SHOWDROPDOWN", NULL), "ACTION", showdropdown_cb, NULL),
    IupSetCallbacks(IupButton("TOPITEM", NULL), "ACTION", topitem_cb, NULL),
    NULL);
  buttons3 = IupHbox(
    IupSetCallbacks(IupButton("APPEND", NULL), "ACTION", append_cb, NULL),
    IupSetCallbacks(IupButton("Get(CARET)", NULL), "ACTION", getcaret_cb, NULL),
    IupSetCallbacks(IupButton("Set(READONLY)", NULL), "ACTION", readonly_cb, NULL),
    IupSetCallbacks(IupButton("Get(SELECTEDTEXT)", NULL), "ACTION", selectedtext_cb, NULL),
    IupSetCallbacks(IupButton("Get(SELECTION)", NULL), "ACTION", selection_cb, NULL),
    NULL);

  box = IupVbox(lists, IupHbox(IupLabel("Attrib. Value:  "), text, NULL), buttons1, buttons2, buttons3, IupHbox(IupLabel("Current List:  "), label = IupLabel(NULL), NULL), NULL);
  IupSetAttributes(buttons1,"MARGIN=5x5, GAP=5");
  IupSetAttributes(buttons2,"MARGIN=5x5, GAP=5");
  IupSetAttributes(buttons3,"MARGIN=5x5, GAP=5");
  IupSetAttributes(lists,"MARGIN=10x10, GAP=10");
  IupSetAttribute(label,"EXPAND", "HORIZONTAL");

  dlg = IupDialog(box);
  IupSetAttribute(dlg, "TITLE", "IupList Test");
  IupSetAttributeHandle(dlg, "DEFAULTENTER", btok);
  IupSetAttributeHandle(dlg, "DEFAULTESC", btcancel);
  IupSetAttribute(dlg, "_LABEL", (char*)label);

//  IupSetAttribute(box, "BGCOLOR", "92 92 255");
//  IupSetAttribute(dlg, "BGCOLOR", "92 92 255");
//  IupSetAttribute(dlg, "BACKGROUND", "200 10 80");
//  IupSetAttribute(dlg, "BGCOLOR", "173 177 194");  // Motif BGCOLOR for documentation

//  IupSetAttribute(dlg, "FONT", "Helvetica, 24");
//  IupSetAttribute(box, "FGCOLOR", "255 0 0");

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
}