Imask* iupMaskCreateReal(int positive, const char* decimal_symbol) { Imask* mask; int use_comma = 0; if (decimal_symbol) { if (decimal_symbol[0] == ',') use_comma = 1; } else { struct lconv* locale_info = localeconv(); if (locale_info->decimal_point[0] == ',') use_comma = 1; } if (use_comma) { if (positive) mask = iupMaskCreate(IUP_MASK_UFLOATCOMMA, 0); else mask = iupMaskCreate(IUP_MASK_FLOATCOMMA, 0); } else { if (positive) mask = iupMaskCreate(IUP_MASK_UFLOAT, 0); else mask = iupMaskCreate(IUP_MASK_FLOAT, 0); } return mask; }
static int iListSetMaskAttrib(Ihandle* ih, const char* value) { if (!ih->data->has_editbox) return 0; if (!value) { if (ih->data->mask) { iupMaskDestroy(ih->data->mask); ih->data->mask = NULL; } } else { Imask* mask = iupMaskCreate(value); if (mask) { int val = iupAttribGetInt(ih, "MASKCASEI"); iupMaskSetCaseI(mask, val); val = iupAttribGetInt(ih, "MASKNOEMPTY"); iupMaskSetNoEmpty(mask, val); if (ih->data->mask) iupMaskDestroy(ih->data->mask); ih->data->mask = mask; return 0; } } return 0; }
static int iTextSetMaskAttrib(Ihandle* ih, const char* value) { if (!value) { if (ih->data->mask) { iupMaskDestroy(ih->data->mask); ih->data->mask = NULL; } } else { int casei = iupAttribGetInt(ih, "MASKCASEI"); Imask* mask = iupMaskCreate(value,casei); if (mask) { if (ih->data->mask) iupMaskDestroy(ih->data->mask); ih->data->mask = mask; return 0; } } return 0; }
Imask* iupMaskCreateInt(int min, int max) { Imask* mask; if (min < 0) mask = iupMaskCreate(IUP_MASK_INT, 0); else mask = iupMaskCreate(IUP_MASK_UINT, 0); if (mask) { mask->imin = min; mask->imax = max; mask->type = 'I'; } return mask; }