HtmlControlAdapter.cs 3.8 KB

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