예제 #1
0
파일: ListUI.cs 프로젝트: weimingtom/QUILib
        public override void setPos(Rectangle rc)
        {
            base.setPos(rc);

            if (mHeader == null)
            {
                return;
            }
            // Determine general list information and the size of header columns
            mListInfo.mColumns = Math.Min(mHeader.getCount(), UILIST_MAX_COLUMNS);
            // The header/columns may or may not be visible at runtime. In either case
            // we should determine the correct dimensions...

            if (!mHeader.isVisible())
            {
                mHeader.setInternVisible(true);
                mHeader.setPos(new Rectangle(rc.Left, 0, rc.Width, 0));
            }
            int iOffset = mList.getScrollPos().Width;

            for (int i = 0; i < mListInfo.mColumns; i++)
            {
                ControlUI pControl = (ControlUI)mHeader.getItemAt(i);
                if (!pControl.isVisible())
                {
                    continue;
                }
                if (pControl.isFloat())
                {
                    continue;
                }

                Rectangle rcPos = pControl.getPos();
                if (iOffset > 0)
                {
                    int newLeft  = rcPos.X - iOffset;
                    int newRight = rcPos.Right - iOffset;
                    rcPos.X     = newLeft;
                    rcPos.Width = newRight - newLeft;
                    pControl.setPos(rcPos);
                }
                mListInfo.mListColumn[i] = pControl.getPos();
            }
            if (!mHeader.isVisible())
            {
                mHeader.setInternVisible(false);
            }
        }
예제 #2
0
        public virtual void invalidate()
        {
            if (isVisible() == false)
            {
                return;
            }

            Rectangle invalidateRc = mRectItem;

            ControlUI parent = this;
            Rectangle rcTtemp;
            Rectangle rcParent;

            while ((parent = parent.getParent()) != null)
            {
                rcTtemp  = invalidateRc;
                rcParent = parent.getPos();
                if (rcTtemp.IntersectsWith(rcParent) == true)
                {
                    invalidateRc.Intersect(rcParent);
                }
                else
                {
                    return;
                }
            }

            if (mManager != null)
            {
                mManager.invalidate(ref invalidateRc);
            }
        }
예제 #3
0
        public override void paintText(ref Graphics graphics, ref Bitmap bitmap)
        {
            Rectangle rcText    = mRectItem;
            int       newLeft   = rcText.Left + mTextPadding.Left;
            int       newRight  = rcText.Right - mTextPadding.Right;
            int       newTop    = rcText.Top + mTextPadding.Top;
            int       newBottom = rcText.Bottom - mTextPadding.Bottom;

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

            if (mCurSel >= 0)
            {
                ControlUI   pControl = (ControlUI)mItems[mCurSel];
                IListItemUI pElement = (IListItemUI)pControl.getInterface("ListItem");
                if (pElement != null)
                {
                    pElement.drawItemText(ref graphics, ref bitmap, ref rcText);
                }
                else
                {
                    Rectangle rcOldPos = pControl.getPos();
                    pControl.setPos(rcText);
                    pControl.doPaint(ref graphics, ref bitmap, rcText);
                    pControl.setPos(rcOldPos);
                }
            }
        }
예제 #4
0
        public virtual void setScrollPos(Size szPos)
        {
            int cx = 0;
            int cy = 0;

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                int iLastScrollPos = mVerticalScrollbar.getScrollPos();
                mVerticalScrollbar.setScrollPos(szPos.Height);
                cy = mVerticalScrollbar.getScrollPos() - iLastScrollPos;
            }

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                int iLastScrollPos = mHorizontalScrollbar.getScrollPos();
                mHorizontalScrollbar.setScrollPos(szPos.Width);
                cx = mHorizontalScrollbar.getScrollPos() - iLastScrollPos;
            }

            if (cx == 0 && cy == 0)
            {
                return;
            }

            Rectangle rcPos;

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

                rcPos = pControl.getPos();
                int       newLeft   = rcPos.Left - cx;
                int       newRight  = rcPos.Right - cx;
                int       newTop    = rcPos.Top - cy;
                int       newBottom = rcPos.Bottom - cy;
                Rectangle newRect   = new Rectangle(newLeft, newTop, newRight - newLeft, newBottom - newTop);
                pControl.setPos(newRect);
            }

            invalidate();
        }
예제 #5
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();
            }
        }
