char* iupdrvGetGlobal(const char *name) { if (iupStrEqual(name, "CURSORPOS")) { int x, y; char* str = iupStrGetMemory(50); iupdrvGetCursorPos(&x, &y); sprintf(str, "%dx%d", x, y); return str; } if (iupStrEqual(name, "SHIFTKEY")) { char key[5]; iupdrvGetKeyState(key); if (key[0] == 'S') return "ON"; return "OFF"; } if (iupStrEqual(name, "CONTROLKEY")) { char key[5]; iupdrvGetKeyState(key); if (key[1] == 'C') return "ON"; return "OFF"; } if (iupStrEqual(name, "MODKEYSTATE")) { char *str = iupStrGetMemory(5); iupdrvGetKeyState(str); return str; } if (iupStrEqual(name, "SCREENSIZE")) { char *str = iupStrGetMemory(50); int w, h; iupdrvGetScreenSize(&w, &h); sprintf(str, "%dx%d", w, h); return str; } if (iupStrEqual(name, "FULLSIZE")) { char *str = iupStrGetMemory(50); int w, h; iupdrvGetFullSize(&w, &h); sprintf(str, "%dx%d", w, h); return str; } if (iupStrEqual(name, "SCREENDEPTH")) { char *str = iupStrGetMemory(50); int bpp = iupdrvGetScreenDepth(); sprintf(str, "%d", bpp); return str; } return NULL; }
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 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 winDialogSetFullScreenAttrib(Ihandle* ih, const char* value) { if (iupStrBoolean(value)) { if (!iupAttribGet(ih, "_IUPWIN_FS_STYLE")) { int width, height; LONG off_style, new_style; BOOL visible = ShowWindow (ih->handle, SW_HIDE); /* remove the decorations */ off_style = WS_BORDER | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU; new_style = GetWindowLong(ih->handle, GWL_STYLE); iupAttribSetStr(ih, "_IUPWIN_FS_STYLE", (char*)new_style); new_style &= (~off_style); SetWindowLong(ih->handle, GWL_STYLE, new_style); /* save the previous decoration attributes */ iupAttribStoreStr(ih, "_IUPWIN_FS_MAXBOX", iupAttribGet(ih, "MAXBOX")); iupAttribStoreStr(ih, "_IUPWIN_FS_MINBOX", iupAttribGet(ih, "MINBOX")); iupAttribStoreStr(ih, "_IUPWIN_FS_MENUBOX",iupAttribGet(ih, "MENUBOX")); iupAttribStoreStr(ih, "_IUPWIN_FS_RESIZE", iupAttribGet(ih, "RESIZE")); iupAttribStoreStr(ih, "_IUPWIN_FS_BORDER", iupAttribGet(ih, "BORDER")); iupAttribStoreStr(ih, "_IUPWIN_FS_TITLE", IupGetAttribute(ih, "TITLE")); /* must use IupGetAttribute to check from the native implementation */ /* save the previous position and size */ iupAttribStoreStr(ih, "_IUPWIN_FS_X", IupGetAttribute(ih, "X")); /* must use IupGetAttribute to check from the native implementation */ iupAttribStoreStr(ih, "_IUPWIN_FS_Y", IupGetAttribute(ih, "Y")); iupAttribStoreStr(ih, "_IUPWIN_FS_SIZE", IupGetAttribute(ih, "RASTERSIZE")); /* remove the decorations attributes */ iupAttribSetStr(ih, "MAXBOX", "NO"); iupAttribSetStr(ih, "MINBOX", "NO"); iupAttribSetStr(ih, "MENUBOX", "NO"); IupSetAttribute(ih, "TITLE", NULL); iupAttribSetStr(ih, "RESIZE", "NO"); iupAttribSetStr(ih, "BORDER", "NO"); /* full screen size */ iupdrvGetFullSize(&width, &height); SetWindowPos(ih->handle, HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); /* layout will be updated in WM_SIZE */ if (visible) ShowWindow(ih->handle, SW_SHOW); } } else { LONG style = (LONG)iupAttribGet(ih, "_IUPWIN_FS_STYLE"); if (style) { BOOL visible = ShowWindow(ih->handle, SW_HIDE); /* restore the decorations attributes */ iupAttribStoreStr(ih, "MAXBOX", iupAttribGet(ih, "_IUPWIN_FS_MAXBOX")); iupAttribStoreStr(ih, "MINBOX", iupAttribGet(ih, "_IUPWIN_FS_MINBOX")); iupAttribStoreStr(ih, "MENUBOX",iupAttribGet(ih, "_IUPWIN_FS_MENUBOX")); IupSetAttribute(ih, "TITLE", iupAttribGet(ih, "_IUPWIN_FS_TITLE")); /* TITLE is not stored in the HashTable */ iupAttribStoreStr(ih, "RESIZE", iupAttribGet(ih, "_IUPWIN_FS_RESIZE")); iupAttribStoreStr(ih, "BORDER", iupAttribGet(ih, "_IUPWIN_FS_BORDER")); /* restore the decorations */ SetWindowLong(ih->handle, GWL_STYLE, style); /* restore position and size */ SetWindowPos(ih->handle, HWND_TOP, iupAttribGetInt(ih, "_IUPWIN_FS_X"), iupAttribGetInt(ih, "_IUPWIN_FS_Y"), IupGetInt(ih, "_IUPWIN_FS_SIZE"), IupGetInt2(ih, "_IUPWIN_FS_SIZE"), 0); /* layout will be updated in WM_SIZE */ if (visible) ShowWindow(ih->handle, SW_SHOW); /* remove auxiliar attributes */ iupAttribSetStr(ih, "_IUPWIN_FS_MAXBOX", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_MINBOX", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_MENUBOX",NULL); iupAttribSetStr(ih, "_IUPWIN_FS_TITLE", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_RESIZE", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_BORDER", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_X", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_Y", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_SIZE", NULL); iupAttribSetStr(ih, "_IUPWIN_FS_STYLE", NULL); } } 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; }
char* IupGetGlobal(const char *name) { char* value; iupASSERT(name!=NULL); if (!name) return NULL; if (iupStrEqual(name, "DEFAULTFONTSIZE")) return iupGetDefaultFontSizeGlobalAttrib(); if (iupStrEqual(name, "DEFAULTFONTSTYLE")) return iupGetDefaultFontStyleGlobalAttrib(); if (iupStrEqual(name, "DEFAULTFONTFACE")) return iupGetDefaultFontFaceGlobalAttrib(); if (iupStrEqual(name, "CURSORPOS")) { int x, y; iupdrvGetCursorPos(&x, &y); return iupStrReturnIntInt(x, y, 'x'); } if (iupStrEqual(name, "SHIFTKEY")) { char key[5]; iupdrvGetKeyState(key); return iupStrReturnChecked(key[0] == 'S'); } if (iupStrEqual(name, "CONTROLKEY")) { char key[5]; iupdrvGetKeyState(key); return iupStrReturnChecked(key[1] == 'C'); } if (iupStrEqual(name, "MODKEYSTATE")) { char *str = iupStrGetMemory(5); iupdrvGetKeyState(str); return str; } if (iupStrEqual(name, "SCREENSIZE")) { int w, h; iupdrvGetScreenSize(&w, &h); return iupStrReturnIntInt(w, h, 'x'); } if (iupStrEqual(name, "FULLSIZE")) { int w, h; iupdrvGetFullSize(&w, &h); return iupStrReturnIntInt(w, h, 'x'); } if (iupStrEqual(name, "SCREENDEPTH")) { int bpp = iupdrvGetScreenDepth(); return iupStrReturnInt(bpp); } if (iupStrEqual(name, "SCREENDPI")) { double dpi = iupdrvGetScreenDpi(); return iupStrReturnDouble(dpi); } if (iupStrEqual(name, "SYSTEMLOCALE")) return iupdrvLocaleInfo(); if (iupStrEqual(name, "SCROLLBARSIZE")) return iupStrReturnInt(iupdrvGetScrollbarSize()); value = iupdrvGetGlobal(name); if (!value) value = (char*)iupTableGet(iglobal_table, name); return value; }