2005-09-27 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / class / Microsoft.Web.Atlas / Microsoft.Web.UI / ListView.cs
1 //
2 // Microsoft.Web.UI.ListView
3 //
4 // Author:
5 //   Chris Toshok (toshok@ximian.com)
6 //
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 #if NET_2_0
31
32 using System;
33 using System.ComponentModel;
34 using System.Web.UI;
35 using Microsoft.Web;
36
37 namespace Microsoft.Web.UI
38 {
39         public class ListView : ScriptControl
40         {
41                 ITemplate emptyTemplate;
42                 ITemplate layoutTemplate;
43                 
44                 public ListView ()
45                 {
46                 }
47
48                 protected override void AddAttributesToElement (ScriptTextWriter writer)
49                 {
50                         base.AddAttributesToElement (writer);
51                 }
52
53                 protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
54                 {
55                         base.InitializeTypeDescriptor (typeDescriptor);
56
57                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("alternatingItemCssClass", ScriptType.String, false, "AlternatingItemCssClass"));
58                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("data", ScriptType.Object, false, ""));
59                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("length", ScriptType.Number, true, ""));
60                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("layoutTemplate", ScriptType.Object, false, ""));
61                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemCssClass", ScriptType.String, false, "ItemCssClass"));
62                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemTemplateParentElementId", ScriptType.String, false, ""));
63                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("separatorTemplate", ScriptType.Object, false, ""));
64                         typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("emptyTemplate", ScriptType.Object, false, ""));
65                 }
66
67                 protected override void OnPreRender (EventArgs e)
68                 {
69                         base.OnPreRender (e);
70
71                         ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
72                         mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
73                         mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
74                 }
75
76                 protected override void Render (HtmlTextWriter writer)
77                 {
78                 }
79
80                 protected override void RenderScriptTagContents (ScriptTextWriter writer)
81                 {
82                         base.RenderScriptTagContents (writer);
83
84                         writer.WriteStartElement ("layoutTemplate");
85                         writer.WriteStartElement ("template");
86                         writer.WriteAttributeString ("layoutElement", ID + "_layoutTemplate"); // XXX ?
87                         writer.WriteEndElement (); // template
88                         writer.WriteEndElement (); // layoutTemplate
89
90                         writer.WriteStartElement ("itemTemplate");
91                         writer.WriteEndElement (); // itemTemplate
92                 }
93
94                 public string AlternatingItemCssClass {
95                         get {
96                                 object o = ViewState["AlternatingItemCssClass"];
97                                 if (o == null)
98                                         return "";
99                                 return (string)o;
100                         }
101                         set {
102                                 ViewState["AlternatingItemCssClass"] = value;
103                         }
104                 }
105
106                 public ITemplate EmptyTemplate {
107                         get {
108                                 return emptyTemplate;
109                         }
110                         set {
111                                 emptyTemplate = value;
112                         }
113                 }
114
115                 public string ItemCssClass {
116                         get {
117                                 object o = ViewState["ItemCssClass"];
118                                 if (o == null)
119                                         return "";
120                                 return (string)o;
121                         }
122                         set {
123                                 ViewState["ItemCssClass"] = value;
124                         }
125                 }
126
127                 public string ItemTemplateControlID {
128                         get {
129                                 object o = ViewState["ItemTemplateControlID"];
130                                 if (o == null)
131                                         return "";
132                                 return (string)o;
133                         }
134                         set {
135                                 ViewState["ItemTemplateControlID"] = value;
136                         }
137                 }
138
139                 public ITemplate LayoutTemplate {
140                         get {
141                                 return layoutTemplate;
142                         }
143                         set {
144                                 layoutTemplate = value;
145                         }
146                 }
147
148                 public string SeparatorTemplateControlID {
149                         get {
150                                 object o = ViewState["SeparatorTemplateControlID"];
151                                 if (o == null)
152                                         return "";
153                                 return (string)o;
154                         }
155                         set {
156                                 ViewState["SeparatorTemplateControlID"] = value;
157                         }
158                 }
159
160                 public override string TagName {
161                         get {
162                                 return "listView";
163                         }
164                 }
165         }
166
167 }
168
169 #endif