2008-03-27 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripItem.cs
1 //
2 // ToolStripItem.cs
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 // Copyright (c) 2006 Jonathan Pobst
24 //
25 // Authors:
26 //      Jonathan Pobst (monkey@jpobst.com)
27 //
28 #if NET_2_0
29
30 using System;
31 using System.Drawing;
32 using System.ComponentModel;
33 using System.Runtime.InteropServices;
34
35 namespace System.Windows.Forms
36 {
37         [DefaultEvent ("Click")]
38         [DefaultProperty ("Text")]
39         [DesignTimeVisible (false)]
40         [ToolboxItem (false)]
41         [Designer ("System.Windows.Forms.Design.ToolStripItemDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
42         public abstract class ToolStripItem : Component, IDropTarget, IComponent, IDisposable
43         {
44                 #region Private Variables
45                 private AccessibleObject accessibility_object;
46                 private string accessible_default_action_description;
47                 private bool allow_drop;
48                 private ToolStripItemAlignment alignment;
49                 private AnchorStyles anchor;
50                 private bool available;
51                 private bool auto_size;
52                 private bool auto_tool_tip;
53                 private Color back_color;
54                 private Image background_image;
55                 private ImageLayout background_image_layout;
56                 private Rectangle bounds;
57                 private bool can_select;
58                 private ToolStripItemDisplayStyle display_style;
59                 private DockStyle dock;
60                 private bool double_click_enabled;
61                 private bool enabled;
62                 private Size explicit_size;
63                 private Font font;
64                 private Color fore_color;
65                 private Image image;
66                 private ContentAlignment image_align;
67                 private int image_index;
68                 private string image_key;
69                 private ToolStripItemImageScaling image_scaling;
70                 private Color image_transparent_color;
71                 private bool is_disposed;
72                 internal bool is_pressed;
73                 private bool is_selected;
74                 private Padding margin;
75                 private MergeAction merge_action;
76                 private int merge_index;
77                 private string name;
78                 private ToolStripItemOverflow overflow;
79                 private ToolStrip owner;
80                 internal ToolStripItem owner_item;
81                 private Padding padding;
82                 private ToolStripItemPlacement placement;
83                 private RightToLeft right_to_left;
84                 private bool right_to_left_auto_mirror_image;
85                 private Object tag;
86                 private string text;
87                 private ContentAlignment text_align;
88                 private ToolStripTextDirection text_direction;
89                 private TextImageRelation text_image_relation;
90                 private string tool_tip_text;
91                 private bool visible;
92
93                 private EventHandler frame_handler;     // For animating images
94                 private ToolStrip parent;
95                 private Size text_size;
96                 #endregion
97
98                 #region Public Constructors
99                 protected ToolStripItem ()
100                         : this (String.Empty, null, null, String.Empty)
101                 {
102                 }
103
104                 protected ToolStripItem (string text, Image image, EventHandler onClick)
105                         : this (text, image, onClick, String.Empty)
106                 {
107                 }
108
109                 protected ToolStripItem (string text, Image image, EventHandler onClick, string name)
110                 {
111                         this.alignment = ToolStripItemAlignment.Left;
112                         this.anchor = AnchorStyles.Left | AnchorStyles.Top;
113                         this.auto_size = true;
114                         this.auto_tool_tip = this.DefaultAutoToolTip;
115                         this.available = true;
116                         this.back_color = Control.DefaultBackColor;
117                         this.background_image_layout = ImageLayout.Tile;
118                         this.can_select = true;
119                         this.display_style = this.DefaultDisplayStyle;
120                         this.dock = DockStyle.None;
121                         this.enabled = true;
122                         this.font = new Font ("Tahoma", 8.25f);
123                         this.fore_color = Control.DefaultForeColor;
124                         this.image = image;
125                         this.image_align = ContentAlignment.MiddleCenter;
126                         this.image_index = -1;
127                         this.image_key = string.Empty;
128                         this.image_scaling = ToolStripItemImageScaling.SizeToFit;
129                         this.image_transparent_color = Color.Empty;
130                         this.margin = this.DefaultMargin;
131                         this.merge_action = MergeAction.Append;
132                         this.merge_index = -1;
133                         this.name = name;
134                         this.overflow = ToolStripItemOverflow.AsNeeded;
135                         this.padding = this.DefaultPadding;
136                         this.placement = ToolStripItemPlacement.None;
137                         this.right_to_left = RightToLeft.Inherit;
138                         this.bounds.Size = this.DefaultSize;
139                         this.text = text;
140                         this.text_align = ContentAlignment.MiddleCenter;
141                         this.text_direction = DefaultTextDirection;
142                         this.text_image_relation = TextImageRelation.ImageBeforeText;
143                         this.visible = true;
144
145                         this.Click += onClick;
146                         OnLayout (new LayoutEventArgs (null, string.Empty));
147                 }
148                 #endregion
149
150                 #region Public Properties
151                 [Browsable (false)]
152                 [EditorBrowsable (EditorBrowsableState.Advanced)]
153                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
154                 public AccessibleObject AccessibilityObject {
155                         get { 
156                                 if (this.accessibility_object == null)
157                                         this.accessibility_object = CreateAccessibilityInstance ();
158                                         
159                                 return this.accessibility_object;
160                         }
161                 }
162
163                 [Browsable (false)]
164                 [EditorBrowsable (EditorBrowsableState.Advanced)]
165                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
166                 public string AccessibleDefaultActionDescription {
167                         get {
168                                 if (this.accessibility_object == null)
169                                         return null;
170                                 
171                                 return this.accessible_default_action_description;
172                         }
173                         set { this.accessible_default_action_description = value; }
174                 }
175
176                 [Localizable (true)]
177                 [DefaultValue (null)]
178                 public string AccessibleDescription {
179                         get {
180                                 if (this.accessibility_object == null)
181                                         return null;
182                                 
183                                 return this.AccessibilityObject.Description;
184                         }
185                         set { this.AccessibilityObject.description = value; }
186                 }
187
188                 [Localizable (true)]
189                 [DefaultValue (null)]
190                 public string AccessibleName {
191                         get { 
192                                 if (this.accessibility_object == null)
193                                         return null;
194                                         
195                                 return this.AccessibilityObject.Name; 
196                         }
197                         set { this.AccessibilityObject.Name = value; }
198                 }
199                 
200                 [DefaultValue (AccessibleRole.Default)]
201                 public AccessibleRole AccessibleRole {
202                         get
203                         {
204                                 if (this.accessibility_object == null)
205                                         return AccessibleRole.Default;
206                                 
207                                 return this.AccessibilityObject.Role;
208                         }
209                         set { this.AccessibilityObject.role = value; }
210                 }
211                 
212                 [DefaultValue (ToolStripItemAlignment.Left)]
213                 public ToolStripItemAlignment Alignment {
214                         get { return this.alignment; }
215                         set {
216                                 if (!Enum.IsDefined (typeof (ToolStripItemAlignment), value))
217                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ToolStripItemAlignment", value));
218
219                                 this.alignment = value;
220                         }
221                 }
222
223                 [MonoTODO]
224                 [Browsable (false)]
225                 [DefaultValue (false)]
226                 [EditorBrowsable (EditorBrowsableState.Advanced)]
227                 public virtual bool AllowDrop {
228                         get { return this.allow_drop; }
229                         set { this.allow_drop = value; }
230                 }
231                 
232                 [Browsable (false)]
233                 [DefaultValue (AnchorStyles.Top | AnchorStyles.Left)]
234                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
235                 public AnchorStyles Anchor {
236                         get { return this.anchor; }
237                         set { this.anchor = value; }
238                 }
239                         
240                 [Localizable (true)]
241                 [DefaultValue (true)]
242                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
243                 [RefreshProperties (RefreshProperties.All)]
244                 public bool AutoSize {
245                         get { return this.auto_size; }
246                         set { 
247                                 this.auto_size = value; 
248                                 this.CalculateAutoSize (); 
249                         }
250                 }
251
252                 [DefaultValue (false)]
253                 public bool AutoToolTip {
254                         get { return this.auto_tool_tip; }
255                         set { this.auto_tool_tip = value; }
256                 }
257
258                 [Browsable (false)]
259                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
260                 public bool Available {
261                         get { return this.available; }
262                         set {
263                                 if (this.available != value) {
264                                         available = value;
265                                         visible = value;
266
267                                         if (this.parent != null)
268                                                 parent.PerformLayout (); 
269                                                 
270                                         OnAvailableChanged (EventArgs.Empty); 
271                                         OnVisibleChanged (EventArgs.Empty);
272                                 }
273                         }
274                 }
275
276                 public virtual Color BackColor {
277                         get { return this.back_color; }
278                         set {
279                                 if (this.back_color != value) {
280                                         back_color = value;
281                                         OnBackColorChanged (EventArgs.Empty);
282                                         this.Invalidate ();
283                                 }
284                         }
285                 }
286
287                 [Localizable (true)]
288                 [DefaultValue (null)]
289                 public virtual Image BackgroundImage {
290                         get { return this.background_image; }
291                         set { 
292                                 if (this.background_image != value) {
293                                         this.background_image = value;
294                                         this.Invalidate ();
295                                 }
296                         }
297                 }
298
299                 [Localizable (true)]
300                 [DefaultValue (ImageLayout.Tile)]
301                 public virtual ImageLayout BackgroundImageLayout {
302                         get { return this.background_image_layout; }
303                         set { 
304                                 if (this.background_image_layout != value) {
305                                         this.background_image_layout = value;
306                                         this.Invalidate (); 
307                                 }
308                         }
309                 }
310
311                 [Browsable (false)]
312                 public virtual Rectangle Bounds {
313                         get { return this.bounds; }
314                 }
315
316                 [Browsable (false)]
317                 public virtual bool CanSelect {
318                         get { return this.can_select; }
319                 }
320
321                 [Browsable (false)]
322                 public Rectangle ContentRectangle {
323                         get {
324                                 // ToolStripLabels don't have a border
325                                 if (this is ToolStripLabel || this is ToolStripStatusLabel)
326                                         return new Rectangle (0, 0, this.bounds.Width, this.bounds.Height);
327
328                                 if (this is ToolStripDropDownButton && (this as ToolStripDropDownButton).ShowDropDownArrow)
329                                         return new Rectangle (2, 2, this.bounds.Width - 13, this.bounds.Height - 4);
330
331                                 return new Rectangle (2, 2, this.bounds.Width - 4, this.bounds.Height - 4);
332                         }
333                 }
334
335                 public virtual ToolStripItemDisplayStyle DisplayStyle {
336                         get { return this.display_style; }
337                         set {
338                                 if (this.display_style != value) {
339                                         this.display_style = value; 
340                                         this.CalculateAutoSize (); 
341                                         OnDisplayStyleChanged (EventArgs.Empty);
342                                         if (this.Parent != null)
343                                                 this.Parent.PerformLayout ();
344                                 }
345                         }
346                 }
347
348                 [Browsable (false)]
349                 public bool IsDisposed {
350                         get { return this.is_disposed; }
351                 }
352                 
353                 [Browsable (false)]
354                 [DefaultValue (DockStyle.None)]
355                 public DockStyle Dock {
356                         get { return this.dock; }
357                         set {
358                                 if (this.dock != value) {
359                                         if (!Enum.IsDefined (typeof (DockStyle), value))
360                                                 throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for DockStyle", value));
361
362                                         this.dock = value;
363                                         this.CalculateAutoSize ();
364                                 }
365                         }
366                 }
367
368                 [DefaultValue (false)]
369                 public bool DoubleClickEnabled {
370                         get { return this.double_click_enabled; }
371                         set { this.double_click_enabled = value; }
372                 }
373
374                 [Localizable (true)]
375                 [DefaultValue (true)]
376                 public virtual bool Enabled {
377                         get { 
378                                 if (Parent != null)
379                                         if (!Parent.Enabled)
380                                                 return false;
381
382                                 if (Owner != null)
383                                         if (!Owner.Enabled)
384                                                 return false;
385                                                 
386                                 return enabled;
387                         }
388                         set { 
389                                 if (this.enabled != value) {
390                                         this.enabled = value; 
391                                         OnEnabledChanged (EventArgs.Empty); 
392                                         this.Invalidate ();
393                                 }
394                         }
395                 }
396
397                 [Localizable (true)]
398                 public virtual Font Font
399                 {
400                         get { return this.font; }
401                         set { 
402                                 if (this.font != value) {
403                                         this.font = value; 
404                                         this.CalculateAutoSize (); 
405                                         this.OnFontChanged (EventArgs.Empty); 
406                                         this.Invalidate ();
407                                 }
408                         }
409                 }
410
411                 public virtual Color ForeColor {
412                         get { return this.fore_color; }
413                         set { 
414                                 if (this.fore_color != value) {
415                                         this.fore_color = value; 
416                                         this.OnForeColorChanged (EventArgs.Empty); 
417                                         this.Invalidate ();
418                                 }
419                         }
420                 }
421
422                 [Browsable (false)]
423                 [EditorBrowsable (EditorBrowsableState.Always)]
424                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
425                 public int Height {
426                         get { return this.Size.Height; }
427                         set { 
428                                 this.Size = new Size (this.Size.Width, value); 
429                                 this.explicit_size.Height = value;
430                                 
431                                 if (this.Visible) {
432                                         this.CalculateAutoSize ();
433                                         this.OnBoundsChanged ();
434                                         this.Invalidate (); 
435                                 } 
436                         }
437                 }
438
439                 [Localizable (true)]
440                 public virtual Image Image {
441                         get { 
442                                 if (this.image != null)
443                                         return this.image;
444                                         
445                                 if (this.image_index >= 0)
446                                         if (this.owner != null && this.owner.ImageList != null)
447                                                 return this.owner.ImageList.Images[this.image_index];
448
449
450                                 if (!string.IsNullOrEmpty (this.image_key))
451                                         if (this.owner != null && this.owner.ImageList != null)
452                                                 return this.owner.ImageList.Images[this.image_key];
453                                                 
454                                 return null;
455                         }
456                         set {
457                                 if (this.image != value) {
458                                         StopAnimation ();
459                                         
460                                         this.image = value; 
461                                         this.image_index = -1;
462                                         this.image_key = string.Empty;
463                                         this.CalculateAutoSize (); 
464                                         this.Invalidate ();
465                                         
466                                         BeginAnimation ();
467                                 }
468                         }
469                 }
470
471                 [Localizable (true)]
472                 [DefaultValue (ContentAlignment.MiddleCenter)]
473                 public ContentAlignment ImageAlign {
474                         get { return this.image_align; }
475                         set {
476                                 if (!Enum.IsDefined (typeof (ContentAlignment), value))
477                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ContentAlignment", value));
478
479                                 this.image_align = value;
480                                 this.Invalidate ();
481                         }
482                 }
483
484                 [Localizable (true)]
485                 [Browsable (false)]
486                 [RelatedImageList ("Owner.ImageList")]
487                 [TypeConverter (typeof (NoneExcludedImageIndexConverter))]
488                 [RefreshProperties (RefreshProperties.Repaint)]
489                 [Editor ("System.Windows.Forms.Design.ToolStripImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
490                 public int ImageIndex {
491                         get { return this.image_index; }
492                         set {
493                                 if (this.image_index != value) {
494                                         // Lamespec: MSDN says ArgumentException, tests say otherwise
495                                         if (value < -1)
496                                                 throw new ArgumentOutOfRangeException ("ImageIndex cannot be less than -1");
497
498                                         this.image_index = value;
499                                         this.image = null;
500                                         this.image_key = string.Empty;
501                                         this.CalculateAutoSize ();
502                                         this.Invalidate ();
503                                 }
504                         }
505                 }
506
507                 [Localizable (true)]
508                 [Browsable (false)]
509                 [RelatedImageList ("Owner.ImageList")]
510                 [TypeConverter (typeof (ImageKeyConverter))]
511                 [RefreshProperties (RefreshProperties.Repaint)]
512                 [Editor ("System.Windows.Forms.Design.ToolStripImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
513                 public string ImageKey {
514                         get { return this.image_key; }
515                         set { 
516                                 if (this.image_key != value) {
517                                         this.image = null;
518                                         this.image_index = -1;
519                                         this.image_key = value;
520                                         this.CalculateAutoSize ();
521                                         this.Invalidate ();
522                                 }
523                         }
524                 }
525                 
526                 [Localizable (true)]
527                 [DefaultValue (ToolStripItemImageScaling.SizeToFit)]
528                 public ToolStripItemImageScaling ImageScaling {
529                         get { return this.image_scaling; }
530                         set { 
531                                 this.image_scaling = value; 
532                                 this.CalculateAutoSize (); 
533                                 this.Invalidate (); 
534                         }
535                 }
536
537                 [Localizable (true)]
538                 public Color ImageTransparentColor {
539                         get { return this.image_transparent_color; }
540                         set { this.image_transparent_color = value; }
541                 }
542                 
543                 [Browsable (false)]
544                 public bool IsOnDropDown {
545                         get {
546                                 if (this.parent != null && this.parent is ToolStripDropDown)
547                                         return true;
548
549                                 return false;
550                         }
551                 }
552
553                 [Browsable (false)]
554                 public bool IsOnOverflow {
555                         get { return this.placement == ToolStripItemPlacement.Overflow; }
556                 }
557                 
558                 public Padding Margin {
559                         get { return this.margin; }
560                         set {
561                                 this.margin = value; 
562                                 this.CalculateAutoSize ();
563                         }
564                 }
565
566                 [DefaultValue (MergeAction.Append)]
567                 public MergeAction MergeAction {
568                         get { return this.merge_action; }
569                         set {
570                                 if (!Enum.IsDefined (typeof (MergeAction), value))
571                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for MergeAction", value));
572                                         
573                                 this.merge_action = value;
574                         }
575                 }
576
577                 [DefaultValue (-1)]
578                 public int MergeIndex {
579                         get { return this.merge_index; }
580                         set { this.merge_index = value; }
581                 }
582
583                 [DefaultValue (null)]
584                 [Browsable (false)]
585                 public string Name {
586                         get { return this.name; }
587                         set { this.name = value; }
588                 }
589
590                 [DefaultValue (ToolStripItemOverflow.AsNeeded)]
591                 public ToolStripItemOverflow Overflow {
592                         get { return this.overflow; }
593                         set { 
594                                 if (this.overflow != value) {
595                                         if (!Enum.IsDefined (typeof (ToolStripItemOverflow), value))
596                                                 throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ToolStripItemOverflow", value));
597                                 
598                                         this.overflow = value;
599                                         
600                                         if (owner != null)
601                                                 owner.PerformLayout ();
602                                 }
603                         }
604                 }
605                         
606                 [Browsable (false)]
607                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
608                 public ToolStrip Owner {
609                         get { return this.owner; }
610                         set { 
611                                 if (this.owner != value) {
612                                         this.owner = value; 
613                                         this.CalculateAutoSize (); 
614                                         OnOwnerChanged (EventArgs.Empty);
615                                 }
616                         }
617                 }
618
619                 [Browsable (false)]
620                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
621                 public ToolStripItem OwnerItem {
622                         get { return this.owner_item; }
623                 }
624
625                 public virtual Padding Padding {
626                         get { return this.padding; }
627                         set { 
628                                 this.padding = value; 
629                                 this.CalculateAutoSize (); 
630                                 this.Invalidate (); 
631                         }
632                 }
633
634                 [Browsable (false)]
635                 public ToolStripItemPlacement Placement {
636                         get { return this.placement; }
637                 }
638                 
639                 [Browsable (false)]
640                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
641                 public virtual bool Pressed { get { return this.is_pressed; } }
642
643                 [MonoTODO ("Stub, not implemented")]
644                 [Localizable (true)]
645                 public virtual RightToLeft RightToLeft {
646                         get { return this.right_to_left; }
647                         set { 
648                                 if (this.right_to_left != value) {
649                                         this.right_to_left = value;
650                                         this.OnRightToLeftChanged (EventArgs.Empty);
651                                 }
652                         }
653                 }
654                 
655                 [Localizable (true)]
656                 [DefaultValue (false)]
657                 public bool RightToLeftAutoMirrorImage {
658                         get { return this.right_to_left_auto_mirror_image; }
659                         set { 
660                                 if (this.right_to_left_auto_mirror_image != value) {
661                                         this.right_to_left_auto_mirror_image = value;
662                                         this.Invalidate ();
663                                 }
664                         }
665                 }
666                 
667                 [Browsable (false)]
668                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
669                 public virtual bool Selected { get { return this.is_selected; } }
670
671                 [Localizable (true)]
672                 public virtual Size Size {
673                         get { 
674                                 if (!this.AutoSize && this.explicit_size != Size.Empty) 
675                                         return this.explicit_size; 
676                                         
677                                 return this.bounds.Size; 
678                         }
679                         set { 
680                                 this.bounds.Size = value; 
681                                 this.explicit_size = value;
682                                 
683                                 if (this.Visible) {
684                                         this.CalculateAutoSize ();
685                                         this.OnBoundsChanged (); 
686                                 }
687                         }
688                 }
689
690                 [Localizable (false)]
691                 [Bindable (true)]
692                 [DefaultValue (null)]
693                 [TypeConverter (typeof (StringConverter))]
694                 public Object Tag {
695                         get { return this.tag; }
696                         set { this.tag = value; }
697                 }
698
699                 [Localizable (true)]
700                 [DefaultValue ("")]
701                 public virtual string Text
702                 {
703                         get { return this.text; }
704                         set { 
705                                 if (this.text != value) { 
706                                         this.text = value; 
707                                         this.Invalidate (); 
708                                         this.CalculateAutoSize (); 
709                                         this.Invalidate ();
710                                         this.OnTextChanged (EventArgs.Empty); 
711                                 } 
712                         }
713                 }
714
715                 [Localizable (true)]
716                 [DefaultValue (ContentAlignment.MiddleCenter)]
717                 public virtual ContentAlignment TextAlign {
718                         get { return this.text_align; }
719                         set {
720                                 if (!Enum.IsDefined (typeof (ContentAlignment), value))
721                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ContentAlignment", value));
722                                 this.text_align = value;
723                                 this.Invalidate ();
724                         }
725                 }
726
727                 public virtual ToolStripTextDirection TextDirection {
728                         get {
729                                 if (this.text_direction == ToolStripTextDirection.Inherit) {
730                                         if (this.Parent != null)
731                                                 return this.Parent.TextDirection;
732                                         else
733                                                 return ToolStripTextDirection.Horizontal;
734                                 }
735
736                                 return this.text_direction;
737                         }
738                         set {
739                                 if (!Enum.IsDefined (typeof (ToolStripTextDirection), value))
740                                         throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ToolStripTextDirection", value));
741                                 
742                                 if (this.text_direction != value) {
743                                         this.text_direction = value;
744                                         this.CalculateAutoSize ();
745                                         this.Invalidate ();
746                                 }
747                         }       
748                 }
749
750                 [Localizable (true)]
751                 [DefaultValue (TextImageRelation.ImageBeforeText)]
752                 public TextImageRelation TextImageRelation {
753                         get { return this.text_image_relation; }
754                         set { 
755                                 this.text_image_relation = value; 
756                                 this.CalculateAutoSize (); 
757                                 this.Invalidate (); 
758                         }
759                 }
760
761                 [Localizable (true)]
762                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
763                          "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
764                 public string ToolTipText {
765                         get { return this.tool_tip_text; }
766                         set { this.tool_tip_text = value; }
767                 }
768
769                 [Localizable (true)]
770                 public bool Visible {
771                         get { 
772                                 if (this.parent == null)
773                                         return false;
774                         
775                                 return this.visible && this.parent.Visible; 
776                         }
777                         set { 
778                                 if (this.visible != value) {
779                                         this.available = value;
780                                         this.SetVisibleCore (value);
781                                         if (this.Owner != null)
782                                                 this.Owner.PerformLayout ();
783                                 }
784                         }
785                 }
786
787                 [Browsable (false)]
788                 [EditorBrowsable (EditorBrowsableState.Always)]
789                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
790                 public int Width {
791                         get { return this.Size.Width; }
792                         set { 
793                                 this.Size = new Size (value, this.Size.Height); 
794                                 this.explicit_size.Width = value;
795                                 
796                                 if (this.Visible) {
797                                         this.CalculateAutoSize ();
798                                         this.OnBoundsChanged ();
799                                         this.Invalidate ();
800                                 }
801                         }
802                 }
803                 #endregion
804
805                 #region Protected Properties
806                 protected virtual bool DefaultAutoToolTip { get { return false; } }
807                 protected virtual ToolStripItemDisplayStyle DefaultDisplayStyle { get { return ToolStripItemDisplayStyle.ImageAndText; } }
808                 protected internal virtual Padding DefaultMargin { get { return new Padding (0, 1, 0, 2); } }
809                 protected virtual Padding DefaultPadding { get { return new Padding (); } }
810                 protected virtual Size DefaultSize { get { return new Size (23, 23); } }
811                 protected internal virtual bool DismissWhenClicked { get { return true; } }
812                 [Browsable (false)]
813                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
814                 protected internal ToolStrip Parent {
815                         get { return this.parent; }
816                         set { 
817                                 if (this.parent != value) {
818                                         ToolStrip old_parent = this.parent;
819                                         this.parent = value; 
820                                         OnParentChanged(old_parent, this.parent);
821                                 }
822                         }
823                 }
824                 protected internal virtual bool ShowKeyboardCues { get { return false; } }
825                 #endregion
826
827                 #region Public Methods
828                 [MonoTODO ("Stub")]
829                 [EditorBrowsable (EditorBrowsableState.Advanced)]
830                 public DragDropEffects DoDragDrop (Object data, DragDropEffects allowedEffects)
831                 {
832                         return allowedEffects;
833                 }
834                 
835                 public ToolStrip GetCurrentParent ()
836                 { 
837                         return this.parent; 
838                 }
839
840                 public virtual Size GetPreferredSize (Size constrainingSize)
841                 {
842                         return this.CalculatePreferredSize (constrainingSize);
843                 }
844
845                 public void Invalidate ()
846                 {
847                         if (parent != null)
848                                 parent.Invalidate (this.bounds);
849                 }
850
851                 public void Invalidate (Rectangle r)
852                 {
853                         if (parent != null)
854                                 parent.Invalidate (r);
855                 }
856
857                 public void PerformClick ()
858                 { 
859                         this.OnClick (EventArgs.Empty); 
860                 }
861
862                 [EditorBrowsable (EditorBrowsableState.Never)]
863                 public virtual void ResetBackColor () { this.BackColor = Control.DefaultBackColor; }
864
865                 [EditorBrowsable (EditorBrowsableState.Never)]
866                 public virtual void ResetDisplayStyle () { this.display_style = this.DefaultDisplayStyle; }
867
868                 [EditorBrowsable (EditorBrowsableState.Never)]
869                 public virtual void ResetFont () { this.font = new Font ("Tahoma", 8.25f); }
870
871                 [EditorBrowsable (EditorBrowsableState.Never)]
872                 public virtual void ResetForeColor () { this.ForeColor = Control.DefaultForeColor; }
873
874                 [EditorBrowsable (EditorBrowsableState.Never)]
875                 public virtual void ResetImage () { this.image = null; }
876
877                 [EditorBrowsable (EditorBrowsableState.Never)]
878                 public void ResetMargin () { this.margin = this.DefaultMargin; }
879
880                 [EditorBrowsable (EditorBrowsableState.Never)]
881                 public void ResetPadding () { this.padding = this.DefaultPadding; }
882
883                 [EditorBrowsable (EditorBrowsableState.Never)]
884                 public virtual void ResetRightToLeft () { this.right_to_left = RightToLeft.Inherit; }
885                 
886                 [EditorBrowsable (EditorBrowsableState.Never)]
887                 public virtual void ResetTextDirection () { this.TextDirection = this.DefaultTextDirection; }
888
889                 public void Select ()
890                 {
891                         if (!this.is_selected && this.CanSelect) {
892                                 this.is_selected = true;
893                                 
894                                 if (this.Visible && this.Parent.Focused && this is ToolStripControlHost)
895                                         (this as ToolStripControlHost).Focus ();
896                                         
897                                 this.Invalidate ();
898                                 this.Parent.NotifySelectedChanged (this);
899                         }
900                 }
901
902                 public override string ToString ()
903                 {
904                         return this.text;
905                 }
906                 #endregion
907
908                 #region Protected Methods
909                 [EditorBrowsable (EditorBrowsableState.Advanced)]
910                 protected virtual AccessibleObject CreateAccessibilityInstance ()
911                 {
912                         return new ToolStripItemAccessibleObject (this);
913                 }
914
915                 protected override void Dispose (bool disposing)
916                 {
917                         if (!is_disposed && disposing)
918                                 is_disposed = true;
919
920                         if (image != null) {
921                                 StopAnimation ();
922                                 image = null;
923                         }
924                         
925                         base.Dispose (disposing);
926                 }
927                 
928                 protected internal virtual bool IsInputChar (char charCode)
929                 {
930                         return false;
931                 }
932                 
933                 protected internal virtual bool IsInputKey (Keys keyData)
934                 {
935                         return false;
936                 }
937                 
938                 protected virtual void OnAvailableChanged (EventArgs e)
939                 {
940                         EventHandler eh = (EventHandler)(Events [AvailableChangedEvent]);
941                         if (eh != null)
942                                 eh (this, e);
943                 }
944
945                 [EditorBrowsable (EditorBrowsableState.Advanced)]
946                 protected virtual void OnBackColorChanged (EventArgs e)
947                 {
948                         EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
949                         if (eh != null)
950                                 eh (this, e);
951                 }
952
953                 protected virtual void OnBoundsChanged ()
954                 {
955                         OnLayout (new LayoutEventArgs(null, string.Empty));
956                 }
957
958                 protected virtual void OnClick (EventArgs e)
959                 {
960                         EventHandler eh = (EventHandler)(Events [ClickEvent]);
961                         if (eh != null)
962                                 eh (this, e);
963                 }
964
965                 [EditorBrowsable (EditorBrowsableState.Advanced)]
966                 protected virtual void OnDisplayStyleChanged (EventArgs e)
967                 {
968                         EventHandler eh = (EventHandler)(Events [DisplayStyleChangedEvent]);
969                         if (eh != null)
970                                 eh (this, e);
971                 }
972
973                 protected virtual void OnDoubleClick (EventArgs e)
974                 {
975                         EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
976                         if (eh != null)
977                                 eh (this, e);
978
979                         if (!double_click_enabled)
980                                 OnClick (e);
981                 }
982
983                 [EditorBrowsable (EditorBrowsableState.Advanced)]
984                 protected virtual void OnDragDrop (DragEventArgs dragEvent)
985                 {
986                         DragEventHandler eh = (DragEventHandler)(Events[DragDropEvent]);
987                         if (eh != null)
988                                 eh (this, dragEvent);
989                 }
990
991                 [EditorBrowsable (EditorBrowsableState.Advanced)]
992                 protected virtual void OnDragEnter (DragEventArgs dragEvent)
993                 {
994                         DragEventHandler eh = (DragEventHandler)(Events[DragEnterEvent]);
995                         if (eh != null)
996                                 eh (this, dragEvent);
997                 }
998
999                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1000                 protected virtual void OnDragLeave (EventArgs e)
1001                 {
1002                         EventHandler eh = (EventHandler)(Events[DragLeaveEvent]);
1003                         if (eh != null)
1004                                 eh (this, e);
1005                 }
1006
1007                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1008                 protected virtual void OnDragOver (DragEventArgs dragEvent)
1009                 {
1010                         DragEventHandler eh = (DragEventHandler)(Events[DragOverEvent]);
1011                         if (eh != null)
1012                                 eh (this, dragEvent);
1013                 }
1014
1015                 protected virtual void OnEnabledChanged (EventArgs e)
1016                 {
1017                         EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
1018                         if (eh != null)
1019                                 eh (this, e);
1020                 }
1021
1022                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1023                 protected virtual void OnFontChanged (EventArgs e)
1024                 {
1025                 }
1026
1027                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1028                 protected virtual void OnForeColorChanged (EventArgs e)
1029                 {
1030                         EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
1031                         if (eh != null)
1032                                 eh (this, e);
1033                 }
1034
1035                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1036                 protected virtual void OnGiveFeedback (GiveFeedbackEventArgs giveFeedbackEvent)
1037                 {
1038                         GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events[GiveFeedbackEvent]);
1039                         if (eh != null)
1040                                 eh (this, giveFeedbackEvent);
1041                 }
1042
1043                 protected virtual void OnLayout (LayoutEventArgs e)
1044                 {
1045                 }
1046
1047                 protected virtual void OnLocationChanged (EventArgs e)
1048                 {
1049                         EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
1050                         if (eh != null)
1051                                 eh (this, e);
1052                 }
1053
1054                 protected virtual void OnMouseDown (MouseEventArgs e)
1055                 {
1056                         if (this.Enabled) {
1057                                 this.is_pressed = true;
1058                                 this.Invalidate ();
1059
1060                                 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
1061                                 if (eh != null)
1062                                         eh (this, e);
1063                         }
1064                 }
1065
1066                 protected virtual void OnMouseEnter (EventArgs e)
1067                 {
1068                         this.Select ();
1069
1070                         EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
1071                         if (eh != null)
1072                                 eh (this, e);
1073                 }
1074
1075                 protected virtual void OnMouseHover (EventArgs e)
1076                 {
1077                         if (this.Enabled) {
1078                                 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
1079                                 if (eh != null)
1080                                         eh (this, e);
1081                         }
1082                 }
1083
1084                 protected virtual void OnMouseLeave (EventArgs e)
1085                 {
1086                         if (this.CanSelect) {
1087                                 this.is_selected = false;
1088                                 this.is_pressed = false;
1089                                 this.Invalidate ();
1090                         }
1091
1092                         EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
1093                         if (eh != null)
1094                                 eh (this, e);
1095                 }
1096
1097                 protected virtual void OnMouseMove (MouseEventArgs mea)
1098                 {
1099                         if (this.Enabled) {
1100                                 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
1101                                 if (eh != null)
1102                                         eh (this, mea);
1103                         }
1104                 }
1105
1106                 protected virtual void OnMouseUp (MouseEventArgs e)
1107                 {
1108                         if (this.Enabled) {
1109                                 this.is_pressed = false;
1110                                 this.Invalidate ();
1111
1112                                 if (this.IsOnDropDown)
1113                                         if (!(this is ToolStripDropDownItem) || !(this as ToolStripDropDownItem).HasDropDownItems || (this as ToolStripDropDownItem).DropDown.Visible == false) {
1114                                                 if ((this.Parent as ToolStripDropDown).OwnerItem != null)
1115                                                         ((this.Parent as ToolStripDropDown).OwnerItem as ToolStripDropDownItem).HideDropDown ();
1116                                                 else
1117                                                         (this.Parent as ToolStripDropDown).Hide ();
1118                                         }
1119                                                 
1120                                 
1121                                 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
1122                                 if (eh != null)
1123                                         eh (this, e);
1124                         }
1125                 }
1126
1127                 protected virtual void OnOwnerChanged (EventArgs e)
1128                 {
1129                         EventHandler eh = (EventHandler)(Events [OwnerChangedEvent]);
1130                         if (eh != null)
1131                                 eh (this, e);
1132                 }
1133
1134                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1135                 protected internal virtual void OnOwnerFontChanged (EventArgs e)
1136                 {
1137                 }
1138                 
1139                 protected virtual void OnPaint (PaintEventArgs e)
1140                 {
1141                         if (this.parent != null)
1142                                 this.parent.Renderer.DrawItemBackground (new ToolStripItemRenderEventArgs (e.Graphics, this));
1143                                 
1144                         PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
1145                         if (eh != null)
1146                                 eh (this, e);
1147                 }
1148
1149                 // This is never called.
1150                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1151                 protected virtual void OnParentBackColorChanged (EventArgs e)
1152                 {
1153                 }
1154                 
1155                 protected virtual void OnParentChanged (ToolStrip oldParent, ToolStrip newParent)
1156                 {
1157                         if (oldParent != null)
1158                                 oldParent.PerformLayout ();
1159                                 
1160                         if (newParent != null)
1161                                 newParent.PerformLayout ();
1162                 }
1163
1164                 protected internal virtual void OnParentEnabledChanged (EventArgs e)
1165                 {
1166                         this.OnEnabledChanged (e);
1167                 }
1168
1169                 // This is never called.
1170                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1171                 protected virtual void OnParentForeColorChanged (EventArgs e)
1172                 {
1173                 }
1174
1175                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1176                 protected internal virtual void OnParentRightToLeftChanged (EventArgs e)
1177                 {
1178                         this.OnRightToLeftChanged (e);
1179                 }
1180
1181                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1182                 protected virtual void OnQueryContinueDrag (QueryContinueDragEventArgs queryContinueDragEvent)
1183                 {
1184                         QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events[QueryContinueDragEvent]);
1185                         if (eh != null)
1186                                 eh (this, queryContinueDragEvent);
1187                 }
1188                 
1189                 protected virtual void OnRightToLeftChanged (EventArgs e)
1190                 {
1191                         EventHandler eh = (EventHandler)(Events[RightToLeftChangedEvent]);
1192                         if (eh != null)
1193                                 eh (this, e);
1194                 }
1195                 
1196                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1197                 protected virtual void OnTextChanged (EventArgs e)
1198                 {
1199                         EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
1200                         if (eh != null)
1201                                 eh (this, e);
1202                 }
1203
1204                 protected virtual void OnVisibleChanged (EventArgs e)
1205                 {
1206                         EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
1207                         if (eh != null)
1208                                 eh (this, e);
1209                 }
1210
1211                 protected internal virtual bool ProcessCmdKey (ref Message m, Keys keyData)
1212                 {
1213                         return false;
1214                 }
1215                 
1216                 protected internal virtual bool ProcessDialogKey (Keys keyData)
1217                 {
1218                         if (this.Selected && keyData == Keys.Enter) {
1219                                 this.FireEvent (EventArgs.Empty, ToolStripItemEventType.Click);
1220                                 return true;
1221                         }
1222                                 
1223                         return false;
1224                 }
1225                 
1226                 // ProcessMnemonic will only be called if we are supposed to handle
1227                 // it.  None of that fancy "thinking" needed!
1228                 protected internal virtual bool ProcessMnemonic (char charCode)
1229                 {
1230                         ToolStripManager.SetActiveToolStrip (this.Parent, true);
1231                         this.PerformClick ();
1232                         return true;
1233                 }
1234                 
1235                 protected internal virtual void SetBounds (Rectangle bounds)
1236                 {
1237                         if (this.bounds != bounds) {
1238                                 this.bounds = bounds;
1239                                 OnBoundsChanged ();
1240                         }
1241                 }
1242                 
1243                 protected virtual void SetVisibleCore (bool visible)
1244                 {
1245                         this.visible = visible;
1246                         this.OnVisibleChanged (EventArgs.Empty);
1247                         
1248                         if (this.visible)
1249                                 BeginAnimation ();
1250                         else
1251                                 StopAnimation ();
1252                         this.Invalidate ();
1253                 }
1254                 #endregion
1255
1256                 #region Public Events
1257                 static object AvailableChangedEvent = new object ();
1258                 static object BackColorChangedEvent = new object ();
1259                 static object ClickEvent = new object ();
1260                 static object DisplayStyleChangedEvent = new object ();
1261                 static object DoubleClickEvent = new object ();
1262                 static object DragDropEvent = new object ();
1263                 static object DragEnterEvent = new object ();
1264                 static object DragLeaveEvent = new object ();
1265                 static object DragOverEvent = new object ();
1266                 static object EnabledChangedEvent = new object ();
1267                 static object ForeColorChangedEvent = new object ();
1268                 static object GiveFeedbackEvent = new object ();
1269                 static object LocationChangedEvent = new object ();
1270                 static object MouseDownEvent = new object ();
1271                 static object MouseEnterEvent = new object ();
1272                 static object MouseHoverEvent = new object ();
1273                 static object MouseLeaveEvent = new object ();
1274                 static object MouseMoveEvent = new object ();
1275                 static object MouseUpEvent = new object ();
1276                 static object OwnerChangedEvent = new object ();
1277                 static object PaintEvent = new object ();
1278                 static object QueryAccessibilityHelpEvent = new object ();
1279                 static object QueryContinueDragEvent = new object ();
1280                 static object RightToLeftChangedEvent = new object ();
1281                 static object TextChangedEvent = new object ();
1282                 static object VisibleChangedEvent = new object ();
1283
1284                 [Browsable (false)]
1285                 public event EventHandler AvailableChanged {
1286                         add { Events.AddHandler (AvailableChangedEvent, value); }
1287                         remove {Events.RemoveHandler (AvailableChangedEvent, value); }
1288                 }
1289
1290                 public event EventHandler BackColorChanged {
1291                         add { Events.AddHandler (BackColorChangedEvent, value); }
1292                         remove {Events.RemoveHandler (BackColorChangedEvent, value); }
1293                 }
1294
1295                 public event EventHandler Click {
1296                         add { Events.AddHandler (ClickEvent, value); }
1297                         remove {Events.RemoveHandler (ClickEvent, value); }
1298                 }
1299
1300                 public event EventHandler DisplayStyleChanged {
1301                         add { Events.AddHandler (DisplayStyleChangedEvent, value); }
1302                         remove {Events.RemoveHandler (DisplayStyleChangedEvent, value); }
1303                 }
1304
1305                 public event EventHandler DoubleClick {
1306                         add { Events.AddHandler (DoubleClickEvent, value); }
1307                         remove {Events.RemoveHandler (DoubleClickEvent, value); }
1308                 }
1309
1310                 [MonoTODO ("Not raised")]
1311                 [Browsable (false)]
1312                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1313                 public event DragEventHandler DragDrop {
1314                         add { Events.AddHandler (DragDropEvent, value); }
1315                         remove { Events.RemoveHandler (DragDropEvent, value); }
1316                 }
1317
1318                 [MonoTODO ("Not raised")]
1319                 [Browsable (false)]
1320                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1321                 public event DragEventHandler DragEnter {
1322                         add { Events.AddHandler (DragEnterEvent, value); }
1323                         remove { Events.RemoveHandler (DragEnterEvent, value); }
1324                 }
1325
1326                 [MonoTODO ("Not raised")]
1327                 [Browsable (false)]
1328                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1329                 public event EventHandler DragLeave {
1330                         add { Events.AddHandler (DragLeaveEvent, value); }
1331                         remove { Events.RemoveHandler (DragLeaveEvent, value); }
1332                 }
1333
1334                 [MonoTODO ("Not raised")]
1335                 [Browsable (false)]
1336                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1337                 public event DragEventHandler DragOver {
1338                         add { Events.AddHandler (DragOverEvent, value); }
1339                         remove { Events.RemoveHandler (DragOverEvent, value); }
1340                 }
1341
1342                 public event EventHandler EnabledChanged {
1343                         add { Events.AddHandler (EnabledChangedEvent, value); }
1344                         remove {Events.RemoveHandler (EnabledChangedEvent, value); }
1345                 }
1346
1347                 public event EventHandler ForeColorChanged {
1348                         add { Events.AddHandler (ForeColorChangedEvent, value); }
1349                         remove {Events.RemoveHandler (ForeColorChangedEvent, value); }
1350                 }
1351
1352                 [MonoTODO ("Not raised")]
1353                 [Browsable (false)]
1354                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1355                 public event GiveFeedbackEventHandler GiveFeedback {
1356                         add { Events.AddHandler (GiveFeedbackEvent, value); }
1357                         remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
1358                 }
1359
1360                 public event EventHandler LocationChanged {
1361                         add { Events.AddHandler (LocationChangedEvent, value); }
1362                         remove {Events.RemoveHandler (LocationChangedEvent, value); }
1363                 }
1364
1365                 public event MouseEventHandler MouseDown {
1366                         add { Events.AddHandler (MouseDownEvent, value); }
1367                         remove {Events.RemoveHandler (MouseDownEvent, value); }
1368                 }
1369
1370                 public event EventHandler MouseEnter {
1371                         add { Events.AddHandler (MouseEnterEvent, value); }
1372                         remove {Events.RemoveHandler (MouseEnterEvent, value); }
1373                 }
1374
1375                 public event EventHandler MouseHover {
1376                         add { Events.AddHandler (MouseHoverEvent, value); }
1377                         remove {Events.RemoveHandler (MouseHoverEvent, value); }
1378                 }
1379
1380                 public event EventHandler MouseLeave {
1381                         add { Events.AddHandler (MouseLeaveEvent, value); }
1382                         remove {Events.RemoveHandler (MouseLeaveEvent, value); }
1383                 }
1384
1385                 public event MouseEventHandler MouseMove {
1386                         add { Events.AddHandler (MouseMoveEvent, value); }
1387                         remove {Events.RemoveHandler (MouseMoveEvent, value); }
1388                 }
1389
1390                 public event MouseEventHandler MouseUp {
1391                         add { Events.AddHandler (MouseUpEvent, value); }
1392                         remove {Events.RemoveHandler (MouseUpEvent, value); }
1393                 }
1394
1395                 public event EventHandler OwnerChanged {
1396                         add { Events.AddHandler (OwnerChangedEvent, value); }
1397                         remove {Events.RemoveHandler (OwnerChangedEvent, value); }
1398                 }
1399
1400                 public event PaintEventHandler Paint {
1401                         add { Events.AddHandler (PaintEvent, value); }
1402                         remove {Events.RemoveHandler (PaintEvent, value); }
1403                 }
1404
1405                 [MonoTODO ("Not raised")]
1406                 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
1407                         add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
1408                         remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
1409                 }
1410
1411                 [MonoTODO ("Not raised")]
1412                 [Browsable (false)]
1413                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1414                 public event QueryContinueDragEventHandler QueryContinueDrag {
1415                         add { Events.AddHandler (QueryContinueDragEvent, value); }
1416                         remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
1417                 }
1418
1419                 public event EventHandler RightToLeftChanged {
1420                         add { Events.AddHandler (RightToLeftChangedEvent, value); }
1421                         remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
1422                 }
1423                 
1424                 public event EventHandler TextChanged {
1425                         add { Events.AddHandler (TextChangedEvent, value); }
1426                         remove {Events.RemoveHandler (TextChangedEvent, value); }
1427                 }
1428
1429                 public event EventHandler VisibleChanged {
1430                         add { Events.AddHandler (VisibleChangedEvent, value); }
1431                         remove {Events.RemoveHandler (VisibleChangedEvent, value); }
1432                 }
1433                 #endregion
1434
1435                 #region Internal Methods
1436                 internal Rectangle AlignInRectangle (Rectangle outer, Size inner, ContentAlignment align)
1437                 {
1438                         int x = 0;
1439                         int y = 0;
1440
1441                         if (align == ContentAlignment.BottomLeft || align == ContentAlignment.MiddleLeft || align == ContentAlignment.TopLeft)
1442                                 x = outer.X;
1443                         else if (align == ContentAlignment.BottomCenter || align == ContentAlignment.MiddleCenter || align == ContentAlignment.TopCenter)
1444                                 x = Math.Max (outer.X + ((outer.Width - inner.Width) / 2), outer.Left);
1445                         else if (align == ContentAlignment.BottomRight || align == ContentAlignment.MiddleRight || align == ContentAlignment.TopRight)
1446                                 x = outer.Right - inner.Width;
1447                         if (align == ContentAlignment.TopCenter || align == ContentAlignment.TopLeft || align == ContentAlignment.TopRight)
1448                                 y = outer.Y;
1449                         else if (align == ContentAlignment.MiddleCenter || align == ContentAlignment.MiddleLeft || align == ContentAlignment.MiddleRight)
1450                                 y = outer.Y + (outer.Height - inner.Height) / 2;
1451                         else if (align == ContentAlignment.BottomCenter || align == ContentAlignment.BottomRight || align == ContentAlignment.BottomLeft)
1452                                 y = outer.Bottom - inner.Height;
1453
1454                         return new Rectangle (x, y, Math.Min (inner.Width, outer.Width), Math.Min (inner.Height, outer.Height));
1455                 }
1456
1457                 internal void CalculateAutoSize ()
1458                 {
1459                         this.text_size = TextRenderer.MeasureText (this.Text == null ? string.Empty: this.text, this.Font, Size.Empty, TextFormatFlags.HidePrefix);
1460
1461                         // If our text is rotated, flip the width and height
1462                         ToolStripTextDirection direction = this.TextDirection;
1463                         
1464                         if (direction == ToolStripTextDirection.Vertical270 || direction == ToolStripTextDirection.Vertical90)
1465                                 this.text_size = new Size (this.text_size.Height, this.text_size.Width);
1466                         
1467                         if (!this.auto_size || this is ToolStripControlHost)
1468                                 return;
1469                         //this.text_size.Width += 6;
1470
1471                         Size final_size = this.CalculatePreferredSize (Size.Empty);
1472
1473                         if (final_size != this.Size) {
1474                                 this.bounds.Width = final_size.Width;
1475                                 if (this.parent != null)
1476                                         this.parent.PerformLayout ();
1477                         }
1478                 }
1479
1480                 internal virtual Size CalculatePreferredSize (Size constrainingSize)
1481                 {
1482                         if (!this.auto_size)
1483                                 return this.explicit_size;
1484                                 
1485                         Size preferred_size = this.DefaultSize;
1486
1487                         switch (this.display_style) {
1488                                 case ToolStripItemDisplayStyle.Text:
1489                                         int width = text_size.Width + this.padding.Horizontal;
1490                                         int height = text_size.Height + this.padding.Vertical;
1491                                         preferred_size = new Size (width, height);
1492                                         break;
1493                                 case ToolStripItemDisplayStyle.Image:
1494                                         if (this.Image == null)
1495                                                 preferred_size = this.DefaultSize;
1496                                         else {
1497                                                 switch (this.image_scaling) {
1498                                                         case ToolStripItemImageScaling.None:
1499                                                                 preferred_size = this.Image.Size;
1500                                                                 break;
1501                                                         case ToolStripItemImageScaling.SizeToFit:
1502                                                                 if (this.parent == null)
1503                                                                         preferred_size = this.Image.Size;
1504                                                                 else
1505                                                                         preferred_size = this.parent.ImageScalingSize;
1506                                                                 break;
1507                                                 }
1508                                         }
1509                                         break;
1510                                 case ToolStripItemDisplayStyle.ImageAndText:
1511                                         int width2 = text_size.Width + this.padding.Horizontal;
1512                                         int height2 = text_size.Height + this.padding.Vertical;
1513
1514                                         if (this.Image != null) {
1515                                                 Size image_size = this.Image.Size;
1516                                                 
1517                                                 if (this.image_scaling == ToolStripItemImageScaling.SizeToFit && this.parent != null)
1518                                                         image_size = this.parent.ImageScalingSize;
1519                                                 
1520                                                 switch (this.text_image_relation) {
1521                                                         case TextImageRelation.Overlay:
1522                                                                 width2 = Math.Max (width2, image_size.Width);
1523                                                                 height2 = Math.Max (height2, image_size.Height);
1524                                                                 break;
1525                                                         case TextImageRelation.ImageAboveText:
1526                                                         case TextImageRelation.TextAboveImage:
1527                                                                 width2 = Math.Max (width2, image_size.Width);
1528                                                                 height2 += image_size.Height;
1529                                                                 break;
1530                                                         case TextImageRelation.ImageBeforeText:
1531                                                         case TextImageRelation.TextBeforeImage:
1532                                                                 height2 = Math.Max (height2, image_size.Height);
1533                                                                 width2 += image_size.Width;
1534                                                                 break;
1535                                                 }
1536                                         }
1537
1538                                         preferred_size = new Size (width2, height2);
1539                                         break;
1540                         }
1541
1542                         if (!(this is ToolStripLabel)) {                // Everything but labels have a border
1543                                 preferred_size.Height += 4;
1544                                 preferred_size.Width += 4;
1545                         }
1546                         
1547                         // Account for ToolStripDropDownButton's drop down arrow
1548                         if (this is ToolStripDropDownButton && (this as ToolStripDropDownButton).ShowDropDownArrow)
1549                                 preferred_size.Width += 9;
1550
1551                         return preferred_size;
1552                 }
1553
1554                 internal void CalculateTextAndImageRectangles (out Rectangle text_rect, out Rectangle image_rect)
1555                 {
1556                         this.CalculateTextAndImageRectangles (this.ContentRectangle, out text_rect, out image_rect);
1557                 }
1558                 
1559                 internal void CalculateTextAndImageRectangles (Rectangle contentRectangle, out Rectangle text_rect, out Rectangle image_rect)
1560                 {
1561                         text_rect = Rectangle.Empty;
1562                         image_rect = Rectangle.Empty;
1563                                 
1564                         switch (this.display_style) {
1565                                 case ToolStripItemDisplayStyle.None:
1566                                         break;
1567                                 case ToolStripItemDisplayStyle.Text:
1568                                         if (this.text != string.Empty)
1569                                                 text_rect = AlignInRectangle (contentRectangle, this.text_size, this.text_align);
1570                                         break;
1571                                 case ToolStripItemDisplayStyle.Image:
1572                                         if (this.Image != null && this.UseImageMargin)
1573                                                 image_rect = AlignInRectangle (contentRectangle, GetImageSize (), this.image_align);
1574                                         break;
1575                                 case ToolStripItemDisplayStyle.ImageAndText:
1576                                         if (this.text != string.Empty && (this.Image == null || !this.UseImageMargin))
1577                                                 text_rect = AlignInRectangle (contentRectangle, this.text_size, this.text_align);
1578                                         else if (this.text == string.Empty && (this.Image == null || !this.UseImageMargin))
1579                                                 break;
1580                                         else if (this.text == string.Empty && this.Image != null)
1581                                                 image_rect = AlignInRectangle (contentRectangle, GetImageSize (), this.image_align);
1582                                         else {
1583                                                 Rectangle text_area;
1584                                                 Rectangle image_area;
1585
1586                                                 switch (this.text_image_relation) {
1587                                                         case TextImageRelation.Overlay:
1588                                                                 text_rect = AlignInRectangle (contentRectangle, this.text_size, this.text_align);
1589                                                                 image_rect = AlignInRectangle (contentRectangle, GetImageSize (), this.image_align);
1590                                                                 break;
1591                                                         case TextImageRelation.ImageAboveText:
1592                                                                 text_area = new Rectangle (contentRectangle.Left, contentRectangle.Bottom - (text_size.Height - 4), contentRectangle.Width, text_size.Height - 4);
1593                                                                 image_area = new Rectangle (contentRectangle.Left, contentRectangle.Top, contentRectangle.Width, contentRectangle.Height - text_area.Height);
1594
1595                                                                 text_rect = AlignInRectangle (text_area, this.text_size, this.text_align);
1596                                                                 image_rect = AlignInRectangle (image_area, GetImageSize (), this.image_align);
1597                                                                 break;
1598                                                         case TextImageRelation.TextAboveImage:
1599                                                                 text_area = new Rectangle (contentRectangle.Left, contentRectangle.Top, contentRectangle.Width, text_size.Height - 4);
1600                                                                 image_area = new Rectangle (contentRectangle.Left, text_area.Bottom, contentRectangle.Width, contentRectangle.Height - text_area.Height);
1601
1602                                                                 text_rect = AlignInRectangle (text_area, this.text_size, this.text_align);
1603                                                                 image_rect = AlignInRectangle (image_area, GetImageSize (), this.image_align);
1604                                                                 break;
1605                                                         case TextImageRelation.ImageBeforeText:
1606                                                                 LayoutTextBeforeOrAfterImage (contentRectangle, false, text_size, GetImageSize (), text_align, image_align, out text_rect, out image_rect);
1607                                                                 break;
1608                                                         case TextImageRelation.TextBeforeImage:
1609                                                                 LayoutTextBeforeOrAfterImage (contentRectangle, true, text_size, GetImageSize (), text_align, image_align, out text_rect, out image_rect);
1610                                                                 break;
1611                                                 }
1612                                         }
1613                                         break;
1614                         }
1615                 }
1616
1617                 internal virtual ToolStripTextDirection DefaultTextDirection { get { return ToolStripTextDirection.Inherit; } }
1618
1619                 internal virtual void Dismiss (ToolStripDropDownCloseReason reason)
1620                 {
1621                         if (is_selected) {
1622                                 this.is_selected = false;
1623                                 this.Invalidate ();
1624                         }
1625                 }
1626                 
1627                 internal virtual ToolStrip GetTopLevelToolStrip ()
1628                 {
1629                         if (this.Parent != null)
1630                                 return this.Parent.GetTopLevelToolStrip ();
1631                                 
1632                         return null;
1633                 }
1634
1635                 private void LayoutTextBeforeOrAfterImage (Rectangle totalArea, bool textFirst, Size textSize, Size imageSize, ContentAlignment textAlign, ContentAlignment imageAlign, out Rectangle textRect, out Rectangle imageRect)
1636                 {
1637                         int element_spacing = 0;        // Spacing between the Text and the Image
1638                         int total_width = textSize.Width + element_spacing + imageSize.Width;
1639                         int excess_width = totalArea.Width - total_width;
1640                         int offset = 0;
1641                         
1642                         Rectangle final_text_rect;
1643                         Rectangle final_image_rect;
1644
1645                         HorizontalAlignment h_text = GetHorizontalAlignment (textAlign);
1646                         HorizontalAlignment h_image = GetHorizontalAlignment (imageAlign);
1647                         
1648                         if (h_image == HorizontalAlignment.Left)
1649                                 offset = 0;
1650                         else if (h_image == HorizontalAlignment.Right && h_text == HorizontalAlignment.Right)
1651                                 offset = excess_width;
1652                         else if (h_image == HorizontalAlignment.Center && (h_text == HorizontalAlignment.Left || h_text == HorizontalAlignment.Center))
1653                                 offset += (int)(excess_width / 3);
1654                         else
1655                                 offset += (int)(2 * (excess_width / 3));
1656                                 
1657                         if (textFirst) {
1658                                 final_text_rect = new Rectangle (totalArea.Left + offset, AlignInRectangle (totalArea, textSize, textAlign).Top, textSize.Width, textSize.Height);
1659                                 final_image_rect = new Rectangle (final_text_rect.Right + element_spacing, AlignInRectangle (totalArea, imageSize, imageAlign).Top, imageSize.Width, imageSize.Height);
1660                         } else {
1661                                 final_image_rect = new Rectangle (totalArea.Left + offset, AlignInRectangle (totalArea, imageSize, imageAlign).Top, imageSize.Width, imageSize.Height);
1662                                 final_text_rect = new Rectangle (final_image_rect.Right + element_spacing, AlignInRectangle (totalArea, textSize, textAlign).Top, textSize.Width, textSize.Height);
1663                         }
1664                         
1665                         textRect = final_text_rect;
1666                         imageRect = final_image_rect;
1667                 }
1668                 
1669                 private HorizontalAlignment GetHorizontalAlignment (ContentAlignment align)
1670                 {
1671                         switch (align) {
1672                                 case ContentAlignment.BottomLeft:
1673                                 case ContentAlignment.MiddleLeft:
1674                                 case ContentAlignment.TopLeft:
1675                                         return HorizontalAlignment.Left;
1676                                 case ContentAlignment.BottomCenter:
1677                                 case ContentAlignment.MiddleCenter:
1678                                 case ContentAlignment.TopCenter:
1679                                         return HorizontalAlignment.Center;
1680                                 case ContentAlignment.BottomRight:
1681                                 case ContentAlignment.MiddleRight:
1682                                 case ContentAlignment.TopRight:
1683                                         return HorizontalAlignment.Right;
1684                         }
1685                         
1686                         return HorizontalAlignment.Left;
1687                 }
1688                 
1689                 internal Size GetImageSize ()
1690                 {
1691                         if (this.Image == null)
1692                                 return Size.Empty;
1693                         
1694                         if (this.image_scaling == ToolStripItemImageScaling.None)
1695                                 return this.Image.Size;
1696                                 
1697                         if (this.Parent == null)
1698                                 return Size.Empty;
1699                                 
1700                         return this.Parent.ImageScalingSize;
1701                 }
1702                 
1703                 internal string GetToolTip ()
1704                 {
1705                         if (this.auto_tool_tip && string.IsNullOrEmpty (this.tool_tip_text))
1706                                 return this.Text;
1707                                 
1708                         return this.tool_tip_text;
1709                 }
1710                 
1711                 internal void FireEvent (EventArgs e, ToolStripItemEventType met)
1712                 {
1713                         // If we're disabled, don't fire any of these events, except Paint
1714                         if (!this.Enabled && met != ToolStripItemEventType.Paint)
1715                                 return;
1716                                 
1717                         switch (met) {
1718                                 case ToolStripItemEventType.MouseUp:
1719                                         this.OnMouseUp ((MouseEventArgs)e);
1720                                         this.HandleClick (e);
1721                                         break;
1722                                 case ToolStripItemEventType.MouseDown:
1723                                         this.OnMouseDown ((MouseEventArgs)e);
1724                                         break;
1725                                 case ToolStripItemEventType.MouseEnter:
1726                                         this.OnMouseEnter (e);
1727                                         break;
1728                                 case ToolStripItemEventType.MouseHover:
1729                                         this.OnMouseHover (e);
1730                                         break;
1731                                 case ToolStripItemEventType.MouseLeave:
1732                                         this.OnMouseLeave (e);
1733                                         break;
1734                                 case ToolStripItemEventType.MouseMove:
1735                                         this.OnMouseMove ((MouseEventArgs)e);
1736                                         break;
1737                                 case ToolStripItemEventType.Paint:
1738                                         this.OnPaint ((PaintEventArgs)e);
1739                                         break;
1740                                 case ToolStripItemEventType.Click:
1741                                         this.HandleClick (e);
1742                                         break;
1743                         }
1744                 }
1745                 
1746                 internal virtual void HandleClick (EventArgs e)
1747                 {
1748                         this.Parent.HandleItemClick (this);
1749                         this.OnClick (e);
1750                 }
1751                 
1752                 internal virtual void SetPlacement (ToolStripItemPlacement placement)
1753                 {
1754                         this.placement = placement;
1755                 }
1756
1757                 private void BeginAnimation ()
1758                 {
1759                         if (image != null && ImageAnimator.CanAnimate (image)) {
1760                                 frame_handler = new EventHandler (OnAnimateImage);
1761                                 ImageAnimator.Animate (image, frame_handler);
1762                         }
1763                 }
1764
1765                 private void OnAnimateImage (object sender, EventArgs e)
1766                 {
1767                         // This is called from a worker thread,BeginInvoke is used
1768                         // so the control is updated from the correct thread
1769
1770                         // Check if we have a handle again, since it may have gotten
1771                         // destroyed since the last time we checked.
1772                         if (Parent == null || !Parent.IsHandleCreated)
1773                                 return;
1774
1775                         Parent.BeginInvoke (new EventHandler (UpdateAnimatedImage), new object[] { this, e });
1776                 }
1777
1778                 private void StopAnimation ()
1779                 {
1780                         if (frame_handler == null)
1781                                 return;
1782                                 
1783                         ImageAnimator.StopAnimate (image, frame_handler);
1784                         frame_handler = null;
1785                 }
1786
1787                 private void UpdateAnimatedImage (object sender, EventArgs e)
1788                 {
1789                         // Check if we have a handle again, since it may have gotten
1790                         // destroyed since the last time we checked.
1791                         if (Parent == null || !Parent.IsHandleCreated)
1792                                 return;
1793
1794                         ImageAnimator.UpdateFrames (image);
1795                         Invalidate ();
1796                 }
1797
1798                 internal bool ShowMargin {
1799                         get {
1800                                 if (!this.IsOnDropDown)
1801                                         return true;
1802
1803                                 if (!(this.Owner is ToolStripDropDownMenu))
1804                                         return true;
1805
1806                                 ToolStripDropDownMenu tsddm = (ToolStripDropDownMenu)this.Owner;
1807
1808                                 return tsddm.ShowCheckMargin || tsddm.ShowImageMargin;
1809                         }
1810                 }
1811
1812                 internal bool UseImageMargin {
1813                         get {
1814                                 if (!this.IsOnDropDown)
1815                                         return true;
1816
1817                                 if (!(this.Owner is ToolStripDropDownMenu))
1818                                         return true;
1819
1820                                 ToolStripDropDownMenu tsddm = (ToolStripDropDownMenu)this.Owner;
1821
1822                                 return tsddm.ShowImageMargin || tsddm.ShowCheckMargin;
1823                         }
1824                 }
1825
1826                 internal virtual bool InternalVisible {
1827                         get { return this.visible; }
1828                         set { this.visible = value; Invalidate (); }
1829                 }
1830                 
1831                 internal Point Location {
1832                         get { return this.bounds.Location; }
1833                         set {
1834                                 if (this.bounds.Location != value) {
1835                                         this.bounds.Location = value;
1836                                         this.OnLocationChanged (EventArgs.Empty);
1837                                 }
1838                         }
1839                 }
1840
1841                 internal int Top {
1842                         get { return this.bounds.Y; }
1843                         set {
1844                                 if (this.bounds.Y != value) {
1845                                         this.bounds.Y = value;
1846                                         this.OnLocationChanged (EventArgs.Empty);
1847                                 }
1848                         }
1849                 }
1850
1851                 internal int Left {
1852                         get { return this.bounds.X; }
1853                         set {
1854                                 if (this.bounds.X != value) {
1855                                         this.bounds.X = value;
1856                                         this.OnLocationChanged (EventArgs.Empty);
1857                                 }
1858                         }
1859                 }
1860                 
1861                 internal int Right { get { return this.bounds.Right; } }
1862                 internal int Bottom { get { return this.bounds.Bottom; } }
1863                 #endregion
1864
1865                 #region IDropTarget Members
1866                 void IDropTarget.OnDragDrop (DragEventArgs e)
1867                 {
1868                         OnDragDrop (e);
1869                 }
1870
1871                 void IDropTarget.OnDragEnter (DragEventArgs e)
1872                 {
1873                         OnDragEnter (e);
1874                 }
1875
1876                 void IDropTarget.OnDragLeave (EventArgs e)
1877                 {
1878                         OnDragLeave (e);
1879                 }
1880
1881                 void IDropTarget.OnDragOver (DragEventArgs e)
1882                 {
1883                         OnDragOver (e);
1884                 }
1885                 #endregion
1886
1887                 [ComVisible (true)]
1888                 public class ToolStripItemAccessibleObject : AccessibleObject
1889                 {
1890                         internal ToolStripItem owner_item;
1891                         
1892                         public ToolStripItemAccessibleObject (ToolStripItem ownerItem)
1893                         {
1894                                 if (ownerItem == null)
1895                                         throw new ArgumentNullException ("ownerItem");
1896                                         
1897                                 this.owner_item = ownerItem;
1898                                 base.default_action = string.Empty;
1899                                 base.keyboard_shortcut = string.Empty;
1900                                 base.name = string.Empty;
1901                                 base.value = string.Empty;
1902                         }
1903
1904                         #region Public Properties
1905                         public override Rectangle Bounds {
1906                                 get {
1907                                         return owner_item.Visible ? owner_item.Bounds : Rectangle.Empty;
1908                                 }
1909                         }
1910
1911                         public override string DefaultAction {
1912                                 get { return base.DefaultAction; }
1913                         }
1914
1915                         public override string Description {
1916                                 get { return base.Description; }
1917                         }
1918
1919                         public override string Help {
1920                                 get { return base.Help; }
1921                         }
1922
1923                         public override string KeyboardShortcut {
1924                                 get { return base.KeyboardShortcut; }
1925                         }
1926
1927                         public override string Name {
1928                                 get {
1929                                         if (base.name == string.Empty)
1930                                                 return owner_item.Text;
1931                                                 
1932                                         return base.Name;
1933                                 }
1934                                 set { base.Name = value; }
1935                         }
1936
1937                         public override AccessibleObject Parent {
1938                                 get { return base.Parent; }
1939                         }
1940
1941                         public override AccessibleRole Role {
1942                                 get { return base.Role; }
1943                         }
1944
1945                         public override AccessibleStates State {
1946                                 get { return base.State; }
1947                         }
1948                         #endregion
1949
1950                         #region Public Methods
1951                         public void AddState (AccessibleStates state)
1952                         {
1953                                 base.state = state;
1954                         }
1955
1956                         public override void DoDefaultAction ()
1957                         {
1958                                 base.DoDefaultAction ();
1959                         }
1960
1961                         public override int GetHelpTopic (out string fileName)
1962                         {
1963                                 return base.GetHelpTopic (out fileName);
1964                         }
1965
1966                         public override AccessibleObject Navigate (AccessibleNavigation navigationDirection)
1967                         {
1968                                 return base.Navigate (navigationDirection);
1969                         }
1970
1971                         public override string ToString ()
1972                         {
1973                                 return string.Format ("ToolStripItemAccessibleObject: Owner = {0}", owner_item.ToString());
1974                         }
1975                         #endregion
1976                 }
1977         }
1978
1979         #region NoneExcludedImageIndexConverter Class
1980         internal class NoneExcludedImageIndexConverter : ImageIndexConverter
1981         {
1982         }
1983         #endregion
1984 }
1985 #endif