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
35 using System
.ComponentModel
;
37 namespace System
.Windows
.Forms
39 public class GroupBox
: Control
41 private FlatStyle flat_style
;
42 private Bitmap bmp_mem
= null;
43 private Graphics dc_mem
= null;
44 private Rectangle display_rectangle
= new Rectangle ();
47 public new event EventHandler Click
;
48 public new event EventHandler DoubleClick
;
49 public new event KeyEventHandler KeyDown
;
50 public new event KeyPressEventHandler KeyPress
;
51 public new event KeyEventHandler KeyUp
;
52 public new event MouseEventHandler MouseDown
;
53 public new event EventHandler MouseEnter
;
54 public new event EventHandler MouseLeave
;
55 public new event MouseEventHandler MouseMove
;
56 public new event MouseEventHandler MouseUp
;
57 public new event EventHandler TabStopChanged
;
63 flat_style
= FlatStyle
.Standard
;
66 #region Public Properties
67 public override bool AllowDrop
{
68 get { return base.AllowDrop; }
69 set { base.AllowDrop = value; }
72 protected override CreateParams CreateParams
{
73 get { return base.CreateParams; }
76 protected override Size DefaultSize
{
77 get { return ThemeEngine.Current.GroupBoxDefaultSize;}
80 public override Rectangle DisplayRectangle
{
82 display_rectangle
.X
= 3;
83 display_rectangle
.Y
= Font
.Height
+ 3;
84 display_rectangle
.Width
= Width
- 6;
85 display_rectangle
.Height
= Height
- Font
.Height
- 6;
86 return display_rectangle
;
90 public FlatStyle FlatStyle
{
91 get { return flat_style; }
93 if (!Enum
.IsDefined (typeof (FlatStyle
), value))
94 new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for FlatStyle", value));
96 if (flat_style
== value)
104 public new bool TabStop
{
105 get { return base.TabStop; }
106 set { base.TabStop = value; }
109 public override string Text
{
110 get { return base.Text; }
112 if (base.Text
== value)
120 #endregion //Public Properties
122 #region Public Methods
123 protected override void OnFontChanged (EventArgs e
)
125 base.OnFontChanged (e
);
129 protected override void OnPaint (PaintEventArgs pevent
)
132 pevent
.Graphics
.DrawImage (ImageBuffer
, 0, 0);
135 protected override bool ProcessMnemonic (char charCode
)
137 return base.ProcessMnemonic(charCode
);
140 public override string ToString()
142 return GetType ().FullName
.ToString () + ", Text: " + Text
;
145 protected override void WndProc(ref Message m
) {
146 switch ((Msg
) m
.Msg
) {
147 case Msg
.WM_ERASEBKGND
:
148 m
.Result
= (IntPtr
)1;
151 base.WndProc (ref m
);
156 #endregion Public Methods
158 #region Private Methods
162 ThemeEngine
.Current
.DrawGroupBox (DeviceContext
, ClientRectangle
, this);
165 #endregion // Private Methods