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, "System.ComponentModel.Design.IDesigner")]
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
50 SetStyle (ControlStyles.CacheText, true);
53 public TabPage (string text) : base ()
58 #endregion // Public Constructors
60 #region Public Instance Properties
62 [EditorBrowsable(EditorBrowsableState.Never)]
63 public override AnchorStyles Anchor {
64 get { return base.Anchor; }
65 set { base.Anchor = value; }
69 [EditorBrowsable(EditorBrowsableState.Never)]
70 public override DockStyle Dock {
71 get { return base.Dock; }
72 set { base.Dock = value; }
76 [EditorBrowsable(EditorBrowsableState.Never)]
77 public new bool Enabled {
78 get { return base.Enabled; }
79 set { base.Enabled = value; }
83 [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
85 [TypeConverter(typeof(ImageIndexConverter))]
86 public int ImageIndex {
87 get { return image_index; }
89 if (image_index == value)
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 public new int TabIndex {
99 get { return base.TabIndex; }
100 set { base.TabIndex = value; }
104 [EditorBrowsable(EditorBrowsableState.Never)]
105 public new bool TabStop {
106 get { return base.TabStop; }
107 set { base.TabStop = value; }
112 public override string Text {
113 get { return base.Text; }
115 if (value == base.Text)
124 public string ToolTipText {
125 get { return tooltip_text; }
128 value = String.Empty;
129 tooltip_text = value;
134 [EditorBrowsable(EditorBrowsableState.Never)]
135 public new bool Visible {
136 get { return base.Visible; }
137 set { base.Visible = value; }
140 #endregion // Public Instance Properties
142 #region Public Static Methods
143 public static TabPage GetTabPageOfComponent (object comp)
145 Control control = comp as Control;
148 control = control.Parent;
149 while (control != null) {
150 if (control is TabPage)
152 control = control.Parent;
154 return control as TabPage;
157 #endregion // Public Static Methods
159 #region Public Instance Methods
160 public override string ToString ()
162 return "TabPage: {" + Text + "}";
165 #endregion // Public Instance Methods
167 #region Internal & Private Methods and Properties
168 internal Rectangle TabBounds {
169 get { return tab_bounds; }
170 set { tab_bounds = value; }
178 private void UpdateOwner ()
185 private TabControl Owner {
186 get { return base.Parent as TabControl; }
189 #endregion // Internal & Private Methods and Properties
191 #region Protected Instance Methods
192 protected override ControlCollection CreateControlsInstance ()
194 return new TabPageControlCollection (this);
197 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
199 if (Owner != null && Owner.IsHandleCreated) {
200 Rectangle display = Owner.DisplayRectangle;
202 base.SetBoundsCore (display.X, display.Y,
203 display.Width, display.Height,
204 BoundsSpecified.All);
206 base.SetBoundsCore (x, y, width, height, specified);
210 #endregion // Protected Instance Methods
214 [EditorBrowsable(EditorBrowsableState.Never)]
215 public new event EventHandler DockChanged {
216 add { base.DockChanged += value; }
217 remove { base.DockChanged -= value; }
221 [EditorBrowsable(EditorBrowsableState.Never)]
222 public new event EventHandler EnabledChanged {
223 add { base.EnabledChanged += value; }
224 remove { base.EnabledChanged -= value; }
228 [EditorBrowsable(EditorBrowsableState.Never)]
229 public new event EventHandler TabIndexChanged {
230 add { base.TabIndexChanged += value; }
231 remove { base.TabIndexChanged -= value; }
235 [EditorBrowsable(EditorBrowsableState.Never)]
236 public new event EventHandler TabStopChanged {
237 add { base.TabStopChanged += value; }
238 remove { base.TabStopChanged -= value; }
242 [EditorBrowsable(EditorBrowsableState.Never)]
243 public new event EventHandler VisibleChanged {
244 add { base.VisibleChanged += value; }
245 remove { base.VisibleChanged -= value; }
250 #region Class TabPageControlCollection
251 public class TabPageControlCollection : ControlCollection {
253 private TabPage owner;
255 public TabPageControlCollection (TabPage owner) : base (owner)
260 public void Add (Control value)
265 #endregion // Class TabPageControlCollection