2008-03-13 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / PanelStyle.cs
1 //\r
2 // System.Web.UI.WebControls.MenuItemStyle.cs\r
3 //\r
4 // Authors:\r
5 //      Igor Zelmanovich (igorz@mainsoft.com)\r
6 //\r
7 // (C) 2007 Mainsoft, Inc (http://www.mainsoft.com)\r
8 //\r
9 // Permission is hereby granted, free of charge, to any person obtaining\r
10 // a copy of this software and associated documentation files (the\r
11 // "Software"), to deal in the Software without restriction, including\r
12 // without limitation the rights to use, copy, modify, merge, publish,\r
13 // distribute, sublicense, and/or sell copies of the Software, and to\r
14 // permit persons to whom the Software is furnished to do so, subject to\r
15 // the following conditions:\r
16 // \r
17 // The above copyright notice and this permission notice shall be\r
18 // included in all copies or substantial portions of the Software.\r
19 // \r
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
27 //\r
28 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
29 //\r
30 \r
31 #if NET_2_0\r
32 \r
33 using System;\r
34 using System.Web.UI;\r
35 using System.ComponentModel;\r
36 \r
37 namespace System.Web.UI.WebControls\r
38 {\r
39         public class PanelStyle : Style\r
40         {\r
41                 [Flags]\r
42                 enum PanelStyles\r
43                 {\r
44                         BackImageUrl = 0x00010000,\r
45                         Direction = 0x00020000,\r
46                         HorizontalAlign = 0x00040000,\r
47                         ScrollBars = 0x00080000,\r
48                         Wrap = 0x00100000,\r
49                 }\r
50 \r
51                 public PanelStyle (StateBag bag)\r
52                         : base (bag)\r
53                 {\r
54                 }\r
55 \r
56                 public virtual string BackImageUrl {\r
57                         get {\r
58                                 if (!CheckBit ((int) PanelStyles.BackImageUrl))\r
59                                         return String.Empty;\r
60 \r
61                                 return ViewState.GetString ("BackImageUrl", String.Empty);\r
62                         }\r
63 \r
64                         set {\r
65                                 ViewState ["BackImageUrl"] = value;\r
66                                 SetBit ((int) PanelStyles.BackImageUrl);\r
67                         }\r
68                 }\r
69 \r
70                 public virtual ContentDirection Direction {\r
71                         get {\r
72                                 if (!CheckBit ((int) PanelStyles.Direction))\r
73                                         return ContentDirection.NotSet;\r
74 \r
75                                 return (ContentDirection) ViewState ["Direction"];\r
76                         }\r
77                         set {\r
78                                 ViewState ["Direction"] = value;\r
79                                 SetBit ((int) PanelStyles.Direction);\r
80                         }\r
81                 }\r
82 \r
83                 public virtual HorizontalAlign HorizontalAlign {\r
84                         get {\r
85                                 if (!CheckBit ((int) PanelStyles.HorizontalAlign))\r
86                                         return HorizontalAlign.NotSet;\r
87 \r
88                                 return (HorizontalAlign) ViewState ["HorizontalAlign"];\r
89                         }\r
90                         set {\r
91                                 ViewState ["HorizontalAlign"] = value;\r
92                                 SetBit ((int) PanelStyles.HorizontalAlign);\r
93                         }\r
94                 }\r
95 \r
96                 public virtual ScrollBars ScrollBars {\r
97                         get {\r
98                                 if (!CheckBit ((int) PanelStyles.ScrollBars))\r
99                                         return ScrollBars.None;\r
100 \r
101                                 return (ScrollBars) ViewState ["ScrollBars"];\r
102                         }\r
103                         set {\r
104                                 ViewState ["ScrollBars"] = value;\r
105                                 SetBit ((int) PanelStyles.ScrollBars);\r
106                         }\r
107                 }\r
108 \r
109                 public virtual bool Wrap {\r
110                         get {\r
111                                 if (!CheckBit ((int) PanelStyles.Wrap))\r
112                                         return true;\r
113 \r
114                                 return (bool) ViewState ["Wrap"];\r
115                         }\r
116                         set {\r
117                                 ViewState ["Wrap"] = value;\r
118                                 SetBit ((int) PanelStyles.Wrap);\r
119                         }\r
120                 }\r
121 \r
122                 public override void CopyFrom (Style s)\r
123                 {\r
124                         if ((s == null) || s.IsEmpty)\r
125                                 return;\r
126 \r
127                         base.CopyFrom (s);\r
128 \r
129                         PanelStyle ps = s as PanelStyle;\r
130                         if (ps == null)\r
131                                 return;\r
132 \r
133                         if (s.CheckBit ((int) PanelStyles.BackImageUrl)) {\r
134                                 this.BackImageUrl = ps.BackImageUrl;\r
135                         }\r
136                         if (s.CheckBit ((int) PanelStyles.Direction)) {\r
137                                 this.Direction = ps.Direction;\r
138                         }\r
139                         if (s.CheckBit ((int) PanelStyles.HorizontalAlign)) {\r
140                                 this.HorizontalAlign = ps.HorizontalAlign;\r
141                         }\r
142                         if (s.CheckBit ((int) PanelStyles.ScrollBars)) {\r
143                                 this.ScrollBars = ps.ScrollBars;\r
144                         }\r
145                         if (s.CheckBit ((int) PanelStyles.Wrap)) {\r
146                                 this.Wrap = ps.Wrap;\r
147                         }\r
148                 }\r
149 \r
150                 public override void MergeWith (Style s)\r
151                 {\r
152                         if ((s == null) || (s.IsEmpty))\r
153                                 return;\r
154 \r
155                         base.MergeWith (s);\r
156 \r
157                         PanelStyle ps = s as PanelStyle;\r
158                         if (ps == null)\r
159                                 return;\r
160 \r
161                         if (!CheckBit ((int) PanelStyles.BackImageUrl) && s.CheckBit ((int) PanelStyles.BackImageUrl)) {\r
162                                 this.BackImageUrl = ps.BackImageUrl;\r
163                         }\r
164                         if (!CheckBit ((int) PanelStyles.Direction) && s.CheckBit ((int) PanelStyles.Direction)) {\r
165                                 this.Direction = ps.Direction;\r
166                         }\r
167                         if (!CheckBit ((int) PanelStyles.HorizontalAlign) && s.CheckBit ((int) PanelStyles.HorizontalAlign)) {\r
168                                 this.HorizontalAlign = ps.HorizontalAlign;\r
169                         }\r
170                         if (!CheckBit ((int) PanelStyles.ScrollBars) && s.CheckBit ((int) PanelStyles.ScrollBars)) {\r
171                                 this.ScrollBars = ps.ScrollBars;\r
172                         }\r
173                         if (!CheckBit ((int) PanelStyles.Wrap) && s.CheckBit ((int) PanelStyles.Wrap)) {\r
174                                 this.Wrap = ps.Wrap;\r
175                         }\r
176                 }\r
177 \r
178                 public override void Reset ()\r
179                 {\r
180                         base.Reset ();\r
181 \r
182                         ViewState.Remove ("BackImageUrl");\r
183                         ViewState.Remove ("Direction");\r
184                         ViewState.Remove ("HorizontalAlign");\r
185                         ViewState.Remove ("ScrollBars");\r
186                         ViewState.Remove ("Wrap");\r
187                 }\r
188         }\r
189 }\r
190 \r
191 #endif\r