Пример #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;
        }
Пример #2
0
		// Constructor will go when complete, only for testing - pdb
		internal TextBoxBase ()
		{
			alignment = HorizontalAlignment.Left;
			accepts_return = false;
			accepts_tab = false;
			auto_size = true;
			InternalBorderStyle = BorderStyle.Fixed3D;
			actual_border_style = BorderStyle.Fixed3D;
			character_casing = CharacterCasing.Normal;
			hide_selection = true;
			max_length = short.MaxValue;
			password_char = '\0';
			read_only = false;
			word_wrap = true;
			richtext = false;
			show_selection = false;
			enable_links = false;
			list_links = new ArrayList ();
			current_link = null;
			show_caret_w_selection = (this is TextBox);
			document = new Document(this);
			document.WidthChanged += new EventHandler(document_WidthChanged);
			document.HeightChanged += new EventHandler(document_HeightChanged);
			//document.CaretMoved += new EventHandler(CaretMoved);
			document.Wrap = false;
			click_last = DateTime.Now;
			click_mode = CaretSelection.Position;

			MouseDown += new MouseEventHandler(TextBoxBase_MouseDown);
			MouseUp += new MouseEventHandler(TextBoxBase_MouseUp);
			MouseMove += new MouseEventHandler(TextBoxBase_MouseMove);
			SizeChanged += new EventHandler(TextBoxBase_SizeChanged);
			FontChanged += new EventHandler(TextBoxBase_FontOrColorChanged);
			ForeColorChanged += new EventHandler(TextBoxBase_FontOrColorChanged);
			MouseWheel += new MouseEventHandler(TextBoxBase_MouseWheel);
			RightToLeftChanged += new EventHandler (TextBoxBase_RightToLeftChanged);
			
			scrollbars = RichTextBoxScrollBars.None;

			hscroll = new ImplicitHScrollBar();
			hscroll.ValueChanged += new EventHandler(hscroll_ValueChanged);
			hscroll.SetStyle (ControlStyles.Selectable, false);
			hscroll.Enabled = false;
			hscroll.Visible = false;
			hscroll.Maximum = Int32.MaxValue;

			vscroll = new ImplicitVScrollBar();
			vscroll.ValueChanged += new EventHandler(vscroll_ValueChanged);
			vscroll.SetStyle (ControlStyles.Selectable, false);
			vscroll.Enabled = false;
			vscroll.Visible = false;
			vscroll.Maximum = Int32.MaxValue;

			SuspendLayout ();
			this.Controls.AddImplicit (hscroll);
			this.Controls.AddImplicit (vscroll);
			ResumeLayout ();
			
			SetStyle(ControlStyles.UserPaint | ControlStyles.StandardClick, false);
#if NET_2_0
			SetStyle(ControlStyles.UseTextForAccessibility, false);
			
			base.SetAutoSizeMode (AutoSizeMode.GrowAndShrink);
#endif

			canvas_width = ClientSize.Width;
			canvas_height = ClientSize.Height;
			document.ViewPortWidth = canvas_width;
			document.ViewPortHeight = canvas_height;

			Cursor = Cursors.IBeam;
		}
Пример #3
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);
        }
Пример #4
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;
		}
Пример #5
0
		public ListBox ()
		{
			items = CreateItemCollection ();
			selected_indices = new SelectedIndexCollection (this);
			selected_items = new SelectedObjectCollection (this);

			requested_height = bounds.Height;
			InternalBorderStyle = BorderStyle.Fixed3D;
			BackColor = ThemeEngine.Current.ColorWindow;

			/* Vertical scrollbar */
			vscrollbar = new ImplicitVScrollBar ();
			vscrollbar.Minimum = 0;
			vscrollbar.SmallChange = 1;
			vscrollbar.LargeChange = 1;
			vscrollbar.Maximum = 0;
			vscrollbar.ValueChanged += new EventHandler (VerticalScrollEvent);
			vscrollbar.Visible = false;

			/* Horizontal scrollbar */
			hscrollbar = new ImplicitHScrollBar ();
			hscrollbar.Minimum = 0;
			hscrollbar.SmallChange = 1;
			hscrollbar.LargeChange = 1;
			hscrollbar.Maximum = 0;
			hscrollbar.Visible = false;
			hscrollbar.ValueChanged += new EventHandler (HorizontalScrollEvent);

			Controls.AddImplicit (vscrollbar);
			Controls.AddImplicit (hscrollbar);

			/* Events */
			MouseDown += new MouseEventHandler (OnMouseDownLB);
			MouseMove += new MouseEventHandler (OnMouseMoveLB);
			MouseUp += new MouseEventHandler (OnMouseUpLB);
			MouseWheel += new MouseEventHandler (OnMouseWheelLB);
			KeyUp += new KeyEventHandler (OnKeyUpLB);
			GotFocus += new EventHandler (OnGotFocus);
			LostFocus += new EventHandler (OnLostFocus);
			
			SetStyle (ControlStyles.UserPaint, false);

#if NET_2_0
			custom_tab_offsets = new IntegerCollection (this);
#endif
		}
Пример #6
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);
		}