* Control.cs: ControlCollection.Count must be public. Fixed build of
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / GroupBox.cs
index aaa06df9ded87a51e3ef4b7ad60fc23c9bae322b..fdb24c2487df8c05773df8bbd3fcce7a1d5492eb 100644 (file)
 //
 //
 
-// COMPLETE
-
 using System.Drawing;
 using System.ComponentModel;
 using System.ComponentModel.Design;
+using System.Runtime.InteropServices;
 
 namespace System.Windows.Forms
 {
        [DefaultProperty("Text")]
        [DefaultEvent("Enter")]
-       [Designer ("System.Windows.Forms.Design.GroupBoxDesigner, " + Consts.AssemblySystem_Design, (string)null)]
+       [Designer ("System.Windows.Forms.Design.GroupBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+#if NET_2_0
+       [ClassInterface (ClassInterfaceType.AutoDispatch)]
+       [ComVisible (true)]
+#endif
        public class GroupBox : Control
        {
                private FlatStyle flat_style;
@@ -48,47 +51,80 @@ namespace System.Windows.Forms
                #region Events
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event EventHandler Click;
+               public new event EventHandler Click {
+                       add { base.Click += value; }
+                       remove { base.Click -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event EventHandler DoubleClick;
+               public new event EventHandler DoubleClick {
+                       add { base.DoubleClick += value; }
+                       remove { base.DoubleClick -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event KeyEventHandler KeyDown;
+               public new event KeyEventHandler KeyDown {
+                       add { base.KeyDown += value; }
+                       remove { base.KeyDown -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event KeyPressEventHandler KeyPress;
+               public new event KeyPressEventHandler KeyPress {
+                       add { base.KeyPress += value; }
+                       remove { base.KeyPress -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event KeyEventHandler KeyUp;
+               public new event KeyEventHandler KeyUp {
+                       add { base.KeyUp += value; }
+                       remove { base.KeyUp -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event MouseEventHandler MouseDown;
+               public new event MouseEventHandler MouseDown {
+                       add { base.MouseDown += value; }
+                       remove { base.MouseDown -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event EventHandler MouseEnter;
+               public new event EventHandler MouseEnter {
+                       add { base.MouseEnter += value; }
+                       remove { base.MouseEnter -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event EventHandler MouseLeave;
+               public new event EventHandler MouseLeave {
+                       add { base.MouseLeave += value; }
+                       remove { base.MouseLeave -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event MouseEventHandler MouseMove;
+               public new event MouseEventHandler MouseMove {
+                       add { base.MouseMove += value; }
+                       remove { base.MouseMove -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event MouseEventHandler MouseUp;
+               public new event MouseEventHandler MouseUp {
+                       add { base.MouseUp += value; }
+                       remove { base.MouseUp -= value; }
+               }
 
                [Browsable(false)]
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               public new event EventHandler TabStopChanged;
+               public new event EventHandler TabStopChanged {
+                       add { base.TabStopChanged += value; }
+                       remove { base.TabStopChanged -= value; }
+               }
                #endregion Events
 
                public GroupBox ()
@@ -96,9 +132,8 @@ namespace System.Windows.Forms
                        TabStop = false;
                        flat_style = FlatStyle.Standard;
 
-                       SetStyle(ControlStyles.ContainerControl, true);
+                       SetStyle(ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
                        SetStyle(ControlStyles.Selectable, false);
-                       SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
                }
 
                #region Public Properties
@@ -172,16 +207,16 @@ namespace System.Windows.Forms
 
                protected override void OnPaint (PaintEventArgs pevent)
                {
-                       Draw ();
-                       pevent.Graphics.DrawImage (ImageBuffer, 0, 0);
+                       ThemeEngine.Current.DrawGroupBox (pevent.Graphics, ClientRectangle, this);
+                       base.OnPaint(pevent);
                }
 
                protected override bool ProcessMnemonic (char charCode)
                {
                        if (IsMnemonic(charCode, Text) == true) {
                                // Select item next in line in tab order
-                               if (this.parent != null) {
-                                       parent.SelectNextControl(this, true, false, true, false);
+                               if (this.Parent != null) {
+                                       Parent.SelectNextControl(this, true, false, true, false);
                                }
                                return true;
                        }
@@ -195,25 +230,21 @@ namespace System.Windows.Forms
                }
 
                protected override void WndProc(ref Message m) {
-                       switch ((Msg) m.Msg) {
-                               case Msg.WM_ERASEBKGND:
-                                       m.Result = (IntPtr)1;
-                                       break;
-                               default:
-                                       base.WndProc (ref m);
-                                       break;
-                       }
+                       base.WndProc (ref m);
                }
                                
                #endregion Public Methods
-               
-               #region Private Methods
+#if NET_2_0
+               [DefaultValue (false)]
+               public bool UseCompatibleTextRendering {
+                       get {
+                               return use_compatible_text_rendering;
+                       }
 
-               private void Draw ()
-               {                       
-                       ThemeEngine.Current.DrawGroupBox (DeviceContext, ClientRectangle, this);                        
+                       set {
+                               use_compatible_text_rendering = value;
+                       }
                }
-               
-               #endregion // Private Methods
+#endif
        }
 }