2007-03-29 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripDropDown.cs
1 //\r
2 // ToolStripDropDown.cs\r
3 //\r
4 // Permission is hereby granted, free of charge, to any person obtaining\r
5 // a copy of this software and associated documentation files (the\r
6 // "Software"), to deal in the Software without restriction, including\r
7 // without limitation the rights to use, copy, modify, merge, publish,\r
8 // distribute, sublicense, and/or sell copies of the Software, and to\r
9 // permit persons to whom the Software is furnished to do so, subject to\r
10 // the following conditions:\r
11 // \r
12 // The above copyright notice and this permission notice shall be\r
13 // included in all copies or substantial portions of the Software.\r
14 // \r
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22 //\r
23 // Copyright (c) 2006 Jonathan Pobst\r
24 //\r
25 // Authors:\r
26 //      Jonathan Pobst (monkey@jpobst.com)\r
27 //\r
28 \r
29 #if NET_2_0\r
30 using System.Drawing;\r
31 using System.Runtime.InteropServices;\r
32 using System.ComponentModel;\r
33 \r
34 namespace System.Windows.Forms\r
35 {\r
36         [ClassInterface (ClassInterfaceType.AutoDispatch)]\r
37         [ComVisible (true)]\r
38         public class ToolStripDropDown : ToolStrip\r
39         {\r
40                 private bool allow_transparency;\r
41                 private bool auto_close;\r
42                 private bool can_overflow;\r
43                 private bool drop_shadow_enabled = true;\r
44                 private double opacity = 1D;\r
45                 private ToolStripItem owner_item;\r
46 \r
47                 #region Public Constructor\r
48                 public ToolStripDropDown () : base ()\r
49                 {\r
50                         SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);\r
51                         SetStyle (ControlStyles.ResizeRedraw, true);\r
52 \r
53                         this.auto_close = true;\r
54                         is_visible = false;\r
55                         this.DefaultDropDownDirection = ToolStripDropDownDirection.Right;\r
56                         this.GripStyle = ToolStripGripStyle.Hidden;\r
57                         this.TopLevel = true;\r
58                 }\r
59                 #endregion\r
60 \r
61                 #region Public Properties\r
62                 [Browsable (false)]\r
63                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
64                 public bool AllowTransparency {\r
65                         get { return allow_transparency; }\r
66                         set {\r
67                                 if (value == allow_transparency)\r
68                                         return;\r
69 \r
70                                 if ((XplatUI.SupportsTransparency () & TransparencySupport.Set) != 0) {\r
71                                         allow_transparency = value;\r
72 \r
73                                         if (this.IsHandleCreated) {\r
74                                                 if (value) \r
75                                                         XplatUI.SetWindowTransparency (Handle, Opacity, Color.Empty);\r
76                                                 else\r
77                                                         UpdateStyles (); // Remove the WS_EX_LAYERED style\r
78                                         }\r
79                                 }\r
80                         }\r
81                 }\r
82 \r
83                 [Browsable (false)]\r
84                 [EditorBrowsable (EditorBrowsableState.Never)]\r
85                 public override AnchorStyles Anchor {\r
86                         get { return base.Anchor; }\r
87                         set { base.Anchor = value; }\r
88                 }\r
89 \r
90                 [DefaultValue (true)]\r
91                 public bool AutoClose\r
92                 {\r
93                         get { return this.auto_close; }\r
94                         set { this.auto_close = value; }\r
95                 }\r
96 \r
97                 [DefaultValue (true)]\r
98                 public override bool AutoSize {\r
99                         get { return base.AutoSize; }\r
100                         set { base.AutoSize = value; }\r
101                 }\r
102 \r
103                 public new bool CanOverflow {\r
104                         get { return this.can_overflow; }\r
105                         set { this.can_overflow = value; }\r
106                 }\r
107                 \r
108                 [Browsable (false)]\r
109                 [EditorBrowsable (EditorBrowsableState.Never)]\r
110                 public new ContextMenu ContextMenu {\r
111                         get { return null; }\r
112                         set { }\r
113                 }\r
114 \r
115                 [Browsable (false)]\r
116                 [EditorBrowsable (EditorBrowsableState.Never)]\r
117                 public new ContextMenuStrip ContextMenuStrip {\r
118                         get { return null; }\r
119                         set { }\r
120                 }\r
121 \r
122                 public override ToolStripDropDownDirection DefaultDropDownDirection {\r
123                         get { return base.DefaultDropDownDirection; }\r
124                         set { base.DefaultDropDownDirection = value; }\r
125                 }\r
126                 \r
127                 [Browsable (false)]\r
128                 [EditorBrowsable (EditorBrowsableState.Always)]\r
129                 [DefaultValue (DockStyle.None)]\r
130                 public override DockStyle Dock {\r
131                         get { return base.Dock; }\r
132                         set { base.Dock = value; }\r
133                 }\r
134                 \r
135                 public bool DropShadowEnabled {\r
136                         get { return this.drop_shadow_enabled; }\r
137                         set {\r
138                                 if (this.drop_shadow_enabled == value)\r
139                                         return;\r
140                                         \r
141                                 this.drop_shadow_enabled = value;\r
142                                 UpdateStyles ();        // Re-CreateParams\r
143                         }\r
144                 }\r
145 \r
146                 public override Font Font {\r
147                         get { return base.Font; }\r
148                         set { base.Font = value; }\r
149                 }\r
150 \r
151                 [Browsable (false)]\r
152                 [EditorBrowsable (EditorBrowsableState.Never)]\r
153                 public new ToolStripGripDisplayStyle GripDisplayStyle {\r
154                         get { return ToolStripGripDisplayStyle.Vertical; }\r
155                 }\r
156 \r
157                 [Browsable (false)]\r
158                 [EditorBrowsable (EditorBrowsableState.Never)]\r
159                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
160                 public new Padding GripMargin {\r
161                         get { return Padding.Empty; }\r
162                         set { }\r
163                 }\r
164 \r
165                 [Browsable (false)]\r
166                 [EditorBrowsable (EditorBrowsableState.Never)]\r
167                 public new Rectangle GripRectangle {\r
168                         get { return Rectangle.Empty; }\r
169                 }\r
170 \r
171                 [Browsable (false)]\r
172                 [EditorBrowsable (EditorBrowsableState.Never)]\r
173                 [DefaultValue (ToolStripGripStyle.Hidden)]\r
174                 public new ToolStripGripStyle GripStyle {\r
175                         get { return base.GripStyle; }\r
176                         set { base.GripStyle = value; }\r
177                 }\r
178 \r
179                 public bool IsAutoGenerated {\r
180                         get { return this is ToolStripOverflow; }\r
181                 }\r
182                 \r
183                 [Browsable (false)]\r
184                 [EditorBrowsable (EditorBrowsableState.Never)]\r
185                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
186                 public new Point Location {\r
187                         get { return base.Location; }\r
188                         set { base.Location = value; }\r
189                 }\r
190 \r
191                 [DefaultValue (1D)]\r
192                 [TypeConverter (typeof (OpacityConverter))]\r
193                 [Browsable (false)]\r
194                 [EditorBrowsable (EditorBrowsableState.Advanced)]\r
195                 public double Opacity {\r
196                         get { return this.opacity; }\r
197                         set {\r
198                                         if (this.opacity == value)\r
199                                                 return;\r
200                                                 \r
201                                         this.opacity = value;\r
202                                         this.allow_transparency = true;\r
203                                         \r
204                                         if (this.IsHandleCreated) {\r
205                                                 UpdateStyles ();\r
206                                                 XplatUI.SetWindowTransparency (Handle, opacity, Color.Empty);\r
207                                         }\r
208                         }\r
209                 }\r
210 \r
211                 [EditorBrowsable (EditorBrowsableState.Never)]\r
212                 public new ToolStripOverflowButton OverflowButton {\r
213                         get { return base.OverflowButton; }\r
214                 }\r
215 \r
216                 [Browsable (false)]\r
217                 [DefaultValue (null)]\r
218                 public ToolStripItem OwnerItem {\r
219                         get { return this.owner_item; }\r
220                         set { this.owner_item = value; \r
221                                 \r
222                                 if (this.owner_item != null)\r
223                                         if (this.owner_item.Owner != null)\r
224                                                 this.Renderer = this.owner_item.Owner.Renderer;\r
225                         }\r
226                 }\r
227 \r
228                 [Browsable (false)]\r
229                 [EditorBrowsable (EditorBrowsableState.Always)]\r
230                 public new Region Region {\r
231                         get { return base.Region; }\r
232                         set { base.Region = value; }\r
233                 }\r
234 \r
235                 [Localizable (true)]\r
236                 [AmbientValue (RightToLeft.Inherit)]\r
237                 public override RightToLeft RightToLeft {\r
238                         get { return base.RightToLeft; }\r
239                         set { base.RightToLeft = value; }\r
240                 }\r
241 \r
242                 [Browsable (false)]\r
243                 [EditorBrowsable (EditorBrowsableState.Never)]\r
244                 public new bool Stretch {\r
245                         get { return false; }\r
246                         set { }\r
247                 }\r
248 \r
249                 [Browsable (false)]\r
250                 [EditorBrowsable (EditorBrowsableState.Never)]\r
251                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
252                 public new int TabIndex {\r
253                         get { return 0; }\r
254                         set { }\r
255                 }\r
256 \r
257                 [Browsable (false)]\r
258                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
259                 [EditorBrowsable (EditorBrowsableState.Advanced)]\r
260                 public bool TopLevel {\r
261                         get { return GetTopLevel (); }\r
262                         set { SetTopLevel (value); }\r
263                 }\r
264                 \r
265                 [Browsable (false)]\r
266                 [Localizable (true)]\r
267                 [DefaultValue (false)]\r
268                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
269                 public new bool Visible {\r
270                         get { return base.Visible; }\r
271                         set { base.Visible = value; }\r
272                 }\r
273                 #endregion\r
274 \r
275                 #region Protected Properties\r
276                 protected override CreateParams CreateParams {\r
277                         get {\r
278                                 CreateParams cp = base.CreateParams;\r
279 \r
280                                 cp.Style = unchecked ((int)(WindowStyles.WS_POPUP | WindowStyles.WS_CLIPCHILDREN));\r
281                                 cp.ClassStyle |= (int)XplatUIWin32.ClassStyle.CS_DROPSHADOW;\r
282                                 cp.ExStyle |= (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);\r
283 \r
284                                 if (Opacity < 1.0 && allow_transparency)\r
285                                         cp.ExStyle |= (int)WindowExStyles.WS_EX_LAYERED;\r
286                                 if (TopMost)\r
287                                         cp.ExStyle |= (int) WindowExStyles.WS_EX_TOPMOST;\r
288 \r
289                                 return cp;\r
290                         }\r
291                 }\r
292 \r
293                 protected override DockStyle DefaultDock {\r
294                         get { return DockStyle.None; }\r
295                 }\r
296 \r
297                 protected override Padding DefaultPadding {\r
298                         get { return new Padding (1, 2, 1, 2); }\r
299                 }\r
300 \r
301                 protected override bool DefaultShowItemToolTips {\r
302                         get { return true; }\r
303                 }\r
304 \r
305                 //protected internal override Size MaxItemSize {\r
306                 //        get {  return new Size (Screen.PrimaryScreen.Bounds.Width - 2, Screen.PrimaryScreen.Bounds.Height - 34); }\r
307                 //}\r
308 \r
309                 protected virtual bool TopMost {\r
310                         get { return true; }\r
311                 }\r
312                 #endregion\r
313 \r
314                 #region Public Methods\r
315                 public void Close ()\r
316                 {\r
317                         this.Close (ToolStripDropDownCloseReason.CloseCalled);\r
318                 }\r
319 \r
320                 public void Close (ToolStripDropDownCloseReason reason)\r
321                 {\r
322                         // Give users a chance to cancel the close\r
323                         ToolStripDropDownClosingEventArgs e = new ToolStripDropDownClosingEventArgs (reason);\r
324                         this.OnClosing (e);\r
325 \r
326                         if (e.Cancel)\r
327                                 return;\r
328 \r
329                         // Don't actually close if AutoClose == true unless explicitly called\r
330                         if (!this.auto_close && reason != ToolStripDropDownCloseReason.CloseCalled)\r
331                                 return;\r
332 \r
333                         // Detach from the tracker\r
334                         ToolStripManager.AppClicked -= new EventHandler (ToolStripMenuTracker_AppClicked); ;\r
335                         ToolStripManager.AppFocusChange -= new EventHandler (ToolStripMenuTracker_AppFocusChange);\r
336 \r
337                         // Hide this dropdown\r
338                         this.Hide ();\r
339 \r
340                         // Owner MenuItem needs to be told to redraw (it's no longer selected)\r
341                         if (owner_item != null)\r
342                                 owner_item.Invalidate ();\r
343 \r
344                         // Recursive hide all child dropdowns\r
345                         foreach (ToolStripItem tsi in this.Items)\r
346                                 if (tsi is ToolStripMenuItem)\r
347                                         (tsi as ToolStripMenuItem).HideDropDown (reason);\r
348                         \r
349                         this.OnClosed (new ToolStripDropDownClosedEventArgs (reason));\r
350                 }\r
351 \r
352                 [Browsable (false)]\r
353                 [EditorBrowsable (EditorBrowsableState.Never)]\r
354                 public new void Show ()\r
355                 {\r
356                         CancelEventArgs e = new CancelEventArgs ();\r
357                         this.OnOpening (e);\r
358                         \r
359                         if (e.Cancel)\r
360                                 return;\r
361 \r
362                         // The tracker lets us know when the form is clicked or loses focus\r
363                         ToolStripManager.AppClicked += new EventHandler (ToolStripMenuTracker_AppClicked);\r
364                         ToolStripManager.AppFocusChange += new EventHandler (ToolStripMenuTracker_AppFocusChange);\r
365 \r
366                         base.Show ();\r
367                         \r
368                         this.OnOpened (EventArgs.Empty);\r
369                 }\r
370                 \r
371                 public void Show (Point screenLocation)\r
372                 {\r
373                         this.Location = screenLocation;\r
374                         Show ();\r
375                 }\r
376                 \r
377                 public void Show (Control control, Point position)\r
378                 {\r
379                         if (control == null)\r
380                                 throw new ArgumentNullException ("control");\r
381                                 \r
382                         this.Location = control.PointToScreen (position);\r
383                         Show ();\r
384                 }\r
385                 \r
386                 public void Show (int x, int y)\r
387                 {\r
388                         this.Location = new Point (x, y);\r
389                         Show ();\r
390                 }\r
391                 \r
392                 public void Show (Point position, ToolStripDropDownDirection direction)\r
393                 {\r
394                         this.PerformLayout ();\r
395                         \r
396                         Point show_point = position;\r
397 \r
398                         switch (direction) {\r
399                                 case ToolStripDropDownDirection.AboveLeft:\r
400                                         show_point.Y -= this.Height;\r
401                                         show_point.X -= this.Width;\r
402                                         break;\r
403                                 case ToolStripDropDownDirection.AboveRight:\r
404                                         show_point.Y -= this.Height;\r
405                                         break;\r
406                                 case ToolStripDropDownDirection.BelowLeft:\r
407                                         show_point.X -= this.Width;\r
408                                         break;\r
409                                 case ToolStripDropDownDirection.Left:\r
410                                         show_point.X -= this.Width;\r
411                                         break;\r
412                                 case ToolStripDropDownDirection.Right:\r
413                                         break;\r
414                         }\r
415                         \r
416                         if (this.Location != show_point)\r
417                                 this.Location = show_point;\r
418                                 \r
419                         Show ();\r
420                 }\r
421                 \r
422                 public void Show (Control control, int x, int y)\r
423                 {\r
424                         if (control == null)\r
425                                 throw new ArgumentNullException ("control");\r
426 \r
427                         Show (control, new Point (x, y));\r
428                 }\r
429                 \r
430                 public void Show (Control control, Point position, ToolStripDropDownDirection direction)\r
431                 {\r
432                         if (control == null)\r
433                                 throw new ArgumentNullException ("control");\r
434 \r
435                         Show (control.PointToScreen (position), direction);\r
436                 }\r
437                 #endregion\r
438 \r
439                 #region Protected Methods\r
440                 protected override void CreateHandle ()\r
441                 {\r
442                         base.CreateHandle ();\r
443                 }\r
444 \r
445                 protected override LayoutSettings CreateLayoutSettings (ToolStripLayoutStyle style)\r
446                 {\r
447                         return base.CreateLayoutSettings (style);\r
448                 }\r
449                 \r
450                 protected override void Dispose (bool disposing)\r
451                 {\r
452                         base.Dispose (disposing);\r
453                 }\r
454 \r
455                 protected virtual void OnClosed (ToolStripDropDownClosedEventArgs e)\r
456                 {\r
457                         ToolStripDropDownClosedEventHandler eh = (ToolStripDropDownClosedEventHandler)(Events [ClosedEvent]);\r
458                         if (eh != null)\r
459                                 eh (this, e);\r
460                 }\r
461 \r
462                 protected virtual void OnClosing (ToolStripDropDownClosingEventArgs e)\r
463                 {\r
464                         ToolStripDropDownClosingEventHandler eh = (ToolStripDropDownClosingEventHandler)(Events [ClosingEvent]);\r
465                         if (eh != null)\r
466                                 eh (this, e);\r
467                 }\r
468 \r
469                 protected override void OnHandleCreated (EventArgs e)\r
470                 {\r
471                         base.OnHandleCreated (e);\r
472                 }\r
473 \r
474                 protected override void OnItemClicked (ToolStripItemClickedEventArgs e)\r
475                 {\r
476                         base.OnItemClicked (e);\r
477                 }\r
478 \r
479                 protected override void OnLayout (LayoutEventArgs e)\r
480                 {\r
481                         // Find the widest menu item\r
482                         int widest = 0;\r
483 \r
484                         foreach (ToolStripItem tsi in this.Items) {\r
485                                 if (!tsi.Available) \r
486                                         continue;\r
487                                         \r
488                                 tsi.SetPlacement (ToolStripItemPlacement.Main);\r
489                                 \r
490                                 if (tsi.GetPreferredSize (Size.Empty).Width > widest)\r
491                                         widest = tsi.GetPreferredSize (Size.Empty).Width;\r
492                         }\r
493                         \r
494                         int x = this.Padding.Left;\r
495                         widest += 68 - this.Padding.Horizontal;\r
496                         int y = this.Padding.Top;\r
497 \r
498                         foreach (ToolStripItem tsi in this.Items) {\r
499                                 if (!tsi.Available)\r
500                                         continue;\r
501 \r
502                                 y += tsi.Margin.Top;\r
503 \r
504                                 int height = 0;\r
505 \r
506                                 if (tsi is ToolStripSeparator)\r
507                                         height = 7;\r
508                                 else\r
509                                         height = 22;\r
510 \r
511                                 tsi.SetBounds (new Rectangle (x, y, widest, height));\r
512                                 y += tsi.Height + tsi.Margin.Bottom;\r
513                         }\r
514 \r
515                         this.Size = new Size (widest + this.Padding.Horizontal, y + this.Padding.Bottom);// + 2);\r
516                         this.SetDisplayedItems ();\r
517                         this.OnLayoutCompleted (EventArgs.Empty);\r
518                         this.Invalidate ();\r
519                 }\r
520 \r
521                 protected override void OnMouseUp (MouseEventArgs mea)\r
522                 {\r
523                         base.OnMouseUp (mea);\r
524                 }\r
525 \r
526                 protected virtual void OnOpened (EventArgs e)\r
527                 {\r
528                         EventHandler eh = (EventHandler)(Events [OpenedEvent]);\r
529                         if (eh != null)\r
530                                 eh (this, e);\r
531                 }\r
532 \r
533                 protected virtual void OnOpening (CancelEventArgs e)\r
534                 {\r
535                         CancelEventHandler eh = (CancelEventHandler)(Events [OpeningEvent]);\r
536                         if (eh != null)\r
537                                 eh (this, e);\r
538                 }\r
539 \r
540                 protected override void OnParentChanged (EventArgs e)\r
541                 {\r
542                         base.OnParentChanged (e);\r
543                         \r
544                         if (Parent is ToolStrip)\r
545                                 this.Renderer = (Parent as ToolStrip).Renderer;\r
546                 }\r
547 \r
548                 protected override void OnVisibleChanged (EventArgs e)\r
549                 {\r
550                         base.OnVisibleChanged (e);\r
551                 }\r
552 \r
553                 [EditorBrowsable (EditorBrowsableState.Advanced)]\r
554                 protected override bool ProcessDialogChar (char charCode)\r
555                 {\r
556                         return base.ProcessDialogChar (charCode);\r
557                 }\r
558 \r
559                 protected override bool ProcessDialogKey (Keys keyData)\r
560                 {\r
561                         return base.ProcessDialogKey (keyData);\r
562                 }\r
563 \r
564                 protected override bool ProcessMnemonic (char charCode)\r
565                 {\r
566                         return base.ProcessMnemonic (charCode);\r
567                 }\r
568 \r
569                 [EditorBrowsable (EditorBrowsableState.Never)]\r
570                 protected override void ScaleCore (float dx, float dy)\r
571                 {\r
572                         base.ScaleCore (dx, dy);\r
573                 }\r
574 \r
575                 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)\r
576                 {\r
577                         base.SetBoundsCore (x, y, width, height, specified);\r
578                 }\r
579 \r
580                 protected override void SetVisibleCore (bool value)\r
581                 {\r
582                         base.SetVisibleCore (value);\r
583                 }\r
584 \r
585                 protected override void WndProc (ref Message m)\r
586                 {\r
587                         const int MA_NOACTIVATE = 0x0003;\r
588 \r
589                         // Don't activate when the WM tells us to\r
590                         if ((Msg)m.Msg == Msg.WM_MOUSEACTIVATE) {\r
591                                 m.Result = (IntPtr)MA_NOACTIVATE;\r
592                                 return;\r
593                         }\r
594 \r
595                         base.WndProc (ref m);\r
596                 }\r
597                 #endregion\r
598 \r
599                 #region Public Events\r
600                 static object ClosedEvent = new object ();\r
601                 static object ClosingEvent = new object ();\r
602                 static object OpenedEvent = new object ();\r
603                 static object OpeningEvent = new object ();\r
604                 static object ScrollEvent = new object ();\r
605 \r
606                 [Browsable (false)]\r
607                 public new event EventHandler BackgroundImageChanged {\r
608                         add { base.BackgroundImageChanged += value; }\r
609                         remove { base.BackgroundImageChanged -= value; }\r
610                 }\r
611 \r
612                 [Browsable (false)]\r
613                 public new event EventHandler BackgroundImageLayoutChanged {\r
614                         add { base.BackgroundImageLayoutChanged += value; }\r
615                         remove { base.BackgroundImageLayoutChanged -= value; }\r
616                 }\r
617 \r
618                 [Browsable (false)]\r
619                 public new event EventHandler BindingContextChanged {\r
620                         add { base.BindingContextChanged += value; }\r
621                         remove { base.BindingContextChanged -= value; }\r
622                 }\r
623 \r
624                 [Browsable (false)]\r
625                 [EditorBrowsable (EditorBrowsableState.Always)]\r
626                 public new event UICuesEventHandler ChangeUICues {\r
627                         add { base.ChangeUICues += value; }\r
628                         remove { base.ChangeUICues -= value; }\r
629                 }\r
630 \r
631                 public event ToolStripDropDownClosedEventHandler Closed {\r
632                         add { Events.AddHandler (ClosedEvent, value); }\r
633                         remove { Events.RemoveHandler (ClosedEvent, value); }\r
634                 }\r
635 \r
636                 public event ToolStripDropDownClosingEventHandler Closing {\r
637                         add { Events.AddHandler (ClosingEvent, value); }\r
638                         remove { Events.RemoveHandler (ClosingEvent, value); }\r
639                 }\r
640 \r
641                 [Browsable (false)]\r
642                 [EditorBrowsable (EditorBrowsableState.Never)]\r
643                 public new event EventHandler ContextMenuChanged {\r
644                         add { base.ContextMenuChanged += value; }\r
645                         remove { base.ContextMenuChanged -= value; }\r
646                 }\r
647 \r
648                 [Browsable (false)]\r
649                 [EditorBrowsable (EditorBrowsableState.Always)]\r
650                 public new event EventHandler ContextMenuStripChanged {\r
651                         add { base.ContextMenuStripChanged += value; }\r
652                         remove { base.ContextMenuStripChanged -= value; }\r
653                 }\r
654 \r
655                 [Browsable (false)]\r
656                 [EditorBrowsable (EditorBrowsableState.Always)]\r
657                 public new event EventHandler DockChanged {\r
658                         add { base.DockChanged += value; }\r
659                         remove { base.DockChanged -= value; }\r
660                 }\r
661 \r
662                 [Browsable (false)]\r
663                 [EditorBrowsable (EditorBrowsableState.Always)]\r
664                 public new event EventHandler Enter {\r
665                         add { base.Enter += value; }\r
666                         remove { base.Enter -= value; }\r
667                 }\r
668 \r
669                 [Browsable (false)]\r
670                 [EditorBrowsable (EditorBrowsableState.Always)]\r
671                 public new event EventHandler FontChanged {\r
672                         add { base.FontChanged += value; }\r
673                         remove { base.FontChanged -= value; }\r
674                 }\r
675 \r
676                 [Browsable (false)]\r
677                 [EditorBrowsable (EditorBrowsableState.Never)]\r
678                 public new event EventHandler ForeColorChanged {\r
679                         add { base.ForeColorChanged += value; }\r
680                         remove { base.ForeColorChanged -= value; }\r
681                 }\r
682 \r
683                 [Browsable (false)]\r
684                 [EditorBrowsable (EditorBrowsableState.Never)]\r
685                 public new event GiveFeedbackEventHandler GiveFeedback {\r
686                         add { base.GiveFeedback += value; }\r
687                         remove { base.GiveFeedback -= value; }\r
688                 }\r
689 \r
690                 [Browsable (false)]\r
691                 [EditorBrowsable (EditorBrowsableState.Always)]\r
692                 public new event HelpEventHandler HelpRequested {\r
693                         add { base.HelpRequested += value; }\r
694                         remove { base.HelpRequested -= value; }\r
695                 }\r
696 \r
697                 [Browsable (false)]\r
698                 [EditorBrowsable (EditorBrowsableState.Always)]\r
699                 public new event EventHandler ImeModeChanged {\r
700                         add { base.ImeModeChanged += value; }\r
701                         remove { base.ImeModeChanged -= value; }\r
702                 }\r
703 \r
704                 [Browsable (false)]\r
705                 [EditorBrowsable (EditorBrowsableState.Always)]\r
706                 public new event KeyEventHandler KeyDown {\r
707                         add { base.KeyDown += value; }\r
708                         remove { base.KeyDown -= value; }\r
709                 }\r
710 \r
711                 [Browsable (false)]\r
712                 [EditorBrowsable (EditorBrowsableState.Always)]\r
713                 public new event KeyPressEventHandler KeyPress {\r
714                         add { base.KeyPress += value; }\r
715                         remove { base.KeyPress -= value; }\r
716                 }\r
717 \r
718                 [Browsable (false)]\r
719                 [EditorBrowsable (EditorBrowsableState.Always)]\r
720                 public new event KeyEventHandler KeyUp {\r
721                         add { base.KeyUp += value; }\r
722                         remove { base.KeyUp -= value; }\r
723                 }\r
724 \r
725                 [Browsable (false)]\r
726                 [EditorBrowsable (EditorBrowsableState.Always)]\r
727                 public new event EventHandler Leave {\r
728                         add { base.Leave += value; }\r
729                         remove { base.Leave -= value; }\r
730                 }\r
731 \r
732                 public event EventHandler Opened {\r
733                         add { Events.AddHandler (OpenedEvent, value); }\r
734                         remove { Events.RemoveHandler (OpenedEvent, value); }\r
735                 }\r
736 \r
737                 public event CancelEventHandler Opening {\r
738                         add { Events.AddHandler (OpeningEvent, value); }\r
739                         remove { Events.RemoveHandler (OpeningEvent, value); }\r
740                 }\r
741 \r
742                 [Browsable (false)]\r
743                 [EditorBrowsable (EditorBrowsableState.Always)]\r
744                 public new event EventHandler RegionChanged {\r
745                         add { base.RegionChanged += value; }\r
746                         remove { base.RegionChanged -= value; }\r
747                 }\r
748 \r
749                 [Browsable (false)]\r
750                 [EditorBrowsable (EditorBrowsableState.Never)]\r
751                 public new event ScrollEventHandler Scroll {\r
752                         add { Events.AddHandler (ScrollEvent, value); }\r
753                         remove { Events.RemoveHandler (ScrollEvent, value); }\r
754                 }\r
755 \r
756                 [Browsable (false)]\r
757                 [EditorBrowsable (EditorBrowsableState.Always)]\r
758                 public new event EventHandler StyleChanged {\r
759                         add { base.StyleChanged += value; }\r
760                         remove { base.StyleChanged -= value; }\r
761                 }\r
762 \r
763                 [Browsable (false)]\r
764                 [EditorBrowsable (EditorBrowsableState.Never)]\r
765                 public new event EventHandler TabIndexChanged {\r
766                         add { base.TabIndexChanged += value; }\r
767                         remove { base.TabIndexChanged -= value; }\r
768                 }\r
769 \r
770                 [Browsable (false)]\r
771                 [EditorBrowsable (EditorBrowsableState.Never)]\r
772                 public new event EventHandler TabStopChanged {\r
773                         add { base.TabStopChanged += value; }\r
774                         remove { base.TabStopChanged -= value; }\r
775                 }\r
776 \r
777                 [Browsable (false)]\r
778                 [EditorBrowsable (EditorBrowsableState.Never)]\r
779                 public new event EventHandler TextChanged {\r
780                         add { base.TextChanged += value; }\r
781                         remove { base.TextChanged -= value; }\r
782                 }\r
783 \r
784                 [Browsable (false)]\r
785                 [EditorBrowsable (EditorBrowsableState.Never)]\r
786                 public new event EventHandler Validated {\r
787                         add { base.Validated += value; }\r
788                         remove { base.Validated -= value; }\r
789                 }\r
790 \r
791                 [Browsable (false)]\r
792                 [EditorBrowsable (EditorBrowsableState.Never)]\r
793                 public new event CancelEventHandler Validating {\r
794                         add { base.Validating += value; }\r
795                         remove { base.Validating -= value; }\r
796                 }\r
797                 #endregion\r
798 \r
799                 #region Private Methods\r
800                 private void ToolStripMenuTracker_AppFocusChange (object sender, EventArgs e)\r
801                 {\r
802                         this.Close (ToolStripDropDownCloseReason.AppFocusChange);\r
803                 }\r
804 \r
805                 private void ToolStripMenuTracker_AppClicked (object sender, EventArgs e)\r
806                 {\r
807                         this.Close (ToolStripDropDownCloseReason.AppClicked);\r
808                 }\r
809                 #endregion\r
810 \r
811                 #region Internal Properties\r
812                 internal override bool ActivateOnShow { get { return false; } }\r
813                 #endregion\r
814         }\r
815 }\r
816 #endif\r