2005-09-22 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Style.cs
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     (pbartok@novell.com)
24 //
25 //
26
27 using System.ComponentModel;
28 using System.Drawing;
29 using System.Security.Permissions;
30
31 namespace System.Web.UI.WebControls {
32
33         // CAS
34         [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
35         [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
36         // attributes
37 #if NET_2_0
38 // Not until we actually have StyleConverter
39 //      [TypeConverter(typeof(System.Web.UI.WebControls.StyleConverter))]
40 #else
41         [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
42 #endif
43         [ToolboxItem("")]
44         public class Style : System.ComponentModel.Component, System.Web.UI.IStateManager 
45         {
46                 [Flags]
47                 internal enum Styles 
48                 {
49                         None            = 0,
50                         BackColor       = 0x00000001,
51                         BorderColor     = 0x00000002,
52                         BorderStyle     = 0x00000004,
53                         BorderWidth     = 0x00000008,
54                         CssClass        = 0x00000010,
55                         Font            = 0x00000020,
56                         ForeColor       = 0x00000040,
57                         Height          = 0x00000080,
58                         Width           = 0x00000100,
59
60                         // from TableStyle (which doesn't override IsEmpty)
61                         BackImageUrl    = 0x00000200,
62                         CellPadding     = 0x00000400,
63                         CellSpacing     = 0x00000800,
64                         GridLines       = 0x00001000,
65                         HorizontalAlign = 0x00002000,
66
67                         // from TableItemStyle (which doesn't override IsEmpty neither)
68                         VerticalAlign   = 0x00004000,
69                         Wrap            = 0x00008000,
70
71                         // from DataGridPagerStyle (and, once again, no IsEmpty override)
72                         Mode            = 0x00010000,
73                         NextPageText    = 0x00020000,
74                         PageButtonCount = 0x00040000,
75                         Position        = 0x00080000,
76                         PrevPageText    = 0x00100000,
77                         Visible         = 0x00200000
78                         
79                 }
80
81                 #region Fields
82                 internal Styles         styles;
83                 internal StateBag       viewstate;
84                 private FontInfo        fontinfo;
85                 private bool            tracking;
86 #if NET_2_0
87                 private string          registered_class;
88 #endif
89                 #endregion      // Fields
90
91                 #region Public Constructors
92                 public Style() : this(new StateBag()) 
93                 {
94                 }
95
96                 public Style(System.Web.UI.StateBag bag) 
97                 {
98                         if (bag != null) {
99                                 viewstate = bag;
100                         } else {
101                                 viewstate = new StateBag();
102                         }
103                         tracking = false;
104                 }
105                 #endregion      // Public Constructors
106
107                 #region Public Instance Properties
108 #if !NET_2_0
109                 [Bindable(true)]
110 #endif
111                 [DefaultValue(typeof (Color), "")]
112                 [NotifyParentProperty(true)]
113                 [TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
114                 [WebSysDescription ("")]
115                 [WebCategory ("Appearance")]
116                 public Color BackColor 
117                 {
118                         get 
119                         {
120                                 if ((styles & Styles.BackColor) == 0) 
121                                 {
122                                         return Color.Empty;
123                                 }
124
125                                 return (Color)viewstate["BackColor"];
126                         }
127
128                         set 
129                         {
130                                 viewstate["BackColor"] = value;
131                                 styles |= Styles.BackColor;
132                         }
133                 }
134
135 #if !NET_2_0
136                 [Bindable(true)]
137 #endif
138                 [DefaultValue(typeof (Color), "")]
139                 [NotifyParentProperty(true)]
140                 [TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
141                 [WebSysDescription ("")]
142                 [WebCategory ("Appearance")]
143                 public Color BorderColor 
144                 {
145                         get 
146                         {
147                                 if ((styles & Styles.BorderColor) == 0) 
148                                 {
149                                         return Color.Empty;
150                                 }
151
152                                 return (Color)viewstate["BorderColor"];
153                         }
154
155                         set 
156                         {
157                                 viewstate["BorderColor"] = value;
158                                 styles |= Styles.BorderColor;
159                         }
160                 }
161
162 #if !NET_2_0
163                 [Bindable(true)]
164 #endif
165                 [DefaultValue(BorderStyle.NotSet)]
166                 [NotifyParentProperty(true)]
167                 [WebSysDescription ("")]
168                 [WebCategory ("Appearance")]
169                 public BorderStyle BorderStyle 
170                 {
171                         get 
172                         {
173                                 if ((styles & Styles.BorderStyle) == 0) 
174                                 {
175                                         return BorderStyle.NotSet;
176                                 }
177
178                                 return (BorderStyle)viewstate["BorderStyle"];
179                         }
180
181                         set 
182                         {
183                                 viewstate["BorderStyle"] = value;
184                                 styles |= Styles.BorderStyle;
185                         }
186                 }
187
188 #if !NET_2_0
189                 [Bindable(true)]
190 #endif
191                 [DefaultValue(typeof (Unit), "")]
192                 [NotifyParentProperty(true)]
193                 [WebSysDescription ("")]
194                 [WebCategory ("Appearance")]
195                 public Unit BorderWidth 
196                 {
197                         get 
198                         {
199                                 if ((styles & Styles.BorderWidth) == 0) 
200                                 {
201                                         return Unit.Empty;
202                                 }
203
204                                 return (Unit)viewstate["BorderWidth"];
205                         }
206
207                         set 
208                         {
209                                 if (value.Value < 0) 
210                                 {
211                                         throw new ArgumentOutOfRangeException("Value", value.Value, "BorderWidth must not be negative");
212                                 }
213
214                                 viewstate["BorderWidth"] = value;
215                                 styles |= Styles.BorderWidth;
216                         }
217                 }
218
219                 [DefaultValue("")]
220                 [NotifyParentProperty(true)]
221                 [WebSysDescription ("")]
222                 [WebCategory ("Appearance")]
223                 public string CssClass 
224                 {
225                         get 
226                         {
227                                 if ((styles & Styles.CssClass) == 0) 
228                                 {
229                                         return string.Empty;
230                                 }
231
232                                 return (string)viewstate["CssClass"];
233                         }
234
235                         set 
236                         {
237                                 viewstate["CssClass"] = value;
238                                 styles |= Styles.CssClass;
239                         }
240                 }
241
242                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
243                 [NotifyParentProperty(true)]
244                 [WebSysDescription ("")]
245                 [WebCategory ("Appearance")]
246                 public FontInfo Font 
247                 {
248                         get 
249                         {
250                                 if (fontinfo == null) 
251                                 {
252                                         fontinfo = new FontInfo(this);
253                                 }
254                                 return fontinfo;
255                         }
256                 }
257
258 #if !NET_2_0
259                 [Bindable(true)]
260 #endif
261                 [DefaultValue(typeof (Color), "")]
262                 [NotifyParentProperty(true)]
263                 [TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter))]
264                 [WebSysDescription ("")]
265                 [WebCategory ("Appearance")]
266                 public Color ForeColor 
267                 {
268                         get 
269                         {
270                                 if ((styles & Styles.ForeColor) == 0) 
271                                 {
272                                         return Color.Empty;
273                                 }
274
275                                 return (Color)viewstate["ForeColor"];
276                         }
277
278                         set 
279                         {
280                                 viewstate["ForeColor"] = value;
281                                 styles |= Styles.ForeColor;
282                         }
283                 }
284
285 #if !NET_2_0
286                 [Bindable(true)]
287 #endif
288                 [DefaultValue(typeof (Unit), "")]
289                 [NotifyParentProperty(true)]
290                 [WebSysDescription ("")]
291                 [WebCategory ("Appearance")]
292                 public Unit Height 
293                 {
294                         get 
295                         {
296                                 if ((styles & Styles.Height) == 0) 
297                                 {
298                                         return Unit.Empty;
299                                 }
300
301                                 return (Unit)viewstate["Height"];
302                         }
303
304                         set 
305                         {
306                                 if (value.Value < 0) 
307                                 {
308                                         throw new ArgumentOutOfRangeException("Value", value.Value, "Height must not be negative");
309                                 }
310
311                                 viewstate["Height"] = value;
312                                 styles |= Styles.Height;
313                         }
314                 }
315
316 #if !NET_2_0
317                 [Bindable(true)]
318 #endif
319                 [DefaultValue(typeof (Unit), "")]
320                 [NotifyParentProperty(true)]
321                 [WebSysDescription ("")]
322                 [WebCategory ("Appearance")]
323                 public Unit Width 
324                 {
325                         get 
326                         {
327                                 if ((styles & Styles.Width) == 0) 
328                                 {
329                                         return Unit.Empty;
330                                 }
331
332                                 return (Unit)viewstate["Width"];
333                         }
334
335                         set 
336                         {
337                                 if (value.Value < 0) 
338                                 {
339                                         throw new ArgumentOutOfRangeException("Value", value.Value, "Width must not be negative");
340                                 }
341
342                                 viewstate["Width"] = value;
343                                 styles |= Styles.Width;
344                         }
345                 }
346                 #endregion      // Public Instance Properties
347
348                 #region Protected Instance Properties
349 #if NET_2_0
350                 [Browsable (false)]
351                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
352                 public virtual bool IsEmpty 
353 #else
354                 protected internal virtual bool IsEmpty 
355 #endif
356                 {
357                         get 
358                         {
359                                 return (styles == 0 && (fontinfo == null || fontinfo.IsEmpty));
360                         }
361                 }
362
363                 protected bool IsTrackingViewState 
364                 {
365                         get 
366                         {
367                                 return tracking;
368                         }
369                 }
370
371                 [Browsable(false)]
372                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
373                 protected internal StateBag ViewState 
374                 {
375                         get 
376                         {
377                                 return viewstate;
378                         }
379                 }
380                 #endregion      // Protected Instance Properties
381
382                 #region Public Instance Methods
383                 public void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer) 
384                 {
385                         AddAttributesToRender(writer, null);
386                 }
387
388                 public virtual void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer, WebControl owner)
389                 {
390                         if ((styles & Styles.CssClass) != 0) 
391                         {
392                                 string s = (string)viewstate["CssClass"];
393                                 if (s != string.Empty)
394                                         writer.AddAttribute (HtmlTextWriterAttribute.Class, s);
395                         }
396
397                         CssStyleCollection attributes = new CssStyleCollection ();
398                         FillStyleAttributes (attributes);
399                         foreach (string attr in attributes.Keys)
400                                 writer.AddStyleAttribute (attr, attributes [attr]);
401                 }
402                  
403                 void FillStyleAttributes (CssStyleCollection attributes) 
404                 {
405                         string          s;
406                         Color           color;
407                         BorderStyle     bs;
408                         Unit            u;
409
410                         if ((styles & Styles.BackColor) != 0)
411                         {
412                                 color = (Color)viewstate["BackColor"];
413                                 if (!color.IsEmpty)
414                                         attributes.Add (HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color));
415                         }
416
417                         if ((styles & Styles.BorderColor) != 0) 
418                         {
419                                 color = (Color)viewstate["BorderColor"];
420                                 if (!color.IsEmpty)
421                                         attributes.Add (HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
422                         }
423
424                         if ((styles & Styles.BorderStyle) != 0) 
425                         {
426                                 bs = (BorderStyle)viewstate["BorderStyle"];
427                                 if (bs != BorderStyle.NotSet) 
428                                         attributes.Add (HtmlTextWriterStyle.BorderStyle, bs.ToString());
429                         }
430
431                         if ((styles & Styles.BorderWidth) != 0) 
432                         {
433                                 u = (Unit)viewstate["BorderWidth"];
434                                 if (!u.IsEmpty)
435                                         attributes.Add (HtmlTextWriterStyle.BorderWidth, u.ToString());
436                         }
437
438                         if ((styles & Styles.ForeColor) != 0) 
439                         {
440                                 color = (Color)viewstate["ForeColor"];
441                                 if (!color.IsEmpty)
442                                         attributes.Add (HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color));
443                         }
444
445                         if ((styles & Styles.Height) != 0) 
446                         {
447                                 u = (Unit)viewstate["Height"];
448                                 if (!u.IsEmpty)
449                                         attributes.Add (HtmlTextWriterStyle.Height, u.ToString());
450                         }
451
452                         if ((styles & Styles.Width) != 0) 
453                         {
454                                 u = (Unit)viewstate["Width"];
455                                 if (!u.IsEmpty)
456                                         attributes.Add (HtmlTextWriterStyle.Width, u.ToString());
457                         }
458
459                         if (fontinfo != null) {
460                                 // Fonts are a bit weird
461                                 if (fontinfo.Name != string.Empty) 
462                                 {
463                                         s = fontinfo.Names[0];
464                                         for (int i = 1; i < fontinfo.Names.Length; i++) 
465                                         {
466                                                 s += "," + fontinfo.Names[i];
467                                         }
468                                         attributes.Add (HtmlTextWriterStyle.FontFamily, s);
469                                 }
470
471                                 if (fontinfo.Bold) 
472                                 {
473                                         attributes.Add (HtmlTextWriterStyle.FontWeight, "bold");
474                                 }
475
476                                 if (fontinfo.Italic) 
477                                 {
478                                         attributes.Add (HtmlTextWriterStyle.FontStyle, "italic");
479                                 }
480
481                                 if (!fontinfo.Size.IsEmpty) 
482                                 {
483                                         attributes.Add (HtmlTextWriterStyle.FontSize, fontinfo.Size.ToString());
484                                 }
485
486                                 // These styles are munged into a attribute decoration
487                                 s = string.Empty;
488
489                                 if (fontinfo.Overline) 
490                                 {
491                                         s += "overline ";
492                                 }
493
494                                 if (fontinfo.Strikeout) 
495                                 {
496                                         s += "line-through ";
497                                 }
498
499                                 if (fontinfo.Underline) 
500                                 {
501                                         s += "underline ";
502                                 }
503
504                                 if (s != string.Empty) 
505                                 {
506                                         attributes.Add (HtmlTextWriterStyle.TextDecoration, s);
507                                 }
508                         }
509                 }
510
511                 public virtual void CopyFrom(Style s) 
512                 {
513                         if ((s == null) || s.IsEmpty) 
514                         {
515                                 return;
516                         }
517
518                         if (s.fontinfo != null) 
519                         {
520                                 Font.CopyFrom(s.fontinfo);
521                         }
522
523                         if (((s.styles & Styles.BackColor) != 0) && (s.BackColor != Color.Empty))
524                         {
525                                 this.BackColor = s.BackColor;
526                         }
527                         if (((s.styles & Styles.BorderColor) != 0) && (s.BorderColor != Color.Empty))
528                         {
529                                 this.BorderColor = s.BorderColor;
530                         }
531                         if (((s.styles & Styles.BorderStyle) != 0) && (s.BorderStyle != BorderStyle.NotSet))
532                         {
533                                 this.BorderStyle = s.BorderStyle;
534                         }
535                         if (((s.styles & Styles.BorderWidth) != 0) && (s.BorderWidth != Unit.Empty))
536                         {
537                                 this.BorderWidth = s.BorderWidth;
538                         }
539                         if (((s.styles & Styles.CssClass) != 0) && (s.CssClass != string.Empty))
540                         {
541                                 this.CssClass = s.CssClass;
542                         }
543                         if (((s.styles & Styles.ForeColor) != 0) && (s.ForeColor != Color.Empty))
544                         {
545                                 this.ForeColor = s.ForeColor;
546                         }
547                         if (((s.styles & Styles.Height) != 0) && (s.Height != Unit.Empty))
548                         {
549                                 this.Height = s.Height;
550                         }
551                         if (((s.styles & Styles.Width) != 0) && (s.Width != Unit.Empty))
552                         {
553                                 this.Width = s.Width;
554                         }
555                 }
556
557                 public virtual void MergeWith(Style s) 
558                 {
559                         if ((s == null) || (s.IsEmpty))
560                         {
561                                 return;
562                         }
563
564                         if (s.fontinfo != null) 
565                         {
566                                 Font.MergeWith(s.fontinfo);
567                         }
568
569                         if (((styles & Styles.BackColor) == 0) && ((s.styles & Styles.BackColor) != 0) && (s.BackColor != Color.Empty))
570                         {
571                                 this.BackColor = s.BackColor;
572                         }
573                         if (((styles & Styles.BorderColor) == 0) && ((s.styles & Styles.BorderColor) != 0) && (s.BorderColor != Color.Empty)) 
574                         {
575                                 this.BorderColor = s.BorderColor;
576                         }
577                         if (((styles & Styles.BorderStyle) == 0) && ((s.styles & Styles.BorderStyle) != 0) && (s.BorderStyle != BorderStyle.NotSet)) 
578                         {
579                                 this.BorderStyle = s.BorderStyle;
580                         }
581                         if (((styles & Styles.BorderWidth) == 0) && ((s.styles & Styles.BorderWidth) != 0) && (s.BorderWidth != Unit.Empty)) 
582                         {
583                                 this.BorderWidth = s.BorderWidth;
584                         }
585                         if (((styles & Styles.CssClass) == 0) && ((s.styles & Styles.CssClass) != 0) && (s.CssClass != string.Empty)) 
586                         {
587                                 this.CssClass = s.CssClass;
588                         }
589                         if (((styles & Styles.ForeColor) == 0) && ((s.styles & Styles.ForeColor) != 0) && (s.ForeColor != Color.Empty)) 
590                         {
591                                 this.ForeColor = s.ForeColor;
592                         }
593                         if (((styles & Styles.Height) == 0) && ((s.styles & Styles.Height) != 0) && (s.Height != Unit.Empty)) 
594                         {
595                                 this.Height = s.Height;
596                         }
597                         if (((styles & Styles.Width) == 0) && ((s.styles & Styles.Width) != 0) && (s.Width != Unit.Empty)) 
598                         {
599                                 this.Width = s.Width;
600                         }
601                 }
602
603                 public virtual void Reset() 
604                 {
605                         viewstate.Remove("BackColor");
606                         viewstate.Remove("BorderColor");
607                         viewstate.Remove("BorderStyle");
608                         viewstate.Remove("BorderWidth");
609                         viewstate.Remove("CssClass");
610                         viewstate.Remove("ForeColor");
611                         viewstate.Remove("Height");
612                         viewstate.Remove("Width");
613                         if (fontinfo != null) 
614                         {
615                                 fontinfo.Reset();
616                         }
617                         styles = Styles.None;
618                 }
619 #if ONLY_1_1
620                 public override string ToString() 
621                 {
622                         return string.Empty;
623                 }
624 #endif
625                 #endregion      // Public Instance Methods
626
627                 #region Protected Instance Methods
628                 protected internal void LoadViewState(object state) 
629                 {
630                         viewstate.LoadViewState(state);
631
632                         // Update our style
633                         this.styles = Styles.None;
634
635                         if (viewstate["BackColor"] != null) 
636                         {
637                                 styles |= Styles.BackColor;
638                         }
639                         if (viewstate["BorderColor"] != null) 
640                         {
641                                 styles |= Styles.BorderColor;
642                         }
643                         if (viewstate["BorderStyle"] != null) 
644                         {
645                                 styles |= Styles.BorderStyle;
646                         }
647                         if (viewstate["BorderWidth"] != null) 
648                         {
649                                 styles |= Styles.BorderWidth;
650                         }
651                         if (viewstate["CssClass"] != null) 
652                         {
653                                 styles |= Styles.CssClass;
654                         }
655                         if (viewstate["ForeColor"] != null) 
656                         {
657                                 styles |= Styles.ForeColor;
658                         }
659                         if (viewstate["Height"] != null) 
660                         {
661                                 styles |= Styles.Height;
662                         }
663                         if (viewstate["Width"] != null) 
664                         {
665                                 styles |= Styles.Width;
666                         }
667                         if (fontinfo != null) {
668                                 fontinfo.LoadViewState();
669                         }
670
671                         LoadViewStateInternal();
672                 }
673
674                 internal virtual void LoadViewStateInternal()
675                 {
676                         // Override me
677                 }
678
679                 protected internal virtual object SaveViewState () 
680                 {
681                         if (styles != Styles.None) 
682                         {
683                                 return viewstate.SaveViewState();
684                         }
685                         return null;
686                 }
687
688                 [MonoTODO]
689                 protected internal virtual void SetBit( int bit ) 
690                 {
691                         throw new NotImplementedException();
692                 }
693
694                 protected internal virtual void TrackViewState() 
695                 {
696                         tracking = true;
697                         viewstate.TrackViewState();
698                 }
699                 #endregion      // Protected Instance Methods
700
701                 #region IStateManager Properties & Methods
702                 void IStateManager.LoadViewState(object state) 
703                 {
704                         LoadViewState(state);
705                 }
706
707                 object IStateManager.SaveViewState() 
708                 {
709                         return SaveViewState();
710                 }
711
712                 void IStateManager.TrackViewState() 
713                 {
714                         TrackViewState();
715                 }
716
717                 bool IStateManager.IsTrackingViewState 
718                 {
719                         get 
720                         {
721                                 return this.IsTrackingViewState;
722                         }
723                 }
724                 #endregion      // IStateManager Properties & Methods
725
726 #if NET_2_0
727                 protected virtual void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver)
728                 {
729                         FillStyleAttributes (attributes);
730                 }
731
732                 internal void SetRegisteredCssClass (string name)
733                 {
734                         registered_class = name;
735                 }
736
737                 public CssStyleCollection GetStyleAttributes (IUrlResolutionService resolver)
738                 {
739                         CssStyleCollection col = new CssStyleCollection ();
740                         FillStyleAttributes (col, resolver);
741                         return col;
742                 }
743
744                 [MonoTODO]
745                 [EditorBrowsable(EditorBrowsableState.Advanced)]
746                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
747                 [Browsable(false)]
748                 public string RegisteredCssClass {
749                         get {
750                                 if (registered_class == null)
751                                         registered_class = String.Empty;
752                                 return registered_class;
753                         }
754                 }
755
756                 internal virtual void CopyTextStylesFrom (Style source)
757                 {
758                         // Need to ask lluis if we need fonts, too
759                         if ((styles & Styles.ForeColor) != 0) {
760                                 ForeColor = source.ForeColor;
761                         }
762                         if ((styles & Styles.BackColor) != 0) {
763                                 BackColor = source.BackColor;
764                         }
765                 }
766
767                 public void SetDirty ()
768                 {
769                         if (viewstate != null)
770                                 viewstate.SetDirty (true);
771                 }
772 #endif
773         }
774 }