예제 #6
0
        protected void setPos0(Rectangle rc)
        {
            if (rc.Right < rc.Left)
            {
                int left = rc.Left;
                rc.Width = 0;
                rc.X     = left;
            }
            if (rc.Bottom < rc.Top)
            {
                int top = rc.Top;
                rc.Height = 0;
                rc.Y      = top;
            }

            Rectangle invalidateRc = mRectItem;

            if (invalidateRc.IsEmpty)
            {
                invalidateRc = rc;
            }

            mRectItem = rc;
            if (mManager == null)
            {
                return;
            }
            ControlUI pParent = null;

            if (mFloat)
            {
                if (!mFloatSetPos)
                {
                    mFloatSetPos = true;
                    mManager.sendNotify(this, "setpos");
                    mFloatSetPos = false;
                }

                pParent = getParent();
                if (pParent != null)
                {
                    Rectangle rcParentPos = pParent.getPos();
                    if (mXY.Width >= 0)
                    {
                        mXY.Width = mRectItem.Left - rcParentPos.Left;
                    }
                    else
                    {
                        mXY.Width = mRectItem.Right - rcParentPos.Right;
                    }

                    if (mXY.Height >= 0)
                    {
                        mXY.Height = mRectItem.Top - rcParentPos.Top;
                    }
                    else
                    {
                        mXY.Height = mRectItem.Bottom - rcParentPos.Bottom;
                    }
                }
            }

            mUpdateNeeded = false;

            // NOTE: SetPos() is usually called during the WM_PAINT cycle where all controls are
            //       being laid out. Calling UpdateLayout() again would be wrong. Refreshing the
            //       window won't hurt (if we're already inside WM_PAINT we'll just validate it out).
            invalidateRc.Intersect(mRectItem);

            pParent = this;
            Rectangle rcTemp;
            Rectangle rcParent;

            while ((pParent = pParent.getParent()) != null)
            {
                rcTemp   = invalidateRc;
                rcParent = pParent.getPos();
                if (rcTemp.IntersectsWith(rcParent) == false)
                {
                    rcTemp.Intersect(rcParent);
                    invalidateRc.Intersect(rcTemp);
                }
                else
                {
                    return;
                }
            }
            mManager.invalidate(ref invalidateRc);
        }
