static int User(lua_State *L) { Ihandle *ih = IupUser(); iuplua_plugstate(L, ih); iuplua_pushihandle_raw(L, ih); return 1; }
static Ihandle *motTimerCreate(Iclass *ic) { Ihandle *timer = NULL; assert(ic != NULL); if(ic == NULL) return NULL; timer = IupUser(); number(timer) = -1; return timer; }
static Ihandle* motMessageDlgCreate(Iclass *ic) { Ihandle* user = IupUser(); Ihandle* ih = IupDialog( user ); IupSetAttribute( user, IUP_EXPAND, IUP_YES ); IupSetAttribute( ih, IUP_MINBOX, IUP_NO ); IupSetAttribute( ih, IUP_MAXBOX, IUP_NO ); IupSetAttribute( ih, IUP_RESIZE, IUP_NO ); return ih; }
static void create_CircleProgress_animation(void) { Ihandle* animation = IupUser(); int i; char name[30]; for (i = 0; i < 12; i++) { sprintf(name, "IUP_CircleProgress%d", i); IupAppend(animation, IupGetHandle(name)); } IupSetHandle("IUP_CircleProgressAnimation", animation); IupSetAttribute(animation, "FRAMETIME", "83"); /* near 1s for a full turn */ }
void TextTest(void) { int formatting = 0; Ihandle *dlg, *mltline, *text, *opt, *btn_def_enter, *btn_def_esc, *btn_active, *btn_overwrite, *btn_append, *btn_insert, *btn_caret, *btn_clip, *btn_key, *btn_readonly, *btn_tabsize, *btn_selection, *btn_selectedtext, *btn_nc, *btn_value, *lbl, *formattag, *btn_remformat; // IupSetGlobal("UTF8AUTOCONVERT", "NO"); text = IupText (NULL); IupSetAttribute(text, "EXPAND", "HORIZONTAL"); // IupSetAttribute(text, "VALUE", "Single Line Text"); IupSetAttribute(text, "CUEBANNER", "Enter Attribute Value Here"); IupSetAttribute(text, "NAME", "text"); IupSetAttribute(text, "TIP", "Attribute Value"); // IupSetAttribute(text, "FORMATTING", "YES"); opt = IupToggle("Set/Get", NULL); IupSetAttribute (opt, "VALUE", "ON"); IupSetHandle ("text2multi", opt); mltline = IupMultiLine(NULL); // mltline = IupText(NULL); // IupSetAttribute(mltline, "MULTILINE", "YES"); IupSetAttribute(mltline, "NAME", "mltline"); IupSetCallback(mltline, "DROPFILES_CB", (Icallback)dropfiles_cb); IupSetCallback(mltline, "BUTTON_CB", (Icallback)button_cb); // IupSetCallback(mltline, "MOTION_CB", (Icallback)motion_cb); IupSetCallback(mltline, "HELP_CB", (Icallback)help_cb); IupSetCallback(mltline, "GETFOCUS_CB", (Icallback)getfocus_cb); IupSetCallback(mltline, "KILLFOCUS_CB", (Icallback)killfocus_cb); IupSetCallback(mltline, "ENTERWINDOW_CB", (Icallback)enterwindow_cb); IupSetCallback(mltline, "LEAVEWINDOW_CB", (Icallback)leavewindow_cb); IupSetCallback(mltline, "ACTION", (Icallback)action); // IupSetCallback(mltline, "VALUECHANGED_CB", (Icallback)valuechanged_cb); // IupSetCallback(mltline, "K_ANY", (Icallback)k_any); IupSetCallback(mltline, "K_F2", (Icallback)k_f2); // IupSetCallback(mltline, "CARET_CB", (Icallback)caret_cb); // IupSetAttribute(mltline, "WORDWRAP", "YES"); // IupSetAttribute(mltline, "BORDER", "NO"); // IupSetAttribute(mltline, "AUTOHIDE", "YES"); // IupSetAttribute(mltline, "BGCOLOR", "255 0 128"); // IupSetAttribute(mltline, "FGCOLOR", "0 128 192"); // IupSetAttribute(mltline, "PADDING", "15x15"); if (IupGetInt(NULL, "UTF8MODE")) IupSetAttribute(mltline, "VALUE", "First Line\nSecond Line Big Big Big\nThird Line\nmore\nmore\n(çãõáóé)"); // UTF-8 else { char* txt = "First Line\nSecond Line Big Big Big\nThird Line\nmore\nmore\n(ηγυασι)"; //int len = strlen(txt); IupSetAttribute(mltline, "VALUE", txt); // Windows-1252 } IupSetAttribute(mltline, "TIP", "First Line\nSecond Line\nThird Line"); // IupSetAttribute(mltline, "FONT", "Helvetica, 14"); // IupSetAttribute(mltline, "MASK", IUP_MASK_FLOAT); // IupSetAttribute(mltline, "FILTER", "UPPERCASE"); // IupSetAttribute(mltline, "ALIGNMENT", "ACENTER"); // IupSetAttribute(mltline, "CANFOCUS", "NO"); // IupSetAttribute(mltline, "SCROLLBAR", "NO"); // IupSetAttribute(mltline, "NOHIDESEL", "Yes"); /* Turns on multiline expand and text horizontal expand */ IupSetAttribute(mltline, "SIZE", "80x40"); IupSetAttribute(mltline, "EXPAND", "YES"); // IupSetAttribute(mltline, "FONT", "Courier, 16"); // IupSetAttribute(mltline, "FONT", "Arial, 12"); // IupSetAttribute(mltline, "FORMATTING", "YES"); formatting = 1; if (formatting) /* just to make easier to comment this section */ { /* formatting before Map */ IupSetAttribute(mltline, "FORMATTING", "YES"); formattag = IupUser(); IupSetAttribute(formattag, "ALIGNMENT", "CENTER"); IupSetAttribute(formattag, "SPACEAFTER", "10"); IupSetAttribute(formattag, "FONTSIZE", "24"); IupSetAttribute(formattag, "SELECTION", "3,1:3,50"); IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); formattag = IupUser(); IupSetAttribute(formattag, "BGCOLOR", "255 128 64"); IupSetAttribute(formattag, "UNDERLINE", "SINGLE"); IupSetAttribute(formattag, "WEIGHT", "BOLD"); IupSetAttribute(formattag, "SELECTION", "3,7:3,11"); IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); } /* Creates buttons */ btn_append = IupButton ("&APPEND", NULL); btn_insert = IupButton ("INSERT", NULL); btn_caret = IupButton ("CARET", NULL); btn_readonly = IupButton ("READONLY", NULL); btn_selection = IupButton ("SELECTION", NULL); btn_selectedtext = IupButton ("SELECTEDTEXT", NULL); btn_nc = IupButton ("NC", NULL); btn_value = IupButton ("VALUE", NULL); btn_tabsize = IupButton ("TABSIZE", NULL); btn_clip = IupButton ("CLIPBOARD", NULL); btn_key = IupButton ("KEY", NULL); btn_def_enter = IupButton ("Default Enter", NULL); btn_def_esc = IupButton ("Default Esc", NULL); btn_active = IupButton("ACTIVE", NULL); btn_remformat = IupButton("REMOVEFORMATTING", NULL); btn_overwrite = IupButton("OVERWRITE", NULL); IupSetAttribute(btn_append, "TIP", "First Line\nSecond Line\nThird Line"); /* Registers callbacks */ IupSetCallback(btn_append, "ACTION", (Icallback) btn_append_cb); IupSetCallback(btn_insert, "ACTION", (Icallback) btn_insert_cb); IupSetCallback(btn_caret, "ACTION", (Icallback) btn_caret_cb); IupSetCallback(btn_readonly, "ACTION", (Icallback) btn_readonly_cb); IupSetCallback(btn_selection, "ACTION", (Icallback) btn_selection_cb); IupSetCallback(btn_selectedtext, "ACTION", (Icallback) btn_selectedtext_cb); IupSetCallback(btn_nc, "ACTION", (Icallback) btn_nc_cb); IupSetCallback(btn_value, "ACTION", (Icallback) btn_value_cb); IupSetCallback(btn_tabsize, "ACTION", (Icallback) btn_tabsize_cb); IupSetCallback(btn_clip, "ACTION", (Icallback) btn_clip_cb); IupSetCallback(btn_key, "ACTION", (Icallback) btn_key_cb); IupSetCallback(btn_def_enter, "ACTION", (Icallback) btn_def_enter_cb); IupSetCallback(btn_def_esc, "ACTION", (Icallback) btn_def_esc_cb); IupSetCallback(btn_active, "ACTION", (Icallback) btn_active_cb); IupSetCallback(btn_remformat, "ACTION", (Icallback) btn_remformat_cb); IupSetCallback(btn_overwrite, "ACTION", (Icallback) btn_overwrite_cb); lbl = IupLabel("&Multiline:"); IupSetAttribute(lbl, "PADDING", "2x2"); /* Creates dlg */ dlg = IupDialog(IupVbox(lbl, mltline, IupHbox (text, opt, NULL), IupHbox (btn_append, btn_insert, btn_caret, btn_readonly, btn_selection, NULL), IupHbox (btn_selectedtext, btn_nc, btn_value, btn_tabsize, btn_clip, btn_key, NULL), IupHbox (btn_def_enter, btn_def_esc, btn_active, btn_remformat, btn_overwrite, NULL), NULL)); IupSetCallback(dlg, "K_cO", (Icallback)file_open); IupSetAttribute(dlg, "TITLE", "IupText Test"); IupSetAttribute(dlg, "MARGIN", "10x10"); IupSetAttribute(dlg, "GAP", "5"); IupSetAttributeHandle(dlg, "DEFAULTENTER", btn_def_enter); IupSetAttributeHandle(dlg, "DEFAULTESC", btn_def_esc); IupSetAttribute(dlg, "SHRINK", "YES"); if (formatting) /* just to make easier to comment this section */ { IupMap(dlg); /* formatting after Map */ formattag = IupUser(); IupSetAttribute(formattag, "ITALIC", "YES"); IupSetAttribute(formattag, "STRIKEOUT", "YES"); IupSetAttribute(formattag, "SELECTION", "2,1:2,12"); IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); if (1) { int count = IupGetInt(mltline, "COUNT"); IupSetAttribute(mltline, "APPEND", "Append Test"); formattag = IupUser(); IupSetAttribute(formattag, "FGCOLOR", "0 128 64"); IupSetfAttribute(formattag, "SELECTIONPOS", "%d:%d", count+1, IupGetInt(mltline, "COUNT")); IupSetAttribute(mltline, "ADDFORMATTAG_HANDLE", (char*)formattag); } } /* Shows dlg in the center of the screen */ IupShowXY(dlg, IUP_CENTER, IUP_CENTER); IupSetFocus(mltline); }
static void CreateUser(void) { lua_pushusertag(IupUser(), iuplua_tag); }
Ihandle* IupCreatev(const char *name, void **params) { Iclass *ic = NULL; char lower[30]; int size = 0; assert(name); if(name == NULL) return NULL; size = (int)strlen(name); size++; assert(size < 30 && size > 0); /* invalid name */ if(size > 30 || size <= 0) return NULL; while(size--) lower[size] = (char)tolower(name[size]); if(iupStrEqual(lower, "dialog")) return IupDialog(params? params[0] : NULL); else if(iupStrEqual(lower, "canvas")) return IupCanvas(NULL); else if(iupStrEqual(lower, "button")) return IupButton(NULL, NULL); else if(iupStrEqual(lower, "toggle")) return IupToggle(NULL, NULL); else if(iupStrEqual(lower, "label")) return IupLabel(NULL); else if(iupStrEqual(lower, "frame")) return IupFrame(NULL); else if(iupStrEqual(lower, "list")) return IupList(NULL); else if(iupStrEqual(lower, "multiline")) return IupMultiLine(NULL); else if(iupStrEqual(lower, "text")) return IupText(NULL); else if(iupStrEqual(lower, "user")) return IupUser(); else if(iupStrEqual(lower, "fill")) return IupFill(); else if(iupStrEqual(lower, "separator")) return IupSeparator(); else if(iupStrEqual(lower, "item")) return IupItem(NULL, NULL); else if(iupStrEqual(lower, "hbox")) return IupHboxv((Ihandle**)params); else if(iupStrEqual(lower, "zbox")) return IupZboxv((Ihandle**)params); else if(iupStrEqual(lower, "vbox")) return IupVboxv((Ihandle**)params); else if(iupStrEqual(lower, "menu")) return IupMenuv((Ihandle**)params); else if(iupStrEqual(lower, "radio")) return IupRadio(params[0]); else if(iupStrEqual(lower, "submenu")) return IupSubmenu(NULL, params? params[0] : NULL); /* Not accepted: image color IupGetFile IupListDialog IupMessage IupScanf IupAlarm */ ic = iupCpiGetClass(lower); return iupCpiCreate(ic, params); }