Ejemplo n.º 1
0
        public void SetLabel(Gtk.Widget page, Xwt.Drawing.Image icon, string label)
        {
            string labelNoSpaces = label != null?label.Replace(' ', '-') : null;

            this.label = label;
            this.page  = page;

            if (icon == null)
            {
                icon = ImageService.GetIcon("md-empty");
            }

            if (box == null)
            {
                box = new HBox();
                box.Accessible.SetShouldIgnore(true);
                box.Spacing = -2;

                tabIcon = new ImageView();
                tabIcon.Accessible.SetShouldIgnore(true);
                tabIcon.Show();
                box.PackStart(tabIcon, false, false, 3);

                labelWidget = new ExtendedLabel(label);
                // Ignore the label because the title tab already contains its name
                labelWidget.Accessible.SetShouldIgnore(true);
                labelWidget.UseMarkup = true;
                var alignLabel = new Alignment(0.0f, 0.5f, 1, 1);
                alignLabel.Accessible.SetShouldIgnore(true);
                alignLabel.BottomPadding = 0;
                alignLabel.RightPadding  = 15;
                alignLabel.Add(labelWidget);
                box.PackStart(alignLabel, false, false, 0);

                btnDock             = new ImageButton();
                btnDock.Image       = pixAutoHide;
                btnDock.TooltipText = GettextCatalog.GetString("Auto Hide");
                btnDock.CanFocus    = true;
                //			btnDock.WidthRequest = btnDock.HeightRequest = 17;
                btnDock.Clicked          += OnClickDock;
                btnDock.ButtonPressEvent += (o, args) => args.RetVal = true;
                btnDock.WidthRequest      = btnDock.SizeRequest().Width;
                UpdateDockButtonAccessibilityLabels();

                btnClose             = new ImageButton();
                btnClose.Image       = pixClose;
                btnClose.TooltipText = GettextCatalog.GetString("Close");
                btnClose.CanFocus    = true;
                //			btnClose.WidthRequest = btnClose.HeightRequest = 17;
                btnClose.WidthRequest = btnDock.SizeRequest().Width;
                btnClose.Clicked     += delegate {
                    item.Visible = false;
                };
                btnClose.ButtonPressEvent += (o, args) => args.RetVal = true;

                al = new Alignment(0, 0.5f, 1, 1);
                al.Accessible.SetShouldIgnore(true);
                HBox btnBox = new HBox(false, 0);
                btnBox.Accessible.SetShouldIgnore(true);
                btnBox.PackStart(btnDock, false, false, 3);
                btnBox.PackStart(btnClose, false, false, 1);
                al.Add(btnBox);
                box.PackEnd(al, false, false, 3);

                Add(box);
            }

            tabIcon.Image = icon;

            string realLabel, realHelp;

            if (!string.IsNullOrEmpty(label))
            {
                labelWidget.Parent.Show();
                labelWidget.Name = label;
                btnDock.Name     = string.Format("btnDock_{0}", labelNoSpaces ?? string.Empty);
                btnClose.Name    = string.Format("btnClose_{0}", labelNoSpaces ?? string.Empty);
                realLabel        = GettextCatalog.GetString("Close {0}", label);
                realHelp         = GettextCatalog.GetString("Close the {0} pad", label);
            }
            else
            {
                labelWidget.Parent.Hide();
                realLabel = GettextCatalog.GetString("Close pad");
                realHelp  = GettextCatalog.GetString("Close the pad");
            }

            btnClose.Accessible.SetLabel(realLabel);
            btnClose.Accessible.Description = realHelp;

            if (label != null)
            {
                Accessible.Name        = $"DockTab.{labelNoSpaces}";
                Accessible.Description = GettextCatalog.GetString("Switch to the {0} tab", label);
                Accessible.SetTitle(label);
                Accessible.SetLabel(label);
            }

            // Get the required size before setting the ellipsize property, since ellipsized labels
            // have a width request of 0
            box.ShowAll();
            Show();

            minWidth = tabIcon.SizeRequest().Width + al.SizeRequest().Width + 10;

            UpdateBehavior();
            UpdateVisualStyle();
        }
Ejemplo n.º 2
0
		public void SetLabel (Gtk.Widget page, Xwt.Drawing.Image icon, string label)
		{
			this.label = label;
			this.page = page;
			if (Child != null) {
				Gtk.Widget oc = Child;
				Remove (oc);
				oc.Destroy ();
			}
			
			Gtk.HBox box = new HBox ();
			box.Spacing = -2;
			
			if (icon == null)
				icon = ImageService.GetIcon ("md-empty");

			tabIcon = new ImageView (icon);
			tabIcon.Show ();
			box.PackStart (tabIcon, false, false, 3);

			if (!string.IsNullOrEmpty (label)) {
				labelWidget = new ExtendedLabel (label);
				labelWidget.UseMarkup = true;
				labelWidget.Name = label;
				var alignLabel = new Alignment (0.0f, 0.5f, 1, 1);
				alignLabel.BottomPadding = 0;
				alignLabel.RightPadding = 15;
				alignLabel.Add (labelWidget);
				box.PackStart (alignLabel, false, false, 0);
			} else {
				labelWidget = null;
			}

			btnDock = new ImageButton ();
			btnDock.Image = pixAutoHide;
			btnDock.TooltipText = GettextCatalog.GetString ("Auto Hide");
			btnDock.CanFocus = false;
//			btnDock.WidthRequest = btnDock.HeightRequest = 17;
			btnDock.Clicked += OnClickDock;
			btnDock.ButtonPressEvent += (o, args) => args.RetVal = true;
			btnDock.WidthRequest = btnDock.SizeRequest ().Width;
			btnDock.Name = string.Format("btnDock_{0}", label ?? string.Empty);

			btnClose = new ImageButton ();
			btnClose.Image = pixClose;
			btnClose.TooltipText = GettextCatalog.GetString ("Close");
			btnClose.CanFocus = false;
//			btnClose.WidthRequest = btnClose.HeightRequest = 17;
			btnClose.WidthRequest = btnDock.SizeRequest ().Width;
			btnClose.Clicked += delegate {
				item.Visible = false;
			};
			btnClose.ButtonPressEvent += (o, args) => args.RetVal = true;
			btnClose.Name = string.Format ("btnClose_{0}", label ?? string.Empty);

			Gtk.Alignment al = new Alignment (0, 0.5f, 1, 1);
			HBox btnBox = new HBox (false, 0);
			btnBox.PackStart (btnDock, false, false, 3);
			btnBox.PackStart (btnClose, false, false, 1);
			al.Add (btnBox);
			box.PackEnd (al, false, false, 3);

			Add (box);
			
			// Get the required size before setting the ellipsize property, since ellipsized labels
			// have a width request of 0
			box.ShowAll ();
			Show ();

			minWidth = tabIcon.SizeRequest ().Width + al.SizeRequest ().Width + 10;

			UpdateBehavior ();
			UpdateVisualStyle ();
		}