Esempio n. 1
0
        public virtual void RepositionChildren()
        {
            if (_edit != null)
            {
                Rectangle clientRect = ClientRectangle;
                if (clientRect.Width > 0)
                {
                    // Get the margins of the editbox
                    int rawMargins = Win32Calls.LoWord(Win32Calls.SendMessage(_edit.Handle, Win32Calls.EM_GETMARGINS, 0, 0));
                    int margins    = Win32Calls.LoWord(rawMargins) + Win32Calls.HiWord(rawMargins);

                    int buttonWidth = GetButtonWidth(null);

                    Rectangle valueRect = ClientRectangle;
                    valueRect.Width -= buttonWidth + 1;
                    valueRect.Height++; // for GetStringValueRect()
                    Graphics graphics = CreateGraphics();
                    valueRect = _ownerPropertyEnum.Property.Value.GetStringValueRect(graphics, valueRect, Point.Empty);
                    valueRect.Height--;

                    int margin  = _ownerPropertyEnum.Property.ParentGrid.GlobalTextMargin;
                    int leftPos = valueRect.Left - margin + (_ownerPropertyEnum.Property.Value.EditboxLeftMargin == -1 ? 0 :
                                                             margin - _ownerPropertyEnum.Property.Value.EditboxLeftMargin);

                    Rectangle editRect = new Rectangle(leftPos, 0, clientRect.Width - buttonWidth - leftPos, clientRect.Height);
                    editRect.Y++;
                    editRect.Height--;

                    // The width of the editbox can't be smaller than the margins or the margins would be void and the text misplaced
                    if (editRect.Width <= margins)
                    {
                        if (_edit.Focused)
                        {
                            Parent.Focus();
                        }

                        _edit.Visible = false;
                    }
                    else
                    {
                        _edit.Visible = true;

                        Win32Calls.TEXTMETRIC tm = new Win32Calls.TEXTMETRIC();
                        Win32Calls.GetTextMetrics(graphics, Font, ref tm);
                        int extraHeight = editRect.Height - tm.tmHeight;
                        editRect.Y      += extraHeight / 2;
                        editRect.Height -= extraHeight / 2;

                        _edit.Invalidate();
                        _edit.Bounds = editRect;
                    }

                    graphics.Dispose();
                }
            }

            Invalidate(false);
        }
Esempio n. 2
0
        public virtual void RepositionChildren()
        {
            if (mEdit != null)
            {
                Rectangle clientRect = ClientRectangle;
                if (clientRect.Width > 0)
                {
                    // Get the margins of the editbox
                    int rawMargins = Win32Calls.LoWord(Win32Calls.SendMessage(mEdit.Handle, Win32Calls.EM_GETMARGINS, 0, 0));
                    int margins    = Win32Calls.LoWord(rawMargins) + Win32Calls.HiWord(rawMargins);

                    int margin  = mOwnerPropertyEnum.Property.ParentGrid.GlobalTextMargin;
                    int leftPos = (mOwnerPropertyEnum.Property.Value.EditboxLeftMargin == -1 ? 0 :
                                   margin - mOwnerPropertyEnum.Property.Value.EditboxLeftMargin);

                    int       buttonWidth = GetButtonWidth(null);
                    Rectangle editRect    = new Rectangle(leftPos, 0, clientRect.Width - buttonWidth - leftPos, clientRect.Height);
                    editRect.Y++;
                    editRect.Height--;

                    // The width of the editbox can't be smaller than the margins or the margins would be void and the text misplaced
                    if (editRect.Width <= margins)
                    {
                        if (mEdit.Focused)
                        {
                            Parent.Focus();
                        }

                        mEdit.Visible = false;
                    }
                    else
                    {
                        mEdit.Visible = true;

                        Win32Calls.TEXTMETRIC tm = new Win32Calls.TEXTMETRIC();
                        Graphics graphics        = CreateGraphics();
                        Win32Calls.GetTextMetrics(graphics, Font, ref tm);
                        graphics.Dispose();
                        int extraHeight = editRect.Height - tm.tmHeight;
                        editRect.Y      += extraHeight / 2;
                        editRect.Height -= extraHeight / 2;

                        mEdit.Invalidate();
                        mEdit.Bounds = editRect;
                    }
                }
            }

            Invalidate(false);

//            mEdit.Location = new Point(0, 0);
//          mEdit.Size = new Size(ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth, ClientRectangle.Height);
        }
