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); }
int IupGetColor(int x, int y, unsigned char *r, unsigned char *g, unsigned char *b) { int ret; Ihandle* dlg = IupColorDlg(); IupSetAttribute(dlg, "TITLE", iupStrMessageGet("IUP_GETCOLOR")); IupSetfAttribute(dlg, "VALUE", "%d %d %d", *r, *g, *b); IupSetAttribute(dlg, "PARENTDIALOG", IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg, "ICON", IupGetGlobal("ICON")); IupPopup(dlg, x, y); ret = IupGetInt(dlg, "STATUS"); if (ret) iupStrToRGB(IupGetAttribute(dlg, "VALUE"), r, g, b); IupDestroy(dlg); return ret; }
int item_saveas_action_cb(Ihandle* item_saveas) { Ihandle* multitext = IupGetDialogChild(item_saveas, "MULTITEXT"); Ihandle *filedlg = IupFileDlg(); IupSetAttribute(filedlg, "DIALOGTYPE", "SAVE"); IupSetAttribute(filedlg, "EXTFILTER", "Text Files|*.txt|All Files|*.*|"); IupSetAttributeHandle(filedlg, "PARENTDIALOG", IupGetDialog(item_saveas)); IupSetStrAttribute(filedlg, "FILE", IupGetAttribute(multitext, "FILENAME")); IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(filedlg, "STATUS") != -1) { char* filename = IupGetAttribute(filedlg, "VALUE"); saveas_file(multitext, filename); } IupDestroy(filedlg); return IUP_DEFAULT; }
static void new_message(char* type, char* buttons) { Ihandle* dlg = IupMessageDlg(); if (strcmp(type, "ERROR")!=0) IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); IupSetAttribute(dlg, "DIALOGTYPE", type); IupSetAttribute(dlg, "TITLE", "IupMessageDlg Test"); IupSetAttribute(dlg, "BUTTONS", buttons); IupSetAttribute(dlg, "VALUE", "Message Text\nSecond Line"); if (strcmp(type, "WARNING")==0) IupSetAttribute(dlg, "BUTTONDEFAULT", "2"); if (strcmp(type, "INFORMATION")!=0) IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); IupPopup(dlg, IUP_CURRENT, IUP_CURRENT); printf("BUTTONRESPONSE(%s)\n", IupGetAttribute(dlg, "BUTTONRESPONSE")); IupDestroy(dlg); }
void iupVersionDlg(void) { Ihandle* dlg; dlg = IupDialog(IupVbox(IupFrame(IupVbox( IupLabel(IupVersion()), IupLabel(IUP_VERSION_DATE), IupLabel(IUP_COPYRIGHT), NULL)), IupButton("OK", NULL), NULL)); IupSetAttribute(dlg,"TITLE","IUP Version"); IupSetAttribute(dlg,"DIALOGFRAME","YES"); IupSetAttribute(dlg,"DIALOGHINT","YES"); IupSetAttribute(dlg,"GAP","10"); IupSetAttribute(dlg,"MARGIN","10x10"); IupPopup(dlg, IUP_CENTER, IUP_CENTER); IupDestroy(dlg); }
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); }
int main(int argc, char **argv) { Ihandle *dg, *A, *B; IupOpen(&argc, &argv); IupControlsOpen(); IupSetFunction("showcb", (Icallback) show_cb); IupSetFunction("buttoncb", (Icallback) button_cb); IupSetFunction("getfocus_cb", (Icallback) getfocus_cb); IupSetFunction("mm", (Icallback) mm); A = IupButton("Open Popup", "buttoncb"); B = IupButton("Dummy", ""); IupSetAttribute(A, IUP_TIP, "TIP DO PRIMEIRO ELEMENTO"); dg = IupDialog(IupVbox(A, B, NULL)); IupPopup(dg, IUP_CENTER, IUP_CENTER); IupMainLoop(); IupClose(); return 1; }
int item_background_action_cb(Ihandle* item_background) { Ihandle* canvas = IupGetDialogChild(item_background, "CANVAS"); Ihandle* config = (Ihandle*)IupGetAttribute(canvas, "CONFIG"); Ihandle* colordlg = IupColorDlg(); const char* background = IupConfigGetVariableStrDef(config, "MainWindow", "Background", "255 255 255"); IupSetStrAttribute(colordlg, "VALUE", background); IupSetAttributeHandle(colordlg, "PARENTDIALOG", IupGetDialog(item_background)); IupPopup(colordlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(colordlg, "STATUS") == 1) { background = IupGetAttribute(colordlg, "VALUE"); IupConfigSetVariableStr(config, "MainWindow", "Background", background); IupUpdate(canvas); } IupDestroy(colordlg); return IUP_DEFAULT; }
int item_font_action_cb(Ihandle* item_font) { Ihandle* multitext = IupGetDialogChild(item_font, "MULTITEXT"); Ihandle* fontdlg = IupFontDlg(); char* font = IupGetAttribute(multitext, "FONT"); IupSetStrAttribute(fontdlg, "VALUE", font); IupSetAttributeHandle(fontdlg, "PARENTDIALOG", IupGetDialog(item_font)); IupPopup(fontdlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(fontdlg, "STATUS") == 1) { Ihandle* config = (Ihandle*)IupGetAttribute(multitext, "CONFIG"); char* font = IupGetAttribute(fontdlg, "VALUE"); IupSetStrAttribute(multitext, "FONT", font); IupConfigSetVariableStr(config, "MainWindow", "Font", font); } IupDestroy(fontdlg); return IUP_DEFAULT; }
int item_open_action_cb(Ihandle* item_open) { Ihandle *filedlg; if (!save_check(item_open)) return IUP_DEFAULT; filedlg = IupFileDlg(); IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN"); IupSetAttribute(filedlg, "EXTFILTER", "Text Files|*.txt|All Files|*.*|"); IupSetAttributeHandle(filedlg, "PARENTDIALOG", IupGetDialog(item_open)); IupPopup(filedlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(filedlg, "STATUS") != -1) { char* filename = IupGetAttribute(filedlg, "VALUE"); open_file(item_open, filename); } IupDestroy(filedlg); return IUP_DEFAULT; }
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) { char* filename = IupGetAttribute(filedlg, "VALUE"); char* str = IupGetAttribute(multitext, "VALUE"); int count = IupGetInt(multitext, "COUNT"); write_file(filename, str, count); } IupDestroy(filedlg); return IUP_DEFAULT; }
static void new_font(void) { Ihandle* dlg = IupFontDlg(); IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); IupSetAttribute(dlg, "COLOR", "128 0 255"); IupSetAttribute(dlg, "VALUE", "Times New Roman, Bold 20"); IupSetAttribute(dlg, "TITLE", "IupFontDlg 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(" COLOR(%s)\n", IupGetAttribute(dlg, "COLOR")); } else printf("CANCEL\n"); IupDestroy(dlg); }
int IupGetFile(char* filename) { Ihandle *dlg = 0; int ret; char filter[4096] = "*.*"; static char dir[4096] = ""; /* static will make the dir persist from one call to another if not defined */ if (!filename) return -1; dlg = IupFileDlg(); iupStrSplitFileName(filename, dir, filter); IupSetAttribute(dlg, "FILTER", filter); IupSetAttribute(dlg, "DIRECTORY", dir); IupSetAttribute(dlg, "ALLOWNEW", "YES"); IupSetAttribute(dlg, "NOCHANGEDIR", "YES"); IupSetAttribute(dlg, "PARENTDIALOG", IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg, "ICON", IupGetGlobal("ICON")); IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); ret = IupGetInt(dlg, "STATUS"); if (ret != -1) { char* value = IupGetAttribute(dlg, "VALUE"); if (value) { strcpy(filename, value); iupStrSplitFileName(filename, dir, NULL); } } IupDestroy(dlg); return ret; }
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") + IupGetInt2(ih, "RASTERSIZE"); IupPopup(menu, x, y); IupDestroy(menu); }
int item_open_action_cb(Ihandle* item_open) { Ihandle* multitext = IupGetDialogChild(item_open, "MULTITEXT"); Ihandle *filedlg = IupFileDlg(); IupSetAttribute(filedlg, "DIALOGTYPE", "OPEN"); IupSetAttribute(filedlg, "EXTFILTER", "Text Files|*.txt|All 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; }
int iupDataEntry ( int maxlin, int maxcol[], int maxscr[], const char *title, const char **text, char *data[] ) { int i, bt; Ihandle *ok, *cancel, *dialog, *vb, *hb, **txt, *button_box, *dlg_box; char scroll[20]; char sizecol[20]; txt = (Ihandle **) calloc(maxlin, sizeof(Ihandle*)); if (txt == NULL) return -2; vb = IupVbox(NULL); for (i=0; i<maxlin; i++) { sprintf(scroll, "%d", 4*maxscr[i]+4); sprintf(sizecol, "%d", maxcol[i]); txt[i] = IupText("do_nothing"); IupSetAttribute(txt[i],IUP_VALUE,data[i]); IupStoreAttribute(txt[i],IUP_SIZE,scroll); IupStoreAttribute(txt[i],IUP_NC,sizecol); hb = IupHbox(IupLabel(text[i]), IupFill(), txt[i],NULL); IupSetAttribute(hb,IUP_MARGIN,"0x0"); IupSetAttribute(hb,IUP_ALIGNMENT,IUP_ACENTER); IupAppend(vb, hb); } ok = IupButton(strok, NULL); IupSetAttribute(ok, IUP_SIZE, "50x"); IupSetCallback(ok, "ACTION", (Icallback)CB_button_OK); IupSetHandle("iupDataEntryOkButton", ok); cancel = IupButton(strcancel, NULL); IupSetAttribute(cancel, IUP_SIZE, "50x"); IupSetCallback(cancel, "ACTION", (Icallback)CB_button_CANCEL); IupSetHandle("iupDataEntryCancelButton", cancel ); button_box = IupHbox( IupSetAttributes(IupFill(), "EXPAND=HORIZONTAL"), ok, IupSetAttributes(IupFill(), "SIZE=1x"), cancel, NULL); IupSetAttribute(button_box,IUP_MARGIN,"0x0"); dlg_box = IupVbox( IupFrame(vb), 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_RESIZE,IUP_NO); IupSetAttribute(dialog,IUP_DEFAULTENTER,"iupDataEntryOkButton"); IupSetAttribute(dialog,IUP_DEFAULTESC,"iupDataEntryCancelButton"); IupSetAttribute(dialog,IUP_PARENTDIALOG,IupGetGlobal(IUP_PARENTDIALOG)); IupSetAttribute(dialog,IUP_ICON, IupGetGlobal(IUP_ICON)); IupPopup(dialog,IUP_CENTER,IUP_CENTER); for (i=0; i<maxlin; i++) { data[i] = (char *)iupStrDup(IupGetAttribute(txt[i], IUP_VALUE)); } free(txt); bt = IupGetInt(dialog, IUP_STATUS); IupDestroy(dialog); return bt; }
void main_about(){ //Callback for the about button of the main dialog IupPopup(aboutDlg, IUP_CENTERPARENT, IUP_CENTERPARENT); //Shows the "about" window }
void new_dialog(int test, char* tip) { Ihandle *dlg = IupDialog(NULL); IupSetAttribute(dlg, "TIP", tip); IupSetfAttribute(dlg, "_TEST_", "%d", test); if (test == 0) IupSetHandle("_MAIN_DIALOG_TEST_", dlg); else { IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); IupSetAttribute(dlg, "CURSOR", "CROSS"); } if (test != 3) IupSetfAttribute(dlg, "TITLE", "dlg%d", test); IupSetfAttribute(dlg, "TESTTITLE", "dlg%d", test); if (test == 1) IupSetAttribute(dlg, "SIZE", "FULLxFULL"); else if (test != 6) IupSetAttribute(dlg, "RASTERSIZE", "500x500"); if (test == 2) { IupSetAttribute(dlg, "CURSOR", "DLG_CURSOR"); IupSetAttribute(dlg, "ICON", "DLG_ICON"); IupSetAttribute(dlg, "MINSIZE", "300x300"); IupSetAttribute(dlg, "MAXSIZE", "600x600"); // IupSetAttribute(dlg, "FONTSIZE", "20"); { static int count = 0; if (count == 1) { // IupSetAttribute(dlg, "FONT", "TIMES_ITALIC_14"); IupSetAttribute(dlg, "FONT", "Times, Italic 14"); // IupSetAttribute(dlg, "FONT", "Times, Underline Italic Strikeout -14"); IupSetAttribute(dlg, "TIPBGCOLOR", "255 128 128"); IupSetAttribute(dlg, "TIPFGCOLOR", "0 92 255"); // Windows Only IupSetAttribute(dlg, "TIPBALLON", "YES"); IupSetAttribute(dlg, "TIPBALLONTITLE", "Tip Title Test"); IupSetAttribute(dlg, "TIPBALLONTITLEICON", "2"); //IupSetAttribute(dlg, "TIPDELAY", "5000"); } if (count == 2) { // Windows Only IupSetAttribute(dlg, "TOPMOST", "YES"); IupSetAttribute(dlg, "LAYERED", "YES"); IupSetAttribute(dlg, "LAYERALPHA", "128"); IupSetAttribute(dlg, "TOOLBOX", "YES"); } count++; } } if (test == 3) { IupSetAttribute(dlg, "BGCOLOR", "255 0 255"); IupSetAttribute(dlg, "RESIZE", "NO"); IupSetAttribute(dlg, "MENUBOX", "NO"); IupSetAttribute(dlg, "MAXBOX", "NO"); IupSetAttribute(dlg, "MINBOX", "NO"); IupSetAttribute(dlg, "BORDER", "NO"); IupSetAttribute(dlg, "RASTERSIZE", "500x500"); } if (test == 5) { IupSetAttribute(dlg, "DIALOGFRAME", "YES"); // Windows Only IupSetAttribute(dlg, "HELPBUTTON", "YES"); } if (test == 1) IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb2); else IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb); IupSetCallback(dlg, "SHOW_CB", (Icallback)show_cb); IupSetCallback(dlg, "MAP_CB", (Icallback)map_cb); IupSetCallback(dlg, "K_ANY", (Icallback)k_any); IupSetCallback(dlg, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(dlg, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); IupSetCallback(dlg, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); IupSetCallback(dlg, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); IupSetCallback(dlg, "RESIZE_CB", (Icallback)resize_cb); // Windows and GTK Only IupSetCallback(dlg, "DROPFILES_CB", (Icallback)dropfiles_cb); if (test == 0 || test == 1) IupShow(dlg); else if (test == 3) IupShowXY(dlg, IUP_RIGHT, IUP_CENTER); else if (test == 2) IupShowXY(dlg, 100, 100); else if (test == 4) { static int count = 0; if (count == 0) { IupSetAttribute(dlg, "PLACEMENT", "MINIMIZED"); IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=MINIMIZED."); } else if (count == 1) { IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED"); IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=MAXIMIZED."); } else { IupSetAttribute(dlg, "PLACEMENT", "FULL"); IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=FULL."); } count++; if (count == 3) // cicle from 0 to 2 count = 0; IupShow(dlg); } else if (test == 5) { IupPopup(dlg, IUP_CURRENT, IUP_CURRENT); } else if (test == 6) { IupSetAttribute(dlg, "FULLSCREEN", "YES"); IupShow(dlg); } }
int IupAlarm (const char *title, const char *m, const char *b1, const char *b2, const char *b3) { Ihandle *dialog, *dlg_box, *lbl_box, *botoes, *button; char *aux, *linha, *default_esc; int i, bt, wb; char button_size[10]; m = m ? m : ""; if (b1 == NULL) return 0; aux=(char *)iupStrDup(m); if (aux == NULL) return 0; lbl_box = IupVbox(NULL); IupSetAttribute(lbl_box,IUP_MARGIN,"0x0"); IupSetAttribute(lbl_box,IUP_GAP,"0"); IupSetAttribute(lbl_box,IUP_ALIGNMENT, IUP_ACENTER); for (i=0,linha=aux; linha[i]; ++i) { if (linha[i] == '\n') { linha[i] = '\0'; IupAppend(lbl_box,IupHbox(IupFill(),IupLabel(linha),IupFill(),NULL)); linha=&linha[i+1]; i=-1; } } if (*linha) IupAppend(lbl_box,IupHbox(IupFill(),IupLabel(linha),IupFill(),NULL)); botoes = IupHbox(NULL); button = IupButton(b1, NULL); IupSetHandle("IupAlarmButton1", button ); IupSetAttribute(button, "_BUTTON_NUMBER", "1"); IupAppend(botoes, IupFill()); IupAppend(botoes, button); IupSetCallback (button, "ACTION", (Icallback)CB_button); default_esc = "IupAlarmButton1"; if (b2 != NULL) { button = IupButton(b2, NULL); IupSetHandle( "IupAlarmButton2", button ); IupSetAttribute(button, "_BUTTON_NUMBER", "2"); IupAppend(botoes, IupFill()); IupAppend(botoes, button); IupSetCallback (button, "ACTION", (Icallback)CB_button); default_esc = "IupAlarmButton2"; } if (b3 != NULL) { button = IupButton(b3, NULL); IupSetHandle( "IupAlarmButton3", button ); IupSetAttribute(button, "_BUTTON_NUMBER", "3"); IupAppend(botoes, IupFill()); IupAppend(botoes, button); IupSetCallback (button, "ACTION", (Icallback)CB_button); default_esc = "IupAlarmButton3"; } IupAppend(botoes, IupFill()); dlg_box = IupVbox ( IupSetAttributes(IupFill(), "SIZE=1x"), lbl_box, IupSetAttributes(IupFill(), "SIZE=1x"), botoes, NULL); IupSetAttribute(dlg_box,IUP_MARGIN,"10x10"); IupSetAttribute(dlg_box,IUP_GAP,"5"); dialog = IupDialog(dlg_box); IupSetAttribute(dialog,IUP_TITLE,title ? title : ""); IupSetAttribute(dialog,IUP_MINBOX ,IUP_NO); IupSetAttribute(dialog,IUP_MAXBOX ,IUP_NO); IupSetAttribute(dialog,IUP_RESIZE ,IUP_NO); IupSetAttribute(dialog,IUP_DEFAULTENTER,"IupAlarmButton1"); IupSetAttribute(dialog,IUP_DEFAULTESC,default_esc); IupSetAttribute(dialog, IUP_PARENTDIALOG, IupGetGlobal(IUP_PARENTDIALOG)); IupSetAttribute(dialog, IUP_ICON, IupGetGlobal(IUP_ICON)); IupMap(dialog); wb = IupGetInt(IupGetHandle("IupAlarmButton1"), IUP_SIZE); if (b2 != NULL) { int wb2 = IupGetInt(IupGetHandle("IupAlarmButton2"), IUP_SIZE); if(wb2 > wb) wb = wb2; } if (b3 != NULL) { int wb3 = IupGetInt(IupGetHandle("IupAlarmButton3"), IUP_SIZE); if(wb3 > wb) wb = wb3; } sprintf(button_size, "%dx", wb); IupSetAttribute(IupGetHandle("IupAlarmButton1"), IUP_SIZE, button_size); IupSetAttribute(IupGetHandle("IupAlarmButton2"), IUP_SIZE, button_size); IupSetAttribute(IupGetHandle("IupAlarmButton3"), IUP_SIZE, button_size); /* Force to calculate dialog's size again. */ IupSetAttribute(dialog, IUP_RASTERSIZE, 0); IupPopup(dialog,IUP_CENTER,IUP_CENTER); bt = IupGetInt(dialog, "_BUTTON_NUMBER"); IupDestroy(dialog); free(aux); return bt; }
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; }
int IupListDialog (int tipo, const char *titulo, int tam, const char *lista[], int opcao, int max_col, int max_lin, int marcas[]) { Ihandle *listaiup, *ok, *dialog, *cancel, *dlg_box, *button_box; int i, bt; char op[5]; char lastop[5]; char maxsize[20]; char opcaoini[20]; char *m=NULL; if (tam > 999) tam = 999; listaiup = IupList(NULL); for (i=0;i<tam;i++) { sprintf(op,"%d",i+1); IupSetAttribute(listaiup,op,lista[i]); } sprintf(lastop,"%d",tam+1); IupSetAttribute(listaiup,lastop,NULL); ok = IupButton(strok, NULL); IupSetAttribute (ok ,IUP_SIZE ,"50x"); IupSetCallback (ok, "ACTION", (Icallback)CB_button_OK); IupSetHandle( "IupListOkButton", ok ); cancel = IupButton(strcancel, NULL); IupSetAttribute (cancel,IUP_SIZE ,"50x"); IupSetCallback (cancel, "ACTION", (Icallback)CB_button_CANCEL); IupSetHandle( "IupListCancelButton", cancel ); button_box = IupHbox( IupSetAttributes(IupFill(), "EXPAND=HORIZONTAL"), ok, IupSetAttributes(IupFill(), "SIZE=1x"), cancel, NULL); IupSetAttribute(button_box,IUP_MARGIN,"0x0"); dlg_box = IupVbox( listaiup, IupSetAttributes(IupFill(), "SIZE=1x"), button_box, NULL); IupSetAttribute(dlg_box,IUP_MARGIN,"10x10"); IupSetAttribute(dlg_box,IUP_GAP,"5"); dialog = IupDialog (dlg_box); if (tipo == 1) { if (opcao<1 || opcao>tam) opcao=1; IupSetfAttribute(dialog, "_LIST_NUMBER", "%d", opcao-1); sprintf(opcaoini,"%d",opcao); IupSetAttribute(listaiup,IUP_VALUE,opcaoini); IupSetCallback (listaiup, "ACTION", (Icallback)CB_lista); } else if ((tipo == 2) && (marcas != NULL)) { m=(char *)marcas; for (i=0;i<tam;i++) m[i] = marcas[i] ? '+' : '-'; m[i]='\0'; IupSetAttribute(listaiup,IUP_MULTIPLE,IUP_YES); IupSetAttribute(listaiup,IUP_VALUE,m); } sprintf (maxsize,"%dx%d",max_col*5,max_lin==1?16:max_lin*9+4); IupSetAttribute (listaiup,IUP_SIZE , maxsize); IupSetAttribute (dialog,IUP_TITLE,titulo); IupSetAttribute (dialog,IUP_MINBOX,IUP_NO); IupSetAttribute (dialog,IUP_MAXBOX,IUP_NO); IupSetAttribute (dialog,IUP_RESIZE,IUP_NO); IupSetAttribute (dialog,IUP_DEFAULTENTER,"IupListOkButton"); IupSetAttribute (dialog,IUP_DEFAULTESC,"IupListCancelButton"); IupSetAttribute (dialog, IUP_PARENTDIALOG, IupGetGlobal(IUP_PARENTDIALOG)); IupSetAttribute (dialog, IUP_ICON, IupGetGlobal(IUP_ICON)); IupPopup(dialog,IUP_CENTER,IUP_CENTER); if ((tipo == 2) && (marcas != NULL)) { m=IupGetAttribute(listaiup,IUP_VALUE); for (i=0;i<tam;i++) marcas[i] = (m[i] == '+'); } bt = IupGetInt(dialog, IUP_STATUS); if (bt != -1 && tipo == 1) bt = IupGetInt(dialog, "_LIST_NUMBER"); IupDestroy(dialog); return bt; }
static void Popup(void) { lua_pushnumber(IupPopup(iuplua_checkihandle(1), luaL_opt_int(2, IUP_CURRENT), luaL_opt_int(3, IUP_CURRENT))); }
static void new_dialog(int test, char* tip) { Ihandle *dlg = IupDialog(NULL); IupSetAttribute(dlg, "TIP", tip); IupSetfAttribute(dlg, "_TEST_", "%d", test); if (test == 0) { char* msg = "Press a key for a dialog test:\n" "1 = new with SIZE=FULLxFULL\n" "2 = new with dialog decorations\n" "3 = new with NO decorations\n" "4 = new changing PLACEMENT\n" "5 = new using IupPopup\n" "6 = new with FULLSCREEN=YES\n" "p = PLACEMENT=MAXIMIZED\n" "pp = PLACEMENT=MINIMIZED\n" "ppp = PLACEMENT=NORMAL\n" "pppp = PLACEMENT=FULL\n" "s = IupShow(main)\n" "f = toggle FULLSCREEN state\n" "c = return IUP_CLOSE;\n" "h = IupHide\n" "r = RASTERSIZE+IupRefresh\n" "Esc = quit"; IupAppend(dlg, IupVbox(IupLabel(msg), NULL)); IupSetHandle("_MAIN_DIALOG_TEST_", dlg); } else { IupSetAttribute(dlg, "PARENTDIALOG", "_MAIN_DIALOG_TEST_"); IupSetAttribute(dlg, "CURSOR", "CROSS"); } if (test != 3) IupSetfAttribute(dlg, "TITLE", "dlg%d", test); IupSetfAttribute(dlg, "TESTTITLE", "dlg%d", test); if (test == 1) IupSetAttribute(dlg, "SIZE", "FULLxFULL"); else if (test != 6) IupSetAttribute(dlg, "RASTERSIZE", "500x500"); if (test == 2) { IupSetAttribute(dlg, "CURSOR", "DLG_CURSOR"); IupSetAttribute(dlg, "ICON", "DLG_ICON"); IupSetAttribute(dlg, "MINSIZE", "300x300"); IupSetAttribute(dlg, "MAXSIZE", "600x600"); // IupSetAttribute(dlg, "FONTSIZE", "20"); { static int count = 0; if (count == 1) { // IupSetAttribute(dlg, "FONT", "TIMES_ITALIC_14"); IupSetAttribute(dlg, "FONT", "Times, Italic 14"); // IupSetAttribute(dlg, "FONT", "Times, Underline Italic Strikeout -14"); IupSetAttribute(dlg, "TIPBGCOLOR", "255 128 128"); IupSetAttribute(dlg, "TIPFGCOLOR", "0 92 255"); // Windows Only IupSetAttribute(dlg, "TIPBALLON", "YES"); IupSetAttribute(dlg, "TIPBALLONTITLE", "Tip Title Test"); IupSetAttribute(dlg, "TIPBALLONTITLEICON", "2"); //IupSetAttribute(dlg, "TIPDELAY", "5000"); } if (count == 2) { // Windows Only IupSetAttribute(dlg, "TOPMOST", "YES"); IupSetAttribute(dlg, "OPACITY", "128"); IupSetAttribute(dlg, "TOOLBOX", "YES"); } count++; } } if (test == 3) { IupSetAttribute(dlg, "BGCOLOR", "255 0 255"); IupSetAttribute(dlg, "RESIZE", "NO"); IupSetAttribute(dlg, "MENUBOX", "NO"); IupSetAttribute(dlg, "MAXBOX", "NO"); IupSetAttribute(dlg, "MINBOX", "NO"); IupSetAttribute(dlg, "BORDER", "NO"); IupSetAttribute(dlg, "RASTERSIZE", "500x500"); } if (test == 5) { IupSetAttribute(dlg, "DIALOGFRAME", "YES"); // Windows Only IupSetAttribute(dlg, "HELPBUTTON", "YES"); } if (test == 1) IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb2); else IupSetCallback(dlg, "CLOSE_CB", (Icallback)close_cb); IupSetCallback(dlg, "SHOW_CB", (Icallback)show_cb); IupSetCallback(dlg, "MAP_CB", (Icallback)map_cb); IupSetCallback(dlg, "K_ANY", (Icallback)k_any); IupSetCallback(dlg, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(dlg, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); IupSetCallback(dlg, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); IupSetCallback(dlg, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); IupSetCallback(dlg, "RESIZE_CB", (Icallback)resize_cb); IupSetCallback(dlg, "MOVE_CB", (Icallback)move_cb); // Windows and GTK Only IupSetCallback(dlg, "DROPFILES_CB", (Icallback)dropfiles_cb); if (test == 0 || test == 1) IupShow(dlg); else if (test == 3) IupShowXY(dlg, IUP_RIGHT, IUP_CENTER); else if (test == 2) IupShowXY(dlg, 100, 100); else if (test == 4) { static int count = 0; if (count == 0) { IupSetAttribute(dlg, "PLACEMENT", "MINIMIZED"); IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=MINIMIZED."); } else if (count == 1) { IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED"); IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=MAXIMIZED."); } else { IupSetAttribute(dlg, "PLACEMENT", "FULL"); IupSetfAttribute(dlg, "TIP", "%s%s", IupGetAttribute(dlg, "TIP"), "\n.PLACEMENT=FULL."); } count++; if (count == 3) // cicle from 0 to 2 count = 0; IupShow(dlg); } else if (test == 5) { IupPopup(dlg, IUP_CURRENT, IUP_CURRENT); } else if (test == 6) { IupSetAttribute(dlg, "FULLSCREEN", "YES"); IupShow(dlg); } }
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; }
void GaugeTest(void) { Ihandle *dlg, *vbox, *hbox; Ihandle *btn_restart, *btn_accelerate, *btn_decelerate, *btn_show1, *btn_show2; timer = IupTimer(); IupSetCallback(timer, "ACTION_CB", (Icallback)time_cb); IupSetAttribute(timer, "TIME", "100"); gauge = IupGauge(); IupSetAttribute(gauge, "EXPAND", "YES"); // IupSetAttribute(gauge, "BGCOLOR", "255 0 128"); // IupSetAttribute(gauge, "FGCOLOR", "0 128 0"); btn_restart = IupButton(NULL, NULL); btn_pause = IupButton(NULL, NULL); btn_accelerate = IupButton(NULL, NULL); btn_decelerate = IupButton(NULL, NULL); btn_show1 = IupButton("Dashed", NULL); btn_show2 = IupButton("Text", NULL); createimg_s(); IupSetAttribute(btn_restart, "IMAGE", "img_restart"); IupSetAttribute(btn_restart, "TIP", "Restart" ); IupSetAttribute(btn_pause, "IMAGE", "img_pause"); IupSetAttribute(btn_pause, "TIP", "Play/Pause"); IupSetAttribute(btn_accelerate, "IMAGE", "img_forward"); IupSetAttribute(btn_accelerate, "TIP", "Accelerate"); IupSetAttribute(btn_decelerate, "IMAGE", "img_rewind"); IupSetAttribute(btn_decelerate, "TIP", "Decelerate"); IupSetAttribute(btn_show1, "TIP", "Dashed or Continuous"); IupSetAttribute(btn_show2, "TIP", "Text or None"); hbox = IupHbox ( IupFill(), btn_pause, btn_restart, btn_decelerate, btn_accelerate, btn_show1, btn_show2, IupFill(), NULL ); vbox = IupVbox(gauge, hbox, NULL); IupSetAttribute(vbox, "MARGIN", "10x10"); IupSetAttribute(vbox, "GAP", "5"); dlg = IupDialog(vbox); IupSetAttribute(dlg, "TITLE", "IupGauge Test"); IupSetCallback(btn_pause, "ACTION", (Icallback) btn_pause_cb); IupSetCallback(btn_restart, "ACTION", (Icallback) btn_restart_cb); IupSetCallback(btn_accelerate, "ACTION", (Icallback) btn_accelerate_cb); IupSetCallback(btn_decelerate, "ACTION", (Icallback) btn_decelerate_cb); IupSetCallback(btn_show1, "ACTION", (Icallback) btn_show1_cb); IupSetCallback(btn_show2, "ACTION", (Icallback) btn_show2_cb); IupSetAttribute(timer, "RUN", "YES"); IupPopup(dlg, IUP_CENTER, IUP_CENTER); IupDestroy(timer); }
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; }
static int cb_btnDecodeToMorse(Ihandle *btn) { Ihandle *txtMorse, *txtAscii, *msgDialog; char *morseText, *asciiText; int morseLen, asciiLen; Ihandle *errorDialog; char *errorText; int opReturnCode; extern char *error_decode; extern BisTree textToMorse; /* Might be declared in the driver file */ txtMorse = IupGetHandle(TXTMORSE_4); txtAscii = IupGetHandle(TXTASCII_2); asciiText = IupGetAttribute(txtAscii, "VALUE"); asciiLen = strlen(asciiText); morseText = (char *) malloc(8 * asciiLen * sizeof(char)); if (asciiLen == 0) { msgDialog = IupMessageDlg(); IupSetAttribute(msgDialog, "DIALOGTYPE", "INFORMATION"); IupSetAttribute(msgDialog, "TITLE", "Decoding Procedure"); IupSetAttribute(msgDialog, "VALUE", generalInfo); IupSetAttribute(msgDialog, "BOTTONS", "OK"); IupSetAttribute(msgDialog, "PARENTDIALOG", MAINDIALOG); IupPopup(msgDialog, IUP_CENTER, IUP_CENTER); IupDestroy(msgDialog); // IupSetAttribute(txtMorse, "VALUE", 0); goto END; } opReturnCode = morse_convAsciiToMorse( &textToMorse, asciiText, asciiLen, morseText, &morseLen); /* Check to see if decoding operation is successful or not */ if (opReturnCode != 0) { errorText = (char *) malloc(strlen(error_decode) + 10); sprintf(errorText, error_decode, opReturnCode); errorDialog = IupMessageDlg(); IupSetAttribute(errorDialog, "DIALOGTYPE", "ERROR"); IupSetAttribute(errorDialog, "BUTTONS", "OK"); IupSetAttribute(errorDialog, "TITLE", "Error"); IupSetAttribute(errorDialog, "PARENTDIALOG", MAINDIALOG); IupSetAttribute(errorDialog, "VALUE", errorText); IupPopup(errorDialog, IUP_CENTER, IUP_CENTER); IupDestroy(errorDialog); free((void *) errorText); goto END; } /* Add a nul terminator at the end of the output buffer */ *(morseText + morseLen) = '\0'; /*printf("Decoded morse %s, len %d\n", morseText, morseLen);*/ IupSetStrAttribute(txtMorse, "VALUE", morseText); END: cb_txtMorseAction(txtMorse); free((void *) morseText); return IUP_DEFAULT; }
int IupListDialog (int type, const char *title, int size, const char** list_str, int op, int max_col, int max_lin, int* marks) { Ihandle *lst, *ok, *dlg, *cancel, *dlg_box, *button_box; int i, bt; char attrib_str[20]; char *m=NULL; if (size > 999) size = 999; lst = IupList(NULL); for (i=0;i<size;i++) { sprintf(attrib_str,"%d",i+1); IupSetAttribute(lst,attrib_str,list_str[i]); } sprintf(attrib_str,"%d",i+1); IupSetAttribute(lst,attrib_str,NULL); IupSetAttribute(lst,"EXPAND","YES"); 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( lst, button_box, NULL); IupSetAttribute(dlg_box,"MARGIN","10x10"); IupSetAttribute(dlg_box,"GAP","10"); dlg = IupDialog(dlg_box); if (type == 1) { if (op<1 || op>size) op=1; iupAttribSetStrf(dlg, "_IUP_LIST_NUMBER", "%d", op-1); IupSetfAttribute(lst,"VALUE","%d",op); IupSetCallback(lst, "ACTION", (Icallback)CB_lista); } else if ((type == 2) && (marks != NULL)) { m=(char *)marks; for (i=0;i<size;i++) m[i] = marks[i] ? '+' : '-'; m[i]='\0'; IupSetAttribute(lst,"MULTIPLE","YES"); IupSetAttribute(lst,"VALUE",m); } if (max_lin < 4) max_lin = 4; IupSetfAttribute(lst, "VISIBLELINES", "%d", max_lin); IupSetfAttribute(lst, "VISIBLECOLUMNS", "%d", max_col); 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")); IupPopup(dlg,IUP_CENTER,IUP_CENTER); if ((type == 2) && (marks != NULL)) { m=IupGetAttribute(lst,"VALUE"); for (i=0;i<size;i++) marks[i] = (m[i] == '+'); } bt = IupGetInt(dlg, "STATUS"); if (type == 1) { if (bt == 1) bt = iupAttribGetInt(dlg, "_IUP_LIST_NUMBER"); else bt = -1; } else { if (bt != 1) bt = -1; } IupDestroy(dlg); return bt; }
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, "FILTER", "*.jpg;*.jpeg;*.bmp;*.gif;*.tif;*.tiff;*.png"); // IupSetAttribute(dlg, "EXTFILTER", "Text files|*.txt;*.doc|Image files|*.jpg;*.bmp;*.gif|"); // IupSetAttribute(dlg, "FILE", "/tecgraf/im/test.bmp"); // IupSetAttribute(dlg, "FILE", "test.bmp"); // IupSetAttribute(dlg, "FILTER", "*.txt"); // IupSetAttribute(dlg, "FILTER", "*.bmp;*.jpg"); // IupSetAttribute(dlg, "EXTFILTER", "TEXT|*.txt|"); // IupSetAttribute(dlg, "EXTFILTER", "BMP FILES|*.bmp|JPEG FILES|*.jpg|"); IupSetAttribute(dlg, "EXTFILTER", "IMAGEFILES|*.bmp;*.jpg|TEXT|*.txt|"); } IupSetCallback(dlg, "HELP_CB", (Icallback)help_cb); IupSetAttribute(dlg, "FILE", "test.bmp"); // 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"); // IupSetAttribute(dlg, "RASTERSIZE", "800x600"); IupSetCallback(dlg, "FILE_CB", (Icallback)file_cb); if (preview) { IupSetAttribute(dlg, "SHOWPREVIEW", "YES"); #ifdef USE_OPENGL if (preview==2) { Ihandle* glcanvas = IupGLCanvas(NULL); IupSetAttribute(glcanvas, "BUFFER", "DOUBLE"); IupSetAttributeHandle(dlg, "PREVIEWGLCANVAS", glcanvas); } #endif } IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); switch(IupGetInt(dlg, "STATUS")) { case 1: printf("OK\n"); printf(" New file - VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); printf(" DIRECTORY(%s)\n", IupGetAttribute(dlg, "DIRECTORY")); break; case 0 : printf("OK\n"); printf(" File exists - VALUE(%s)\n", IupGetAttribute(dlg, "VALUE")); printf(" DIRECTORY(%s)\n", IupGetAttribute(dlg, "DIRECTORY")); break; case -1 : printf("CANCEL\n"); break; } IupDestroy(dlg); }