Beispiel #1
0
        private void CreateScrollbars()
        {
            hscrollbar                       = new ImplicitHScrollBar();
            hscrollbar.Visible               = false;
            hscrollbar.ValueChanged         += new EventHandler(HandleScrollBar);
            hscrollbar.Height                = SystemInformation.HorizontalScrollBarHeight;
            hscrollbar.use_manual_thumb_size = true;
            hscrollbar.Scroll               += new ScrollEventHandler(HandleScrollEvent);

            vscrollbar                       = new ImplicitVScrollBar();
            vscrollbar.Visible               = false;
            vscrollbar.ValueChanged         += new EventHandler(HandleScrollBar);
            vscrollbar.Width                 = SystemInformation.VerticalScrollBarWidth;
            vscrollbar.use_manual_thumb_size = true;
            vscrollbar.Scroll               += new ScrollEventHandler(HandleScrollEvent);

            sizegrip         = new SizeGrip(this);
            sizegrip.Visible = false;
        }
Beispiel #2
0
		private new void UpdateSizeGripVisible ()
		{
			// Following link explains when to show size grip:
			// http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=138687&SiteID=1
			// if SizeGripStyle.Auto, only shown if form is shown using ShowDialog and is sizable
			// if SizeGripStyle.Show, only shown if form is sizable
			
			bool show = false;
			
			switch (size_grip_style) {
			case SizeGripStyle.Auto:
				show = is_modal && (form_border_style == FormBorderStyle.Sizable || form_border_style == FormBorderStyle.SizableToolWindow);
				break;
			case SizeGripStyle.Hide:
				show = false;
				break;
			case SizeGripStyle.Show:
				show = (form_border_style == FormBorderStyle.Sizable || form_border_style == FormBorderStyle.SizableToolWindow);
				break;
			}
			
			if (!show) {
				if (size_grip != null && size_grip.Visible)
					size_grip.Visible = false;
			} else {
				if (size_grip == null) {
					size_grip = new SizeGrip (this);
					size_grip.Virtual = true;
					size_grip.FillBackground = false;
				}
				size_grip.Visible = true;
			}
		}
Beispiel #3
0
		private void CreateScrollbars ()
		{
			hscrollbar = new ImplicitHScrollBar ();
			hscrollbar.Visible = false;
			hscrollbar.ValueChanged += new EventHandler (HandleScrollBar);
			hscrollbar.Height = SystemInformation.HorizontalScrollBarHeight;
			hscrollbar.use_manual_thumb_size = true;
			hscrollbar.Scroll += new ScrollEventHandler (HandleScrollEvent);

			vscrollbar = new ImplicitVScrollBar ();
			vscrollbar.Visible = false;
			vscrollbar.ValueChanged += new EventHandler (HandleScrollBar);
			vscrollbar.Width = SystemInformation.VerticalScrollBarWidth;
			vscrollbar.use_manual_thumb_size = true;
			vscrollbar.Scroll += new ScrollEventHandler (HandleScrollEvent);

			sizegrip = new SizeGrip (this);
			sizegrip.Visible = false;
		}
Beispiel #4
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);
        }
		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);
		}