示例#1
0
        public void InsertTab(int index, Tab tab)
        {
            if (index < 0 || index >= tabs.Count)
            {
                tabs.Add(tab);
                tabSizes.Add(tab.Size);
            }
            else
            {
                tabs.Insert(index, tab);
                tabSizes.Insert(index, tab.Size);
            }
            if (tabs.Count == 1)
            {
                tab.Active = true;
            }
            else if (activeTab >= index)
            {
                activeTab++;
            }

            if (focusedTab >= index)
            {
                focusedTab++;
            }

            QueueResize();

            tab.Allocation = GetBounds(tab);
            Accessible.AddAccessibleElement(tab.Accessible);
            tab.AccessibilityPressed += OnTabPressed;

            UpdateAccessibilityTabs();
        }
示例#2
0
        public void ReplaceTab(int position, Tab tab)
        {
            var oldTab = tabs [position];

            tabs [position]     = tab;
            tabSizes [position] = tab.Size;

            if (oldTab.Active)
            {
                tab.Active = tab.Visible;
            }

            if (oldTab.Accessible != null)
            {
                Accessible.RemoveAccessibleElement(oldTab.Accessible);
                oldTab.AccessibilityPressed -= OnTabPressed;
                UpdateAccessibilityTabs();
            }

            oldTab.Dispose();

            QueueResize();

            tab.Allocation = GetBounds(tab);
            if (tab.Accessible != null)
            {
                Accessible.AddAccessibleElement(tab.Accessible);
                tab.AccessibilityPressed += OnTabPressed;
                UpdateAccessibilityTabs();
            }
        }
示例#3
0
            void CalcAccessibility()
            {
                var columnElement = new AtkCocoaHelper.AccessibilityElementProxy();

                columnElement.GtkParent = this;
                columnElement.SetRole(AtkCocoa.Roles.AXColumn);
                Accessible.AddAccessibleElement(columnElement);

                for (int i = 0; i < win.DataProvider.IconCount; i++)
                {
                    var rowElement = new AtkCocoaHelper.AccessibilityElementProxy();
                    rowElement.GtkParent = this;
                    rowElement.SetRole(AtkCocoa.Roles.AXRow);
                    Accessible.AddAccessibleElement(rowElement);

                    var cellElement = new AtkCocoaHelper.AccessibilityElementProxy();
                    cellElement.GtkParent = this;
                    cellElement.SetRole(AtkCocoa.Roles.AXCell);
                    columnElement.AddAccessibleChild(cellElement);
                    rowElement.AddAccessibleChild(cellElement);

                    var textElement = new TextElement();
                    textElement.RowIndex      = i;
                    textElement.PerformPress += PerformPress;
                    textElement.GtkParent     = this;
                    textElement.Value         = win.DataProvider.GetMarkup(i);
                    cellElement.AddAccessibleChild(textElement);
                }
            }
示例#4
0
        void PageAddedHandler(object sender, TabEventArgs args)
        {
            var tab = args.Tab;

            Accessible.AddAccessibleElement(tab.Accessible);

            tab.AccessibilityPressTab         += OnAccessibilityPressTab;
            tab.AccessibilityPressCloseButton += OnAccessibilityPressCloseButton;
            tab.AccessibilityShowMenu         += OnAccessibilityShowMenu;

            QueueResize();

            UpdateAccessibilityTabs();
        }
示例#5
0
        void PageAddedHandler(object sender, EventArgs args)
        {
            int idx = 0;

            foreach (var tab in notebook.Tabs)
            {
                if (idx >= allTabs.Count || tab != allTabs [idx])
                {
                    allTabs.Insert(idx, tab);
                    Accessible.AddAccessibleElement(tab.Accessible);

                    tab.AccessibilityPressTab         += OnAccessibilityPressTab;
                    tab.AccessibilityPressCloseButton += OnAccessibilityPressCloseButton;
                    tab.AccessibilityShowMenu         += OnAccessibilityShowMenu;
                    break;
                }

                idx++;
            }

            QueueResize();

            UpdateAccessibilityTabs();
        }
