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
33 using System.ComponentModel;
34 using System.ComponentModel.Design;
35 using System.Runtime.InteropServices;
37 namespace System.Windows.Forms
39 [DefaultProperty("Text")]
40 [DefaultEvent("Enter")]
41 [Designer ("System.Windows.Forms.Design.GroupBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
43 [ClassInterface (ClassInterfaceType.AutoDispatch)]
46 public class GroupBox : Control
48 private FlatStyle flat_style;
49 private Rectangle display_rectangle = new Rectangle ();
53 [EditorBrowsable(EditorBrowsableState.Advanced)]
54 public new event EventHandler Click {
55 add { base.Click += value; }
56 remove { base.Click -= value; }
60 [EditorBrowsable(EditorBrowsableState.Advanced)]
61 public new event EventHandler DoubleClick {
62 add { base.DoubleClick += value; }
63 remove { base.DoubleClick -= value; }
67 [EditorBrowsable(EditorBrowsableState.Advanced)]
68 public new event KeyEventHandler KeyDown {
69 add { base.KeyDown += value; }
70 remove { base.KeyDown -= value; }
74 [EditorBrowsable(EditorBrowsableState.Advanced)]
75 public new event KeyPressEventHandler KeyPress {
76 add { base.KeyPress += value; }
77 remove { base.KeyPress -= value; }
81 [EditorBrowsable(EditorBrowsableState.Advanced)]
82 public new event KeyEventHandler KeyUp {
83 add { base.KeyUp += value; }
84 remove { base.KeyUp -= value; }
88 [EditorBrowsable(EditorBrowsableState.Advanced)]
89 public new event MouseEventHandler MouseDown {
90 add { base.MouseDown += value; }
91 remove { base.MouseDown -= value; }
95 [EditorBrowsable(EditorBrowsableState.Advanced)]
96 public new event EventHandler MouseEnter {
97 add { base.MouseEnter += value; }
98 remove { base.MouseEnter -= value; }
102 [EditorBrowsable(EditorBrowsableState.Advanced)]
103 public new event EventHandler MouseLeave {
104 add { base.MouseLeave += value; }
105 remove { base.MouseLeave -= value; }
109 [EditorBrowsable(EditorBrowsableState.Advanced)]
110 public new event MouseEventHandler MouseMove {
111 add { base.MouseMove += value; }
112 remove { base.MouseMove -= value; }
116 [EditorBrowsable(EditorBrowsableState.Advanced)]
117 public new event MouseEventHandler MouseUp {
118 add { base.MouseUp += value; }
119 remove { base.MouseUp -= value; }
123 [EditorBrowsable(EditorBrowsableState.Advanced)]
124 public new event EventHandler TabStopChanged {
125 add { base.TabStopChanged += value; }
126 remove { base.TabStopChanged -= value; }
133 flat_style = FlatStyle.Standard;
135 SetStyle(ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
136 SetStyle(ControlStyles.Selectable, false);
139 #region Public Properties
141 [EditorBrowsable(EditorBrowsableState.Advanced)]
142 public override bool AllowDrop {
143 get { return base.AllowDrop; }
144 set { base.AllowDrop = value; }
147 protected override CreateParams CreateParams {
148 get { return base.CreateParams; }
151 protected override Size DefaultSize {
152 get { return ThemeEngine.Current.GroupBoxDefaultSize;}
155 public override Rectangle DisplayRectangle {
157 display_rectangle.X = 3;
158 display_rectangle.Y = Font.Height + 3;
159 display_rectangle.Width = Width - 6;
160 display_rectangle.Height = Height - Font.Height - 6;
161 return display_rectangle;
165 [DefaultValue(FlatStyle.Standard)]
166 public FlatStyle FlatStyle {
167 get { return flat_style; }
169 if (!Enum.IsDefined (typeof (FlatStyle), value))
170 new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for FlatStyle", value));
172 if (flat_style == value)
181 [EditorBrowsable(EditorBrowsableState.Advanced)]
182 public new bool TabStop {
183 get { return base.TabStop; }
184 set { base.TabStop = value; }
188 public override string Text {
189 get { return base.Text; }
191 if (base.Text == value)
199 #endregion //Public Properties
201 #region Public Methods
202 protected override void OnFontChanged (EventArgs e)
204 base.OnFontChanged (e);
208 protected override void OnPaint (PaintEventArgs pevent)
210 ThemeEngine.Current.DrawGroupBox (pevent.Graphics, ClientRectangle, this);
211 base.OnPaint(pevent);
214 protected override bool ProcessMnemonic (char charCode)
216 if (IsMnemonic(charCode, Text) == true) {
217 // Select item next in line in tab order
218 if (this.Parent != null) {
219 Parent.SelectNextControl(this, true, false, true, false);
224 return base.ProcessMnemonic (charCode);
227 public override string ToString()
229 return GetType ().FullName.ToString () + ", Text: " + Text;
232 protected override void WndProc(ref Message m) {
233 base.WndProc (ref m);
236 #endregion Public Methods
238 [DefaultValue (false)]
239 public bool UseCompatibleTextRendering {
241 return use_compatible_text_rendering;
245 use_compatible_text_rendering = value;