2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / CheckBox.cs
index 51fd6af77465edceaab38c1ac5585a1069bc8e84..5d7691b535660ef0406db6de496d96bc0038d7ed 100644 (file)
 //     Dennis Hayes    dennish@raytek.com
 //     Peter Bartok    pbartok@novell.com
 //
-//
-// $Log: CheckBox.cs,v $
-// Revision 1.7  2004/09/28 18:44:25  pbartok
-// - Streamlined Theme interfaces:
-//   * Each DrawXXX method for a control now is passed the object for the
-//     control to be drawn in order to allow accessing any state the theme
-//     might require
-//
-//   * ControlPaint methods for the theme now have a CP prefix to avoid
-//     name clashes with the Draw methods for controls
-//
-//   * Every control now retrieves it's DefaultSize from the current theme
-//
-// Revision 1.6  2004/09/01 20:01:24  pbartok
-// - Added missing default
-// - Added missing region mark
-//
-// Revision 1.5  2004/09/01 01:55:58  pbartok
-// - Fixed to match the removal of the needs_redraw concept
-//
-// Revision 1.4  2004/08/31 18:48:31  pbartok
-// - Finished (famous last words)
-//
-// Revision 1.3  2004/08/30 20:42:26  pbartok
-// - Implemented CheckBox drawing code
-//
-// Revision 1.2  2004/08/30 15:44:20  pbartok
-// - Updated to fix broken build. Not complete yet.
-//
-// Revision 1.1  2004/07/09 05:21:25  pbartok
-// - Initial check-in
-//
-//
 
 // COMPLETE
 
 using System;
+using System.ComponentModel;
 using System.Drawing;
 
 namespace System.Windows.Forms {
+       [DefaultProperty("Checked")]
+       [DefaultEvent("CheckedChanged")]
        public class CheckBox : ButtonBase {
                #region Local Variables
                internal Appearance             appearance;
                internal bool                   auto_check;
                internal ContentAlignment       check_alignment;
-               internal ContentAlignment       text_alignment;
                internal CheckState             check_state;
                internal bool                   three_state;
                #endregion      // Local Variables
@@ -83,7 +52,22 @@ namespace System.Windows.Forms {
                }
                #endregion      // Public Constructors
 
+               #region Internal Methods
+               internal override void Draw (PaintEventArgs pe) {
+                       if (redraw) {
+                               ThemeEngine.Current.DrawCheckBox (this.DeviceContext, this.ClientRectangle, this);
+                               redraw = false;
+                       }
+               }
+
+               internal override void HaveDoubleClick() {
+                       if (DoubleClick != null) DoubleClick(this, EventArgs.Empty);
+               }
+               #endregion      // Internal Methods
+
                #region Public Instance Properties
+               [DefaultValue(Appearance.Normal)]
+               [Localizable(true)]
                public Appearance Appearance {
                        get {
                                return appearance;
@@ -91,7 +75,7 @@ namespace System.Windows.Forms {
 
                        set {
                                if (value != appearance) {
-                                       value = appearance;
+                                       appearance = value;
                                        if (AppearanceChanged != null) {
                                                AppearanceChanged(this, EventArgs.Empty);
                                        }
@@ -100,6 +84,7 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue(true)]
                public bool AutoCheck {
                        get {
                                return auto_check;
@@ -110,6 +95,9 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [Bindable(true)]
+               [Localizable(true)]
+               [DefaultValue(ContentAlignment.MiddleLeft)]
                public ContentAlignment CheckAlign {
                        get {
                                return check_alignment;
@@ -124,6 +112,9 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [Bindable(true)]
+               [RefreshProperties(RefreshProperties.All)]
+               [DefaultValue(false)]
                public bool Checked {
                        get {
                                if (check_state != CheckState.Unchecked) {
@@ -145,6 +136,9 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue(CheckState.Unchecked)]
+               [RefreshProperties(RefreshProperties.All)]
+               [Bindable(true)]
                public CheckState CheckState {
                        get {
                                return check_state;
@@ -166,6 +160,8 @@ namespace System.Windows.Forms {
                        }
                }
 
+               [DefaultValue(ContentAlignment.MiddleLeft)]
+               [Localizable(true)]
                public override ContentAlignment TextAlign {
                        get {
                                return text_alignment;
@@ -180,6 +176,7 @@ namespace System.Windows.Forms {
                }
 
 
+               [DefaultValue(false)]
                public bool ThreeState {
                        get {
                                return three_state;
@@ -278,11 +275,10 @@ namespace System.Windows.Forms {
                public event EventHandler       CheckStateChanged;
                #endregion      // Events
 
-               #region Internal drawing code
-               internal override void Redraw() {\r
-                       ThemeEngine.Current.DrawCheckBox(this.DeviceContext, this.ClientRectangle, this);
-                       Refresh();
-               }\r
-               #endregion      // Internal drawing code
+               #region Events
+               [Browsable(false)]
+               [EditorBrowsable (EditorBrowsableState.Never)]
+               public event EventHandler DoubleClick;
+               #endregion      // Events
        }
 }