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