1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Jackson Harper (jackson@ximian.com)
27 using System.ComponentModel;
28 using System.ComponentModel.Design;
31 namespace System.Windows.Forms {
32 [DefaultEvent("Click")]
33 [DesignTimeVisible(false)]
34 [DefaultProperty("Text")]
35 [Designer("System.Windows.Forms.Design.TabPageDesigner, " + Consts.AssemblySystem_Design)]
37 public class TabPage : Panel {
39 private int image_index = -1;
40 private string tooltip_text = String.Empty;
41 private Rectangle tab_bounds;
45 #region Public Constructors
51 public TabPage (string text) : base ()
56 #endregion // Public Constructors
58 #region Public Instance Properties
60 [EditorBrowsable(EditorBrowsableState.Never)]
61 public override AnchorStyles Anchor {
62 get { return base.Anchor; }
63 set { base.Anchor = value; }
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 public override DockStyle Dock {
69 get { return base.Dock; }
70 set { base.Dock = value; }
74 [EditorBrowsable(EditorBrowsableState.Never)]
75 public new bool Enabled {
76 get { return base.Enabled; }
77 set { base.Enabled = value; }
81 [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
83 [TypeConverter(typeof(ImageIndexConverter))]
84 public int ImageIndex {
85 get { return image_index; }
87 if (image_index == value)
95 [EditorBrowsable(EditorBrowsableState.Never)]
96 public new int TabIndex {
97 get { return base.TabIndex; }
98 set { base.TabIndex = value; }
102 [EditorBrowsable(EditorBrowsableState.Never)]
103 public new bool TabStop {
104 get { return base.TabStop; }
105 set { base.TabStop = value; }
110 public override string Text {
111 get { return base.Text; }
113 if (value == base.Text)
122 public string ToolTipText {
123 get { return tooltip_text; }
126 value = String.Empty;
127 tooltip_text = value;
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 public new bool Visible {
134 get { return base.Visible; }
135 set { base.Visible = value; }
138 #endregion // Public Instance Properties
140 #region Public Static Methods
141 public static TabPage GetTabPageOfComponent (object comp)
143 Control control = comp as Control;
146 control = control.Parent;
147 while (control != null) {
148 if (control is TabPage)
150 control = control.Parent;
152 return control as TabPage;
155 #endregion // Public Static Methods
157 #region Public Instance Methods
158 public override string ToString ()
160 return "TabPage: {" + Text + "}";
163 #endregion // Public Instance Methods
165 #region Internal & Private Methods and Properties
166 internal Rectangle TabBounds {
167 get { return tab_bounds; }
168 set { tab_bounds = value; }
176 private void UpdateOwner ()
183 private TabControl Owner {
184 get { return base.Parent as TabControl; }
187 #endregion // Internal & Private Methods and Properties
189 #region Protected Instance Methods
190 protected override ControlCollection CreateControlsInstance ()
192 return new TabPageControlCollection (this);
195 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
197 if (Owner != null && Owner.IsHandleCreated) {
198 Rectangle display = Owner.DisplayRectangle;
200 base.SetBoundsCore (display.X, display.Y,
201 display.Width, display.Height,
202 BoundsSpecified.All);
204 base.SetBoundsCore (x, y, width, height, specified);
208 #endregion // Protected Instance Methods
212 [EditorBrowsable(EditorBrowsableState.Never)]
213 public new event EventHandler DockChanged {
214 add { base.DockChanged += value; }
215 remove { base.DockChanged -= value; }
219 [EditorBrowsable(EditorBrowsableState.Never)]
220 public new event EventHandler EnabledChanged {
221 add { base.EnabledChanged += value; }
222 remove { base.EnabledChanged -= value; }
226 [EditorBrowsable(EditorBrowsableState.Never)]
227 public new event EventHandler TabIndexChanged {
228 add { base.TabIndexChanged += value; }
229 remove { base.TabIndexChanged -= value; }
233 [EditorBrowsable(EditorBrowsableState.Never)]
234 public new event EventHandler TabStopChanged {
235 add { base.TabStopChanged += value; }
236 remove { base.TabStopChanged -= value; }
240 [EditorBrowsable(EditorBrowsableState.Never)]
241 public new event EventHandler VisibleChanged {
242 add { base.VisibleChanged += value; }
243 remove { base.VisibleChanged -= value; }
248 #region Class TabPageControlCollection
249 public class TabPageControlCollection : ControlCollection {
251 private TabPage owner;
253 public TabPageControlCollection (TabPage owner) : base (owner)
258 public void Add (Control value)
263 #endregion // Class TabPageControlCollection