static void gtkDialogLayoutUpdateMethod(Ihandle *ih) { int border, caption, menu; int width, height; if (ih->data->ignore_resize || iupAttribGet(ih, "_IUPGTK_FS_STYLE")) return; /* for dialogs the position is not updated here */ ih->data->ignore_resize = 1; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); /* set size excluding the border */ width = ih->currentwidth - 2*border; height = ih->currentheight - 2*border - caption; /* menu is inside the client area. */ gtk_window_resize((GtkWindow*)ih->handle, width, height); if (!iupAttribGetBoolean(ih, "RESIZE")) { GdkGeometry geometry; geometry.min_width = width; geometry.min_height = height; geometry.max_width = width; geometry.max_height = height; gtk_window_set_geometry_hints((GtkWindow*)ih->handle, ih->handle, &geometry, (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE)); } ih->data->ignore_resize = 0; }
static void motDialogConfigureNotify(Widget w, XEvent *evt, String* s, Cardinal *card) { IFnii cb; int border, caption, menu; XConfigureEvent *cevent = (XConfigureEvent *)evt; Ihandle* ih; (void)s; (void)card; XtVaGetValues(w, XmNuserData, &ih, NULL); if (!ih) return; if (ih->data->menu && ih->data->menu->handle) { XtVaSetValues(ih->data->menu->handle, XmNwidth, (XtArgVal)(cevent->width), NULL); } if (ih->data->ignore_resize) return; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); ih->currentwidth = cevent->width + 2*border; ih->currentheight = cevent->height + 2*border + caption; /* menu is inside the dialog_manager */ cb = (IFnii)IupGetCallback(ih, "RESIZE_CB"); if (cb) cb(ih, cevent->width, cevent->height - menu); /* notify to the application size the client area size */ ih->data->ignore_resize = 1; IupRefresh(ih); ih->data->ignore_resize = 0; }
void iupDialogGetDecorSize(Ihandle* ih, int *decorwidth, int *decorheight) { int border, caption, menu; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); *decorwidth = 2*border; *decorheight = 2*border + caption + menu; }
int iupdrvDialogSetPlacement(Ihandle* ih) { char* placement; ih->data->cmd_show = SW_SHOWNORMAL; ih->data->show_state = IUP_SHOW; if (iupAttribGetBoolean(ih, "FULLSCREEN")) return 1; placement = iupAttribGet(ih, "PLACEMENT"); if (!placement) { if (IsIconic(ih->handle) || IsZoomed(ih->handle)) ih->data->show_state = IUP_RESTORE; return 0; } if (iupStrEqualNoCase(placement, "MAXIMIZED")) { ih->data->cmd_show = SW_SHOWMAXIMIZED; ih->data->show_state = IUP_MAXIMIZE; } else if (iupStrEqualNoCase(placement, "MINIMIZED")) { ih->data->cmd_show = SW_SHOWMINIMIZED; ih->data->show_state = IUP_MINIMIZE; } else if (iupStrEqualNoCase(placement, "FULL")) { int width, height, x, y; int caption, border, menu; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); /* the dialog will cover the task bar */ iupdrvGetFullSize(&width, &height); /* position the decoration and menu outside the screen */ x = -(border); y = -(border+caption+menu); width += 2*border; height += 2*border + caption + menu; /* set the new size and position */ /* WM_SIZE will update the layout */ SetWindowPos(ih->handle, HWND_TOP, x, y, width, height, 0); if (IsIconic(ih->handle) || IsZoomed(ih->handle)) ih->data->show_state = IUP_RESTORE; } iupAttribSetStr(ih, "PLACEMENT", NULL); /* reset to NORMAL */ return 1; }
int iupDialogSetClientSizeAttrib(Ihandle* ih, const char* value) { int width = 0, height = 0; int border = 0, caption = 0, menu = 0; iupStrToIntInt(value, &width, &height, 'x'); iupdrvDialogGetDecoration(ih, &border, &caption, &menu); if (width) width = width + 2*border; if (height) height = height + 2*border + caption + menu; IupSetfAttribute(ih, "RASTERSIZE", "%dx%d", width, height); return 0; }
void iupdrvDialogGetSize(Ihandle* ih, InativeHandle* handle, int *w, int *h) { int width, height; int border = 0, caption = 0, menu; if (!handle) handle = ih->handle; gtk_window_get_size((GtkWindow*)handle, &width, &height); /* client size */ if (ih) iupdrvDialogGetDecoration(ih, &border, &caption, &menu); if (w) *w = width + 2*border; if (h) *h = height + 2*border + caption; /* menu is inside the dialog_manager */ }
static gboolean gtkDialogConfigureEvent(GtkWidget *widget, GdkEventConfigure *evt, Ihandle *ih) { int old_width, old_height; (void)widget; #ifndef HILDON /* In hildon the menu is not a menubar */ if (ih->data->menu && ih->data->menu->handle) gtk_widget_set_size_request(ih->data->menu->handle, evt->width, -1); #endif if (ih->data->ignore_resize) return FALSE; old_width = iupAttribGetInt(ih, "_IUPGTK_OLD_WIDTH"); old_height = iupAttribGetInt(ih, "_IUPGTK_OLD_HEIGHT"); /* Check the size change, because configure is called also for position changes */ if (evt->width != old_width || evt->height != old_height) { IFnii cb; int border, caption, menu; iupAttribSetInt(ih, "_IUPGTK_OLD_WIDTH", evt->width); iupAttribSetInt(ih, "_IUPGTK_OLD_HEIGHT", evt->height); iupdrvDialogGetDecoration(ih, &border, &caption, &menu); #ifdef HILDON /* In Hildon, the configure event contains the window size, not the client area size */ ih->currentwidth = evt->width; ih->currentheight = evt->height; #else ih->currentwidth = evt->width + 2*border; ih->currentheight = evt->height + 2*border + caption; /* menu is inside the window client area */ #endif cb = (IFnii)IupGetCallback(ih, "RESIZE_CB"); if (cb) cb(ih, evt->width, evt->height - menu); /* notify to the application size the client area size */ ih->data->ignore_resize = 1; IupRefresh(ih); ih->data->ignore_resize = 0; } return FALSE; }
static void motDialogLayoutUpdateMethod(Ihandle *ih) { int border, caption, menu; if (ih->data->ignore_resize || iupAttribGet(ih, "_IUPMOT_FS_STYLE")) return; /* for dialogs the position is not updated here */ ih->data->ignore_resize = 1; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); if (!iupAttribGetInt(ih, "RESIZE")) { int width = ih->currentwidth - 2*border; int height = ih->currentheight - 2*border - caption; XtVaSetValues(ih->handle, XmNwidth, width, XmNheight, height, XmNminWidth, width, XmNminHeight, height, XmNmaxWidth, width, XmNmaxHeight, height, NULL); } else { XtVaSetValues(ih->handle, XmNwidth, (XtArgVal)(ih->currentwidth - 2*border), /* excluding the border */ XmNheight, (XtArgVal)(ih->currentheight - 2*border - caption), NULL); } ih->data->ignore_resize = 0; }
static gboolean gtkDialogConfigureEvent(GtkWidget *widget, GdkEventConfigure *evt, Ihandle *ih) { int old_width, old_height, old_x, old_y; gint x, y; (void)widget; #ifndef HILDON /* In hildon the menu is not a menubar */ if (ih->data->menu && ih->data->menu->handle) gtk_widget_set_size_request(ih->data->menu->handle, evt->width, -1); #endif if (ih->data->ignore_resize) return FALSE; old_width = iupAttribGetInt(ih, "_IUPGTK_OLD_WIDTH"); old_height = iupAttribGetInt(ih, "_IUPGTK_OLD_HEIGHT"); /* Check the size change, because configure is called also for position changes */ if (evt->width != old_width || evt->height != old_height) { IFnii cb; int border, caption, menu; iupAttribSetInt(ih, "_IUPGTK_OLD_WIDTH", evt->width); iupAttribSetInt(ih, "_IUPGTK_OLD_HEIGHT", evt->height); iupdrvDialogGetDecoration(ih, &border, &caption, &menu); /* update dialog size */ #ifdef HILDON /* In Hildon, the configure event contains the window size, not the client area size */ ih->currentwidth = evt->width; ih->currentheight = evt->height; #else ih->currentwidth = evt->width + 2*border; ih->currentheight = evt->height + 2*border + caption; /* menu is inside the window client area */ #endif cb = (IFnii)IupGetCallback(ih, "RESIZE_CB"); if (!cb || cb(ih, evt->width, evt->height - menu)!=IUP_IGNORE) /* width and height here are for the client area */ { ih->data->ignore_resize = 1; IupRefresh(ih); ih->data->ignore_resize = 0; } } old_x = iupAttribGetInt(ih, "_IUPGTK_OLD_X"); old_y = iupAttribGetInt(ih, "_IUPGTK_OLD_Y"); iupdrvDialogGetPosition(ih, NULL, &x, &y); /* ignore evt->x and evt->y because they are the clientpos and not X/Y */ /* Check the position change, because configure is called also for size changes */ if (x != old_x || y != old_y) { IFnii cb; iupAttribSetInt(ih, "_IUPGTK_OLD_X", x); iupAttribSetInt(ih, "_IUPGTK_OLD_Y", y); cb = (IFnii)IupGetCallback(ih, "MOVE_CB"); if (cb) cb(ih, x, y); } return FALSE; }
int iupdrvDialogSetPlacement(Ihandle* ih) { char* placement; int old_state = ih->data->show_state; ih->data->show_state = IUP_SHOW; if (iupAttribGetBoolean(ih, "FULLSCREEN")) { gtk_window_fullscreen((GtkWindow*)ih->handle); return 1; } placement = iupAttribGet(ih, "PLACEMENT"); if (!placement) { if (old_state == IUP_MAXIMIZE || old_state == IUP_MINIMIZE) ih->data->show_state = IUP_RESTORE; gtk_window_unmaximize((GtkWindow*)ih->handle); gtk_window_deiconify((GtkWindow*)ih->handle); return 0; } if (iupStrEqualNoCase(placement, "MINIMIZED")) { ih->data->show_state = IUP_MINIMIZE; gtk_window_iconify((GtkWindow*)ih->handle); } else if (iupStrEqualNoCase(placement, "MAXIMIZED")) { ih->data->show_state = IUP_MAXIMIZE; gtk_window_maximize((GtkWindow*)ih->handle); } else if (iupStrEqualNoCase(placement, "FULL")) { int width, height, x, y; int border, caption, menu; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); /* position the decoration outside the screen */ x = -(border); y = -(border+caption+menu); /* the dialog client area will cover the task bar */ iupdrvGetFullSize(&width, &height); height += menu; /* menu is inside the client area. */ /* set the new size and position */ /* The resize evt will update the layout */ gtk_window_move((GtkWindow*)ih->handle, x, y); gtk_window_resize((GtkWindow*)ih->handle, width, height); if (old_state == IUP_MAXIMIZE || old_state == IUP_MINIMIZE) ih->data->show_state = IUP_RESTORE; } iupAttribSetStr(ih, "PLACEMENT", NULL); /* reset to NORMAL */ return 1; }
static int motDialogSetFullScreenAttrib(Ihandle* ih, const char* value) { if (iupStrBoolean(value)) { if (!iupAttribGet(ih, "_IUPMOT_FS_STYLE")) { int visible = iupdrvDialogIsVisible(ih); if (visible) iupAttribSetStr(ih, "_IUPMOT_FS_STYLE", "VISIBLE"); else iupAttribSetStr(ih, "_IUPMOT_FS_STYLE", "HIDDEN"); /* save the previous decoration attributes */ /* during fullscreen these attributes can be consulted by the application */ iupAttribStoreStr(ih, "_IUPMOT_FS_MAXBOX", iupAttribGet(ih, "MAXBOX")); iupAttribStoreStr(ih, "_IUPMOT_FS_MINBOX", iupAttribGet(ih, "MINBOX")); iupAttribStoreStr(ih, "_IUPMOT_FS_MENUBOX",iupAttribGet(ih, "MENUBOX")); iupAttribStoreStr(ih, "_IUPMOT_FS_RESIZE", iupAttribGet(ih, "RESIZE")); iupAttribStoreStr(ih, "_IUPMOT_FS_BORDER", iupAttribGet(ih, "BORDER")); iupAttribStoreStr(ih, "_IUPMOT_FS_TITLE", IupGetAttribute(ih, "TITLE")); /* must use IupGetAttribute to check from the native implementation */ /* remove the decorations attributes */ iupAttribSetStr(ih, "MAXBOX", "NO"); iupAttribSetStr(ih, "MINBOX", "NO"); iupAttribSetStr(ih, "MENUBOX", "NO"); IupSetAttribute(ih, "TITLE", NULL); iupAttribSetStr(ih, "TITLE", NULL); /* remove from the hash table if we are during IupMap */ iupAttribSetStr(ih, "RESIZE", "NO"); iupAttribSetStr(ih, "BORDER", "NO"); /* use WM fullscreen support */ if (!motDialogSetFullScreen(ih, 1)) { /* or configure fullscreen manually */ int decor; int width, height; /* hide before changing decorations */ if (visible) { iupAttribSetStr(ih, "_IUPMOT_SHOW_STATE", NULL); /* To avoid a SHOW_CB notification */ XtUnmapWidget(ih->handle); } /* save the previous position and size */ iupAttribStoreStr(ih, "_IUPMOT_FS_X", IupGetAttribute(ih, "X")); /* must use IupGetAttribute to check from the native implementation */ iupAttribStoreStr(ih, "_IUPMOT_FS_Y", IupGetAttribute(ih, "Y")); iupAttribStoreStr(ih, "_IUPMOT_FS_SIZE", IupGetAttribute(ih, "RASTERSIZE")); /* save the previous decoration */ XtVaGetValues(ih->handle, XmNmwmDecorations, &decor, NULL); iupAttribSetStr(ih, "_IUPMOT_FS_DECOR", (char*)decor); /* remove the decorations */ XtVaSetValues(ih->handle, XmNmwmDecorations, (XtArgVal)0, NULL); motDialogSetWindowManagerStyle(ih); /* get full screen size */ iupdrvGetFullSize(&width, &height); /* set position and size */ XtVaSetValues(ih->handle, XmNwidth, (XtArgVal)width, XmNheight, (XtArgVal)height, XmNx, (XtArgVal)0, XmNy, (XtArgVal)0, NULL); /* layout will be updated in motDialogConfigureNotify */ if (visible) XtMapWidget(ih->handle); } } } else { char* fs_style = iupAttribGet(ih, "_IUPMOT_FS_STYLE"); if (fs_style) { /* can only switch back from full screen if window was visible */ /* when fullscreen was set */ if (iupStrEqualNoCase(fs_style, "VISIBLE")) { iupAttribSetStr(ih, "_IUPMOT_FS_STYLE", NULL); /* restore the decorations attributes */ iupAttribStoreStr(ih, "MAXBOX", iupAttribGet(ih, "_IUPMOT_FS_MAXBOX")); iupAttribStoreStr(ih, "MINBOX", iupAttribGet(ih, "_IUPMOT_FS_MINBOX")); iupAttribStoreStr(ih, "MENUBOX",iupAttribGet(ih, "_IUPMOT_FS_MENUBOX")); IupSetAttribute(ih, "TITLE", iupAttribGet(ih, "_IUPMOT_FS_TITLE")); /* TITLE is not stored in the HashTable */ iupAttribStoreStr(ih, "RESIZE", iupAttribGet(ih, "_IUPMOT_FS_RESIZE")); iupAttribStoreStr(ih, "BORDER", iupAttribGet(ih, "_IUPMOT_FS_BORDER")); if (!motDialogSetFullScreen(ih, 0)) { int border, caption, menu, x, y; int visible = iupdrvDialogIsVisible(ih); if (visible) XtUnmapWidget(ih->handle); /* restore the decorations */ XtVaSetValues(ih->handle, XmNmwmDecorations, (XtArgVal)(int)iupAttribGet(ih, "_IUPMOT_FS_DECOR"), NULL); motDialogSetWindowManagerStyle(ih); /* the dialog decoration will not be considered yet in the next XtVaSetValues */ /* so compensate the decoration when restoring the position and size */ iupdrvDialogGetDecoration(ih, &border, &caption, &menu); x = iupAttribGetInt(ih, "_IUPMOT_FS_X") - (border); y = iupAttribGetInt(ih, "_IUPMOT_FS_Y") - (border+caption+menu); /* restore position and size */ XtVaSetValues(ih->handle, XmNx, (XtArgVal)x, XmNy, (XtArgVal)y, XmNwidth, (XtArgVal)(IupGetInt(ih, "_IUPMOT_FS_SIZE") - (2*border)), XmNheight, (XtArgVal)(IupGetInt2(ih, "_IUPMOT_FS_SIZE") - (2*border+caption)), NULL); /* layout will be updated in motDialogConfigureNotify */ if (visible) XtMapWidget(ih->handle); /* remove auxiliar attributes */ iupAttribSetStr(ih, "_IUPMOT_FS_X", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_Y", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_SIZE", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_DECOR", NULL); } /* remove auxiliar attributes */ iupAttribSetStr(ih, "_IUPMOT_FS_MAXBOX", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_MINBOX", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_MENUBOX",NULL); iupAttribSetStr(ih, "_IUPMOT_FS_RESIZE", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_BORDER", NULL); iupAttribSetStr(ih, "_IUPMOT_FS_TITLE", NULL); } } } return 1; }
int iupdrvDialogSetPlacement(Ihandle* ih, int x, int y) { char* placement; if (iupAttribGetInt(ih, "FULLSCREEN")) return 1; placement = iupAttribGet(ih, "PLACEMENT"); if (!placement) return 0; if (iupStrEqualNoCase(placement, "MINIMIZED")) { if (iupdrvDialogIsVisible(ih)) XIconifyWindow(iupmot_display, XtWindow(ih->handle), iupmot_screen); else { /* TODO: This is not working, so force a minimize after visible. */ /*XWMHints wm_hints; */ /*wm_hints.flags = StateHint; */ /*wm_hints.initial_state = IconicState; */ /*XSetWMHints(iupmot_display, XtWindow(ih->handle), &wm_hints); */ XtMapWidget(ih->handle); XIconifyWindow(iupmot_display, XtWindow(ih->handle), iupmot_screen); } } else if (iupStrEqualNoCase(placement, "MAXIMIZED")) { static Atom maxatoms[2] = {0, 0}; if (!(maxatoms[0])) { maxatoms[0] = XmInternAtom(iupmot_display, "_NET_WM_STATE_MAXIMIZED_VERT", False); maxatoms[1] = XmInternAtom(iupmot_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); } motDialogChangeWMState(ih, maxatoms[0], maxatoms[1], 1); } else if (iupStrEqualNoCase(placement, "FULL")) { int width, height; int border, caption, menu; iupdrvDialogGetDecoration(ih, &border, &caption, &menu); /* position the decoration outside the screen */ x = -(border); y = -(border+caption+menu); /* the dialog client area will cover the task bar */ iupdrvGetFullSize(&width, &height); height += menu; /* the menu is included in the client area size in Motif. */ /* set the new size and position */ /* The resize event will update the layout */ XtVaSetValues(ih->handle, XmNx, (XtArgVal)x, /* outside border */ XmNy, (XtArgVal)y, XmNwidth, (XtArgVal)width, /* client size */ XmNheight, (XtArgVal)height, NULL); } iupAttribSetStr(ih, "PLACEMENT", NULL); /* reset to NORMAL */ return 1; }