Beispiel #1
0
int IupGetText(const char* title, char* text)
{
  Ihandle *ok, *cancel, *multi_text, *button_box, *dlg_box, *dialog;
  int bt;

  multi_text = IupMultiLine("do_nothing");
  IupSetAttribute(multi_text,IUP_EXPAND, IUP_YES);
  IupSetAttribute(multi_text, IUP_SIZE, "200x80");
  IupSetAttribute(multi_text,IUP_VALUE, text);
  IupSetAttribute(multi_text,IUP_FONT, IUP_COURIER_NORMAL_12);

  ok   = IupButton(strok, NULL);
  IupSetAttribute (ok   ,IUP_SIZE ,"50x");
  IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK);
  IupSetHandle( "IupGetTextOkButton", ok );

  cancel  = IupButton(strcancel, NULL);
  IupSetAttribute (cancel,IUP_SIZE ,"50x");
  IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL);
  IupSetHandle( "IupGetTextCancelButton", cancel );

  button_box = IupHbox(
    IupSetAttributes(IupFill(), "EXPAND=HORIZONTAL"),
    ok,
    IupSetAttributes(IupFill(), "SIZE=1x"),
    cancel,
    NULL);
  IupSetAttribute(button_box,IUP_MARGIN,"0x0");

  dlg_box = IupVbox(
    multi_text,
    IupSetAttributes(IupFill(), "SIZE=1x"),
    button_box,
    NULL);

  IupSetAttribute(dlg_box,IUP_MARGIN,"10x10");
  IupSetAttribute(dlg_box,IUP_GAP,"5");

  dialog = IupDialog (dlg_box);

  IupSetAttribute (dialog,IUP_TITLE,title);
  IupSetAttribute (dialog,IUP_MINBOX,IUP_NO);
  IupSetAttribute (dialog,IUP_MAXBOX,IUP_NO);
  IupSetAttribute (dialog,IUP_DEFAULTENTER,"IupGetTextOkButton");
  IupSetAttribute (dialog,IUP_DEFAULTESC,"IupGetTextCancelButton");
  IupSetAttribute (dialog,IUP_PARENTDIALOG, IupGetGlobal(IUP_PARENTDIALOG));
  IupSetAttribute (dialog, IUP_ICON, IupGetGlobal(IUP_ICON));

  IupPopup(dialog, IUP_CENTER, IUP_CENTER);

  bt = IupGetInt(dialog, IUP_STATUS);
  if (bt==1)
    strcpy(text, IupGetAttribute(multi_text, IUP_VALUE));
  else
    bt = 0;  /* return 0 instead of -1 */

  IupDestroy(dialog);
  return bt;
}
Beispiel #2
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();
}
Beispiel #3
0
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;

}
Beispiel #4
0
Ihandle *IupQuakeScale(char *title, float min, float max, float step, char *key, float def)
{
    Ihandle *scale,*label_value,*label_min,*label_max;

    char buf[128];

    scale = IupVal("HORIZONTAL");
    snprintf(buf, 128, "EXPAND=HORIZONTAL, MIN=%.1f, MAX=%.1f, VALUE=%.1f, STEP=0.01", min, max, def);
    IupSetAttributes(scale, buf);
    IupSetCallback(scale, "VALUECHANGED_CB", (Icallback)IupQuakeScaleUpdate);

    snprintf(buf, 16, "%.1f", def);
    label_value = IupLabel(buf);
    IupStoreAttribute(label_value, "EXPAND", "HORIZONTAL");
    IupStoreAttribute(label_value, "ALIGNMENT", "ACENTER:ACENTER");

    snprintf(buf, 16, "%.1f", min);
    label_min = IupLabel(buf);
    IupStoreAttribute(label_min, "ALIGNMENT", "ACENTER:ACENTER");
    snprintf(buf, 16, "%.1f", max);
    label_max = IupLabel(buf);
    IupStoreAttribute(label_max, "ALIGNMENT", "ACENTER:ACENTER");

    return IupVbox(
            IupLabel(title),
            IupHbox(
                label_min,
                label_value,
                label_max,
                NULL
            ),
            scale,
            NULL
    );
}
Beispiel #5
0
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);
}
Beispiel #6
0
int main(int argc, char **argv)
{
  Ihandle *dlg;
  Ihandle *btn;

  IupOpen(&argc, &argv);

  /* Creates a backgroundbox */
  btn = IupBackgroundBox(IupVbox(IupButton("This button does nothing", ""), IupText(""), NULL));

  /* Creates dialog */
  dlg = IupDialog
  (
    IupVbox
    (
      btn,
      NULL
    )
  );

  IupSetAttributes (dlg, "MARGIN=10x10, GAP=10, TITLE = \"IupBackgroundBox Example\"");

  IupShowXY (dlg, IUP_CENTER, IUP_CENTER );

  IupMainLoop ();
  IupClose ();
  return EXIT_SUCCESS;
}
Beispiel #7
0
static int SetAttributes(lua_State *L)
{
  Ihandle * ih = iuplua_checkihandle(L,1);
  const char *attributes = luaL_checkstring(L,2);
  IupSetAttributes(ih, attributes);
  iuplua_pushihandle(L,ih);
  return 1;
}
Beispiel #8
0
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);
}
Beispiel #9
0
/* Main program */
int main(int argc, char **argv)
{
    /* IUP identifiers */
    Ihandle *dlg;
    Ihandle *img_star;
    Ihandle *lbl, *lbl_explain, *lbl_star;

    /* Initializes IUP */
    IupOpen(&argc, &argv);

    /* Program begin */

    /* Creates the star image */
    img_star = IupImage ( 13, 13, pixmap_star );

    /* Sets star image colors */
    IupSetAttribute ( img_star, "1", "0 0 0");
    IupSetAttribute ( img_star, "2", "0 198 0");

    /* Associates "img_star" to image img_star */
    IupSetHandle ( "img_star", img_star );


    /* Creates a label */
    lbl = IupLabel ( "This label has the following attributes set:\nBGCOLOR = 255 255 0\nFGCOLOR = 0 0 255\nFONT = COURIER_NORMAL_14\nTITLE = All text contained here\nALIGNMENT = ACENTER" );

    /* Sets all the attributes of label lbl, except for IMAGE */
    IupSetAttributes ( lbl, "BGCOLOR = \"255 255 0\", FGCOLOR = \"0 0 255\", FONT = COURIER_NORMAL_14, ALIGNMENT = ACENTER");

    /* Creates a label to explain that the label on the right has an image */
    lbl_explain = IupLabel ( "The label on the right has the image of a star" );

    /* Creates a label whose title is not important, cause it will have an image */
    lbl_star = IupLabel (NULL);

    /* Associates image "img_star" with label lbl_star */
    IupSetAttribute ( lbl_star, "IMAGE", "img_star" );

    /* Creates dialog with the label */
    dlg = IupDialog ( IupVbox ( lbl, IupHbox ( lbl_explain, lbl_star, NULL ), NULL ) );

    /* Sets title of the dialog */
    IupSetAttribute ( dlg, "TITLE", "IupLabel Example" );

    /* Shows dialog in the center of the screen */
    IupShowXY ( dlg, IUP_CENTER, IUP_CENTER );

    /* Initializes IUP main loop */
    IupMainLoop();

    /* Finishes IUP */
    IupClose();

    /* Program finished successfully */
    return EXIT_SUCCESS;

}
Beispiel #10
0
static void new_file(char* dialogtype, int preview)
{
  Ihandle *dlg = IupFileDlg(); 

  IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_");
  IupSetAttribute(dlg, "DIALOGTYPE", dialogtype);
  IupSetAttribute(dlg, "TITLE", "IupFileDlg Test");
  IupSetAttribute(dlg, "DIRECTORY", "/tecgraf/iup");
  if (strcmp(dialogtype, "DIR")!=0)
  {
    IupSetAttributes(dlg, "FILTER = \"*.bmp\", FILTERINFO = \"Bitmap Files\"");
    IupSetAttribute(dlg, "EXTFILTER", "Text files|*.txt;*.doc|Image files|*.jpg;*.bmp;*.gif|");
//    IupSetAttribute(dlg, "FILE", "/tecgraf/im/test.bmp");
    IupSetAttribute(dlg, "FILE", "test.bmp");
  }
  IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb);
