示例#1
0
        void UpdateLayout()
        {
            uint tempX = left;
            uint tempY = top;

            Size.width  = minimizeSize;
            Size.height = 0;

            foreach (MenuItem mi in itemList)
            {
                Size itemSize = mi.GetPreferedSize();
                Size.width    = Math.Max(Size.width, itemSize.width);
                Size.height  += itemSize.height + spacer;
                mi.Position.X = (int)tempX;
                mi.Position.Y = (int)tempY;
                tempY        += spacer + itemSize.height;
            }

            for (int cont = 0; cont < itemList.Count; cont++)
            {
                itemList[cont].Size.width = Size.width;
            }

            Size.width  += left + right;
            Size.height += top + bottom - spacer;
        }
示例#2
0
        public override void Pack()
        {
            tittleBar.Position.X  = (int)left;
            tittleBar.Position.Y  = (int)top;
            tittleBar.Size.width  = Size.width - left - right;
            tittleBar.Size.height = 20;

            borderUpRight.Position.X = (int)Size.width - 13;
            borderUp.Size.width      = Size.width - 26;
            borderLeft.Size.height   = Size.height - 27;
            borderRight.Position.X   = (int)Size.width - 13;
            borderRight.Size.height  = Size.height - 27;

            borderBottomLeft.Position.Y = (int)Size.height - 15;

            borderBottom.Position.Y = (int)Size.height - 15;
            borderBottom.Size.width = Size.width - 26;

            borderBottomRight.Position.X = (int)Size.width - 13;
            borderBottomRight.Position.Y = (int)Size.height - 15;

            contentPosition = new Position((int)left, (int)(top + tittleBar.Size.height + 2));
            contentSize     = new Size(Size.width - left - right, Size.height - top - bottom - 2 - tittleBar.Size.height);

            if (Layout_ != null)
            {
                Layout_.UpdateLayout(childList, contentPosition, contentSize);
            }
        }
示例#3
0
 public Component()
 {
     Size = new Size();
     isHover = false;
     isEnable = true;
     isVisible = true;
     LayoutProperty = 0;
 }
示例#4
0
        public override Size GetPreferedSize()
        {
            Size result = new Size(tittleBar.GetPreferedSize());

            result.width  += left + right;
            result.height += top + bottom;
            return(result);
        }
示例#5
0
        public override void Paint()
        {
			UI.Instance.CurrentTheme.PaintScrollPanel(this);
			UI.Instance.PushPosition(new Position(Position));

            Position sPosition = new Position(2,2);
			Size sArea = new Size(scissorWidth,scissorHeight);
			UI.Instance.CurrentTheme.ScissorBegin(sPosition,sArea);
			/*if(content)
			{
				content->paint();
			}*/
			UI.Instance.CurrentTheme.ScissorEnd();
            UI.Instance.PopPosition();
        }
示例#6
0
        public override void UpdateLayout(List<Component> componentList, Position origin, Size area)
        {
            if (componentList.Count > 0)
            {
                int tempX = (int)(origin.X + Left);
                int tempY = (int)(origin.Y + Top);
                uint nextY = 0;
                uint width = area.width - Left;
                uint height = area.height - Top - Bottom;

                Size preferedSize = componentList[0].GetPreferedSize();
                componentList[0].Position.X = tempX;
                componentList[0].Position.Y = tempY;
                tempX += (int)(preferedSize.width + Spacer);
                nextY = (uint)Math.Max(nextY, preferedSize.height);

                for (int i = 1; i < componentList.Count; ++i)
                {
                    preferedSize = componentList[i].GetPreferedSize();
                    if ((tempX + preferedSize.width) > width)
                    {
                        tempX = (int)(origin.X + Left);
                        tempY += (int)(nextY + Spacer);
                        nextY = 0;
                        componentList[i].Position.X = tempX;
                        componentList[i].Position.Y = tempY;
                        tempX += (int)(preferedSize.width + Spacer);
                        nextY = (uint)Math.Max(nextY, preferedSize.height);
                    }
                    else
                    {
                        componentList[i].Position.X = tempX;
                        componentList[i].Position.Y = tempY;
                        tempX += (int)(preferedSize.width + Spacer);
                        nextY = (uint)Math.Max(nextY, preferedSize.height);
                    }
                }
            }
        }
示例#7
0
        public Menu(String text)
        {
            Text = text;
            this.textFont = new Text("Menu", UI.Instance.CurrentTheme.defaultTextFont, text);
            float w, h;
            Size = new Size(23, 10);
            //Size=Font::FontEngine::getSingleton().getFont().getStringBoundingBox(textFont);
            UI.Instance.CurrentTheme.defaultTextFont.MeasureString(text, out w, out h);
            Size.width = (uint)w;
            Size.height = (uint)h;

            Size.width += 10;
            Size.height = 20;
            Position.X = 100;
            Position.Y = 100;

            status = EStatus.Normal;
            expand = false;

            menuList.Position.X = -9;
            menuList.Position.Y = 25;
        }