예제 #7
0
파일: ListUI.cs 프로젝트: weimingtom/QUILib
        public override void doPaint(ref Graphics graphics, ref Bitmap bitmap, Rectangle rectPaint)
        {
            Rectangle rcTemp;

            if (rectPaint.IntersectsWith(mRectItem) == false)
            {
                return;
            }
            rcTemp = rectPaint;
            rcTemp.Intersect(mRectItem);

            RenderClip clip = new RenderClip();

            RenderClip.generateClip(ref graphics, rcTemp, ref clip);

            base.doPaint(ref graphics, ref bitmap, rectPaint);

            if (mItems.Count > 0)
            {
                Rectangle rc        = mRectItem;
                int       newLeft   = rc.Left + mRectInset.Left;
                int       newRight  = rc.Right - mRectInset.Right;
                int       newTop    = rc.Top + mRectInset.Top;
                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;
                }

                // 绘制子控件
                if (rectPaint.IntersectsWith(rc) == false)
                {
                    for (int i = mItems.Count - 1; i >= 0; i--)
                    {
                        ControlUI item = mItems[i];
                        if (item.isVisible() == false)
                        {
                            continue;
                        }
                        if (rectPaint.IntersectsWith(item.getPos()) == false)
                        {
                            continue;
                        }
                        if (item.isFloat())
                        {
                            if (mRectItem.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            item.doPaint(ref graphics, ref bitmap, rectPaint);
                        }
                    }
                }
                else
                {
                    RenderClip childClip = new RenderClip();
                    RenderClip.generateClip(ref graphics, rcTemp, ref childClip);

                    for (int i = mItems.Count - 1; i >= 0; i--)
                    {
                        ControlUI item = mItems[i];
                        if (item.isVisible() == false)
                        {
                            continue;
                        }
                        if (rectPaint.IntersectsWith(item.getPos()) == false)
                        {
                            continue;
                        }
                        if (item.isFloat())
                        {
                            if (mRectItem.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            RenderClip.useOldClipBegin(ref graphics, ref childClip);
                            item.doPaint(ref graphics, ref bitmap, rectPaint);
                            RenderClip.useOldClipEnd(ref graphics, ref childClip);
                        }
                        else
                        {
                            if (rc.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            item.doPaint(ref graphics, ref bitmap, rectPaint);
                        }
                    }
                }
            }

            if (mVerticalScrollbar != null &&
                mVerticalScrollbar.isVisible())
            {
                if (rectPaint.IntersectsWith(mVerticalScrollbar.getPos()))
                {
                    mVerticalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                }
            }

            if (mHorizontalScrollbar != null &&
                mHorizontalScrollbar.isVisible())
            {
                if (rectPaint.IntersectsWith(mHorizontalScrollbar.getPos()))
                {
                    mHorizontalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                }
            }
        }
예제 #8
0
        public override void setScrollPos(Size szPos)
        {
            int cx = 0;
            int cy = 0;

            if (mVerticalScrollbar != null && mVerticalScrollbar.isVisible())
            {
                int iLastScrollPos = mVerticalScrollbar.getScrollPos();
                mVerticalScrollbar.setScrollPos(szPos.Height);
                cy = mVerticalScrollbar.getScrollPos() - iLastScrollPos;
            }

            if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
            {
                int iLastScrollPos = mHorizontalScrollbar.getScrollPos();
                mHorizontalScrollbar.setScrollPos(szPos.Width);
                cx = mHorizontalScrollbar.getScrollPos() - iLastScrollPos;
            }

            if (cx == 0 && cy == 0)
            {
                return;
            }

            Rectangle rcPos;

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

                rcPos = pControl.getPos();
                int newLeft   = rcPos.Left - cx;
                int newRight  = rcPos.Right - cx;
                int newTop    = rcPos.Top - cy;
                int newBottom = rcPos.Bottom - cy;

                rcPos.X      = newLeft;
                rcPos.Width  = newRight - newLeft;
                rcPos.Y      = newTop;
                rcPos.Height = newBottom - newTop;
                pControl.setPos(rcPos);
            }

            invalidate();

            if (cx != 0 && mOwner != null)
            {
                ListHeaderUI pHeader = mOwner.getHeader();
                if (pHeader == null)
                {
                    return;
                }
                TListInfoUI pInfo = mOwner.getListInfo();
                pInfo.mColumns = Math.Min(pHeader.getCount(), ListUI.UILIST_MAX_COLUMNS);

                if (!pHeader.isVisible())
                {
                    pHeader.setInternVisible(true);
                }
                for (int i = 0; i < pInfo.mColumns; i++)
                {
                    ControlUI pControl = pHeader.getItemAt(i);
                    if (!pControl.isVisible())
                    {
                        continue;
                    }
                    if (pControl.isFloat())
                    {
                        continue;
                    }

                    Rectangle rcPos1   = pControl.getPos();
                    int       newLeft  = rcPos1.Left - cx;
                    int       newRight = rcPos1.Right - cx;
                    rcPos1.X     = newLeft;
                    rcPos1.Width = newRight - newLeft;
                    pControl.setPos(rcPos1);
                    pInfo.mListColumn[i] = pControl.getPos();
                }
                if (!pHeader.isVisible())
                {
                    pHeader.setInternVisible(false);
                }
            }
        }
예제 #9
0
        public override void doPaint(ref Graphics graphics, ref Bitmap bitmap, Rectangle rectPaint)
        {
            lock (lockObj)
            {
                Rectangle rcTemp = rectPaint;
                rcTemp.Intersect(mRectItem);
                if (rcTemp.IsEmpty == true)
                {
                    return;
                }
                Region oldRgn = graphics.Clip.Clone();
                graphics.IntersectClip(rcTemp);

                base.doPaint(ref graphics, ref bitmap, rectPaint);

                if (mItems.Count > 0)
                {
                    Rectangle rc        = mRectItem;
                    int       newLeft   = rc.Left + mRectInset.Left;
                    int       newRight  = rc.Right - mRectInset.Right;
                    int       newTop    = rc.Top + mRectInset.Top;
                    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 -= mVerticalScrollbar.getFixedWidth();
                    }
                    if (mHorizontalScrollbar != null && mHorizontalScrollbar.isVisible())
                    {
                        rc.Height -= mHorizontalScrollbar.getFixedHeight();
                    }

                    // 绘制子控件
                    rcTemp = rectPaint;
                    rcTemp.Intersect(rc);
                    if (rcTemp.IsEmpty == true)
                    {
                        foreach (var item in mItems)
                        {
                            if (item.isVisible() == false)
                            {
                                continue;
                            }
                            if (rectPaint.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            if (item.isFloat())
                            {
                                if (mRectItem.IntersectsWith(item.getPos()) == false)
                                {
                                    continue;
                                }
                                item.doPaint(ref graphics, ref bitmap, rectPaint);
                            }
                        }
                    }
                    else
                    {
                        Region oldRgn1 = graphics.Clip.Clone();
                        graphics.IntersectClip(rcTemp);

                        for (int i = 0; i < mItems.Count; i++)
                        {
                            ControlUI item = mItems[i];
                            if (item.isVisible() == false)
                            {
                                continue;
                            }
                            if (rectPaint.IntersectsWith(item.getPos()) == false)
                            {
                                continue;
                            }
                            if (item.isFloat())
                            {
                                if (mRectItem.IntersectsWith(item.getPos()) == false)
                                {
                                    continue;
                                }
                                Region oldRgn2 = graphics.Clip;
                                graphics.Clip = oldRgn1;
                                item.doPaint(ref graphics, ref bitmap, rectPaint);
                                graphics.Clip = oldRgn2;
                            }
                            else
                            {
                                if (rc.IntersectsWith(item.getPos()) == false)
                                {
                                    continue;
                                }
                                item.doPaint(ref graphics, ref bitmap, rectPaint);
                            }
                        }
                        graphics.Clip = oldRgn1;
                    }
                }

                if (mVerticalScrollbar != null &&
                    mVerticalScrollbar.isVisible())
                {
                    if (rectPaint.IntersectsWith(mVerticalScrollbar.getPos()))
                    {
                        mVerticalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                    }
                }

                if (mHorizontalScrollbar != null &&
                    mHorizontalScrollbar.isVisible())
                {
                    if (rectPaint.IntersectsWith(mHorizontalScrollbar.getPos()))
                    {
                        mHorizontalScrollbar.doPaint(ref graphics, ref bitmap, rectPaint);
                    }
                }
                graphics.Clip = oldRgn;
            }
        }