Author: jpobst
Date: 2007-06-04 16:00:44 -0400 (Mon, 04 Jun 2007)
New Revision: 78587
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
Log:
2007-06-04 Jonathan Pobst <[EMAIL PROTECTED]>
* Button.cs: Completely reformat and a little refactor to bring
this closer to Mono circa 2007.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
2007-06-04 19:44:31 UTC (rev 78586)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs
2007-06-04 20:00:44 UTC (rev 78587)
@@ -42,127 +42,119 @@
#endregion // Local variables
#region Public Constructors
- public Button() {
+ public Button ()
+ {
dialog_result = DialogResult.None;
- SetStyle(ControlStyles.StandardDoubleClick, false);
+ SetStyle (ControlStyles.StandardDoubleClick, false);
}
#endregion // Public Constructors
- #region Internal methods
- internal override void HaveDoubleClick() {
- EventHandler eh = (EventHandler)(Events
[DoubleClickEvent]);
- if (eh != null)
- eh (this, EventArgs.Empty);
- }
-
+ #region Public Properties
#if NET_2_0
- internal override void Draw (PaintEventArgs pevent)
- {
- // System style does not use any of the new 2.0 stuff
- if (this.FlatStyle == FlatStyle.System) {
- base.Draw (pevent);
- return;
- }
-
- // FIXME: This should be called every time something
that can affect it
- // is changed, not every paint. Can only change so
many things at a time.
-
- // Figure out where our text and image should go
- Rectangle text_rectangle;
- Rectangle image_rectangle;
-
- ThemeEngine.Current.CalculateButtonTextAndImageLayout
(this, out text_rectangle, out image_rectangle);
-
- // Draw our button
- if (this.FlatStyle == FlatStyle.Standard)
- ThemeEngine.Current.DrawButton
(pevent.Graphics, this, text_rectangle, image_rectangle, pevent.ClipRectangle);
- else if (this.FlatStyle == FlatStyle.Flat)
- ThemeEngine.Current.DrawFlatButton
(pevent.Graphics, this, text_rectangle, image_rectangle, pevent.ClipRectangle);
- else if (this.FlatStyle == FlatStyle.Popup)
- ThemeEngine.Current.DrawPopupButton
(pevent.Graphics, this, text_rectangle, image_rectangle, pevent.ClipRectangle);
+ [Localizable (true)]
+ public AutoSizeMode AutoSizeMode {
+ get { return base.GetAutoSizeMode (); }
+ set { base.SetAutoSizeMode (value); }
}
#endif
- #endregion // Internal methods
- #region Public Instance Properties
- [DefaultValue(DialogResult.None)]
- public virtual DialogResult DialogResult { //
IButtonControl
- get {
- return dialog_result;
- }
- set {
- dialog_result = value;
- }
+ [DefaultValue (DialogResult.None)]
+ public virtual DialogResult DialogResult { //
IButtonControl
+ get { return dialog_result; }
+ set { dialog_result = value; }
}
- #endregion // Public Instance Properties
+ #endregion // Public Properties
- #region Protected Instance Properties
+ #region Protected Properties
protected override CreateParams CreateParams {
- get {
- return base.CreateParams;
- }
+ get { return base.CreateParams; }
}
- #endregion // Protected Instance Properties
+ #endregion // Protected Properties
- #region Public Instance Methods
- public virtual void NotifyDefault(bool value) { //
IButtonControl
+ #region Public Methods
+ public virtual void NotifyDefault (bool value) //
IButtonControl
+ {
this.IsDefault = value;
}
- public void PerformClick() { //
IButtonControl
+ public void PerformClick () //
IButtonControl
+ {
if (CanSelect)
- OnClick(EventArgs.Empty);
+ OnClick (EventArgs.Empty);
}
- public override string ToString() {
- return base.ToString() + ", Text: " + this.Text;
+ public override string ToString ()
+ {
+ return base.ToString () + ", Text: " + this.Text;
}
- #endregion // Public Instance Methods
+ #endregion // Public Methods
- #region Protected Instance Methods
- protected override void OnClick(EventArgs e) {
+ #region Protected Methods
+ protected override void OnClick (EventArgs e)
+ {
if (dialog_result != DialogResult.None) {
Form p = FindForm ();
- if (p != null) {
+ if (p != null)
p.DialogResult = dialog_result;
- }
}
- base.OnClick(e);
+
+ base.OnClick (e);
}
- protected override void OnMouseUp(MouseEventArgs e) {
+#if NET_2_0
+ protected override void OnFontChanged (EventArgs e)
+ {
+ base.OnFontChanged (e);
+ }
+
+ protected override void OnMouseEnter (EventArgs e)
+ {
+ base.OnMouseEnter (e);
+ }
+
+ protected override void OnMouseLeave (EventArgs e)
+ {
+ base.OnMouseLeave (e);
+ }
+#endif
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
base.OnMouseUp (e);
}
- protected override bool ProcessMnemonic(char charCode) {
- if (this.UseMnemonic && IsMnemonic(charCode, Text) ==
true) {
- PerformClick();
+#if NET_2_0
+ protected override void OnTextChanged (EventArgs e)
+ {
+ base.OnTextChanged (e);
+ }
+#endif
+
+ protected override bool ProcessMnemonic (char charCode)
+ {
+ if (this.UseMnemonic && IsMnemonic (charCode, Text) ==
true) {
+ PerformClick ();
return true;
}
-
- return base.ProcessMnemonic(charCode);
+
+ return base.ProcessMnemonic (charCode);
}
- protected override void WndProc(ref Message m) {
+ protected override void WndProc (ref Message m)
+ {
base.WndProc (ref m);
}
- #endregion // Protected Instance Methods
+ #endregion // Protected Methods
#region Events
- static object DoubleClickEvent = new object ();
-
- // XXX this and HaveDoubleClick above need to be
- // looked at.. it's far more likely that this just
- // uses base.DoubleClick, and HaveDoubleClick goes
- // away in favor of calls to OnDoubleClick.
- [Browsable(false)]
+ [Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public new event EventHandler DoubleClick {
- add { Events.AddHandler (DoubleClickEvent, value); }
- remove { Events.RemoveHandler (DoubleClickEvent,
value); }
+ add { base.DoubleClick += value; }
+ remove { base.DoubleClick -= value; }
}
-
+
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Advanced)]
@@ -172,27 +164,35 @@
}
#endif
#endregion // Events
-
+
+ #region Internal methods
#if NET_2_0
- protected override void OnFontChanged (EventArgs e)
+ internal override void Draw (PaintEventArgs pevent)
{
- base.OnFontChanged (e);
- }
-
- protected override void OnMouseEnter (EventArgs e)
- {
- base.OnMouseEnter (e);
- }
-
- protected override void OnMouseLeave (EventArgs e)
- {
- base.OnMouseLeave (e);
- }
+ // System style does not use any of the new 2.0 stuff
+ if (this.FlatStyle == FlatStyle.System) {
+ base.Draw (pevent);
+ return;
+ }
- protected override void OnTextChanged (EventArgs e)
- {
- base.OnTextChanged (e);
+ // FIXME: This should be called every time something
that can affect it
+ // is changed, not every paint. Can only change so
many things at a time.
+
+ // Figure out where our text and image should go
+ Rectangle text_rectangle;
+ Rectangle image_rectangle;
+
+ ThemeEngine.Current.CalculateButtonTextAndImageLayout
(this, out text_rectangle, out image_rectangle);
+
+ // Draw our button
+ if (this.FlatStyle == FlatStyle.Standard)
+ ThemeEngine.Current.DrawButton
(pevent.Graphics, this, text_rectangle, image_rectangle, pevent.ClipRectangle);
+ else if (this.FlatStyle == FlatStyle.Flat)
+ ThemeEngine.Current.DrawFlatButton
(pevent.Graphics, this, text_rectangle, image_rectangle, pevent.ClipRectangle);
+ else if (this.FlatStyle == FlatStyle.Popup)
+ ThemeEngine.Current.DrawPopupButton
(pevent.Graphics, this, text_rectangle, image_rectangle, pevent.ClipRectangle);
}
#endif
+ #endregion // Internal methods
}
}
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-06-04 19:44:31 UTC (rev 78586)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-06-04 20:00:44 UTC (rev 78587)
@@ -1,5 +1,10 @@
2007-06-04 Jonathan Pobst <[EMAIL PROTECTED]>
+ * Button.cs: Completely reformat and a little refactor to bring
+ this closer to Mono circa 2007.
+
+2007-06-04 Jonathan Pobst <[EMAIL PROTECTED]>
+
* CheckBox.cs, Form.cs, RadioButton.cs: Change call to ButtonBase.Redraw
to be ButtonBase.Invalidate.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches