Пример #1
0
        public override void setPos(Rectangle rc)
        {
            setPos0(rc);
            rc = mRectItem;

            // Adjust for inset
            rc.X     += mRectInset.X;
            rc.Y     += mRectInset.Y;
            rc.Width  = rc.Right - mRectInset.Right - rc.X;
            rc.Height = rc.Bottom - mRectInset.Bottom - rc.Y;

            for (int it = 0; it < mItems.Count; it++)
            {
                ControlUI pControl = mItems[it];
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    setFloatPos(it);
                    continue;
                }

                if (it != mCurSel)
                {
                    continue;
                }

                Rectangle rcPadding = pControl.getPadding();
                rc.X     += rcPadding.Left;
                rc.Y     += rcPadding.Top;
                rc.Width  = rc.Right - rcPadding.Right - rc.X;
                rc.Height = rc.Bottom - rcPadding.Bottom - rc.Y;

                Size szAvailable = new Size(rc.Right - rc.Left, rc.Bottom - rc.Top);

                Size sz = pControl.estimateSize(szAvailable);
                if (sz.Width == 0)
                {
                    sz.Width = Math.Max(0, szAvailable.Width);
                }
                if (sz.Width < pControl.getMinWidth())
                {
                    sz.Width = pControl.getMinWidth();
                }
                if (sz.Width > pControl.getMaxWidth())
                {
                    sz.Width = pControl.getMaxWidth();
                }

                if (sz.Height == 0)
                {
                    sz.Height = Math.Max(0, szAvailable.Height);
                }
                if (sz.Height < pControl.getMinHeight())
                {
                    sz.Height = pControl.getMinHeight();
                }
                if (sz.Height > pControl.getMaxHeight())
                {
                    sz.Height = pControl.getMaxHeight();
                }

                Rectangle rcCtrl = new Rectangle(rc.Left, rc.Top, sz.Width, sz.Height);
                pControl.setPos(rcCtrl);
            }
        }
Пример #2
0
        public override void setPos(Rectangle rc)
        {
            setPos0(rc);
            rc = mRectItem;

            // Adjust for inset
            int newLeft   = rc.Left + mRectInset.Left;
            int newTop    = rc.Top + mRectInset.Top;
            int newRight  = rc.Right - mRectInset.Right;
            int newBottom = rc.Bottom - mRectInset.Bottom;

            rc.X      = newLeft;
            rc.Width  = newRight - newLeft;
            rc.Y      = newTop;
            rc.Height = newBottom - newTop;

            if (mItems.Count == 0)
            {
                processScrollbar(rc, 0, 0);
                return;
            }

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                rc.Width -= mVerticalScrollbar.getFixedWidth();
            }
            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                rc.Height -= mHorizontalScrollbar.getFixedHeight();
            }

            // Determine the width of elements that are sizeable
            Size szAvailable = new Size(rc.Right - rc.Left, rc.Bottom - rc.Top);

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                szAvailable.Width += mHorizontalScrollbar.getScrollRange();
            }

            int nAdjustables = 0;
            int cxFixed      = 0;
            int nEstimateNum = 0;

            for (int it1 = 0; it1 < mItems.Count; it1++)
            {
                ControlUI pControl = (mItems[it1]);
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    continue;
                }
                Size sz = pControl.estimateSize(szAvailable);
                if (sz.Width == 0)
                {
                    nAdjustables++;
                }
                else
                {
                    if (sz.Width < pControl.getMinWidth())
                    {
                        sz.Width = pControl.getMinWidth();
                    }
                    if (sz.Width > pControl.getMaxWidth())
                    {
                        sz.Width = pControl.getMaxWidth();
                    }
                }
                cxFixed += sz.Width + pControl.getPadding().Left + pControl.getPadding().Right;
                nEstimateNum++;
            }
            cxFixed += (nEstimateNum - 1) * mChildPadding;

            int cxExpand = 0;

            if (nAdjustables > 0)
            {
                cxExpand = (0 - (szAvailable.Width - cxFixed) / nAdjustables) > 0 ? 0 : ((szAvailable.Width - cxFixed) / nAdjustables);
            }
            // Position the elements
            Size szRemaining = szAvailable;
            int  iPosX       = rc.Left;

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                iPosX -= mHorizontalScrollbar.getScrollPos();
            }
            int iAdjustable      = 0;
            int cxFixedRemaining = cxFixed;

            for (int it2 = 0; it2 < mItems.Count; it2++)
            {
                ControlUI pControl = (mItems[it2]);
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    setFloatPos(it2);
                    continue;
                }
                Rectangle rcPadding = pControl.getPadding();
                szRemaining.Width -= rcPadding.Left;
                Size sz = pControl.estimateSize(szRemaining);
                if (sz.Width == 0)
                {
                    iAdjustable++;
                    sz.Width = cxExpand;
                    // Distribute remaining to last element (usually round-off left-overs)
                    if (iAdjustable == nAdjustables)
                    {
                        sz.Width = (0 - (szRemaining.Width - rcPadding.Right - cxFixedRemaining)) > 0 ? 0 : szRemaining.Width - rcPadding.Right - cxFixedRemaining;
                    }
                    if (sz.Width < pControl.getMinWidth())
                    {
                        sz.Width = pControl.getMinWidth();
                    }
                    if (sz.Width > pControl.getMaxWidth())
                    {
                        sz.Width = pControl.getMaxWidth();
                    }
                }
                else
                {
                    if (sz.Width < pControl.getMinWidth())
                    {
                        sz.Width = pControl.getMinWidth();
                    }
                    if (sz.Width > pControl.getMaxWidth())
                    {
                        sz.Width = pControl.getMaxWidth();
                    }

                    cxFixedRemaining -= sz.Width;
                }

                sz.Height = (0 - (rc.Bottom - rc.Top - rcPadding.Top - rcPadding.Bottom)) > 0 ? 0 : rc.Bottom - rc.Top - rcPadding.Top - rcPadding.Bottom;

                if (sz.Height < pControl.getMinHeight())
                {
                    sz.Height = pControl.getMinHeight();
                }
                if (sz.Height > pControl.getMaxHeight())
                {
                    sz.Height = pControl.getMaxHeight();
                }

                Rectangle rcCtrl = new Rectangle(iPosX + rcPadding.Left,
                                                 rc.Top + rcPadding.Top,
                                                 sz.Width + rcPadding.Right,
                                                 sz.Height);

                pControl.setPos(rcCtrl);
                iPosX             += sz.Width + mChildPadding + rcPadding.Left + rcPadding.Right;
                szRemaining.Width -= sz.Width + mChildPadding + rcPadding.Right;
            }
        }
