Ejemplo n.º 1
0
        /// <summary>
        /// Returns the bounding rectangle for a specified tab in this tab control.
        /// </summary>
        /// <param name="page">The Tab Page to retrieve the bounds for.</param>
        /// <returns>A <see cref="Rectangle"/> that represents the bounds of the specified tab.</returns>
        public virtual Rectangle GetTabRect(BpTabPage page)
        {
            TabPosition position = positions[page];
            int         row      = position.Row;

            if (selectedRow > row)
            {
                row++;
            }
            else if (selectedRow == row)
            {
                row = 0;
            }
            Rectangle result = Rectangle.Empty;

            result.X      = tabsRectangle.Left + position.Offset + tabExpand.Left;
            result.Width  = position.Size.Width;
            result.Y      = tabsRectangle.Bottom - (row * tabHeight) - tabHeight;
            result.Height = tabHeight;
            if (page == selectedTab)
            {
                result.Y      -= tabExpand.Top;
                result.Height += tabExpand.Vertical;
                result.X      -= tabExpand.Left;
                result.Width  += tabExpand.Horizontal;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static IPlatformElementConfiguration <GTK, FormsElement> SetTabPosition(
            this IPlatformElementConfiguration <GTK, FormsElement> config, TabPosition value)
        {
            SetTabPosition(config.Element, value);

            return(config);
        }
Ejemplo n.º 3
0
        public Tab(Tabstrip parent, string label, TabPosition tabPosition)
        {
            this.parent = parent;
            this.Label  = label;

            layout = PangoUtil.CreateLayout(parent);
            layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11);
            layout.SetText(label);
            layout.Alignment = Pango.Alignment.Center;
            layout.GetPixelSize(out w, out h);

            if (IsSeparator)
            {
                w = SpacerWidth * 2;
            }

            this.TabPosition = tabPosition;

            if (AccessibilityElementProxy.Enabled)
            {
                Accessible = AccessibilityElementProxy.ButtonElementProxy();
                Accessible.SetRole(AtkCocoa.Roles.AXRadioButton, "tab");
                Accessible.Title         = label;
                Accessible.GtkParent     = parent;
                Accessible.Identifier    = "Tabstrip.Tab";
                Accessible.PerformPress += OnTabPressed;
            }
        }
Ejemplo n.º 4
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var panel = new TagBuilder("a2-tab-panel", null, IsInGrid);

            onRender?.Invoke(panel);
            MergeAttributes(panel, context);
            panel.AddCssClassBool(Border, "bordered");
            panel.AddCssClassBool(FullPage, "full-page");
            panel.AddCssClassBool(Overflow, "overflow");
            panel.AddCssClass($"tab-pos-{TabPosition.ToString().ToLowerInvariant()}");

            if (MinHeight != null)
            {
                panel.MergeStyleUnit("min-height", MinHeight.Value);
            }

            if (Width != null)
            {
                panel.MergeStyle("width", Width.Value);
            }

            var isBind = GetBinding(nameof(ItemsSource));

            if (isBind != null)
            {
                panel.MergeAttribute(":items", isBind.GetPath(context));
                if (Tabs.Count != 1)
                {
                    throw new XamlException("If ItemsSource is specified, then only one Tab allowed in the collection");
                }
                panel.RenderStart(context);
                var tml = new TagBuilder("template");
                tml.MergeAttribute("slot", "items");
                tml.MergeAttribute("slot-scope", "tabitem");
                tml.RenderStart(context);
                using (var cts = new ScopeContext(context, "tabitem.item", isBind.Path, _replaceScope))
                {
                    Tabs[0].RenderTemplate(context);
                }
                tml.RenderEnd(context);
                RenderHeaderTemplate(context);
                RenderHeader(context);
                panel.RenderEnd(context);
            }
            else
            {
                panel.RenderStart(context);
                RenderTabs(context);
                RenderHeader(context);
                panel.RenderEnd(context);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gives the correct <see cref="VisualStyleElement"/> to use for
        /// a give tab.
        /// </summary>
        /// <param name="page">The tab to return the element for.</param>
        /// <returns>The element to use when rendering the tab.</returns>
        internal VisualStyleElement GetElement(BpTabPage page)
        {
            string className = "TAB";
            int    part;
            int    state;

            if (page == selectedTab)
            {
                state = 3;
            }
            else if (page.Disabled)
            {
                state = 4;
            }
            else if (page == hoverTab)
            {
                state = 2;
            }
            else
            {
                state = 1;
            }

            TabPosition position = positions[page];
            int         toprow   = rows - 1;

            if ((rows > 1) && (toprow == selectedRow))
            {
                toprow--;
            }

            if (rowCounts[position.Row] == 1)
            {
                part = 1;
            }
            else if (position.Pos == rowCounts[position.Row] - 1)
            {
                part = 2;
            }
            else if (position.Pos == 0)
            {
                part = 3;
            }
            else
            {
                part = 4;
            }

            if (position.Row == toprow)
            {
                part += 4;
            }

            return(VisualStyleElement.CreateElement(className, part, state));
        }
Ejemplo n.º 6
0
        public Tabs(string id = null, TabPosition position = TabPosition.Top, object htmlAttributes = null)
            : base(htmlAttributes)
        {
            if (string.IsNullOrEmpty(id))
            {
                id = "tabs-" + Guid.NewGuid();
            }

            this.Position = position;
            this.Id       = HtmlHelper.GenerateIdFromName(id);
            EnsureHtmlAttribute("id", this.Id);
        }
Ejemplo n.º 7
0
        public Tabs(string id, TabPosition position, object htmlAttributes)
            : base(KoreUISettings.Provider.TabsProvider.TabsTag, htmlAttributes)
        {
            if (string.IsNullOrEmpty(id))
            {
                id = "tabs";
            }

            this.Position = position;
            this.Id       = HtmlHelper.GenerateIdFromName(id);
            EnsureHtmlAttribute("id", this.Id);
            KoreUISettings.Provider.TabsProvider.BeginTabs(this);
        }
Ejemplo n.º 8
0
            private static bool DrawButton(ToolbarButton button, TabPosition tabPosition, bool isSelected, float toolbarHeight = -1)
            {
                Color initialColor = GUI.color;
                var   buttonStyle  = new GUIStyle(Button.ButtonStyle(tabPosition, isSelected))
                {
                    fixedHeight = toolbarHeight >= 0 ? toolbarHeight : Button.ButtonStyle(tabPosition, isSelected).fixedHeight
                };
                float iconPadding = Mathf.Max(buttonStyle.fixedHeight * 0.2f, Properties.Space(2));

                if (button.IconStyle != null)
                {
                    GUILayout.BeginVertical();
                    buttonStyle.alignment     = TextAnchor.MiddleLeft;
                    buttonStyle.padding.left  = (int)(buttonStyle.fixedHeight);
                    buttonStyle.padding.right = (int)iconPadding;
                }

                buttonStyle.padding.right = (int)Properties.Space(3);

                GUI.color = Colors.GetDColor(isSelected ? button.SelectedColorName : button.NormalColorName).Normal.WithAlpha(GUI.color.a * 0.8f);
                bool result = GUILayout.Button(new GUIContent(button.Name), buttonStyle);

                GUI.color = initialColor;

                if (button.IconStyle != null)
                {
                    float iconSize = buttonStyle.fixedHeight * 0.6f;
                    GUILayout.Space(-buttonStyle.fixedHeight);
                    GUILayout.BeginHorizontal(GUILayout.Width(iconSize));
                    {
                        GUILayout.Space(iconPadding);
                        Icon.Draw(button.IconStyle, iconSize, buttonStyle.fixedHeight, isSelected ? button.SelectedColorName : button.NormalColorName);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }

                // ReSharper disable once InvertIf
                if (result)
                {
                    Properties.ResetKeyboardFocus();
                    if (button.Callback != null)
                    {
                        button.Callback.Invoke();
                    }
                }

                return(result);
            }
Ejemplo n.º 9
0
        public Tab(Tabstrip parent, string label, TabPosition tabPosition)
        {
            this.parent = parent;
            this.Label  = label;
            layout      = PangoUtil.CreateLayout(parent);
            layout.SetText(label);
            layout.GetPixelSize(out w, out h);

            if (IsSeparator)
            {
                w = SpacerWidth * 2;
            }

            this.TabPosition = tabPosition;
        }
Ejemplo n.º 10
0
        public Tabs(TabPosition position, object htmlAttributes)
            : base("div", htmlAttributes)
        {
            switch (position)
            {
                case TabPosition.Left: EnsureClass("tabbable tabs-left"); break;
                case TabPosition.Right: EnsureClass("tabbable tabs-right"); break;

                //case TabPosition.Bottom: EnsureClass("tabbable tabs-bottom"); break;
            }

            this.InternalTabTemplate = @"<li><a data-toggle=""tab"" href=""#{href}"">#{label}</a></li>";
            this.InternalActiveTabTemplate = @"<li class=""active""><a data-toggle=""tab"" href=""#{href}"">#{label}</a></li>";
            this.InternalPanelTag = "div";
        }
Ejemplo n.º 11
0
        public Tabs(TabPosition position, object htmlAttributes)
            : base("div", htmlAttributes)
        {
            switch (position)
            {
            case TabPosition.Left: EnsureClass("tabbable tabs-left"); break;

            case TabPosition.Right: EnsureClass("tabbable tabs-right"); break;

                //case TabPosition.Bottom: EnsureClass("tabbable tabs-bottom"); break;
            }

            this.InternalTabTemplate       = @"<li><a data-toggle=""tab"" href=""#{href}"">#{label}</a></li>";
            this.InternalActiveTabTemplate = @"<li class=""active""><a data-toggle=""tab"" href=""#{href}"">#{label}</a></li>";
            this.InternalPanelTag          = "div";
        }
Ejemplo n.º 12
0
        public static string GetName(TabPosition type)
        {
            string result = String.Empty;

            switch (type)
            {
                case TabPosition.Top:
                    result = "top";
                    break;
                case TabPosition.Bottom:
                    result = "bottom";
                    break;
            }

            return result;
        }
Ejemplo n.º 13
0
        public static string GetName(TabPosition type)
        {
            string result = String.Empty;

            switch (type)
            {
            case TabPosition.Top:
                result = "top";
                break;

            case TabPosition.Bottom:
                result = "bottom";
                break;
            }

            return(result);
        }
Ejemplo n.º 14
0
        public Tab(Tabstrip parent, string label, TabPosition tabPosition)
        {
            //this.parent = parent;
            this.Label = label;

            layout = PangoUtil.CreateLayout(parent);
            layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11);
            layout.SetText(label);
            layout.Alignment = Pango.Alignment.Center;
            layout.GetPixelSize(out w, out h);

            if (IsSeparator)
            {
                w = SpacerWidth * 2;
            }

            this.TabPosition = tabPosition;
        }
Ejemplo n.º 15
0
        public override int GetHashCode()
        {
            // Use a different bit for bool fields: bool.GetHashCode() will return 0 (false) or 1 (true). So we would
            // end up having the same hash code for e.g. two instances where one has only noCache set and the other
            // only noStore.
            var result = Pills.GetHashCode()
                         ^ (FullWidth.GetHashCode() << 1)
                         ^ (Justified.GetHashCode() << 2); // increase shift by one for every bool field

            result = result
                     ^ (TabPosition.GetHashCode() ^ 1); // power of two for every other field(^1, ^2, ^4, ^8, ^16, ...)

            if (SelectedTab != null)
            {
                result ^= SelectedTab.GetHashCode();
            }

            return(result);
        }
            public static GUIStyle ButtonStyle(TabPosition position, State state = DEFAULT_STATE)
            {
                switch (position)
                {
                case TabPosition.Left:
                    switch (state)
                    {
                    case State.Disabled: return(Styles.GetStyle(Styles.StyleName.ButtonLeftDisabled));

                    case State.Enabled:  return(Styles.GetStyle(Styles.StyleName.ButtonLeftEnabled));

                    default:             throw new ArgumentOutOfRangeException("state", state, null);
                    }

                case TabPosition.Middle:
                    switch (state)
                    {
                    case State.Disabled: return(Styles.GetStyle(Styles.StyleName.ButtonMiddleDisabled));

                    case State.Enabled:  return(Styles.GetStyle(Styles.StyleName.ButtonMiddleEnabled));

                    default:             throw new ArgumentOutOfRangeException("state", state, null);
                    }

                case TabPosition.Right:
                    switch (state)
                    {
                    case State.Disabled: return(Styles.GetStyle(Styles.StyleName.ButtonRightDisabled));

                    case State.Enabled:  return(Styles.GetStyle(Styles.StyleName.ButtonRightEnabled));

                    default:             throw new ArgumentOutOfRangeException("state", state, null);
                    }

                default: throw new ArgumentOutOfRangeException("position", position, null);
                }
            }
Ejemplo n.º 17
0
 public Tabs(TabPosition position)
     : this(position, null)
 {
 }
Ejemplo n.º 18
0
		public Tab (Tabstrip parent, string label, TabPosition tabPosition)
		{
			this.parent = parent;
			this.Label = label;
			layout = PangoUtil.CreateLayout (parent);
			layout.SetText (label);
			layout.GetPixelSize (out w, out h);

			if (IsSeparator)
				w = SpacerWidth * 2;
			
			this.TabPosition = tabPosition;
		}
Ejemplo n.º 19
0
		// Size the tabs for SizeMode normal or fixed
		private void SizeTabsNormal(ref TabPosition[] tabs, Graphics g, int rowWidth, out int row, bool fixedSize)
		{
			int pos = 0;
			row = 0;
			
			for( int i=0;i < tabs.Length; i++)
			{
				if ((tabPageCollection[i] as TabPage).Visible)
				{
					int measuredWidth;
					if (fixedSize)
						measuredWidth = itemSize.Width;
					else
						measuredWidth = (int)g.MeasureString(tabPageCollection[i].Text, Font).Width + tabTextWidthMargin * 2;
					if (measuredWidth < minimumTabSize)
						measuredWidth = minimumTabSize;
					// Are we out of room on that row?
					if (pos + measuredWidth > rowWidth && multiline)
					{
						row++;
						pos = 0;
					}

					tabs[i]=new TabPosition( new Rectangle( pos, 0, measuredWidth, 0 ), row, false );
					pos += measuredWidth;
				}
			}
		}
 public static GUIStyle ButtonStyle(TabPosition position, bool enabled = false)
 {
     return(ButtonStyle(position, enabled ? State.Enabled : State.Disabled));
 }
Ejemplo n.º 21
0
			public TabPositionInfo( int totalRows, TabPosition[] positions)
			{
				this.totalRows = totalRows;
				this.positions = positions;
			}
Ejemplo n.º 22
0
		// Size the tabs for SizeMode fillRight
		private void SizeTabsFillRight(ref TabPosition[] tabs, Graphics g, int rowWidth, out int maxRow)
		{
			// Start by sizing as per normal
			SizeTabsNormal( ref tabs, g, rowWidth, out maxRow, false );

			// The details of the row/tab for the smallest padding + tab width
			// Used to "fill" the last tab if required for the optimal FillRight packing.
			int minPadded = int.MaxValue;
			int minTabWidth = 0;
			int minTabPos = -1;

			int currentPos = 0;
			for ( int row = 0; row <= maxRow; row++ )
			{
				int thisPadded;
				int thisMinTabPos;
				int thisMinTabWidth;
					
				// For the last row we might want to move a tab in to improve the packing
				if (row == maxRow)
				{
					// Make a copy of the last row of tabs in case we need to redo that line
					TabPosition[] tabsCopy = (TabPosition[])tabs.Clone();

					int startOfLastRow = currentPos;
					PadRow( ref tabs, ref currentPos, out thisPadded, row, rowWidth, out thisMinTabPos, out thisMinTabWidth );

					// Would it be optimal to pack with our best tab?
					if (minTabPos > -1 && thisPadded >= minPadded + minTabWidth)
					{
						// Find the beginning and end of the row that we are removing the tab from.
						int startPos = -1;
						int posEnd = -1;
						int currentRow = tabs[minTabPos].row;
						for (int i = 0; i < tabs.Length; i++)
						{
							if (tabs[i].row == currentRow)
							{
								if (startPos == -1)
									startPos = i;
								posEnd = i;
							}
						}

						// Create a temporary array for the row less the tab we are moving
						TabPosition[] tabs1 = new TabPosition[posEnd - startPos];
						int j = startPos;
						for (int i = 0; i < tabs1.Length; i++)
						{
							if (j == minTabPos)
								j++;
							tabs1[i] = tabs[j];
							j++;
						}

						// Recalculate this row
						PadTabs(ref tabs1, 0, tabs1.Length, tabs[minTabPos].bounds.Width);
						CalcTabPosFromWidths(ref tabs1, 0, tabs1.Length, currentRow);

						// Write this back into tabs.
						j = startPos;
						for (int i = 0; i < tabs1.Length; i++)
						{
							if (j == minTabPos)
								j++;
							tabs[j] = tabs1[i];
							j++;
						}
						
						// minTabPos now starts the last row
						tabsCopy[startOfLastRow - 1] = tabs[minTabPos];
						PadTabs(ref tabsCopy, startOfLastRow - 1, tabsCopy.Length, thisPadded - tabs[minTabPos].bounds.Width);
						CalcTabPosFromWidths(ref tabsCopy, startOfLastRow - 1, tabsCopy.Length, tabs[startOfLastRow].row);
						// Write the calculated values back to tabs.
						tabs[minTabPos] = tabsCopy[startOfLastRow - 1];
						tabs[minTabPos].row = tabs[startOfLastRow].row;
						for (int i = startOfLastRow; i < tabs.Length; i++)
							tabs[i] = tabsCopy[i];
						
					}
				}
				else
				{
					PadRow( ref tabs, ref currentPos, out thisPadded, row, rowWidth, out thisMinTabPos, out thisMinTabWidth );

					// Find the minimum Tabsize for this row
					if (thisPadded + thisMinTabWidth < minPadded + minTabWidth)
					{
						minPadded = thisPadded;
						minTabWidth = thisMinTabWidth;
						minTabPos = thisMinTabPos;
					}
				}
			}
		}
Ejemplo n.º 23
0
		// Add pixelsToPad to the widths of the tabs
		private void PadTabs(ref TabPosition[] tabs, int startPos, int posEnd, int pixelsToPad)
		{
			// Add 1 pixel to the smallest tab until the row is filled.
			while (pixelsToPad > 0)
			{
				// Find the smallest tab in the row
				int smallestPos = -1;
				int smallestWidth = int.MaxValue;
				for (int i = startPos; i < posEnd; i++ )
				{
					if (!(tabPageCollection[i] as TabPage).Visible)
						continue;

					if (tabs[i].bounds.Width < smallestWidth)
					{
						smallestPos = i;
						smallestWidth = tabs[i].bounds.Width;
					}
				}
				// If we have no visible tabs.
				if (smallestPos == -1)
					return;
				tabs[smallestPos].bounds = new Rectangle(0,0, smallestWidth + 1,0);
				pixelsToPad--;
			}
		}
Ejemplo n.º 24
0
		// Write the x cooridinate of the tab from the width and write the row we want.
		private void CalcTabPosFromWidths(ref TabPosition[] tabs, int startPos, int posEnd, int newRow)
		{
			int posTotal = 0;
			for (int pos = startPos; pos < posEnd; pos++ )
			{
				if (!(tabPageCollection[pos] as TabPage).Visible)
					continue;
				int width = tabs[pos].bounds.Width;
				tabs[pos].bounds = new Rectangle(posTotal,0,width,0);
				tabs[pos].row = newRow;
				posTotal += width;
			}
		}
Ejemplo n.º 25
0
		// Using the tabs row and the widths, calculate each tabs actual bounds
		private void LayoutTabBounds(ref TabPosition[] tabs, int rowWidth)
		{
			int down = ActualTabHeight;
			int top = 0;
			int yDirection = 1;
			// At the bottom, we start a row higher
			int extraRow = 0;
			if (alignment == TabAlignment.Bottom)
			{
				yDirection = -1;
				extraRow = 1;
				top = Height;
			}
			
			int lastVisible = -1;
			int leftOffset = 0;
			if (moveButtonsShowing)
				leftOffset = tabs[moveButtonsTabOffset].bounds.Left;
			int totalWidth = 0;
			for( int i=0;i < tabPageCollection.Count; i++)
			{
				if ((tabPageCollection[i] as TabPage).Visible)
				{
					// Move the tabs thats selected by 1
					int selDelta = 0;
					if (i != SelectedIndex)
						selDelta = 1;

					TabPosition tab = tabs[i];
					int width = tab.bounds.Width + (1-selDelta)*2*indent;
					// Draw the left edge of tabs that begin a row or are selected
					if (tab.bounds.Left - leftOffset == 0 || SelectedIndex == i)
						tab.leftExposed = true;
					tab.bounds = new Rectangle(tab.bounds.Left + indent - (1-selDelta)*2 - leftOffset, yDirection *((tab.row + extraRow ) * down + selDelta) + top, width, down + 1 - selDelta );
					tabs[i] = tab;
					lastVisible = i;
					totalWidth += width;
				}
			}
			moveButtonsShowing = !multiline && totalWidth > rowWidth;
			// Are the tab move buttons covered by a tab. This is used to disallow the tabs moving left anymore
			if (moveButtonsShowing)
				moveButtonsCovered = moveButtonLeftBounds.Left < tabs[lastVisible].bounds.Right;
					
		}
Ejemplo n.º 26
0
        /// <summary>
        /// Calculates the rectangles for the tab area, the client area,
        /// the display area, and the transformed display area.
        /// </summary>
        private void CalculateRectangles()
        {
            Rectangle olddisp = displayRectangle;

            positions.Clear();
            Graphics g = this.CreateGraphics();

            if (Controls.Count > 0)
            {
                int width = Width;

                width    -= tabExpand.Horizontal;
                tabHeight = 0;
                rows      = 0;
                int used = 0;
                int pos  = 0;
                foreach (BpTabPage page in Controls)
                {
                    VisualStyleElement  element;
                    VisualStyleRenderer renderer;

                    Size closebutton = new Size(0, 0);
                    if (IncludesCloseButton(page))
                    {
                        element = VisualStyleElement.ToolTip.Close.Normal;
                        if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(element))
                        {
                            renderer    = new VisualStyleRenderer(element);
                            closebutton = renderer.GetPartSize(g, ThemeSizeType.Draw);
                        }
                        else
                        {
                            Font closefont = new Font("Marlett", SystemFonts.MenuFont.Size);
                            closebutton         = TextRenderer.MeasureText("r", closefont);
                            closebutton.Height += SystemInformation.Border3DSize.Height * 2;
                            closebutton.Width  += SystemInformation.Border3DSize.Width * 2;
                        }
                    }

                    Size size = page.GetPreferredTabSize(g);
                    size.Height = Math.Max(size.Height, closebutton.Height);
                    size.Width += closebutton.Width;
                    element     = GetGuessedElement(page);
                    if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(element))
                    {
                        renderer = new VisualStyleRenderer(element);
                        Rectangle fake = new Rectangle(0, 0, size.Width, size.Height);
                        fake = renderer.GetBackgroundExtent(g, fake);
                        size = new Size(fake.Width, fake.Height);
                    }
                    size.Height += SystemInformation.Border3DSize.Height * 2;
                    size.Width  += SystemInformation.Border3DSize.Width * 2;

                    if (size.Width > width)
                    {
                        size.Width = width;
                    }
                    if ((size.Width + used) > width)
                    {
                        rowCounts.Add(pos);
                        rows++;
                        used = 0;
                        pos  = 0;
                    }
                    TabPosition position = new TabPosition(rows, used, size, pos);
                    positions[page] = position;
                    tabHeight       = Math.Max(tabHeight, size.Height);
                    used           += size.Width;
                    pos++;
                    if (page == selectedTab)
                    {
                        selectedRow = rows;
                    }
                }
                rowCounts.Add(pos);
                rows++;
                tabsRectangle = new Rectangle(0, 0, Width, (rows * tabHeight) + tabExpand.Top);
                paneRectangle = new Rectangle(0, tabsRectangle.Bottom, Width, Height - tabsRectangle.Bottom);
            }
            else
            {
                paneRectangle = ClientRectangle;
                tabsRectangle = Rectangle.Empty;
            }
            if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(VisualStyleElement.Tab.Pane.Normal))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
                displayRectangle = renderer.GetBackgroundContentRectangle(g, paneRectangle);
            }
            else
            {
                Padding paneMargin = new Padding(SystemInformation.Border3DSize.Width, SystemInformation.Border3DSize.Height, SystemInformation.Border3DSize.Width, SystemInformation.Border3DSize.Height);
                displayRectangle        = Rectangle.Empty;
                displayRectangle.Y      = paneRectangle.Y + paneMargin.Top;
                displayRectangle.Height = paneRectangle.Height - paneMargin.Vertical;
                displayRectangle.X      = paneRectangle.X + paneMargin.Left;
                displayRectangle.Width  = paneRectangle.Width - paneMargin.Horizontal;
            }
            if (olddisp != displayRectangle)
            {
                Invalidate();
                PerformLayout();
                Update();
            }
            else
            {
                Rectangle badrect = tabsRectangle;
                badrect.Height += tabExpand.Bottom;
                Invalidate(badrect);
                Update();
            }
        }
