* Test/System.Windows.Forms/DataGridViewCellTest.cs: Added
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ButtonBase.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2004-2006 Novell, Inc.
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24 //
25
26 using System.ComponentModel;
27 using System.ComponentModel.Design;
28 using System.Drawing;
29 using System.Drawing.Text;
30 using System.Runtime.InteropServices;
31
32 namespace System.Windows.Forms {
33 #if NET_2_0
34         [ClassInterface (ClassInterfaceType.AutoDispatch)]
35         [ComVisible (true)]
36         [Designer ("System.Windows.Forms.Design.ButtonBaseDesigner, " + Consts.AssemblySystem_Design,
37                    "System.ComponentModel.Design.IDesigner")]
38 #endif
39         public abstract class ButtonBase : Control
40         {
41                 #region Local Variables
42                 private FlatStyle               flat_style;
43                 private int                     image_index;
44                 internal Image                  image;
45                 internal ImageList              image_list;
46                 private ContentAlignment        image_alignment;
47                 internal ContentAlignment       text_alignment;
48                 private bool                    is_default;
49                 internal bool                   is_pressed;
50 //              private bool                    enter_state;
51                 internal StringFormat           text_format;
52                 internal bool                   paint_as_acceptbutton;
53                 
54                 // Properties are 2.0, but variables used in 1.1 for common drawing code
55                 private bool                    auto_ellipsis;
56                 private FlatButtonAppearance    flat_button_appearance;
57 #if NET_2_0             
58                 private string                  image_key;
59 #endif
60                 private TextImageRelation       text_image_relation;
61                 private TextFormatFlags         text_format_flags;
62                 private bool                    use_mnemonic;
63                 private bool                    use_visual_style_back_color;
64                 #endregion      // Local Variables
65
66                 #region Public Constructors
67                 protected ButtonBase() : base()
68                 {
69                         flat_style      = FlatStyle.Standard;
70 #if NET_2_0
71                         flat_button_appearance = new FlatButtonAppearance (this);
72                         this.image_key = string.Empty;
73                         this.text_image_relation = TextImageRelation.Overlay;
74                         this.use_mnemonic = true;
75                         use_visual_style_back_color = true;
76 #endif
77                         image_index     = -1;
78                         image           = null;
79                         image_list      = null;
80                         image_alignment = ContentAlignment.MiddleCenter;
81                         ImeMode         = ImeMode.Disable;
82                         text_alignment  = ContentAlignment.MiddleCenter;
83                         is_default      = false;
84                         is_pressed      = false;
85                         text_format     = new StringFormat();
86                         text_format.Alignment = StringAlignment.Center;
87                         text_format.LineAlignment = StringAlignment.Center;
88                         text_format.HotkeyPrefix = HotkeyPrefix.Show;
89
90                         text_format_flags = TextFormatFlags.HorizontalCenter;
91                         text_format_flags |= TextFormatFlags.VerticalCenter;
92
93                         SetStyle (ControlStyles.ResizeRedraw | 
94                                 ControlStyles.Opaque | 
95                                 ControlStyles.UserMouse | 
96                                 ControlStyles.SupportsTransparentBackColor | 
97                                 ControlStyles.CacheText |
98 #if NET_2_0
99                                 ControlStyles.OptimizedDoubleBuffer, true);
100 #else
101                                 ControlStyles.DoubleBuffer, true);
102 #endif
103                         SetStyle (ControlStyles.StandardClick, false);
104                 }
105                 #endregion      // Public Constructors
106
107                 #region Public Properties
108                 [Browsable (true)]
109                 [DefaultValue (false)]
110                 [EditorBrowsable (EditorBrowsableState.Always)]
111 #if NET_2_0
112                 public
113 #else
114                 internal
115 #endif
116                 bool AutoEllipsis {
117                         get { return this.auto_ellipsis; }
118                         set
119                         {
120                                 if (this.auto_ellipsis != value) {
121                                         this.auto_ellipsis = value;
122
123                                         if (this.auto_ellipsis) {
124                                                 text_format_flags |= TextFormatFlags.EndEllipsis;
125                                                 text_format_flags &= ~TextFormatFlags.WordBreak;
126                                         } else {
127                                                 text_format_flags &= ~TextFormatFlags.EndEllipsis;
128                                                 text_format_flags |= TextFormatFlags.WordBreak;
129                                         }
130
131                                         this.Invalidate ();
132                                 }
133                         }
134                 }
135
136 #if NET_2_0
137                 [Browsable (true)]
138                 [EditorBrowsable (EditorBrowsableState.Always)]
139                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
140                 public override bool AutoSize {
141                         get { return base.AutoSize; }
142                         set { base.AutoSize = value; }
143                 }
144
145                 public override Color BackColor {
146                         get { return base.BackColor; }
147                         set { base.BackColor = value; }
148                 }
149 #endif
150
151                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
152                 [Browsable (true)]
153 #if NET_2_0
154                 public
155 #else
156                 internal
157 #endif
158                 FlatButtonAppearance FlatAppearance {
159                         get { return flat_button_appearance; }
160                 }
161
162                 [Localizable(true)]
163                 [DefaultValue(FlatStyle.Standard)]
164                 [MWFDescription("Determines look of button"), MWFCategory("Appearance")]
165                 public FlatStyle FlatStyle {
166                         get { return flat_style; }
167                         set { 
168                                 if (flat_style != value) {
169                                         flat_style = value;
170                                         Invalidate();
171                                 }
172                         }
173                 }
174
175                 [Localizable(true)]
176                 [MWFDescription("Sets image to be displayed on button face"), MWFCategory("Appearance")]
177                 public Image Image {
178                         get {
179                                 if (this.image != null)
180                                         return this.image;
181
182                                 if (this.image_index >= 0)
183                                         if (this.image_list != null)
184                                                 return this.image_list.Images[this.image_index];
185
186 #if NET_2_0
187                                 if (!string.IsNullOrEmpty (this.image_key))
188                                         if (this.image_list != null)
189                                                 return this.image_list.Images[this.image_key];
190 #endif
191                                 return null;
192                         }
193                         set {
194                                 if (this.image != value) {
195                                         this.image = value;
196                                         this.image_index = -1;
197 #if NET_2_0
198                                         this.image_key = string.Empty;
199 #endif
200                                         this.image_list = null;
201
202 #if NET_2_0
203                                         if (this.AutoSize && this.Parent != null)
204                                                 this.Parent.PerformLayout (this, "Image");
205 #endif
206
207                                         Invalidate ();
208                                 }
209                         }
210                 }
211
212                 internal bool ShouldSerializeImage ()
213                 {
214                         return this.Image != null;
215                 }
216
217                 [Localizable(true)]
218                 [DefaultValue(ContentAlignment.MiddleCenter)]
219                 [MWFDescription("Sets the alignment of the image to be displayed on button face"), MWFCategory("Appearance")]
220                 public ContentAlignment ImageAlign {
221                         get { return image_alignment; }
222                         set {
223                                 if (image_alignment != value) {
224                                         image_alignment = value;
225                                         Invalidate ();
226                                 }
227                         }
228                 }
229
230                 [Localizable(true)]
231                 [DefaultValue(-1)]
232                 [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
233                 [TypeConverter(typeof(ImageIndexConverter))]
234                 [MWFDescription("Index of image to display, if ImageList is used for button face images"), MWFCategory("Appearance")]
235 #if NET_2_0
236                 [RefreshProperties (RefreshProperties.Repaint)]
237 #endif
238                 public int ImageIndex {
239                         get {
240                                 if (image_list == null)
241                                         return -1;
242
243                                 return image_index;
244                         }
245                         set {
246                                 if (this.image_index != value) {
247                                         this.image_index = value;
248                                         this.image = null;
249 #if NET_2_0
250                                         this.image_key = string.Empty;
251 #endif
252                                         Invalidate ();
253                                 }
254                         }
255                 }
256
257 #if NET_2_0
258                 [Localizable (true)]
259                 [DefaultValue ("")]
260                 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
261                 [RefreshProperties (RefreshProperties.Repaint)]
262                 [TypeConverter (typeof (ImageKeyConverter))]
263                 public string ImageKey {
264                         get { return this.image_key; }
265                         set {
266                                 if (this.image_key != value) {
267                                         this.image = null;
268                                         this.image_index = -1;
269                                         this.image_key = value;
270                                         this.Invalidate ();
271                                 }
272                         }
273                 }
274 #endif
275
276                 [DefaultValue(null)]
277                 [MWFDescription("ImageList used for ImageIndex"), MWFCategory("Appearance")]
278 #if NET_2_0
279                 [RefreshProperties (RefreshProperties.Repaint)]
280 #endif
281                 public ImageList ImageList {
282                         get { return image_list; }
283                         set {
284                                 if (image_list != value) {
285                                         image_list = value;
286                                 
287                                         if (value != null && image != null)
288                                                 image = null;
289                                 
290                                         Invalidate ();
291                                 }
292                         }
293                 }
294
295                 [Browsable(false)]
296                 [EditorBrowsable (EditorBrowsableState.Never)]
297                 public new ImeMode ImeMode {
298                         get { return base.ImeMode; }
299                         set { base.ImeMode = value; }
300                 }
301
302 #if NET_2_0
303                 [SettingsBindable (true)]
304                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
305                          "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
306                 public override string Text {
307                         get { return base.Text; }
308                         set { base.Text = value; }
309                 }
310 #endif
311
312                 [Localizable(true)]
313                 [DefaultValue(ContentAlignment.MiddleCenter)]
314                 [MWFDescription("Alignment for button text"), MWFCategory("Appearance")]
315                 public virtual ContentAlignment TextAlign {
316                         get { return text_alignment; }
317                         set {
318                                 if (text_alignment != value) {
319                                         text_alignment = value;
320
321                                         text_format_flags &= ~TextFormatFlags.Bottom;
322                                         text_format_flags &= ~TextFormatFlags.Top;
323                                         text_format_flags &= ~TextFormatFlags.Left;
324                                         text_format_flags &= ~TextFormatFlags.Right;
325                                         text_format_flags &= ~TextFormatFlags.HorizontalCenter;
326                                         text_format_flags &= ~TextFormatFlags.VerticalCenter;
327                                         
328                                         switch (text_alignment) {
329                                                 case ContentAlignment.TopLeft:
330                                                         text_format.Alignment=StringAlignment.Near;
331                                                         text_format.LineAlignment=StringAlignment.Near;
332                                                         break;
333
334                                                 case ContentAlignment.TopCenter:
335                                                         text_format.Alignment=StringAlignment.Center;
336                                                         text_format.LineAlignment=StringAlignment.Near;
337                                                         text_format_flags |= TextFormatFlags.HorizontalCenter;
338                                                         break;
339
340                                                 case ContentAlignment.TopRight:
341                                                         text_format.Alignment=StringAlignment.Far;
342                                                         text_format.LineAlignment=StringAlignment.Near;
343                                                         text_format_flags |= TextFormatFlags.Right;
344                                                         break;
345
346                                                 case ContentAlignment.MiddleLeft:
347                                                         text_format.Alignment=StringAlignment.Near;
348                                                         text_format.LineAlignment=StringAlignment.Center;
349                                                         text_format_flags |= TextFormatFlags.VerticalCenter;
350                                                         break;
351
352                                                 case ContentAlignment.MiddleCenter:
353                                                         text_format.Alignment=StringAlignment.Center;
354                                                         text_format.LineAlignment=StringAlignment.Center;
355                                                         text_format_flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
356                                                         break;
357
358                                                 case ContentAlignment.MiddleRight:
359                                                         text_format.Alignment=StringAlignment.Far;
360                                                         text_format.LineAlignment=StringAlignment.Center;
361                                                         text_format_flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
362                                                         break;
363
364                                                 case ContentAlignment.BottomLeft:
365                                                         text_format.Alignment=StringAlignment.Near;
366                                                         text_format.LineAlignment=StringAlignment.Far;
367                                                         text_format_flags |= TextFormatFlags.Bottom;
368                                                         break;
369
370                                                 case ContentAlignment.BottomCenter:
371                                                         text_format.Alignment=StringAlignment.Center;
372                                                         text_format.LineAlignment=StringAlignment.Far;
373                                                         text_format_flags |= TextFormatFlags.HorizontalCenter | TextFormatFlags.Bottom;
374                                                         break;
375
376                                                 case ContentAlignment.BottomRight:
377                                                         text_format.Alignment=StringAlignment.Far;
378                                                         text_format.LineAlignment=StringAlignment.Far;
379                                                         text_format_flags |= TextFormatFlags.Bottom | TextFormatFlags.Right;
380                                                         break;
381                                         }
382                                         
383                                         Invalidate();
384                                 }
385                         }
386                 }
387
388 #if NET_2_0
389                 [Localizable (true)]
390                 [DefaultValue (TextImageRelation.Overlay)]
391                 public
392 #else
393                 internal
394 #endif
395                 TextImageRelation TextImageRelation {
396                         get { return this.text_image_relation; }
397                         set {
398                                 if (!Enum.IsDefined (typeof (TextImageRelation), value))
399                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for TextImageRelation", value));
400
401                                 if (this.text_image_relation != value) {
402                                         this.text_image_relation = value;
403                                         
404 #if NET_2_0
405                                         if (this.AutoSize && this.Parent != null)
406                                                 this.Parent.PerformLayout (this, "TextImageRelation");
407 #endif
408                                         
409                                         this.Invalidate ();
410                                 }
411                         }
412                 }
413
414                 [DefaultValue (false)]
415 #if NET_2_0
416                 public
417 #else
418                 internal
419 #endif
420                 bool UseCompatibleTextRendering {
421                         get { return use_compatible_text_rendering; }
422                         set {
423                                 if (use_compatible_text_rendering != value) {
424                                         use_compatible_text_rendering = value;
425                                         Invalidate ();
426                                 }
427                         }
428                 }
429                 
430                 [DefaultValue (true)]
431 #if NET_2_0
432                 public
433 #else
434                 internal
435 #endif
436                 bool UseMnemonic {
437                         get { return this.use_mnemonic; }
438                         set {
439                                 if (this.use_mnemonic != value) {
440                                         this.use_mnemonic = value;
441
442                                         if (this.use_mnemonic)
443                                                 text_format_flags &= ~TextFormatFlags.NoPrefix;
444                                         else
445                                                 text_format_flags |= TextFormatFlags.NoPrefix;
446
447                                         this.Invalidate ();
448                                 }
449                         }
450                 }
451
452 #if NET_2_0
453                 public
454 #else
455                 internal
456 #endif
457                 bool UseVisualStyleBackColor {
458                         get { return use_visual_style_back_color; }
459                         set {
460                                 if (use_visual_style_back_color != value) {
461                                         use_visual_style_back_color = value;
462                                         Invalidate ();
463                                 }
464                         }
465                 }
466                 #endregion      // Public Instance Properties
467
468                 #region Protected Properties
469                 protected override CreateParams CreateParams {
470                         get { return base.CreateParams; }
471                 }
472
473                 protected override ImeMode DefaultImeMode {
474                         get { return ImeMode.Disable; }
475                 }
476
477                 protected override Size DefaultSize {
478                         get { return ThemeEngine.Current.ButtonBaseDefaultSize; }
479                 }
480
481                 protected bool IsDefault {
482                         get { return is_default; }
483                         set {
484                                 if (is_default != value) {
485                                         is_default = true;
486                                         Invalidate ();
487                                 }
488                         }
489                 }
490                 #endregion      // Public Instance Properties
491
492                 #region Public Methods
493 #if NET_2_0
494                 // The base calls into GetPreferredSizeCore, which we will override in our subclasses
495                 public override Size GetPreferredSize (Size proposedSize)
496                 {
497                         return base.GetPreferredSize (proposedSize);
498                 }
499 #endif
500                 #endregion
501                 
502                 #region Protected Methods
503                 protected override AccessibleObject CreateAccessibilityInstance ()
504                 {
505                         return new ButtonBaseAccessibleObject (this);
506                 }
507
508                 protected override void Dispose (bool disposing)
509                 {
510                         base.Dispose (disposing);
511                 }
512
513                 protected override void OnEnabledChanged (EventArgs e)
514                 {
515                         base.OnEnabledChanged (e);
516                 }
517
518                 protected override void OnGotFocus (EventArgs e)
519                 {
520                         Invalidate ();
521                         base.OnGotFocus (e);
522                 }
523
524                 protected override void OnKeyDown (KeyEventArgs kevent)
525                 {
526                         if (kevent.KeyData == Keys.Space) {
527                                 is_pressed = true;
528                                 Invalidate ();
529                                 kevent.Handled = true;
530                         }
531                         
532                         base.OnKeyDown (kevent);
533                 }
534
535                 protected override void OnKeyUp (KeyEventArgs kevent)
536                 {
537                         if (kevent.KeyData == Keys.Space) {
538                                 is_pressed = false;
539                                 Invalidate ();
540                                 OnClick (EventArgs.Empty);
541                                 kevent.Handled = true;
542                         }
543                         
544                         base.OnKeyUp (kevent);
545                 }
546
547                 protected override void OnLostFocus (EventArgs e)
548                 {
549                         Invalidate ();
550                         base.OnLostFocus (e);
551                 }
552
553                 protected override void OnMouseDown (MouseEventArgs mevent)
554                 {
555                         if ((mevent.Button & MouseButtons.Left) != 0) {
556                                 is_pressed = true;
557                                 Invalidate ();
558                         }
559
560                         base.OnMouseDown (mevent);
561                 }
562
563                 protected override void OnMouseEnter (EventArgs e)
564                 {
565                         is_entered = true;
566                         Invalidate ();
567                         base.OnMouseEnter (e);
568                 }
569
570                 protected override void OnMouseLeave (EventArgs e)
571                 {
572                         is_entered = false;
573                         Invalidate ();
574                         base.OnMouseLeave (e);
575                 }
576
577                 protected override void OnMouseMove (MouseEventArgs mevent) {
578                         bool inside = false;
579                         bool redraw = false;
580
581                         if (ClientRectangle.Contains (mevent.Location))
582                                 inside = true;
583
584                         // If the button was pressed and we leave, release the button press and vice versa
585                         if ((mevent.Button & MouseButtons.Left) != 0) {
586                                 if (this.Capture && (inside != is_pressed)) {
587                                         is_pressed = inside;
588                                         redraw = true;
589                                 }
590                         }
591
592                         if (is_entered != inside) {
593                                 is_entered = inside;
594                                 redraw = true;
595                         }
596
597                         if (redraw)
598                                 Invalidate ();
599
600                         base.OnMouseMove (mevent);
601                 }
602
603                 protected override void OnMouseUp (MouseEventArgs mevent)
604                 {
605                         if (this.Capture && ((mevent.Button & MouseButtons.Left) != 0)) {
606                                 this.Capture = false;
607
608                                 if (is_pressed) {
609                                         is_pressed = false;
610                                         Invalidate ();
611                                 } else if ((this.flat_style == FlatStyle.Flat) || (this.flat_style == FlatStyle.Popup)) {
612                                         Invalidate ();
613                                 }
614
615                                 if (ClientRectangle.Contains (mevent.Location))
616                                         OnClick (EventArgs.Empty);
617                         }
618                         
619                         base.OnMouseUp (mevent);
620                 }
621
622                 protected override void OnPaint (PaintEventArgs pevent)
623                 {
624                         Draw (pevent);
625                         base.OnPaint (pevent);
626                 }
627
628                 protected override void OnParentChanged (EventArgs e)
629                 {
630                         base.OnParentChanged (e);
631                 }
632
633                 protected override void OnTextChanged (EventArgs e)
634                 {
635                         Invalidate ();
636                         base.OnTextChanged (e);
637                 }
638
639                 protected override void OnVisibleChanged (EventArgs e)
640                 {
641                         if (!Visible) {
642                                 is_pressed = false;
643                                 is_entered = false;
644                         }
645                         
646                         base.OnVisibleChanged (e);
647                 }
648
649                 protected void ResetFlagsandPaint ()
650                 {
651                         // Nothing to do; MS internal
652                         // Should we do Invalidate (); ?
653                 }
654
655                 protected override void WndProc (ref Message m)
656                 {
657                         switch ((Msg)m.Msg) {
658                                 case Msg.WM_LBUTTONDBLCLK: {
659                                         HaveDoubleClick ();
660                                         break;
661                                 }
662
663                                 case Msg.WM_MBUTTONDBLCLK: {
664                                         HaveDoubleClick ();
665                                         break;
666                                 }
667
668                                 case Msg.WM_RBUTTONDBLCLK: {
669                                         HaveDoubleClick ();
670                                         break;
671                                 }
672                         }
673                         
674                         base.WndProc (ref m);
675                 }
676                 #endregion      // Public Instance Properties
677
678                 #region Public Events
679 #if NET_2_0
680                 [Browsable (true)]
681                 [EditorBrowsable (EditorBrowsableState.Always)]
682                 public new event EventHandler AutoSizeChanged {
683                         add { base.AutoSizeChanged += value; }
684                         remove { base.AutoSizeChanged -= value; }
685                 }
686 #endif
687
688                 [Browsable (false)]
689                 [EditorBrowsable (EditorBrowsableState.Never)]
690                 public new event EventHandler ImeModeChanged {
691                         add { base.ImeModeChanged += value; }
692                         remove { base.ImeModeChanged -= value; }
693                 }
694                 #endregion      // Events
695
696                 #region Internal Properties
697                 internal ButtonState ButtonState {
698                         get {
699                                 ButtonState ret = ButtonState.Normal;
700
701                                 if (Enabled) {
702                                         // Popup style is only followed as long as the mouse isn't "in" the control
703                                         if (is_entered) {
704                                                 if (flat_style == FlatStyle.Flat) {
705                                                         ret |= ButtonState.Flat;
706                                                 }
707                                         } else {
708                                                 if (flat_style == FlatStyle.Flat || flat_style == FlatStyle.Popup) {
709                                                         ret |= ButtonState.Flat;
710                                                 }
711                                         }
712
713                                         if (is_entered && is_pressed) {
714                                                 ret |= ButtonState.Pushed;
715                                         }
716                                 } else {
717                                         ret |= ButtonState.Inactive;
718                                         if ((flat_style == FlatStyle.Flat) || (flat_style == FlatStyle.Popup)) {
719                                                 ret |= ButtonState.Flat;
720                                         }
721                                 }
722                                 return ret;
723                         }
724                 }
725
726                 internal bool Pressed {
727                         get { return this.is_pressed; }
728                 }
729                 
730                 // The flags to be used for MeasureText and DrawText
731                 internal TextFormatFlags TextFormatFlags {
732                         get { return this.text_format_flags; }
733                 }
734                 #endregion
735                 
736                 #region Internal Methods
737                 // Derived classes should override Draw method and we dont want
738                 // to break the control signature, hence this approach.
739                 internal virtual void Draw (PaintEventArgs pevent)
740                 {
741                         ThemeEngine.Current.DrawButtonBase (pevent.Graphics, pevent.ClipRectangle, this);
742                 }
743                 
744                 internal virtual void HaveDoubleClick ()
745                 {
746                         // override me
747                 }
748
749                 internal override void OnPaintBackgroundInternal (PaintEventArgs e)
750                 {
751                         base.OnPaintBackground (e);
752                 }
753                 #endregion      // Internal Methods
754
755                 #region ButtonBaseAccessibleObject sub-class
756                 [ComVisible (true)]
757                 public class ButtonBaseAccessibleObject : ControlAccessibleObject
758                 {
759                         #region ButtonBaseAccessibleObject Local Variables
760                         private new Control owner;
761                         #endregion      // ButtonBaseAccessibleObject Local Variables
762
763                         #region ButtonBaseAccessibleObject Constructors
764                         public ButtonBaseAccessibleObject (Control owner) : base (owner)
765                         {
766                                 if (owner == null)
767                                         throw new ArgumentNullException ("owner");
768                                         
769                                 this.owner = owner;
770                                 default_action = "Press";
771                                 role = AccessibleRole.PushButton;
772                         }
773                         #endregion      // ButtonBaseAccessibleObject Constructors
774
775                         #region Public Properties
776 #if NET_2_0
777                         public override AccessibleStates State {
778                                 get { return base.State; }
779                         }
780 #endif
781                         #endregion
782                         
783                         #region ButtonBaseAccessibleObject Methods
784                         public override void DoDefaultAction ()
785                         {
786                                 ((ButtonBase)owner).OnClick (EventArgs.Empty);
787                         }
788                         #endregion      // ButtonBaseAccessibleObject Methods
789                 }
790                 #endregion      // ButtonBaseAccessibleObject sub-class
791         }
792 }