示例#1
0
        public virtual void setFloatPos(int iIndex)
        {
            lock (lockObj)
            {
                // 因为CControlUI::SetPos对float的操作影响,这里不能对float组件添加滚动条的影响
                if (iIndex < 0 || iIndex >= mItems.Count)
                {
                    return;
                }

                ControlUI pControl = mItems[iIndex];

                if (!pControl.isVisible())
                {
                    return;
                }
                if (!pControl.isFloat())
                {
                    return;
                }

                Size      szXY   = pControl.getFixedXY();
                Size      sz     = new Size(pControl.getFixedWidth(), pControl.getFixedHeight());
                Rectangle rcCtrl = new Rectangle();
                int       right  = 0;
                int       bottom = 0;
                if (szXY.Width >= 0)
                {
                    rcCtrl.X = mRectItem.Left + szXY.Width;
                    right    = mRectItem.Left + szXY.Width + sz.Width;
                }
                else
                {
                    rcCtrl.X = mRectItem.Right + szXY.Width - sz.Width;
                    right    = mRectItem.Right + szXY.Width;
                }
                if (szXY.Height >= 0)
                {
                    rcCtrl.Y = mRectItem.Top + szXY.Height;
                    bottom   = mRectItem.Top + szXY.Height + sz.Height;
                }
                else
                {
                    rcCtrl.Y = mRectItem.Bottom + szXY.Height - sz.Height;
                    bottom   = mRectItem.Bottom + szXY.Height;
                }
                rcCtrl = new Rectangle(rcCtrl.X, rcCtrl.Y, right - rcCtrl.X, bottom - rcCtrl.Y);
                pControl.setPos(rcCtrl);
            }
        }