Inheritance: Gtk.DrawingArea
Example #1
0
		void Init ()
		{
			image = new ImageBox (actx);

			this.Title        = "";
			this.Resizable    = false;
		}
Example #2
0
		void Init ()
		{
			image = new ImageBox (actx);
			this.AddContent (hbox);
			hbox.PackStart (image, false, false, 0);
			hbox.PackStart (labelsBox, true, true, 0);
			labelsBox.PackStart (label, true, true, 0);
				
			// Table 3.1
			this.Title        = "";
			this.BorderWidth  = 6;
			//this.Type         = WindowType.Toplevel;
			this.Resizable    = false;
			#if !XWT_GTK3
			this.HasSeparator = false;
			#endif
			
			// Table 3.2
			this.SetContentSpacing (12);
			
			// Table 3.3
			this.hbox.Spacing     = 12;
			this.hbox.BorderWidth = 6;
			
			// Table 3.4
			this.image.Yalign   = 0.00f;
			//this.image.IconSize = Gtk.IconSize.Dialog;
			
			// Table 3.5
			this.label.UseMarkup = true;
			this.label.Wrap      = true;
			this.label.Yalign    = 0.00f;
			this.label.Xalign    = 0.00f;
		}
Example #3
0
		public void SetImage (ImageDescription image)
		{
			Gtk.ImageMenuItem it = item as Gtk.ImageMenuItem;
			if (it == null)
				return;
			if (!image.IsNull) {
				var img = new ImageBox (context, image);
				img.ShowAll ();
				it.Image = img;
				GtkWorkarounds.ForceImageOnMenuItem (it);
			}
			else
				it.Image = null;
		}
 public void SetImage(ImageDescription image)
 {
     Gtk.ImageMenuItem it = item as Gtk.ImageMenuItem;
     if (it == null)
     {
         return;
     }
     if (!image.IsNull)
     {
         var img = new ImageBox(context, image);
         img.ShowAll();
         it.Image = img;
         GtkWorkarounds.ForceImageOnMenuItem(it);
     }
     else
     {
         it.Image = null;
     }
 }
Example #5
0
        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;
            }
        }
Example #6
0
        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;
        }
Example #7
0
        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;
            }
        }
Example #9
0
 public void SetImage(ImageDescription image)
 {
     Gtk.ImageMenuItem it = item as Gtk.ImageMenuItem;
     if (it == null)
         return;
     if (!image.IsNull) {
         if (defImage == null)
             item.StateChanged += ImageMenuItemStateChanged;
         defImage = image;
         selImage = new ImageDescription {
             Backend = image.Backend,
             Size = image.Size,
             Alpha = image.Alpha,
             Styles = image.Styles.Add ("sel")
         };
         var img = new ImageBox (context, image);
         img.ShowAll ();
         it.Image = img;
         GtkWorkarounds.ForceImageOnMenuItem (it);
     } else {
         if (defImage.HasValue) {
             item.StateChanged -= ImageMenuItemStateChanged;
             defImage = selImage = null;
         }
         it.Image = null;
     }
 }
Example #10
0
        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;
        }
Example #11
0
		public override void Initialize ()
		{
			Widget = new ImageBox (ApplicationContext);
			Widget.Show ();
		}
Example #12
0
		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 override void Initialize()
 {
     Widget = new ImageBox(ApplicationContext);
     Widget.Show();
 }