Пример #3
0
        public override void setPos(Rectangle rc)
        {
            setPos0(rc);
            rc = mRectItem;

            // Adjust for inset
            int newLeft   = rc.Left + mRectInset.Left;
            int newTop    = rc.Top + mRectInset.Top;
            int newRight  = rc.Right - mRectInset.Right;
            int newBottom = rc.Bottom - mRectInset.Bottom;

            rc.X      = newLeft;
            rc.Width  = newRight - newLeft;
            rc.Y      = newTop;
            rc.Height = newBottom - newTop;

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                rc.Width = rc.Right - mVerticalScrollbar.getFixedWidth() - rc.Left;
            }
            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                rc.Height = rc.Bottom - mHorizontalScrollbar.getFixedHeight() - rc.Top;
            }

            // 计算最小大小
            Size szAvailable = new Size(rc.Right - rc.Left, rc.Bottom - rc.Top);

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                szAvailable.Width += mHorizontalScrollbar.getScrollRange();
            }

            int cxNeeded     = 0;
            int nAdjustables = 0;
            int cyFixed      = 0;
            int nEstimateNum = 0;

            for (int it1 = 0; it1 < mItems.Count; it1++)
            {
                ControlUI pControl = mItems[it1];
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    continue;
                }
                Size sz = pControl.estimateSize(szAvailable);
                if (sz.Height == 0)
                {
                    nAdjustables++;
                }
                else
                {
                    if (sz.Height < pControl.getMinHeight())
                    {
                        sz.Height = pControl.getMinHeight();
                    }
                    if (sz.Height > pControl.getMaxHeight())
                    {
                        sz.Height = pControl.getMaxHeight();
                    }
                }
                cyFixed += sz.Height + pControl.getPadding().Top + pControl.getPadding().Bottom;

                Rectangle rcPadding = pControl.getPadding();
                sz.Width = Math.Max(sz.Width, 0);
                if (sz.Width < pControl.getMinWidth())
                {
                    sz.Width = pControl.getMinWidth();
                }
                if (sz.Width > pControl.getMaxWidth())
                {
                    sz.Width = pControl.getMaxWidth();
                }
                cxNeeded = Math.Max(cxNeeded, sz.Width);
                nEstimateNum++;
            }
            cyFixed += (nEstimateNum - 1) * mChildPadding;

            if (mOwner != null)
            {
                ListHeaderUI pHeader = mOwner.getHeader();
                if (pHeader != null && pHeader.getCount() > 0)
                {
                    cxNeeded = Math.Max(0, pHeader.estimateSize(new Size(rc.Right - rc.Left, rc.Bottom - rc.Top)).Width);
                }
            }

            // Place elements
            int cyNeeded = 0;
            int cyExpand = 0;

            if (nAdjustables > 0)
            {
                cyExpand = Math.Max(0, (szAvailable.Height - cyFixed) / nAdjustables);
            }
            // Position the elements
            Size szRemaining = szAvailable;
            int  iPosY       = rc.Top;

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                iPosY -= mVerticalScrollbar.getScrollPos();
            }
            int iPosX = rc.Left;

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                iPosX -= mHorizontalScrollbar.getScrollPos();
            }
            int iAdjustable      = 0;
            int cyFixedRemaining = cyFixed;

            for (int it2 = 0; it2 < mItems.Count; it2++)
            {
                ControlUI pControl = mItems[it2];
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    setFloatPos(it2);
                    continue;
                }

                Rectangle rcPadding = pControl.getPadding();
                szRemaining.Height -= rcPadding.Top;
                Size sz = pControl.estimateSize(szRemaining);
                if (sz.Height == 0)
                {
                    iAdjustable++;
                    sz.Height = cyExpand;
                    // Distribute remaining to last element (usually round-off left-overs)
                    if (iAdjustable == nAdjustables)
                    {
                        sz.Height = Math.Max(0, szRemaining.Height - rcPadding.Bottom - cyFixedRemaining);
                    }
                    if (sz.Height < pControl.getMinHeight())
                    {
                        sz.Height = pControl.getMinHeight();
                    }
                    if (sz.Height > pControl.getMaxHeight())
                    {
                        sz.Height = pControl.getMaxHeight();
                    }
                }
                else
                {
                    if (sz.Height < pControl.getMinHeight())
                    {
                        sz.Height = pControl.getMinHeight();
                    }
                    if (sz.Height > pControl.getMaxHeight())
                    {
                        sz.Height = pControl.getMaxHeight();
                    }
                    cyFixedRemaining -= sz.Height;
                }

                sz.Width = Math.Max(cxNeeded, szAvailable.Width - rcPadding.Left - rcPadding.Right);

                if (sz.Width < pControl.getMinWidth())
                {
                    sz.Width = pControl.getMinWidth();
                }
                if (sz.Width > pControl.getMaxWidth())
                {
                    sz.Width = pControl.getMaxWidth();
                }

                newLeft   = iPosX + rcPadding.Left;
                newRight  = iPosX + rcPadding.Left + sz.Width;
                newTop    = iPosY + rcPadding.Top;
                newBottom = iPosY + sz.Height + rcPadding.Top + rcPadding.Bottom;
                Rectangle rcCtrl = new Rectangle(newLeft,
                                                 newTop,
                                                 newRight - newLeft,
                                                 newBottom - newTop);
                pControl.setPos(rcCtrl);

                iPosY              += sz.Height + mChildPadding + rcPadding.Top + rcPadding.Bottom;
                cyNeeded           += sz.Height + rcPadding.Top + rcPadding.Bottom;
                szRemaining.Height -= sz.Height + mChildPadding + rcPadding.Bottom;
            }
            cyNeeded += (nEstimateNum - 1) * mChildPadding;

            if (mHorizontalScrollbar != null)
            {
                if (cxNeeded > rc.Right - rc.Left)
                {
                    if (mHorizontalScrollbar.isVisible())
                    {
                        mHorizontalScrollbar.setScrollRange(cxNeeded - (rc.Right - rc.Left));
                    }
                    else
                    {
                        mHorizontalScrollbar.setVisible(true);
                        mHorizontalScrollbar.setScrollRange(cxNeeded - (rc.Right - rc.Left));
                        mHorizontalScrollbar.setScrollPos(0);
                        newBottom = rc.Bottom - mHorizontalScrollbar.getFixedHeight();
                        rc.Height = newBottom - rc.Top;
                    }
                }
                else
                {
                    if (mHorizontalScrollbar.isVisible())
                    {
                        mHorizontalScrollbar.setVisible(false);
                        mHorizontalScrollbar.setScrollRange(0);
                        mHorizontalScrollbar.setScrollPos(0);
                        newBottom = rc.Bottom + mHorizontalScrollbar.getFixedHeight();
                        rc.Height = newBottom - rc.Top;
                    }
                }
            }

            // 计算滚动条大小
            processScrollbar(rc, cxNeeded, cyNeeded);
        }