//  IupSetAttributes(dlg, "FILE = \"\\tecgraf\\iup\\test.bmp\""); // OK
//  IupSetAttributes(dlg, "FILE = \"/tecgraf/iup/test.bmp\""); // OK
//  IupSetAttributes(dlg, "FILE = \"test.bmp\", DIRECTORY = \"/tecgraf/iup\"");   // OK
//  IupSetAttributes(dlg, "FILE = \"test.bmp\", DIRECTORY = \"\\tecgraf\\iup\"");  // OK
//  IupSetAttribute(dlg, "NOCHANGEDIR", "NO");
//  IupSetAttribute(dlg, "MULTIPLEFILES", "YES");

  if (preview)
  {
    IupSetAttribute(dlg, "SHOWPREVIEW", "YES");
    IupSetCallback(dlg, "FILE_CB", (Icallback)file_cb);

#ifdef USE_OPENGL
    if (preview==2)
    {
      Ihandle* glcanvas = IupGLCanvas(NULL);
      IupSetAttribute(glcanvas, "BUFFER", "DOUBLE");
      IupSetAttributeHandle(dlg, "PREVIEWGLCANVAS", glcanvas);
    }
#endif
  }
  
  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT); 

  switch(IupGetInt(dlg, "STATUS"))
  {
    case 1: 
      printf("OK\n");
      printf("  New file - VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); 
      break; 
    case 0 : 
      printf("OK\n");
      printf("  File exists - VALUE(%s)\n", IupGetAttribute(dlg, "VALUE"));
      break; 
    case -1 : 
      printf("CANCEL\n");
      break; 
  }

  IupDestroy(dlg);
}
Beispiel #11
0
/* 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;
}
Beispiel #12
0
int item_goto_action_cb(Ihandle* item_goto)
{
  Ihandle* multitext = IupGetDialogChild(item_goto, "MULTITEXT");
  Ihandle *dlg, *box, *bt_ok, *bt_cancel, *txt, *lbl;

  int line_count = IupGetInt(multitext, "LINECOUNT");

  lbl = IupLabel(NULL);
  IupSetfAttribute(lbl, "TITLE", "Line Number [1-%d]:", line_count);
  txt = IupText(NULL);
  IupSetAttribute(txt, "MASK", IUP_MASK_UINT);  /* unsigned integer numbers only */
  IupSetAttribute(txt, "NAME", "LINE_TEXT");
  IupSetAttribute(txt, "VISIBLECOLUMNS", "20");
  bt_ok = IupButton("OK", NULL);
  IupSetInt(bt_ok, "TEXT_LINECOUNT", line_count);
  IupSetAttribute(bt_ok, "PADDING", "10x2");
  IupSetCallback(bt_ok, "ACTION", (Icallback)goto_ok_action_cb);
  bt_cancel = IupButton("Cancel", NULL);
  IupSetCallback(bt_cancel, "ACTION", (Icallback)goto_cancel_action_cb);
  IupSetAttribute(bt_cancel, "PADDING", "10x2");

  box = IupVbox(
    lbl,
    txt,
    IupSetAttributes(IupHbox(
      IupFill(),
      bt_ok,
      bt_cancel,
      NULL), "NORMALIZESIZE=HORIZONTAL"),
    NULL);
  IupSetAttribute(box, "MARGIN", "10x10");
  IupSetAttribute(box, "GAP", "5");

  dlg = IupDialog(box);
  IupSetAttribute(dlg, "TITLE", "Go To Line");
  IupSetAttribute(dlg, "DIALOGFRAME", "Yes");
  IupSetAttributeHandle(dlg, "DEFAULTENTER", bt_ok);
  IupSetAttributeHandle(dlg, "DEFAULTESC", bt_cancel);
  IupSetAttributeHandle(dlg, "PARENTDIALOG", IupGetDialog(item_goto));

  IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT);

  if (IupGetInt(dlg, "STATUS") == 1)
  {
    int line = IupGetInt(txt, "VALUE");
    int pos;
    IupTextConvertLinColToPos(multitext, line, 0, &pos);
    IupSetInt(multitext, "CARETPOS", pos);
    IupSetInt(multitext, "SCROLLTOPOS", pos);
  }

  IupDestroy(dlg);

  return IUP_DEFAULT;
}
Beispiel #13
0
Ihandle *IupQuakeMouseLayout()
{
    Ihandle *tab;

    tab = IupSetAttributes(
            IupHbox(
                IupVbox(
                    IupQuakeSetToggle("Reverse mouse", "m_pitch", "-0.022", "0.022", 0),
                    IupQuakeSetToggle("Use automatic sensitivity scaling", "m_autosens", "1", "0", 1),
                    IupQuakeScale("Mouse sensitivity", 1.00, 20.00, 0.1, "sensitivity", 3.00),
                    NULL
                ),
                IupFill(),
                NULL
            ),
            "HOMOGENEOUS=YES"
        );
    IupSetAttributes(tab, "GAP=5");
    return tab;
}
Beispiel #14
0
/* Main program */
int main(int argc, char **argv)
{
    Ihandle *dlg, *cb;

    /* Initializes IUP */
    IupOpen(&argc, &argv);
    IupControlsOpen();


    /* Creates a canvas associated with the redraw action */
    cnvs = IupCanvas(NULL);
    IupSetCallback(cnvs, "ACTION", (Icallback)redraw_cb);

    /* Sets size, minimum and maximum values, position and size of the thumb   */
    /* of the horizontal scrollbar of the canvas                               */
    IupSetAttributes(cnvs, "RASTERSIZE=200x300");

    cb = IupColorbar();
    IupSetAttribute(cb, "RASTERSIZE", "70x");
    IupSetAttribute(cb, "EXPAND", "VERTICAL");
    IupSetAttribute(cb, "NUM_PARTS", "2");
    IupSetAttribute(cb, "SHOW_SECONDARY", "YES");
    IupSetCallback(cb, "SELECT_CB", (Icallback)select_cb);
    IupSetCallback(cb, "CELL_CB", (Icallback)cell_cb);
    IupSetCallback(cb, "SWITCH_CB", (Icallback)switch_cb);
//  IupSetAttribute(cb, "SQUARED", "NO");
    IupSetAttribute(cb, "PREVIEW_SIZE", "60");

    /* Creates a dialog with a vbox containing the canvas and the colorbar. */
    dlg = IupDialog(IupHbox(cnvs, cb, NULL));

    /* Sets the dialog's title, so that it is mapped properly */
    IupSetAttribute(dlg, "TITLE", "IupColorbar");

    /* Maps the dialog. This must be done before the creation of the CD canvas */
    IupMap(dlg);

    /* Creates a CD canvas of type CD_IUP */
    cdcanvas = cdCreateCanvas(CD_IUP, cnvs);

    /* Shows dialog on the center of the screen */
    IupShow(dlg);

    /* Initializes IUP main loop */
    IupMainLoop();

    /* Finishes IUP */
    IupClose();

    /* Program finished successfully */
    return EXIT_SUCCESS;

}
Beispiel #15
0
int item_find_action_cb(Ihandle* item_find)
{
  Ihandle* dlg = (Ihandle*)IupGetAttribute(item_find, "FIND_DIALOG");
  if (!dlg)
  {
    Ihandle* multitext = IupGetDialogChild(item_find, "MULTITEXT");
    Ihandle *box, *bt_next, *bt_close, *txt, *find_case;


    txt = IupText(NULL);
    IupSetAttribute(txt, "NAME", "FIND_TEXT");
    IupSetAttribute(txt, "VISIBLECOLUMNS", "20");
    find_case = IupToggle("Case Sensitive", NULL);
    IupSetAttribute(find_case, "NAME", "FIND_CASE");
    bt_next = IupButton("Find Next", NULL);
    IupSetAttribute(bt_next, "PADDING", "10x2");
    IupSetCallback(bt_next, "ACTION", (Icallback)find_next_action_cb);
    bt_close = IupButton("Close", NULL);
    IupSetCallback(bt_close, "ACTION", (Icallback)find_close_action_cb);
    IupSetAttribute(bt_close, "PADDING", "10x2");

    box = IupVbox(
      IupLabel("Find What:"),
      txt,
      find_case,
      IupSetAttributes(IupHbox(
        IupFill(),
        bt_next,
        bt_close,
        NULL), "NORMALIZESIZE=HORIZONTAL"),
      NULL);
    IupSetAttribute(box, "MARGIN", "10x10");
    IupSetAttribute(box, "GAP", "5");

    dlg = IupDialog(box);
    IupSetAttribute(dlg, "TITLE", "Find");
    IupSetAttribute(dlg, "DIALOGFRAME", "Yes");
    IupSetAttributeHandle(dlg, "DEFAULTENTER", bt_next);
    IupSetAttributeHandle(dlg, "DEFAULTESC", bt_close);
    IupSetAttributeHandle(dlg, "PARENTDIALOG", IupGetDialog(item_find));

    /* Save the multiline to acess it from the callbacks */
    IupSetAttribute(dlg, "MULTITEXT", (char*)multitext);

    /* Save the dialog to reuse it */
    IupSetAttribute(item_find, "FIND_DIALOG", (char*)dlg);
  }

  /* centerparent first time, next time reuse the last position */
  IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT);

  return IUP_DEFAULT;
}
Beispiel #16
0
static void show_menu(Ihandle* ih)
{
  int x, y;

  Ihandle* menu_file = IupMenu(
    IupSetAttributes(IupItem("Item with Image", "item_cb"), "IMAGE=image_tec"),
    IupSetAttributes(IupItem("Toggle using VALUE", NULL), "VALUE=ON, KEY=K_V"), 
    IupSetAttributes(IupItem("Auto &Toggle", "item_cb"), "AUTOTOGGLE=YES, VALUE=OFF, IMAGE=image_test, IMPRESS=image_test_pressed"), 
    IupSeparator(), 
    IupItem("E&xit (Close)", NULL), 
    NULL);
  Ihandle* menu = IupMenu(
    IupSetAttributes(IupSubmenu("Submenu", menu_file), "KEY=K_S, IMAGE=image_tec"), 
    IupItem("Item", "item_cb"), 
    IupSetAttributes(IupItem("Item", "item_cb"), "VALUE=ON"), 
    IupSetAttributes(IupItem("Item", "item_cb"), "KEY=K_I, IMAGE=image_tec"), 
    NULL);

  x = IupGetInt(ih, "X");
  y = IupGetInt(ih, "Y");
  y += IupGetInt2(ih, "RASTERSIZE");

  IupPopup(menu, x, y);

  IupDestroy(menu);
}
Beispiel #17
0
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);
}
Beispiel #18
0
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;
}
Beispiel #19
0
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; 
}
Beispiel #20
0
void SpinTest(void)
{
    Ihandle *dlg, *spinbox, *text;

    spinbox = IupSpinbox(IupSetAttributes(text = IupText(NULL), "SIZE=50x, EXPAND=HORIZONTAL, FONT=\"Times, 24\""));
//  IupSetAttribute(text, "MASK", "/d+|AUTO");

    IupSetCallback(spinbox, "SPIN_CB", (Icallback)spin_cb);

    dlg = IupDialog(IupVbox(spinbox, NULL));
    IupSetAttribute(dlg, "MARGIN", "10x10");

    IupSetAttribute(dlg, "TITLE", "IupSpin Test");
    IupShow(dlg);
}
Beispiel #21
0
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);
}
Beispiel #22
0
void mainDialogCreate(void)
{
  Ihandle *dialog, *box, *canvas;

  /* initialize interface */

  /* canvas for the image */

  canvas = IupGLCanvas("app_repaint_cb");
  IupSetAttribute(canvas, "BORDER", "NO");
  IupSetAttribute(canvas, "BUFFER", "DOUBLE");   /* use double buffer */
  IupSetAttribute(canvas, "RESIZE_CB", "app_resize_cb");   /* configure the resize callback */

  IupSetFunction("app_resize_cb", (Icallback)app_resize_cb);
  IupSetFunction("app_repaint_cb", (Icallback)app_repaint_cb);

  /* this is the most external box that puts together
     the toolbar, the two canvas and the status bar */
  box = IupSetAttributes(IupHbox(
            canvas, 
            NULL), "MARGIN=10x10");

  /* create the dialog and set its attributes */

  mainMenuCreate();

  dialog = IupDialog(box);
  IupSetAttribute(dialog, "MENU", "app_menu");     /* configure the menu */
  IupSetAttribute(dialog, "CLOSE_CB", "app_exit_cb");
  IupSetAttribute(dialog, "TITLE", "IUPGLView");
  IupSetAttribute(dialog, "RASTERSIZE", "680x380"); /* initial size */
  IupSetAttribute(dialog, "SHRINK", "YES");
  IupSetHandle("app_dialog", dialog);

  IupShowXY(dialog, IUP_CENTER, IUP_CENTER);
}
Beispiel #23
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);
}
Beispiel #24
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;

}
Beispiel #25
0
/* 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 ;
}
Beispiel #26
0
int IupAlarm(const char *title, const char *msg, const char *b1, const char *b2, const char *b3)
{
  Ihandle  *dlg, *dlg_box, *button_box, *button, *default_esc, *default_enter;
  int bt, len;
  char* padding;

  msg = msg? msg: "";

  if (b1 == NULL)
    return 0;

  len = strlen(b1);
  if (b2)
  {
    int len2 = strlen(b2);
    if (len2 > len)
      len = len2;
  }
  if (b3)
  {
    int len3 = strlen(b3);
    if (len3 > len)
      len = len3;
  }

  if (len > 7)
    padding = "12x2";
  else
    padding = "20x5";

  button_box = IupHbox(NULL);
  IupSetAttribute(button_box, "NORMALIZESIZE", "HORIZONTAL");
  IupSetAttribute(button_box,"MARGIN","0x0");

  button = IupButton(b1, NULL);
  iupAttribSetStrf(button, "_IUP_BUTTON_NUMBER", "1");
  IupSetAttribute(button, "PADDING", padding);
  IupAppend(button_box, button);
  IupSetCallback (button, "ACTION", (Icallback)iAlarmButtonAction_CB);
  default_enter = button;
  default_esc = button;

  if (b2 != NULL)
  {
    button = IupButton(b2, NULL);
    iupAttribSetStr(button, "_IUP_BUTTON_NUMBER", "2");
    IupSetAttribute(button, "PADDING", padding);
    IupAppend(button_box, button);
    IupSetCallback (button, "ACTION", (Icallback)iAlarmButtonAction_CB);
    default_esc = button;
  }

  if (b3 != NULL)
  {
    button = IupButton(b3, NULL);
    iupAttribSetStr(button, "_IUP_BUTTON_NUMBER", "3");
    IupSetAttribute(button, "PADDING", padding);
    IupAppend(button_box, button);
    IupSetCallback (button, "ACTION", (Icallback)iAlarmButtonAction_CB);
    default_esc = button;
  }

  dlg_box = IupVbox(
    IupLabel(msg),
    IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"),
    button_box,
    NULL);

  IupSetAttribute(dlg_box,"MARGIN","10x10");
  IupSetAttribute(dlg_box,"GAP","10");

  dlg = IupDialog(dlg_box);

  IupSetAttribute(dlg,"TITLE", title);
  IupSetAttribute(dlg,"DIALOGFRAME","YES");
  IupSetAttribute(dlg,"DIALOGHINT","YES");
  IupSetAttributeHandle(dlg,"DEFAULTENTER", default_enter);
  IupSetAttributeHandle(dlg,"DEFAULTESC", default_esc);
  IupSetAttribute(dlg,"PARENTDIALOG", IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON"));

  IupPopup(dlg,IUP_CENTER,IUP_CENTER);

  bt = iupAttribGetInt(dlg, "_IUP_BUTTON_NUMBER");

  IupDestroy(dlg);

  return bt;
}
Beispiel #27
0
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;
}
Beispiel #28
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;
  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 *statusbar, *toolbar, *recent_menu, *item_background;

  canvas = IupGLCanvas(NULL);
  IupSetAttribute(canvas, "NAME", "CANVAS");
  IupSetAttribute(canvas, "DIRTY", "NO");
  IupSetAttribute(canvas, "BUFFER", "DOUBLE");
  IupSetCallback(canvas, "ACTION", (Icallback)canvas_action_cb);
  IupSetCallback(canvas, "DROPFILES_CB", (Icallback)dropfiles_cb);

  statusbar = IupLabel("(0, 0) = [0   0   0]");
  IupSetAttribute(statusbar, "NAME", "STATUSBAR");
  IupSetAttribute(statusbar, "EXPAND", "HORIZONTAL");
  IupSetAttribute(statusbar, "PADDING", "10x5");

  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_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_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(),
    IupSubmenu("Recent &Files", recent_menu),
    item_exit,
    NULL);
  edit_menu = IupMenu(
    item_copy,
    item_paste,
    NULL);
  view_menu = IupMenu(
    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);

  /* 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;
}
Beispiel #29
0
int main(int argc, char **argv)
{
  Ihandle *dlg, *vbox, *multitext, *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_find, *item_goto, *item_copy, *item_paste, *item_cut, *item_delete, *item_select_all;
  Ihandle *btn_cut, *btn_copy, *btn_paste, *btn_find, *btn_new, *btn_open, *btn_save;
  Ihandle *sub_menu_format, *format_menu, *item_font;
  Ihandle *sub_menu_help, *help_menu, *item_help, *item_about;
  Ihandle *sub_menu_view, *view_menu, *item_toolbar, *item_statusbar;
  Ihandle *lbl_statusbar, *toolbar_hb, *recent_menu;
  Ihandle *config;
  const char* font;

  IupOpen(&argc, &argv);
  IupImageLibOpen();

  config = IupConfig();
  IupSetAttribute(config, "APP_NAME", "simple_notepad");
  IupConfigLoad(config);

  multitext = IupText(NULL);
    IupSetAttribute(multitext, "MULTILINE", "YES");
    IupSetAttribute(multitext, "EXPAND", "YES");
    IupSetAttribute(multitext, "NAME", "MULTITEXT");
    IupSetAttribute(multitext, "DIRTY", "NO");
    IupSetCallback(multitext, "CARET_CB", (Icallback)multitext_caret_cb);
    IupSetCallback(multitext, "VALUECHANGED_CB", (Icallback)multitext_valuechanged_cb);
    IupSetCallback(multitext, "DROPFILES_CB", (Icallback)dropfiles_cb);

  font = IupConfigGetVariableStr(config, "MainWindow", "Font");
  if (font)
    IupSetStrAttribute(multitext, "FONT", font);

  lbl_statusbar = IupLabel("Lin 1, Col 1");
    IupSetAttribute(lbl_statusbar, "NAME", "STATUSBAR");  
    IupSetAttribute(lbl_statusbar, "EXPAND", "HORIZONTAL");
    IupSetAttribute(lbl_statusbar, "PADDING", "10x5");

  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);

  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);

  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);

  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_exit = IupItem("E&xit", NULL);
    IupSetCallback(item_exit, "ACTION", (Icallback)item_exit_action_cb);

  item_find = IupItem("&Find...\tCtrl+F", NULL);
    IupSetAttribute(item_find, "IMAGE", "IUP_EditFind");
    IupSetCallback(item_find, "ACTION", (Icallback)item_find_action_cb);
  btn_find = IupButton(NULL, NULL);
    IupSetAttribute(btn_find, "IMAGE", "IUP_EditFind");
    IupSetAttribute(btn_find, "FLAT", "Yes");
    IupSetCallback(btn_find, "ACTION", (Icallback)item_find_action_cb);

  item_cut = IupItem("Cut\tCtrl+X", NULL);
    IupSetAttribute(item_cut, "NAME", "ITEM_CUT");
    IupSetAttribute(item_cut, "IMAGE", "IUP_EditCut");
    IupSetCallback(item_cut, "ACTION", (Icallback)item_cut_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);
  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);
  item_delete = IupItem("Delete\tDel", NULL);
    IupSetAttribute(item_delete, "IMAGE", "IUP_EditErase");  
    IupSetAttribute(item_delete, "NAME", "ITEM_DELETE");
    IupSetCallback(item_delete, "ACTION", (Icallback)item_delete_action_cb);
  item_select_all = IupItem("Select All\tCtrl+A", NULL);
    IupSetCallback(item_select_all, "ACTION", (Icallback)item_select_all_action_cb);

  btn_cut = IupButton(NULL, NULL);
    IupSetAttribute(btn_cut, "IMAGE", "IUP_EditCut");
    IupSetAttribute(btn_cut, "FLAT", "Yes");
    IupSetCallback(btn_cut, "ACTION", (Icallback)item_cut_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);
  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);

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

  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");

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

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

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

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

  item_goto = IupItem("&Go To...\tCtrl+G", NULL);
    IupSetCallback(item_goto, "ACTION", (Icallback)item_goto_action_cb);

  item_font = IupItem("&Font...", NULL);
    IupSetCallback(item_font, "ACTION", (Icallback)item_font_action_cb);
  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(),
    IupSubmenu("Recent &Files", recent_menu),
    item_exit,
    NULL);
  edit_menu = IupMenu(
    item_cut,
    item_copy,
    item_paste,
    item_delete,
    IupSeparator(),
    item_find,
    item_goto,
    IupSeparator(),
    item_select_all,
    NULL);
  format_menu = IupMenu(
    item_font,
    NULL);
  view_menu = IupMenu(
    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_format = IupSubmenu("F&ormat", format_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_format,
    sub_menu_view,
    sub_menu_help,
    NULL);

  vbox = IupVbox(
    toolbar_hb,
    multitext,
    lbl_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);

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

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

  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_cF", (Icallback)item_find_action_cb);
  IupSetCallback(dlg, "K_cG", (Icallback)item_goto_action_cb);
  
  IupConfigRecentInit(config, recent_menu, item_recent_cb, 10);

  IupShowXY(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT);
  IupSetAttribute(dlg, "USERSIZE", NULL);  /* remove minimum size restriction */

  new_file(dlg);

  /* open a file from the command line (allow file association in Windows) */
  if (argc > 1 && argv[1])
  {
    const char* filename = argv[1];
    open_file(dlg, filename);
  }

  IupMainLoop();

  IupClose();
  return EXIT_SUCCESS;
}
Beispiel #30
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);
}