Style.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
  21. //
  22. // Authors:
  23. // Peter Dennis Bartok ([email protected])
  24. //
  25. //
  26. using System.ComponentModel;
  27. using System.Drawing;
  28. using System.Security.Permissions;
  29. namespace System.Web.UI.WebControls {
  30. // CAS
  31. [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  32. [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  33. // attributes
  34. // Not until we actually have StyleConverter
  35. // [TypeConverter(typeof(System.Web.UI.WebControls.StyleConverter))]
  36. [ToolboxItem("")]
  37. public class Style : System.ComponentModel.Component, System.Web.UI.IStateManager
  38. {
  39. internal const string BitStateKey = "_!SB";
  40. [Flags]
  41. internal enum Styles
  42. {
  43. BackColor = 0x00000008,
  44. BorderColor = 0x00000010,
  45. BorderStyle = 0x00000040,
  46. BorderWidth = 0x00000020,
  47. CssClass = 0x00000002,
  48. Font = 0x00000001,
  49. ForeColor = 0x00000004,
  50. Height = 0x00000080,
  51. Width = 0x00000100,
  52. FontAll = 0xFE00,
  53. FontBold = 0x800,
  54. FontItalic = 0x1000,
  55. FontNames = 0x200,
  56. FontOverline = 0x4000,
  57. FontSize = 0x400,
  58. FontStrikeout = 0x8000,
  59. FontUnderline = 0x2000
  60. }
  61. #region Fields
  62. int styles;
  63. int stylesTraked;
  64. internal StateBag viewstate;
  65. FontInfo fontinfo;
  66. bool tracking;
  67. bool _isSharedViewState;
  68. string registered_class;
  69. #endregion // Fields
  70. #region Public Constructors
  71. public Style()
  72. {
  73. viewstate = new StateBag ();
  74. GC.SuppressFinalize (this);
  75. }
  76. public Style(System.Web.UI.StateBag bag)
  77. {
  78. viewstate = bag;
  79. if (viewstate == null)
  80. viewstate = new StateBag ();
  81. _isSharedViewState = true;
  82. GC.SuppressFinalize (this);
  83. }
  84. #endregion // Public Constructors
  85. #region Public Instance Properties
  86. [DefaultValue(typeof (Color), "")]
  87. [NotifyParentProperty(true)]
  88. [TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
  89. [WebSysDescription ("")]
  90. [WebCategory ("Appearance")]
  91. public Color BackColor
  92. {
  93. get
  94. {
  95. if (!CheckBit ((int) Styles.BackColor))
  96. {
  97. return Color.Empty;
  98. }
  99. return (Color)viewstate["BackColor"];
  100. }
  101. set
  102. {
  103. viewstate["BackColor"] = value;
  104. SetBit ((int) Styles.BackColor);
  105. }
  106. }
  107. [DefaultValue(typeof (Color), "")]
  108. [NotifyParentProperty(true)]
  109. [TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
  110. [WebSysDescription ("")]
  111. [WebCategory ("Appearance")]
  112. public Color BorderColor
  113. {
  114. get
  115. {
  116. if (!CheckBit ((int) Styles.BorderColor))
  117. {
  118. return Color.Empty;
  119. }
  120. return (Color)viewstate["BorderColor"];
  121. }
  122. set
  123. {
  124. viewstate["BorderColor"] = value;
  125. SetBit ((int) Styles.BorderColor);
  126. }
  127. }
  128. [DefaultValue(BorderStyle.NotSet)]
  129. [NotifyParentProperty(true)]
  130. [WebSysDescription ("")]
  131. [WebCategory ("Appearance")]
  132. public BorderStyle BorderStyle
  133. {
  134. get
  135. {
  136. if (!CheckBit ((int) Styles.BorderStyle))
  137. {
  138. return BorderStyle.NotSet;
  139. }
  140. return (BorderStyle)viewstate["BorderStyle"];
  141. }
  142. set
  143. {
  144. if (value < BorderStyle.NotSet || value > BorderStyle.Outset)
  145. throw new ArgumentOutOfRangeException ("value", "The selected value is not one of the BorderStyle enumeration values.");
  146. viewstate["BorderStyle"] = value;
  147. SetBit ((int) Styles.BorderStyle);
  148. }
  149. }
  150. [DefaultValue(typeof (Unit), "")]
  151. [NotifyParentProperty(true)]
  152. [WebSysDescription ("")]
  153. [WebCategory ("Appearance")]
  154. public Unit BorderWidth
  155. {
  156. get
  157. {
  158. if (!CheckBit ((int) Styles.BorderWidth))
  159. {
  160. return Unit.Empty;
  161. }
  162. return (Unit)viewstate["BorderWidth"];
  163. }
  164. set
  165. {
  166. if (value.Value < 0)
  167. {
  168. throw new ArgumentOutOfRangeException("Value", value.Value, "BorderWidth must not be negative");
  169. }
  170. viewstate["BorderWidth"] = value;
  171. SetBit ((int) Styles.BorderWidth);
  172. }
  173. }
  174. //[TypeConverter ("System.Web.UI.WebControls.EmptyStringExpandableObjectConverter")]
  175. [CssClassProperty]
  176. [DefaultValue("")]
  177. [NotifyParentProperty(true)]
  178. [WebSysDescription ("")]
  179. [WebCategory ("Appearance")]
  180. public string CssClass {
  181. get {
  182. if (!CheckBit ((int) Styles.CssClass))
  183. {
  184. return String.Empty;
  185. }
  186. string ret = viewstate["CssClass"] as string;
  187. if (ret == null)
  188. return String.Empty;
  189. return ret;
  190. }
  191. set {
  192. viewstate["CssClass"] = value;
  193. SetBit ((int) Styles.CssClass);
  194. }
  195. }
  196. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  197. [NotifyParentProperty(true)]
  198. [WebSysDescription ("")]
  199. [WebCategory ("Appearance")]
  200. public FontInfo Font
  201. {
  202. get
  203. {
  204. if (fontinfo == null)
  205. {
  206. fontinfo = new FontInfo(this);
  207. }
  208. return fontinfo;
  209. }
  210. }
  211. [DefaultValue(typeof (Color), "")]
  212. [NotifyParentProperty(true)]
  213. [TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
  214. [WebSysDescription ("")]
  215. [WebCategory ("Appearance")]
  216. public Color ForeColor
  217. {
  218. get
  219. {
  220. if (!CheckBit ((int) Styles.ForeColor))
  221. {
  222. return Color.Empty;
  223. }
  224. return (Color)viewstate["ForeColor"];
  225. }
  226. set
  227. {
  228. viewstate["ForeColor"] = value;
  229. SetBit ((int) Styles.ForeColor);
  230. }
  231. }
  232. [DefaultValue(typeof (Unit), "")]
  233. [NotifyParentProperty(true)]
  234. [WebSysDescription ("")]
  235. [WebCategory ("Appearance")]
  236. public Unit Height
  237. {
  238. get
  239. {
  240. if (!CheckBit ((int) Styles.Height))
  241. {
  242. return Unit.Empty;
  243. }
  244. return (Unit)viewstate["Height"];
  245. }
  246. set
  247. {
  248. if (value.Value < 0)
  249. {
  250. throw new ArgumentOutOfRangeException("Value", value.Value, "Height must not be negative");
  251. }
  252. viewstate["Height"] = value;
  253. SetBit ((int) Styles.Height);
  254. }
  255. }
  256. [DefaultValue(typeof (Unit), "")]
  257. [NotifyParentProperty(true)]
  258. [WebSysDescription ("")]
  259. [WebCategory ("Appearance")]
  260. public Unit Width
  261. {
  262. get
  263. {
  264. if (!CheckBit ((int) Styles.Width))
  265. {
  266. return Unit.Empty;
  267. }
  268. return (Unit)viewstate["Width"];
  269. }
  270. set
  271. {
  272. if (value.Value < 0)
  273. {
  274. throw new ArgumentOutOfRangeException("Value", value.Value, "Width must not be negative");
  275. }
  276. viewstate["Width"] = value;
  277. SetBit ((int) Styles.Width);
  278. }
  279. }
  280. #endregion // Public Instance Properties
  281. #region Protected Instance Properties
  282. [Browsable (false)]
  283. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  284. public virtual bool IsEmpty
  285. {
  286. get
  287. {
  288. return (styles == 0 && RegisteredCssClass.Length == 0);
  289. }
  290. }
  291. protected bool IsTrackingViewState
  292. {
  293. get
  294. {
  295. return tracking;
  296. }
  297. }
  298. [Browsable(false)]
  299. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  300. protected internal StateBag ViewState
  301. {
  302. get
  303. {
  304. return viewstate;
  305. }
  306. }
  307. #endregion // Protected Instance Properties
  308. #region Internal Instance Properties
  309. internal bool AlwaysRenderTextDecoration
  310. {
  311. get
  312. {
  313. if (viewstate["AlwaysRenderTextDecoration"] == null)
  314. return false;
  315. return (bool)viewstate["AlwaysRenderTextDecoration"];
  316. }
  317. set
  318. {
  319. viewstate["AlwaysRenderTextDecoration"] = value;
  320. }
  321. }
  322. #endregion // Internal Instance Properties
  323. #region Public Instance Methods
  324. public void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
  325. {
  326. AddAttributesToRender(writer, null);
  327. }
  328. public virtual void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer, WebControl owner)
  329. {
  330. if (RegisteredCssClass.Length > 0) {
  331. string cssclass = CssClass;
  332. if (!String.IsNullOrEmpty (cssclass))
  333. writer.AddAttribute (HtmlTextWriterAttribute.Class, cssclass + " " + RegisteredCssClass);
  334. else
  335. writer.AddAttribute (HtmlTextWriterAttribute.Class, RegisteredCssClass);
  336. }
  337. else
  338. {
  339. string cssclass = CssClass;
  340. if (cssclass != null && cssclass.Length > 0)
  341. writer.AddAttribute (HtmlTextWriterAttribute.Class, cssclass);
  342. CssStyleCollection col = new CssStyleCollection ();
  343. FillStyleAttributes (col, owner);
  344. foreach (string key in col.Keys) {
  345. writer.AddStyleAttribute (key, col [key]);
  346. }
  347. }
  348. }
  349. protected virtual void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
  350. {
  351. Color color;
  352. BorderStyle bs;
  353. Unit u;
  354. if (CheckBit ((int) Styles.BackColor))
  355. {
  356. color = (Color)viewstate["BackColor"];
  357. if (!color.IsEmpty)
  358. attributes.Add (HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color));
  359. }
  360. if (CheckBit ((int) Styles.BorderColor))
  361. {
  362. color = (Color)viewstate["BorderColor"];
  363. if (!color.IsEmpty)
  364. attributes.Add (HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
  365. }
  366. bool have_width = false;
  367. if (CheckBit ((int) Styles.BorderWidth)) {
  368. u = (Unit) viewstate ["BorderWidth"];
  369. if (!u.IsEmpty) {
  370. if (u.Value > 0)
  371. have_width = true;
  372. attributes.Add (HtmlTextWriterStyle.BorderWidth, u.ToString ());
  373. }
  374. }
  375. if (CheckBit ((int) Styles.BorderStyle)) {
  376. bs = (BorderStyle) viewstate ["BorderStyle"];
  377. if (bs != BorderStyle.NotSet)
  378. attributes.Add (HtmlTextWriterStyle.BorderStyle, bs.ToString ());
  379. else if (have_width)
  380. attributes.Add (HtmlTextWriterStyle.BorderStyle, "solid");
  381. }
  382. else if (have_width) {
  383. attributes.Add (HtmlTextWriterStyle.BorderStyle, "solid");
  384. }
  385. if (CheckBit ((int) Styles.ForeColor))
  386. {
  387. color = (Color)viewstate["ForeColor"];
  388. if (!color.IsEmpty)
  389. attributes.Add (HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color));
  390. }
  391. if (CheckBit ((int) Styles.Height))
  392. {
  393. u = (Unit)viewstate["Height"];
  394. if (!u.IsEmpty)
  395. attributes.Add (HtmlTextWriterStyle.Height, u.ToString());
  396. }
  397. if (CheckBit ((int) Styles.Width))
  398. {
  399. u = (Unit)viewstate["Width"];
  400. if (!u.IsEmpty)
  401. attributes.Add (HtmlTextWriterStyle.Width, u.ToString());
  402. }
  403. Font.FillStyleAttributes (attributes, AlwaysRenderTextDecoration);
  404. }
  405. public virtual void CopyFrom(Style s)
  406. {
  407. if ((s == null) || s.IsEmpty)
  408. {
  409. return;
  410. }
  411. if (s.fontinfo != null)
  412. {
  413. Font.CopyFrom(s.fontinfo);
  414. }
  415. if ((s.CheckBit ((int) Styles.BackColor)) && (s.BackColor != Color.Empty))
  416. {
  417. this.BackColor = s.BackColor;
  418. }
  419. if ((s.CheckBit ((int) Styles.BorderColor)) && (s.BorderColor != Color.Empty))
  420. {
  421. this.BorderColor = s.BorderColor;
  422. }
  423. if ((s.CheckBit ((int) Styles.BorderStyle)) && (s.BorderStyle != BorderStyle.NotSet))
  424. {
  425. this.BorderStyle = s.BorderStyle;
  426. }
  427. if ((s.CheckBit ((int) Styles.BorderWidth)) && (!s.BorderWidth.IsEmpty))
  428. {
  429. this.BorderWidth = s.BorderWidth;
  430. }
  431. if ((s.CheckBit ((int) Styles.CssClass)) && (s.CssClass != string.Empty))
  432. {
  433. this.CssClass = s.CssClass;
  434. }
  435. if ((s.CheckBit ((int) Styles.ForeColor)) && (s.ForeColor != Color.Empty))
  436. {
  437. this.ForeColor = s.ForeColor;
  438. }
  439. if ((s.CheckBit ((int) Styles.Height)) && (!s.Height.IsEmpty))
  440. {
  441. this.Height = s.Height;
  442. }
  443. if ((s.CheckBit ((int) Styles.Width)) && (!s.Width.IsEmpty))
  444. {
  445. this.Width = s.Width;
  446. }
  447. }
  448. public virtual void MergeWith(Style s)
  449. {
  450. if ((s == null) || (s.IsEmpty))
  451. {
  452. return;
  453. }
  454. if (s.fontinfo != null)
  455. {
  456. Font.MergeWith(s.fontinfo);
  457. }
  458. if ((!CheckBit ((int) Styles.BackColor)) && (s.CheckBit ((int) Styles.BackColor)) && (s.BackColor != Color.Empty))
  459. {
  460. this.BackColor = s.BackColor;
  461. }
  462. if ((!CheckBit ((int) Styles.BorderColor)) && (s.CheckBit ((int) Styles.BorderColor)) && (s.BorderColor != Color.Empty))
  463. {
  464. this.BorderColor = s.BorderColor;
  465. }
  466. if ((!CheckBit ((int) Styles.BorderStyle)) && (s.CheckBit ((int) Styles.BorderStyle)) && (s.BorderStyle != BorderStyle.NotSet))
  467. {
  468. this.BorderStyle = s.BorderStyle;
  469. }
  470. if ((!CheckBit ((int) Styles.BorderWidth)) && (s.CheckBit ((int) Styles.BorderWidth)) && (!s.BorderWidth.IsEmpty))
  471. {
  472. this.BorderWidth = s.BorderWidth;
  473. }
  474. if ((!CheckBit ((int) Styles.CssClass)) && (s.CheckBit ((int) Styles.CssClass)) && (s.CssClass != string.Empty))
  475. {
  476. this.CssClass = s.CssClass;
  477. }
  478. if ((!CheckBit ((int) Styles.ForeColor)) && (s.CheckBit ((int) Styles.ForeColor)) && (s.ForeColor != Color.Empty))
  479. {
  480. this.ForeColor = s.ForeColor;
  481. }
  482. if ((!CheckBit ((int) Styles.Height)) && (s.CheckBit ((int) Styles.Height)) && (!s.Height.IsEmpty))
  483. {
  484. this.Height = s.Height;
  485. }
  486. if ((!CheckBit ((int) Styles.Width)) && (s.CheckBit ((int) Styles.Width)) && (!s.Width.IsEmpty))
  487. {
  488. this.Width = s.Width;
  489. }
  490. }
  491. /*
  492. internal void Print ()
  493. {
  494. Console.WriteLine ("BackColor: {0}", BackColor);
  495. Console.WriteLine ("BorderColor: {0}", BorderColor);
  496. Console.WriteLine ("BorderStyle: {0}", BorderStyle);
  497. Console.WriteLine ("BorderWidth: {0}", BorderWidth);
  498. Console.WriteLine ("CssClass: {0}", CssClass);
  499. Console.WriteLine ("ForeColor: {0}", ForeColor);
  500. Console.WriteLine ("Height: {0}", Height);
  501. Console.WriteLine ("Width: {0}", Width);
  502. }
  503. */
  504. public virtual void Reset()
  505. {
  506. viewstate.Remove("BackColor");
  507. viewstate.Remove("BorderColor");
  508. viewstate.Remove("BorderStyle");
  509. viewstate.Remove("BorderWidth");
  510. viewstate.Remove("CssClass");
  511. viewstate.Remove("ForeColor");
  512. viewstate.Remove("Height");
  513. viewstate.Remove("Width");
  514. if (fontinfo != null)
  515. {
  516. fontinfo.Reset();
  517. }
  518. styles = 0;
  519. viewstate.Remove (BitStateKey);
  520. stylesTraked = 0;
  521. }
  522. #endregion // Public Instance Methods
  523. #region Protected Instance Methods
  524. protected internal void LoadViewState(object state)
  525. {
  526. viewstate.LoadViewState(state);
  527. LoadBitState ();
  528. }
  529. protected internal virtual object SaveViewState ()
  530. {
  531. SaveBitState ();
  532. if (_isSharedViewState)
  533. return null;
  534. return viewstate.SaveViewState ();
  535. }
  536. internal void SaveBitState ()
  537. {
  538. if (stylesTraked != 0)
  539. viewstate [BitStateKey] = stylesTraked;
  540. }
  541. internal void LoadBitState () {
  542. if (viewstate [BitStateKey] == null)
  543. return;
  544. int bit = (int) viewstate [BitStateKey];
  545. styles |= bit;
  546. stylesTraked |= bit;
  547. }
  548. protected internal virtual void SetBit( int bit )
  549. {
  550. styles |= bit;
  551. if (tracking)
  552. stylesTraked |= bit;
  553. }
  554. internal void RemoveBit (int bit) {
  555. styles &= ~bit;
  556. if (tracking) {
  557. stylesTraked &= ~bit;
  558. if (stylesTraked == 0)
  559. viewstate.Remove (BitStateKey);
  560. }
  561. }
  562. internal bool CheckBit (int bit) {
  563. return (styles & bit) != 0;
  564. }
  565. protected internal virtual void TrackViewState ()
  566. {
  567. tracking = true;
  568. viewstate.TrackViewState();
  569. }
  570. #endregion // Protected Instance Methods
  571. #region IStateManager Properties & Methods
  572. void IStateManager.LoadViewState(object state)
  573. {
  574. LoadViewState(state);
  575. }
  576. object IStateManager.SaveViewState()
  577. {
  578. return SaveViewState();
  579. }
  580. void IStateManager.TrackViewState()
  581. {
  582. TrackViewState();
  583. }
  584. bool IStateManager.IsTrackingViewState
  585. {
  586. get
  587. {
  588. return this.IsTrackingViewState;
  589. }
  590. }
  591. #endregion // IStateManager Properties & Methods
  592. internal void SetRegisteredCssClass (string name)
  593. {
  594. registered_class = name;
  595. }
  596. public CssStyleCollection GetStyleAttributes (IUrlResolutionService resolver)
  597. {
  598. CssStyleCollection col = new CssStyleCollection ();
  599. FillStyleAttributes (col, resolver);
  600. return col;
  601. }
  602. [EditorBrowsable(EditorBrowsableState.Advanced)]
  603. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  604. [Browsable(false)]
  605. public string RegisteredCssClass {
  606. get {
  607. if (registered_class == null)
  608. registered_class = String.Empty;
  609. return registered_class;
  610. }
  611. }
  612. internal void CopyTextStylesFrom (Style source) {
  613. // Used primary for TreeView and Menu
  614. if (source.CheckBit ((int) Styles.ForeColor)) {
  615. ForeColor = source.ForeColor;
  616. }
  617. if (source.CheckBit((int) Styles.FontAll)) {
  618. Font.CopyFrom (source.Font);
  619. }
  620. }
  621. internal void RemoveTextStyles () {
  622. ForeColor = Color.Empty;
  623. fontinfo = null;
  624. }
  625. internal void AddCssClass (string cssClass)
  626. {
  627. if (String.IsNullOrEmpty (cssClass))
  628. return;
  629. string newClass = CssClass;
  630. if (newClass.Length > 0)
  631. newClass += " ";
  632. newClass += cssClass;
  633. CssClass = newClass;
  634. }
  635. internal void PrependCssClass (string cssClass)
  636. {
  637. if (String.IsNullOrEmpty (cssClass))
  638. return;
  639. string oldClass = CssClass;
  640. if (oldClass.Length > 0)
  641. cssClass += " ";
  642. CssClass = cssClass + oldClass;
  643. }
  644. public void SetDirty ()
  645. {
  646. if (viewstate != null)
  647. viewstate.SetDirty (true);
  648. stylesTraked = styles;
  649. }
  650. }
  651. }