private void BuildCustomComboBox() { _entry = new Gtk.Entry(); _entry.CanFocus = true; _entry.IsEditable = true; PackStart(_entry, true, true, 0); _button = new Gtk.Button(); _button.WidthRequest = 30; _button.CanFocus = true; _arrow = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.EtchedOut); _button.Add(_arrow); PackEnd(_button, false, false, 0); }
protected virtual void Build() { Stetic.Gui.Initialize(this); // Widget HollyLibrary.HBaseComboBox Stetic.BinContainer.Attach(this); this.Name = "HollyLibrary.HBaseComboBox"; // Container child HollyLibrary.HBaseComboBox.Gtk.Container+ContainerChild this.hbox3 = new Gtk.HBox(); this.hbox3.Name = "hbox3"; // Container child hbox3.Gtk.Box+BoxChild this.hbox4 = new Gtk.HBox(); this.hbox4.Name = "hbox4"; this.hbox4.Spacing = 2; this.hbox4.BorderWidth = ((uint)(5)); // Container child hbox4.Gtk.Box+BoxChild this.entry = new Gtk.Entry(); this.entry.CanFocus = true; this.entry.Name = "entry"; this.entry.IsEditable = true; this.entry.HasFrame = false; this.entry.InvisibleChar = '●'; this.hbox4.Add(this.entry); Gtk.Box.BoxChild w1 = ((Gtk.Box.BoxChild)(this.hbox4[this.entry])); w1.Position = 0; this.hbox3.Add(this.hbox4); Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hbox3[this.hbox4])); w2.Position = 0; // Container child hbox3.Gtk.Box+BoxChild this.popupButton = new Gtk.Button(); this.popupButton.WidthRequest = 30; this.popupButton.CanFocus = true; this.popupButton.Name = "popupButton"; // Container child popupButton.Gtk.Container+ContainerChild this.arrow1 = new Gtk.Arrow(((Gtk.ArrowType)(1)), ((Gtk.ShadowType)(2))); this.arrow1.Name = "arrow1"; this.popupButton.Add(this.arrow1); this.popupButton.Label = null; this.hbox3.Add(this.popupButton); Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hbox3[this.popupButton])); w4.Position = 1; w4.Expand = false; this.Add(this.hbox3); if ((this.Child != null)) { this.Child.ShowAll(); } this.Show(); this.entry.FocusInEvent += new Gtk.FocusInEventHandler(this.OnEntryFocusInEvent); this.entry.FocusOutEvent += new Gtk.FocusOutEventHandler(this.OnEntryFocusOutEvent); }
public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position) { Widget.UseUnderline = useMnemonic; this.image = image; if (label != null && label.Length == 0) { label = null; } Button b = (Button)Frontend; if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll(); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (image.Backend != null) { imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button)); } labelWidget = null; if (label != null && imageWidget == null) { contentWidget = labelWidget = new Gtk.Label(label); } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3); labelWidget = new Gtk.Label(label) { UseUnderline = useMnemonic }; if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart(imageWidget, false, false, 0); box.PackStart(labelWidget, false, false, 0); } else { box.PackStart(labelWidget, false, false, 0); box.PackStart(imageWidget, false, false, 0); } contentWidget = box; } var expandButtonContent = false; if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox(false, 3); box.PackStart(contentWidget, true, true, 3); box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; expandButtonContent = true; } else { contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); } } if (contentWidget != null) { contentWidget.ShowAll(); Widget.Label = null; Widget.Image = contentWidget; var alignment = Widget.Child as Gtk.Alignment; if (alignment != null) { if (expandButtonContent) { var box = alignment.Child as Gtk.Box; if (box != null) { alignment.Xscale = 1; box.SetChildPacking(box.Children [0], true, true, 0, Gtk.PackType.Start); if (labelWidget != null) { labelWidget.Xalign = 0; } } } else if (position == ContentPosition.Left && (contentWidget is Gtk.Box)) { // in case the button is wider than its natural size and has text and an image on the left, // optimize its alignment to make the text more centered. // FIXME: more sophisticated size calculation alignment.Xalign = 0.475f; } } if (labelWidget != null) { labelWidget.UseUnderline = useMnemonic; if (customFont != null) { labelWidget.ModifyFont(customFont); } if (customLabelColor.HasValue) { labelWidget.SetForegroundColor(customLabelColor.Value); labelWidget.SetForegroundColor(Gtk.StateType.Prelight, customLabelColor.Value); } } } else { Widget.Label = null; } }
public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position) { Widget.UseUnderline = useMnemonic; this.image = image; if (label != null && label.Length == 0) label = null; Button b = (Button) Frontend; if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll (); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (image.Backend != null) imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button)); labelWidget = null; if (label != null && imageWidget == null) { contentWidget = labelWidget = new Gtk.Label (label); } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3); labelWidget = new Gtk.Label (label) { UseUnderline = useMnemonic }; if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart (imageWidget, false, false, 0); box.PackStart (labelWidget, false, false, 0); } else { box.PackStart (labelWidget, false, false, 0); box.PackStart (imageWidget, false, false, 0); } contentWidget = box; } var expandButtonContent = false; if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox (false, 3); box.PackStart (contentWidget, true, true, 3); box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; expandButtonContent = true; } else contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); } if (contentWidget != null) { contentWidget.ShowAll (); Widget.Label = null; Widget.Image = contentWidget; var alignment = Widget.Child as Gtk.Alignment; if (alignment != null) { if (expandButtonContent) { var box = alignment.Child as Gtk.Box; if (box != null) { alignment.Xscale = 1; box.SetChildPacking (box.Children [0], true, true, 0, Gtk.PackType.Start); if (labelWidget != null) labelWidget.Xalign = 0; } } else if (position == ContentPosition.Left && (contentWidget is Gtk.Box)) { // in case the button is wider than its natural size and has text and an image on the left, // optimize its alignment to make the text more centered. // FIXME: more sophisticated size calculation alignment.Xalign = 0.475f; } } if (labelWidget != null) { labelWidget.UseUnderline = useMnemonic; if (customFont != null) labelWidget.ModifyFont (customFont); if (customLabelColor.HasValue) { labelWidget.SetForegroundColor (customLabelColor.Value); labelWidget.SetForegroundColor (Gtk.StateType.Prelight, customLabelColor.Value); } } } else Widget.Label = null; }
public void SetContent(string label, object imageBackend, ContentPosition position) { if (label != null && label.Length == 0) label = null; Button b = (Button) Frontend; if (label != null && imageBackend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll (); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (imageBackend != null) imageWidget = new Gtk.Image ((Gdk.Pixbuf)imageBackend); if (label != null && imageWidget == null) { contentWidget = new Gtk.Label (label); } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3); var lab = new Gtk.Label (label); if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart (imageWidget, false, false, 0); box.PackStart (lab, false, false, 0); } else { box.PackStart (lab, false, false, 0); box.PackStart (imageWidget, false, false, 0); } contentWidget = box; } if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox (false, 3); box.PackStart (contentWidget, true, true, 0); box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; } else contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); } if (contentWidget != null) { contentWidget.ShowAll (); Widget.Label = null; Widget.Image = contentWidget; } else Widget.Label = null; }
public void SetContent(string label, object imageBackend, ContentPosition position) { if (label != null && label.Length == 0) { label = null; } Button b = (Button)Frontend; if (label != null && imageBackend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll(); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (imageBackend != null) { imageWidget = new Gtk.Image((Gdk.Pixbuf)imageBackend); } if (label != null && imageWidget == null) { contentWidget = new Gtk.Label(label); } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3); var lab = new Gtk.Label(label); if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart(imageWidget, false, false, 0); box.PackStart(lab, false, false, 0); } else { box.PackStart(lab, false, false, 0); box.PackStart(imageWidget, false, false, 0); } contentWidget = box; } if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox(false, 3); box.PackStart(contentWidget, true, true, 3); box.PackStart(new Gtk.VSeparator(), true, true, 0); box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; } else { contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); } } if (contentWidget != null) { contentWidget.ShowAll(); Widget.Label = null; Widget.Image = contentWidget; } else { Widget.Label = null; } }
void CreateControls() { if (node.Type == Gtk.UIManagerItemType.Separator) { Gtk.Widget sep; if (parentMenu.IsTopMenu) { sep = new Gtk.VSeparator(); sep.WidthRequest = 6; } else { sep = new Gtk.HSeparator(); sep.HeightRequest = 6; } Add(sep); ShowAll(); return; } else { if (Child != null && Child is Gtk.Separator) { Remove(Child); } } if (node.Action == null) { return; } bool isGlobal = wrapper != null && wrapper.Project.ActionGroups.IndexOf(node.Action.ActionGroup) != -1; Gtk.Action gaction = node.Action.GtkAction; bool barItem = parentMenu.IsTopMenu; string text = gaction.Label; string stock = gaction.StockId; if (barItem) { icon = null; } else if (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio) { icon = new CheckActionIcon(true, node.Action.Active); } else if (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle) { icon = new CheckActionIcon(node.Action.DrawAsRadio, node.Action.Active); } if (stock != null) { Gtk.StockItem item = Gtk.Stock.Lookup(stock); if (text == null || text.Length == 0) { text = item.Label; } if (item.Keyval != 0 && !editing && !barItem) { Gtk.Label lac = new Gtk.Label(); string accelName = Gtk.Accelerator.Name(item.Keyval, item.Modifier).ToUpper(); accelName = accelName.Replace("<CONTROL>", "Ctrl+"); accelName = accelName.Replace("<SHIFT>", "Shift+"); accelName = accelName.Replace("<ALT>", "Alt+"); lac.Text = accelName; accel = lac; } if (icon == null && !barItem) { icon = node.Action.CreateIcon(Gtk.IconSize.Menu); } } Gtk.Tooltips tooltips = null; if (editing) { tooltips = new Gtk.Tooltips(); } if (editing && !isGlobal) { if (!barItem) { Gtk.HBox bbox = new Gtk.HBox(); if (icon != null) { bbox.PackStart(icon, false, false, 0); } bbox.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.In), false, false, 0); Gtk.Button b = new Gtk.Button(bbox); tooltips.SetTip(b, Catalog.GetString("Select action type"), ""); b.Relief = Gtk.ReliefStyle.None; b.ButtonPressEvent += OnSelectIcon; icon = b; } else { icon = null; } Gtk.Entry entry = new Gtk.Entry(); entry.Text = text; entry.Activated += OnLabelActivated; entry.KeyPressEvent += OnEntryKeyPress; entry.HasFrame = false; this.label = entry; tooltips.SetTip(entry, Catalog.GetString("Action label"), ""); } else { Gtk.Label label = new Gtk.Label(text); label.Xalign = 0; this.label = label; } if (editing && wrapper != null) { // Add a button for creating / deleting a submenu Gdk.Pixbuf img; string tip; if (node.Type != Gtk.UIManagerItemType.Menu) { img = addMenuImage; tip = Catalog.GetString("Add submenu (Ctrl+Right)"); } else { img = removeMenuImage; tip = Catalog.GetString("Remove submenu (Ctrl+Left)"); } Gtk.Button sb = new Gtk.Button(new Gtk.Image(img)); tooltips.SetTip(sb, tip, ""); sb.Relief = Gtk.ReliefStyle.None; sb.Clicked += OnCreateDeleteSubmenu; // Make sure the button is alligned to the right of the column Gtk.HBox bbox = new Gtk.HBox(); bbox.PackEnd(sb, false, false, 0); accel = bbox; } if (node.Type == Gtk.UIManagerItemType.Menu && !editing && !barItem) { Gtk.Arrow arrow = new Gtk.Arrow(Gtk.ArrowType.Right, Gtk.ShadowType.None); arrow.Xalign = 1; this.accel = arrow; } if (itemSpacing > 0 && icon != null) { // Add some padding to the left of the icon Gtk.Alignment a = new Gtk.Alignment(0, 0.5f, 0, 0); a.LeftPadding = itemSpacing; a.Add(icon); icon = a; } }
void CreateControls () { if (node.Type == Gtk.UIManagerItemType.Separator) { Gtk.Widget sep; if (parentMenu.IsTopMenu) { sep = new Gtk.VSeparator (); sep.WidthRequest = 6; } else { sep = new Gtk.HSeparator (); sep.HeightRequest = 6; } Add (sep); ShowAll (); return; } else { if (Child != null && Child is Gtk.Separator) Remove (Child); } if (node.Action == null) return; bool isGlobal = wrapper != null && wrapper.Project.ActionGroups.IndexOf (node.Action.ActionGroup) != -1; Gtk.Action gaction = node.Action.GtkAction; bool barItem = parentMenu.IsTopMenu; string text = gaction.Label; string stock = gaction.StockId; if (barItem) { icon = null; } else if (node.Action.Type == Stetic.Wrapper.Action.ActionType.Radio) { icon = new CheckActionIcon (true, node.Action.Active); } else if (node.Action.Type == Stetic.Wrapper.Action.ActionType.Toggle) { icon = new CheckActionIcon (node.Action.DrawAsRadio, node.Action.Active); } if (stock != null) { Gtk.StockItem item = Gtk.Stock.Lookup (stock); if (text == null || text.Length == 0) text = item.Label; if (item.Keyval != 0 && !editing && !barItem) { Gtk.Label lac = new Gtk.Label (); string accelName = Gtk.Accelerator.Name (item.Keyval, item.Modifier).ToUpper (); accelName = accelName.Replace ("<CONTROL>", "Ctrl+"); accelName = accelName.Replace ("<SHIFT>", "Shift+"); accelName = accelName.Replace ("<ALT>", "Alt+"); lac.Text = accelName; accel = lac; } if (icon == null && !barItem) icon = node.Action.CreateIcon (Gtk.IconSize.Menu); } if (editing && !isGlobal) { if (!barItem) { Gtk.HBox bbox = new Gtk.HBox (); if (icon != null) { bbox.PackStart (icon, false, false, 0); } bbox.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.In), false, false, 0); Gtk.Button b = new Gtk.Button (bbox); b.TooltipText = Catalog.GetString ("Select action type"); b.Relief = Gtk.ReliefStyle.None; b.ButtonPressEvent += OnSelectIcon; icon = b; } else icon = null; Gtk.Entry entry = new Gtk.Entry (); entry.Text = text; entry.Activated += OnLabelActivated; entry.KeyPressEvent += OnEntryKeyPress; entry.HasFrame = false; this.label = entry; entry.TooltipText = Catalog.GetString ("Action label"); } else { Gtk.Label label = new Gtk.Label (text); label.Xalign = 0; this.label = label; } if (editing && wrapper != null) { // Add a button for creating / deleting a submenu Gdk.Pixbuf img; string tip; if (node.Type != Gtk.UIManagerItemType.Menu) { img = addMenuImage; tip = Catalog.GetString ("Add submenu (Ctrl+Right)"); } else { img = removeMenuImage; tip = Catalog.GetString ("Remove submenu (Ctrl+Left)"); } Gtk.Button sb = new Gtk.Button (new Gtk.Image (img)); sb.TooltipText = tip; sb.Relief = Gtk.ReliefStyle.None; sb.Clicked += OnCreateDeleteSubmenu; // Make sure the button is alligned to the right of the column Gtk.HBox bbox = new Gtk.HBox (); bbox.PackEnd (sb, false, false, 0); accel = bbox; } if (node.Type == Gtk.UIManagerItemType.Menu && !editing && !barItem) { Gtk.Arrow arrow = new Gtk.Arrow (Gtk.ArrowType.Right, Gtk.ShadowType.None); arrow.Xalign = 1; this.accel = arrow; } if (itemSpacing > 0 && icon != null) { // Add some padding to the left of the icon Gtk.Alignment a = new Gtk.Alignment (0, 0.5f, 0, 0); a.LeftPadding = itemSpacing; a.Add (icon); icon = a; } }
public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position) { Widget.UseUnderline = useMnemonic; this.image = image; if (label != null && label.Length == 0) { label = null; } Button b = (Button)Frontend; if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll(); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (image.Backend != null) { imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button)); } Gtk.Label labelWidget = null; if (label != null && imageWidget == null) { contentWidget = labelWidget = new Gtk.Label(label); } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3); labelWidget = new Gtk.Label(label) { UseUnderline = useMnemonic }; if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart(imageWidget, false, false, 0); box.PackStart(labelWidget, false, false, 0); } else { box.PackStart(labelWidget, false, false, 0); box.PackStart(imageWidget, false, false, 0); } contentWidget = box; } var expandButtonContent = false; if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox(false, 3); box.PackStart(contentWidget, true, true, 3); box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; expandButtonContent = true; } else { contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); } } if (contentWidget != null) { contentWidget.ShowAll(); Widget.Label = null; Widget.Image = contentWidget; if (expandButtonContent) { var alignment = Widget.Child as Gtk.Alignment; if (alignment != null) { var box = alignment.Child as Gtk.Box; if (box != null) { alignment.Xscale = 1; box.SetChildPacking(box.Children [0], true, true, 0, Gtk.PackType.Start); if (labelWidget != null) { labelWidget.Xalign = 0; } } } } if (labelWidget != null) { labelWidget.UseUnderline = useMnemonic; if (customFont != null) { labelWidget.ModifyFont(customFont); } } } else { Widget.Label = null; } }
public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position) { Widget.UseUnderline = useMnemonic; this.image = image; if (label != null && label.Length == 0) { label = null; } Button b = (Button)Frontend; if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll(); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (image.Backend != null) { imageWidget = new ImageBox(ApplicationContext, image.WithDefaultSize(Gtk.IconSize.Button)); } if (label != null && imageWidget == null) { contentWidget = new Gtk.Label(label) { UseUnderline = useMnemonic }; } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3); var lab = new Gtk.Label(label) { UseUnderline = useMnemonic }; if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart(imageWidget, false, false, 0); box.PackStart(lab, false, false, 0); } else { box.PackStart(lab, false, false, 0); box.PackStart(imageWidget, false, false, 0); } contentWidget = box; } if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox(false, 3); box.PackStart(contentWidget, true, true, 3); box.PackStart(new Gtk.VSeparator(), true, true, 0); box.PackStart(new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; } else { contentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); } } if (contentWidget != null) { contentWidget.ShowAll(); Widget.Label = null; Widget.Image = contentWidget; } else { Widget.Label = null; } }
protected virtual void SetContent(Xwt.ContentPosition position) { var label = this.Label; if (label != null && label.Length == 0) { label = null; } if (ButtonType == Xwt.ButtonType.Disclosure) { this.Label = null; this.ContentWidget = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); this.ContentWidget.ShowAll(); return; } Gtk.Widget contentWidget = null; if (label != null && Image == null) { contentWidget = new Gtk.Label(label) { UseUnderline = this.UseUnderline }; } else if (label == null && Image != null) { contentWidget = AllocEventBox(ImageWidget, true); contentWidget.AddEvents((int)Gdk.EventMask.ButtonPressMask); contentWidget.ButtonPressEvent -= this.ButtonPressed; contentWidget.ButtonPressEvent += this.ButtonPressed; Gdk.Color?background = null; contentWidget.FocusInEvent += (s, e) => { var w = s as Gtk.Widget; }; contentWidget.EnterNotifyEvent += (s, e) => { var w = s as Gtk.Widget; if (background == null) { background = w.Style.Background(Gtk.StateType.Normal); } w.ModifyBg(Gtk.StateType.Normal, Notifycolor); w.QueueDraw(); }; contentWidget.LeaveNotifyEvent += (s, e) => { var w = s as Gtk.Widget; w.ModifyBg(Gtk.StateType.Normal, background.Value); w.QueueDraw(); }; } else if (label != null && Image != null) { var box = position == Xwt.ContentPosition.Left || position == Xwt.ContentPosition.Right ? (Gtk.Box) new Gtk.HBox(false, 3) : (Gtk.Box) new Gtk.VBox(false, 3); var lab = new Gtk.Label(label) { UseUnderline = this.UseUnderline }; if (position == Xwt.ContentPosition.Left || position == Xwt.ContentPosition.Top) { box.PackStart(ImageWidget, false, false, 0); box.PackStart(lab, false, false, 0); } else { box.PackStart(lab, false, false, 0); box.PackStart(ImageWidget, false, false, 0); } contentWidget = box; } if (ButtonType == Xwt.ButtonType.DropDown) { Gtk.Widget dropDownArrow = new Gtk.Arrow(Gtk.ArrowType.Down, Gtk.ShadowType.Out); dropDownArrow = AllocEventBox(dropDownArrow); dropDownArrow.AddEvents((int)Gdk.EventMask.ButtonPressMask); dropDownArrow.ButtonPressEvent += this.DropDownPressed; dropDownArrow.ModifyBg(Gtk.StateType.Normal, Widget.Style.Background(Gtk.StateType.Normal)); if (contentWidget != null) { var box = new Gtk.HBox(false, 3); box.PackStart(contentWidget, true, true, 3); //box.PackStart (new Gtk.VSeparator (), true, true, 0); box.PackStart(dropDownArrow, false, false, 0); contentWidget = box; } else { contentWidget = dropDownArrow; } } if (contentWidget != null) { contentWidget.ShowAll(); this.ContentWidget = contentWidget; } else { this.Label = null; } }
public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position) { Widget.UseUnderline = useMnemonic; this.image = image; if (label != null && label.Length == 0) label = null; Button b = (Button) Frontend; if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll (); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (image.Backend != null) imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button)); if (label != null && imageWidget == null) { contentWidget = new Gtk.Label (label) { UseUnderline = useMnemonic }; } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3); var lab = new Gtk.Label (label) { UseUnderline = useMnemonic }; if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart (imageWidget, false, false, 0); box.PackStart (lab, false, false, 0); } else { box.PackStart (lab, false, false, 0); box.PackStart (imageWidget, false, false, 0); } contentWidget = box; } if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox (false, 3); box.PackStart (contentWidget, true, true, 3); box.PackStart (new Gtk.VSeparator (), true, true, 0); box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; } else contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); } if (contentWidget != null) { contentWidget.ShowAll (); Widget.Label = null; Widget.Image = contentWidget; } else Widget.Label = null; }
public void SetContent (string label, bool useMnemonic, ImageDescription image, ContentPosition position) { Widget.UseUnderline = useMnemonic; this.image = image; if (label != null && label.Length == 0) label = null; Button b = (Button) Frontend; if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } if (b.Type == ButtonType.Disclosure) { Widget.Label = null; Widget.Image = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); Widget.Image.ShowAll (); return; } Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; if (image.Backend != null) imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button)); Gtk.Label labelWidget = null; if (label != null && imageWidget == null) { contentWidget = labelWidget = new Gtk.Label (label); } else if (label == null && imageWidget != null) { contentWidget = imageWidget; } else if (label != null && imageWidget != null) { Gtk.Box box = position == ContentPosition.Left || position == ContentPosition.Right ? (Gtk.Box) new Gtk.HBox (false, 3) : (Gtk.Box) new Gtk.VBox (false, 3); labelWidget = new Gtk.Label (label) { UseUnderline = useMnemonic }; if (position == ContentPosition.Left || position == ContentPosition.Top) { box.PackStart (imageWidget, false, false, 0); box.PackStart (labelWidget, false, false, 0); } else { box.PackStart (labelWidget, false, false, 0); box.PackStart (imageWidget, false, false, 0); } contentWidget = box; } var expandButtonContent = false; if (b.Type == ButtonType.DropDown) { if (contentWidget != null) { Gtk.HBox box = new Gtk.HBox (false, 3); box.PackStart (contentWidget, true, true, 3); box.PackStart (new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out), false, false, 0); contentWidget = box; expandButtonContent = true; } else contentWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out); } if (contentWidget != null) { contentWidget.ShowAll (); Widget.Label = null; Widget.Image = contentWidget; if (expandButtonContent) { var alignment = Widget.Child as Gtk.Alignment; if (alignment != null) { var box = alignment.Child as Gtk.Box; if (box != null) { alignment.Xscale = 1; box.SetChildPacking (box.Children [0], true, true, 0, Gtk.PackType.Start); if (labelWidget != null) labelWidget.Xalign = 0; } } } if (labelWidget != null) { labelWidget.UseUnderline = useMnemonic; if (customFont != null) labelWidget.ModifyFont (customFont); } } else Widget.Label = null; }