Пример #1
0
        public override int getItemIndex(ControlUI pControl)
        {
            if (pControl.getInterface("ListHeader") != null)
            {
                return(base.getItemIndex(pControl));
            }
            // We also need to recognize header sub-items
            if (pControl.getClass() == "ListHeaderItemUI")
            {
                return(mHeader.getItemIndex(pControl));
            }

            return(mList.getItemIndex(pControl));
        }
Пример #2
0
        public override bool setItemIndex(ControlUI pControl, int iIndex)
        {
            if (pControl.getInterface("ListHeader") != null)
            {
                return(base.setItemIndex(pControl, iIndex));
            }
            // We also need to recognize header sub-items
            if (pControl.getClass() == "ListHeaderItemUI")
            {
                return(mHeader.setItemIndex(pControl, iIndex));
            }

            int iOrginIndex = mList.getItemIndex(pControl);

            if (iOrginIndex == -1)
            {
                return(false);
            }

            if (!mList.setItemIndex(pControl, iIndex))
            {
                return(false);
            }

            // The list items should know about us
            IListItemUI pListItem = (IListItemUI)pControl.getInterface("ListItem");

            if (pListItem != null)
            {
                pListItem.setIndex(getCount());
            }

            for (int i = iOrginIndex; i < mList.getCount(); ++i)
            {
                ControlUI p = mList.getItemAt(i);
                pListItem = (IListItemUI)(p.getInterface("ListItem"));
                if (pListItem != null)
                {
                    pListItem.setIndex(pListItem.getIndex() - 1);
                }
            }

            selectItem(findSelectable(mCurSel, false));
            ensureVisible(mCurSel);

            return(true);
        }
Пример #3
0
        public override bool addAt(ControlUI pControl, int iIndex)
        {
            // Override the AddAt() method so we can add items specifically to
            // the intended widgets. Headers and are assumed to be
            // answer the correct interface so we can add multiple list headers.
            if (pControl.getInterface("ListHeader") != null)
            {
                return(base.addAt(pControl, iIndex));
            }
            // We also need to recognize header sub-items
            if (pControl.getClass() == "ListHeaderItemUI")
            {
                return(mHeader.addAt(pControl, iIndex));
            }

            if (!mList.addAt(pControl, iIndex))
            {
                return(false);
            }

            // The list items should know about us
            IListItemUI pListItem = (IListItemUI)pControl.getInterface("ListItem");

            if (pListItem != null)
            {
                pListItem.setOwner(this);
                pListItem.setIndex(iIndex);
            }

            for (int i = iIndex + 1; i < mList.getCount(); ++i)
            {
                ControlUI p = mList.getItemAt(i);
                pListItem = (IListItemUI)p.getInterface("ListItem");
                if (pListItem != null)
                {
                    pListItem.setIndex(pListItem.getIndex() + 1);
                }
            }
            return(true);
        }
Пример #4
0
        public override bool remove(ControlUI pControl)
        {
            if (pControl.getInterface("ListHeader") != null)
            {
                return(base.remove(pControl));
            }
            // We also need to recognize header sub-items
            if (pControl.getClass() == "ListHeaderItemUI")
            {
                return(mHeader.remove(pControl));
            }

            int iIndex = mList.getItemIndex(pControl);

            if (iIndex == -1)
            {
                return(false);
            }

            if (!mList.removeAt(iIndex))
            {
                return(false);
            }

            for (int i = iIndex; i < mList.getCount(); ++i)
            {
                ControlUI   p         = mList.getItemAt(i);
                IListItemUI pListItem = (IListItemUI)p.getInterface("ListItem");
                if (pListItem != null)
                {
                    pListItem.setIndex(pListItem.getIndex() - 1);
                }
            }

            selectItem(findSelectable(mCurSel, false));
            ensureVisible(mCurSel);

            return(true);
        }
Пример #5
0
        public override bool add(ControlUI pControl)
        {
            // Override the Add() method so we can add items specifically to
            // the intended widgets. Headers are assumed to be
            // answer the correct interface so we can add multiple list headers.
            if (pControl.getInterface("ListHeader") != null)
            {
                if (mHeader != pControl && mHeader.getCount() == 0)
                {
                    {
                        // 把旧的表头控件属性赋予到新的表头控件
                        pControl.setBackImage(mHeader.getBackImage());
                        pControl.setVisible(mHeader.isVisible());
                    }
                    base.remove(mHeader);
                    mHeader = null;
                    mHeader = (ListHeaderUI)(pControl);
                }

                return(base.addAt(pControl, 0));
            }
            // We also need to recognize header sub-items
            if (pControl.getClass() == "ListHeaderItemUI")
            {
                return(mHeader.add(pControl));
            }
            // The list items should know about us
            IListItemUI pListItem = (IListItemUI)pControl.getInterface("ListItem");

            if (pListItem != null)
            {
                pListItem.setOwner(this);
                pListItem.setIndex(getCount());
            }
            return(mList.add(pControl));
        }