示例#6
0
        public TabStrip(DockNotebook notebook)
        {
            if (notebook == null)
            {
                throw new ArgumentNullException("notebook");
            }

            Accessible.SetRole(AtkCocoa.Roles.AXTabGroup);

            // Handle focus for the tabs.
            CanFocus = true;

            TabWidth    = 125;
            TargetWidth = 125;
            tracker     = new MouseTracker(this);
            GtkWorkarounds.FixContainerLeak(this);

            innerBox = new HBox(false, 0);
            innerBox.Accessible.SetShouldIgnore(true);
            Add(innerBox);

            this.notebook = notebook;
            WidgetFlags  |= Gtk.WidgetFlags.AppPaintable;
            Events       |= EventMask.PointerMotionMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask;

            var arr = new Xwt.ImageView(tabbarPrevImage);

            arr.HeightRequest = arr.WidthRequest = 10;

            var alignment = new Alignment(0.5f, 0.5f, 0.0f, 0.0f);

            alignment.Add(arr.ToGtkWidget());
            PreviousButton                 = new Button(alignment);
            PreviousButton.TooltipText     = Core.GettextCatalog.GetString("Switch to previous document");
            PreviousButton.Relief          = ReliefStyle.None;
            PreviousButton.CanDefault      = false;
            PreviousButton.CanFocus        = true;
            PreviousButton.Accessible.Name = "DockNotebook.Tabstrip.PreviousButton";
            PreviousButton.Accessible.SetTitle(Core.GettextCatalog.GetString("Previous document"));
            PreviousButton.Accessible.Description = Core.GettextCatalog.GetString("Switch to previous document");

            arr = new Xwt.ImageView(tabbarNextImage);
            arr.HeightRequest = arr.WidthRequest = 10;

            alignment = new Alignment(0.5f, 0.5f, 0.0f, 0.0f);
            alignment.Add(arr.ToGtkWidget());
            NextButton                 = new Button(alignment);
            NextButton.TooltipText     = Core.GettextCatalog.GetString("Switch to next document");
            NextButton.Relief          = ReliefStyle.None;
            NextButton.CanDefault      = false;
            NextButton.CanFocus        = true;
            NextButton.Accessible.Name = "DockNotebook.Tabstrip.NextButton";
            NextButton.Accessible.SetTitle(Core.GettextCatalog.GetString("Next document"));
            NextButton.Accessible.Description = Core.GettextCatalog.GetString("Switch to next document");

            DropDownButton                 = new MenuButton();
            DropDownButton.TooltipText     = Core.GettextCatalog.GetString("Document List");
            DropDownButton.Relief          = ReliefStyle.None;
            DropDownButton.CanDefault      = false;
            DropDownButton.CanFocus        = true;
            DropDownButton.Accessible.Name = "DockNotebook.Tabstrip.DocumentListButton";
            DropDownButton.Accessible.SetTitle(Core.GettextCatalog.GetString("Document list"));
            DropDownButton.Accessible.Description = Core.GettextCatalog.GetString("Display the document list menu");

            PreviousButton.ShowAll();
            PreviousButton.NoShowAll = true;
            NextButton.ShowAll();
            NextButton.NoShowAll = true;
            DropDownButton.ShowAll();

            PreviousButton.Name = "MonoDevelop.DockNotebook.BarButton";
            NextButton.Name     = "MonoDevelop.DockNotebook.BarButton";
            DropDownButton.Name = "MonoDevelop.DockNotebook.BarButton";

            innerBox.PackStart(PreviousButton, false, false, 0);
            innerBox.PackStart(NextButton, false, false, 0);
            innerBox.PackEnd(DropDownButton, false, false, 0);

            tracker.HoveredChanged += (sender, e) => {
                if (!tracker.Hovered)
                {
                    SetHighlightedTab(null);
                    UpdateTabWidth(tabEndX - tabStartX);
                    QueueDraw();
                }
            };

            foreach (var tab in notebook.Tabs)
            {
                Accessible.AddAccessibleElement(tab.Accessible);
            }
            UpdateAccessibilityTabs();
            notebook.PageAdded     += PageAddedHandler;
            notebook.PageRemoved   += PageRemovedHandler;
            notebook.TabsReordered += PageReorderedHandler;

            closingTabs = new Dictionary <int, DockNotebookTab> ();
        }