public SectionList() { GtkWorkarounds.FixContainerLeak(this); this.WidgetFlags |= WidgetFlags.NoWindow; WidthRequest = 100; EnsureLayout(); }
public static Xwt.Size GetSize(this IconSize size) { var displayScale = Platform.IsWindows ? GtkWorkarounds.GetScaleFactor() : 1.0; int w, h; size.GetSize(out w, out h); return(new Xwt.Size((double)w / displayScale, (double)h / displayScale)); }
public SearchEntry() { AppPaintable = true; BuildWidget(); NoShowAll = true; GtkWorkarounds.SetTransparentBgHint(this, true); }
public FramelessEntry(SearchEntry parent) : base() { this.parent = parent; HasFrame = false; parent.StyleSet += OnParentStyleSet; WidthChars = 1; GtkWorkarounds.SetTransparentBgHint(this, true); }
public HPanedThin() { GtkWorkarounds.FixContainerLeak(this); #if MAC if (Core.Platform.IsMac) { handle = new CustomMacPanedHandle(this); } else #endif handle = new CustomGtkPanedHandle(this); }
public static void ShowContextMenu(Gtk.Widget parent, Gdk.EventButton evt, Gtk.Menu menu) { if (parent == null) { throw new ArgumentNullException("parent"); } if (menu == null) { throw new ArgumentNullException("menu"); } GtkWorkarounds.ShowContextMenu(menu, parent, evt); }
public static void ShowContextMenu(Gtk.Widget parent, int x, int y, Gtk.Menu menu) { if (parent == null) { throw new ArgumentNullException("parent"); } if (menu == null) { throw new ArgumentNullException("menu"); } GtkWorkarounds.ShowContextMenu(menu, parent, x, y, parent.Allocation); }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { bool retVal; bool changed; using (var context = Gdk.CairoHelper.Create(evnt.Window)) { context.Save(); if (SupportsAlpha) { context.Operator = Cairo.Operator.Source; context.SetSourceRGBA(1, 1, 1, 0); } else { context.Operator = Cairo.Operator.Over; context.SetSourceRGB(1, 1, 1); } context.Paint(); context.Restore(); OnDrawContent(evnt, context); // Draw content first so we can easily clip it retVal = base.OnExposeEvent(evnt); changed = Theme.SetBorderPath(context, BorderAllocation, position); context.Operator = Cairo.Operator.DestIn; context.SetSourceRGBA(1, 1, 1, 1); context.Fill(); context.Operator = Cairo.Operator.Over; // protect against overriden methods which leave in a bad state context.Save(); if (Theme.DrawPager) { Theme.RenderPager(context, PangoContext, new Gdk.Rectangle(Allocation.X, Allocation.Y, paintSize.Width, paintSize.Height)); } Theme.RenderBorder(context, BorderAllocation, position); context.Restore(); } if (changed) { GtkWorkarounds.UpdateNativeShadow(this); } return(retVal); }
private void BuildWidget() { var yscale = 0f; if (Platform.IsWindows) { yscale = (float)GtkWorkarounds.GetScaleFactor(this); } alignment = new Alignment(0.5f, 0.5f, 1f, yscale); alignment.SetPadding(1, 1, 3, 3); VisibleWindow = false; box = new HBox(); entry = new FramelessEntry(this); entry.UseNativeContextMenus(); filter_button = new HoverImageButton(IconSize.Menu, "md-searchbox-search"); clear_button = new HoverImageButton(IconSize.Menu, "md-searchbox-clear"); entryAlignment = new Gtk.Alignment(0.5f, 0.5f, 1f, 1f); alignment.SetPadding(0, 0, 3, 3); entryAlignment.Add(entry); box.PackStart(filter_button, false, false, 0); box.PackStart(entryAlignment, true, true, 0); box.PackStart(clear_button, false, false, 0); alignment.Add(box); Add(alignment); alignment.ShowAll(); entry.StyleSet += OnInnerEntryStyleSet; entry.StateChanged += OnInnerEntryStateChanged; entry.FocusInEvent += OnInnerEntryFocusEvent; entry.FocusOutEvent += OnInnerEntryFocusEvent; entry.Changed += OnInnerEntryChanged; entry.Activated += delegate { NotifyActivated(); }; filter_button.CanFocus = false; clear_button.CanFocus = false; filter_button.ButtonReleaseEvent += OnButtonReleaseEvent; clear_button.ButtonReleaseEvent += OnButtonReleaseEvent; clear_button.Clicked += OnClearButtonClicked; ShowHideButtons(); }
Gdk.Rectangle GetUsableMonitorGeometry(Gdk.Rectangle caret) { Screen screen = null; if (parent != null) { screen = parent.Screen; } else if (xwtParent != null) { screen = Gdk.Screen.Default; // FIXME: should we try to get the Screen from the backend? } if (screen != null) { return(GtkWorkarounds.GetUsableMonitorGeometry(screen, screen.GetMonitorAtPoint(caret.X, caret.Y))); } return(Gdk.Rectangle.Zero); }
void PositionWidget(Gtk.Widget widget) { if (!(widget is Gtk.Window)) { return; } int ox, oy; ParentWindow.GetOrigin(out ox, out oy); int w; int itemXPosition = GetHoverXPosition(out w); int dx = ox + this.Allocation.X + itemXPosition; int dy = oy + this.Allocation.Bottom; var req = widget.SizeRequest(); Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry(Screen, Screen.GetMonitorAtPoint(dx, dy)); int width = System.Math.Max(req.Width, w); if (width >= geometry.Width - spacing * 2) { width = geometry.Width - spacing * 2; dx = geometry.Left + spacing; } widget.WidthRequest = width; if (dy + req.Height > geometry.Bottom) { dy = oy + this.Allocation.Y - req.Height; } if (dx + width > geometry.Right) { dx = geometry.Right - width; } (widget as Gtk.Window).Move(dx, dy); (widget as Gtk.Window).Resize(width, req.Height); widget.GrabFocus(); }
public IdeDialog() { IdeTheme.ApplyTheme(this); GtkWorkarounds.DisableMinimizeMaximizeButtons(this); }
public virtual void RepositionWindow(Gdk.Rectangle?newCaret = null) { if (parent == null) { return; } int x, y; if (newCaret.HasValue) //Update caret if parameter is given { currentCaret = newCaret.Value; } Gdk.Rectangle caret = currentCaret; Gdk.Window window = targetWindow; if (targetWindow == null) { return; } PopupPosition position = Theme.TargetPosition; this.position = Theme.TargetPosition; UpdatePadding(); window.GetOrigin(out x, out y); var alloc = parent.Allocation; if (eventProvided) { caret.X = x; caret.Y = y; caret.Width = caret.Height = 1; } else { if (caret.Equals(Gdk.Rectangle.Zero)) { caret = new Gdk.Rectangle(0, 0, alloc.Width, alloc.Height); } caret = GtkUtil.ToScreenCoordinates(parent, parent.GdkWindow, caret); } Gtk.Requisition request = SizeRequest(); var screen = parent.Screen; Gdk.Rectangle geometry = GtkWorkarounds.GetUsableMonitorGeometry(screen, screen.GetMonitorAtPoint(caret.X, caret.Y)); // Add some spacing between the screen border and the popover window geometry.Inflate(-5, -5); // Flip the orientation if the window doesn't fit the screen. int intPos = (int)position; switch ((PopupPosition)(intPos & 0x0f)) { case PopupPosition.Top: if (caret.Bottom + request.Height > geometry.Bottom) { intPos = (intPos & 0xf0) | (int)PopupPosition.Bottom; } break; case PopupPosition.Bottom: if (caret.Top - request.Height < geometry.X) { intPos = (intPos & 0xf0) | (int)PopupPosition.Top; } break; case PopupPosition.Right: if (caret.X - request.Width < geometry.X) { intPos = (intPos & 0xf0) | (int)PopupPosition.Left; } break; case PopupPosition.Left: if (caret.Right + request.Width > geometry.Right) { intPos = (intPos & 0xf0) | (int)PopupPosition.Right; } break; } position = (PopupPosition)intPos; UpdatePadding(); // Calculate base coordinate switch ((PopupPosition)((int)position & 0x0f)) { case PopupPosition.Top: y = caret.Bottom; break; case PopupPosition.Bottom: y = caret.Y - request.Height; break; case PopupPosition.Right: x = caret.X - request.Width; break; case PopupPosition.Left: x = caret.Right; break; } int offset; if ((position & PopupPosition.Top) != 0 || (position & PopupPosition.Bottom) != 0) { if (((int)position & 0x10) != 0) { x = caret.X - MinArrowSpacing - Theme.ArrowWidth / 2; } else if (((int)position & 0x20) != 0) { x = caret.Right - request.Width + MinArrowSpacing + Theme.ArrowWidth / 2; } else { x = caret.X + (caret.Width - request.Width) / 2; } if (x < geometry.Left) { x = geometry.Left; } else if (x + request.Width > geometry.Right) { x = geometry.Right - request.Width; } offset = caret.X + caret.Width / 2 - x; if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing) { offset = MinArrowSpacing + Theme.ArrowWidth / 2; } if (offset > request.Width - MinArrowSpacing - Theme.ArrowWidth / 2) { offset = request.Width - MinArrowSpacing - Theme.ArrowWidth / 2; } } else { if (((int)position & 0x10) != 0) { y = caret.Y - MinArrowSpacing - Theme.ArrowWidth / 2; } else if (((int)position & 0x20) != 0) { y = caret.Bottom - request.Height + MinArrowSpacing + Theme.ArrowWidth / 2; } else { y = caret.Y + (caret.Height - request.Height) / 2; } if (y < geometry.Top) { y = geometry.Top; } else if (y + request.Height > geometry.Bottom) { y = geometry.Bottom - request.Height; } if (MaximumYTopBound > 0) { y = Math.Max(MaximumYTopBound, y); } offset = caret.Y + caret.Height / 2 - y; if (offset - Theme.ArrowWidth / 2 < MinArrowSpacing) { offset = MinArrowSpacing + Theme.ArrowWidth / 2; } if (offset > request.Height - MinArrowSpacing - Theme.ArrowWidth / 2) { offset = request.Height - MinArrowSpacing - Theme.ArrowWidth / 2; } } Theme.ArrowOffset = offset; this.position = position; UpdatePadding(); Move(x, y); Show(); if (!ShowWindowShadow) { DesktopService.RemoveWindowShadow(this); } }
public HPanedThin() { GtkWorkarounds.FixContainerLeak(this); handle = new CustomPanedHandle(this); handle.Parent = this; }
static Gtk.MenuItem CreateMenuItem(ContextMenuItem item) { if (!item.Visible) { return(null); } if (item.IsSeparator) { return(new Gtk.SeparatorMenuItem()); } Gtk.MenuItem menuItem; if (item is RadioButtonContextMenuItem) { var radioItem = (RadioButtonContextMenuItem)item; menuItem = new Gtk.CheckMenuItem(item.Label) { Active = radioItem.Checked, DrawAsRadio = true }; } else if (item is CheckBoxContextMenuItem) { var checkItem = (CheckBoxContextMenuItem)item; menuItem = new Gtk.CheckMenuItem(item.Label) { Active = checkItem.Checked }; } else { menuItem = new Gtk.ImageMenuItem(item.Label); } if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu(item.SubMenu, null); } else { menuItem.Activated += (sender, e) => item.Click(); } menuItem.Sensitive = item.Sensitive; var label = (Gtk.Label)menuItem.Child; label.UseUnderline = item.UseMnemonic; if (item.UseMnemonic) { label.TextWithMnemonic = item.Label; } if (item.Image != null) { Gtk.ImageMenuItem imageItem = menuItem as Gtk.ImageMenuItem; if (imageItem != null) { var img = new ImageView(item.Image); img.ShowAll(); imageItem.Image = img; GtkWorkarounds.ForceImageOnMenuItem(imageItem); } } return(menuItem); }
public VPanedThin() { GtkWorkarounds.FixContainerLeak(this); handle = new CustomGtkPanedHandle(this); }
static void UpdateXwtDefaults() { // Xwt default dialog icons Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.InformationIcon = ImageService.GetIcon("gtk-dialog-info", Gtk.IconSize.Dialog); Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.WarningIcon = ImageService.GetIcon("gtk-dialog-warning", Gtk.IconSize.Dialog); Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.ErrorIcon = ImageService.GetIcon("gtk-dialog-error", Gtk.IconSize.Dialog); Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.QuestionIcon = ImageService.GetIcon("gtk-dialog-question", Gtk.IconSize.Dialog); Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.ConfirmationIcon = ImageService.GetIcon("gtk-dialog-question", Gtk.IconSize.Dialog); if (Platform.IsMac && UserInterfaceTheme == Theme.Dark) { // dark NSAppearance can not handle custom drawn images in dialogs Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.InformationIcon = ImageService.GetIcon("gtk-dialog-info", Gtk.IconSize.Dialog).ToBitmap(GtkWorkarounds.GetScaleFactor()); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.WarningIcon = ImageService.GetIcon("gtk-dialog-warning", Gtk.IconSize.Dialog).ToBitmap(GtkWorkarounds.GetScaleFactor()); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ErrorIcon = ImageService.GetIcon("gtk-dialog-error", Gtk.IconSize.Dialog).ToBitmap(GtkWorkarounds.GetScaleFactor()); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.QuestionIcon = ImageService.GetIcon("gtk-dialog-question", Gtk.IconSize.Dialog).ToBitmap(GtkWorkarounds.GetScaleFactor()); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ConfirmationIcon = ImageService.GetIcon("gtk-dialog-question", Gtk.IconSize.Dialog).ToBitmap(GtkWorkarounds.GetScaleFactor()); } else { Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.InformationIcon = ImageService.GetIcon("gtk-dialog-info", Gtk.IconSize.Dialog); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.WarningIcon = ImageService.GetIcon("gtk-dialog-warning", Gtk.IconSize.Dialog); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ErrorIcon = ImageService.GetIcon("gtk-dialog-error", Gtk.IconSize.Dialog); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.QuestionIcon = ImageService.GetIcon("gtk-dialog-question", Gtk.IconSize.Dialog); Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ConfirmationIcon = ImageService.GetIcon("gtk-dialog-question", Gtk.IconSize.Dialog); } Xwt.Toolkit.CurrentEngine.Defaults.FallbackLinkColor = Styles.LinkForegroundColor; Xwt.Toolkit.NativeEngine.Defaults.FallbackLinkColor = Styles.LinkForegroundColor; }