public ButtonBarButton(IButtonBarButton button) { this.button = button; if (!button.Image.IsNull) { try { SetImageFromResource(button.Image + ".png"); } catch { Image = button.Image.GetImageSource(Xwt.IconSize.Medium); } } VerticalContentAlignment = VerticalAlignment.Center; ToolTip = button.Tooltip; IsEnabled = button.Enabled; Visibility = button.Visible ? Visibility.Visible : Visibility.Collapsed; Margin = new Thickness(3, 0, 3, 0); button.EnabledChanged += OnButtonEnabledChanged; button.VisibleChanged += OnButtonVisibleChanged; button.TooltipChanged += OnButtonTooltipChanged; button.ImageChanged += OnButtonImageChanged; Click += OnButtonClicked; }
protected override bool OnButtonReleaseEvent(EventButton evnt) { if (State == StateType.Selected && pushedButton != null) { pushedButton.NotifyPushed(); } State = StateType.Prelight; leaveState = StateType.Normal; pushedButton = null; return(true); }
protected override bool OnButtonPressEvent(EventButton evnt) { if (evnt.Button == 1) { pushedButton = VisibleButtons.FirstOrDefault(b => allocations [b].Contains(Allocation.X + (int)evnt.X, Allocation.Y + (int)evnt.Y)); if (pushedButton != null && pushedButton.Enabled) { State = StateType.Selected; } } return(true); }
void UpdateButton(IButtonBarButton button, int idx) { LoadIcon(button); if (button.Enabled != IsEnabled(idx)) { SetEnabled(button.Enabled, idx); } if (button.Tooltip != Cell.GetToolTip(idx)) { Cell.SetToolTip(button.Tooltip, idx); } SetNeedsDisplay(); }
void LoadIcon(IButtonBarButton button) { if (!indexMap.ContainsKey(button)) { return; } NSImage img; if (button.Enabled) { img = ImageService.GetIcon(button.Image, Gtk.IconSize.Menu).ToNSImage(); } else { img = ImageService.GetIcon(button.Image, Gtk.IconSize.Menu).WithStyles("disabled").ToNSImage(); } SetImage(img, indexMap [button]); }
public ButtonBarButton(IButtonBarButton button) : base(button.Image.IsNull ? null : button.Image.GetStockIcon().WithSize(Xwt.IconSize.Medium)) { this.button = button; VerticalContentAlignment = VerticalAlignment.Center; ToolTip = button.Tooltip; IsEnabled = button.Enabled; Visibility = button.Visible ? Visibility.Visible : Visibility.Collapsed; Margin = new Thickness(3, 0, 3, 0); button.EnabledChanged += OnButtonEnabledChanged; button.VisibleChanged += OnButtonVisibleChanged; button.TooltipChanged += OnButtonTooltipChanged; button.ImageChanged += OnButtonImageChanged; Click += OnButtonClicked; }
void UpdateButton(IButtonBarButton button, int idx) { var img = ImageService.GetIcon(button.Image, Gtk.IconSize.Menu); if (img.ToNSImage() != GetImage(idx)) { SetImage(ImageService.GetIcon(button.Image, Gtk.IconSize.Menu).ToNSImage(), idx); SetNeedsDisplay(); } if (button.Enabled != IsEnabled(idx)) { SetEnabled(button.Enabled, idx); SetNeedsDisplay(); } if (button.Tooltip != Cell.GetToolTip(idx)) { Cell.SetToolTip(button.Tooltip, idx); } }
void UpdateButton(IButtonBarButton button, int idx) { LoadIcon(button); if (button.Enabled != IsEnabled(idx)) { SetEnabled(button.Enabled, idx); } if (button.Tooltip != Cell.GetToolTip(idx)) { // SetToolTip is missing NullAllowed // https://github.com/xamarin/xamarin-macios/issues/6044 Cell.SetToolTip(button.Tooltip ?? string.Empty, idx); } if (button.Title != GetLabel(idx)) { SetLabel(button.Title, idx); } SetNeedsDisplay(); }
void LoadIcon(IButtonBarButton button) { if (!indexMap.ContainsKey(button)) { return; } NSImage img; if (button.Enabled) { img = ImageService.GetIcon(button.Image, Gtk.IconSize.Menu).ToNSImage(); } else { img = ImageService.GetIcon(button.Image, Gtk.IconSize.Menu).WithStyles("disabled").ToNSImage(); } SetImage(img, indexMap [button]); // We need to set the width because if there is an image and a title set, then Cocoa uses the // title to set the width, even if the title isn't shown. We need to set the title for accessibility. SetWidth(ButtonBarContainer.SegmentWidth - 1, indexMap [button]); }
protected override bool OnExposeEvent(EventExpose evnt) { ScaleImages(Allocation.Height); using (var context = Gdk.CairoHelper.Create(evnt.Window)) { double x = Allocation.X, y = Allocation.Y; for (int i = 0; i < VisibleButtons.Length; i++) { bool nextIsSeparator = (i < VisibleButtons.Length - 1 && VisibleButtons[i + 1].IsSeparator) || i == VisibleButtons.Length - 1; bool lastWasSeparator = (i > 0 && VisibleButtons[i - 1].IsSeparator) || i == 0; IButtonBarButton button = VisibleButtons [i]; if (button.IsSeparator) { if (!lastWasSeparator) { x += SeparatorSpacing; } continue; } Xwt.Drawing.Image[] images = State == StateType.Selected && pushedButton == button ? btnPressed : btnNormal; Xwt.Drawing.Image img = images [lastWasSeparator ? 0 : nextIsSeparator ? 2 : 1]; context.DrawImage(this, img, x, y); allocations [button] = new Gdk.Rectangle((int)x, (int)y, (int)img.Width, (int)img.Height); var icon = ImageService.GetIcon(button.Image, IconSize.Menu); if (!Sensitive || !button.Enabled) { icon = icon.WithAlpha(0.4); } context.DrawImage(this, icon, Math.Truncate(x + (img.Width - icon.Width) / 2), Math.Truncate(y + (img.Height - icon.Height) / 2)); x += img.Width; } } return(base.OnExposeEvent(evnt)); }
public ButtonBarButton (IButtonBarButton button) : base (button.Image.IsNull ? null : button.Image.GetStockIcon().WithSize(Xwt.IconSize.Medium)) { this.button = button; VerticalContentAlignment = VerticalAlignment.Center; ToolTip = button.Tooltip; IsEnabled = button.Enabled; Visibility = button.Visible ? Visibility.Visible : Visibility.Collapsed; Margin = new Thickness(3, 0, 3, 0); button.EnabledChanged += OnButtonEnabledChanged; button.VisibleChanged += OnButtonVisibleChanged; button.TooltipChanged += OnButtonTooltipChanged; button.ImageChanged += OnButtonImageChanged; Click += OnButtonClicked; }
public ButtonBarButton (IButtonBarButton button) { this.button = button; if (!button.Image.IsNull) { try { SetImageFromResource (button.Image + ".png"); } catch { Image = button.Image.GetImageSource (Xwt.IconSize.Medium); } } VerticalContentAlignment = VerticalAlignment.Center; ToolTip = button.Tooltip; IsEnabled = button.Enabled; Visibility = button.Visible ? Visibility.Visible : Visibility.Collapsed; Margin = new Thickness(3, 0, 3, 0); button.EnabledChanged += OnButtonEnabledChanged; button.VisibleChanged += OnButtonVisibleChanged; button.TooltipChanged += OnButtonTooltipChanged; button.ImageChanged += OnButtonImageChanged; Click += OnButtonClicked; }
void LoadIcon (IButtonBarButton button) { if (!indexMap.ContainsKey (button)) return; NSImage img; if (button.Enabled) img = ImageService.GetIcon (button.Image, Gtk.IconSize.Menu).ToNSImage (); else img = ImageService.GetIcon (button.Image, Gtk.IconSize.Menu).WithStyles ("disabled").ToNSImage (); SetImage (img, indexMap [button]); }
void UpdateButton (IButtonBarButton button, int idx) { LoadIcon (button); if (button.Enabled != IsEnabled (idx)) SetEnabled (button.Enabled, idx); if (button.Tooltip != Cell.GetToolTip (idx)) Cell.SetToolTip (button.Tooltip, idx); SetNeedsDisplay (); }
protected override bool OnButtonReleaseEvent (EventButton evnt) { if (State == StateType.Selected && pushedButton != null) { pushedButton.NotifyPushed (); } State = StateType.Prelight; leaveState = StateType.Normal; pushedButton = null; return true; }
protected override bool OnButtonPressEvent (EventButton evnt) { if (evnt.Button == 1) { pushedButton = VisibleButtons.FirstOrDefault (b => allocations [b].Contains (Allocation.X + (int)evnt.X, Allocation.Y + (int)evnt.Y)); if (pushedButton != null && pushedButton.Enabled) State = StateType.Selected; } return true; }
void UpdateButton (IButtonBarButton button, int idx) { var img = ImageService.GetIcon (button.Image, Gtk.IconSize.Menu); if (img.ToNSImage () != GetImage (idx)) { SetImage (ImageService.GetIcon (button.Image, Gtk.IconSize.Menu).ToNSImage (), idx); SetNeedsDisplay (); } if (button.Enabled != IsEnabled (idx)) { SetEnabled (button.Enabled, idx); SetNeedsDisplay (); } if (button.Tooltip != Cell.GetToolTip (idx)) Cell.SetToolTip (button.Tooltip, idx); }