HtmlControlAdapter.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. //
  2. // Permission is hereby granted, free of charge, to any person obtaining
  3. // a copy of this software and associated documentation files (the
  4. // "Software"), to deal in the Software without restriction, including
  5. // without limitation the rights to use, copy, modify, merge, publish,
  6. // distribute, sublicense, and/or sell copies of the Software, and to
  7. // permit persons to whom the Software is furnished to do so, subject to
  8. // the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be
  11. // included in all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. /**
  22. * Project : Mono
  23. * Namespace : System.Web.UI.MobileControls.Adapters
  24. * Class : HtmlControlAdapter
  25. * Author : Gaurav Vaish
  26. *
  27. * Copyright : 2003 with Gaurav Vaish, and with
  28. * Ximian Inc
  29. */
  30. using System;
  31. using System.Web.Mobile;
  32. namespace System.Web.UI.MobileControls.Adapters
  33. {
  34. public class HtmlControlAdapter : ControlAdapter
  35. {
  36. protected static readonly int NotSecondaryUI = -1;
  37. [MonoTODO("Whould_like_to_keep_it_FFFFFFFF")]
  38. internal const int NotSecondaryUIInitial = 0x7FFFFFFF;
  39. private static string[] multimediaAttrs = {
  40. "src",
  41. "soundstart",
  42. "loop",
  43. "volume",
  44. "vibration",
  45. "viblength"
  46. };
  47. public HtmlControlAdapter()
  48. {
  49. }
  50. protected HtmlFormAdapter FormAdapter
  51. {
  52. get
  53. {
  54. return (HtmlFormAdapter)Control.Form.Adapter;
  55. }
  56. }
  57. protected HtmlPageAdapter PageAdapter
  58. {
  59. get
  60. {
  61. return (HtmlPageAdapter)Page.Adapter;
  62. }
  63. }
  64. [MonoTODO]
  65. protected int SecondaryUIMode
  66. {
  67. get
  68. {
  69. throw new NotImplementedException();
  70. }
  71. set
  72. {
  73. throw new NotImplementedException();
  74. }
  75. }
  76. public virtual bool RequiresFormTag
  77. {
  78. get
  79. {
  80. return false;
  81. }
  82. }
  83. [MonoTODO]
  84. private void AddAttributePrivate(HtmlMobileTextWriter writer,
  85. string attribute)
  86. {
  87. //string val = Control.GetAttribute(attribute);
  88. string val = String.Empty;
  89. if(val != null && val.Length > 0)
  90. {
  91. writer.WriteAttribute(attribute, val);
  92. }
  93. }
  94. protected virtual void AddAccesskey(HtmlMobileTextWriter writer)
  95. {
  96. if(Device.SupportsAccesskeyAttribute)
  97. {
  98. AddAttributePrivate(writer, "accesskey");
  99. }
  100. }
  101. protected virtual void AddAttributes(HtmlMobileTextWriter writer)
  102. {
  103. }
  104. protected virtual void AddJPhoneMultiMediaAttributes(
  105. HtmlMobileTextWriter writer)
  106. {
  107. if(Device.SupportsJPhoneMultiMediaAttributes)
  108. {
  109. foreach(string cAttrib in multimediaAttrs)
  110. {
  111. AddAttributePrivate(writer, cAttrib);
  112. }
  113. }
  114. }
  115. protected void ExitSecondaryUIMode()
  116. {
  117. this.SecondaryUIMode = NotSecondaryUI;
  118. }
  119. public override void LoadAdapterState(object state)
  120. {
  121. if(state != null && state is int)
  122. {
  123. this.SecondaryUIMode = (int)state;
  124. }
  125. }
  126. public virtual void Render(HtmlMobileTextWriter writer)
  127. {
  128. base.RenderChildren(writer);
  129. }
  130. public override void Render(HtmlTextWriter writer)
  131. {
  132. if(writer is HtmlMobileTextWriter)
  133. {
  134. Render((HtmlMobileTextWriter)writer);
  135. }
  136. }
  137. protected virtual void RenderAsHiddenInputField(HtmlMobileTextWriter writer)
  138. {
  139. }
  140. [MonoTODO]
  141. protected void RenderBeginLink(HtmlMobileTextWriter writer,
  142. string target)
  143. {
  144. bool isHTTP = false;
  145. if(PageAdapter.PersistCookielessData)
  146. {
  147. if(target.StartsWith("http:") || target.StartsWith("https:"))
  148. {
  149. throw new NotImplementedException();
  150. }
  151. }
  152. }
  153. [MonoTODO]
  154. protected void RenderEndLink(HtmlMobileTextWriter writer)
  155. {
  156. throw new NotImplementedException();
  157. }
  158. [MonoTODO]
  159. protected void RenderPostBackEventAsAnchor(HtmlMobileTextWriter writer,
  160. string argument, string linkText)
  161. {
  162. throw new NotImplementedException();
  163. }
  164. protected void RenderPostBackEventAsAttribute(HtmlMobileTextWriter writer,
  165. string name, string value)
  166. {
  167. writer.Write(" " + name + "=\"");
  168. RenderPostBackEventReference(writer, value);
  169. writer.Write("\" ");
  170. }
  171. protected void RenderPostBackEventReference(HtmlMobileTextWriter writer,
  172. string argument)
  173. {
  174. PageAdapter.RenderPostBackEvent(writer, Control.UniqueID, argument);
  175. }
  176. public override object SaveAdapterState()
  177. {
  178. int uiMode = SecondaryUIMode;
  179. object retVal = null;
  180. if(uiMode != NotSecondaryUI)
  181. retVal = uiMode;
  182. return retVal;
  183. }
  184. }
  185. }