示例#8
0
        public Menu(String text)
        {
            Text          = text;
            this.textFont = new Text("Menu", UI.Instance.CurrentTheme.defaultTextFont, text);
            float w, h;

            Size = new Size(23, 10);
            //Size=Font::FontEngine::getSingleton().getFont().getStringBoundingBox(textFont);
            UI.Instance.CurrentTheme.defaultTextFont.MeasureString(text, out w, out h);
            Size.width  = (uint)w;
            Size.height = (uint)h;

            Size.width += 10;
            Size.height = 20;
            Position.X  = 100;
            Position.Y  = 100;

            status = EStatus.Normal;
            expand = false;

            menuList.Position.X = -9;
            menuList.Position.Y = 25;
        }
示例#9
0
		public override void PaintDropDown(Position position, Size area)
		{
            GL.Disable(EnableCap.Texture2D);
            GL.Color3((byte)79, (byte)91, (byte)84);
            GL.Begin(BeginMode.Quads);
            GL.Vertex2(position.X, position.Y);
            GL.Vertex2(position.X + area.width, position.Y);
            GL.Vertex2(position.X + area.width, position.Y + area.height);
            GL.Vertex2(position.X, position.Y + area.height);
            GL.End();

            GL.Color3((byte)46, (byte)55, (byte)53);
            GL.Begin(BeginMode.LineStrip);
            GL.Vertex2(position.X, position.Y);
            GL.Vertex2(position.X + area.width, position.Y);
            GL.Vertex2(position.X + area.width, position.Y + area.height);
            GL.Vertex2(position.X, position.Y + area.height);
            GL.Vertex2(position.X, position.Y);
            GL.End();
        }
示例#10
0
        public override void ScissorBegin(Position Position, Size area)
        {
            Position origin = UI.Instance.GetOrigin();

            GL.Enable(EnableCap.ScissorTest);
            GL.Scissor((int)(origin.X + Position.X), (int)(UI.Instance.CurrentTheme.ScreenHeight - origin.Y - area.height - Position.Y), (int)area.width, (int)area.height);
        }
