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;
43 private bool use_visual_style_back_color;
46 #region Public Constructors
51 SetStyle (ControlStyles.CacheText, true);
54 public TabPage (string text) : base ()
59 #endregion // Public Constructors
61 #region .NET 2.0 Public Instance Properties
63 public bool UseVisualStyleBackColor {
64 get { return use_visual_style_back_color; }
65 set { use_visual_style_back_color = value; }
68 public override Color BackColor {
69 get { return base.BackColor; }
70 set { use_visual_style_back_color = false; base.BackColor = value; }
75 #region Public Instance Properties
77 [EditorBrowsable(EditorBrowsableState.Never)]
78 public override AnchorStyles Anchor {
79 get { return base.Anchor; }
80 set { base.Anchor = value; }
84 [EditorBrowsable(EditorBrowsableState.Never)]
85 public override DockStyle Dock {
86 get { return base.Dock; }
87 set { base.Dock = value; }
91 [EditorBrowsable(EditorBrowsableState.Never)]
92 public new bool Enabled {
93 get { return base.Enabled; }
94 set { base.Enabled = value; }
98 [Editor("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
100 [TypeConverter(typeof(ImageIndexConverter))]
101 public int ImageIndex {
102 get { return image_index; }
104 if (image_index == value)
112 [EditorBrowsable(EditorBrowsableState.Never)]
113 public new int TabIndex {
114 get { return base.TabIndex; }
115 set { base.TabIndex = value; }
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public new bool TabStop {
121 get { return base.TabStop; }
122 set { base.TabStop = value; }
127 public override string Text {
128 get { return base.Text; }
130 if (value == base.Text)
139 public string ToolTipText {
140 get { return tooltip_text; }
143 value = String.Empty;
144 tooltip_text = value;
149 [EditorBrowsable(EditorBrowsableState.Never)]
150 public new bool Visible {
151 get { return base.Visible; }
152 set { /* according to MS docs we can ignore this */ }
155 #endregion // Public Instance Properties
157 #region Public Static Methods
158 public static TabPage GetTabPageOfComponent (object comp)
160 Control control = comp as Control;
163 control = control.Parent;
164 while (control != null) {
165 if (control is TabPage)
167 control = control.Parent;
169 return control as TabPage;
172 #endregion // Public Static Methods
174 #region Public Instance Methods
175 public override string ToString ()
177 return "TabPage: {" + Text + "}";
180 #endregion // Public Instance Methods
182 #region Internal & Private Methods and Properties
183 internal Rectangle TabBounds {
184 get { return tab_bounds; }
185 set { tab_bounds = value; }
193 private void UpdateOwner ()
200 private TabControl Owner {
201 get { return base.Parent as TabControl; }
204 internal void SetVisible (bool value)
206 base.Visible = value;
209 #endregion // Internal & Private Methods and Properties
211 #region Protected Instance Methods
212 protected override ControlCollection CreateControlsInstance ()
214 return new TabPageControlCollection (this);
217 protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
219 if (Owner != null && Owner.IsHandleCreated) {
220 Rectangle display = Owner.DisplayRectangle;
222 base.SetBoundsCore (display.X, display.Y,
223 display.Width, display.Height,
224 BoundsSpecified.All);
226 base.SetBoundsCore (x, y, width, height, specified);
230 #endregion // Protected Instance Methods
234 [EditorBrowsable(EditorBrowsableState.Never)]
235 public new event EventHandler DockChanged {
236 add { base.DockChanged += value; }
237 remove { base.DockChanged -= value; }
241 [EditorBrowsable(EditorBrowsableState.Never)]
242 public new event EventHandler EnabledChanged {
243 add { base.EnabledChanged += value; }
244 remove { base.EnabledChanged -= value; }
248 [EditorBrowsable(EditorBrowsableState.Never)]
249 public new event EventHandler TabIndexChanged {
250 add { base.TabIndexChanged += value; }
251 remove { base.TabIndexChanged -= value; }
255 [EditorBrowsable(EditorBrowsableState.Never)]
256 public new event EventHandler TabStopChanged {
257 add { base.TabStopChanged += value; }
258 remove { base.TabStopChanged -= value; }
262 [EditorBrowsable(EditorBrowsableState.Never)]
263 public new event EventHandler VisibleChanged {
264 add { base.VisibleChanged += value; }
265 remove { base.VisibleChanged -= value; }
271 public new Point Location {
273 return base.Location;
277 base.Location = value;
281 #region Class TabPageControlCollection
282 public class TabPageControlCollection : ControlCollection {
284 //private TabPage owner;
286 public TabPageControlCollection (TabPage owner) : base (owner)
288 //this.owner = owner;
291 public override void Add (Control value)
296 #endregion // Class TabPageControlCollection