merge from trunk revisions 58933, 58935, 58936
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / HotSpot.cs
1 //
2 // System.Web.UI.WebControls.HotSpot.cs
3 //
4 // Authors:
5 //      Lluis Sanchez Gual (lluis@novell.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System.ComponentModel;
34 using System.Security.Permissions;
35
36 namespace System.Web.UI.WebControls
37 {
38         [TypeConverterAttribute (typeof(ExpandableObjectConverter))]\r
39         [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
40         [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
41         public abstract class HotSpot: IStateManager
42         {
43                 StateBag viewState = new StateBag ();
44                 
45             [LocalizableAttribute (true)]\r
46             [DefaultValueAttribute ("")]\r
47                 public virtual string AccessKey {
48                         get {
49                                 object o = viewState ["AccessKey"];
50                                 return o != null ? (string) o : "";
51                         }
52                         set {
53                                 viewState ["AccessKey"] = value;
54                         }
55                 }
56                 
57             [NotifyParentPropertyAttribute (true)]\r
58             [WebCategoryAttribute ("Behavior")]\r
59             [DefaultValueAttribute ("")]\r
60             [BindableAttribute (true)]\r
61                 public virtual string AlternateText {
62                         get {
63                                 object o = viewState ["AlternateText"];
64                                 return o != null ? (string) o : "";
65                         }
66                         set {
67                                 viewState ["AlternateText"] = value;
68                         }
69                 }
70                 
71             [WebCategoryAttribute ("Behavior")]\r
72             [DefaultValueAttribute (HotSpotMode.NotSet)]\r
73             [NotifyParentPropertyAttribute (true)]\r
74                 public virtual HotSpotMode HotSpotMode {
75                         get {
76                                 object o = viewState ["HotSpotMode"];
77                                 return o != null ? (HotSpotMode) o : HotSpotMode.NotSet;
78                         }
79                         set {
80                                 viewState ["HotSpotMode"] = value;
81                         }
82                 }
83                 
84             [DefaultValueAttribute ("")]\r
85             [BindableAttribute (true)]\r
86             [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
87             [NotifyParentPropertyAttribute (true)]\r
88             [UrlPropertyAttribute]\r
89                 public virtual string NavigateUrl {
90                         get {
91                                 object o = viewState ["NavigateUrl"];
92                                 return o != null ? (string) o : "";
93                         }
94                         set {
95                                 viewState ["NavigateUrl"] = value;
96                         }
97                 }
98                 
99             [BindableAttribute (true)]\r
100             [WebCategoryAttribute ("Behavior")]\r
101             [DefaultValueAttribute ("")]\r
102             [NotifyParentPropertyAttribute (true)]\r
103                 public virtual string PostBackValue {
104                         get {
105                                 object o = viewState ["PostBackValue"];
106                                 return o != null ? (string) o : "";
107                         }
108                         set {
109                                 viewState ["PostBackValue"] = value;
110                         }
111                 }
112                 
113             [DefaultValueAttribute ((short)0)]\r
114             [WebCategoryAttribute ("Accessibility")]\r
115                 public virtual short TabIndex {
116                         get {
117                                 object o = viewState ["TabIndex"];
118                                 return o != null ? (short) o : (short) 0;
119                         }
120                         set {
121                                 viewState ["TabIndex"] = value;
122                         }
123                 }
124                 
125             [WebCategoryAttribute ("Behavior")]\r
126             [NotifyParentPropertyAttribute (true)]\r
127             [DefaultValueAttribute ("")]\r
128             [TypeConverterAttribute (typeof(TargetConverter))]\r
129                 public virtual string Target {
130                         get {
131                                 object o = viewState ["Target"];
132                                 return o != null ? (string) o : "";
133                         }
134                         set {
135                                 viewState ["Target"] = value;
136                         }
137                 }
138                 
139                 [Browsable (false)]
140                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
141                 protected StateBag ViewState {
142                         get { return viewState; }
143                 } 
144                 
145                 protected virtual void LoadViewState (object savedState)
146                 {
147                         viewState.LoadViewState (savedState);
148                 }
149                 
150                 protected virtual object SaveViewState ()
151                 {
152                         return viewState.SaveViewState ();
153                 }
154                 
155                 protected virtual void TrackViewState ()
156                 {
157                         viewState.TrackViewState ();
158                 }
159                 
160                 protected virtual bool IsTrackingViewState
161                 {
162                         get { return viewState.IsTrackingViewState; }
163                 }
164         
165                 void IStateManager.LoadViewState (object savedState)
166                 {
167                         LoadViewState (savedState);
168                 }
169                 
170                 object IStateManager.SaveViewState ()
171                 {
172                         return SaveViewState ();
173                 }
174                 
175                 void IStateManager.TrackViewState ()
176                 {
177                         TrackViewState ();
178                 }
179                 
180                 bool IStateManager.IsTrackingViewState
181                 {
182                         get { return IsTrackingViewState; }
183                 }
184                 
185                 public override string ToString ()
186                 {
187                         return GetType().Name;
188                 }
189                 
190                 internal void SetDirty ()
191                 {
192                         viewState.SetDirty (true);
193                 }
194         
195                 public abstract string GetCoordinates ();
196                 
197                 protected internal abstract string MarkupName { get; }
198         }
199 }
200
201 #endif