2 // System.Windows.Forms.GroupBox.cs
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 // Jordi Mas i Hernandez, jordi@ximian.com
28 // Copyright (C) Novell Inc., 2004-2005
35 using System.ComponentModel;
36 using System.ComponentModel.Design;
38 namespace System.Windows.Forms
40 [DefaultProperty("Text")]
41 [DefaultEvent("Enter")]
42 [Designer ("System.Windows.Forms.Design.GroupBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
43 public class GroupBox : Control
45 private FlatStyle flat_style;
46 private Rectangle display_rectangle = new Rectangle ();
50 [EditorBrowsable(EditorBrowsableState.Advanced)]
51 public new event EventHandler Click;
54 [EditorBrowsable(EditorBrowsableState.Advanced)]
55 public new event EventHandler DoubleClick;
58 [EditorBrowsable(EditorBrowsableState.Advanced)]
59 public new event KeyEventHandler KeyDown;
62 [EditorBrowsable(EditorBrowsableState.Advanced)]
63 public new event KeyPressEventHandler KeyPress;
66 [EditorBrowsable(EditorBrowsableState.Advanced)]
67 public new event KeyEventHandler KeyUp;
70 [EditorBrowsable(EditorBrowsableState.Advanced)]
71 public new event MouseEventHandler MouseDown;
74 [EditorBrowsable(EditorBrowsableState.Advanced)]
75 public new event EventHandler MouseEnter;
78 [EditorBrowsable(EditorBrowsableState.Advanced)]
79 public new event EventHandler MouseLeave;
82 [EditorBrowsable(EditorBrowsableState.Advanced)]
83 public new event MouseEventHandler MouseMove;
86 [EditorBrowsable(EditorBrowsableState.Advanced)]
87 public new event MouseEventHandler MouseUp;
90 [EditorBrowsable(EditorBrowsableState.Advanced)]
91 public new event EventHandler TabStopChanged;
97 flat_style = FlatStyle.Standard;
99 SetStyle(ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
100 SetStyle(ControlStyles.Selectable, false);
103 #region Public Properties
105 [EditorBrowsable(EditorBrowsableState.Advanced)]
106 public override bool AllowDrop {
107 get { return base.AllowDrop; }
108 set { base.AllowDrop = value; }
111 protected override CreateParams CreateParams {
112 get { return base.CreateParams; }
115 protected override Size DefaultSize {
116 get { return ThemeEngine.Current.GroupBoxDefaultSize;}
119 public override Rectangle DisplayRectangle {
121 display_rectangle.X = 3;
122 display_rectangle.Y = Font.Height + 3;
123 display_rectangle.Width = Width - 6;
124 display_rectangle.Height = Height - Font.Height - 6;
125 return display_rectangle;
129 [DefaultValue(FlatStyle.Standard)]
130 public FlatStyle FlatStyle {
131 get { return flat_style; }
133 if (!Enum.IsDefined (typeof (FlatStyle), value))
134 new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for FlatStyle", value));
136 if (flat_style == value)
145 [EditorBrowsable(EditorBrowsableState.Advanced)]
146 public new bool TabStop {
147 get { return base.TabStop; }
148 set { base.TabStop = value; }
152 public override string Text {
153 get { return base.Text; }
155 if (base.Text == value)
163 #endregion //Public Properties
165 #region Public Methods
166 protected override void OnFontChanged (EventArgs e)
168 base.OnFontChanged (e);
172 protected override void OnPaint (PaintEventArgs pevent)
174 ThemeEngine.Current.DrawGroupBox (pevent.Graphics, ClientRectangle, this);
175 base.OnPaint(pevent);
178 protected override bool ProcessMnemonic (char charCode)
180 if (IsMnemonic(charCode, Text) == true) {
181 // Select item next in line in tab order
182 if (this.parent != null) {
183 parent.SelectNextControl(this, true, false, true, false);
188 return base.ProcessMnemonic (charCode);
191 public override string ToString()
193 return GetType ().FullName.ToString () + ", Text: " + Text;
196 protected override void WndProc(ref Message m) {
197 switch ((Msg) m.Msg) {
198 case Msg.WM_ERASEBKGND:
199 m.Result = (IntPtr)1;
202 base.WndProc (ref m);
207 #endregion Public Methods