2 // System.Windows.Forms.GroupBox.cs
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@raytek.com)
7 // (C) 2002/3 Ximian, Inc
11 namespace System.Windows.Forms {
16 public class GroupBox : Control {
24 //SubClassWndProc_ = true;
28 // --- Public Properties
32 public override bool AllowDrop {
35 return base.AllowDrop;
39 base.AllowDrop = value;
44 public override Rectangle DisplayRectangle {
47 return base.DisplayRectangle;
52 public FlatStyle FlatStyle {
54 throw new NotImplementedException ();
66 public override string ToString() {
68 return base.ToString();
72 static private bool classRegistered = false;
74 // --- Protected Properties
77 protected override CreateParams CreateParams {
79 if (!classRegistered) {
80 WNDCLASS wndClass = new WNDCLASS();
82 wndClass.style = (int) (CS_.CS_DBLCLKS);
83 wndClass.lpfnWndProc = NativeWindow.GetWindowProc();
84 wndClass.cbClsExtra = 0;
85 wndClass.cbWndExtra = 0;
86 wndClass.hInstance = (IntPtr)0;
87 wndClass.hIcon = (IntPtr)0;
88 wndClass.hCursor = Win32.LoadCursor( (IntPtr)0, LC_.IDC_ARROW);
89 wndClass.hbrBackground = (IntPtr)((int)GetSysColorIndex.COLOR_BTNFACE + 1);
90 wndClass.lpszMenuName = "";
91 wndClass.lpszClassName = "mono_static_control";
93 if (Win32.RegisterClass(ref wndClass) != 0)
94 classRegistered = true;
97 CreateParams createParams = base.CreateParams;
99 createParams.ClassName = "mono_static_control";
101 createParams.Style = (int) (
102 (int)WindowStyles.WS_CHILDWINDOW |
103 (int)SS_Static_Control_Types.SS_LEFT |
104 (int)WindowStyles.WS_CLIPCHILDREN |
105 (int)WindowStyles.WS_CLIPSIBLINGS |
106 (int)WindowStyles.WS_OVERLAPPED |
107 (int)WindowStyles.WS_VISIBLE );
114 protected override Size DefaultSize {
116 return new Size(200,100);//correct value
121 // --- Protected Methods
125 protected override void OnFontChanged(EventArgs e) {
127 base.OnFontChanged(e);
130 protected virtual void OnPaintBackground (PaintEventArgs e)
135 protected override void OnPaint(PaintEventArgs e) {
137 //FIXME: use TextMetrics to calculate coordinates in the method
138 Rectangle bounds = new Rectangle(new Point(0,0), Size);
140 Bitmap bmp = new Bitmap(bounds.Width, bounds.Height, e.Graphics);
141 Graphics paintOn = Graphics.FromImage(bmp);
143 Brush br = new SolidBrush(BackColor);
144 paintOn.FillRectangle(br, bounds);
145 bounds.Inflate(-4,-4);
147 ControlPaint.DrawBorder(paintOn, bounds, SystemColors.ControlDark, 1, ButtonBorderStyle.Solid,
148 SystemColors.ControlDark, 1, ButtonBorderStyle.Solid, SystemColors.ControlLightLight, 1, ButtonBorderStyle.Solid,
149 SystemColors.ControlLightLight, 1, ButtonBorderStyle.Solid);
150 bounds.Inflate(-1,-1);
151 ControlPaint.DrawBorder(paintOn, bounds, SystemColors.ControlLightLight, 1, ButtonBorderStyle.Solid,
152 SystemColors.ControlLightLight, 1, ButtonBorderStyle.Solid, SystemColors.ControlDark, 1, ButtonBorderStyle.Solid,
153 SystemColors.ControlDark, 1, ButtonBorderStyle.Solid);
154 SizeF sz = paintOn.MeasureString( Text, Font);
156 paintOn.FillRectangle( br, new RectangleF(new PointF((float)bounds.Left + 3.0F, 0.0F), sz));
157 paintOn.DrawString(Text, Font, SystemBrushes.ControlText, (float)bounds.Left + 5, 0);
158 e.Graphics.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height);
162 catch(Exception ex) {
168 protected override bool ProcessMnemonic(char charCode) {
170 return base.ProcessMnemonic(charCode);
174 protected override void WndProc(ref Message m) {
176 case Msg.WM_ERASEBKGND:
177 m.Result = (IntPtr)1;
180 base.WndProc (ref m);