Пример #4
0
        public void init(ComboUI pOwner)
        {
            mOwner          = pOwner;
            mVerticalLayout = null;
            mOldSel         = mOwner.getCurSel();

            // 使用显示器坐标显示组合控件窗口
            Size      szDrop  = mOwner.getDropBoxSize();
            Rectangle rcOwner = pOwner.getPos();
            Rectangle rc      = rcOwner;

            rc.Y      = rc.Bottom;
            rc.Height = szDrop.Height;

            if (szDrop.Width > 0)
            {
                rc.Width = rc.Left + szDrop.Width - rc.X;
            }

            Size szAvailable = new Size(rc.Right - rc.Left, rc.Bottom - rc.Top);
            int  cyFixed     = 0;

            for (int it = 0; it < pOwner.getCount(); it++)
            {
                ControlUI pControl = (ControlUI)pOwner.getItemAt(it);
                if (!pControl.isVisible())
                {
                    continue;
                }
                Size sz = pControl.estimateSize(szAvailable);
                cyFixed += sz.Height;
            }
            cyFixed  += 4; // CVerticalLayoutUI 默认的Inset 调整
            rc.Height = Math.Min(cyFixed, szDrop.Height);


            rc = mOwner.getManager().getPaintWindow().RectangleToScreen(rc);

            Rectangle rcMonitor = Screen.PrimaryScreen.Bounds;
            Rectangle rcWork    = Screen.PrimaryScreen.WorkingArea;

            rcWork.Offset(-rcWork.Left, -rcWork.Top);
            if (rc.Bottom > rcWork.Bottom)
            {
                rc.X     = rcOwner.X;
                rc.Width = rcOwner.Right - rc.X;
                if (szDrop.Width > 0)
                {
                    rc.Width = szDrop.Width;
                }
                rc.Y      = rcOwner.Y - Math.Min(cyFixed, szDrop.Height);
                rc.Height = rcOwner.Top - rc.Y;
                rc        = mOwner.getManager().getPaintWindow().RectangleToScreen(rc);
            }
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.ShowInTaskbar   = false;
            mRectClient          = rc;

            this.StartPosition = FormStartPosition.Manual;
            this.ClientSize    = new Size(rc.Width, rc.Height);
            this.Location      = new Point(rc.Left, rc.Top);
            this.TopMost       = true;

            this.Show();
        }
