Beispiel #1
0
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            if (Parent != null && Parent.IsHandleCreated)
            {
                XplatUI.InvalidateNC(Parent.Handle);
            }
            // Should probably make this into one loop
            SizeScrollBars();
            ArrangeWindows();
        }
        protected override void HandleTitleBarLeave(int x, int y)
        {
            base.HandleTitleBarLeave(x, y);

            if (maximized_title_buttons != null)
            {
                maximized_title_buttons.MouseLeave(x, y);
            }

            if (IsMaximized)
            {
                XplatUI.InvalidateNC(form.MdiParent.Handle);
            }
        }
Beispiel #3
0
        protected virtual void HandleTitleBarDown(int x, int y)
        {
            title_buttons.MouseDown(x, y);

            if (!TitleButtons.AnyPushedTitleButtons && !IsMaximized)
            {
                state         = State.Moving;
                clicked_point = new Point(x, y);
                if (form.Parent != null)
                {
                    form.CaptureWithConfine(form.Parent);
                }
                else
                {
                    form.Capture = true;
                }
            }

            XplatUI.InvalidateNC(form.Handle);
        }
Beispiel #4
0
        internal void ActivateChild(Form form)
        {
            if (Controls.Count < 1)
            {
                return;
            }

            if (ParentForm.is_changing_visible_state > 0)
            {
                return;
            }

            Form current          = (Form)Controls [0];
            bool raise_deactivate = ParentForm.ActiveControl == current;

            // We want to resize the new active form before it is
            // made active to avoid flickering. Can't do it in the
            // normal way (form.WindowState = Maximized) since it's not
            // active yet and everything would just return to before.
            // We also won't suspend layout, this way the layout will
            // happen before the form is made active (and in many cases
            // before it is visible, which avoids flickering as well).
            MdiWindowManager wm = (MdiWindowManager)form.WindowManager;

            if (current.WindowState == FormWindowState.Maximized && form.WindowState != FormWindowState.Maximized && form.Visible)
            {
                FormWindowState old_state = form.window_state;
                SetWindowState(form, old_state, FormWindowState.Maximized, true);
                wm.was_minimized  = form.window_state == FormWindowState.Minimized;
                form.window_state = FormWindowState.Maximized;
                SetParentText(false);
            }

            form.BringToFront();
            form.SendControlFocus(form);
            SetWindowStates(wm);
            if (current != form)
            {
                form.has_focus = false;
                if (current.IsHandleCreated)
                {
                    XplatUI.InvalidateNC(current.Handle);
                }
                if (form.IsHandleCreated)
                {
                    XplatUI.InvalidateNC(form.Handle);
                }
                if (raise_deactivate)
                {
                    MdiWindowManager current_wm = (MdiWindowManager)current.window_manager;
                    current_wm.RaiseDeactivate();
                }
            }
            active_child = (Form)Controls [0];

            if (active_child.Visible)
            {
                bool raise_activated = ParentForm.ActiveControl != active_child;
                ParentForm.ActiveControl = active_child;
                if (raise_activated)
                {
                    MdiWindowManager active_wm = (MdiWindowManager)active_child.window_manager;
                    active_wm.RaiseActivated();
                }
            }
        }
Beispiel #5
0
        internal void SizeScrollBars()
        {
            if (lock_sizing)
            {
                return;
            }

            if (!IsHandleCreated)
            {
                return;
            }

            if (Controls.Count == 0 || ((Form)Controls [0]).WindowState == FormWindowState.Maximized)
            {
                if (hbar != null)
                {
                    hbar.Visible = false;
                }
                if (vbar != null)
                {
                    vbar.Visible = false;
                }
                if (sizegrip != null)
                {
                    sizegrip.Visible = false;
                }
                return;
            }

            int right  = 0;
            int left   = 0;
            int top    = 0;
            int bottom = 0;

            foreach (Form child in Controls)
            {
                if (!child.Visible)
                {
                    continue;
                }
                if (child.Right > right)
                {
                    right = child.Right;
                }
                if (child.Left < left)
                {
                    left = child.Left;
                }

                if (child.Bottom > bottom)
                {
                    bottom = child.Bottom;
                }
                if (child.Top < 0)
                {
                    top = child.Top;
                }
            }

            int available_width  = ClientSize.Width;
            int available_height = ClientSize.Height;

            bool need_hbar = false;
            bool need_vbar = false;

            if (right - left > available_width || left < 0)
            {
                need_hbar         = true;
                available_height -= SystemInformation.HorizontalScrollBarHeight;
            }
            if (bottom - top > available_height || top < 0)
            {
                need_vbar        = true;
                available_width -= SystemInformation.VerticalScrollBarWidth;

                if (!need_hbar && (right - left > available_width || left < 0))
                {
                    need_hbar         = true;
                    available_height -= SystemInformation.HorizontalScrollBarHeight;
                }
            }

            if (need_hbar)
            {
                if (hbar == null)
                {
                    hbar = new ImplicitHScrollBar();
                    Controls.AddImplicit(hbar);
                }
                hbar.Visible = true;
                CalcHBar(left, right, need_vbar);
            }
            else if (hbar != null)
            {
                hbar.Visible = false;
            }

            if (need_vbar)
            {
                if (vbar == null)
                {
                    vbar = new ImplicitVScrollBar();
                    Controls.AddImplicit(vbar);
                }
                vbar.Visible = true;
                CalcVBar(top, bottom, need_hbar);
            }
            else if (vbar != null)
            {
                vbar.Visible = false;
            }

            if (need_hbar && need_vbar)
            {
                if (sizegrip == null)
                {
                    sizegrip = new SizeGrip(this.ParentForm);
                    Controls.AddImplicit(sizegrip);
                }
                sizegrip.Location = new Point(hbar.Right, vbar.Bottom);
                sizegrip.Visible  = true;
                XplatUI.SetZOrder(sizegrip.Handle, vbar.Handle, false, false);
            }
            else if (sizegrip != null)
            {
                sizegrip.Visible = false;
            }

            XplatUI.InvalidateNC(Handle);
        }