public static void PopModal(this Window dialog) { if (windows.Count == 0) { return; } // Prevent double pop if (!ReferenceEquals(windows.Peek(), dialog)) { return; } windows.Pop(); dialog.FocusInEvent -= dialog_FocusInEvent; if (windows.Count == 0) { return; } Window parentWindow = windows.Peek(); // Don't present intentially hidden windows (like the main form) if (!parentWindow.Visible) { return; } parentWindow.Sensitive = true; parentWindow.Present(); parentWindow.GrabFocus(); }
void PositionListWindow() { if (window == null) { return; } int ox, oy; ParentWindow.GetOrigin(out ox, out oy); int dx = ox + this.Allocation.X; int dy = oy + this.Allocation.Bottom; window.WidthRequest = Allocation.Width; int width, height; window.GetSizeRequest(out width, out height); Xwt.Rectangle geometry = DesktopService.GetUsableMonitorGeometry(Screen.Number, Screen.GetMonitorAtPoint(dx, dy)); if (dy + height > geometry.Bottom) { dy = oy + this.Allocation.Y - height; } if (dx + width > geometry.Right) { dx = (int)geometry.Right - width; } window.Move(dx, dy); window.GetSizeRequest(out width, out height); window.GrabFocus(); window.FocusOutEvent += delegate { DestroyWindow(); }; window.ShowAll(); }
public static void GrabWindow(Gtk.Window window) { window.GrabFocus(); Grab.Add(window); Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(window.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = Gdk.Keyboard.Grab(window.GdkWindow, true, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(window); window.Destroy(); } } else { Grab.Remove(window); window.Destroy(); } }
private void ShowPopup() { win = new Gtk.Window(Gtk.WindowType.Popup); win.Screen = this.Screen; win.WidthRequest = this.Allocation.Width; cal = new Gtk.Calendar(); win.Add(cal); if (validDate) { cal.Date = date; } // events win.ButtonPressEvent += OnWinButtonPressEvent; cal.DaySelectedDoubleClick += OnCalDaySelectedDoubleClick; cal.KeyPressEvent += OnCalKeyPressEvent; cal.ButtonPressEvent += OnCalButtonPressEvent; int x, y; GetWidgetPos(this, out x, out y); win.Move(x, y + Allocation.Height + 2); win.ShowAll(); win.GrabFocus(); Grab.Add(win); Gdk.GrabStatus grabStatus; grabStatus = Gdk.Pointer.Grab(win.GdkWindow, true, EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask, null, null, Gtk.Global.CurrentEventTime); if (grabStatus == Gdk.GrabStatus.Success) { grabStatus = Gdk.Keyboard.Grab(win.GdkWindow, true, Gtk.Global.CurrentEventTime); if (grabStatus != Gdk.GrabStatus.Success) { Grab.Remove(win); win.Destroy(); win = null; } } else { Grab.Remove(win); win.Destroy(); win = null; } }
private static void dialog_FocusInEvent(object o, FocusInEventArgs args) { if (windows.Count == 0) { return; } Window top = windows.Peek(); if (ReferenceEquals(top, o)) { return; } top.Present(); top.GrabFocus(); }
public void ShowCalendar() { popup = new Window(WindowType.Popup); popup.Screen = parent.Screen; Frame frame = new Frame(); frame.Shadow = ShadowType.Out; frame.Show(); popup.Add(frame); VBox box = new VBox(false, 0); box.Show(); frame.Add(box); cal = new Calendar(); cal.DisplayOptions = CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers; cal.KeyPressEvent += OnCalendarKeyPressed; popup.ButtonPressEvent += OnButtonPressed; cal.Show(); Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); calAlignment.Show(); calAlignment.SetPadding(4, 4, 4, 4); calAlignment.Add(cal); box.PackStart(calAlignment, false, false, 0); //Requisition req = SizeRequest(); parent.GdkWindow.GetOrigin(out xPos, out yPos); // popup.Move(x + Allocation.X, y + Allocation.Y + req.Height + 3); popup.Move(xPos, yPos); popup.Show(); popup.GrabFocus(); Grab.Add(popup); Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = Gdk.Keyboard.Grab(popup.GdkWindow, true, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(popup); popup.Destroy(); popup = null; } } else { Grab.Remove(popup); popup.Destroy(); popup = null; } cal.DaySelected += OnCalendarDaySelected; cal.MonthChanged += OnCalendarMonthChanged; cal.Date = date; }
private void ShowCalendar() { popup = new Window(WindowType.Popup); popup.Screen = tree.Screen; Frame frame = new Frame(); frame.Shadow = ShadowType.Out; frame.Show(); popup.Add(frame); VBox box = new VBox(false, 0); box.Show(); frame.Add(box); cal = new Calendar(); cal.DisplayOptions = CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers; cal.KeyPressEvent += OnCalendarKeyPressed; popup.ButtonPressEvent += OnButtonPressed; cal.Show(); Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); calAlignment.Show(); calAlignment.SetPadding(4, 4, 4, 4); calAlignment.Add(cal); box.PackStart(calAlignment, false, false, 0); // FIXME: Make the popup appear directly below the date Gdk.Rectangle allocation = tree.Allocation; // Gtk.Requisition req = tree.SizeRequest (); int x = 0, y = 0; tree.GdkWindow.GetOrigin(out x, out y); // popup.Move(x + allocation.X, y + allocation.Y + req.Height + 3); popup.Move(x + allocation.X, y + allocation.Y); popup.Show(); popup.GrabFocus(); Grab.Add(popup); Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = Gdk.Keyboard.Grab(popup.GdkWindow, true, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(popup); popup.Destroy(); popup = null; } } else { Grab.Remove(popup); popup.Destroy(); popup = null; } cal.DaySelectedDoubleClick += OnCalendarDaySelected; cal.ButtonPressEvent += OnCalendarButtonPressed; cal.Date = date == DateTime.MinValue ? DateTime.Now : date; }
private void ShowPopup() { win = new Gtk.Window(Gtk.WindowType.Popup); win.Screen = this.Screen; win.WidthRequest = this.Allocation.Width; cal = new Gtk.Calendar(); win.Add(cal); if (validDate) cal.Date = date; // events win.ButtonPressEvent += OnWinButtonPressEvent; cal.DaySelectedDoubleClick += OnCalDaySelectedDoubleClick; cal.KeyPressEvent += OnCalKeyPressEvent; cal.ButtonPressEvent += OnCalButtonPressEvent; int x, y; GetWidgetPos(this, out x, out y); win.Move(x, y + Allocation.Height + 2); win.ShowAll(); win.GrabFocus(); Grab.Add(win); Gdk.GrabStatus grabStatus; grabStatus = Gdk.Pointer.Grab(win.GdkWindow, true, EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask, null, null, Gtk.Global.CurrentEventTime); if (grabStatus == Gdk.GrabStatus.Success) { grabStatus = Gdk.Keyboard.Grab(win.GdkWindow, true, Gtk.Global.CurrentEventTime); if (grabStatus != Gdk.GrabStatus.Success) { Grab.Remove(win); win.Destroy(); win = null; } } else { Grab.Remove(win); win.Destroy(); win = null; } }
private void ShowCalendarPopup() { cal_popup.Show(); cal_popup.GrabFocus(); }