2 // ToolStripOverflowButton.cs
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:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
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.
23 // Copyright (c) 2007 Novell
26 // Jonathan Pobst (monkey@jpobst.com)
30 using System.Runtime.InteropServices;
31 using System.ComponentModel;
33 using System.Windows.Forms.Design;
35 namespace System.Windows.Forms
37 [ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.None)]
38 public class ToolStripOverflowButton : ToolStripDropDownButton
40 #region Internal Constructor
41 internal ToolStripOverflowButton (ToolStrip ts)
43 this.InternalOwner = ts;
49 #region Public Properties
50 public override bool HasDropDownItems {
52 if (this.drop_down == null)
55 return this.DropDown.DisplayedItems.Count > 0;
60 [EditorBrowsable (EditorBrowsableState.Never)]
61 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
62 public new bool RightToLeftAutoMirrorImage {
63 get { return base.RightToLeftAutoMirrorImage; }
64 set { base.RightToLeftAutoMirrorImage = value; }
68 #region Protected Properties
69 protected internal override Padding DefaultMargin {
70 get { return new Padding (0, 1, 0, 2); }
74 #region Public Methods
75 public override Size GetPreferredSize (Size constrainingSize)
77 return new Size (16, this.Parent.Height);
81 #region Protected Methods
82 protected override AccessibleObject CreateAccessibilityInstance ()
84 return new ToolStripOverflowButtonAccessibleObject ();
87 protected override ToolStripDropDown CreateDefaultDropDown ()
89 ToolStripDropDown tsdd = new ToolStripOverflow (this);
90 tsdd.DefaultDropDownDirection = ToolStripDropDownDirection.BelowLeft;
91 tsdd.OwnerItem = this;
95 protected override void OnPaint (PaintEventArgs e)
97 if (this.Owner != null)
98 this.Owner.Renderer.DrawOverflowButtonBackground (new ToolStripItemRenderEventArgs (e.Graphics, this));
101 protected internal override void SetBounds (Rectangle bounds)
103 base.SetBounds (bounds);
107 #region ToolStripOverflowButtonAccessibleObject Class
108 private class ToolStripOverflowButtonAccessibleObject : AccessibleObject