[bcl] Remove NET_2_0 defines from the class libs. This has been done using: unifdef...
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / SubMenuStyle.cs
1 //
2 // System.Web.UI.WebControls.SubMenuStyle.cs
3 //
4 // Authors:
5 //      Lluis Sanchez Gual (lluis@novell.com)
6 //
7 // (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
29 //
30
31
32 using System;
33 using System.Web.UI;
34 using System.ComponentModel;
35
36 namespace System.Web.UI.WebControls
37 {
38         public class SubMenuStyle: Style, ICustomTypeDescriptor
39         {
40                 const string HORZ_PADD = "HorizontalPadding";
41                 const string VERT_PADD = "VerticalPadding";
42                 
43                 public SubMenuStyle ()
44                 {
45                 }
46                 
47                 public SubMenuStyle (StateBag bag): base (bag)
48                 {
49                 }
50                 
51                 bool IsSet (string v)
52                 {
53                         return ViewState [v] != null;
54                 }
55                 
56                 [DefaultValue (typeof(Unit), "")]
57                 [NotifyParentProperty (true)]
58                 public Unit HorizontalPadding {
59                         get {
60                                 if(IsSet(HORZ_PADD))
61                                         return (Unit)(ViewState[HORZ_PADD]);
62                                 return Unit.Empty;
63                         }
64                         set {
65                                 ViewState[HORZ_PADD] = value;
66                         }
67                 }
68
69                 [DefaultValue (typeof(Unit), "")]
70                 [NotifyParentProperty (true)]
71                 public Unit VerticalPadding {
72                         get {
73                                 if(IsSet(VERT_PADD))
74                                         return (Unit)(ViewState[VERT_PADD]);
75                                 return Unit.Empty;
76                         }
77                         set {
78                                 ViewState[VERT_PADD] = value;
79                         }
80                 }
81
82                 public override void CopyFrom (Style s)
83                 {
84                         if (s == null || s.IsEmpty)
85                                 return;
86
87                         base.CopyFrom (s);
88                         SubMenuStyle from = s as SubMenuStyle;
89                         if (from == null)
90                                 return;
91
92                         if (from.IsSet (HORZ_PADD))
93                                 HorizontalPadding = from.HorizontalPadding;
94
95                         if (from.IsSet (VERT_PADD))
96                                 VerticalPadding = from.VerticalPadding;
97                 }
98                 
99                 public override void MergeWith(Style s)
100                 {
101                         if(s != null && !s.IsEmpty)
102                         {
103                                 if (IsEmpty) {
104                                         CopyFrom (s);
105                                         return;
106                                 }
107                                 base.MergeWith(s);
108
109                                 SubMenuStyle with = s as SubMenuStyle;
110                                 if (with == null) return;
111                                 
112                                 if (with.IsSet(HORZ_PADD) && !IsSet(HORZ_PADD)) {
113                                         HorizontalPadding = with.HorizontalPadding;
114                                 }
115                                 if (with.IsSet(VERT_PADD) && !IsSet(VERT_PADD)) {
116                                         VerticalPadding = with.VerticalPadding;
117                                 }
118                         }
119                 }
120
121                 public override void Reset()
122                 {
123                         if(IsSet(HORZ_PADD))
124                                 ViewState.Remove("HorizontalPadding");
125                         if(IsSet(VERT_PADD))
126                                 ViewState.Remove("VerticalPadding");
127                         base.Reset();
128                 }
129                 
130                 protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
131                 {
132                         base.FillStyleAttributes (attributes, urlResolver);
133                         if (IsSet (HORZ_PADD)) {
134                                 attributes.Add (HtmlTextWriterStyle.PaddingLeft, HorizontalPadding.ToString ());
135                                 attributes.Add (HtmlTextWriterStyle.PaddingRight, HorizontalPadding.ToString ());
136                         }
137                         if (IsSet (VERT_PADD)) {
138                                 attributes.Add (HtmlTextWriterStyle.PaddingTop, VerticalPadding.ToString ());
139                                 attributes.Add (HtmlTextWriterStyle.PaddingBottom, VerticalPadding.ToString ());
140                         }
141                 }
142
143                 [MonoTODO ("Not implemented")]
144                 System.ComponentModel.AttributeCollection ICustomTypeDescriptor.GetAttributes ()
145                 {
146                         throw new NotImplementedException ();
147                 }
148
149                 [MonoTODO("Not implemented")]
150                 string ICustomTypeDescriptor.GetClassName ()
151                 {
152                         throw new NotImplementedException ();
153                 }
154
155                 [MonoTODO("Not implemented")]
156                 string ICustomTypeDescriptor.GetComponentName ()
157                 {
158                         throw new NotImplementedException ();
159                 }
160
161                 [MonoTODO("Not implemented")]
162                 TypeConverter ICustomTypeDescriptor.GetConverter ()
163                 {
164                         throw new NotImplementedException ();
165                 }
166
167                 [MonoTODO("Not implemented")]
168                 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent ()
169                 {
170                         throw new NotImplementedException ();
171                 }
172
173                 [MonoTODO("Not implemented")]
174                 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty ()
175                 {
176                         throw new NotImplementedException ();
177                 }
178
179                 [MonoTODO("Not implemented")]
180                 object ICustomTypeDescriptor.GetEditor (Type editorBaseType)
181                 {
182                         throw new NotImplementedException ();
183                 }
184
185                 [MonoTODO("Not implemented")]
186                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents ()
187                 {
188                         throw new NotImplementedException ();
189                 }
190
191                 [MonoTODO("Not implemented")]
192                 EventDescriptorCollection ICustomTypeDescriptor.GetEvents (Attribute [] arr)
193                 {
194                         throw new NotImplementedException ();
195                 }
196
197                 [MonoTODO("Not implemented")]
198                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties ()
199                 {
200                         throw new NotImplementedException ();
201                 }
202
203                 [MonoTODO("Not implemented")]
204                 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties (Attribute [] arr)
205                 {
206                         throw new NotImplementedException ();
207                 }
208
209                 [MonoTODO("Not implemented")]
210                 object ICustomTypeDescriptor.GetPropertyOwner (PropertyDescriptor pd)
211                 {
212                         throw new NotImplementedException ();
213                 }
214         }
215 }
216