Tab header.
Inheritance: Button
Esempio n. 1
0
 /// <summary>
 /// Move pane to a container relative to targetPaneGroup. 
 /// </summary>
 /// <param name="pane">Pane to be moved</param>
 /// <param name="targetPaneGroup"> </param>
 /// <param name="depth">Refer a parent container of targetPaneGroup, each depth is one parent container away. 
 /// Depth 0 add a PaneContainer in the same container if the container is horizontal, if not
 /// adds the movedPane to a new child vertical container</param>
 /// <param name="moveRigth"> True to move pane to the rigth of targetPaneGroup </param>
 internal static void MovePaneHorizontally(TabButton pane, PaneGroup targetPaneGroup, uint depth, bool moveRigth)
 {
     var container = GetParentContainer(targetPaneGroup);
     if (!container.IsHorizontal)
     {
         var childContainer = new Container(container);
         childContainer.IsHorizontal = true;
         container.ReplacePanel(targetPaneGroup,childContainer,false);
         childContainer.InsertPanel(targetPaneGroup);
         container = childContainer;
     }
     var paneGroup = new PaneGroup(container);
     paneGroup.AddPage(pane);
     container.InsertPanel(paneGroup,targetPaneGroup,!moveRigth);
 }
Esempio n. 2
0
        public void MoveTabsTo(DockedTabControl target)
        {
            var children = TabStrip.Children.ToArray(); // copy because collection will be modified

            foreach (Control child in children)
            {
                TabButton button = child as TabButton;
                if (button == null)
                {
                    continue;
                }
                target.AddPage(button);
            }
            Invalidate();
        }
Esempio n. 3
0
        /// <summary>
        /// Move pane to a container relative to targetPaneGroup.
        /// </summary>
        /// <param name="pane">Pane to be moved</param>
        /// <param name="depth">Refer a parent container of targetPaneGroup, each
        /// depth is one parent container away. Depth 0 add a PaneContainer in the
        /// same container if the container is horizontal, if not adds the movedPane
        /// to a new child vertical container</param>
        /// <param name="moveRight"> True to move pane to the rigth of PaneGroup </param>
        internal void MovePaneHorizontally(TabButton pane, uint depth, bool moveRight)
        {
            var container = GetParentContainer(this);

            if (!container.IsHorizontal)
            {
                var childContainer = new Container(container) {IsHorizontal = true};
                container.ReplacePanel(this,childContainer,false);
                childContainer.InsertPanel(this);
                container = childContainer;
            }

            var paneGroup = new PaneGroup(container, paneManager);
            paneGroup.AddPage(pane);
            container.InsertPanel(paneGroup,this,!moveRight);
        }
Esempio n. 4
0
        /// <summary>
        /// Handler for tab removing.
        /// </summary>
        /// <param name="button"></param>
        internal virtual void OnLoseTab(TabButton button)
        {
            if (m_CurrentButton == button)
            {
                m_CurrentButton = null;
            }

            //TODO: Select a tab if any exist.

            if (TabRemoved != null)
            {
                TabRemoved.Invoke(this);
            }

            Invalidate();
        }
Esempio n. 5
0
        /// <summary>
        /// Handler for tab selection.
        /// </summary>
        /// <param name="control">Event source (TabButton).</param>
        internal virtual void OnTabPressed(Control control)
        {
            TabButton button = control as TabButton;

            if (null == button)
            {
                return;
            }

            Control page = button.Page;

            if (null == page)
            {
                return;
            }

            if (m_CurrentButton == button)
            {
                return;
            }

            if (null != m_CurrentButton)
            {
                Control page2 = m_CurrentButton.Page;
                if (page2 != null)
                {
                    page2.IsHidden = true;
                }
                m_CurrentButton.Redraw();
                m_CurrentButton = null;
            }

            m_CurrentButton = button;

            if (TabSelected != null)
            {
                TabSelected.Invoke(m_CurrentButton);
            }

            page.IsHidden = false;

            m_TabStrip.Invalidate();
            Invalidate();
        }
Esempio n. 6
0
        /// <summary>
        /// Adds a new page/tab.
        /// </summary>
        /// <param name="label">Tab label.</param>
        /// <param name="page">Page contents.</param>
        /// <returns>Newly created control.</returns>
        public TabButton AddPage(String label, Control page = null)
        {
            if (null == page)
            {
                page = new Control(this);
            }
            else
            {
                page.Parent = this;
            }

            TabButton button = new TabButton(m_TabStrip);

            button.SetText(label);
            button.Page      = page;
            button.IsTabable = false;

            AddPage(button);
            return(button);
        }
Esempio n. 7
0
 public void RemovePage(TabButton button)
 {
     RemoveChild(button.Page, true);
     m_TabStrip.RemoveChild(button, true);
 }