Пример #5
0
        public override void setPos(Rectangle rc)
        {
            setPos0(rc);

            rc = mRectItem;

            // mRectInset 为垂直布局控件的边界限制,在使用时,要忽略Right和Bottom属性,而使用Width和Height
            int newLeft   = rc.Left + mRectInset.Left;
            int newTop    = rc.Top + mRectInset.Top;
            int newRight  = rc.Right - mRectInset.Right;
            int newBottom = rc.Bottom - mRectInset.Bottom;

            rc.X      = newLeft;
            rc.Width  = newRight - newLeft;
            rc.Y      = newTop;
            rc.Height = newBottom - newTop;

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                newRight = rc.Right - mVerticalScrollbar.getFixedWidth();
                Rectangle newRect = new Rectangle(rc.Left, rc.Top, newRight - rc.Left, rc.Bottom - rc.Top);
                rc = newRect;
            }
            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                newBottom = rc.Bottom - mHorizontalScrollbar.getFixedHeight();
                Rectangle newRect = new Rectangle(rc.Left, rc.Top, rc.Width, newBottom - rc.Top);
                rc = newRect;
            }

            if (mItems.Count == 0)
            {
                processScrollbar(rc, 0, 0);
                return;
            }

            // Determine the minimum size
            Size szAvailable = new Size(rc.Right - rc.Left, rc.Bottom - rc.Top);

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                szAvailable.Width += mHorizontalScrollbar.getScrollRange();
            }

            int nAdjustables = 0;
            int cyFixed      = 0;
            int nEstimateNum = 0;

            for (int it1 = 0; it1 < mItems.Count; it1++)
            {
                ControlUI pControl = mItems[it1];
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    continue;
                }
                Size sz = pControl.estimateSize(szAvailable);
                if (sz.Height == 0)
                {
                    nAdjustables++;
                }
                else
                {
                    if (sz.Height < pControl.getMinHeight())
                    {
                        sz.Height = pControl.getMinHeight();
                    }
                    if (sz.Height > pControl.getMaxHeight())
                    {
                        sz.Height = pControl.getMaxHeight();
                    }
                }
                cyFixed += sz.Height + pControl.getPadding().Top + pControl.getPadding().Bottom;
                nEstimateNum++;
            }
            cyFixed += (nEstimateNum - 1) * mChildPadding;

            // Place elements
            int cyNeeded = 0;
            int cyExpand = 0;

            if (nAdjustables > 0)
            {
                cyExpand = (0 - (szAvailable.Height - cyFixed) / nAdjustables) > 0 ? 0 : (szAvailable.Height - cyFixed) / nAdjustables;
            }
            // Position the elements
            Size szRemaining = szAvailable;
            int  iPosY       = rc.Top;

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                iPosY -= mVerticalScrollbar.getScrollPos();
            }
            int iPosX = rc.Left;

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                iPosX -= mHorizontalScrollbar.getScrollPos();
            }
            int iAdjustable      = 0;
            int cyFixedRemaining = cyFixed;

            for (int it2 = 0; it2 < mItems.Count; it2++)
            {
                ControlUI pControl = (mItems[it2]);
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    setFloatPos(it2);
                    continue;
                }

                Rectangle rcPadding = pControl.getPadding();
                szRemaining.Height -= rcPadding.Top;
                Size sz = pControl.estimateSize(szRemaining);
                if (sz.Height == 0)
                {
                    iAdjustable++;
                    sz.Height = cyExpand;
                    // Distribute remaining to last element (usually round-off left-overs)
                    if (iAdjustable == nAdjustables)
                    {
                        sz.Height = (0 - szRemaining.Height - rcPadding.Bottom - cyFixedRemaining) > 0 ? 0 : szRemaining.Height - rcPadding.Bottom - cyFixedRemaining;
                    }
                    if (sz.Height < pControl.getMinHeight())
                    {
                        sz.Height = pControl.getMinHeight();
                    }
                    if (sz.Height > pControl.getMaxHeight())
                    {
                        sz.Height = pControl.getMaxHeight();
                    }
                }
                else
                {
                    if (sz.Height < pControl.getMinHeight())
                    {
                        sz.Height = pControl.getMinHeight();
                    }
                    if (sz.Height > pControl.getMaxHeight())
                    {
                        sz.Height = pControl.getMaxHeight();
                    }
                    cyFixedRemaining -= sz.Height;
                }

                sz.Width = (0 - szAvailable.Width - rcPadding.Left - rcPadding.Right) > 0 ? 0 : (szAvailable.Width - rcPadding.Left - rcPadding.Right);

                if (sz.Width < pControl.getMinWidth())
                {
                    sz.Width = pControl.getMinWidth();
                }
                if (sz.Width > pControl.getMaxWidth())
                {
                    sz.Width = pControl.getMaxWidth();
                }
                Rectangle rcCtrl = new Rectangle(iPosX + rcPadding.Left,
                                                 iPosY + rcPadding.Top,
                                                 iPosX + rcPadding.Left + sz.Width - (iPosX + rcPadding.Left),
                                                 iPosY + sz.Height + rcPadding.Top + rcPadding.Bottom - (iPosY + rcPadding.Top));

                pControl.setPos(rcCtrl);

                iPosY              += sz.Height + mChildPadding + rcPadding.Top + rcPadding.Bottom;
                cyNeeded           += sz.Height + rcPadding.Top + rcPadding.Bottom;
                szRemaining.Height -= sz.Height + mChildPadding + rcPadding.Bottom;
            }
            cyNeeded += (nEstimateNum - 1) * mChildPadding;

            // 计算滚动条大小
            processScrollbar(rc, 0, cyNeeded);
        }
