2010-03-02 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Web / System.Web.UI.WebControls / PanelStyle.cs
blob505105cc36fb1207ff5e0fa85bbd60bad89e3ec9
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.
28 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
31 #if NET_2_0
33 using System;
34 using System.Web.UI;
35 using System.ComponentModel;
37 namespace System.Web.UI.WebControls
39 public class PanelStyle : Style
41 [Flags]
42 enum PanelStyles
44 BackImageUrl = 0x00010000,
45 Direction = 0x00020000,
46 HorizontalAlign = 0x00040000,
47 ScrollBars = 0x00080000,
48 Wrap = 0x00100000,
51 public PanelStyle (StateBag bag)
52 : base (bag)
56 public virtual string BackImageUrl {
57 get {
58 if (!CheckBit ((int) PanelStyles.BackImageUrl))
59 return String.Empty;
61 return ViewState.GetString ("BackImageUrl", String.Empty);
64 set {
65 ViewState ["BackImageUrl"] = value;
66 SetBit ((int) PanelStyles.BackImageUrl);
70 public virtual ContentDirection Direction {
71 get {
72 if (!CheckBit ((int) PanelStyles.Direction))
73 return ContentDirection.NotSet;
75 return (ContentDirection) ViewState ["Direction"];
77 set {
78 ViewState ["Direction"] = value;
79 SetBit ((int) PanelStyles.Direction);
83 public virtual HorizontalAlign HorizontalAlign {
84 get {
85 if (!CheckBit ((int) PanelStyles.HorizontalAlign))
86 return HorizontalAlign.NotSet;
88 return (HorizontalAlign) ViewState ["HorizontalAlign"];
90 set {
91 ViewState ["HorizontalAlign"] = value;
92 SetBit ((int) PanelStyles.HorizontalAlign);
96 public virtual ScrollBars ScrollBars {
97 get {
98 if (!CheckBit ((int) PanelStyles.ScrollBars))
99 return ScrollBars.None;
101 return (ScrollBars) ViewState ["ScrollBars"];
103 set {
104 ViewState ["ScrollBars"] = value;
105 SetBit ((int) PanelStyles.ScrollBars);
109 public virtual bool Wrap {
110 get {
111 if (!CheckBit ((int) PanelStyles.Wrap))
112 return true;
114 return (bool) ViewState ["Wrap"];
116 set {
117 ViewState ["Wrap"] = value;
118 SetBit ((int) PanelStyles.Wrap);
122 public override void CopyFrom (Style s)
124 if ((s == null) || s.IsEmpty)
125 return;
127 base.CopyFrom (s);
129 PanelStyle ps = s as PanelStyle;
130 if (ps == null)
131 return;
133 if (s.CheckBit ((int) PanelStyles.BackImageUrl)) {
134 this.BackImageUrl = ps.BackImageUrl;
136 if (s.CheckBit ((int) PanelStyles.Direction)) {
137 this.Direction = ps.Direction;
139 if (s.CheckBit ((int) PanelStyles.HorizontalAlign)) {
140 this.HorizontalAlign = ps.HorizontalAlign;
142 if (s.CheckBit ((int) PanelStyles.ScrollBars)) {
143 this.ScrollBars = ps.ScrollBars;
145 if (s.CheckBit ((int) PanelStyles.Wrap)) {
146 this.Wrap = ps.Wrap;
150 public override void MergeWith (Style s)
152 if ((s == null) || (s.IsEmpty))
153 return;
155 base.MergeWith (s);
157 PanelStyle ps = s as PanelStyle;
158 if (ps == null)
159 return;
161 if (!CheckBit ((int) PanelStyles.BackImageUrl) && s.CheckBit ((int) PanelStyles.BackImageUrl)) {
162 this.BackImageUrl = ps.BackImageUrl;
164 if (!CheckBit ((int) PanelStyles.Direction) && s.CheckBit ((int) PanelStyles.Direction)) {
165 this.Direction = ps.Direction;
167 if (!CheckBit ((int) PanelStyles.HorizontalAlign) && s.CheckBit ((int) PanelStyles.HorizontalAlign)) {
168 this.HorizontalAlign = ps.HorizontalAlign;
170 if (!CheckBit ((int) PanelStyles.ScrollBars) && s.CheckBit ((int) PanelStyles.ScrollBars)) {
171 this.ScrollBars = ps.ScrollBars;
173 if (!CheckBit ((int) PanelStyles.Wrap) && s.CheckBit ((int) PanelStyles.Wrap)) {
174 this.Wrap = ps.Wrap;
178 public override void Reset ()
180 base.Reset ();
182 ViewState.Remove ("BackImageUrl");
183 ViewState.Remove ("Direction");
184 ViewState.Remove ("HorizontalAlign");
185 ViewState.Remove ("ScrollBars");
186 ViewState.Remove ("Wrap");
191 #endif