A
download GroupBox.cs
Language: C#
License: GPL
Copyright: (C) 2003 Free Software Foundation, Inc.
LOC: 222
Project Info
DotGNU Portable.NET(dotgnu-pnet)
Server: Savannah GNU
Type: cvs
...etlib\System.Windows.Forms\
   .cvsignore
   AccessibleEvents.cs
   AccessibleNavigation.cs
   AccessibleObject.cs
   AccessibleRole.cs
   AccessibleSelection.cs
   AccessibleStates.cs
   ActivationGesture.cs
   ActivationState.cs
   AmbientProperties.cs
   AnchorStyles.cs
   Appearance.cs
   Application.cs
   ApplicationContext.cs
   ArrangeDirection.cs
   ArrangeStartingPosition.cs
   BaseCollection.cs
   Binding.cs
   BindingContext.cs
   BindingManagerBase.cs
   BindingMemberInfo.cs
   BindingsCollection.cs
   BootMode.cs
   Border3DSide.cs
   Border3DStyle.cs
   BorderStyle.cs
   BoundsSpecified.cs
   Button.cs
   ButtonBase.cs
   ButtonBorderStyle.cs
   ButtonBoxLayout.cs
   ButtonState.cs
   CancelEventArgs.cs
   CancelEventHandler.cs
   CaptionButton.cs
   CharacterCasing.cs
   CheckBox.cs
   CheckListBox.cs
   CheckState.cs
   Clipboard.cs
   ColorDepth.cs
   ColorDialog.cs
   ColumnClickEventArgs.cs
   ColumnClickEventHandler.cs
   ColumnHeader.cs
   ColumnHeaderStyle.cs
   ComboBox.cs
   ComboBoxStyle.cs
   CommonDialog.cs
   ContainerControl.cs
   ...entsResizedEventArgs.cs
   ...sResizedEventHandler.cs
   ContextMenu.cs
   Control.cs
   ...olBindingsCollection.cs
   ControlEventArgs.cs
   ControlEventHandler.cs
   ControlPaint.cs
   ControlStyles.cs
   ControlToolkitMgr.cs
   ConvertEventArgs.cs
   ConvertEventHandler.cs
   CreateParams.cs
   CurrencyManager.cs
   Cursor.cs
   CursorConverter.cs
   Cursors.cs
   DataFormats.cs
   DataGrid.cs
   DataGridBoolColumn.cs
   DataGridCell.cs
   DataGridColumnStyle.cs
   DataGridLineStyle.cs
   ...ParentRowsLabelStyle.cs
   ...mnWidthTypeConverter.cs
   DataGridTableStyle.cs
   DataGridTextBox.cs
   DataGridTextBoxColumn.cs
   DataObject.cs
   DateBoldEventArgs.cs
   DateBoldEventHandler.cs
   DateRangeEventArgs.cs
   DateRangeEventHandler.cs
   DateTimePickerFormat.cs
   Day.cs
   DialogResult.cs
   DockStyle.cs
   DomainUpDown.cs
   DragAction.cs
   DragDropEffects.cs
   DragEventArgs.cs
   DragEventHandler.cs
   DrawItemEventArgs.cs
   DrawItemEventHandler.cs
   DrawItemState.cs
   DrawMode.cs
   ErrorBlinkStyle.cs
   ErrorIconAlignment.cs
   ErrorProvider.cs
   EventId.cs
   FeatureSupport.cs
   FileDialog.cs
   FlatStyle.cs
   FolderBrowserDialog.cs
   FontDialog.cs
   Form.cs
   FormBorderStyle.cs
   Forms.build
   FormStartPosition.cs
   FormWindowState.cs
   FrameStyle.cs
   GiveFeedbackEventArgs.cs
   ...FeedbackEventHandler.cs
   ...lumnStylesCollection.cs
   GridItem.cs
   GridItemCollection.cs
   GridItemType.cs
   GridLayout.cs
   ...ableStylesCollection.cs
   GroupBox.cs
   HBoxLayout.cs
   Help.cs
   HelpEventArgs.cs
   HelpEventHandler.cs
   HelpNavigator.cs
   HelpProvider.cs
   HorizontalAlignment.cs
   HScrollBar.cs
   IBindableComponent.cs
   IButtonControl.cs
   ICommandExecutor.cs
   ...ponentEditorPageSite.cs
   IContainerControl.cs
   ...gNotificationService.cs
   IDataGridEditingService.cs
   IDataObject.cs
   IDropTarget.cs
   IFeatureSupport.cs
   IFileReaderService.cs
   ImageIndexConverter.cs
   ImageList.cs
   ImageListStreamer.cs
   ImeMode.cs
   IMessageFilter.cs
   InputLanguage.cs
   ...uageChangedEventArgs.cs
   ...eChangedEventHandler.cs
   ...ageChangingEventArgs.cs
   ...ChangingEventHandler.cs
   InvalidateEventArgs.cs
   InvalidateEventHandler.cs
   IRecommendedSize.cs
   ItemActivation.cs
   ItemBoundsPortion.cs
   ItemChangedEventArgs.cs
   ItemChangedEventHandler.cs
   ItemCheckEventArgs.cs
   ItemCheckEventHandler.cs
   ItemDragEventArgs.cs
   ItemDragEventHandler.cs
   IWin32Window.cs
   IWindowTarget.cs
   KeyEventArgs.cs
   KeyEventHandler.cs
   KeyPressEventArgs.cs
   KeyPressEventHandler.cs
   Keys.cs
   Label.cs
   LabelEditEventArgs.cs
   LabelEditEventHandler.cs
   LayoutEventArgs.cs
   LayoutEventHandler.cs
   LeftRightAlignment.cs
   LinkArea.cs
   LinkBehavior.cs
   LinkClickedEventArgs.cs
   LinkClickedEventHandler.cs
   LinkLabel.cs
   ...LinkClickedEventArgs.cs
   ...kClickedEventHandler.cs
   LinkState.cs
   ListBindingConverter.cs
   ListBox.cs
   ListControl.cs
   ListView.cs
   ListViewAlignment.cs
   ListViewItem.cs
   ListViewItemConverter.cs
   ...ViewSubItemConverter.cs
   MainMenu.cs
   Makefile.am
   MdiClient.cs
   MdiLayout.cs
   MeasureItemEventArgs.cs
   MeasureItemEventHandler.cs
   Menu.cs
   MenuGlyph.cs
   MenuItem.cs
   MenuMerge.cs
   Message.cs
   MessageBox.cs
   MessageBoxButtons.cs
   MessageBoxDefaultButton.cs
   MessageBoxIcon.cs
   MessageBoxOptions.cs
   MethodInvoker.cs
   MonthCalendar.cs
   MouseButtons.cs
   MouseEventArgs.cs
   MouseEventHandler.cs
   NativeWindow.cs
   NavigateEventArgs.cs
   NavigateEventHandler.cs
   NodeLabelEditEventArgs.cs
   ...abelEditEventHandler.cs
   NotifyIcon.cs
   NumericUpDown.cs
   OpenFileDialog.cs
   Orientation.cs
   OSFeature.cs
   OwnerDrawPropertyBag.cs
   PaintEventArgs.cs
   PaintEventHandler.cs
   Panel.cs
   PictureBox.cs
   PictureBoxSizeMode.cs
   PopupControl.cs
   PrintDialog.cs
   ProgressBar.cs
   PropertySort.cs
   ...yTabChangedEventArgs.cs
   ...bChangedEventHandler.cs
   ...alueChangedEventArgs.cs
   ...eChangedEventHandler.cs
   ...ccessibilityHelpArgs.cs
   ...lityHelpEventHandler.cs
   ...ontinueDragEventArgs.cs
   ...inueDragEventHandler.cs
   RadioButton.cs
   RichTextBox.cs
   RichTextBoxFinds.cs
   RichTextBoxScrollBars.cs
   ...oxSelectionAttribute.cs
   ...extBoxSelectionTypes.cs
   RichTextBoxStreamType.cs
   ...tBoxWordPunctuations.cs
   RightToLeft.cs
   S.cs
   SaveFileDialog.cs
   Screen.cs
   ScrollableControl.cs
   ScrollBar.cs
   ScrollBars.cs
   ScrollButton.cs
   ScrollEventArgs.cs
   ScrollEventHandler.cs
   ScrollEventType.cs
   SecurityIDType.cs
   ...ItemChangedEventArgs.cs
   ...mChangedEventHandler.cs
   SelectionMode.cs
   Shortcut.cs
   SizeGripStyle.cs
   SortOrder.cs
   Splitter.cs
   SplitterEventArgs.cs
   SplitterEventHandler.cs
   StatusBar.cs
   ...BarDrawItemEventArgs.cs
   ...DrawItemEventHandler.cs
   StatusBarPanel.cs
   StatusBarPanelAutoSize.cs
   ...sBarPanelBorderStyle.cs
   ...rPanelClickEventArgs.cs
   ...nelClickEventHandler.cs
   StatusBarPanelStyle.cs
   StructFormat.cs
   SystemInformation.cs
   TabAlignment.cs
   TabAppearance.cs
   TabControl.cs
   TabDrawMode.cs
   TabPage.cs
   TabSizeMode.cs
   TextBox.cs
   TextBoxBase.cs
   TickStyle.cs
   Timer.cs
   TODOAttribute.cs
   ToolBar.cs
   ToolBarAppearance.cs
   ToolBarButton.cs
   ...ButtonClickEventArgs.cs
   ...tonClickEventHandler.cs
   ToolBarButtonStyle.cs
   ToolBarTextAlign.cs
   ToolTip.cs
   TrackBar.cs
   TreeNode.cs
   TreeNodeCollection.cs
   TreeView.cs
   TreeViewAction.cs
   TreeViewCancelEventArgs.cs
   ...ewCancelEventHandler.cs
   TreeViewEventArgs.cs
   TreeViewEventHandler.cs
   TriangleDirection.cs
   UICues.cs
   UICuesEventArgs.cs
   UICuesEventHandler.cs
   UpDownBase.cs
   UpDownEventArgs.cs
   UpDownEventHandler.cs
   UserControl.cs
   VBoxLayout.cs
   View.cs
   VScrollBar.cs
   Win32Constants.cs

