/// <summary> /// Cross-platform handy method to get the size of the screen /// </summary> /// <returns>SIZE measures of the screen of primary monitor</returns> public SciterSize GetPrimaryScreenSize() { var screenWidth = PInvokeGtk.gdk_screen_width(); var screenHeight = PInvokeGtk.gdk_screen_height(); return(new SciterSize(screenWidth, screenHeight)); }
public IntPtr GetWindowHandle(IntPtr handle) { Debug.Assert(handle != IntPtr.Zero); var result = PInvokeGtk.gtk_widget_get_toplevel(handle); Debug.Assert(result != IntPtr.Zero); return(result); }
//TODO: Better implementation public static void Initialize() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { PInvokeGtk.gtk_init(IntPtr.Zero, IntPtr.Zero); } //Everything else is not supported }
public void Show(IntPtr window, bool show = true) { if (show) { PInvokeGtk.gtk_window_present(window); } else { PInvokeGtk.gtk_widget_hide(window); } }
/* #if WINDOWS || NETCORE * public bool ModifyStyle(PInvokeWindows.WindowStyles dwRemove, PInvokeWindows.WindowStyles dwAdd) * { * int GWL_EXSTYLE = -20; * * PInvokeWindows.WindowStyles dwStyle = * (PInvokeWindows.WindowStyles) PInvokeWindows.GetWindowLongPtr(Handle, GWL_EXSTYLE); * PInvokeWindows.WindowStyles dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; * * if (dwStyle == dwNewStyle) * return false; * * PInvokeWindows.SetWindowLongPtr(Handle, GWL_EXSTYLE, (IntPtr) dwNewStyle); * return true; * } * * public bool ModifyStyleEx(PInvokeWindows.WindowStyles dwRemove, PInvokeWindows.WindowStyles dwAdd) * { * int GWL_STYLE = -16; * * PInvokeWindows.WindowStyles dwStyle = * (PInvokeWindows.WindowStyles) PInvokeWindows.GetWindowLongPtr(Handle, GWL_STYLE); * PInvokeWindows.WindowStyles dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; * if (dwStyle == dwNewStyle) * return false; * * PInvokeWindows.SetWindowLongPtr(Handle, GWL_STYLE, (IntPtr) dwNewStyle); * return true; * } #endif*/ /// <summary> /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering /// </summary> public void CenterWindow(IntPtr window) { var screenWidth = PInvokeGtk.gdk_screen_width(); var screenHeight = PInvokeGtk.gdk_screen_height(); PInvokeGtk.gtk_window_get_size(window, out var windowWidth, out var windowHeight); var newX = (screenWidth - windowWidth) / 2; var newY = (screenHeight - windowHeight) / 2; PInvokeGtk.gtk_window_move(window, newX, newY); }
//TODO: Better implementation public static void RunMessageLoop(IntPtr handle) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { while (PInvokeWindows.GetMessage(out var msg, handle, 0, 0) != 0) { PInvokeWindows.TranslateMessage(ref msg); PInvokeWindows.DispatchMessage(ref msg); } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { PInvokeGtk.gtk_main(); } //Everything else is not supported }
/*public SciterWindow CreateMainWindow(int width, int height, * SciterXDef.SCITER_CREATE_WINDOW_FLAGS creationFlags = DefaultCreateFlags) * { * var frame = new PInvokeUtils.RECT(width, height); * return CreateWindow(frame, creationFlags); * } * * public SciterWindow CreateOwnedWindow(IntPtr owner, int width, int height, * SciterXDef.SCITER_CREATE_WINDOW_FLAGS creationFlags = DefaultCreateFlags) * { * var frame = new PInvokeUtils.RECT(width, height); * return CreateWindow(frame, creationFlags, owner); * }*/ /* * /// <summary> * /// Create an owned top-level Sciter window * /// </summary> * /// <param name="width"></param> * /// <param name="height"></param> * /// <param name="owner_hwnd"></param> * public void CreatePopupAlphaWindow(int width, int height, IntPtr owner_hwnd) * { * PInvokeUtils.RECT frame = new PInvokeUtils.RECT(); * frame.right = width; * frame.bottom = height; * CreateWindow(frame, SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_ALPHA | SciterXDef.SCITER_CREATE_WINDOW_FLAGS.SW_TOOL, owner_hwnd); * // Sciter BUG: window comes with WM_EX_APPWINDOW style * }*/ public void Destroy(IntPtr window) { PInvokeGtk.gtk_widget_destroy(window); }
public void SetTitle(IntPtr window, string title) => PInvokeGtk.gtk_window_set_title(window, title);
/*#if WINDOWS && !WPF * public SciterWindow SetIcon(Icon icon) * { * // instead of using this property, you can use View.windowIcon on all platforms * // larger icon * PInvokeWindows.SendMessageW(Handle, PInvokeWindows.Win32Msg.WM_SETICON, new IntPtr(1), icon.Handle); * // small icon * PInvokeWindows.SendMessageW(Handle, PInvokeWindows.Win32Msg.WM_SETICON, IntPtr.Zero, * new Icon(icon, 16, 16).Handle); * return this; * } #endif*/ #region Title public string GetTitle(IntPtr window) { var titlePtr = PInvokeGtk.gtk_window_get_title(window); return(Marshal.PtrToStringAnsi(titlePtr)); }
public bool GetIsVisible(IntPtr window) => PInvokeGtk.gtk_widget_get_visible(window) != 0;
/// <summary> /// Close the window. Posts WM_CLOSE message on Windows. /// </summary> public void Close(IntPtr window) => PInvokeGtk.gtk_window_close(window);
public void SetPosition(IntPtr window, SciterPoint point) => PInvokeGtk.gtk_window_move(window, point.X, point.Y);
public SciterSize Size(IntPtr window) { PInvokeGtk.gtk_window_get_size(window, out var windowWidth, out var windowHeight); return(new SciterSize(windowWidth, windowHeight)); }