2 // System.Web.UI.WebControls.TreeNodeStyle.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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)
36 namespace System.Web.UI.WebControls
38 public sealed class TreeNodeStyle: Style
40 private static int CHILD_PADD = (0x01 << 16);
41 private static int HORZ_PADD = (0x01 << 17);
42 private static int IMG_URL = (0x01 << 18);
43 private static int SPACING = (0x01 << 19);
44 private static int VERT_PADD = (0x01 << 20);
46 public string ImageUrl {
49 return (string)(ViewState["ImageUrl"]);
54 throw new ArgumentNullException("value");
55 ViewState["ImageUrl"] = value;
60 public int ChildNodesPadding {
63 return (int)(ViewState["ChildNodesPadding"]);
67 ViewState["ChildNodesPadding"] = value;
72 public int HorizontalPadding {
75 return (int)(ViewState["HorizontalPadding"]);
79 ViewState["HorizontalPadding"] = value;
84 public int VerticalPadding {
87 return (int)(ViewState["VerticalPadding"]);
91 ViewState["VerticalPadding"] = value;
96 public int NodeSpacing {
99 return (int)(ViewState["NodeSpacing"]);
103 ViewState["NodeSpacing"] = value;
108 protected internal override bool IsEmpty {
109 get { return base.IsEmpty; }
112 public override void CopyFrom (Style s)
114 if (s == null || s.IsEmpty)
118 TreeNodeStyle from = s as TreeNodeStyle;
122 if (from.IsSet (CHILD_PADD))
123 ChildNodesPadding = from.ChildNodesPadding;
125 if (from.IsSet (HORZ_PADD))
126 HorizontalPadding = from.HorizontalPadding;
128 if (from.IsSet (IMG_URL))
129 ImageUrl = from.ImageUrl;
131 if (from.IsSet (SPACING))
132 NodeSpacing = from.NodeSpacing;
134 if (from.IsSet (VERT_PADD))
135 VerticalPadding = from.VerticalPadding;
138 public override void MergeWith(Style s)
140 if(s != null && !s.IsEmpty)
148 TreeNodeStyle with = s as TreeNodeStyle;
149 if (with == null) return;
151 if (with.IsSet(CHILD_PADD) && !IsSet(CHILD_PADD)) {
152 ChildNodesPadding = with.ChildNodesPadding;
154 if (with.IsSet(HORZ_PADD) && !IsSet(HORZ_PADD)) {
155 HorizontalPadding = with.HorizontalPadding;
157 if (with.IsSet(IMG_URL) && !IsSet(IMG_URL)) {
158 ImageUrl = with.ImageUrl;
160 if (with.IsSet(SPACING) && !IsSet(SPACING)) {
161 NodeSpacing = with.NodeSpacing;
163 if (with.IsSet(VERT_PADD) && !IsSet(VERT_PADD)) {
164 VerticalPadding = with.VerticalPadding;
169 public override void Reset()
171 if(IsSet(CHILD_PADD))
172 ViewState.Remove("ChildNodesPadding");
174 ViewState.Remove("HorizontalPadding");
176 ViewState.Remove("ImageUrl");
178 ViewState.Remove("NodeSpacing");
180 ViewState.Remove("VerticalPadding");