示例#11
0
        void OrderComponents(List<Component> list,
                             EHorizontalAlignment HAlignment, EVerticalAlignment VAlignment,
                             EFormat format, Position origin, Size area)
        {
            if (list.Count > 0)
            {
                if (format == EFormat.Horizontal)
                {
                    switch (HAlignment)
                    {
                        case EHorizontalAlignment.HLeft:
                            {
                                int strechSegment = 0;
                                uint widthTakenUp = 0;
                                foreach (Component ele in list)
                                {
                                    if (((IElement)ele).HorizontalStyle == EElementStyle.Stretch)
                                    {
                                        ++strechSegment;
                                    }
                                    else
                                    {
                                        Size perfectSize = ele.GetPreferedSize();
                                        widthTakenUp += perfectSize.width;
                                    }
                                }

                                uint widthAvailable = (uint)(area.width - Spacer * (list.Count - 1) - widthTakenUp);
                                uint averageWidth = 0;
                                if (strechSegment > 0)
                                {
                                    averageWidth = (uint)(widthAvailable / strechSegment);
                                }

                                int tempX = origin.X;
                                foreach (Component comp in list)
                                {
                                    Size perfectSize = comp.GetPreferedSize();
                                    if (((IElement)comp).HorizontalStyle == EElementStyle.Fit)
                                    {
                                        comp.Position.X = tempX;
                                        comp.Size.width = perfectSize.width;
                                        tempX += (int)(Spacer + perfectSize.width);
                                    }
                                    else if (((IElement)comp).HorizontalStyle == EElementStyle.Stretch)
                                    {
                                        comp.Position.X = tempX;
                                        comp.Size.width = averageWidth;
                                        tempX += (int)(Spacer + averageWidth);
                                    }
                                }
                                break;
                            }
                        case EHorizontalAlignment.HRight:
                            {
                                int strechSegment = 0;
                                uint widthTakenUp = 0;
                                foreach (Component ele in list)
                                {
                                    if (((IElement)ele).HorizontalStyle == EElementStyle.Stretch)
                                    {
                                        ++strechSegment;
                                    }
                                    else
                                    {
                                        Size perfectSize = ele.GetPreferedSize();
                                        widthTakenUp += perfectSize.width;
                                    }
                                }

                                uint widthAvailable = (uint)(area.width - Spacer * (list.Count - 1) - widthTakenUp);
                                uint averageWidth = 0;
                                if (strechSegment > 0)
                                {
                                    averageWidth = (uint)(widthAvailable / strechSegment);
                                }

                                int tempX = (int)(origin.X + area.width);

                                for (int i = list.Count - 1; i >= 0; --i)
                                {
                                    Component iter = list[i];
                                    Size perfectSize = iter.GetPreferedSize();
                                    if (((IElement)iter).HorizontalStyle == EElementStyle.Fit)
                                    {
                                        tempX -= (int)perfectSize.width;
                                        iter.Position.X = tempX;
                                        iter.Size.width = perfectSize.width;
                                        tempX -= (int)Spacer;
                                    }
                                    else if (((IElement)iter).HorizontalStyle == EElementStyle.Stretch)
                                    {
                                        tempX -= (int)averageWidth;
                                        iter.Position.X = tempX;
                                        iter.Size.width = averageWidth;
                                        tempX -= (int)Spacer;
                                    }
                                }
                                break;
                            }
                        case EHorizontalAlignment.HCenter:
                            {
                                bool isStretch = false;
                                int strechSegment = 0;
                                uint widthTakenUp = 0;
                                foreach (Component ele in list)
                                {
                                    if (((IElement)ele).HorizontalStyle == EElementStyle.Stretch)
                                    {
                                        ++strechSegment;
                                        isStretch = true;
                                    }
                                    else
                                    {
                                        Size perfectSize = ele.GetPreferedSize();
                                        widthTakenUp += perfectSize.width;
                                    }
                                }

                                if (isStretch)
                                {
                                    uint widthAvailable = (uint)(area.width - Spacer * (list.Count - 1) - widthTakenUp);
                                    uint averageWidth = (uint)(widthAvailable / strechSegment);
                                    int tempX = origin.X;

                                    for (int iter = 0; iter < list.Count - 1; ++iter)
                                    {
                                        Component comp = list[iter];

                                        Size perfectSize = comp.GetPreferedSize();
                                        if (((IElement)comp).HorizontalStyle == EElementStyle.Fit)
                                        {
                                            comp.Position.X = tempX;
                                            comp.Size.width = perfectSize.width;
                                            tempX += (int)(Spacer + perfectSize.width);
                                        }
                                        else if (((IElement)comp).HorizontalStyle == EElementStyle.Stretch)
                                        {
                                            comp.Position.X = tempX;
                                            comp.Size.width = averageWidth;
                                            tempX += (int)(Spacer + averageWidth);
                                        }
                                    }
                                }
                                else
                                {
                                    widthTakenUp += (uint)(Spacer * (list.Count - 1));
                                    int tempX = (int)(origin.X + area.width * 0.5f - widthTakenUp * 0.5f);

                                    foreach (Component comp in list)
                                    {
                                        Size perfectSize = comp.GetPreferedSize();
                                        comp.Position.X = tempX;
                                        comp.Size.width = perfectSize.width;
                                        tempX += (int)(Spacer + perfectSize.width);
                                    }
                                }
                                break;
                            }
                    }

                    switch (VAlignment)
                    {
                        case EVerticalAlignment.VTop:
                            {
                                int tempY = origin.Y;
                                foreach (Component comp in list)
                                {
                                    Size perfectSize = comp.GetPreferedSize();
                                    if (((IElement)comp).VerticalStyle == EElementStyle.Stretch)
                                    {
                                        comp.Position.Y = tempY;
                                        comp.Size.height = area.height;
                                    }
                                    else if (((IElement)comp).VerticalStyle == EElementStyle.Fit)
                                    {
                                        comp.Position.Y = tempY;
                                        comp.Size.height = perfectSize.height;
                                    }
                                }
                                break;
                            }
                        case EVerticalAlignment.VBottom:
                            {
                                int tempY = origin.Y;
                                foreach (Component comp in list)
                                {
                                    Size perfectSize = comp.GetPreferedSize();
                                    if (((IElement)comp).VerticalStyle == EElementStyle.Stretch)
                                    {
                                        comp.Position.Y = tempY;
                                        comp.Size.height = area.height;
                                    }
                                    else if (((IElement)comp).VerticalStyle == EElementStyle.Fit)
                                    {
                                        comp.Position.Y = (int)(tempY + area.height - perfectSize.height);
                                        comp.Size.height = perfectSize.height;
                                    }
                                }
                                break;
                            }
                        case EVerticalAlignment.VCenter:
                            {
                                int tempY = origin.Y;
                                foreach (Component comp in list)
                                {
                                    Size perfectSize = comp.GetPreferedSize();
                                    if (((IElement)comp).VerticalStyle == EElementStyle.Stretch)
                                    {
                                        comp.Position.Y = tempY;
                                        comp.Size.height = area.height;
                                    }
                                    else if (((IElement)comp).VerticalStyle == EElementStyle.Fit)
                                    {
                                        comp.Position.Y = (int)(tempY + area.height * 0.5 - perfectSize.height * 0.5);
                                        comp.Size.height = perfectSize.height;
                                    }
                                }
                                break;
                            }
                    }
                }
                else if (format == EFormat.Vertical)
                {

                }

                foreach (Component ele in list)
                {
                    ele.Pack();
                }
            }
        }
