Use UNIX line endings consistently
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / PanelStyle.cs
1 //
2 // System.Web.UI.WebControls.MenuItemStyle.cs
3 //
4 // Authors:
5 //      Igor Zelmanovich (igorz@mainsoft.com)
6 //
7 // (C) 2007 Mainsoft, Inc (http://www.mainsoft.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 #if NET_2_0
32
33 using System;
34 using System.Web.UI;
35 using System.ComponentModel;
36
37 namespace System.Web.UI.WebControls
38 {
39         public class PanelStyle : Style
40         {
41                 [Flags]
42                 enum PanelStyles
43                 {
44                         BackImageUrl = 0x00010000,
45                         Direction = 0x00020000,
46                         HorizontalAlign = 0x00040000,
47                         ScrollBars = 0x00080000,
48                         Wrap = 0x00100000,
49                 }
50
51                 public PanelStyle (StateBag bag)
52                         : base (bag)
53                 {
54                 }
55
56                 public virtual string BackImageUrl {
57                         get {
58                                 if (!CheckBit ((int) PanelStyles.BackImageUrl))
59                                         return String.Empty;
60
61                                 return ViewState.GetString ("BackImageUrl", String.Empty);
62                         }
63
64                         set {
65                                 ViewState ["BackImageUrl"] = value;
66                                 SetBit ((int) PanelStyles.BackImageUrl);
67                         }
68                 }
69
70                 public virtual ContentDirection Direction {
71                         get {
72                                 if (!CheckBit ((int) PanelStyles.Direction))
73                                         return ContentDirection.NotSet;
74
75                                 return (ContentDirection) ViewState ["Direction"];
76                         }
77                         set {
78                                 ViewState ["Direction"] = value;
79                                 SetBit ((int) PanelStyles.Direction);
80                         }
81                 }
82
83                 public virtual HorizontalAlign HorizontalAlign {
84                         get {
85                                 if (!CheckBit ((int) PanelStyles.HorizontalAlign))
86                                         return HorizontalAlign.NotSet;
87
88                                 return (HorizontalAlign) ViewState ["HorizontalAlign"];
89                         }
90                         set {
91                                 ViewState ["HorizontalAlign"] = value;
92                                 SetBit ((int) PanelStyles.HorizontalAlign);
93                         }
94                 }
95
96                 public virtual ScrollBars ScrollBars {
97                         get {
98                                 if (!CheckBit ((int) PanelStyles.ScrollBars))
99                                         return ScrollBars.None;
100
101                                 return (ScrollBars) ViewState ["ScrollBars"];
102                         }
103                         set {
104                                 ViewState ["ScrollBars"] = value;
105                                 SetBit ((int) PanelStyles.ScrollBars);
106                         }
107                 }
108
109                 public virtual bool Wrap {
110                         get {
111                                 if (!CheckBit ((int) PanelStyles.Wrap))
112                                         return true;
113
114                                 return (bool) ViewState ["Wrap"];
115                         }
116                         set {
117                                 ViewState ["Wrap"] = value;
118                                 SetBit ((int) PanelStyles.Wrap);
119                         }
120                 }
121
122                 public override void CopyFrom (Style s)
123                 {
124                         if ((s == null) || s.IsEmpty)
125                                 return;
126
127                         base.CopyFrom (s);
128
129                         PanelStyle ps = s as PanelStyle;
130                         if (ps == null)
131                                 return;
132
133                         if (s.CheckBit ((int) PanelStyles.BackImageUrl)) {
134                                 this.BackImageUrl = ps.BackImageUrl;
135                         }
136                         if (s.CheckBit ((int) PanelStyles.Direction)) {
137                                 this.Direction = ps.Direction;
138                         }
139                         if (s.CheckBit ((int) PanelStyles.HorizontalAlign)) {
140                                 this.HorizontalAlign = ps.HorizontalAlign;
141                         }
142                         if (s.CheckBit ((int) PanelStyles.ScrollBars)) {
143                                 this.ScrollBars = ps.ScrollBars;
144                         }
145                         if (s.CheckBit ((int) PanelStyles.Wrap)) {
146                                 this.Wrap = ps.Wrap;
147                         }
148                 }
149
150                 public override void MergeWith (Style s)
151                 {
152                         if ((s == null) || (s.IsEmpty))
153                                 return;
154
155                         base.MergeWith (s);
156
157                         PanelStyle ps = s as PanelStyle;
158                         if (ps == null)
159                                 return;
160
161                         if (!CheckBit ((int) PanelStyles.BackImageUrl) && s.CheckBit ((int) PanelStyles.BackImageUrl)) {
162                                 this.BackImageUrl = ps.BackImageUrl;
163                         }
164                         if (!CheckBit ((int) PanelStyles.Direction) && s.CheckBit ((int) PanelStyles.Direction)) {
165                                 this.Direction = ps.Direction;
166                         }
167                         if (!CheckBit ((int) PanelStyles.HorizontalAlign) && s.CheckBit ((int) PanelStyles.HorizontalAlign)) {
168                                 this.HorizontalAlign = ps.HorizontalAlign;
169                         }
170                         if (!CheckBit ((int) PanelStyles.ScrollBars) && s.CheckBit ((int) PanelStyles.ScrollBars)) {
171                                 this.ScrollBars = ps.ScrollBars;
172                         }
173                         if (!CheckBit ((int) PanelStyles.Wrap) && s.CheckBit ((int) PanelStyles.Wrap)) {
174                                 this.Wrap = ps.Wrap;
175                         }
176                 }
177
178                 public override void Reset ()
179                 {
180                         base.Reset ();
181
182                         ViewState.Remove ("BackImageUrl");
183                         ViewState.Remove ("Direction");
184                         ViewState.Remove ("HorizontalAlign");
185                         ViewState.Remove ("ScrollBars");
186                         ViewState.Remove ("Wrap");
187                 }
188         }
189 }
190
191 #endif