Ejemplo n.º 27
0
		// Move a particular row Row to the bottom of the tabs (lastRow)
		private void RowToBottom(ref TabPosition[] tabs, int row, int lastRow)
		{
			for (int i = 0; i < tabs.Length; i++)
			{
				if (tabs[i].row == row)
					tabs[i].row = lastRow;
				else if (tabs[i].row > row)
					tabs[i].row--;
			}
		}
Ejemplo n.º 28
0
		public Tab (Tabstrip parent, string label, TabPosition tabPosition)
		{
			//this.parent = parent;
			this.Label = label;

			layout = PangoUtil.CreateLayout (parent);
			layout.FontDescription = FontService.SansFont.CopyModified (Styles.FontScale11);
			layout.SetText (label);
			layout.Alignment = Pango.Alignment.Center;
			layout.GetPixelSize (out w, out h);

			if (IsSeparator)
				w = SpacerWidth * 2;
			
			this.TabPosition = tabPosition;
		}
Ejemplo n.º 29
0
 public Tabs(string id, TabPosition position)
     : this(id, position, null)
 {
 }
Ejemplo n.º 30
0
 public Tabs(TabPosition position)
     : this(position, null)
 {
 }
Ejemplo n.º 31
0
		// Pad tab widths evenly, from startPos and ending where total width is greater than the ideal
		private void PadRow (ref TabPosition[] tabs, ref int startPos, out int totalPadded, int newRow, int rowWidth, out int minTabPos, out int minTabWidth)
		{
			minTabWidth = int.MaxValue;
			minTabPos = -1;
			
			// Find the last tab that fits into this row and the number of pixels we have to fill.
			// Also find the smallest tab.
			totalPadded = rowWidth;
			int posEnd = startPos;
			for (; posEnd < tabs.Length; posEnd++)
			{
				if (!(tabPageCollection[posEnd] as TabPage).Visible)
					continue;

				int width = tabs[posEnd].bounds.Width;
				// We end the count if we have exceeded the ideal width
				if (totalPadded < width)
					break;
				totalPadded -= width;
				
				if (minTabWidth > width)
				{
					minTabWidth = width;
					minTabPos = posEnd;
				}		
			}

			PadTabs( ref tabs, startPos, posEnd, totalPadded);
			CalcTabPosFromWidths( ref tabs, startPos, posEnd, newRow);

			// We will start at this position next time
			startPos = posEnd;
		}