示例#12
0
        public override void UpdateLayout(List<AssortedWidgets.Widgets.Component> componentList, AssortedWidgets.Util.Position origin, AssortedWidgets.Util.Size area)
        {
            int iStyle1;
            int iStyle2;

            List<Component> north = new List<Component>(20);
            EElementStyle northHStyle = EElementStyle.Any;
            EElementStyle northVStyle = EElementStyle.Any;
            List<Component> south = new List<Component>(20);
            EElementStyle southHStyle = EElementStyle.Any;
            EElementStyle southVStyle = EElementStyle.Any;
            List<Component> west = new List<Component>(20);
            EElementStyle westHStyle = EElementStyle.Any;
            EElementStyle westVStyle = EElementStyle.Any;
            List<Component> east = new List<Component>(20);
            EElementStyle eastHStyle = EElementStyle.Any;
            EElementStyle eastVStyle = EElementStyle.Any;
            List<Component> center = new List<Component>(20);
            EElementStyle centerHStyle = EElementStyle.Any;
            EElementStyle centerVStyle = EElementStyle.Any;

            foreach (Component comp in componentList)
            {
                switch (comp.LayoutProperty)
                {
                    case EArea.North:
                        {
                            north.Add(comp);
                            iStyle1 = (int)northHStyle;
                            iStyle2 = (int)(((IElement)comp).HorizontalStyle);
                            northHStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            iStyle1 = (int)northVStyle;
                            iStyle2 = (int)(((IElement)comp).VerticalStyle);
                            northVStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            break;
                        }
                    case EArea.South:
                        {
                            south.Add(comp);
                            iStyle1 = (int)southHStyle;
                            iStyle2 = (int)(((IElement)comp).HorizontalStyle);
                            southHStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            iStyle1 = (int)southVStyle;
                            iStyle2 = (int)(((IElement)comp).VerticalStyle);
                            southVStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            break;
                        }
                    case EArea.West:
                        {
                            west.Add(comp);
                            iStyle1 = (int)westHStyle;
                            iStyle2 = (int)(((IElement)comp).HorizontalStyle);
                            westHStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            iStyle1 = (int)westVStyle;
                            iStyle2 = (int)(((IElement)comp).VerticalStyle);
                            westVStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            break;
                        }
                    case EArea.East:
                        {
                            east.Add(comp);
                            iStyle1 = (int)eastHStyle;
                            iStyle2 = (int)(((IElement)comp).HorizontalStyle);
                            eastHStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            iStyle1 = (int)eastVStyle;
                            iStyle2 = (int)(((IElement)comp).VerticalStyle);
                            eastVStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            break;
                        }
                    case EArea.Center:
                        {
                            center.Add(comp);
                            iStyle1 = (int)centerHStyle;
                            iStyle2 = (int)(((IElement)comp).HorizontalStyle);
                            centerHStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            iStyle1 = (int)centerVStyle;
                            iStyle2 = (int)(((IElement)comp).VerticalStyle);
                            centerVStyle = (EElementStyle)Math.Max(iStyle1, iStyle2);
                            break;
                        }
                }
            }
            uint width = area.width - Left - Right;
            uint height = area.height - Top - Bottom;

            int tempX = (int)(origin.X + Left);
            int tempY = (int)(origin.Y + Top);

            uint westHeight = GetPreferedHeight(west, WestFormat);
            uint centerHeight = GetPreferedHeight(center, CenterFormat);
            uint eastHeight = GetPreferedHeight(east, EastFormat);
            uint northHeight = GetPreferedHeight(north, NorthFormat);
            uint southHeight = GetPreferedHeight(south, SouthFormat);

            uint heightAvailable = area.height - Top - Bottom - Spacer - Spacer;
            heightAvailable = Math.Max(heightAvailable, Math.Max(Math.Max(westHeight, eastHeight), centerHeight) + northHeight + southHeight);
            int strechAreaCount = 1;

            if (northVStyle == EElementStyle.Stretch)
            {
                ++strechAreaCount;
            }
            else
            {
                heightAvailable -= northHeight;
            }

            if (southVStyle == EElementStyle.Stretch)
            {
                ++strechAreaCount;
            }
            else
            {
                heightAvailable -= southHeight;
            }

            uint averageHeight = (uint)(heightAvailable / strechAreaCount);

            if (northVStyle == EElementStyle.Stretch)
            {
                northHeight = Math.Max(northHeight, averageHeight);
            }
            if (southVStyle == EElementStyle.Stretch)
            {
                southHeight = Math.Max(southHeight, averageHeight);
            }

            westHeight = centerHeight = eastHeight = Math.Max(Math.Max(westHeight, eastHeight), Math.Max(centerHeight, averageHeight));

            uint northWidth = GetPreferedWidth(north, NorthFormat);
            uint southWidth = GetPreferedWidth(south, SouthFormat);
            uint eastWidth = GetPreferedWidth(east, EastFormat);
            uint westWidth = GetPreferedWidth(west, WestFormat);
            uint centerWidth = GetPreferedWidth(center, CenterFormat);

            uint widthAvailable = area.width - Left - Right;
            widthAvailable = Math.Max(widthAvailable, Math.Max(westWidth + eastWidth + centerWidth + Spacer + Spacer, Math.Max(northWidth, southWidth)));
            northWidth = southWidth = widthAvailable;
            widthAvailable -= Spacer + Spacer;

            strechAreaCount = 1;

            if (westHStyle == EElementStyle.Stretch)
            {
                ++strechAreaCount;
            }
            else
            {
                widthAvailable -= westWidth;
            }

            if (eastHStyle == EElementStyle.Stretch)
            {
                ++strechAreaCount;
            }
            else
            {
                widthAvailable -= eastWidth;
            }

            uint averageWidth = (uint)(widthAvailable / strechAreaCount);
            if (westHStyle == EElementStyle.Stretch)
            {
                westWidth = averageWidth;
            }
            if (eastHStyle == EElementStyle.Stretch)
            {
                eastWidth = averageWidth;
            }
            centerWidth = Math.Max(averageWidth, centerWidth);

            Position northPosition = new Position((int)(origin.X + Left), (int)(origin.Y + Top));
            Size northArea = new Size(northWidth, northHeight);

            OrderComponents(north, NorthHAlignment, NorthVAlignment, NorthFormat, northPosition, northArea);

            Position southPosition = new Position((int)(origin.X + Left), (int)(origin.Y + Top + Spacer + centerHeight + Spacer + northHeight));
            Size southArea = new Size(southWidth, southHeight);
            OrderComponents(south, SouthHAlignment, SouthVAlignment, SouthFormat, southPosition, southArea);

            Position westPosition = new Position((int)(origin.X + Left), (int)(origin.Y + Top + northHeight + Spacer));
            Size westArea = new Size(westWidth, westHeight);
            OrderComponents(west, WestHAlignment, WestVAlignment, WestFormat, westPosition, westArea);

            Position eastPosition = new Position((int)(origin.X + Left + westWidth + Spacer + centerWidth + Spacer), (int)(origin.Y + Top + northHeight + Spacer));
            Size eastArea = new Size(eastWidth, eastHeight);

            testNorthX = eastPosition.X;
            testNorthY = eastPosition.Y;
            testNorthWidth = eastArea.width;
            testNorthHeight = eastArea.height;

            OrderComponents(east, EastHAlignment, EastVAlignment, EastFormat, eastPosition, eastArea);

            Position centerPosition = new Position((int)(origin.X + Left + Spacer + westWidth), (int)(origin.Y + Spacer + northHeight + Top));
            Size centerArea = new Size(centerWidth, centerHeight);

            OrderComponents(center, CenterHAlignment, CenterVAlignment, CenterFormat, centerPosition, centerArea);
        }
