2003-08-13 Gaurav Vaish <gvaish_mono AT lycos.com>
[mono.git] / mcs / class / System.Web.Mobile / System.Web.UI.MobileControls.Adapters / HtmlControlAdapter.cs
1 /**
2  * Project   : Mono
3  * Namespace : System.Web.UI.MobileControls.Adapters
4  * Class     : HtmlControlAdapter
5  * Author    : Gaurav Vaish
6  *
7  * Copyright : 2003 with Gaurav Vaish, and with
8  *             Ximian Inc
9  */
10
11 using System;
12 using System.Web.Mobile;
13
14 namespace System.Web.UI.MobileControls.Adapters
15 {
16         public class HtmlControlAdapter : ControlAdapter
17         {
18                 protected static readonly int NotSecondaryUI = -1;
19
20                 [MonoTODO("Whould_like_to_keep_it_FFFFFFFF")]
21                 internal  const int NotSecondaryUIInitial = 0x7FFFFFFF;
22
23                 private static string[] multimediaAttrs = {
24                         "src",
25                         "soundstart",
26                         "loop",
27                         "volume",
28                         "vibration",
29                         "viblength"
30                 };
31
32                 public HtmlControlAdapter()
33                 {
34                 }
35
36                 protected HtmlFormAdapter FormAdapter
37                 {
38                         get
39                         {
40                                 return (HtmlFormAdapter)Control.Form.Adapter;
41                         }
42                 }
43
44                 protected HtmlPageAdapter PageAdapter
45                 {
46                         get
47                         {
48                                 return (HtmlPageAdapter)Page.Adapter;
49                         }
50                 }
51
52                 [MonoTODO]
53                 protected int SecondaryUIMode
54                 {
55                         get
56                         {
57                                 throw new NotImplementedException();
58                         }
59                         set
60                         {
61                                 throw new NotImplementedException();
62                         }
63                 }
64
65                 public virtual bool RequiresFormTag
66                 {
67                         get
68                         {
69                                 return false;
70                         }
71                 }
72
73                 [MonoTODO]
74                 private void AddAttributePrivate(HtmlMobileTextWriter writer,
75                                                  string attribute)
76                 {
77                         //string val = Control.GetAttribute(attribute);
78                         string val = String.Empty;
79                         if(val != null && val.Length > 0)
80                         {
81                                 writer.WriteAttribute(attribute, val);
82                         }
83                 }
84
85                 protected virtual void AddAccesskey(HtmlMobileTextWriter writer)
86                 {
87                         if(Device.SupportsAccesskeyAttribute)
88                         {
89                                 AddAttributePrivate(writer, "accesskey");
90                         }
91                 }
92
93                 protected virtual void AddAttributes(HtmlMobileTextWriter writer)
94                 {
95                 }
96
97                 protected virtual void AddJPhoneMultiMediaAttributes(
98                                          HtmlMobileTextWriter writer)
99                 {
100                         if(Device.SupportsJPhoneMultiMediaAttributes)
101                         {
102                                 foreach(string cAttrib in multimediaAttrs)
103                                 {
104                                         AddAttributePrivate(writer, cAttrib);
105                                 }
106                         }
107                 }
108
109                 protected void ExitSecondaryUIMode()
110                 {
111                         this.SecondaryUIMode = NotSecondaryUI;
112                 }
113
114                 public override void LoadAdapterState(object state)
115                 {
116                         if(state != null && state is int)
117                         {
118                                 this.SecondaryUIMode = (int)state;
119                         }
120                 }
121                 
122                 public virtual void Render(HtmlMobileTextWriter writer)
123                 {
124                         base.RenderChildren(writer);
125                 }
126                 
127                 public override void Render(HtmlTextWriter writer)
128                 {
129                         if(writer is HtmlMobileTextWriter)
130                         {
131                                 Render((HtmlMobileTextWriter)writer);
132                         }
133                 }
134                 
135                 protected virtual void RenderAsHiddenInputField(HtmlMobileTextWriter writer)
136                 {
137                 }
138                 
139                 [MonoTODO]
140                 protected void RenderBeginLink(HtmlMobileTextWriter writer,
141                                                string target)
142                 {
143                         bool isHTTP = false;
144                         if(PageAdapter.PersistCookielessData)
145                         {
146                                 if(target.StartsWith("http:") || target.StartsWith("https:"))
147                                 {
148                                         throw new NotImplementedException();
149                                 }
150                         }
151                 }
152
153                 [MonoTODO]
154                 protected void RenderEndLink(HtmlMobileTextWriter writer,
155                                               string target)
156                 {
157                         throw new NotImplementedException();
158                 }
159                 
160                 [MonoTODO]
161                 protected void RenderPostBackEventAsAnchor(HtmlMobileTextWriter writer,
162                                              string argument, string linkText)
163                 {
164                         throw new NotImplementedException();
165                 }
166         }
167 }