Ejemplo n.º 1
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);
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
  Ihandle *dialog, *canvas;

  IupOpen(&argc, &argv);

  canvas = IupCanvas(NULL);
  IupSetAttribute(canvas, "RASTERSIZE", "300x200"); /* initial size */
  IupSetAttribute(canvas, "SCROLLBAR", "YES");
  IupSetAttribute(canvas, "XMAX", "599");
  IupSetAttribute(canvas, "YMAX", "399");

  IupSetCallback(canvas, "SCROLL_CB",  (Icallback)scroll_cb);
  IupSetCallback(canvas, "RESIZE_CB",  (Icallback)resize_cb);
  IupSetCallback(canvas, "ACTION",  (Icallback)action);
                   
  dialog = IupDialog(canvas);
  IupSetAttribute(dialog, "TITLE", "Scrollbar Test");

  IupMap(dialog);
  cdcanvas = cdCreateCanvas(CD_IUP, canvas);
  IupSetAttribute(canvas, "RASTERSIZE", NULL);  /* release the minimum limitation */
  
  IupShowXY(dialog,IUP_CENTER,IUP_CENTER);

  IupMainLoop();

  cdKillCanvas(cdcanvas);
  IupDestroy(dialog);

  IupClose();

  return EXIT_SUCCESS;

}
Ejemplo n.º 3
0
void guiVal_OnInit( void )
{
  guiVal->tbValue  = IupText( NULL );
  guiVal->hlType = IupHList( NULL );
  IupSetStrAttribute( guiVal->hlType,  "1",  "schar" );
  IupSetStrAttribute( guiVal->hlType,  "2",  "uchar" );
  IupSetStrAttribute( guiVal->hlType,  "3",  "short" );
  IupSetStrAttribute( guiVal->hlType,  "4", "ushort" );
  IupSetStrAttribute( guiVal->hlType,  "5",    "int" );
  IupSetStrAttribute( guiVal->hlType,  "6",   "uint" );
  IupSetStrAttribute( guiVal->hlType,  "7",   "long" );
  IupSetStrAttribute( guiVal->hlType,  "8",  "ulong" );
  IupSetStrAttribute( guiVal->hlType,  "9",   "lint" );
  IupSetStrAttribute( guiVal->hlType, "10",  "ulint" );
  IupSetStrAttribute( guiVal->hlType, "11",    "fpn" );
  IupSetStrAttribute( guiVal->hlType, "12",    "dpn" );
  IupSetStrAttribute( guiVal->hlType, "13",    "lpn" );
  guiVal->value.vb   = IupVbox(  guiVal->tbValue, guiVal->hlType, NULL );
  guiVal->value.fset = IupFrame( guiVal->value.vb );
  IupSetAttribute( guiVal->value.fset, IUP_SIZE, "100x30" );
  IupSetAttribute( guiVal->value.fset, IUP_EXPAND, IUP_HORIZONTAL );
  IupAppend( guiVal->main.vb, guiVal->value.fset );
  IupMap( guiVal->value.fset );
  guiVal_OnLang();
}
Ejemplo n.º 4
0
int IupMap (Ihandle* n)
{
  assert(n != NULL);
  if (n == NULL)
    return IUP_ERROR;

  if (handle(n) == NULL)
  {
    iupSetEnv(n,"_IUPWIN_IS_MAPPING",IUP_YES);
    iupdrvCreateObjects (n);
    if (iupSetSize (n) == IUP_ERROR)
      return IUP_ERROR;
    iupdrvResizeObjects(n);

    if(type(n) == DIALOG_)
    {
      IFn map_cb = (IFn) IupGetCallback(n, IUP_MAP_CB);
      if(map_cb != NULL) map_cb(n);
    }

    iupSetEnv(n,"_IUPWIN_IS_MAPPING",NULL);
  }
  else if (child(n))
  {
    Ihandle* c = NULL ;

    foreachchild(c,n)
      IupMap(c);
  }

  return IUP_NOERROR;
}
Ejemplo n.º 5
0
void TransferFunctionsViewer::BuildInterface ()
{
  m_iup_canvas = IupGLCanvas ("tfviewer_canvas");
  IupSetCallback (m_iup_canvas, "ACTION", (Icallback)TransferFunctionsViewer::Action);
  IupSetCallback (m_iup_canvas, "BUTTON_CB", (Icallback)TransferFunctionsViewer::Button_CB);
  IupSetCallback (m_iup_canvas, "MOTION_CB", (Icallback)TransferFunctionsViewer::Motion_CB);
  IupSetAttribute (m_iup_canvas, IUP_BUFFER, IUP_DOUBLE);
  IupSetAttribute (m_iup_canvas, IUP_RASTERSIZE, "258x50");
  IupSetAttribute (m_iup_canvas, IUP_RESIZE, IUP_NO);
  IupSetHandle ("tfviewer_canvas", m_iup_canvas);

  m_iup_sub_menu_file = IupSubmenu ("Arquivo", IupMenu(NULL));

  m_iup_menu = IupMenu (m_iup_sub_menu_file, NULL);
  IupSetHandle ("TransferFunctionMenu", m_iup_menu);

  m_iup_main_dialog = IupDialog (m_iup_canvas);
  //IupSetAttribute (m_iup_main_dialog, "MENU", "TransferFunctionMenu");
  IupSetAttribute (m_iup_main_dialog, "TITLE", "Transfer Function Visualization");
  IupSetAttribute (m_iup_main_dialog, "BORDER", "NO");
  IupSetAttribute (m_iup_main_dialog, "RESIZE", "NO");
  
  IupMap (m_iup_main_dialog);
  IupRefresh (m_iup_main_dialog);

  if (!m_pixels)
    m_pixels = new float[258 * 50 * 4];

  Redraw ();
}
Ejemplo n.º 6
0
void CanvasScrollbarTest(void)
{
  Ihandle *dlg, *cnv;

  cnv = IupCanvas(NULL);
  IupSetAttribute(cnv, "RASTERSIZE", "300x200"); /* initial size */
  IupSetAttribute(cnv, "SCROLLBAR", "YES");
//  IupSetAttribute(cnv, "EXPAND", "NO");

  IupSetCallback(cnv, "RESIZE_CB",  (Icallback)resize_cb);
  IupSetCallback(cnv, "ACTION",  (Icallback)action);
  IupSetCallback(cnv, "MAP_CB",  (Icallback)map_cb);
  IupSetCallback(cnv, "UNMAP_CB",  (Icallback)unmap_cb);
  IupSetCallback(cnv, "WHEEL_CB",  (Icallback)wheel_cb);
  IupSetCallback(cnv, "SCROLL_CB",  (Icallback)scroll_cb);
                   
  dlg = IupDialog(IupVbox(cnv, NULL));
  IupSetAttribute(dlg, "TITLE", "Scrollbar Test");
  IupSetAttribute(dlg, "MARGIN", "10x10");

  IupMap(dlg);
  IupSetAttribute(cnv, "RASTERSIZE", NULL);  /* release the minimum limitation */
 
  IupShowXY(dlg,IUP_CENTER,IUP_CENTER);
}
Ejemplo n.º 7
0
int item_add_cb(Ihandle* ih)
{
  Ihandle* item = IupItem("New Appended Item", "item_cb");
  printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE"));
  IupAppend(IupGetParent(ih), item);   /* after the last item */
  IupMap(item);
  return IUP_DEFAULT;
}
Ejemplo n.º 8
0
Archivo: tabs.c Proyecto: Airr/iup_mac
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);
}
Ejemplo n.º 9
0
static int iDetachBoxSetDetachAttrib(Ihandle* ih, const char* value)
{
  int cur_x, cur_y;
  IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");

  /* Create new dialog */
  Ihandle *new_parent = IupDialog(NULL);
  Ihandle *old_dialog = IupGetDialog(ih);

  /* Set new dialog as child of the current application */
  IupSetAttributeHandle(new_parent, "PARENTDIALOG", old_dialog);

  iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');

  if (detachedCB)
  {
    int ret = detachedCB(ih, new_parent, cur_x, cur_y);
    if (ret == IUP_IGNORE)
    {
      IupDestroy(new_parent);
      return IUP_DEFAULT;
    }
  }

  /* set user size of the detachbox as the current size of the child */
  IupSetStrAttribute(ih, "RASTERSIZE", IupGetAttribute(ih->firstchild->brother, "RASTERSIZE"));

  /* Save current parent and reference child */
  ih->data->old_parent = ih->parent;
  ih->data->old_brother = ih->brother;

  IupMap(new_parent);

  /* Sets the new parent */
  IupReparent(ih, new_parent, NULL);

  /* Hide handler */
  IupSetAttribute(ih->firstchild, "VISIBLE", "No");

  /* force a dialog resize since IupMap already computed the dialog size */
  IupSetAttribute(new_parent, "RASTERSIZE", NULL);

  /* Maps and shows the new dialog */
  IupShowXY(new_parent, cur_x, cur_y);

  /* reset user size of the detachbox */
  IupSetAttribute(ih, "USERSIZE", NULL);

  /* Updates/redraws the layout of the old dialog */
  IupRefresh(old_dialog);

  (void)value;
  return 0;
}
Ejemplo n.º 10
0
int item_insert_cb(Ihandle* ih)
{
  Ihandle* ref_item = IupGetChild(IupGetParent(ih), 4);   /* before the first appended item, just after the separator */
  printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE"));
  if (ref_item)
  {
    Ihandle* item = IupItem("New Inserted Item", "item_cb");
    IupInsert(IupGetParent(ih), ref_item, item);
    IupMap(item);
  }
  return IUP_DEFAULT;
}
Ejemplo n.º 11
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;

}
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
void cCanvasDetailHandler::create_canvas_detach(int w, int h, VglCamera* camera)
{
    cCanvasDetach *canvas;
    Ihandle *h_canvas, *dialog;

    h_canvas = IupGLCanvas("canvas_main");
    dialog = IupDialog(h_canvas);
    IupSetfAttribute(h_canvas, IUP_RASTERSIZE, "%dx%d", w, h);
    IupSetAttribute(h_canvas, "SHAREDCONTEXT", "canvas_main");

    IupSetAttribute(h_canvas, IUP_BUFFER, IUP_DOUBLE);
    IupSetAttribute(h_canvas, IUP_BORDER, IUP_NO);
    IupSetAttribute(h_canvas, IUP_DEPTH_SIZE, "16");

    if(!m_title.empty())
        IupSetAttribute(dialog, IUP_TITLE, m_title.c_str());

    if(!m_icon.empty())
        IupSetAttribute(dialog, IUP_ICON, m_icon.c_str());

    if(!m_parent.empty())
        IupSetAttribute(dialog, IUP_PARENTDIALOG, m_parent.c_str());

    IupMap(dialog);

    canvas = new cCanvasDetach(
        h_canvas,
        m_canvas,
        camera,
        m_redraw_function,
        m_redraw_end_function,
        m_menu_popup_function,
        (void *)m_data);

    if(isAnimating && m_idle_function)
        canvas->add_idle(m_idle_function, m_idle_data, m_idle_repeat);

    canvas->set_dialog(dialog);

    m_vec_canvas_detach.push_back(canvas);
    m_vec_dialog.push_back(dialog);

    //GetDC();
    //
    //wglCreateContextAttribsARB
    //wglCreateContext();
    //wglShareLists();

    IupShowXY(dialog, IUP_CENTERPARENT, IUP_CENTERPARENT);
}
Ejemplo n.º 13
0
// List method changes
static int _list_method_cb(/*@unused@*/ Ihandle *ih,
                                        /*@unused@*/ char *text, int pos, int state) {
    if( state == 0 )
        return IUP_DEFAULT;
    if( !run_task )
        run_task = IupSetAtt(NULL,IupTimer(),"TIME","100",NULL);
    switch(pos) {
    case 1:
        LOG(LOGVERBOSE,_("Running geocode with hostip"));
        IupSetAttribute(lbl_status,"VALUE","");
        IupSetfAttribute(lbl_status,"APPEND",
                         _("Downloading info, this may be slow..."));
        (void)IupSetCallback(run_task,"ACTION_CB",(Icallback)_run_geocode);
        IupSetAttribute(run_task,"RUN","YES");
        IupSetAttribute(list_method,"VISIBLE","NO");
        break;
    case 2:
        LOG(LOGVERBOSE,_("Running geocode with geobytes"));
        IupSetAttribute(lbl_status,"VALUE","");
        IupSetfAttribute(lbl_status,"APPEND",
                         _("Downloading info, this may be slow..."));
        (void)IupSetCallback(run_task,"ACTION_CB",(Icallback)_run_geobytes);
        IupSetAttribute(run_task,"RUN","YES");
        IupSetAttribute(list_method,"VISIBLE","NO");
        break;
    case 3: {
        edt_address = IupSetAtt(NULL,IupText(NULL),
                                "VALUE","Enter Address...",
                                "EXPAND","HORIZONTAL",NULL);
        (void)IupSetCallback(edt_address,"GETFOCUS_CB",(Icallback)_address_clear);
        btn_address = IupSetAtt(NULL,IupButton(_("Lookup"),NULL),NULL);
        (void)IupSetCallback(btn_address,"ACTION",(Icallback)_address_lookup);
        hbox_address = IupHbox(edt_address,btn_address,NULL);
        if( (vbox_method!=NULL)
                && (hbox_address!=NULL)
                && (lbl_status!=NULL) )
            (void)IupInsert(vbox_method,lbl_status,hbox_address);
        else {
            LOG(LOGERR,_("Location search controls not created!"));
            return IUP_DEFAULT;
        }
        IupSetAttribute(list_method,"VISIBLE","NO");
        (void)IupMap(hbox_address);
        IupRefresh(hbox_address);
        break;
    }
    };
    return IUP_DEFAULT;
}
Ejemplo n.º 14
0
void guiMenu_OnInit ( void )
{
  guiHacks_OnInit();
  guiMenu = IupHList ( NULL );
  guiData = IupHList ( NULL );
  guiActionVB = IupHbox ( guiMenu, guiData, NULL );
  IupInsert ( guiDlg.vb, guiOrg.main.fset, guiActionVB );
  IupMap ( guiActionVB );
  IupSetAttribute ( guiActionVB, IUP_EXPAND, IUP_HORIZONTAL );
  IupSetAttribute ( guiMenu, IUP_EXPAND, IUP_HORIZONTAL );
  IupSetAttribute ( guiData, IUP_EXPAND, IUP_HORIZONTAL );
  IupSetCallback ( guiMenu, "VALUECHANGED_CB", guiMenu_OnValueChanged );
  IupSetCallback ( guiData, "VALUECHANGED_CB", guiData_OnValueChanged );
  guiMenu_OnLang();
}
Ejemplo n.º 15
0
static int iDialogSetMenuAttrib(Ihandle* ih, const char* value)
{
  if (!ih->handle)
  {
    Ihandle* menu = IupGetHandle(value);
    ih->data->menu = menu;
    return 1;
  }

  if (!value)
  {
    if (ih->data->menu && ih->data->menu->handle)
    {
      ih->data->ignore_resize = 1;
      IupUnmap(ih->data->menu);  /* this will remove the menu from the dialog */
      ih->data->ignore_resize = 0;

      ih->data->menu = NULL;
    }
  }
  else
  {
    Ihandle* menu = IupGetHandle(value);
    if (!menu || menu->iclass->nativetype != IUP_TYPEMENU || menu->parent)
      return 0;

    /* already the current menu and it is mapped */
    if (ih->data->menu && ih->data->menu==menu && menu->handle)
      return 1;

    /* the current menu is mapped, so unmap it */
    if (ih->data->menu && ih->data->menu->handle && ih->data->menu!=menu)
    {
      ih->data->ignore_resize = 1;
      IupUnmap(ih->data->menu);   /* this will remove the menu from the dialog */
      ih->data->ignore_resize = 0;
    }

    ih->data->menu = menu;

    menu->parent = ih;    /* use this to create a menu bar instead of a popup menu */

    ih->data->ignore_resize = 1;
    IupMap(menu);     /* this will automatically add the menu to the dialog */
    ih->data->ignore_resize = 0;
  }
  return 1;
}
Ejemplo n.º 16
0
static int cbAddTab(Ihandle* ih)
{
  Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS");
  Ihandle *vbox;

  vbox = IupFrame(IupVbox(IupLabel("Label XXX"), IupButton("Button XXX", "cbChildButton"), NULL));
  IupSetAttribute(vbox, "TABTITLE", "XXX");
  IupSetAttribute(vbox, "TITLE", "TABS XXX");

  IupAppend(tabs, vbox);
  IupMap(vbox);

  IupRefresh(tabs); /* update children layout */

  return IUP_DEFAULT;
}
Ejemplo n.º 17
0
static int cbInsertTab(Ihandle* ih)
{
  Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS");
  Ihandle* ref_vbox = IupGetHandle(IupGetAttribute(tabs, "VALUE"));
  Ihandle *vbox;

  vbox = IupFrame(IupVbox(IupLabel("Label YYY"), IupButton("Button YYY", "cbChildButton"), NULL));
  IupSetAttribute(vbox, "TABTITLE", "YYY");
  IupSetAttribute(vbox, "TITLE", "TABS YYY");

  IupInsert(tabs, ref_vbox, vbox);
  IupMap(vbox);

  IupRefresh(tabs); /* update children layout */

  return IUP_DEFAULT;
}
Ejemplo n.º 18
0
void CanvasCDSimpleTest(void)
{
  Ihandle *dlg, *canvas;

  canvas = IupCanvas(NULL);
  IupSetAttribute(canvas, "RASTERSIZE", "300x200"); /* initial size */

  IupSetCallback(canvas, "ACTION",  (Icallback)redraw_cb);
  IupSetCallback(canvas, "MAP_CB",  (Icallback)map_cb);
  IupSetCallback(canvas, "UNMAP_CB",  (Icallback)unmap_cb);
                   
  dlg = IupDialog(canvas);
  IupSetAttribute(dlg, "TITLE", "CD Simple Buffer Test");

  IupMap(dlg);
  IupSetAttribute(canvas, "RASTERSIZE", NULL);  /* release the minimum limitation */
 
  IupShowXY(dlg,IUP_CENTER,IUP_CENTER);
}
Ejemplo n.º 19
0
int main(int argc, char **argv)
{
  Ihandle* txt, *bt;
  IupOpen(&argc, &argv);
  IupOleControlOpen();

  // Creates an instance of the WebBrowser control
  Ihandle* control = IupOleControl("Shell.Explorer.2");

  // Sets production mode
  IupSetAttribute(control, "DESIGNMODE", "NO");

  // Creates a dialog containing the OLE control
  Ihandle* dlg = IupDialog(IupVbox(IupHbox(txt = IupText(""), bt = IupButton("Load", NULL), NULL), control, NULL));
  IupSetAttribute(dlg, "TITLE", "IupOle");
  IupSetAttribute(dlg, "MY_TEXT", (char*)txt);
  IupSetAttribute(txt, "EXPAND", "HORIZONTAL");
  IupSetCallback(bt, "ACTION", (Icallback)load_cb);

  // Maps the dialog to force the creation of the control
  IupMap(dlg);

  // Gathers the IUnknown pointer to access the control's interface

  IUnknown* punk = (IUnknown*) IupGetAttribute(control, "IUNKNOWN");
  IWebBrowser2 *pweb = NULL;
  punk->QueryInterface(IID_IWebBrowser2, (void **)&pweb);
  punk->Release();
  IupSetAttribute(dlg, "MY_WEB", (char*)pweb);

  // Shows dialog
  IupShow(dlg);

  IupMainLoop();

  // Releases the control interface
  pweb->Release();

  IupClose();

  return EXIT_SUCCESS;

}
Ejemplo n.º 20
0
static int iDetachBoxSetDetachAttrib(Ihandle* ih, const char* value)
{
  IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");

  /* Create new dialog */
  Ihandle *new_parent = IupDialog(NULL);
  Ihandle *old_dialog = IupGetDialog(ih);

  /* Set new dialog as child of the current application */
  IupSetAttributeHandle(new_parent, "PARENTDIALOG", old_dialog);

  if (detachedCB)
    detachedCB(ih, new_parent, 0, 0);

  /* Save current parent and reference child */
  ih->data->old_parent = ih->parent;
  ih->data->old_brother = ih->brother;

  IupMap(new_parent);

  /* Sets the new parent */
  IupReparent(ih, new_parent, NULL);

  /* Hide canvas bar */
  ih->data->barsize = 0;
  IupHide(ih->firstchild);

  /* Restores the cursor */
  IupSetAttribute(ih->firstchild, "CURSOR", "MOVE");

  /* Updates/redraws the layout of the dialog application */
  IupRefresh(old_dialog);

  IupSetAttribute(new_parent, "RASTERSIZE", NULL);
  IupRefresh(new_parent);

  /* Maps and shows the new dialog */
  IupShow(new_parent);

  (void)value;
  return 0;
}
Ejemplo n.º 21
0
void iupdrvReparent(Ihandle* ih)
{
  /* Intrinsics and Motif do NOT support reparent. 
     XReparentWindow can NOT be used because will reparent only the X-Windows windows.
     So must unmap and map again to obtain the same effect. */
  Widget new_parent = iupChildTreeGetNativeParentHandle(ih);
  Widget widget = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");  /* here is used as the native child because is the outmost component of the elemement */
  if (!widget) widget = ih->handle;
  if (XtParent(widget) != new_parent)
  {
    int old_visible = IupGetInt(ih, "VISIBLE");
    if (old_visible)
      IupSetAttribute(ih, "VISIBLE", "NO");
    motSaveAttributesRec(ih); /* this does not save everything... */
    IupUnmap(ih);
    IupMap(ih);
    if (old_visible)
      IupSetAttribute(ih, "VISIBLE", "Yes");
  }
}
Ejemplo n.º 22
0
void ColorbarTest(void)
{
  Ihandle *dlg, *cb;
  
  IupControlsOpen();

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

  cb = IupColorbar(); 
  IupSetAttribute(cb, "RASTERSIZE",     "70x");
  IupSetAttribute(cb, "EXPAND",         "VERTICAL");
  IupSetAttribute(cb, "NUM_PARTS",      "2");
  IupSetAttribute(cb, "SHOW_SECONDARY", "YES");
  IupSetAttribute(cb, "PREVIEW_SIZE",   "60");
//  IupSetAttribute(cb, "ACTIVE",   "NO");
//  IupSetAttribute(cb, "BGCOLOR",   "128 0 255");

  IupSetCallback(cb, "SELECT_CB", (Icallback)select_cb);
  IupSetCallback(cb, "CELL_CB",   (Icallback)cell_cb);
  IupSetCallback(cb, "SWITCH_CB", (Icallback)switch_cb);
  IupSetCallback(cb, "EXTENDED_CB", (Icallback)extended_cb);

  dlg = IupDialog(IupHbox(canvas, cb, NULL));
  IupSetAttribute(dlg, "MARGIN", "5x5");
  
  IupSetAttribute(dlg, "TITLE", "IupColorbar");
  
  /* Maps the dlg. This must be done before the creation of the CD canvas.
     Could also use MAP_CB callback. */
  IupMap(dlg);
 
  cdcanvas = cdCreateCanvas(CD_IUP, canvas);
   
  IupPopup(dlg, IUP_CENTER, IUP_CENTER);

  cdKillCanvas(cdcanvas);
}
Ejemplo n.º 23
0
static int _render_image(Ihandle *ih, char *text, int item, int state)
{
	if(state == 1)
	{
		LinkedList *ll = LL_get(images, item-1);
		if(ll == NULL || ll->contents == NULL)
			return IUP_ERROR;
		imImage* img = ll->contents;

		//Display the scaled image
		char buf[64];
		sprintf(buf,"%dx%d",img->width,img->height);
		IupSetAttribute(preview, "RASTERSIZE", buf);
		IupSetAttributeHandle(preview, "IMAGE", ll->iContents);
		IupRefresh(preview);

		//Recreate the grid where to put all the images
		Ihandle* child;
		while((child = IupGetChild(imgmod, 0)) != NULL)
			IupDestroy(child);
		IupSetInt(imgmod, "NUMDIV", ll->cols);

		//Put the images into the grid
		int i;
		for(i = 0; i < ll->cols * ll->rows; i++)
		{
			Ihandle* tinyimg = IupLabel(NULL);
			IupSetAttributeHandle(tinyimg, "IMAGE", ll->iGrid[i]);
			IupAppend(imgmod, tinyimg);
			IupMap(tinyimg);
		}
		IupRefresh(imgmod);
	}

	main_window_set_menu_state();
	return IUP_DEFAULT;
}
Ejemplo n.º 24
0
static void winShowXY(Ihandle* n, int x, int y)
{
  int CmdShow = SW_SHOWNORMAL;
  int Restored = 0;
  int was_hidden;
  char* value;

  IupMap(n);

  value = IupGetAttribute(n, "PLACEMENT");
  if(value && iupStrEqual(value, "MAXIMIZED"))
  {
    CmdShow = SW_SHOWMAXIMIZED;
    IupSetAttribute(n, "PLACEMENT", "NORMAL");
  }
  else if(value && iupStrEqual(value, "MINIMIZED"))
  {
    CmdShow = SW_SHOWMINIMIZED;
    IupSetAttribute(n, "PLACEMENT", "NORMAL");
  }
  else if(value && iupStrEqual(value, "FULL"))
  {
    RECT rect;
    /* client area is the size of the screen */
    GetWindowRect(GetDesktopWindow(), &rect);
    currentwidth(n) = rect.right - rect.left;
    currentheight(n) = rect.bottom - rect.top;

    x = -iupwinDialogDecorLeft(n);
    y = -iupwinDialogDecorTop(n);

    IupSetAttribute(n, "PLACEMENT", "NORMAL");
  }

  if (iupCheck(n, "FULLSCREEN")!=YES)
  {
    /* if NOT full screen*/
    UINT flags = 0;
    int width  = currentwidth(n) + iupwinDialogDecorX(n);
    int height = currentheight(n) +  iupwinDialogDecorY(n);
    iupwinAdjustPos(n, &x, &y, width, height);
    if (x == IUP_CURRENT || y == IUP_CURRENT) /* if iupwinAdjustPos did not change x and y */ 
      flags = SWP_NOMOVE;
    winRefreshChildSize(n);
    SetWindowPos((HWND)handle(n), HWND_TOP, x, y, width, height, flags);
  }

  was_hidden = !IsWindowVisible((HWND)handle(n));

  if ((IsIconic((HWND)handle(n)) && CmdShow != SW_SHOWMINIMIZED) ||
    (IsZoomed((HWND)handle(n)) && CmdShow != SW_SHOWMAXIMIZED))
    Restored = 1;

  ShowWindow ((HWND)handle(n), CmdShow);
  UpdateWindow ((HWND)handle(n));

  if (was_hidden)
  {
    win_nvisiblewin++;

    iupSetEnv(n, "_IUPWIN_SHOWING", IUP_YES);
    iupdrvSetAttribute(n, IUP_VISIBLE, IUP_YES);
    iupSetEnv(n, "_IUPWIN_SHOWING", NULL);
  }

  if (iupGetEnv(n, "_IUPWIN_POPUP_LEVEL"))
  {
    /* was disabled by a Popup, re-enable and reposition */
    EnableWindow((HWND)handle(n),TRUE);
    iupSetEnv(n, "_IUPWIN_POPUP_LEVEL", NULL); /* is at the current popup level */
  }

  {
    IFni show_cb = (IFni)IupGetCallback(n, IUP_SHOW_CB);
    if(show_cb)
    {
      int status = (CmdShow==SW_SHOWMINIMIZED)? IUP_MINIMIZE: (Restored? IUP_RESTORE: IUP_SHOW);
      show_cb(n, status);
    }
  }
}
Ejemplo n.º 25
0
int IupGetText(const char* title, char* text)
{
  Ihandle *ok, *cancel, *multi_text, *button_box, *dlg_box, *dlg;
  int bt;

  multi_text = IupMultiLine(NULL);
  IupSetAttribute(multi_text,"EXPAND", "YES");
  IupSetAttribute(multi_text,"VALUE", text);
  IupSetAttribute(multi_text,"FONT", "Courier, 12");
  IupSetAttribute(multi_text, "VISIBLELINES", "10");
  IupSetAttribute(multi_text, "VISIBLECOLUMNS", "50");

  ok = IupButton("OK", NULL);
  IupSetAttribute(ok, "PADDING", "20x5");
  IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK);

  cancel  = IupButton(iupStrMessageGet("IUP_CANCEL"), NULL);
  IupSetAttribute(cancel, "PADDING", "20x5");
  IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL);

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

  dlg_box = IupVbox(
    multi_text,
    button_box,
    NULL);

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

  dlg = IupDialog (dlg_box);

  IupSetAttribute(dlg,"TITLE", title);
  IupSetAttribute(dlg,"MINBOX","NO");
  IupSetAttribute(dlg,"MAXBOX","NO");
  IupSetAttributeHandle(dlg,"DEFAULTENTER", ok);
  IupSetAttributeHandle(dlg,"DEFAULTESC", cancel);
  IupSetAttribute(dlg,"PARENTDIALOG", IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON"));

  IupMap(dlg);

  IupSetAttribute(multi_text, "VISIBLELINES", NULL);
  IupSetAttribute(multi_text, "VISIBLECOLUMNS", NULL);

  IupPopup(dlg, IUP_CENTER, IUP_CENTER);

  bt = IupGetInt(dlg, "STATUS");
  if (bt==1)
    strcpy(text, IupGetAttribute(multi_text, "VALUE"));
  else
    bt = 0; /* return 0 instead of -1 */

  IupDestroy(dlg);
  return bt;
}
Ejemplo n.º 26
0
int  iupDataEntry(int    maxlin,
                  int*   maxcol,
                  int*   maxscr,
                  char*  title,
                  char** text,
                  char** data)
{
  int i, bt;
  Ihandle *ok, *cancel, *dlg, *vb, *hb, **txt, **lbl, *button_box, *dlg_box;

  txt = (Ihandle **)calloc(maxlin, sizeof(Ihandle*));
  if (txt == NULL) return -2;
  lbl = (Ihandle **)calloc(maxlin+1, sizeof(Ihandle*));

  vb = IupVbox(NULL);

  for (i=0; i<maxlin; i++)
  {
    txt[i] = IupText(NULL);
    IupSetAttribute(txt[i],"VALUE",data[i]);
    IupSetfAttribute(txt[i],"VISIBLECOLUMNS","%dx", maxscr[i]);
    IupSetfAttribute(txt[i],"NC", "%d", maxcol[i]);
    IupSetAttribute(txt[i],"EXPAND","HORIZONTAL");

    hb = IupHbox(lbl[i] = IupLabel(text[i]), txt[i], NULL);
    IupSetAttribute(hb,"MARGIN","0x0");
    IupSetAttribute(hb,"ALIGNMENT","ACENTER");
    IupAppend(vb, hb);
  }
  lbl[i] = NULL;
  IupInsert(vb, NULL, IupNormalizerv(lbl));

  ok = IupButton("OK", NULL);
  IupSetAttribute(ok, "PADDING", "20x0");
  IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK);

  cancel = IupButton(iupStrMessageGet("IUP_CANCEL"), NULL);
  IupSetAttribute(cancel, "PADDING", "20x0");
  IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL);

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

  dlg_box = IupVbox(
    IupFrame(vb),
    button_box,
    NULL);
  IupSetAttribute(dlg_box,"MARGIN","10x10");
  IupSetAttribute(dlg_box,"GAP","5");

  dlg = IupDialog(dlg_box);

  IupSetAttribute(dlg,"TITLE",title);
  IupSetAttribute(dlg,"MINBOX","NO");
  IupSetAttribute(dlg,"MAXBOX","NO");
  IupSetAttributeHandle(dlg,"DEFAULTENTER", ok);
  IupSetAttributeHandle(dlg,"DEFAULTESC", cancel);
  IupSetAttribute(dlg,"PARENTDIALOG",IupGetGlobal("PARENTDIALOG"));
  IupSetAttribute(dlg,"ICON", IupGetGlobal("ICON"));

  IupMap(dlg);

  IupSetfAttribute(dlg,"MAXSIZE", "65535x%d", IupGetInt2(dlg, "RASTERSIZE"));
  IupSetAttribute(dlg,"MINSIZE", IupGetAttribute(dlg, "RASTERSIZE"));

  IupPopup(dlg,IUP_CENTER,IUP_CENTER);

  for (i=0; i<maxlin; i++)
  {
    data[i] = (char *)iupStrDup(IupGetAttribute(txt[i], "VALUE"));
  }

  free(txt);

  bt = IupGetInt(dlg, "STATUS");
  IupDestroy(dlg);
  return bt;
}
Ejemplo n.º 27
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);
}
Ejemplo n.º 28
0
static int iDetachBoxButton_CB(Ihandle* bar, int button, int pressed, int x, int y, char* status)
{
  Ihandle* ih = bar->parent;
  Ihandle* mainDlg = IupGetDialog(ih);

  if (button != IUP_BUTTON1)
    return IUP_DEFAULT;

  if (!ih->data->is_holding && pressed)  /* DRAG BEGIN */
  {
    ih->data->is_holding = 1;
    
    /* Change cursor */
    IupSetAttribute(bar, "CURSOR", "IupDetachBoxCursor");
  }
  else if (ih->data->is_holding && !pressed)  /* DRAG END */
  {
    Ihandle *new_parent;
    IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");
    int cur_x, cur_y;

    ih->data->is_holding = 0;

    iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');

    /* Create new dialog */
    new_parent = IupDialog(NULL);

    /* Set new dialog as child of the current application */
    IupSetAttributeHandle(new_parent, "PARENTDIALOG", mainDlg);

    if (detachedCB)
    {
      int ret = detachedCB(ih, new_parent, cur_x, cur_y);
      if (ret == IUP_IGNORE)
      {
        IupDestroy(new_parent);
        return IUP_DEFAULT;
      }
    }

    /* Save current parent and reference child */
    ih->data->old_parent = ih->parent;
    ih->data->old_brother = ih->brother;

    IupMap(new_parent);

    /* Sets the new parent */
    IupReparent(ih, new_parent, NULL);

    /* Restores the cursor */
    IupSetAttribute(bar, "CURSOR", "MOVE");

    /* Hide canvas bar */
    ih->data->barsize = 0;
    IupHide(bar);

    /* Updates/redraws the layout of the dialog application */
    IupRefresh(mainDlg);

    IupSetAttribute(new_parent, "RASTERSIZE", NULL);
    IupRefresh(new_parent);

    /* Maps and shows the new dialog */
    IupShowXY(new_parent, cur_x, cur_y);
  }

  (void)x;
  (void)y;
  (void)status;
  return IUP_DEFAULT;
}
Ejemplo n.º 29
0
static int Map(lua_State *L)
{
  Ihandle *ih = iuplua_checkihandle(L,1);
  lua_pushinteger(L, IupMap(ih));
  return 1;
}
Ejemplo n.º 30
0
void CanvasTest(void)
{
  Ihandle *dlg, *canvas, *box, *image;

  //image = IupImage(32, 32, pixmap_cursor);
  //IupSetAttribute(image, "1", "255 0 0"); 
  //IupSetAttribute(image, "2", "128 0 0"); 
  //IupSetAttribute(image, "HOTSPOT", "21:10");

  image = IupImage(15,15, matrx_img_cur_excel);
  IupSetAttribute (image, "0", "BGCOLOR"); 
  IupSetAttribute (image, "1", "0 0 0"); 
  IupSetAttribute (image, "2", "255 255 255"); 
  IupSetAttribute (image, "HOTSPOT", "7:7");

  box = IupVbox(NULL);
  IupSetAttribute(box, "MARGIN", "5x5");

  canvas = IupCanvas(NULL);
  IupAppend(box, canvas);
  IupSetAttribute(canvas, "RASTERSIZE", "300x200");
  IupSetAttribute(canvas, "TIP", "Canvas Tip");
  IupSetAttribute(canvas, "SCROLLBAR", "HORIZONTAL");
  //IupSetAttribute(canvas, "BGCOLOR", "0 255 0");
//  IupSetAttribute(canvas, "SCROLLBAR", "NO");
//  IupSetAttribute(canvas, "XAUTOHIDE", "NO");
  IupSetAttribute(canvas, "XMAX", "600");
  IupSetAttribute(canvas, "DX", "300");  /* use a 1x1 scale, this value is updated in RESIZE_CB,
                                           so when the canvas is larger than 600 
                                           it will hide the scrollbar */
  //IupSetAttributeHandle(canvas, "CURSOR", image);
  IupSetAttribute(canvas, "DROPTARGET", "YES");
  IupSetAttribute(canvas, "DROPTYPES", "TEXT");
  IupSetCallback (canvas, "DROPDATA_CB", (Icallback)testDropData_cb);

//  IupSetAttribute(canvas, "BORDER", "NO");
//  IupSetAttribute(canvas, "CURSOR", "CROSS");

  IupSetCallback(canvas, "MAP_CB",       (Icallback)map_cb);

  IupSetCallback(canvas, "KEYPRESS_CB",  (Icallback)keypress_cb);
  IupSetCallback(canvas, "K_ANY",        (Icallback)k_any);
  IupSetCallback(canvas, "HELP_CB",      (Icallback)help_cb);

  IupSetCallback(canvas, "GETFOCUS_CB",  (Icallback)getfocus_cb); 
  IupSetCallback(canvas, "KILLFOCUS_CB", (Icallback)killfocus_cb);
  IupSetCallback(canvas, "FOCUS_CB", (Icallback)focus_cb);
  IupSetCallback(canvas, "ENTERWINDOW_CB", (Icallback)enterwindow_cb);
  IupSetCallback(canvas, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb);

  IupSetCallback(canvas, "BUTTON_CB",    (Icallback)button_cb);
//  IupSetCallback(canvas, "MOTION_CB",    (Icallback)motion_cb);
  IupSetCallback(canvas, "SCROLL_CB",  (Icallback)scroll_cb);
//  IupSetCallback(canvas, "WHEEL_CB",    (Icallback)wheel_cb);

  IupSetCallback(canvas, "RESIZE_CB",    (Icallback)resize_cb);
//  IupSetAttribute(canvas, "BGCOLOR", "255 128 128");
  IupSetCallback(canvas, "ACTION",  (Icallback)action);
                   
  // Windows and GTK Only  
  IupSetCallback(canvas, "DROPFILES_CB", (Icallback)dropfiles_cb);

//{
//  Ihandle* cnv = IupCanvas(NULL);
//  IupAppend(box, cnv);
//  IupSetAttribute(cnv, "RASTERSIZE", "300x200");
//  IupSetAttribute(cnv, "CURSOR", "NONE");
//}

  dlg = IupDialog(box);
  IupSetAttribute(dlg, "TITLE", "IupCanvas Test");

printf("IupMap\n");
  IupMap(dlg);
printf("IupShow\n");
  IupShow(dlg);
  IupSetAttribute(canvas, "RASTERSIZE", NULL);  /* release the minimum limitation */
}