示例#13
0
 public void SumEqual(Size pSize)
 {
     width += pSize.width;
     height += pSize.height;
 }
示例#14
0
        void border_DragMovedEvent(object sender, int offsetX, int offsetY)
        {
            Size minimize = GetPreferedSize();

            DialogBorder db = sender as DialogBorder;

            if (db == borderLeft)
            {
                if ((Size.width - offsetX) > minimize.width)
                {
                    Position.X += offsetX;
                    Size.width -= (uint)offsetX;
                }
            }
            else if ((DialogBorder)sender == borderRight)
            {
                if ((Size.width + offsetX) > minimize.width)
                {
                    Size.width += (uint)offsetX;
                }
            }
            else if ((DialogBorder)sender == borderUp)
            {
                if ((Size.height - offsetY) > minimize.height)
                {
                    Position.Y  += offsetY;
                    Size.height -= (uint)offsetY;
                }
            }
            else if ((DialogBorder)sender == borderBottom)
            {
                if ((Size.height + offsetY) > minimize.height)
                {
                    Size.height += (uint)offsetY;
                }
            }
            else if ((DialogBorder)sender == borderUpLeft)
            {
                if ((Size.width - offsetX) > minimize.width)
                {
                    Position.X += offsetX;
                    Size.width -= (uint)offsetX;
                }
                if ((Size.height - offsetY) > minimize.height)
                {
                    Position.Y  += offsetY;
                    Size.height -= (uint)offsetY;
                }
            }
            else if ((DialogBorder)sender == borderBottomRight)
            {
                if ((Size.width + offsetX) > minimize.width)
                {
                    Size.width += (uint)offsetX;
                }
                if ((Size.height + offsetY) > minimize.height)
                {
                    Size.height += (uint)offsetY;
                }
            }
            else if ((DialogBorder)sender == borderUpRight)
            {
                if ((Size.width + offsetX) > minimize.width)
                {
                    Size.width += (uint)offsetX;
                }
                if ((Size.height - offsetY) > minimize.height)
                {
                    Position.Y  += offsetY;
                    Size.height -= (uint)offsetY;
                }
            }
            else if ((DialogBorder)sender == borderBottomLeft)
            {
                if ((Size.width - offsetX) > minimize.width)
                {
                    Position.X += offsetX;
                    Size.width -= (uint)offsetX;
                }
                if ((Size.height + offsetY) > minimize.height)
                {
                    Size.height += (uint)offsetY;
                }
            }

            Pack();

            Cursor.Current = currentCursor;
        }
