static void gtkDialogSetMinMax(Ihandle* ih, int min_w, int min_h, int max_w, int max_h) { /* The minmax size restricts the client area */ GdkGeometry geometry; int decorwidth = 0, decorheight = 0; iupDialogGetDecorSize(ih, &decorwidth, &decorheight); geometry.min_width = 1; if (min_w > decorwidth) geometry.min_width = min_w-decorwidth; geometry.min_height = 1; if (min_h > decorheight) geometry.min_height = min_h-decorheight; geometry.max_width = 65535; if (max_w > decorwidth && max_w > geometry.min_width) geometry.max_width = max_w-decorwidth; geometry.max_height = 65535; if (max_h > decorheight && max_w > geometry.min_height) geometry.max_height = max_h-decorheight; /* must set both at the same time, or GTK will assume its default */ gtk_window_set_geometry_hints((GtkWindow*)ih->handle, ih->handle, &geometry, (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE)); }
static void iDialogComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *children_expand) { int decorwidth, decorheight; Ihandle* child = ih->firstchild; /* if does not have a menu, but the attribute is defined, try to update the menu before retrieving the decoration. */ char* value = iupAttribGet(ih, "MENU"); if (!ih->data->menu && value) iDialogSetMenuAttrib(ih, value); iupDialogGetDecorSize(ih, &decorwidth, &decorheight); *w = decorwidth; *h = decorheight; if (child) { /* update child natural size first */ iupBaseComputeNaturalSize(child); *children_expand = child->expand; *w += child->naturalwidth; *h += child->naturalheight; } }
static int motDialogSetMaxSizeAttrib(Ihandle* ih, const char* value) { int decorwidth = 0, decorheight = 0; int max_w = 65535, max_h = 65535; /* MAXSIZE default value */ iupStrToIntInt(value, &max_w, &max_h, 'x'); /* The minmax size restricts the client area */ iupDialogGetDecorSize(ih, &decorwidth, &decorheight); if (max_w > decorwidth) XtVaSetValues(ih->handle, XmNmaxWidth, max_w-decorwidth, NULL); if (max_h > decorheight) XtVaSetValues(ih->handle, XmNmaxHeight, max_h-decorheight, NULL); return 1; }
static void iDialogSetCurrentSizeMethod(Ihandle* ih, int w, int h, int shrink) { /* width and height parameters here are ignored, because they are always 0 for the dialog. */ (void)w; (void)h; /* current size is zero before map and when reset by the application */ /* after that the current size must follow the actual size of the dialog */ if (!ih->currentwidth) ih->currentwidth = ih->naturalwidth; if (!ih->currentheight) ih->currentheight = ih->naturalheight; if (ih->firstchild) { int decorwidth, decorheight, client_width, client_height; if (shrink) { client_width = ih->currentwidth; client_height = ih->currentheight; } else { client_width = iupMAX(ih->naturalwidth, ih->currentwidth); client_height = iupMAX(ih->naturalheight, ih->currentheight); } iupDialogGetDecorSize(ih, &decorwidth, &decorheight); client_width -= decorwidth; client_height -= decorheight; iupClassObjectSetCurrentSize(ih->firstchild, client_width, client_height, shrink); } }
static void iDialogSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink) { int decorwidth, decorheight, client_width, client_height; if (shrink) { client_width = ih->currentwidth; client_height = ih->currentheight; } else { client_width = iupMAX(ih->naturalwidth, ih->currentwidth); client_height = iupMAX(ih->naturalheight, ih->currentheight); } iupDialogGetDecorSize(ih, &decorwidth, &decorheight); client_width -= decorwidth; client_height -= decorheight; if (client_width < 0) client_width = 0; if (client_height < 0) client_height = 0; iupBaseSetCurrentSize(ih->firstchild, client_width, client_height, shrink); }
static void iDialogComputeNaturalSizeMethod(Ihandle* ih) { iupBaseContainerUpdateExpand(ih); /* always initialize the natural size using the user size */ ih->naturalwidth = ih->userwidth; ih->naturalheight = ih->userheight; /* the dialog has only one child */ if (ih->firstchild) { int decorwidth, decorheight; Ihandle* child = ih->firstchild; iupDialogGetDecorSize(ih, &decorwidth, &decorheight); /* update child natural size first */ iupClassObjectComputeNaturalSize(child); ih->expand |= child->expand; ih->naturalwidth = iupMAX(ih->naturalwidth, child->naturalwidth + decorwidth); ih->naturalheight = iupMAX(ih->naturalheight, child->naturalheight + decorheight); } }