Style.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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
  24. * Class : Style
  25. * Author : Gaurav Vaish
  26. *
  27. * Copyright : 2003 with Gaurav Vaish, and with
  28. * Ximian Inc
  29. */
  30. using System.Drawing;
  31. using System.Web.UI;
  32. using System.Web.Mobile;
  33. namespace System.Web.UI.MobileControls
  34. {
  35. public class Style : IParserAccessor, ITemplateable, IStateManager,
  36. ICloneable
  37. {
  38. private BooleanOption bold = BooleanOption.NotSet;
  39. private BooleanOption italic = BooleanOption.NotSet;
  40. private Alignment alignment = Alignment.NotSet;
  41. private Color backColor = Color.Empty;
  42. private Color foreColor = Color.Empty;
  43. private string fontName = String.Empty;
  44. private FontSize fontSize = FontSize.NotSet;
  45. private Wrapping wrapping = Wrapping.NotSet;
  46. private bool marked = false;
  47. private bool checkedStyleRef = false;
  48. private MobileControl control = null;
  49. private DeviceSpecific deviceSpecific;
  50. private FontInfo font;
  51. private Style referredStyle;
  52. private StateBag state;
  53. public Style()
  54. {
  55. }
  56. public object this[object key]
  57. {
  58. get
  59. {
  60. throw new NotImplementedException();
  61. }
  62. set
  63. {
  64. throw new NotImplementedException();
  65. }
  66. }
  67. public object this[object key, bool inherit]
  68. {
  69. get
  70. {
  71. throw new NotImplementedException();
  72. }
  73. }
  74. public Alignment Alignment
  75. {
  76. get
  77. {
  78. return this.alignment;
  79. }
  80. set
  81. {
  82. this.alignment = value;
  83. }
  84. }
  85. public Color BackColor
  86. {
  87. get
  88. {
  89. return this.backColor;
  90. }
  91. set
  92. {
  93. this.backColor = value;
  94. }
  95. }
  96. public DeviceSpecific DeviceSpecific
  97. {
  98. get
  99. {
  100. return deviceSpecific;
  101. }
  102. set
  103. {
  104. deviceSpecific = value;
  105. }
  106. }
  107. public FontInfo Font
  108. {
  109. get
  110. {
  111. if(font == null)
  112. {
  113. font = new FontInfo(this);
  114. }
  115. return font;
  116. }
  117. }
  118. public Color ForeColor
  119. {
  120. get
  121. {
  122. return this.foreColor;
  123. }
  124. set
  125. {
  126. this.foreColor = value;
  127. }
  128. }
  129. public bool IsTemlpated
  130. {
  131. get
  132. {
  133. if(this.deviceSpecific != null)
  134. {
  135. return deviceSpecific.HasTemplates;
  136. } else if(ReferredStyle != null)
  137. {
  138. return ReferredStyle.IsTemlpated;
  139. }
  140. return false;
  141. }
  142. }
  143. internal Style ReferredStyle
  144. {
  145. get
  146. {
  147. throw new NotImplementedException();
  148. }
  149. }
  150. internal BooleanOption Bold
  151. {
  152. get
  153. {
  154. return this.bold;
  155. }
  156. set
  157. {
  158. this.bold = value;
  159. }
  160. }
  161. internal BooleanOption Italic
  162. {
  163. get
  164. {
  165. return this.italic;
  166. }
  167. set
  168. {
  169. this.italic = value;
  170. }
  171. }
  172. internal string FontName
  173. {
  174. get
  175. {
  176. return this.fontName;
  177. }
  178. set
  179. {
  180. this.fontName = value;
  181. }
  182. }
  183. internal FontSize FontSize
  184. {
  185. get
  186. {
  187. return this.fontSize;
  188. }
  189. set
  190. {
  191. this.fontSize = value;
  192. }
  193. }
  194. public MobileControl Control
  195. {
  196. get
  197. {
  198. return this.control;
  199. }
  200. set
  201. {
  202. this.control = value;
  203. }
  204. }
  205. protected internal StateBag State
  206. {
  207. get
  208. {
  209. if(this.state == null)
  210. {
  211. this.state = new StateBag();
  212. if(((IStateManager)this).IsTrackingViewState)
  213. {
  214. ((IStateManager)state).TrackViewState();
  215. }
  216. }
  217. return this.state;
  218. }
  219. }
  220. internal void Refresh()
  221. {
  222. this.referredStyle = null;
  223. this.checkedStyleRef = false;
  224. }
  225. void IParserAccessor.AddParsedSubObject(object obj)
  226. {
  227. if(obj is DeviceSpecific)
  228. {
  229. DeviceSpecific ds = (DeviceSpecific) obj;
  230. if(this.DeviceSpecific == null)
  231. this.DeviceSpecific = ds;
  232. else
  233. {
  234. throw new ArgumentException("MobileControl" +
  235. "_NoMultipleDeviceSpecifics");
  236. }
  237. }
  238. }
  239. void IStateManager.LoadViewState(object state)
  240. {
  241. if(state != null)
  242. {
  243. this.Refresh();
  244. ((IStateManager)State).LoadViewState(state);
  245. }
  246. }
  247. object IStateManager.SaveViewState()
  248. {
  249. if(this.state != null)
  250. {
  251. return ((IStateManager)state).SaveViewState();
  252. }
  253. return null;
  254. }
  255. bool IStateManager.IsTrackingViewState
  256. {
  257. get
  258. {
  259. return this.marked;
  260. }
  261. }
  262. void IStateManager.TrackViewState()
  263. {
  264. this.marked = true;
  265. }
  266. public object Clone()
  267. {
  268. throw new NotImplementedException();
  269. }
  270. [MonoTODO]
  271. public void ApplyTo(WebControls.WebControl control)
  272. {
  273. throw new NotImplementedException();
  274. }
  275. }
  276. }