Пример #6
0
        public bool onMessageHandle(int uMsg, ref object wParam, ref object lParam, ref int lRes)
        {
            if (uMsg == (int)WindowMessage.WM_CREATE)
            {
                Form frm = this;
                mManager.init(ref frm);
                // 给下拉列表子控件树重新设置父容器以及资源管理器,在组合框窗口关闭后需要还原该子树控件的父容器以及资源管理器
                mVerticalLayout = new VerticalLayoutUI();
                mManager.useParentResource(mOwner.getManager());
                mVerticalLayout.setManager(mManager, null);
                string pDefaultAttributes = mOwner.getManager().getDefaultAttributeList("VerticalLayout");
                if (pDefaultAttributes != "")
                {
                    mVerticalLayout.applyAttributeList(pDefaultAttributes);
                }
                mVerticalLayout.setInset(new Rectangle(2, 2, 0, 0));
                mVerticalLayout.setBackColor(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF));
                mVerticalLayout.setBorderColor(Color.FromArgb(0xFF, 0x85, 0xE4, 0xFF));
                mVerticalLayout.setBorderSize(2);
                mVerticalLayout.setAutoDestroy(false);
                mVerticalLayout.enableScrollBar();
                mVerticalLayout.applyAttributeList(mOwner.getDropBoxAttributeList());
                for (int i = 0; i < mOwner.getCount(); i++)
                {
                    mVerticalLayout.add((ControlUI)mOwner.getItemAt(i));
                }
                ControlUI rootNode = (ControlUI)mVerticalLayout;
                mManager.attachDialog(ref rootNode);

                this.ClientSize = new Size(mRectClient.Width, mRectClient.Height);

                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_SIZE)
            {
                this.ClientSize = new Size(mRectClient.Width, mRectClient.Height);

                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_ERASEBKGND)
            {
                lRes = 1;

                return(true);
            }

            else if (uMsg == (int)WindowMessage.WM_CLOSE)
            {
                mOwner.setManager(mOwner.getManager(), mOwner.getParent());
                mOwner.setPos(mOwner.getPos());
                mOwner.setFocus();
            }
            else if (uMsg == (int)WindowMessage.WM_LBUTTONUP)
            {
                Point pt = Control.MousePosition;
                pt = mManager.getPaintWindow().PointToClient(pt);
                ControlUI pControl = mManager.findControl(ref pt);
                if (pControl != null && pControl.getClass() != "ScrollbarUI")
                {
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);
                }
            }

            else if (uMsg == (int)WindowMessage.WM_KEYDOWN)
            {
                IntPtr ptr = (IntPtr)wParam;
                int    c   = (int)ptr;
                char   cc  = (char)int.Parse(c.ToString());
                switch ((Keys)cc)
                {
                case Keys.Escape:
                    mOwner.selectItem(mOldSel);
                    ensureVisible(mOldSel);
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);

                    break;

                case Keys.Return:
                    PaintManagerUI.PostMessage(this.Handle, (int)WindowMessage.WM_KILLFOCUS, 0, 0);
                    break;

                default:
                    TEventUI newEvent = new TEventUI();
                    newEvent.mType = (int)EVENTTYPE_UI.UIEVENT_KEYDOWN;
                    newEvent.mKey  = cc;
                    mOwner.eventProc(ref newEvent);
                    ensureVisible(mOwner.getCurSel());
                    return(true);
                }
            }
            else if (uMsg == (int)WindowMessage.WM_MOUSEWHEEL)
            {
                IntPtr ptr = (IntPtr)wParam;
                int    c   = (int)ptr;

                int      zDelta   = (int)(short)HIWORD(c);
                TEventUI newEvent = new TEventUI();
                newEvent.mType      = (int)EVENTTYPE_UI.UIEVENT_SCROLLWHEEL;
                newEvent.mWParam    = makeLong(zDelta < 0 ? (int)ScrollBarCommands.SB_LINEDOWN : (int)ScrollBarCommands.SB_LINEUP, 0);
                newEvent.mLParam    = lParam;
                newEvent.mTimestamp = PaintManagerUI.GetTickCount();
                mOwner.eventProc(ref newEvent);
                ensureVisible(mOwner.getCurSel());
                return(true);
            }
            else if (uMsg == (int)WindowMessage.WM_KILLFOCUS)
            {
                close();
            }

            if (mManager != null && mManager.messageHandler((uint)uMsg, ref wParam, ref lParam, ref lRes))
            {
                return(true);
            }

            return(false);
        }