diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2013-03-22 22:39:08 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2013-03-22 22:39:08 +0400 |
commit | a8c84a6fc4e1e634b02e22b3202a53d028bf59b2 (patch) | |
tree | 5886b3fd6f3a6aded21d2446ea5107e271a3efdb /Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs | |
parent | 0e4d7d3fa7be707aa46c983515df11d6cf582cbf (diff) |
Initial work to support multi-resolution images
Diffstat (limited to 'Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs')
-rwxr-xr-x | Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs index 73dcdb99..6d47f6f5 100755 --- a/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs +++ b/Xwt.Gtk/Xwt.GtkBackend/ButtonBackend.cs @@ -34,6 +34,7 @@ namespace Xwt.GtkBackend public class ButtonBackend: WidgetBackend, IButtonBackend { protected bool ignoreClickEvents; + ImageDescription image; public ButtonBackend () { @@ -55,13 +56,15 @@ namespace Xwt.GtkBackend get { return (IButtonEventSink)base.EventSink; } } - public void SetContent (string label, Image image, ContentPosition position) + public void SetContent (string label, ImageDescription image, ContentPosition position) { + this.image = image; + if (label != null && label.Length == 0) label = null; Button b = (Button) Frontend; - if (label != null && image == null && b.Type == ButtonType.Normal) { + if (label != null && image.Backend == null && b.Type == ButtonType.Normal) { Widget.Label = label; return; } @@ -76,8 +79,8 @@ namespace Xwt.GtkBackend Gtk.Widget contentWidget = null; Gtk.Widget imageWidget = null; - if (image != null) - imageWidget = new Gtk.Image (image.ToPixbuf (Gtk.IconSize.Button)); + if (image.Backend != null) + imageWidget = new ImageBox (ApplicationContext, image.WithDefaultSize (Gtk.IconSize.Button)); if (label != null && imageWidget == null) { contentWidget = new Gtk.Label (label); @@ -138,7 +141,7 @@ namespace Xwt.GtkBackend public void SetButtonType (ButtonType type) { Button b = (Button) Frontend; - SetContent (b.Label, b.Image, b.ImagePosition); + SetContent (b.Label, image, b.ImagePosition); } public override void EnableEvent (object eventId) |