示例#15
0
 public abstract void PaintDropDown(Position position, Size area);
示例#16
0
 public override Size GetPreferedSize()
 {
     Size result = new Size(tittleBar.GetPreferedSize());
     result.width += left + right;
     result.height += top + bottom;
     return result;
 }
示例#17
0
        public override void Pack()
        {
            base.Pack();

            contentPosition = new Position((int)left, (int)top);
            contentSize = new Size(Size.width - left - right, Size.height - top - bottom);

            if (Layout_ != null)
            {
                Layout_.UpdateLayout(childList, contentPosition, contentSize);
            }
        }
示例#18
0
        public override void Pack()
        {
            tittleBar.Position.X = (int)left;
            tittleBar.Position.Y = (int)top;
            tittleBar.Size.width = Size.width - left - right;
            tittleBar.Size.height = 20;

            borderUpRight.Position.X = (int)Size.width - 13;
            borderUp.Size.width = Size.width - 26;
            borderLeft.Size.height = Size.height - 27;
            borderRight.Position.X = (int)Size.width - 13;
            borderRight.Size.height = Size.height - 27;

            borderBottomLeft.Position.Y = (int)Size.height - 15;

            borderBottom.Position.Y = (int)Size.height - 15;
            borderBottom.Size.width = Size.width - 26;

            borderBottomRight.Position.X = (int)Size.width - 13;
            borderBottomRight.Position.Y = (int)Size.height - 15;

            contentPosition = new Position((int)left, (int)(top + tittleBar.Size.height + 2));
            contentSize = new Size(Size.width - left - right, Size.height - top - bottom - 2 - tittleBar.Size.height);

            if (Layout_ != null)
            {
                Layout_.UpdateLayout(childList, contentPosition, contentSize);
            }
        }
示例#19
0
 public Size(Size pSize)
 {
     width = pSize.width;
     height = pSize.height;
 }
示例#20
0
 public void SubtractEqual(Size pSize)
 {
     width -= pSize.width;
     height -= pSize.height;
 }
示例#21
0
 public abstract void ScissorBegin(Position Position, Size area);
示例#22
0
 public abstract void PaintDropDown(Position position, Size area);
示例#23
0
 public virtual void UpdateLayout(List<Component> componentList, Position origin, Size area){}
示例#24
0
 public abstract void ScissorBegin(Position Position, Size area);
示例#25
0
        void OrderComponent(uint row, uint column, Position origin, Size area)
        {
            Alignment compAlignment = alignment[row][column];

            if (compAlignment.component != null)
            {
                if (compAlignment.HStyle == EElementStyle.Stretch)
                {
                    compAlignment.component.Size.width = area.width;
                    compAlignment.component.Position.X = origin.X;
                }
                else
                {
                    switch (compAlignment.HAlignment)
                    {
                        case EHAlignment.HLeft:
                            {
                                compAlignment.component.Position.X = origin.X;
                                break;
                            }
                        case EHAlignment.HCenter:
                            {
                                compAlignment.component.Position.X = (int)(origin.X + (area.width - compAlignment.width) * 0.5f);
                                break;
                            }
                        case EHAlignment.HRight:
                            {
                                compAlignment.component.Position.X = (int)(origin.X + (area.width - compAlignment.width));
                                break;
                            }
                    }
                }

                if (compAlignment.VStyle == EElementStyle.Stretch)
                {
                    compAlignment.component.Size.height = area.height;
                    compAlignment.component.Position.Y = origin.Y;

                }
                else
                {
                    switch (compAlignment.VAlignment)
                    {
                        case EVAlignment.VTop:
                            {
                                compAlignment.component.Position.Y = origin.Y;
                                break;
                            }
                        case EVAlignment.VCenter:
                            {
                                compAlignment.component.Position.Y = (int)(origin.Y + (area.height - compAlignment.height) * 0.5f);
                                break;
                            }
                        case EVAlignment.VBottom:
                            {
                                compAlignment.component.Position.Y = (int)(origin.Y + (area.height - compAlignment.height));
                                break;
                            }
                    }
                }
                compAlignment.component.Pack();
            }
        }
示例#26
0
 public void CopyFrom(Size pSize)
 {
     width = pSize.width;
     height = pSize.height;
 }
