Beispiel #1
0
static int iPlayTimer_CB(Ihandle* timer)
{
  FILE* file = (FILE*)IupGetAttribute(timer, "_IUP_PLAYFILE");
  if(feof(file) || ferror(file))
  {
    fclose(file);
    IupSetAttribute(timer, "RUN", "NO");
    IupDestroy(timer);
    IupSetGlobal("_IUP_PLAYTIMER", NULL);
    return IUP_IGNORE;
  }
  else
  {
    int cont = 1;
    int mode = IupGetInt(timer, "_IUP_PLAYMODE");

/*    while (cont)    //did not work, menus do not receive the click, why? */
    {
      cont = iPlayAction(file, mode);

      if (cont == -1)  /* error */
      {
        fclose(file);
        IupSetAttribute(timer, "RUN", "NO");
        IupDestroy(timer);
        IupSetGlobal("_IUP_PLAYTIMER", NULL);
        return IUP_IGNORE;
      }
    }

    IupFlush();
  }

  return IUP_DEFAULT;
}
Beispiel #2
0
static int motListSetClipboardAttrib(Ihandle *ih, const char *value)
{
  Widget cbedit;
  if (!ih->data->has_editbox)
    return 0;

  XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);

  if (iupStrEqualNoCase(value, "COPY"))
  {
    Ihandle* clipboard;
    char *str = XmTextFieldGetSelection(cbedit);
    if (!str) return 0;

    clipboard = IupClipboard();
    IupSetAttribute(clipboard, "TEXT", str);
    IupDestroy(clipboard);

    XtFree(str);
  }
  else if (iupStrEqualNoCase(value, "CUT"))
  {
    Ihandle* clipboard;
    char *str = XmTextFieldGetSelection(cbedit);
    if (!str) return 0;

    clipboard = IupClipboard();
    IupSetAttribute(clipboard, "TEXT", str);
    IupDestroy(clipboard);

    XtFree(str);

    /* disable callbacks */
    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
    XmTextFieldRemove(cbedit);
    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "PASTE"))
  {
    Ihandle* clipboard;
    char *str;

    clipboard = IupClipboard();
    str = IupGetAttribute(clipboard, "TEXT");

    /* disable callbacks */
    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
    XmTextFieldRemove(cbedit);
    XmTextFieldInsert(cbedit, XmTextFieldGetInsertionPosition(cbedit), str);
    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "CLEAR"))
  {
    /* disable callbacks */
    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
    XmTextFieldRemove(cbedit);
    iupAttribSet(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  return 0;
}
Beispiel #3
0
void cleanup() {

    if(timeout) { IupDestroy(timeout); }
    if(timer)   { IupDestroy(timer);   }

    IupClose();
    endTimePeriod(); // try close if not closing
}
Beispiel #4
0
int main(int argc, char **argv)
{
  IupOpen(&argc, &argv);      
  IupControlsOpen();      
  func_1();
  IupShowXY(IupGetHandle("dlg"),IUP_CENTER,IUP_CENTER);
  IupMainLoop();
  IupDestroy(IupGetHandle("img1"));
  IupDestroy(IupGetHandle("img2"));
  IupDestroy(IupGetHandle("dlg"));
  IupControlsClose();      
  IupClose();  
  return 0;
}
Beispiel #5
0
int select_file(Ihandle* parent_dlg, int is_open)
{
  Ihandle* config = (Ihandle*)IupGetAttribute(parent_dlg, "CONFIG");
  Ihandle* canvas = IupGetDialogChild(parent_dlg, "CANVAS");
  const char* dir = IupConfigGetVariableStr(config, "MainWindow", "LastDirectory");

  Ihandle* filedlg = IupFileDlg();
  if (is_open)
    IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN");
  else
  {
    IupSetAttribute(filedlg, "DIALOGTYPE", "SAVE");
    IupSetStrAttribute(filedlg, "FILE", IupGetAttribute(canvas, "FILENAME"));
  }
  IupSetAttribute(filedlg, "EXTFILTER", "Image Files|*.bmp;*.jpg;*.png;*.tif;*.tga|All Files|*.*|");
  IupSetStrAttribute(filedlg, "DIRECTORY", dir);
  IupSetAttributeHandle(filedlg, "PARENTDIALOG", parent_dlg);

  IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT);
  if (IupGetInt(filedlg, "STATUS") != -1)
  {
    char* filename = IupGetAttribute(filedlg, "VALUE");
    if (is_open)
      open_file(parent_dlg, filename);
    else
      saveas_file(canvas, filename);

    dir = IupGetAttribute(filedlg, "DIRECTORY");
    IupConfigSetVariableStr(config, "MainWindow", "LastDirectory", dir);
  }

  IupDestroy(filedlg);
  return IUP_DEFAULT;
}
Beispiel #6
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;

}
Beispiel #7
0
void iupTextUpdateFormatTags(Ihandle* ih)
{
  /* called when the element is mapped */
  int i, count = iupArrayCount(ih->data->formattags);
  Ihandle** tag_array = (Ihandle**)iupArrayGetData(ih->data->formattags);

  /* must update VALUE before updating the format */
  iTextUpdateValueAttrib(ih);

  for (i = 0; i < count; i++)
  {
    char* bulk = iupAttribGet(tag_array[i], "BULK");
    if (bulk && iupStrBoolean(bulk))
    {
      Ihandle* child;
      void* state = iupdrvTextAddFormatTagStartBulk(ih);

      char* cleanout = iupAttribGet(tag_array[i], "CLEANOUT");
      if (cleanout && iupStrBoolean(cleanout))
        IupSetAttribute(ih, "REMOVEFORMATTING", "ALL");

      for (child = tag_array[i]->firstchild; child; child = child->brother)
        iupdrvTextAddFormatTag(ih, child, 1);

      iupdrvTextAddFormatTagStopBulk(ih, state);
    }
    else
      iupdrvTextAddFormatTag(ih, tag_array[i], 0);
    IupDestroy(tag_array[i]);
  }
  iupArrayDestroy(ih->data->formattags);
  ih->data->formattags = NULL;
}
Beispiel #8
0
/* main program */
int main(int argc, char **argv)
{
  char *error=NULL;

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

  /* loads LED */
  if((error = IupLoad("vbox.led")))
  {
    IupMessage("LED error", error);
    return 1 ;
  }

  dlg = IupGetHandle("Alinhav");

  /* sets callbacks */
//  IupSetFunction( "acao_pausa", (Icallback) btn_pause_cb );

  /* shows dialog */
//  IupShowXY(dlg,IUP_CENTER,IUP_CENTER);
  IupShow(dlg);

  /* main loop */
  IupMainLoop();

  IupDestroy(dlg);

  /* ends IUP */
  IupControlsClose() ;
  IupClose();

  return 0 ;
}
Beispiel #9
0
int main(int argc, char **argv)
{
  IupOpen(&argc, &argv);

  memset(password, 0, 100);

  text = IupText(NULL);
  IupSetAttribute(text, "SIZE",  "200x");
  IupSetCallback(text, "ACTION", (Icallback) action);
  IupSetCallback(text, "K_ANY", (Icallback) k_any);

  pwd = IupText(NULL);
  IupSetAttribute(pwd, "READONLY", "YES");
  IupSetAttribute(pwd, "SIZE", "200x");

  dlg = IupDialog(IupVbox(text, pwd, NULL));
  IupSetAttribute(dlg, "TITLE", "IupText");

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);

  IupMainLoop();
  IupDestroy(dlg);
  IupClose();
  return 0;
}
Beispiel #10
0
int main(int argc, char **argv)
{
  Ihandle *dlg, *bt, *box, *lbl, *ml, *vbox;
  IupOpen(&argc, &argv);

  bt = IupButton("Button", NULL);
  //IupSetAttribute(bt, "EXPAND", "VERTICAL");  /* This is the only necessary EXPAND */
  IupSetAttribute(bt, "EXPAND", "YES");

  box = IupSbox(bt);
  IupSetAttribute(box, "DIRECTION", "SOUTH");  /* place at the bottom of the button */
//  IupSetAttribute(box, "COLOR", "0 255 0");

  ml = IupMultiLine(NULL);
  IupSetAttribute(ml, "EXPAND", "YES");
  IupSetAttribute(ml, "VISIBLELINES", "5");
  vbox = IupVbox(box, ml, NULL);

  lbl = IupLabel("Label");
  IupSetAttribute(lbl, "EXPAND", "VERTICAL");

  dlg = IupDialog(IupHbox(vbox, lbl, NULL));
  IupSetAttribute(dlg, "TITLE", "IupSbox Example");
  IupSetAttribute(dlg, "MARGIN", "10x10");
  IupSetAttribute(dlg, "GAP", "10");

  IupShow(dlg);

  IupMainLoop();
  IupDestroy(dlg);
  IupClose();
  return 1;
}
Beispiel #11
0
static void winDialogUnMapMethod(Ihandle* ih)
{
    if (ih->data->menu)
    {
        ih->data->menu->handle = NULL; /* the dialog will destroy the native menu */
        IupDestroy(ih->data->menu);
    }

    if (iupAttribGet(ih, "_IUPDLG_HASTRAY"))
        winDialogSetTrayAttrib(ih, NULL);

    iupwinTipsDestroy(ih);
    iupwinDestroyDragDrop(ih);

    /* remove the association before destroying */
    iupwinHandleRemove(ih->handle);

    /* Destroys the window, so we can destroy the class */
    if (iupAttribGetBoolean(ih, "MDICHILD"))
    {
        /* for MDICHILDs must send WM_MDIDESTROY, instead of calling DestroyWindow */
        Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
        SendMessage(client->handle, WM_MDIDESTROY, (WPARAM)ih->handle, 0);

        winDialogMDIRefreshMenu(ih);
    }
    else
        DestroyWindow(ih->handle); /* this will destroy the Windows children also. */
    /* but IupDestroy already destroyed the IUP children */
    /* so it is safe to call DestroyWindow */
}
Beispiel #12
0
int iupTextSetAddFormatTagHandleAttrib(Ihandle* ih, const char* value)
{
  Ihandle* formattag = (Ihandle*)value;
  if (!iupObjectCheck(formattag))
    return 0;

  if (ih->handle)
  {
    /* must update VALUE before updating the format */
    iTextUpdateValueAttrib(ih);

    iupdrvTextAddFormatTag(ih, formattag);
    IupDestroy(formattag);
  }
  else
  {
    Ihandle** tag_array;
    int i;

    if (!ih->data->formattags)
      ih->data->formattags = iupArrayCreate(10, sizeof(Ihandle*));

    i = iupArrayCount(ih->data->formattags);
    tag_array = (Ihandle**)iupArrayInc(ih->data->formattags);
    tag_array[i] = formattag;
  }
  return 0;
}
Beispiel #13
0
int item_saveas_action_cb(Ihandle* item_saveas)
{
  Ihandle* multitext = IupGetDialogChild(item_saveas, "MULTITEXT");
  Ihandle *filedlg = IupFileDlg();
  IupSetAttribute(filedlg, "DIALOGTYPE", "SAVE");
  IupSetAttribute(filedlg, "FILTER", "*.txt");
  IupSetAttribute(filedlg, "FILTERINFO", "Text Files");
  IupSetAttributeHandle(filedlg, "PARENTDIALOG", IupGetDialog(item_saveas));

  IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT);

  if (IupGetInt(filedlg, "STATUS") != -1)
  {
    Ihandle* config = (Ihandle*)IupGetAttribute(multitext, "CONFIG");
    char* filename = IupGetAttribute(filedlg, "VALUE");
    char* str = IupGetAttribute(multitext, "VALUE");
    int count = IupGetInt(multitext, "COUNT");
    write_file(filename, str, count);

    IupConfigRecentUpdate(config, filename);
  }

  IupDestroy(filedlg);
  return IUP_DEFAULT;
}
Beispiel #14
0
void iupwinVersion(void)
{
   Ihandle* dial, *ok;

   dial = IupDialog(IupVbox(IupFrame(IupVbox(
                        IupLabel(IupVersion()),
                        IupLabel(IUP_VERSION_DATE),
                        IupLabel(IUP_COPYRIGHT),
                        NULL)), 
                      ok = IupButton("Ok", NULL),
                      NULL));

   IupSetCallback(ok, "ACTION", (Icallback)ok_cb);

   IupSetAttribute(dial,IUP_TITLE,"IUP");
   IupSetAttribute(dial,IUP_MENUBOX,IUP_NO);
   IupSetAttribute(dial,IUP_MINBOX,IUP_NO);
   IupSetAttribute(dial,IUP_MAXBOX,IUP_NO);
   IupSetAttribute(dial,IUP_RESIZE,IUP_NO);

   IupSetAttribute(dial,"GAP","5");
   IupSetAttribute(dial,"MARGIN","5");

   IupPopup(dial, IUP_CENTER, IUP_CENTER);
   IupDestroy(dial);
}
Beispiel #15
0
static int iMatrixExSetPasteAttrib(Ihandle *ih, const char* value)
{
  int lin=0, col=0;

  Ihandle* clipboard = IupClipboard();
  char* data = IupGetAttribute(clipboard, "TEXT");
  IupDestroy(clipboard);

  if (iupStrEqualNoCase(value, "FOCUS"))
    IupGetIntInt(ih, "FOCUS_CELL", &lin, &col);
  else if (iupStrEqualNoCase(value, "MARKED"))
  {
    char *marked = IupGetAttribute(ih,"MARKED");
    if (marked)
    {
      int num_lin = IupGetInt(ih, "NUMLIN");
      int num_col = IupGetInt(ih, "NUMCOL");
      iMatrixExCellMarkedStart(marked, num_lin, num_col, &lin, &col);
    }
  }
  else
  {
    if (iupStrToIntInt(value, &lin, &col, ':')!=2)
      return 0;
  }

  iMatrixExPasteData(ih, data, lin, col, "PASTECLIP");
  return 0;
}
Beispiel #16
0
int main(int argc, char* argv[])
{
  Ihandle* dlg;

  IupOpen(&argc, &argv);

  dlg = CreateDialog();

  IupShow(dlg);
  
  /* Try to get a file name from the command line. */
  if (argc > 1)
    ShowImage(argv[1], dlg);
  else   
  {
    char file_name[1024] = "*.*";
    if (IupGetFile(file_name) == 0)
      ShowImage(file_name, dlg);
  }
                                   
  IupMainLoop();
  IupDestroy(dlg);
  IupClose();

  return 0;
}
Beispiel #17
0
static int k_any(Ihandle *ih, int c)
{
  switch(c)
  {
  case K_m:
    IupSetGlobal("PARENTDIALOG", "_MAIN_DIALOG_TEST_");
    IupMessage("IupMessage Test", "Message Text\nSecond Line.");
    IupSetGlobal("PARENTDIALOG", NULL);
    break;
  case K_e:
    new_message("ERROR", NULL);
    break;
  case K_i:
    new_message("INFORMATION", NULL);
    break;
  case K_w:
    new_message("WARNING", "OKCANCEL");
    break;
  case K_q:
    new_message("QUESTION", "YESNO");
    break;
  case K_c:
    new_color();
    break;
  case K_f:
    new_font();
    break;
  case K_o:
    new_file("OPEN", 0);
    break;
  case K_O:
    new_file("OPEN", 1);
    break;
  case K_G:
    new_file("OPEN", 2);
    break;
  case K_s:
    new_file("SAVE", 0);
    break;
  case K_d:
    new_file("DIR", 0);
    break;
  case K_a:
    new_alarm();
    break;
  case K_g:
    new_getfile();
    break;
  case K_t:
    new_gettext();
    break;
  case K_l:
    new_list();
    break;
  case K_ESC:
    IupDestroy(ih);
    return IUP_IGNORE;
  }
  return IUP_DEFAULT;
}
Beispiel #18
0
static int rightclick_cb(Ihandle* ih, int id)
{
  Ihandle *popup_menu;
  char attr[50];

  popup_menu = IupMenu(
    IupItem ("Node Info","nodeinfo"),
    IupItem ("Rename Node","renamenode"),
    IupSeparator(),
    IupItem ("Add Leaf","addleaf"),
    IupItem ("Add Branch","addbranch"),
    IupItem ("Insert Leaf","insertleaf"),
    IupItem ("Insert Branch","insertbranch"),
    IupItem ("Remove Node","removenode"),
    IupItem ("Remove Children","removechild"),
    IupItem ("Remove Marked","removemarked"),
    IupItem ("Remove All","removeall"),
    IupItem ("Toggle State","togglestate"),
    IupItem ("Expand All","expandall"),
    IupItem ("Contract All","contractall"),
    IupSubmenu("Focus", IupMenu(
      IupItem ("ROOT", "selectnode"),
      IupItem ("LAST", "selectnode"),
      IupItem ("PGUP", "selectnode"),
      IupItem ("PGDN", "selectnode"),
      IupItem ("NEXT", "selectnode"),
      IupItem ("PREVIOUS", "selectnode"),
      NULL)),
    IupSubmenu("Mark", IupMenu(
      IupItem ("INVERT", "selectnode"),
      IupItem ("BLOCK", "selectnode"),
      IupItem ("CLEARALL", "selectnode"),
      IupItem ("MARKALL", "selectnode"),
      IupItem ("INVERTALL", "selectnode"),
      NULL)),
    NULL);
    
  IupSetFunction("nodeinfo", (Icallback) nodeinfo);
  IupSetFunction("selectnode", (Icallback) selectnode);
  IupSetFunction("addleaf",    (Icallback) addleaf);
  IupSetFunction("addbranch",  (Icallback) addbranch);
  IupSetFunction("insertleaf",    (Icallback) insertleaf);
  IupSetFunction("insertbranch",  (Icallback) insertbranch);
  IupSetFunction("removenode", (Icallback) removenode);
  IupSetFunction("removechild", (Icallback) removechild);
  IupSetFunction("removemarked", (Icallback) removemarked);
  IupSetFunction("renamenode", (Icallback) renamenode);
  IupSetFunction("togglestate", (Icallback) togglestate);
  IupSetFunction("removeall", (Icallback) removeall);
  IupSetFunction("expandall", (Icallback) expandall);
  IupSetFunction("contractall", (Icallback) contractall);

//  sprintf(attr, "%d", id);
//  IupSetAttribute(ih, "VALUE", attr);
  IupPopup(popup_menu, IUP_MOUSEPOS, IUP_MOUSEPOS);

  IupDestroy(popup_menu);

  return IUP_DEFAULT;
}
Beispiel #19
0
// Address lookup function
static int _address_lookup(/*@unused@*/ Ihandle *ih) {
    char *result = IupGetAttribute(edt_address,"VALUE");
    float lat,lon;
    char city[100];
    int rescode;

    if( result == NULL )
        return IUP_DEFAULT;

    IupSetAttribute(list_method,"VISIBLE","YES");
    IupSetAttribute(list_method,"VALUE","0");
    IupSetAttribute(lbl_status,"VALUE","");
    IupSetfAttribute(lbl_status,"APPEND",
                     _("Downloading info, this may be slow..."));
    rescode=location_address_lookup(result,&lat,&lon,city,100);
    // Destroy address box
    if( hbox_address )
        IupDestroy(hbox_address);
    hbox_address = btn_address = edt_address = NULL;
    if( dialog_location )
        IupRefresh(dialog_location);
    if(!rescode) {
        IupSetAttribute(lbl_status,"APPEND",_("Unable to download data"));
        return IUP_DEFAULT;
    }

    IupSetfAttribute(lbl_status,"APPEND",_("city: %s"),city);
    IupSetfAttribute(lbl_status,"APPEND",_("lat/lon: %.2f,%.2f"),lat,lon);
    IupSetfAttribute(edt_lat,"VALUE","%f",lat);
    IupSetfAttribute(edt_lon,"VALUE","%f",lon);

    return IUP_DEFAULT;
}
Beispiel #20
0
int item_open_action_cb(Ihandle* item_open)
{
  Ihandle* multitext = IupGetDialogChild(item_open, "MULTITEXT");
  Ihandle *filedlg = IupFileDlg();
  IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN");
  IupSetAttribute(filedlg, "FILTER", "*.txt");
  IupSetAttribute(filedlg, "FILTERINFO", "Text Files");
  IupSetAttributeHandle(filedlg, "PARENTDIALOG", IupGetDialog(item_open));

  IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT);

  if (IupGetInt(filedlg, "STATUS") != -1)
  {
    char* filename = IupGetAttribute(filedlg, "VALUE");
    char* str = read_file(filename);
    if (str)
    {
      IupSetStrAttribute(multitext, "VALUE", str);
      free(str);
    }
  }

  IupDestroy(filedlg);
  return IUP_DEFAULT;
}
Beispiel #21
0
void main(int argc, char* argv[])
{
  Ihandle* dlg = NULL;
  Ihandle* cells  = NULL;

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

  cells  = create();
  dlg = IupDialog(cells);

  IupSetAttribute(dlg, "RASTERSIZE", "400x400");
  IupSetAttribute(dlg, "TITLE", "IupCells");

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER) ;
  IupSetAttribute(dlg, "RASTERSIZE", NULL);

  IupMainLoop() ;

  IupDestroy(dlg);

  IupClose();

  return 0;
}
Beispiel #22
0
void iupNamesDestroyHandles(void)
{
    char *name;
    Ihandle** ih_array, *ih;
    int count, i = 0;

    count = iupTableCount(inames_strtable);
    if (!count)
        return;

    ih_array = (Ihandle**)malloc(count * sizeof(Ihandle*));

    /* store the names before updating so we can remove elements in the loop */
    name = iupTableFirst(inames_strtable);
    while (name)
    {
        ih = (Ihandle*)iupTableGetCurr(inames_strtable);
        if (iupObjectCheck(ih))
        {
            ih_array[i] = ih;
            i++;
        }
        name = iupTableNext(inames_strtable);
    }

    count = i;
    for (i = 0; i < count; i++)
    {
        if (iupObjectCheck(ih_array[i]))
            IupDestroy(ih_array[i]);
    }

    free(ih_array);
}
Beispiel #23
0
int edit_menu_open_cb(Ihandle* ih)
{
  Ihandle *clipboard = IupClipboard(); 

  Ihandle *item_paste = IupGetDialogChild(ih, "ITEM_PASTE");
  Ihandle *item_cut = IupGetDialogChild(ih, "ITEM_CUT");
  Ihandle *item_delete = IupGetDialogChild(ih, "ITEM_DELETE");
  Ihandle *item_copy = IupGetDialogChild(ih, "ITEM_COPY");
  Ihandle* multitext = IupGetDialogChild(ih, "MULTITEXT");

  if (!IupGetInt(clipboard, "TEXTAVAILABLE"))
    IupSetAttribute(item_paste, "ACTIVE", "NO");
  else
    IupSetAttribute(item_paste, "ACTIVE", "YES");

  if (!IupGetAttribute(multitext, "SELECTEDTEXT")) 
  {
    IupSetAttribute(item_cut, "ACTIVE", "NO");
    IupSetAttribute(item_delete, "ACTIVE", "NO");
    IupSetAttribute(item_copy, "ACTIVE", "NO");
  }
  else 
  {
    IupSetAttribute(item_cut, "ACTIVE", "YES");
    IupSetAttribute(item_delete, "ACTIVE", "YES");
    IupSetAttribute(item_copy, "ACTIVE", "YES");
  }

  IupDestroy(clipboard);
  return IUP_DEFAULT;
}
void iupShowError(Ihandle* parent, const char* message)
{
  Ihandle* dlg = IupMessageDlg();
  char* title = NULL, *str_message;

  if (parent)
  {
    IupSetAttributeHandle(dlg, "PARENTDIALOG", parent);
    title = IupGetAttribute(parent, "TITLE");
  }

  if (!title)
    title = "_@IUP_ERROR";

  IupSetStrAttribute(dlg, "TITLE", title);
  IupSetAttribute(dlg, "DIALOGTYPE", "ERROR");
  IupSetAttribute(dlg, "BUTTONS", "OK");

  str_message = IupGetLanguageString(message);
  if (!str_message)
    str_message = (char*)message;
  IupStoreAttribute(dlg, "VALUE", str_message);

  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);

  IupDestroy(dlg);
}
Beispiel #25
0
static void new_color(void)
{
  Ihandle* dlg = IupColorDlg();

  IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_");
  IupSetAttribute(dlg, "VALUE", "128 0 255");
  IupSetAttribute(dlg, "ALPHA", "142");
  //IupSetAttribute(dlg, "COLORTABLE", ";;177 29 234;;;0 0 23;253 20 119");
  IupSetAttribute(dlg, "SHOWHEX", "YES");
  IupSetAttribute(dlg, "SHOWCOLORTABLE", "YES");
  //IupSetAttribute(dlg, "SHOWALPHA", "YES");
  IupSetAttribute(dlg, "TITLE", "IupColorDlg Test");
  IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb);

  IupPopup(dlg, IUP_CURRENT, IUP_CURRENT);

  if (IupGetInt(dlg, "STATUS"))
  {
    printf("OK\n");
    printf("  VALUE(%s)\n", IupGetAttribute(dlg, "VALUE"));
    printf("  COLORTABLE(%s)\n", IupGetAttribute(dlg, "COLORTABLE"));
  }
  else
    printf("CANCEL\n");

  IupDestroy(dlg);
}
Beispiel #26
0
static int iDetachBoxSetRestoreAttrib(Ihandle* ih, const char* value)
{
  Ihandle *dlg = IupGetDialog(ih);
  Ihandle* new_parent = IupGetHandle(value);
  Ihandle* new_brother = NULL;

  if (!new_parent)
  {
    new_parent = ih->data->old_parent;
    new_brother = ih->data->old_brother;

    if (IupGetChildPos(new_parent, new_brother) == -1)  /* not a child of new_parent */
      new_brother = NULL;
  }

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

  /* Show handler */
  if (ih->data->barsize)
    IupSetAttribute(ih->firstchild, "VISIBLE", "Yes");

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

  /* Reset previous parent and brother */
  ih->data->old_parent = NULL;
  ih->data->old_brother = NULL;

  IupDestroy(dlg);
  return 0;
}
Beispiel #27
0
static int winDialogMDICloseChildren(Ihandle* ih)
{
    Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
    if (iupObjectCheck(client))
    {
        HWND hWndChild = (HWND)SendMessage(client->handle, WM_MDIGETACTIVE, 0, 0);

        /* As long as the MDI client has a child, close it */
        while (hWndChild)
        {
            Ihandle* child = iupwinHandleGet(hWndChild);
            if (iupObjectCheck(child) && iupAttribGetBoolean(child, "MDICHILD"))
            {
                Icallback cb = IupGetCallback(child, "CLOSE_CB");
                if (cb)
                {
                    int ret = cb(child);
                    if (ret == IUP_IGNORE)
                        return 0;
                    if (ret == IUP_CLOSE)
                        IupExitLoop();
                }

                IupDestroy(child);
            }

            hWndChild = (HWND)SendMessage(client->handle, WM_MDIGETACTIVE, 0, 0);
        }
    }
    return 1;
}
Beispiel #28
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 #29
0
static void gtkDialogUnMapMethod(Ihandle* ih)
{
  GtkWidget* fixed;
#if GTK_CHECK_VERSION(2, 10, 0)
  GtkStatusIcon* status_icon;
#endif

  if (ih->data->menu) 
  {
    ih->data->menu->handle = NULL; /* the dialog will destroy the native menu */
    IupDestroy(ih->data->menu);  
  }

#if GTK_CHECK_VERSION(2, 10, 0)
  status_icon = (GtkStatusIcon*)iupAttribGet(ih, "_IUPDLG_STATUSICON");
  if (status_icon)
    g_object_unref(status_icon);
#endif

  fixed = gtk_bin_get_child((GtkBin*)ih->handle);
  gtk_widget_unrealize(fixed);
  gtk_widget_destroy(fixed);  

  gtk_widget_unrealize(ih->handle); /* To match the call to gtk_widget_realize */
  gtk_widget_destroy(ih->handle);   /* To match the call to gtk_window_new     */
}
Beispiel #30
0
int main(int argc, char **argv)
{
  IupOpen(&argc, &argv);
  IupControlsOpen();

  bt = IupButton("Test", "");
  IupSetAttribute(bt, "EXPAND", "YES");

  box = IupSbox(bt);
  IupSetAttribute(box, "DIRECTION", "SOUTH");

  ml = IupMultiLine(NULL);
  IupSetAttribute(ml, IUP_EXPAND, "YES");
  vbox = IupVbox(box, ml, NULL);

  lb = IupLabel("Label");
  IupSetAttribute(lb, IUP_EXPAND, "YES");

  dg = IupDialog(IupHbox(vbox, IupFrame(lb), NULL));
  IupSetAttribute(dg, IUP_MARGIN, "10x20");

  //IupSetAttribute(dg,"COMPOSITED", "YES");
  //IupSetAttribute(dg,"LAYERED", "YES");
  //IupSetAttribute(dg,"LAYERALPHA", "192");

  IupShow(dg);

  IupMainLoop();
  IupDestroy(dg);
  IupControlsClose();
  IupClose();
  return 1;
}