* TextBoxBase.cs: These seem to be the correct values.
[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                 private string                  image_key;
58                 private TextImageRelation       text_image_relation;
59                 private TextFormatFlags         text_format_flags;
60                 private bool                    use_mnemonic;
61                 private bool                    use_visual_style_back_color;
62                 #endregion      // Local Variables
63
64                 #region ButtonBaseAccessibleObject sub-class
65                 [ComVisible(true)]
66                 public class ButtonBaseAccessibleObject : ControlAccessibleObject {
67                         #region ButtonBaseAccessibleObject Local Variables
68                         private new Control     owner;
69                         #endregion      // ButtonBaseAccessibleObject Local Variables
70
71                         #region ButtonBaseAccessibleObject Constructors
72                         public ButtonBaseAccessibleObject (Control owner)
73                                 : base (owner)
74                         {
75                                 if (owner == null)
76                                         throw new ArgumentNullException ("owner");
77                                 this.owner = owner;
78                                 default_action = "Press";
79                                 role = AccessibleRole.PushButton;
80                         }
81                         #endregion      // ButtonBaseAccessibleObject Constructors
82
83                         #region ButtonBaseAccessibleObject Methods
84                         public override void DoDefaultAction() {
85                                 ((ButtonBase)owner).PerformClick();
86                         }
87                         #endregion      // ButtonBaseAccessibleObject Methods
88                 }
89                 #endregion      // ButtonBaseAccessibleObject sub-class
90
91                 #region Private Properties and Methods
92                 internal ButtonState ButtonState {
93                         get {
94                                 ButtonState     ret = ButtonState.Normal;
95
96                                 if (Enabled) {
97                                         // Popup style is only followed as long as the mouse isn't "in" the control
98                                         if (is_entered) {
99                                                 if (flat_style == FlatStyle.Flat) {
100                                                         ret |= ButtonState.Flat;
101                                                 }
102                                         } else {
103                                                 if (flat_style == FlatStyle.Flat || flat_style == FlatStyle.Popup) {
104                                                         ret |= ButtonState.Flat;
105                                                 }
106                                         }
107
108                                         if (is_entered && is_pressed) {
109                                                 ret |= ButtonState.Pushed;
110                                         }
111                                 } else {
112                                         ret |= ButtonState.Inactive;
113                                         if ((flat_style == FlatStyle.Flat) || (flat_style == FlatStyle.Popup)) {
114                                                 ret |= ButtonState.Flat;
115                                         }
116                                 }
117                                 return ret;
118                         }
119                 }
120
121                 internal void Redraw() {
122                         Refresh ();
123                 }
124
125                 // Derived classes should override Draw method and we dont want
126                 // to break the control signature, hence this approach.
127                 internal virtual void Draw (PaintEventArgs pevent) {
128                         ThemeEngine.Current.DrawButtonBase (pevent.Graphics, pevent.ClipRectangle, this);
129                 }
130
131                 internal virtual void HaveDoubleClick() {
132                         // override me
133                 }
134
135                 private void RedrawEvent(object sender, System.EventArgs e) {
136                         Invalidate();
137                 }
138
139                 #endregion      // Private Properties and Methods
140
141                 #region Public Constructors
142                 protected ButtonBase() : base()
143                 {
144                         flat_style      = FlatStyle.Standard;
145 #if NET_2_0
146                         flat_button_appearance = new FlatButtonAppearance (this);
147                         this.image_key = string.Empty;
148                         this.text_image_relation = TextImageRelation.Overlay;
149                         this.use_mnemonic = true;
150 #endif
151                         image_index     = -1;
152                         image           = null;
153                         image_list      = null;
154                         image_alignment = ContentAlignment.MiddleCenter;
155                         ImeMode         = ImeMode.Disable;
156                         text_alignment  = ContentAlignment.MiddleCenter;
157                         is_default      = false;
158                         is_pressed      = false;
159                         text_format     = new StringFormat();
160                         text_format.Alignment = StringAlignment.Center;
161                         text_format.LineAlignment = StringAlignment.Center;
162                         text_format.HotkeyPrefix = HotkeyPrefix.Show;
163
164                         text_format_flags = TextFormatFlags.HorizontalCenter;
165                         text_format_flags |= TextFormatFlags.VerticalCenter;
166                 
167                         TextChanged+=new System.EventHandler(RedrawEvent);
168                         SizeChanged+=new EventHandler(RedrawEvent);
169
170                         SetStyle(ControlStyles.ResizeRedraw | 
171                                 ControlStyles.Opaque | 
172                                 ControlStyles.UserMouse | 
173                                 ControlStyles.SupportsTransparentBackColor | 
174                                 ControlStyles.CacheText |
175 #if NET_2_0
176                                 ControlStyles.OptimizedDoubleBuffer, true);
177 #else
178                                 ControlStyles.DoubleBuffer, true);
179 #endif
180                         SetStyle(ControlStyles.StandardClick, false);
181                 }
182                 #endregion      // Public Constructors
183
184                 #region Public Instance Properties
185                 [Localizable(true)]
186                 [DefaultValue(FlatStyle.Standard)]
187                 [MWFDescription("Determines look of button"), MWFCategory("Appearance")]
188                 public FlatStyle FlatStyle {
189                         get {
190                                 return flat_style;
191                         }
192
193                         set {
194                                 flat_style = value;
195                                 Invalidate();
196                         }
197                 }
198
199                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
200                 [Browsable(true)]
201 #if NET_2_0
202                 public 
203 #else
204                 internal
205 #endif
206                 FlatButtonAppearance FlatAppearance
207                 {
208                         get { return flat_button_appearance; }
209                 }
210
211                 [Localizable(true)]
212                 [MWFDescription("Sets image to be displayed on button face"), MWFCategory("Appearance")]
213                 public Image Image {
214                         get {
215                                 if (this.image != null)
216                                         return this.image;
217
218                                 if (this.image_index >= 0)
219                                         if (this.image_list != null)
220                                                 return this.image_list.Images[this.image_index];
221
222 #if NET_2_0
223                                 if (!string.IsNullOrEmpty (this.image_key))
224                                         if (this.image_list != null)
225                                                 return this.image_list.Images[this.image_key];
226 #endif
227                                 return null;
228                         }
229                         set {
230                                 if (this.image != value) {
231                                         this.image = value;
232                                         this.image_index = -1;
233                                         this.image_key = string.Empty;
234                                         this.image_list = null;
235                                         Invalidate();
236                                 }
237                         }
238                 }
239
240                 [Localizable(true)]
241                 [DefaultValue(ContentAlignment.MiddleCenter)]
242                 [MWFDescription("Sets the alignment of the image to be displayed on button face"), MWFCategory("Appearance")]
243                 public ContentAlignment ImageAlign {
244                         get {
245                                 return image_alignment;
246                         }
247
248                         set {
249                                 image_alignment=value;
250                                 Invalidate();
251                         }
252                 }
253
254                 [Localizable(true)]
255                 [DefaultValue(-1)]
256                 [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
257                 [TypeConverter(typeof(ImageIndexConverter))]
258                 [MWFDescription("Index of image to display, if ImageList is used for button face images"), MWFCategory("Appearance")]
259 #if NET_2_0
260                 [RefreshProperties (RefreshProperties.Repaint)]
261 #endif
262                 public int ImageIndex {
263                         get {
264                                 if (image_list==null) {
265                                         return -1;
266                                 }
267                                 return image_index;
268                         }
269
270                         set {
271                                 if (this.image_index != value) {
272                                         this.image_index = value;
273                                         this.image = null;
274                                         this.image_key = string.Empty;
275                                         Invalidate();
276                                 }
277                         }
278                 }
279
280                 [DefaultValue(null)]
281                 [MWFDescription("ImageList used for ImageIndex"), MWFCategory("Appearance")]
282 #if NET_2_0
283                 [RefreshProperties (RefreshProperties.Repaint)]
284 #endif
285                 public ImageList ImageList {
286                         get {
287                                 return image_list;
288                         }
289
290                         set {
291                                 image_list = value;
292                                 if (value != null) {
293                                         if (image != null) {
294                                                 image=null;
295                                         }
296                                 }
297                                 Invalidate();
298                         }
299                 }
300
301                 [Browsable(false)]
302                 [EditorBrowsable (EditorBrowsableState.Never)]
303                 public new ImeMode ImeMode {
304                         get { return base.ImeMode; }
305                         set { base.ImeMode = value; }
306                 }
307
308                 [Localizable(true)]
309                 [DefaultValue(ContentAlignment.MiddleCenter)]
310                 [MWFDescription("Alignment for button text"), MWFCategory("Appearance")]
311                 public virtual ContentAlignment TextAlign {
312                         get {
313                                 return text_alignment;
314                         }
315
316                         set {
317                                 if (text_alignment != value) {
318                                         text_alignment = value;
319
320                                         text_format_flags &= ~TextFormatFlags.Bottom;
321                                         text_format_flags &= ~TextFormatFlags.Top;
322                                         text_format_flags &= ~TextFormatFlags.Left;
323                                         text_format_flags &= ~TextFormatFlags.Right;
324                                         text_format_flags &= ~TextFormatFlags.HorizontalCenter;
325                                         text_format_flags &= ~TextFormatFlags.VerticalCenter;
326                                         
327                                         switch(text_alignment) {
328                                         case ContentAlignment.TopLeft:
329                                                 text_format.Alignment=StringAlignment.Near;
330                                                 text_format.LineAlignment=StringAlignment.Near;
331                                                 break;
332
333                                         case ContentAlignment.TopCenter:
334                                                 text_format.Alignment=StringAlignment.Center;
335                                                 text_format.LineAlignment=StringAlignment.Near;
336                                                 text_format_flags |= TextFormatFlags.HorizontalCenter;
337                                                 break;
338
339                                         case ContentAlignment.TopRight:
340                                                 text_format.Alignment=StringAlignment.Far;
341                                                 text_format.LineAlignment=StringAlignment.Near;
342                                                 text_format_flags |= TextFormatFlags.Right;
343                                                 break;
344
345                                         case ContentAlignment.MiddleLeft:
346                                                 text_format.Alignment=StringAlignment.Near;
347                                                 text_format.LineAlignment=StringAlignment.Center;
348                                                 text_format_flags |= TextFormatFlags.VerticalCenter;
349                                                 break;
350
351                                         case ContentAlignment.MiddleCenter:
352                                                 text_format.Alignment=StringAlignment.Center;
353                                                 text_format.LineAlignment=StringAlignment.Center;
354                                                 text_format_flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
355                                                 break;
356
357                                         case ContentAlignment.MiddleRight:
358                                                 text_format.Alignment=StringAlignment.Far;
359                                                 text_format.LineAlignment=StringAlignment.Center;
360                                                 text_format_flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
361                                                 break;
362
363                                         case ContentAlignment.BottomLeft:
364                                                 text_format.Alignment=StringAlignment.Near;
365                                                 text_format.LineAlignment=StringAlignment.Far;
366                                                 text_format_flags |= TextFormatFlags.Bottom;
367                                                 break;
368
369                                         case ContentAlignment.BottomCenter:
370                                                 text_format.Alignment=StringAlignment.Center;
371                                                 text_format.LineAlignment=StringAlignment.Far;
372                                                 text_format_flags |= TextFormatFlags.HorizontalCenter | TextFormatFlags.Bottom;
373                                                 break;
374
375                                         case ContentAlignment.BottomRight:
376                                                 text_format.Alignment=StringAlignment.Far;
377                                                 text_format.LineAlignment=StringAlignment.Far;
378                                                 text_format_flags |= TextFormatFlags.Bottom | TextFormatFlags.Right;
379                                                 break;
380                                         }
381                                         Invalidate();
382                                 }
383                         }
384                 }
385
386                 #endregion      // Public Instance Properties
387
388                 #region Protected Instance Properties
389                 protected override CreateParams CreateParams {
390                         get {
391                                 return base.CreateParams;
392                         }
393                 }
394
395                 protected override ImeMode DefaultImeMode {
396                         get { return ImeMode.Disable; }
397                 }
398
399                 protected override Size DefaultSize {
400                         get {
401                                 return ThemeEngine.Current.ButtonBaseDefaultSize;
402                         }
403                 }
404
405                 protected bool IsDefault {
406                         get {
407                                 return is_default;
408                         }
409
410                         set {
411                                 if (is_default != value) {
412                                         is_default = true;
413                                         Invalidate();
414                                 }
415                         }
416                 }
417                 #endregion      // Public Instance Properties
418
419                 #region Protected Instance Methods
420                 protected override AccessibleObject CreateAccessibilityInstance ()
421                 {
422                         return new ButtonBaseAccessibleObject (this);
423                 }
424
425                 protected override void Dispose(bool disposing) {
426                         base.Dispose(disposing);
427                 }
428
429                 protected override void OnEnabledChanged(EventArgs e) {
430                         base.OnEnabledChanged(e);
431                 }
432
433                 protected override void OnGotFocus(EventArgs e) {
434                         Invalidate();
435                         base.OnGotFocus(e);
436                 }
437
438                 protected override void OnKeyDown(KeyEventArgs kevent) {
439                         if (kevent.KeyData == Keys.Space) {
440                                 enter_state = is_entered;
441                                 is_entered = true;
442                                 OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 2, 2, 0));
443                                 kevent.Handled=true;
444                         }
445                         base.OnKeyDown(kevent);
446                 }
447
448                 protected override void OnKeyUp(KeyEventArgs kevent) {
449                         if (kevent.KeyData == Keys.Space) {
450                                 OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 2, 2, 0));
451                                 is_entered = enter_state;
452                                 kevent.Handled=true;
453                         }
454                         base.OnKeyUp(kevent);
455                 }
456
457                 protected override void OnLostFocus(EventArgs e) {
458                         Invalidate();
459                         base.OnLostFocus(e);
460                 }
461
462                 protected override void OnMouseDown(MouseEventArgs mevent) {
463                         if ((mevent.Button & MouseButtons.Left) != 0) {
464                                 is_pressed = true;
465                                 this.Capture = true;
466                                 Invalidate();
467                         }
468
469                         base.OnMouseDown(mevent);
470                 }
471
472                 protected override void OnMouseEnter(EventArgs e) {
473                         Invalidate();
474                         base.OnMouseEnter(e);
475                 }
476
477                 protected override void OnMouseLeave(EventArgs e) {
478                         Invalidate();
479                         base.OnMouseLeave(e);
480                 }
481
482                 protected override void OnMouseMove(MouseEventArgs mevent) {
483                         bool    inside = false;
484                         bool    redraw = false;
485
486                         if (mevent.X >= 0 &&
487                             mevent.Y >= 0 &&
488                             mevent.X < this.ClientSize.Width &&
489                             mevent.Y <= this.ClientSize.Height) {
490                                 inside = true;
491                         }
492
493                         // If the button was pressed and we leave, release the button press and vice versa
494                         if ((mevent.Button & MouseButtons.Left) != 0) {
495                                 if (this.Capture && (inside != is_pressed)) {
496                                         is_pressed = inside;
497                                         redraw = true;
498                                 }
499                         }
500
501                         if (is_entered != inside) {
502                                 is_entered = inside;
503                                 redraw = true;
504                         }
505
506                         if (redraw) {
507                                 Invalidate();
508                         }
509
510                         base.OnMouseMove(mevent);
511                 }
512
513                 protected override void OnMouseUp(MouseEventArgs mevent) {
514                         if (this.Capture && ((mevent.Button & MouseButtons.Left) != 0)) {
515                                 this.Capture = false;
516                                 if (is_pressed) {
517                                         is_pressed = false;
518                                         Invalidate();
519                                         Update();
520                                 } else if ((this.flat_style == FlatStyle.Flat) || (this.flat_style == FlatStyle.Popup)) {
521                                         Invalidate();
522                                 }
523
524                                 if (mevent.X >= 0 &&
525                                     mevent.Y >= 0 &&
526                                     mevent.X < this.ClientSize.Width &&
527                                     mevent.Y <= this.ClientSize.Height) {
528                                         OnClick(EventArgs.Empty);
529                                 }
530                         }
531                         base.OnMouseUp(mevent);
532                 }
533
534                 internal override void OnPaintBackgroundInternal(PaintEventArgs e) {
535                         base.OnPaintBackground (e);
536                 }
537
538                 protected override void OnPaint(PaintEventArgs pevent) {
539                         Draw (pevent);
540                         base.OnPaint (pevent);
541                 }
542
543                 protected override void OnParentChanged(EventArgs e) {
544                         base.OnParentChanged(e);
545                 }
546
547                 protected override void OnTextChanged(EventArgs e) {
548                         Invalidate();
549                         base.OnTextChanged(e);
550                 }
551
552                 protected override void OnVisibleChanged(EventArgs e) {
553                         if (!Visible) {
554                                 is_pressed = false;
555                                 is_entered = false;
556                         }
557                         base.OnVisibleChanged(e);
558                 }
559
560                 protected void ResetFlagsandPaint() {
561                         // Nothing to do; MS internal
562                         // Should we do Invalidate (); ?
563                 }
564
565                 protected override void WndProc(ref Message m) {
566                         switch((Msg)m.Msg) {
567                                 case Msg.WM_LBUTTONDBLCLK: {
568                                         HaveDoubleClick();
569                                         break;
570                                 }
571
572                                 case Msg.WM_MBUTTONDBLCLK: {
573                                         HaveDoubleClick();
574                                         break;
575                                 }
576
577                                 case Msg.WM_RBUTTONDBLCLK: {
578                                         HaveDoubleClick();
579                                         break;
580                                 }
581                         }
582                         base.WndProc (ref m);
583                 }
584                 #endregion      // Public Instance Properties
585
586                 #region Internal Instance Properties
587                 internal bool Pressed {
588                         get { return this.is_pressed; }
589                 }
590                 
591                 // The flags to be used for MeasureText and DrawText
592                 internal TextFormatFlags TextFormatFlags {
593                         get { return this.text_format_flags; }
594                 }
595                 #endregion
596                 
597                 #region Internal Methods
598                 private void PerformClick() {
599                         OnClick(EventArgs.Empty);
600                 }
601                 #endregion      // Internal Methods
602
603                 #region Events
604 #if NET_2_0
605                 [Browsable (true)]
606                 [EditorBrowsable (EditorBrowsableState.Always)]
607                 public new event EventHandler AutoSizeChanged {
608                         add { base.AutoSizeChanged += value; }
609                         remove { base.AutoSizeChanged -= value; }
610                 }
611 #endif
612
613                 [Browsable(false)]
614                 [EditorBrowsable (EditorBrowsableState.Never)]
615                 public new event EventHandler ImeModeChanged {
616                         add { base.ImeModeChanged += value; }
617                         remove { base.ImeModeChanged -= value; }
618                 }
619                 #endregion      // Events
620
621
622                 #region .NET 2.0 Public Instance Properties
623                 [Browsable (true)]
624                 [DefaultValue (false)]
625                 [EditorBrowsable (EditorBrowsableState.Always)]
626 #if NET_2_0
627                 public 
628 #else
629                 internal
630 #endif
631                 bool AutoEllipsis {
632                         get { return this.auto_ellipsis; }
633                         set {
634                                 if (this.auto_ellipsis != value) {
635                                         this.auto_ellipsis = value;
636                                         
637                                         if (this.auto_ellipsis) {
638                                                 text_format_flags |= TextFormatFlags.EndEllipsis;
639                                                 text_format_flags &= ~TextFormatFlags.WordBreak;
640                                         }
641                                         else {
642                                                 text_format_flags &= ~TextFormatFlags.EndEllipsis;
643                                                 text_format_flags |= TextFormatFlags.WordBreak;
644                                         }
645                                                 
646                                         this.Invalidate ();
647                                 }
648                         }
649                 }
650
651 #if NET_2_0
652                 [Browsable (true)]
653                 [EditorBrowsable (EditorBrowsableState.Always)]
654                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
655                 public override bool AutoSize {
656                         get { return base.AutoSize; }
657                         set { base.AutoSize = value; }
658                 }
659
660                 public override Color BackColor {
661                         get { return base.BackColor; }
662                         set { base.BackColor = value; }
663                 }
664                 
665                 [Localizable (true)]
666                 [DefaultValue ("")]
667                 [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
668                 [RefreshProperties (RefreshProperties.Repaint)]
669                 public string ImageKey {
670                         get { return this.image_key; }
671                         set {
672                                 if (this.image_key != value) {
673                                         this.image = null;
674                                         this.image_index = -1;
675                                         this.image_key = value;
676                                         this.Invalidate ();
677                                 }
678                         }
679                 }
680                 
681                 [Localizable (true)]
682                 [DefaultValue (TextImageRelation.Overlay)]
683                 public 
684 #else
685                 internal
686 #endif
687                 TextImageRelation TextImageRelation {
688                         get { return this.text_image_relation; }
689                         set {
690                                 if (!Enum.IsDefined (typeof (TextImageRelation), value))
691                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for TextImageRelation", value));
692
693                                 if (this.text_image_relation != value) {
694                                         this.text_image_relation = value;
695                                         this.Invalidate ();
696                                 }
697                         }
698                 }
699                 
700                 [DefaultValue (true)]
701 #if NET_2_0
702                 public 
703 #else
704                 internal
705 #endif
706                 bool UseMnemonic {
707                         get { return this.use_mnemonic; }
708                         set {
709                                 if (this.use_mnemonic != value) {
710                                         this.use_mnemonic = value;
711
712                                         if (this.use_mnemonic)
713                                                 text_format_flags &= ~TextFormatFlags.NoPrefix;
714                                         else
715                                                 text_format_flags |= TextFormatFlags.NoPrefix;
716                                         
717                                         this.Invalidate ();
718                                 }
719                         }
720                 }
721
722 #if NET_2_0
723                 public 
724 #else
725                 internal
726 #endif
727                 bool UseVisualStyleBackColor {
728                         get { return use_visual_style_back_color; }
729                         set { use_visual_style_back_color = value; }
730                 }
731
732                 [DefaultValue (false)]
733 #if NET_2_0
734                 public 
735 #else
736                 internal
737 #endif
738                 bool UseCompatibleTextRendering {
739                         get { return use_compatible_text_rendering; }
740                         set { use_compatible_text_rendering = value; }
741                 }
742
743 #if NET_2_0
744                 [SettingsBindable (true)]
745                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
746                          "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
747                 public override string Text {
748                         get {
749                                 return base.Text;
750                         }
751
752                         set {
753                                 base.Text = value;
754                         }
755                 }
756 #endif
757                 #endregion
758         }
759 }