示例#27
0
        public override void UpdateLayout(List <Component> componentList, AssortedWidgets.Util.Position origin, AssortedWidgets.Util.Size area)
        {
            List <Component> .Enumerator clEnum = componentList.GetEnumerator();

            for (int i = 0; i < rowCount; ++i)
            {
                for (int e = 0; e < columnCount; ++e)
                {
                    if (clEnum.MoveNext())
                    {
                        alignment[i][e].component = clEnum.Current;
                        Size perfectSize = clEnum.Current.GetPreferedSize();
                        alignment[i][e].width  = perfectSize.width;
                        alignment[i][e].height = perfectSize.height;
                        alignment[i][e].HStyle = ((IElement)clEnum.Current).HorizontalStyle;
                        alignment[i][e].VStyle = ((IElement)clEnum.Current).VerticalStyle;
                    }
                    else
                    {
                        alignment[i][e].component = null;
                        alignment[i][e].width     = 0;
                        alignment[i][e].height    = 0;
                        alignment[i][e].HStyle    = EElementStyle.Fit;
                        alignment[i][e].VStyle    = EElementStyle.Fit;
                    }
                }
            }
            OneLineInfo[] columnInfo = new OneLineInfo[columnCount];

            for (int e = 0; e < columnCount; ++e)
            {
                columnInfo[e].miniSize  = 0;
                columnInfo[e].isStretch = false;
                for (int i = 0; i < rowCount; ++i)
                {
                    if (alignment[i][e].HStyle == EElementStyle.Stretch)
                    {
                        columnInfo[e].isStretch = true;
                    }
                    columnInfo[e].miniSize = Math.Max(columnInfo[e].miniSize, alignment[i][e].width);
                }
            }

            OneLineInfo[] rowInfo = new OneLineInfo[rowCount];

            for (int i = 0; i < rowCount; ++i)
            {
                rowInfo[i].miniSize  = 0;
                rowInfo[i].isStretch = false;
                for (int e = 0; e < columnCount; ++e)
                {
                    if (alignment[i][e].VStyle == EElementStyle.Stretch)
                    {
                        rowInfo[i].isStretch = true;
                    }
                    rowInfo[i].miniSize = Math.Max(rowInfo[i].miniSize, alignment[i][e].height);
                }
            }

            int  widthAvailable = (int)(area.width - (columnCount - 1) * Spacer - Left - Right);
            uint stretchSegment = 0;

            for (int e = 0; e < columnCount; ++e)
            {
                if (columnInfo[e].isStretch)
                {
                    ++stretchSegment;
                }
                else
                {
                    widthAvailable -= (int)columnInfo[e].miniSize;
                }
            }

            if (widthAvailable > 0)
            {
                if (stretchSegment > 0)
                {
                    uint averageWidth = (uint)widthAvailable / stretchSegment;

                    for (int e = 0; e < columnCount; ++e)
                    {
                        if (columnInfo[e].isStretch)
                        {
                            columnInfo[e].miniSize = Math.Max(columnInfo[e].miniSize, averageWidth);
                        }
                    }
                }
                else
                {
                    uint averageAppend = (uint)widthAvailable / columnCount;

                    for (int e = 0; e < columnCount; ++e)
                    {
                        columnInfo[e].miniSize += averageAppend;
                    }
                }
            }

            int heightAvailable = (int)(area.height - Top - Bottom - (rowCount - 1) * Spacer);

            stretchSegment = 0;

            for (int i = 0; i < rowCount; ++i)
            {
                if (rowInfo[i].isStretch)
                {
                    ++stretchSegment;
                }
                else
                {
                    heightAvailable -= (int)rowInfo[i].miniSize;
                }
            }

            if (heightAvailable > 0)
            {
                if (stretchSegment > 0)
                {
                    uint averageHeight = (uint)heightAvailable / stretchSegment;

                    for (int i = 0; i < rowCount; ++i)
                    {
                        if (rowInfo[i].isStretch)
                        {
                            rowInfo[i].miniSize = Math.Max(rowInfo[i].miniSize, averageHeight);
                        }
                    }
                }
                else
                {
                    uint averageAppend = (uint)heightAvailable / rowCount;
                    for (int i = 0; i < rowCount; ++i)
                    {
                        rowInfo[i].miniSize += averageAppend;
                    }
                }
            }

            int tempX = (int)Left + origin.X;
            int tempY = (int)Top + origin.Y;

            for (int i = 0; i < rowCount; ++i)
            {
                for (int e = 0; e < columnCount; ++e)
                {
                    Position CPosition = new Position(tempX, tempY);
                    Size     Carea     = new Size(columnInfo[e].miniSize, rowInfo[i].miniSize);
                    OrderComponent((uint)i, (uint)e, CPosition, Carea);
                    tempX += (int)(columnInfo[e].miniSize + Spacer);
                }
                tempX  = (int)Left + origin.X;
                tempY += (int)(Spacer + rowInfo[i].miniSize);
            }
        }