Ejemplo n.º 32
0
            /*  ConfigOptions
             *      -----------------------------------------------------------------------------------------------*/

            /// <summary>
            /// The position where the tab strip should be rendered (defaults to 'top'). The only other supported value is 'Bottom'. Note that tab scrolling is only supported for position 'top'.
            /// </summary>
            public virtual TBuilder TabPosition(TabPosition tabPosition)
            {
                this.ToComponent().TabPosition = tabPosition;
                return(this as TBuilder);
            }
Ejemplo n.º 33
0
        private HtmlGenericControl BuildTabs(TabPosition position)
        {
            HtmlGenericControl header = new HtmlGenericControl("div");
            StringBuilder      headerClass;

            if (position == TabPosition.Top)
            {
                headerClass = new StringBuilder("x-tab-panel-header");
            }
            else
            {
                headerClass = new StringBuilder("x-tab-panel-footer");
            }

            if (!this.tabPanelControl.Border)
            {
                if (position == TabPosition.Top)
                {
                    headerClass.Append(" x-tab-panel-header-noborder");
                }
                else
                {
                    headerClass.Append(" x-tab-panel-footer-noborder");
                }
            }

            if (this.tabPanelControl.Plain && position == TabPosition.Top)
            {
                headerClass.Append(" x-tab-panel-header-plain");
            }

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                headerClass.Append(" x-tab-scrolling");
            }

            header.Attributes["class"] = headerClass.ToString();

            double headerWidth = 0;

            if (this.tabPanelControl.Width != Unit.Empty)
            {
                headerWidth           = this.tabPanelControl.Width.Value - (this.tabPanelControl.Border ? 2 : 0);
                header.Style["width"] = "{0}px".FormatWith(headerWidth.ToString());
            }
            else
            {
                header.Style["width"] = "auto";
            }

            //header.Style["MozUserSelect"] = "none";
            //header.Style["KhtmlUserSelect"] = "none";

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                HtmlGenericControl scrollRight = new HtmlGenericControl("div");
                scrollRight.Attributes["class"] = "x-tab-scroller-right x-unselectable";
                //scrollRight.Style["MozUserSelect"] = "none";
                //scrollRight.Style["KhtmlUserSelect"] = "none";
                int h = 22 - (this.tabPanelControl.Plain ? 1 : 0);

                //foreach (Tab tab in tabPanelControl.Items)
                //{
                //    if (tab.Closable)
                //    {
                //        if (ActiveTabIndexIsValid && this.tabPanelControl.Items[this.tabPanelControl.ActiveTabIndex].Closable)
                //        {
                //            h--;
                //        }
                //        break;
                //    }
                //}

                scrollRight.Style["height"] = h + "px";
                header.Controls.Add(scrollRight);

                HtmlGenericControl scrollLeft = new HtmlGenericControl("div");
                scrollLeft.Attributes["class"] = "x-tab-scroller-left x-unselectable";
                //scrollLeft.Style["MozUserSelect"] = "none";
                //scrollLeft.Style["KhtmlUserSelect"] = "none";
                scrollLeft.Style["height"] = h + "px";
                header.Controls.Add(scrollLeft);
            }

            HtmlGenericControl stripWrap = new HtmlGenericControl("div");

            stripWrap.Attributes["class"] = "x-tab-strip-wrap";
            stripWrap.Style["width"]      = "auto";

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                if (this.tabPanelControl.Width != Unit.Empty)
                {
                    stripWrap.Style["width"] = "{0}px".FormatWith((headerWidth - 36).ToString());
                }
            }

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            if (position == TabPosition.Top)
            {
                ul.Attributes["class"] = "x-tab-strip x-tab-strip-top";
            }
            else
            {
                ul.Attributes["class"] = "x-tab-strip x-tab-strip-bottom";
            }

            //ul.Style["width"] = "100%";
            ul.Style["width"]  = "auto! important";
            ul.Style["height"] = "21px";

            int activeIndex = tabPanelControl.ActiveTabIndex;

            for (int i = 0; i < tabPanelControl.Items.Count; i++)
            {
                PanelBase tabControl = this.tabPanelControl.Items[i] as PanelBase;

                this.AddIcon(tabControl.Icon);

                bool IsActive          = i == activeIndex;
                HtmlGenericControl tab = new HtmlGenericControl("li");

                //tab.Style["height"] = "100%";

                StringBuilder tabClass = new StringBuilder();

                if (tabControl.Closable)
                {
                    tabClass.Append("x-tab-strip-closable");
                }

                if (tabControl.Disabled)
                {
                    tabClass.Append(" x-item-disabled");
                }

                if (tabControl.IconClsProxy.IsNotEmpty())
                {
                    tabClass.Append(" x-tab-with-icon");
                }

                if (IsActive)
                {
                    tabClass.Append(" x-tab-strip-active");
                }

                tab.Attributes["class"] = tabClass.ToString();

                HtmlAnchor tabRight = new HtmlAnchor();
                tabRight.Attributes["class"] = "x-tab-right";

                designerRegions.Add(new DesignerRegion(CurrentDesigner, this.BuildChangeTabSignature(i), false));
                tabRight.Attributes[DesignerRegion.DesignerRegionAttributeName] = (designerRegions.Count - 1).ToString();

                HtmlGenericControl tabLeft = new HtmlGenericControl("em");
                tabLeft.Attributes["class"] = "x-tab-left";

                HtmlGenericControl stripInner = new HtmlGenericControl("span");
                stripInner.Attributes["class"] = "x-tab-strip-inner";

                HtmlGenericControl stripText = new HtmlGenericControl("span");

                if (tabControl.IconClsProxy.IsNotEmpty())
                {
                    stripText.Attributes["class"] = "x-tab-strip-text {0}".FormatWith(tabControl.IconClsProxy);
                }
                else
                {
                    stripText.Attributes["class"] = "x-tab-strip-text";
                }

                stripText.InnerHtml = tabControl.Title.IsEmpty() ? "&nbsp;" : tabControl.Title;

                if (tabControl.Closable)
                {
                    HtmlGenericControl stripClose = new HtmlGenericControl("a");
                    stripClose.Attributes["class"] = "x-tab-strip-close";
                    stripClose.Style["position"]   = "none";
                    //tab.Controls.Add(stripClose);
                    stripText.Controls.Add(stripClose);
                }

                stripInner.Controls.Add(stripText);
                tabLeft.Controls.Add(stripInner);
                tabRight.Controls.Add(tabLeft);
                tab.Controls.Add(tabRight);
                ul.Controls.Add(tab);
            }


            HtmlGenericControl edge = new HtmlGenericControl("li");

            edge.Attributes["class"] = "x-tab-edge";
            ul.Controls.Add(edge);

            HtmlGenericControl clear = new HtmlGenericControl("div");

            clear.Attributes["class"] = "x-clear";
            ul.Controls.Add(clear);

            stripWrap.Controls.Add(ul);
            header.Controls.Add(stripWrap);

            HtmlGenericControl stripSpacer = new HtmlGenericControl("div");

            stripSpacer.Attributes["class"] = "x-tab-strip-spacer";
            header.Controls.Add(stripSpacer);

            return(header);
        }