Esempio n. 3
0
        public void RepositionChildren()
        {
            if (_edit != null)
            {
                Rectangle clientRect = ClientRectangle;
                if (clientRect.Width > 0)
                {
                    // Get the margins of the editbox
                    int rawMargins = Win32Calls.LoWord(Win32Calls.SendMessage(_edit.Handle, Win32Calls.EM_GETMARGINS, 0, 0));
                    int margins    = Win32Calls.LoWord(rawMargins) + Win32Calls.HiWord(rawMargins);

                    int       buttonWidth = GetButtonWidth(null);
                    Rectangle editRect    = new Rectangle(0, 0, clientRect.Width - buttonWidth, clientRect.Height);
                    editRect.Inflate(0, -1);

                    // The width of the editbox can't be smaller than the margins or the margins would be void and the text misplaced
                    if (editRect.Width <= margins)
                    {
                        _edit.Visible = false;
                    }
                    else
                    {
                        _edit.Visible = true;

                        Win32Calls.TEXTMETRIC tm = new Win32Calls.TEXTMETRIC();
                        Graphics graphics        = CreateGraphics();
                        Win32Calls.GetTextMetrics(graphics, Font, ref tm);
                        graphics.Dispose();
                        editRect.Y      += (clientRect.Height - tm.tmHeight) / 2;
                        editRect.Height -= (clientRect.Height - tm.tmHeight) / 2;

                        _edit.Invalidate();
                        _edit.Bounds = editRect;
                    }
                }
            }

            Invalidate(false);
        }
Esempio n. 4
0
        public virtual void RepositionChildren()
        {
            Rectangle clientRect = ClientRectangle;

            if (clientRect.Width > 0)
            {
                if (_edit != null)
                {
                    // Get the margins of the editbox
                    int rawMargins = Win32Calls.LoWord(Win32Calls.SendMessage(_edit.Handle, Win32Calls.EM_GETMARGINS, 0, 0));
                    int margins    = Win32Calls.LoWord(rawMargins) + Win32Calls.HiWord(rawMargins);

                    int margin  = _ownerPropertyEnum.Property.ParentGrid.GlobalTextMargin;
                    int leftPos = (_ownerPropertyEnum.Property.Value.EditboxLeftMargin == -1 ? 0 :
                                   margin - _ownerPropertyEnum.Property.Value.EditboxLeftMargin);

                    Rectangle editRect = new Rectangle(leftPos, 0, GetEditWidth() - leftPos, clientRect.Height);
                    editRect.Y++;
                    editRect.Height--;

                    // The width of the editbox can't be smaller than the margins or the margins would be void and the text misplaced
                    if (editRect.Width <= margins)
                    {
                        if (_edit.Focused)
                        {
                            Parent.Focus();
                        }

                        _edit.Visible = false;
                    }
                    else
                    {
                        _edit.Visible = true;

                        Win32Calls.TEXTMETRIC tm = new Win32Calls.TEXTMETRIC();
                        Graphics graphics        = CreateGraphics();
                        Win32Calls.GetTextMetrics(graphics, Font, ref tm);
                        graphics.Dispose();
                        int extraHeight = editRect.Height - tm.tmHeight;
                        editRect.Y      += extraHeight / 2;
                        editRect.Height -= extraHeight / 2;

                        _edit.Invalidate();
                        _edit.Bounds = editRect;
                    }

                    if (_trackbar != null)
                    {
                        Rectangle trackbarRect = new Rectangle(editRect.Right, 0 + 2, clientRect.Right - editRect.Right, clientRect.Height - 2);
                        if (trackbarRect.Width < 15)
                        {
                            _trackbar.Visible = false;
                        }
                        else
                        {
                            _trackbar.Visible = true;
                            _trackbar.Bounds  = trackbarRect;
                        }
                    }
                }
                else
                {
                    if (_trackbar != null)
                    {
                        int       editWidth    = GetEditWidth();
                        Rectangle trackbarRect = new Rectangle(editWidth, 0, clientRect.Width - editWidth, clientRect.Height);
                        _trackbar.Bounds = trackbarRect;
                    }
                }
            }
        }