static int iGridBoxSetCGapLinAttrib(Ihandle* ih, const char* value) { int cgap, charwidth; iupStrToInt(value, &cgap); iupdrvFontGetCharSize(ih, &charwidth, NULL); ih->data->gap_lin = iupWIDTH2RASTER(cgap, charwidth); return 0; }
static int iDialogSetSizeAttrib(Ihandle* ih, const char* value) { if (!value) { ih->userwidth = 0; ih->userheight = 0; } else { char *sh, sw[40]; strcpy(sw, value); sh = strchr(sw, 'x'); if (!sh) sh = ""; else { *sh = '\0'; /* to mark the end of sw */ ++sh; } { int charwidth, charheight; int screen_width, screen_height; int wscale = iDialogSizeGetScale(sw); int hscale = iDialogSizeGetScale(sh); int width = 0, height = 0; iupStrToIntInt(value, &width, &height, 'x'); if (width < 0) width = 0; if (height < 0) height = 0; iupdrvFontGetCharSize(ih, &charwidth, &charheight); /* desktop size, excluding task bars and menu bars */ iupdrvGetScreenSize(&screen_width, &screen_height); if (wscale) width = screen_width/wscale; else width = iupWIDTH2RASTER(width, charwidth); if (hscale) height = screen_height/hscale; else height = iupHEIGHT2RASTER(height, charheight); ih->userwidth = width; ih->userheight = height; } } /* must reset the current size, */ /* so the user or the natural size will be used to resize the dialog */ ih->currentwidth = 0; ih->currentheight = 0; return 0; }
static int iBoxSetCMarginAttrib(Ihandle* ih, const char* value) { int cmargin_x=-1, cmargin_y=-1; int charwidth, charheight; iupdrvFontGetCharSize(ih, &charwidth, &charheight); iupStrToIntInt(value, &cmargin_x, &cmargin_y, 'x'); if (cmargin_x!=-1) ih->data->margin_horiz = iupWIDTH2RASTER(cmargin_x, charwidth); if (cmargin_y!=-1) ih->data->margin_vert = iupHEIGHT2RASTER(cmargin_y, charheight); return 0; }
static int iBoxSetCGapAttrib(Ihandle* ih, const char* value) { int cgap; iupStrToInt(value, &cgap); if (IupClassMatch(ih, "vbox")) { int charheight; iupdrvFontGetCharSize(ih, NULL, &charheight); ih->data->gap = iupHEIGHT2RASTER(cgap, charheight); } else { int charwidth; iupdrvFontGetCharSize(ih, &charwidth, NULL); ih->data->gap = iupWIDTH2RASTER(cgap, charwidth); } return 0; }
int iupBaseSetSizeAttrib(Ihandle* ih, const char* value) { if (!value) { ih->userwidth = 0; ih->userheight = 0; } else { /* if not specified, the value is 0 */ int w = 0, h = 0; int charwidth, charheight; iupdrvFontGetCharSize(ih, &charwidth, &charheight); iupStrToIntInt(value, &w, &h, 'x'); if (w < 0) w = 0; if (h < 0) h = 0; ih->userwidth = iupWIDTH2RASTER(w, charwidth); ih->userheight = iupHEIGHT2RASTER(h, charheight); } return 1; /* always save in the hash table, so when FONT is changed SIZE can be updated */ }
int iupMatrixGetColumnWidth(Ihandle* ih, int col, int use_value) { int width = 0, pixels = 0; char str[100]; char* value; /* can be called for invalid columns (col>numcol) */ sprintf(str, "WIDTH%d", col); value = iupAttribGet(ih, str); if (!value) { sprintf(str, "RASTERWIDTH%d", col); value = iupAttribGet(ih, str); if (value) pixels = 1; } if (use_value && !value) { /* Use the titles to define the size */ if (col == 0) { if (!ih->data->callback_mode || ih->data->use_title_size) { /* find the largest title */ int lin, max_width = 0; for(lin = 0; lin < ih->data->lines.num; lin++) { char* title_value = iupMatrixCellGetValue(ih, lin, 0); if (title_value) { iupdrvFontGetMultiLineStringSize(ih, title_value, &width, NULL); if (width > max_width) max_width = width; } } width = max_width; } } else if (ih->data->use_title_size && (col>0 && col<ih->data->columns.num)) { char* title_value = iupMatrixCellGetValue(ih, 0, col); if (title_value) iupdrvFontGetMultiLineStringSize(ih, title_value, &width, NULL); } if (width) return width + IMAT_PADDING_W + IMAT_FRAME_W; if (col != 0) value = iupAttribGetStr(ih, "WIDTHDEF"); } if (iupStrToInt(value, &width)) { if (width <= 0) return 0; else { if (pixels) return width + IMAT_PADDING_W + IMAT_FRAME_W; else { int charwidth; iupdrvFontGetCharSize(ih, &charwidth, NULL); return iupWIDTH2RASTER(width, charwidth) + IMAT_PADDING_W + IMAT_FRAME_W; } } } return 0; }
int iupMatrixAuxGetColumnWidth(Ihandle* ih, int col) { int width = 0, pixels = 0; char* str = iupStrGetMemory(100); char* value; sprintf(str, "WIDTH%d", col); value = iupAttribGet(ih, str); if (!value) { sprintf(str, "RASTERWIDTH%d", col); value = iupAttribGet(ih, str); if (value) pixels = 1; } if (!value) { if (col == 0) { /* find the largest title */ int lin, max_width = 0; for(lin = 0; lin < ih->data->lines.num; lin++) { char* title_value = iupMatrixCellGetValue(ih, lin, 0); if (title_value) { iupdrvFontGetMultiLineStringSize(ih, title_value, &width, NULL); if (width > max_width) max_width = width; } } width = max_width; } else { char* title_value = iupMatrixCellGetValue(ih, 0, col); if (title_value) iupdrvFontGetMultiLineStringSize(ih, title_value, &width, NULL); } if (width) return width + IMAT_PADDING_W + IMAT_FRAME_W; if (col!=0) value = iupAttribGetStr(ih, "WIDTHDEF"); } if (iupStrToInt(value, &width)) { if (width <= 0) return 0; else { if (pixels) return width + IMAT_PADDING_W + IMAT_FRAME_W; else { int charwidth; iupdrvFontGetCharSize(ih, &charwidth, NULL); return iupWIDTH2RASTER(width, charwidth) + IMAT_PADDING_W + IMAT_FRAME_W; } } } return 0; }