Пример #1
0
        public void ensureVisible(int iIndex)
        {
            if (mOwner.getCurSel() < 0)
            {
                return;
            }
            mVerticalLayout.findSelectable(mOwner.getCurSel(), false);
            Rectangle   rcItem = mVerticalLayout.getItemAt(iIndex).getPos();
            Rectangle   rcList = mVerticalLayout.getPos();
            ScrollbarUI pHorizontalScrollbar = mVerticalLayout.getHorizontalScrollbar();

            if (pHorizontalScrollbar != null && pHorizontalScrollbar.isVisible())
            {
                rcList.Height = rcList.Bottom - pHorizontalScrollbar.getFixedHeight() - rcList.Top;
            }
            int iPos = mVerticalLayout.getScrollPos().Height;

            if (rcItem.Top >= rcList.Top && rcItem.Bottom < rcList.Bottom)
            {
                return;
            }
            int dx = 0;

            if (rcItem.Top < rcList.Top)
            {
                dx = rcItem.Top - rcList.Top;
            }
            if (rcItem.Bottom > rcList.Bottom)
            {
                dx = rcItem.Bottom - rcList.Bottom;
            }
            scroll(0, dx);
        }
Пример #2
0
        public virtual void enableScrollBar(bool bEnableVertical = true, bool bEnableHorizontal = false)
        {
            if (bEnableVertical && mVerticalScrollbar == null)
            {
                mVerticalScrollbar = new ScrollbarUI();
                mVerticalScrollbar.setOwner(this);
                mVerticalScrollbar.setManager(mManager, null);
                if (mManager != null)
                {
                    string pDefaultAttributes = mManager.getDefaultAttributeList("VScrollBar");
                    if (pDefaultAttributes != "")
                    {
                        mVerticalScrollbar.applyAttributeList(pDefaultAttributes);
                    }
                }
            }
            else if (!bEnableVertical && mVerticalScrollbar != null)
            {
                mVerticalScrollbar = null;
            }

            if (bEnableHorizontal && mHorizontalScrollbar == null)
            {
                mHorizontalScrollbar = new ScrollbarUI();
                mHorizontalScrollbar.setHorizontal(true);
                mHorizontalScrollbar.setOwner(this);
                mHorizontalScrollbar.setManager(mManager, null);
                if (mManager != null)
                {
                    string pDefaultAttributes = mManager.getDefaultAttributeList("HScrollBar");
                    if (pDefaultAttributes != "")
                    {
                        mHorizontalScrollbar.applyAttributeList(pDefaultAttributes);
                    }
                }
            }
            else if (!bEnableHorizontal && mHorizontalScrollbar != null)
            {
                mHorizontalScrollbar = null;
            }

            needUpdate();
        }
Пример #3
0
        public void ensureVisible(int iIndex)
        {
            if (mCurSel < 0)
            {
                return;
            }
            Rectangle rcItem      = mList.getItemAt(iIndex).getPos();
            Rectangle rcList      = mList.getPos();
            Rectangle rcListInset = mList.getInset();

            rcList.X     += rcListInset.X;
            rcList.Width  = rcList.Right - rcListInset.Right - rcList.X;
            rcList.Y     += rcListInset.Y;
            rcList.Height = rcList.Bottom - rcListInset.Bottom - rcList.Y;

            ScrollbarUI pHorizontalScrollbar = mList.getHorizontalScrollbar();

            if (pHorizontalScrollbar != null && pHorizontalScrollbar.isVisible())
            {
                rcList.Height = rcList.Bottom - pHorizontalScrollbar.getFixedHeight() - rcList.Top;
            }

            int iPos = mList.getScrollPos().Height;

            if (rcItem.Top >= rcList.Top && rcItem.Bottom < rcList.Bottom)
            {
                return;
            }
            int dx = 0;

            if (rcItem.Top < rcList.Top)
            {
                dx = rcItem.Top - rcList.Top;
            }
            if (rcItem.Bottom > rcList.Bottom)
            {
                dx = rcItem.Bottom - rcList.Bottom;
            }

            scroll(0, dx);
        }
Пример #4
0
        public override void invalidate()
        {
            if (!isVisible())
            {
                return;
            }

            if (getParent() != null)
            {
                ContainerUI pParentContainer = (ContainerUI)getParent().getInterface("Container");
                if (pParentContainer != null)
                {
                    Rectangle rc      = pParentContainer.getPos();
                    Rectangle rcInset = pParentContainer.getInset();

                    int newLeft   = rc.Left + rcInset.Left;
                    int newRight  = rc.Right - rcInset.Right;
                    int newTop    = rc.Top + rcInset.Top;
                    int newBottom = rc.Bottom - rcInset.Bottom;
                    rc.X      = newLeft;
                    rc.Width  = newRight - newLeft;
                    rc.Y      = newTop;
                    rc.Height = newBottom - newTop;

                    ScrollbarUI pVerticalScrollbar = pParentContainer.getVerticalScrollbar();
                    if (pVerticalScrollbar != null && pVerticalScrollbar.isVisible())
                    {
                        rc.Width = rc.Right - pVerticalScrollbar.getFixedWidth() - rc.Left;
                    }
                    ScrollbarUI pHorizontalScrollbar = pParentContainer.getHorizontalScrollbar();
                    if (pHorizontalScrollbar != null && pHorizontalScrollbar.isVisible())
                    {
                        rc.Height = rc.Bottom - pHorizontalScrollbar.getFixedHeight() - rc.Top;
                    }

                    Rectangle invalidateRc = mRectItem;
                    if (!invalidateRc.IntersectsWith(mRectItem))
                    {
                        return;
                    }
                    invalidateRc.Intersect(mRectItem);

                    ControlUI pParent = getParent();
                    Rectangle rcTemp;
                    Rectangle rcParent;
                    while ((pParent = pParent.getParent()) != null)
                    {
                        rcTemp   = invalidateRc;
                        rcParent = pParent.getPos();
                        if (!rcTemp.IntersectsWith(rcParent))
                        {
                            return;
                        }
                        invalidateRc.Intersect(rcParent);
                    }

                    if (mManager != null)
                    {
                        mManager.invalidate(ref invalidateRc);
                    }
                }
                else
                {
                    base.invalidate();
                }
            }
            else
            {
                base.invalidate();
            }
        }