Esempio n. 8
0
        private void UnsubscribeTabEvent(TabButton button)
        {
            button.Clicked -= OnTabPressed;

            if(button.TabControl.m_CurrentButton == button)
            {
                m_CurrentButton = null;
            }

            if(m_TabStrip.Children.Count > 0)
            {
                ((TabButton)m_TabStrip.Children[0]).Press();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Handler for tab selection.
        /// </summary>
        /// <param name="control">Event source (TabButton).</param>
        internal virtual void OnTabPressed(Control control)
        {
            TabButton button = control as TabButton;
            if (null == button) return;

            Control page = button.Page;
            if (null == page) return;

            if (m_CurrentButton == button)
                return;

            if (null != m_CurrentButton)
            {
                Control page2 = m_CurrentButton.Page;
                if (page2 != null)
                {
                    page2.IsHidden = true;
                }
                m_CurrentButton.Redraw();
                m_CurrentButton = null;
            }

            m_CurrentButton = button;

            if (TabSelected != null)
                TabSelected.Invoke(m_CurrentButton);

            page.IsHidden = false;

            m_TabStrip.Invalidate();
            Invalidate();
        }
Esempio n. 10
0
        /// <summary>
        /// Handler for tab removing.
        /// </summary>
        /// <param name="button"></param>
        internal virtual void OnLoseTab(TabButton button)
        {
            if (m_CurrentButton == button)
                m_CurrentButton = null;

            //TODO: Select a tab if any exist.

            if (TabRemoved != null)
                TabRemoved.Invoke(this);

            Invalidate();
        }
Esempio n. 11
0
 public void RemovePage(TabButton button)
 {
     RemoveChild(button.Page, true);
     m_TabStrip.RemoveChild(button, true);
 }
Esempio n. 12
0
        /// <summary>
        /// Lays out the control's interior according to alignment, padding, dock etc.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Layout(Skins.Skin skin)
        {
            Vector2i largestTab = new Vector2i(5, 5);

            int num = 0;

            foreach (var child in Children)
            {
                TabButton button = child as TabButton;
                if (null == button)
                {
                    continue;
                }

                button.SizeToContents();

                Margin m        = new Margin();
                int    notFirst = num > 0 ? -1 : 0;

                if (Dock == Pos.Top)
                {
                    m.Left      = notFirst;
                    button.Dock = Pos.Left;
                }

                if (Dock == Pos.Left)
                {
                    m.Top       = notFirst;
                    button.Dock = Pos.Top;
                }

                if (Dock == Pos.Right)
                {
                    m.Top       = notFirst;
                    button.Dock = Pos.Top;
                }

                if (Dock == Pos.Bottom)
                {
                    m.Left      = notFirst;
                    button.Dock = Pos.Left;
                }

                largestTab.X = Math.Max(largestTab.X, button.Width);
                largestTab.Y = Math.Max(largestTab.Y, button.Height);

                button.Margin = m;
                num++;
            }

            if (Dock == Pos.Top || Dock == Pos.Bottom)
            {
                SetSize(Width, largestTab.Y);
            }

            if (Dock == Pos.Left || Dock == Pos.Right)
            {
                SetSize(largestTab.X, Height);
            }

            base.Layout(skin);
        }
Esempio n. 13
0
        /// <summary>
        /// Adds a new page/tab.
        /// </summary>
        /// <param name="label">Tab label.</param>
        /// <param name="page">Page contents.</param>
        /// <returns>Newly created control.</returns>
        public TabButton AddPage(String label, Control page = null)
        {
            if (null == page)
            {
                page = new Control(this);
            }
            else
            {
                page.Parent = this;
            }

            TabButton button = new TabButton(m_TabStrip);
            button.SetText(label);
            button.Page = page;
            button.IsTabable = false;

            AddPage(button);
            return button;
        }
Esempio n. 14
0
 /// <summary>
 /// Move pane from the current PaneGroup to the targetPaneGroup. 
 /// </summary>
 /// <param name="pane">Pane to be moved</param>
 /// <param name="targetPaneGroup"></param>
 internal static void MovePane(TabButton pane, PaneGroup targetPaneGroup)
 {
     targetPaneGroup.AddPage(pane);
 }
Esempio n. 15
0
 public void UpdateFromTab(TabButton button)
 {
     Text = button.Text;
     SizeToContents();
 }
Esempio n. 16
0
        public void TestTabButton()
        {
            var control = new TabButton(canvas) { Text = "TabButton" };

            GUI.Test(control, "TabButton1");
        }
Esempio n. 17
0
        /// <summary>
        /// Adds a page/tab.
        /// </summary>
        /// <param name="button">Page to add. (well, it's a TabButton which is a parent to the page).</param>
        public void AddPage(TabButton button)
        {
            Control page = button.Page;
            page.Parent = this;
            page.IsHidden = true;
            page.Margin = new Margin(6, 6, 6, 6);
            page.Dock = Pos.Fill;

            button.Parent = m_TabStrip;
            button.Dock = Pos.Left;
            button.SizeToContents();
            if (button.TabControl != null)
                button.TabControl.UnsubscribeTabEvent(button);
            button.TabControl = this;
            button.Clicked += OnTabPressed;

            if (null == m_CurrentButton)
            {
                button.Press();
            }

            if (TabAdded != null)
                TabAdded.Invoke(this);

            Invalidate();
        }
Esempio n. 18
0
 public void UpdateFromTab(TabButton button)
 {
     Text = button.Text;
     SizeToContents();
 }