static int Normalizer(lua_State *L) { Ihandle *ih = IupNormalizer(NULL); iuplua_plugstate(L, ih); iuplua_pushihandle_raw(L, ih); return 1; }
void iuplua_show_error_message(const char *pname, const char* msg) { Ihandle *multi_text, *lbl, *copy, *button, *box, *dlg, *abort, *buttonbox; char* value = IupGetGlobal("LUA_ERROR_LABEL"); if (!pname) pname = "_@IUP_ERROR"; lbl = IupLabel("_@IUP_LUAERROR"); IupSetAttribute(lbl, "EXPAND", "HORIZONTAL"); if (value) IupSetStrAttribute(lbl, "TITLE", value); copy = IupButton("_@IUP_COPY", NULL); IupSetStrAttribute(copy, "TIP", "_@IUP_COPYTOCLIPBOARD"); IupSetStrAttribute(copy, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback(copy, "ACTION", show_error_copy_action); button = IupButton("_@IUP_CONTINUE", NULL); IupSetStrAttribute(button, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback(button, "ACTION", show_error_continue_action); abort = IupButton("_@IUP_EXIT", NULL); IupSetStrAttribute(abort, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback(abort, "ACTION", show_error_exit_action); multi_text = IupMultiLine(NULL); IupSetAttribute(multi_text, "EXPAND", "YES"); IupSetAttribute(multi_text, "READONLY", "YES"); IupSetAttribute(multi_text, "FONT", "Courier, 12"); IupSetAttribute(multi_text, "VISIBLELINES", "10"); IupSetAttribute(multi_text, "VISIBLECOLUMNS", "50"); IupSetAttribute(multi_text, "NAME", "TEXT"); IupSetStrAttribute(multi_text, "VALUE", msg); buttonbox = IupHbox(copy, button, abort, NULL); IupSetAttribute(buttonbox, "GAP", "50"); IupSetAttribute(IupNormalizer(button, abort, NULL), "NORMALIZE", "HORIZONTAL"); box = IupVbox(lbl, multi_text, buttonbox, NULL); IupSetAttribute(box, "ALIGNMENT", "ACENTER"); IupSetAttribute(box, "NMARGIN", "10x10"); IupSetAttribute(box, "GAP", "10"); dlg = IupDialog(box); IupSetStrAttribute(dlg, "TITLE", pname); IupSetAttribute(dlg, "MINBOX", "NO"); IupSetAttribute(dlg, "MAXBOX", "NO"); IupSetAttribute(dlg, "PARENTDIALOG", IupGetGlobal("PARENTDIALOG")); IupSetAttribute(dlg, "ICON", IupGetGlobal("ICON")); IupSetAttributeHandle(dlg, "DEFAULTESC", button); IupSetAttributeHandle(dlg, "DEFAULTENTER", button); IupSetAttributeHandle(dlg, "STARTFOCUS", button); IupPopup(dlg, IUP_CENTERPARENT, IUP_CENTERPARENT); IupDestroy(dlg); }
static int iBaseSetNormalizerGroupAttrib(Ihandle* ih, const char* value) { Ihandle* ih_normalizer = IupGetHandle(value); if (!ih_normalizer) { ih_normalizer = IupNormalizer(NULL); IupSetHandle(value, ih_normalizer); } IupSetAttribute(ih_normalizer, "ADDCONTROL_HANDLE", (char*)ih); return 1; }
static int iColorDlgCreateMethod(Ihandle* ih, void** params) { Ihandle *ok_bt, *cancel_bt; Ihandle *rgb_vb, *hsi_vb, *clr_vb; Ihandle *lin1, *lin2, *col1, *col2; IcolorDlgData* colordlg_data = (IcolorDlgData*)malloc(sizeof(IcolorDlgData)); memset(colordlg_data, 0, sizeof(IcolorDlgData)); iupAttribSet(ih, "_IUP_GC_DATA", (char*)colordlg_data); /* ======================================================================= */ /* BUTTONS ============================================================= */ /* ======================================================================= */ ok_bt = IupButton("_@IUP_OK", NULL); /* Ok Button */ IupSetStrAttribute(ok_bt, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback (ok_bt, "ACTION", (Icallback)iColorDlgButtonOK_CB); IupSetAttributeHandle(ih, "DEFAULTENTER", ok_bt); cancel_bt = IupButton("_@IUP_CANCEL", NULL); /* Cancel Button */ IupSetStrAttribute(cancel_bt, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback (cancel_bt, "ACTION", (Icallback)iColorDlgButtonCancel_CB); IupSetAttributeHandle(ih, "DEFAULTESC", cancel_bt); colordlg_data->help_bt = IupButton("_@IUP_HELP", NULL); /* Help Button */ IupSetStrAttribute(colordlg_data->help_bt, "PADDING", IupGetGlobal("DEFAULTBUTTONPADDING")); IupSetCallback (colordlg_data->help_bt, "ACTION", (Icallback)iColorDlgButtonHelp_CB); /* ======================================================================= */ /* COLOR =============================================================== */ /* ======================================================================= */ colordlg_data->color_browser = IupColorBrowser(); IupSetAttribute(colordlg_data->color_browser, "EXPAND", "YES"); IupSetCallback(colordlg_data->color_browser, "DRAG_CB", (Icallback)iColorDlgColorSelDrag_CB); IupSetCallback(colordlg_data->color_browser, "CHANGE_CB", (Icallback)iColorDlgColorSelDrag_CB); IupSetAttribute(colordlg_data->color_browser, "MINSIZE", "200x200"); colordlg_data->color_cnv = IupCanvas(NULL); /* Canvas of the color */ IupSetAttribute(colordlg_data->color_cnv, "SIZE", "x12"); IupSetAttribute(colordlg_data->color_cnv, "CANFOCUS", "NO"); IupSetAttribute(colordlg_data->color_cnv, "EXPAND", "HORIZONTAL"); IupSetCallback (colordlg_data->color_cnv, "ACTION", (Icallback)iColorDlgColorCnvAction_CB); IupSetCallback (colordlg_data->color_cnv, "BUTTON_CB", (Icallback)iColorDlgColorCnvButton_CB); colordlg_data->colorhex_txt = IupText(NULL); /* Hex of the color */ IupSetAttribute(colordlg_data->colorhex_txt, "VISIBLECOLUMNS", "7"); IupSetCallback (colordlg_data->colorhex_txt, "ACTION", (Icallback)iColorDlgHexAction_CB); IupSetAttribute(colordlg_data->colorhex_txt, "MASK", "#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"); /* ======================================================================= */ /* ALPHA TRANSPARENCY ================================================== */ /* ======================================================================= */ colordlg_data->alpha_val = IupVal("HORIZONTAL"); IupSetAttribute(colordlg_data->alpha_val, "EXPAND", "HORIZONTAL"); IupSetAttribute(colordlg_data->alpha_val, "MIN", "0"); IupSetAttribute(colordlg_data->alpha_val, "MAX", "255"); IupSetAttribute(colordlg_data->alpha_val, "VALUE", "255"); IupSetAttribute(colordlg_data->alpha_val, "SIZE", "80x12"); IupSetCallback (colordlg_data->alpha_val, "MOUSEMOVE_CB", (Icallback)iColorDlgAlphaVal_CB); IupSetCallback (colordlg_data->alpha_val, "BUTTON_PRESS_CB", (Icallback)iColorDlgAlphaVal_CB); IupSetCallback (colordlg_data->alpha_val, "BUTTON_RELEASE_CB", (Icallback)iColorDlgAlphaVal_CB); colordlg_data->alpha_txt = IupText(NULL); /* Alpha value */ IupSetAttribute(colordlg_data->alpha_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->alpha_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->alpha_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->alpha_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->alpha_txt, "SPININC", "1"); IupSetCallback (colordlg_data->alpha_txt, "ACTION", (Icallback)iColorDlgAlphaAction_CB); IupSetCallback (colordlg_data->alpha_txt, "SPIN_CB", (Icallback)iColorDlgAlphaSpin_CB); IupSetAttribute(colordlg_data->alpha_txt, "MASKINT", "0:255"); /* ======================================================================= */ /* COLOR TABLE ========================================================= */ /* ======================================================================= */ colordlg_data->colortable_cbar = IupColorbar(); IupSetAttribute(colordlg_data->colortable_cbar, "ORIENTATION", "HORIZONTAL"); IupSetAttribute(colordlg_data->colortable_cbar, "NUM_PARTS", "2"); IupSetInt(colordlg_data->colortable_cbar, "NUM_CELLS", COLORTABLE_MAX); IupSetAttribute(colordlg_data->colortable_cbar, "SHOW_PREVIEW", "NO"); IupSetAttribute(colordlg_data->colortable_cbar, "SIZE", "138x22"); IupSetAttribute(colordlg_data->colortable_cbar, "SQUARED", "NO"); IupSetCallback (colordlg_data->colortable_cbar, "SELECT_CB", (Icallback)iColorDlgColorTableSelect_CB); /* ======================================================================= */ /* RGB TEXT FIELDS ===================================================== */ /* ======================================================================= */ colordlg_data->red_txt = IupText(NULL); /* Red value */ IupSetAttribute(colordlg_data->red_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->red_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->red_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->red_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->red_txt, "SPININC", "1"); IupSetCallback (colordlg_data->red_txt, "ACTION", (Icallback)iColorDlgRedAction_CB); IupSetCallback (colordlg_data->red_txt, "SPIN_CB", (Icallback)iColorDlgRedSpin_CB); IupSetAttribute(colordlg_data->red_txt, "MASKINT", "0:255"); colordlg_data->green_txt = IupText(NULL); /* Green value */ IupSetAttribute(colordlg_data->green_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->green_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->green_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->green_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->green_txt, "SPININC", "1"); IupSetCallback (colordlg_data->green_txt, "ACTION", (Icallback)iColorDlgGreenAction_CB); IupSetCallback (colordlg_data->green_txt, "SPIN_CB", (Icallback)iColorDlgGreenSpin_CB); IupSetAttribute(colordlg_data->green_txt, "MASKINT", "0:255"); colordlg_data->blue_txt = IupText(NULL); /* Blue value */ IupSetAttribute(colordlg_data->blue_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->blue_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->blue_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->blue_txt, "SPINMAX", "255"); IupSetAttribute(colordlg_data->blue_txt, "SPININC", "1"); IupSetCallback (colordlg_data->blue_txt, "ACTION", (Icallback)iColorDlgBlueAction_CB); IupSetCallback (colordlg_data->blue_txt, "SPIN_CB", (Icallback)iColorDlgBlueSpin_CB); IupSetAttribute(colordlg_data->blue_txt, "MASKINT", "0:255"); /* ======================================================================= */ /* HSI TEXT FIELDS ===================================================== */ /* ======================================================================= */ colordlg_data->hue_txt = IupText(NULL); /* Hue value */ IupSetAttribute(colordlg_data->hue_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->hue_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->hue_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->hue_txt, "SPINMAX", "359"); IupSetAttribute(colordlg_data->hue_txt, "SPINWRAP", "YES"); IupSetAttribute(colordlg_data->hue_txt, "SPININC", "1"); IupSetCallback(colordlg_data->hue_txt, "ACTION", (Icallback)iColorDlgHueAction_CB); IupSetCallback(colordlg_data->hue_txt, "SPIN_CB", (Icallback)iColorDlgHueSpin_CB); IupSetAttribute(colordlg_data->hue_txt, "MASKINT", "0:359"); colordlg_data->saturation_txt = IupText(NULL); /* Saturation value */ IupSetAttribute(colordlg_data->saturation_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->saturation_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->saturation_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->saturation_txt, "SPINMAX", "100"); IupSetAttribute(colordlg_data->saturation_txt, "SPININC", "1"); IupSetCallback(colordlg_data->saturation_txt, "ACTION", (Icallback)iColorDlgSaturationAction_CB); IupSetCallback(colordlg_data->saturation_txt, "SPIN_CB", (Icallback)iColorDlgSaturationSpin_CB); IupSetAttribute(colordlg_data->saturation_txt, "MASKINT", "0:100"); colordlg_data->intensity_txt = IupText(NULL); /* Intensity value */ IupSetAttribute(colordlg_data->intensity_txt, "VISIBLECOLUMNS", "3"); IupSetAttribute(colordlg_data->intensity_txt, "SPIN", "YES"); IupSetAttribute(colordlg_data->intensity_txt, "SPINMIN", "0"); IupSetAttribute(colordlg_data->intensity_txt, "SPINMAX", "100"); IupSetAttribute(colordlg_data->intensity_txt, "SPININC", "1"); IupSetCallback(colordlg_data->intensity_txt, "ACTION", (Icallback)iColorDlgIntensityAction_CB); IupSetCallback(colordlg_data->intensity_txt, "SPIN_CB", (Icallback)iColorDlgIntensitySpin_CB); IupSetAttribute(colordlg_data->intensity_txt, "MASKINT", "0:100"); /* =================== */ /* 1st line = Controls */ /* =================== */ col1 = IupVbox(colordlg_data->color_browser, IupSetAttributes(IupHbox(colordlg_data->color_cnv, NULL), "MARGIN=30x0"),NULL); hsi_vb = IupVbox(IupSetAttributes(IupHbox(IupLabel("_@IUP_HUE"), colordlg_data->hue_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_SATURATION"), colordlg_data->saturation_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_INTENSITY"), colordlg_data->intensity_txt, NULL), "ALIGNMENT=ACENTER"), NULL); IupSetAttribute(hsi_vb, "GAP", "5"); rgb_vb = IupVbox(IupSetAttributes(IupHbox(IupLabel("_@IUP_RED"), colordlg_data->red_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_GREEN"), colordlg_data->green_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("_@IUP_BLUE"), colordlg_data->blue_txt, NULL), "ALIGNMENT=ACENTER"), NULL); IupSetAttribute(rgb_vb, "GAP", "5"); clr_vb = IupVbox(IupSetAttributes(IupHbox(IupLabel("_@IUP_OPACITY"), colordlg_data->alpha_txt, colordlg_data->alpha_val, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupHbox(IupLabel("He&xa:"), colordlg_data->colorhex_txt, NULL), "ALIGNMENT=ACENTER"), IupSetAttributes(IupVbox(IupLabel("_@IUP_PALETTE"), colordlg_data->colortable_cbar, NULL), "GAP=3"), NULL); IupSetAttribute(clr_vb, "GAP", "5"); IupSetAttribute(clr_vb, "EXPAND", "YES"); IupDestroy(IupSetAttributes(IupNormalizer(IupGetChild(IupGetChild(hsi_vb, 0), 0), /* Hue Label */ IupGetChild(IupGetChild(hsi_vb, 1), 0), /* Saturation Label */ IupGetChild(IupGetChild(hsi_vb, 2), 0), /* Intensity Label */ IupGetChild(IupGetChild(clr_vb, 0), 0), /* Opacity Label */ IupGetChild(IupGetChild(clr_vb, 1), 0), /* Hexa Label */ NULL), "NORMALIZE=HORIZONTAL")); IupDestroy(IupSetAttributes(IupNormalizer(IupGetChild(IupGetChild(rgb_vb, 0), 0), /* Red Label */ IupGetChild(IupGetChild(rgb_vb, 1), 0), /* Green Label */ IupGetChild(IupGetChild(rgb_vb, 2), 0), /* Blue Label */ NULL), "NORMALIZE=HORIZONTAL")); col2 = IupVbox(IupSetAttributes(IupHbox(hsi_vb, IupFill(), rgb_vb, NULL), "EXPAND=YES"), IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), clr_vb, NULL); IupSetAttributes(col2, "EXPAND=NO, GAP=10"); lin1 = IupHbox(col1, col2, NULL); IupSetAttribute(lin1, "GAP", "10"); IupSetAttribute(lin1, "MARGIN", "0x0"); /* ================== */ /* 2nd line = Buttons */ /* ================== */ lin2 = IupHbox(IupFill(), ok_bt, cancel_bt, colordlg_data->help_bt, NULL); IupSetAttribute(lin2, "GAP", "5"); IupSetAttribute(lin2, "MARGIN", "0x0"); IupSetAttribute(lin2, "NORMALIZESIZE", "HORIZONTAL"); /* Do not use IupAppend because we set childtype=IUP_CHILDNONE */ iupChildTreeAppend(ih, IupSetAttributes(IupVbox(lin1, IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL"), lin2, NULL), "MARGIN=10x10, GAP=10")); IupRefresh(ih); if (colordlg_data->color_browser->currentwidth < colordlg_data->color_browser->currentheight) { IupSetStrf(colordlg_data->color_browser, "RASTERSIZE", "%dx", colordlg_data->color_browser->currentheight); IupSetAttribute(ih, "RASTERSIZE", NULL); } IupSetAttribute(ih, "RESIZE", "NO"); iColorDlgInit_Defaults(colordlg_data); (void)params; return IUP_NOERROR; }