int iupKeyProcessMnemonic(Ihandle* ih, int code) { Ihandle *ih_mnemonic, *dialog = IupGetDialog(ih); char attrib[16] = "_IUP_MNEMONIC_ "; attrib[14] = (char)code; iupStrUpper(attrib, attrib); ih_mnemonic = (Ihandle*)IupGetAttribute(dialog, attrib); if (iupObjectCheck(ih_mnemonic)) { if (IupClassMatch(ih_mnemonic, "label")) { Ihandle* ih_next = iupFocusNextInteractive(ih_mnemonic); if (ih_next) { if (IupClassMatch(ih_next, "button") || IupClassMatch(ih_next, "toggle")) iupdrvActivate(ih_next); else IupSetFocus(ih_next); } } else if (IupClassMatch(ih_mnemonic, "tabs")) IupSetAttribute(ih_mnemonic, "VALUEPOS", IupGetAttribute(ih_mnemonic, attrib)); else if (ih_mnemonic->handle) /* button or toggle */ iupdrvActivate(ih_mnemonic); return 1; } return 0; }
static int winFrameMapMethod(Ihandle* ih) { char *title; DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS| BS_OWNERDRAW, /* owner draw necessary because BS_GROUPBOX does not work ok */ dwExStyle = 0; if (!ih->parent) return IUP_ERROR; title = iupAttribGet(ih, "TITLE"); if (title) iupAttribSetStr(ih, "_IUPFRAME_HAS_TITLE", "1"); if (iupAttribGetBoolean(IupGetDialog(ih), "COMPOSITED")) dwExStyle |= WS_EX_COMPOSITED; else dwStyle |= WS_CLIPCHILDREN; if (!iupwinCreateWindowEx(ih, "BUTTON", dwExStyle, dwStyle)) return IUP_ERROR; /* replace the WinProc to handle other messages */ IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winFrameProc); /* Process WM_DRAWITEM */ IupSetCallback(ih, "_IUPWIN_DRAWITEM_CB", (Icallback)winFrameDrawItem); return IUP_NOERROR; }
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; }
/* %F Muda o alihamento dos textos em uma determinada coluna. Redesenha a coluna se estiver visivel. %i h : handle da matriz, col : coluna ater seu alinhamento mudado. col = 1 representa aprimeira coluna da matriz. */ void iupmatSetColAlign (Ihandle *h, int col) { Tmat *mat=(Tmat*)matrix_data(h); Ihandle *d = IupGetDialog(h); int visible = (iupCheck(h,IUP_VISIBLE)==YES) && (iupCheck(d,IUP_VISIBLE)==YES); int err; IsCanvasSet(mat,err); if(col > mat_nc(mat) || col < 0) return; if(!visible || err!=CD_OK) return; if(col == 0) /* Alinhamento da coluna de titulos */ { iupmatDrawLineTitle(h, mat_fl(mat), mat_ll(mat)); } else { col--; /* a celula super. esq. e 1:1 para o usuario, internamente e 0:0 */ /* Se a coluna esta na parte visivel, redesenha a matriz */ if((col >= mat_fc(mat))&&(col <= mat_lc(mat))) { iupmatDrawCells(h,mat_fl(mat),col,mat_ll(mat),col); iupmatShowFocus(h); } } }
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; }
void iupdrvSetFocus(Ihandle *ih) { Ihandle* dialog = IupGetDialog(ih); if (!gtk_window_is_active((GtkWindow*)dialog->handle)) gdk_window_focus(iupgtkGetWindow(dialog->handle), gtk_get_current_event_time()); gtk_widget_grab_focus(ih->handle); }
static int getvalue_cb(Ihandle *ih) { Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); Ihandle *text = IupGetDialogChild(ih, "text"); IupSetAttribute(text, "VALUE", IupGetAttribute(list, "VALUE")); return IUP_DEFAULT; }
void iupwinGetNativeParentStyle(Ihandle* ih, DWORD *dwExStyle, DWORD *dwStyle) { *dwStyle |= WS_CLIPCHILDREN; if (iupAttribGetBoolean(IupGetDialog(ih), "COMPOSITED")) *dwExStyle |= WS_EX_COMPOSITED; }
void setactivelist(Ihandle* ih) { Ihandle* dialog = IupGetDialog(ih); Ihandle* label = (Ihandle*)IupGetAttribute(dialog, "_LABEL"); IupSetAttribute(dialog, "_ACTIVE_LIST", (char*)ih); IupSetAttribute(label, "TITLE", IupGetAttribute(IupGetParent(IupGetParent(ih)), "TITLE")); }
static int selectedtext_cb(Ihandle *ih) { Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); Ihandle *text = IupGetDialogChild(ih, "text"); IupSetAttribute(text, "VALUE", IupGetAttribute(list, "SELECTEDTEXT")); return IUP_DEFAULT; }
static int removeitem_cb(Ihandle *ih) { Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); Ihandle *text = IupGetDialogChild(ih, "text"); IupSetAttribute(list, "REMOVEITEM", IupGetAttribute(text, "VALUE")); return IUP_DEFAULT; }
static int insertitem_cb(Ihandle *ih) { Ihandle *list = (Ihandle*)IupGetAttribute(IupGetDialog(ih), "_ACTIVE_LIST"); Ihandle *text = IupGetDialogChild(ih, "text"); IupSetAttribute(list, "INSERTITEM3", IupGetAttribute(text, "VALUE")); return IUP_DEFAULT; }
int item_open_action_cb(Ihandle* item_open) { if (!save_check(item_open)) return IUP_DEFAULT; return select_file(IupGetDialog(item_open), 1); }
char* iupDialogGetChildIdStr(Ihandle* ih) { char *str = iupStrGetMemory(50); Ihandle* dialog = IupGetDialog(ih); sprintf(str, "iup-%s-%d", ih->iclass->name, dialog->data->child_id); return str; }
Ihandle* IupGetDialogChild(Ihandle* ih, const char* name) { Ihandle *child, *dialog; char attrib[1024] = "_IUP_DIALOG_CHILD_"; iupASSERT(iupObjectCheck(ih)); if (!iupObjectCheck(ih)) return NULL; if (!name) return NULL; dialog = IupGetDialog(ih); if (dialog) ih = dialog; strcat(attrib, name); child = (Ihandle*)iupAttribGetStr(ih, attrib); if (child) return child; if (ih->firstchild) { child = iBaseFindChild(ih, name); if (child) return child; } return NULL; }
static int CB_list (Ihandle *ih, char *text, int item, int state) { (void)text; if (state) iupAttribSetInt(IupGetDialog(ih), "_IUP_LIST_NUMBER", item-1); return IUP_DEFAULT; }
static int action2_cb(Ihandle* ih) { IupSetAttribute(IupGetDialog(ih), "BGCOLOR", "0 128 0"); // IupSetAttribute(IupGetDialog(ih), "RASTERSIZE", "600x300"); // IupRefresh(IupGetDialog(ih)); // IupFlush(); return IUP_DEFAULT; }
static void ShowFormulaError(Ihandle* ih, lua_State *L) { const char* str_message = IupGetLanguageString("IUP_ERRORINVALIDFORMULA"); const char* error = lua_tostring(L, -1); char msg[1024]; sprintf(msg, "%s\n Lua error: %s", str_message, error); IupMessageError(IupGetDialog(ih), msg); }
int iupDialogGetChildId(Ihandle* ih) { int id; ih = IupGetDialog(ih); if (!ih) return -1; id = ih->data->child_id; ih->data->child_id = id+1; return id; }
void set_new_image(Ihandle* canvas, imImage* image, const char* filename, int dirty) { imImage* old_image = (imImage*)IupGetAttribute(canvas, "IMAGE"); Ihandle* size_lbl = IupGetDialogChild(canvas, "SIZELABEL"); Ihandle* zoom_val = IupGetDialogChild(canvas, "ZOOMVAL"); if (filename) { IupSetStrAttribute(canvas, "FILENAME", filename); IupSetfAttribute(IupGetDialog(canvas), "TITLE", "%s - Simple Paint", str_filetitle(filename)); } else { IupSetAttribute(canvas, "FILENAME", NULL); IupSetAttribute(IupGetDialog(canvas), "TITLE", "Untitled - Simple Paint"); } /* we are going to support only RGB images with no alpha */ imImageRemoveAlpha(image); if (image->color_space != IM_RGB) { imImage* new_image = imImageCreateBased(image, -1, -1, IM_RGB, -1); imConvertColorSpace(image, new_image); imImageDestroy(image); image = new_image; } /* default file format */ const char* format = imImageGetAttribString(image, "FileFormat"); if (!format) imImageSetAttribString(image, "FileFormat", "JPEG"); IupSetAttribute(canvas, "DIRTY", dirty? "Yes": "No"); IupSetAttribute(canvas, "IMAGE", (char*)image); IupSetfAttribute(size_lbl, "TITLE", "%d x %d px", image->width, image->height); if (old_image) imImageDestroy(old_image); IupSetDouble(zoom_val, "VALUE", 0); zoom_update(canvas, 0); }
void iupKeySetMnemonic(Ihandle* ih, int code, int pos) { Ihandle* ih_dialog = IupGetDialog(ih); char attrib[16] = "_IUP_MNEMONIC_ "; attrib[14] = (char)toupper(code); IupSetAttribute(ih_dialog, attrib, (char*)ih); if (IupClassMatch(ih, "tabs")) IupSetfAttribute(ih, attrib, "%d", pos); }
void iupFocusPrevious(Ihandle *ih) { Ihandle *previous = NULL; /* search from the dialog down to the element */ iFocusFindPrevious(IupGetDialog(ih), &previous, ih, 0); if (previous) iupdrvSetFocus(previous); }
int iupDialogGetChildId(Ihandle* ih) { int id; ih = IupGetDialog(ih); if (!ih) return -1; id = ih->data->child_id; if (id == 0) id = 100; /* initial number */ ih->data->child_id = id+1; return id; }
void new_file(Ihandle* ih) { Ihandle* dlg = IupGetDialog(ih); Ihandle* multitext = IupGetDialogChild(dlg, "MULTITEXT"); IupSetAttribute(dlg, "TITLE", "Untitled - Simple Notepad"); IupSetAttribute(multitext, "FILENAME", NULL); IupSetAttribute(multitext, "DIRTY", "NO"); IupSetAttribute(multitext, "VALUE", ""); }
int item_goto_action_cb(Ihandle* item_goto) { Ihandle* multitext = IupGetDialogChild(item_goto, "MULTITEXT"); Ihandle *dlg, *box, *bt_ok, *bt_cancel, *txt, *lbl; int line_count = IupGetInt(multitext, "LINECOUNT"); lbl = IupLabel(NULL); IupSetfAttribute(lbl, "TITLE", "Line Number [1-%d]:", line_count); txt = IupText(NULL); IupSetAttribute(txt, "MASK", IUP_MASK_UINT); /* unsigned integer numbers only */ IupSetAttribute(txt, "NAME", "LINE_TEXT"); IupSetAttribute(txt, "VISIBLECOLUMNS", "20"); bt_ok = IupButton("OK", NULL); IupSetInt(bt_ok, "TEXT_LINECOUNT", line_count); IupSetAttribute(bt_ok, "PADDING", "10x2"); IupSetCallback(bt_ok, "ACTION", (Icallback)goto_ok_action_cb); bt_cancel = IupButton("Cancel", NULL); IupSetCallback(bt_cancel, "ACTION", (Icallback)goto_cancel_action_cb); IupSetAttribute(bt_cancel, "PADDING", "10x2"); box = IupVbox( lbl, txt, IupSetAttributes(IupHbox( IupFill(), bt_ok, bt_cancel, NULL), "NORMALIZESIZE=HORIZONTAL"), NULL); IupSetAttribute(box, "MARGIN", "10x10"); IupSetAttribute(box, "GAP", "5"); dlg = IupDialog(box); IupSetAttribute(dlg, "TITLE", "Go To Line"); IupSetAttribute(dlg, "DIALOGFRAME", "Yes"); IupSetAttributeHandle(dlg, "DEFAULTENTER", bt_ok); IupSetAttributeHandle(dlg, "DEFAULTESC", bt_cancel); IupSetAttributeHandle(dlg, "PARENTDIALOG", IupGetDialog(item_goto)); IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); if (IupGetInt(dlg, "STATUS") == 1) { int line = IupGetInt(txt, "VALUE"); int pos; IupTextConvertLinColToPos(multitext, line, 0, &pos); IupSetInt(multitext, "CARETPOS", pos); IupSetInt(multitext, "SCROLLTOPOS", pos); } IupDestroy(dlg); return IUP_DEFAULT; }
int iupBaseSetNameAttrib(Ihandle* ih, const char* value) { Ihandle* dialog = IupGetDialog(ih); if (dialog) { char attrib[1024] = "_IUP_DIALOG_CHILD_"; strcat(attrib, value); iupAttribSet(dialog, attrib, (char*)ih); } return 1; }
/*****************************************\ * Sets the RGB color in the Color Canvas * \*****************************************/ static void iColorDlgColor_Update(IcolorDlgData* colordlg_data) { colordlg_data->color = iupDrawColor(colordlg_data->red, colordlg_data->green, colordlg_data->blue, colordlg_data->alpha); IupUpdate(colordlg_data->color_cnv); { Ihandle* ih = IupGetDialog(colordlg_data->color_browser); Icallback cb = IupGetCallback(ih, "COLORUPDATE_CB"); if (cb) cb(ih); } }
static int iColorDlgButtonHelp_CB(Ihandle* ih) { Icallback cb = IupGetCallback(IupGetDialog(ih), "HELP_CB"); if (cb && cb(ih) == IUP_CLOSE) { IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA"); colordlg_data->status = 0; return IUP_CLOSE; } return IUP_DEFAULT; }
char* iupMenuGetChildIdStr(Ihandle* ih) { Ihandle* dlg = IupGetDialog(ih); if (dlg) return iupDialogGetChildIdStr(ih); else { Ihandle* dialog = iMenuGetTopMenu(ih); return iupStrReturnStrf("iup-%s-%d", ih->iclass->name, dialog->data->child_id); } }
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; }