Ejemplo n.º 34
0
 public static void SetTabPosition(BindableObject element, TabPosition tabPosition)
 {
     element.SetValue(TabPositionProperty, tabPosition);
 }
Ejemplo n.º 35
0
        private HtmlGenericControl BuildTabs(TabPosition position)
        {
            HtmlGenericControl header = new HtmlGenericControl("div");
            StringBuilder headerClass;

            if (position == TabPosition.Top)
            {
                headerClass = new StringBuilder("x-tab-panel-header");
            }
            else
            {
                headerClass = new StringBuilder("x-tab-panel-footer"); 
            }

            if (!this.tabPanelControl.Border)
            {
                if (position == TabPosition.Top)
                {
                    headerClass.Append(" x-tab-panel-header-noborder");
                }
                else
                {
                    headerClass.Append(" x-tab-panel-footer-noborder");
                }
            }

            if (this.tabPanelControl.Plain && position == TabPosition.Top)
            {
                headerClass.Append(" x-tab-panel-header-plain");
            }

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                headerClass.Append(" x-tab-scrolling");
            }

            header.Attributes["class"] = headerClass.ToString();
            
            double headerWidth = 0;

            if (this.tabPanelControl.Width != Unit.Empty)
            {
                headerWidth = this.tabPanelControl.Width.Value - (this.tabPanelControl.Border ? 2 : 0);
                header.Style["width"] = "{0}px".FormatWith(headerWidth.ToString());
            }
            else
            {
                header.Style["width"] = "auto";
            }

            //header.Style["MozUserSelect"] = "none";
            //header.Style["KhtmlUserSelect"] = "none";

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                HtmlGenericControl scrollRight = new HtmlGenericControl("div");
                scrollRight.Attributes["class"] = "x-tab-scroller-right x-unselectable";
                //scrollRight.Style["MozUserSelect"] = "none";
                //scrollRight.Style["KhtmlUserSelect"] = "none";
                int h = 22 - (this.tabPanelControl.Plain ? 1 : 0);

                //foreach (Tab tab in tabPanelControl.Items)
                //{
                //    if (tab.Closable)
                //    {
                //        if (ActiveTabIndexIsValid && this.tabPanelControl.Items[this.tabPanelControl.ActiveTabIndex].Closable)
                //        {
                //            h--;
                //        }
                //        break;
                //    }
                //}

                scrollRight.Style["height"] = h+"px";
                header.Controls.Add(scrollRight);

                HtmlGenericControl scrollLeft = new HtmlGenericControl("div");
                scrollLeft.Attributes["class"] = "x-tab-scroller-left x-unselectable";
                //scrollLeft.Style["MozUserSelect"] = "none";
                //scrollLeft.Style["KhtmlUserSelect"] = "none";
                scrollLeft.Style["height"] = h + "px";
                header.Controls.Add(scrollLeft);
            }

            HtmlGenericControl stripWrap = new HtmlGenericControl("div");
            stripWrap.Attributes["class"] = "x-tab-strip-wrap";
            stripWrap.Style["width"] = "auto";

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                if (this.tabPanelControl.Width != Unit.Empty)
                {
                    stripWrap.Style["width"] = "{0}px".FormatWith((headerWidth - 36).ToString());
                }
            }

            HtmlGenericControl ul = new HtmlGenericControl("ul");
            
            if (position == TabPosition.Top)
            {
                ul.Attributes["class"] = "x-tab-strip x-tab-strip-top";
            }
            else
            {
                ul.Attributes["class"] = "x-tab-strip x-tab-strip-bottom";
            }
                
            //ul.Style["width"] = "100%";
            ul.Style["width"] = "auto! important";
            ul.Style["height"] = "21px";

            int activeIndex = tabPanelControl.ActiveTabIndex;

            for (int i = 0; i < tabPanelControl.Items.Count; i++)
            {
                PanelBase tabControl = this.tabPanelControl.Items[i] as PanelBase;

                this.AddIcon(tabControl.Icon);

                bool IsActive = i == activeIndex;
                HtmlGenericControl tab = new HtmlGenericControl("li");

                //tab.Style["height"] = "100%";

                StringBuilder tabClass = new StringBuilder();

                if (tabControl.Closable)
                {
                    tabClass.Append("x-tab-strip-closable");
                }

                if (tabControl.Disabled)
                {
                    tabClass.Append(" x-item-disabled");
                }

                if (tabControl.IconClsProxy.IsNotEmpty())
                {
                    tabClass.Append(" x-tab-with-icon");
                }

                if (IsActive)
                {
                    tabClass.Append(" x-tab-strip-active");
                }

                tab.Attributes["class"] = tabClass.ToString();

                HtmlAnchor tabRight = new HtmlAnchor();
                tabRight.Attributes["class"] = "x-tab-right";

                designerRegions.Add(new DesignerRegion(CurrentDesigner, this.BuildChangeTabSignature(i), false));
                tabRight.Attributes[DesignerRegion.DesignerRegionAttributeName] = (designerRegions.Count - 1).ToString();
                
                HtmlGenericControl tabLeft= new HtmlGenericControl("em");
                tabLeft.Attributes["class"] = "x-tab-left";

                HtmlGenericControl stripInner = new HtmlGenericControl("span");
                stripInner.Attributes["class"] = "x-tab-strip-inner";

                HtmlGenericControl stripText = new HtmlGenericControl("span");

                if (tabControl.IconClsProxy.IsNotEmpty())
                {
                    stripText.Attributes["class"] = "x-tab-strip-text {0}".FormatWith(tabControl.IconClsProxy); 
                }
                else
                {
                    stripText.Attributes["class"] = "x-tab-strip-text"; 
                }

                stripText.InnerHtml = tabControl.Title.IsEmpty() ? "&nbsp;" : tabControl.Title;

                if (tabControl.Closable)
                {
                    HtmlGenericControl stripClose = new HtmlGenericControl("a");
                    stripClose.Attributes["class"] = "x-tab-strip-close";
                    stripClose.Style["position"] = "none";
                    //tab.Controls.Add(stripClose);
                    stripText.Controls.Add(stripClose);
                }
                
                stripInner.Controls.Add(stripText);
                tabLeft.Controls.Add(stripInner);
                tabRight.Controls.Add(tabLeft);
                tab.Controls.Add(tabRight);
                ul.Controls.Add(tab);
            }
            
           
            HtmlGenericControl edge = new HtmlGenericControl("li");
            edge.Attributes["class"] = "x-tab-edge";
            ul.Controls.Add(edge);

            HtmlGenericControl clear = new HtmlGenericControl("div");
            clear.Attributes["class"] = "x-clear";
            ul.Controls.Add(clear);
            
            stripWrap.Controls.Add(ul);
            header.Controls.Add(stripWrap);

            HtmlGenericControl stripSpacer = new HtmlGenericControl("div");
            stripSpacer.Attributes["class"] = "x-tab-strip-spacer";
            header.Controls.Add(stripSpacer);

            return header;
        }