/*
 * GroupBox.cs - Implementation of "System.Windows.Forms.GroupBox" class
 *
 * Copyright (C) 2003  Free Software Foundation, Inc.
 *
 * Contributions from Cecilio Pardo <cpardo@imayhem.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Windows.Forms
{

using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms.Themes;

public class GroupBox : Control
{
	// Internal state.
	private FlatStyle flatStyle;
	private bool entered;

	// Constructor.
	public GroupBox()
			{
				base.TabStop = false;
				this.flatStyle = FlatStyle.Standard;
				this.entered = false;
				SetStyle(ControlStyles.ContainerControl, true);
				SetStyle(ControlStyles.Selectable, false);
			}

	// Properties.
	public override bool AllowDrop 
			{
				get { return base.AllowDrop; }
				set { base.AllowDrop = value; }
			}
	protected override CreateParams CreateParams
			{
				get { return base.CreateParams; }
			}
	protected override Size DefaultSize 
			{
				get { return new Size(200, 100); }
			}
	public override Rectangle DisplayRectangle
			{
				get
				{
					Size clientSize = ClientSize;
					int x = 0;
					int y = 0;
					int width = clientSize.Width;
					int height = clientSize.Height;
					int fontHeight = Font.Height;

					// Correct the rectangle for borders
					x += 2;
					y += fontHeight + 2;
					width -= 4;
					height -= fontHeight + 4;

					// Handle edge cases.
					width = (width < 0) ? 0 : width;
					height = (height < 0) ? 0 : height;

					return new Rectangle(x, y, width, height);
				}
			}
	public FlatStyle FlatStyle
			{
				get { return flatStyle; }
				set
				{
					if(flatStyle == value) { return; }

					if(!Enum.IsDefined(typeof(FlatStyle), value))
					{
					#if CONFIG_COMPONENT_MODEL
						throw new InvalidEnumArgumentException
							("FlatStyle", (int)value, typeof(FlatStyle));
					#else
						throw new ArgumentException
							("FlatStyle = "+(int)value);
					#endif
					}
					flatStyle = value;
					Invalidate();
				}
			}
	public new bool TabStop
			{
				get { return base.TabStop; }
				set { base.TabStop = value; }
			}
	public override String Text
			{
				get { return base.Text; }
				set
				{
					base.Text = value;
					Invalidate();
				}
			}

	// Methods.
	private void Draw(Graphics g)
			{
				IThemePainter themePainter;

				themePainter = ThemeManager.PainterForStyle(flatStyle);
				using(Brush bgBrush = CreateBackgroundBrush())
				{
					themePainter.DrawGroupBox
						(g, ClientRectangle, ForeColor, BackColor, bgBrush,
						 Enabled, entered, flatStyle, Text, Font,
						 GetStringFormat());
				}
			}
	private StringFormat GetStringFormat()
			{
				StringFormat format = new StringFormat();
				if(ShowKeyboardCues)
				{
					format.HotkeyPrefix = HotkeyPrefix.Show;
				}
				else
				{
					format.HotkeyPrefix = HotkeyPrefix.Hide;
				}
				if(RightToLeft == RightToLeft.Yes)
				{
					format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
				}
				return format;
			}
	protected override void OnFontChanged(EventArgs e)
			{
				Invalidate();
				base.OnFontChanged(e);
			}
	protected override void OnMouseEnter(EventArgs e)
			{
				entered = true;
				Invalidate();
				base.OnMouseEnter(e);
			}
	protected override void OnMouseLeave(EventArgs e)
			{
				entered = false;
				Invalidate();
				base.OnMouseLeave(e);
			}
	protected override void OnPaint(PaintEventArgs e)
			{
				if(Visible && IsHandleCreated)
				{
					Draw(e.Graphics);
				}
				base.OnPaint(e);
			}
	protected override bool ProcessMnemonic(char charCode)
			{
				// check this control's text for the mnemonic
				if(!IsMnemonic(charCode, base.Text))
				{
					return false;
				}

				// make sure all the base controls are visible and enabled
				for(Control c = this; c != null; c = c.Parent)
				{
					if(!c.Visible || !c.Enabled)
					{
						return false;
					}
				}

				// focus on the first selectable child control
				SelectNextControl(null, true, true, true, false);

				// let the caller know that the mnemonic has been processed
				return true;
			}
	public override String ToString()
			{
				return base.ToString() + ", Text: " + Text;
			}
#if !CONFIG_COMPACT_FORMS
	protected override void WndProc(ref Message m)
			{
				base.WndProc(ref m);
			}
#endif // !CONFIG_COMPACT_FORMS

	// Events.
	public new event EventHandler Click
			{
				add { base.Click += value; }
				remove { base.Click -= value; }
			}
	public new event EventHandler DoubleClick
			{
				add { base.DoubleClick += value; }
				remove { base.DoubleClick -= value; }
			}
	public new event KeyEventHandler KeyDown
			{
				add { base.KeyDown += value; }
				remove { base.KeyDown -= value; }
			}
	public new event KeyPressEventHandler KeyPress
			{
				add { base.KeyPress += value; }
				remove { base.KeyPress -= value; }
			}
	public new event KeyEventHandler KeyUp
			{
				add { base.KeyUp += value; }
				remove { base.KeyUp -= value; }
			}
	public new event MouseEventHandler MouseDown
			{
				add { base.MouseDown += value; }
				remove { base.MouseDown -= value; }
			}
	public new event EventHandler MouseEnter
			{
				add { base.MouseEnter += value; }
				remove { base.MouseEnter -= value; }
			}
	public new event EventHandler MouseLeave
			{
				add { base.MouseLeave += value; }
				remove { base.MouseLeave -= value; }
			}
	public new event MouseEventHandler MouseMove
			{
				add { base.MouseMove += value; }
				remove { base.MouseMove -= value; }
			}
	public new event MouseEventHandler MouseUp
			{
				add { base.MouseUp += value; }
				remove { base.MouseUp -= value; }
			}
	public new event EventHandler TabStopChanged
			{
				add { base.TabStopChanged += value; }
				remove { base.TabStopChanged -= value; }
			}

}; // class GroupBox

}; // namespace System.Windows.Forms

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us