Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2011-12-30 21:31:21 +0400
committerLluis Sanchez <lluis@xamarin.com>2011-12-30 21:31:21 +0400
commit310f2feb730a7e75b164b75e6739106ba790d018 (patch)
tree8182e79017a9d74defeb2ad8113a667542212401 /Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs
parent4c995b1ad38e0c62e40466713d2f04caabfa01af (diff)
More sizing fixes. Allow setting a custom natural size.
Diffstat (limited to 'Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs')
-rwxr-xr-xXwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs58
1 files changed, 37 insertions, 21 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs
index c9e80017..b8e3a728 100755
--- a/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs
@@ -53,33 +53,35 @@ namespace Xwt.GtkBackend
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;
+ }
- Gdk.Pixbuf pix = (Gdk.Pixbuf)imageBackend;
+ 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 imageWidget = null;
+ Gtk.Widget contentWidget = null;
- switch (b.Type) {
- case ButtonType.Normal:
- if (pix != null)
- imageWidget = new Gtk.Image (pix);
- break;
- case ButtonType.DropDown:
- imageWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
- break;
- case ButtonType.Disclosure:
- label = null;
- imageWidget = new Gtk.Arrow (Gtk.ArrowType.Down, Gtk.ShadowType.Out);
- break;
- }
+ Gtk.Widget imageWidget = null;
+ if (imageBackend != null)
+ imageWidget = new Gtk.Image ((Gdk.Pixbuf)imageBackend);
if (label != null && imageWidget == null) {
- Widget.Label = label;
+ contentWidget = new Gtk.Label (label);
}
else if (label == null && imageWidget != null) {
- imageWidget.Show ();
- Widget.Image = imageWidget;
- } 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);
@@ -91,9 +93,23 @@ namespace Xwt.GtkBackend
box.PackStart (imageWidget, false, false, 0);
}
- box.ShowAll ();
- Widget.Image = box;
+ 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 SetButtonStyle (ButtonStyle style)