Пример #6
0
        public override void setPos(Rectangle rc)
        {
            setPos0(rc);

            rc = mRectItem;

            // Adjust for inset
            rc.X     += mRectInset.Left;
            rc.Width  = rc.Right - mRectInset.Right - rc.X;
            rc.Y     += mRectInset.Top;
            rc.Height = rc.Bottom - mRectInset.Bottom - rc.Y;

            if (mItems.Count == 0)
            {
                processScrollbar(rc, 0, 0);
                return;
            }

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                rc.Width = rc.Right - mVerticalScrollbar.getFixedWidth() - rc.Left;
            }
            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                rc.Height = rc.Bottom - mHorizontalScrollbar.getFixedHeight() - rc.Top;
            }

            // Position the elements
            int cyNeeded = 0;
            int cxWidth  = (rc.Right - rc.Left) / mColumns;

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                cxWidth = (rc.Right - rc.Left + mHorizontalScrollbar.getScrollRange()) / mColumns;;
            }

            int   cyHeight = 0;
            int   iCount   = 0;
            Point ptTile   = new Point(rc.Left, rc.Top);

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                ptTile.Y -= mVerticalScrollbar.getScrollPos();
            }
            int iPosX = rc.Left;

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                iPosX   -= mHorizontalScrollbar.getScrollPos();
                ptTile.X = iPosX;
            }
            for (int it1 = 0; it1 < mItems.Count; it1++)
            {
                ControlUI pControl = mItems[it1];
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    setFloatPos(it1);
                    continue;
                }
                Rectangle rcPadding;
                Size      szAvailable;
                Size      szTile;
                // Determine size
                Rectangle rcTile = new Rectangle(ptTile.X, ptTile.Y, ptTile.X + cxWidth, ptTile.Y);
                if ((iCount % mColumns) == 0)
                {
                    int iIndex = iCount;
                    for (int it2 = it1; it2 < mItems.Count; it2++)
                    {
                        ControlUI pLineControl = mItems[it2];
                        if (!pLineControl.isVisible())
                        {
                            continue;
                        }
                        if (pLineControl.isFloat())
                        {
                            continue;
                        }

                        rcPadding   = pLineControl.getPadding();
                        szAvailable = new Size(rcTile.Right - rcTile.Left - rcPadding.Left - rcPadding.Right, 9999);
                        if (iIndex == iCount || (iIndex + 1) % mColumns == 0)
                        {
                            szAvailable.Width -= mChildPadding / 2;
                        }
                        else
                        {
                            szAvailable.Width -= mChildPadding;
                        }

                        if (szAvailable.Width < pControl.getMinWidth())
                        {
                            szAvailable.Width = pControl.getMinWidth();
                        }
                        if (szAvailable.Width > pControl.getMaxWidth())
                        {
                            szAvailable.Width = pControl.getMaxWidth();
                        }

                        szTile = pLineControl.estimateSize(szAvailable);
                        if (szTile.Width < pControl.getMinWidth())
                        {
                            szTile.Width = pControl.getMinWidth();
                        }
                        if (szTile.Width > pControl.getMaxWidth())
                        {
                            szTile.Width = pControl.getMaxWidth();
                        }
                        if (szTile.Height < pControl.getMinHeight())
                        {
                            szTile.Height = pControl.getMinHeight();
                        }
                        if (szTile.Height > pControl.getMaxHeight())
                        {
                            szTile.Height = pControl.getMaxHeight();
                        }

                        cyHeight = Math.Max(cyHeight, szTile.Height + rcPadding.Top + rcPadding.Bottom);
                        if ((++iIndex % mColumns) == 0)
                        {
                            break;
                        }
                    }
                }

                rcPadding = pControl.getPadding();

                rcTile.X    += rcPadding.X + mChildPadding / 2;
                rcTile.Width = rcTile.Right - (rcPadding.Right + mChildPadding / 2) - rcTile.X;

                if ((iCount % mColumns) == 0)
                {
                    rcTile.X -= mChildPadding / 2;
                }

                if (((iCount + 1) % mColumns) == 0)
                {
                    rcTile.Width = rcTile.Right + mChildPadding / 2 - rcTile.X;
                }

                // Set position
                rcTile.Y      = ptTile.Y + rcPadding.Top;
                rcTile.Height = ptTile.Y + cyHeight - rcTile.Y;

                szAvailable = new Size(rcTile.Right - rcTile.Left, rcTile.Bottom - rcTile.Top);
                szTile      = pControl.estimateSize(szAvailable);
                if (szTile.Width == 0)
                {
                    szTile.Width = szAvailable.Width;
                }
                if (szTile.Height == 0)
                {
                    szTile.Height = szAvailable.Height;
                }
                if (szTile.Width < pControl.getMinWidth())
                {
                    szTile.Width = pControl.getMinWidth();
                }
                if (szTile.Width > pControl.getMaxWidth())
                {
                    szTile.Width = pControl.getMaxWidth();
                }
                if (szTile.Height < pControl.getMinHeight())
                {
                    szTile.Height = pControl.getMinHeight();
                }
                if (szTile.Height > pControl.getMaxHeight())
                {
                    szTile.Height = pControl.getMaxHeight();
                }
                Rectangle rcPos = new Rectangle((rcTile.Left + rcTile.Right - szTile.Width) / 2, (rcTile.Top + rcTile.Bottom - szTile.Height) / 2,
                                                (rcTile.Left + rcTile.Right - szTile.Width) / 2 + szTile.Width, (rcTile.Top + rcTile.Bottom - szTile.Height) / 2 + szTile.Height);
                pControl.setPos(rcPos);

                if ((++iCount % mColumns) == 0)
                {
                    ptTile.X  = iPosX;
                    ptTile.Y += cyHeight + mChildPadding;
                    cyHeight  = 0;
                }
                else
                {
                    ptTile.X += cxWidth;
                }
                cyNeeded = rcTile.Bottom - rc.Top;
                if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
                {
                    cyNeeded += mVerticalScrollbar.getScrollPos();
                }
            }

            // 计算滚动条大小
            processScrollbar(rc, 0, cyNeeded);
        }