* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / System.Web.UI / Control.cs
index 0bf314bbe2eefdaa04c7dff2d9cc20e5770c058e..83521a7b9de50cf2437e09220253e95467f7da32 100644 (file)
@@ -141,6 +141,9 @@ namespace System.Web.UI
                        stateMask = ENABLE_VIEWSTATE | VISIBLE | AUTOID | BINDING_CONTAINER | AUTO_EVENT_WIREUP;
                         if (this is INamingContainer)
                                stateMask |= IS_NAMING_CONTAINER;
+#if NET_2_0
+                       stateMask |= ENABLE_THEMING;
+#endif
                 }
 
 #if NET_2_0
@@ -180,7 +183,7 @@ namespace System.Web.UI
                public Control BindingContainer {
                        get {
                                Control container = NamingContainer;
-                               if ((container.stateMask & BINDING_CONTAINER) == 0)
+                               if (container != null && (container.stateMask & BINDING_CONTAINER) == 0)
                                        container = container.BindingContainer;
                                return container;
                        }
@@ -222,11 +225,10 @@ namespace System.Web.UI
                 }
 
 #if NET_2_0
+               [MonoTODO ("revisit once we have a real design strategy")]
                protected internal bool DesignMode 
                {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+                       get { return false; }
                }
 #endif         
 
@@ -279,7 +281,14 @@ namespace System.Web.UI
                protected internal bool IsViewStateEnabled 
                {
                        get {
-                               throw new NotImplementedException ();
+                               if (Page == null)
+                                       return false;
+
+                               for (Control control = this; control != null; control = control.Parent)
+                                       if (!control.EnableViewState)
+                                               return false;
+
+                               return true;
                        }
                }
 
@@ -595,6 +604,15 @@ namespace System.Web.UI
                [EditorBrowsable (EditorBrowsableState.Advanced)]
                public virtual void ApplyStyleSheetSkin (Page page)
                {
+                       if (!EnableTheming) /* this enough? */
+                               return;
+
+                       /* apply the style sheet skin here */
+                       if (page.StyleSheetPageTheme != null) {
+                               ControlSkin cs = page.StyleSheetPageTheme.GetControlSkin (GetType(), SkinID);
+                               if (cs != null)
+                                       cs.ApplySkin (this);
+                       }
                }
 #endif         
 
@@ -1235,7 +1253,6 @@ namespace System.Web.UI
                                trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
                        }
 #endif
-
                         if (HasControls ()) {
                                if ((stateMask & IS_NAMING_CONTAINER) != 0)
                                        namingContainer = this;
@@ -1259,6 +1276,8 @@ namespace System.Web.UI
 
                        stateMask |= INITING;
 #if NET_2_0
+                       ApplyTheme ();
+                       
                        if (Adapter != null)
                                Adapter.OnInit (EventArgs.Empty);
                        else
@@ -1373,6 +1392,32 @@ namespace System.Web.UI
 #endif
                        stateMask |= VIEWSTATE_LOADED;
                 }
+
+#if NET_2_0
+               internal ControlSkin controlSkin;
+
+                internal void ApplyTheme ()
+                {
+#if MONO_TRACE
+                       TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
+                       string type_name = null;
+                       if (trace != null) {
+                               type_name = GetType ().Name;
+                               trace.Write ("control", String.Format ("ApplyThemeRecursive {0} {1}", _userId, type_name));
+                       }
+#endif
+                       if (Page.PageTheme != null) {
+                               ControlSkin controlSkin = Page.PageTheme.GetControlSkin (GetType (), SkinID);
+                               if (controlSkin != null)
+                                       controlSkin.ApplySkin (this);
+                       }
+
+#if MONO_TRACE
+                       if (trace != null)
+                               trace.Write ("control", String.Format ("End ApplyThemeRecursive {0} {1}", _userId, type_name));
+#endif
+                }
+#endif
                 
                internal bool AutoID
                {