示例#28
0
        public override void UpdateLayout(List<Component> componentList, AssortedWidgets.Util.Position origin, AssortedWidgets.Util.Size area)
        {
            List<Component>.Enumerator clEnum = componentList.GetEnumerator();

            for (int i = 0; i < rowCount; ++i)
            {
                for (int e = 0; e < columnCount; ++e)
                {
                    if (clEnum.MoveNext())
                    {
                        alignment[i][e].component = clEnum.Current;
                        Size perfectSize = clEnum.Current.GetPreferedSize();
                        alignment[i][e].width = perfectSize.width;
                        alignment[i][e].height = perfectSize.height;
                        alignment[i][e].HStyle = ((IElement)clEnum.Current).HorizontalStyle;
                        alignment[i][e].VStyle = ((IElement)clEnum.Current).VerticalStyle;
                    }
                    else
                    {
                        alignment[i][e].component = null;
                        alignment[i][e].width = 0;
                        alignment[i][e].height = 0;
                        alignment[i][e].HStyle = EElementStyle.Fit;
                        alignment[i][e].VStyle = EElementStyle.Fit;
                    }
                }
            }
            OneLineInfo[] columnInfo = new OneLineInfo[columnCount];

            for (int e = 0; e < columnCount; ++e)
            {
                columnInfo[e].miniSize = 0;
                columnInfo[e].isStretch = false;
                for (int i = 0; i < rowCount; ++i)
                {
                    if (alignment[i][e].HStyle == EElementStyle.Stretch)
                    {
                        columnInfo[e].isStretch = true;
                    }
                    columnInfo[e].miniSize = Math.Max(columnInfo[e].miniSize, alignment[i][e].width);
                }
            }

            OneLineInfo[] rowInfo = new OneLineInfo[rowCount];

            for (int i = 0; i < rowCount; ++i)
            {
                rowInfo[i].miniSize = 0;
                rowInfo[i].isStretch = false;
                for (int e = 0; e < columnCount; ++e)
                {
                    if (alignment[i][e].VStyle == EElementStyle.Stretch)
                    {
                        rowInfo[i].isStretch = true;
                    }
                    rowInfo[i].miniSize = Math.Max(rowInfo[i].miniSize, alignment[i][e].height);
                }
            }

            int widthAvailable = (int)(area.width - (columnCount - 1) * Spacer - Left - Right);
            uint stretchSegment = 0;

            for (int e = 0; e < columnCount; ++e)
            {
                if (columnInfo[e].isStretch)
                {
                    ++stretchSegment;
                }
                else
                {
                    widthAvailable -= (int)columnInfo[e].miniSize;
                }
            }

            if (widthAvailable > 0)
            {
                if (stretchSegment > 0)
                {
                    uint averageWidth = (uint)widthAvailable / stretchSegment;

                    for (int e = 0; e < columnCount; ++e)
                    {
                        if (columnInfo[e].isStretch)
                        {
                            columnInfo[e].miniSize = Math.Max(columnInfo[e].miniSize, averageWidth);
                        }
                    }
                }
                else
                {
                    uint averageAppend = (uint)widthAvailable / columnCount;

                    for (int e = 0; e < columnCount; ++e)
                    {
                        columnInfo[e].miniSize += averageAppend;
                    }
                }
            }

            int heightAvailable = (int)(area.height - Top - Bottom - (rowCount - 1) * Spacer);
            stretchSegment = 0;

            for (int i = 0; i < rowCount; ++i)
            {
                if (rowInfo[i].isStretch)
                {
                    ++stretchSegment;
                }
                else
                {
                    heightAvailable -= (int)rowInfo[i].miniSize;
                }
            }

            if (heightAvailable > 0)
            {
                if (stretchSegment > 0)
                {
                    uint averageHeight = (uint)heightAvailable / stretchSegment;

                    for (int i = 0; i < rowCount; ++i)
                    {
                        if (rowInfo[i].isStretch)
                        {
                            rowInfo[i].miniSize = Math.Max(rowInfo[i].miniSize, averageHeight);
                        }
                    }
                }
                else
                {
                    uint averageAppend = (uint)heightAvailable / rowCount;
                    for (int i = 0; i < rowCount; ++i)
                    {
                        rowInfo[i].miniSize += averageAppend;
                    }
                }
            }

            int tempX = (int)Left + origin.X;
            int tempY = (int)Top + origin.Y;

            for (int i = 0; i < rowCount; ++i)
            {
                for (int e = 0; e < columnCount; ++e)
                {
                    Position CPosition = new Position(tempX, tempY);
                    Size Carea = new Size(columnInfo[e].miniSize, rowInfo[i].miniSize);
                    OrderComponent((uint)i, (uint)e, CPosition, Carea);
                    tempX += (int)(columnInfo[e].miniSize + Spacer);
                }
                tempX = (int)Left + origin.X;
                tempY += (int)(Spacer + rowInfo[i].miniSize);
            }
        }