// This will provide extra information when trace is enabled. Might be too verbose.
#define MONO_TRACE
-using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
+using System.Security.Permissions;
using System.Web;
using System.Web.Util;
#if NET_2_0
namespace System.Web.UI
{
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ // attributes
[DefaultProperty ("ID"), DesignerCategory ("Code"), ToolboxItemFilter ("System.Web.UI", ToolboxItemFilterType.Require)]
[ToolboxItem ("System.Web.UI.Design.WebControlToolboxItem, " + Consts.AssemblySystem_Design)]
[Designer ("System.Web.UI.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
string uniqueID;
string _userId;
+ TemplateControl _templateControl;
ControlCollection _controls;
Control _namingContainer;
Page _page;
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
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;
}
}
#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
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;
}
}
public TemplateControl TemplateControl
{
get {
- throw new NotImplementedException ();
+ return _templateControl;
}
[EditorBrowsable (EditorBrowsableState.Never)]
set {
- throw new NotImplementedException ();
+ _templateControl = value;
}
}
#endif
protected bool ChildControlsCreated {
get { return ((stateMask & CHILD_CONTROLS_CREATED) != 0); }
set {
- if (value == false && (stateMask & CHILD_CONTROLS_CREATED) != 0)
- Controls.Clear();
+ if (value == false && (stateMask & CHILD_CONTROLS_CREATED) != 0) {
+ if (_controls != null)
+ _controls.Clear();
+ }
SetMask (CHILD_CONTROLS_CREATED, value);
}
if (!HasControls ())
return;
- foreach (Control c in Controls)
+ foreach (Control c in _controls)
c.NullifyUniqueID ();
}
}
#if NET_2_0
+ [MonoTODO]
[EditorBrowsable (EditorBrowsableState.Advanced)]
public virtual void ApplyStyleSheetSkin (Page page)
{
- throw new NotImplementedException ();
+ 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
protected bool IsLiteralContent()
{
- if (HasControls () && Controls.Count == 1 && (Controls [0] is LiteralControl))
+ if (HasControls () && _controls.Count == 1 && (_controls [0] is LiteralControl))
return true;
return false;
return null;
Control result = null;
- foreach (Control c in Controls) {
+ foreach (Control c in _controls) {
if (String.Compare (id, c._userId, true) == 0) {
if (result != null && result != c) {
throw new HttpException ("1 Found more than one control with ID '" + id + "'");
{
if (_renderMethodDelegate != null) {
_renderMethodDelegate (writer, this);
- } else if (HasControls ()) {
- int len = Controls.Count;
+ } else if (_controls != null) {
+ int len = _controls.Count;
for (int i = 0; i < len; i++) {
- Control c = Controls [i];
+ Control c = _controls [i];
#if NET_2_0
if (c.Adapter != null)
c.RenderControl (writer, c.Adapter);
if (!HasControls ())
return;
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i = 0; i < len; i++) {
- Control c = Controls [i];
+ Control c = _controls [i];
c.DataBind ();
}
}
#endif
void RenderControl (HtmlTextWriter writer)
{
- if ((stateMask & VISIBLE) != 0)
- Render(writer);
+ if ((stateMask & VISIBLE) != 0) {
+ HttpContext ctx = Context;
+ TraceContext trace = (ctx != null) ? ctx.Trace : null;
+ int pos = 0;
+ if ((trace != null) && trace.IsEnabled)
+ pos = ctx.Response.GetOutputByteCount ();
+
+ Render(writer);
+ if ((trace != null) && trace.IsEnabled) {
+ int size = ctx.Response.GetOutputByteCount () - pos;
+ trace.SaveSize (this, size >= 0 ? size : 0);
+ }
+ }
}
#if NET_2_0
#endif
OnLoad (EventArgs.Empty);
if (HasControls ()) {
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c.LoadRecursive ();
}
}
}
#endif
if (HasControls ()) {
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c.UnloadRecursive (dispose);
}
}
if (!HasControls ())
return;
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c.PreRenderRecursiveInternal ();
}
#if MONO_TRACE
trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
}
#endif
-
if (HasControls ()) {
if ((stateMask & IS_NAMING_CONTAINER) != 0)
namingContainer = this;
namingContainer.AutoID)
namingContainer._userId = namingContainer.GetDefaultName () + "b";
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control c = Controls[i];
+ Control c = _controls[i];
c._page = Page;
c._namingContainer = namingContainer;
if (namingContainer != null && c._userId == null && c.AutoID)
stateMask |= INITING;
#if NET_2_0
+ ApplyTheme ();
+
if (Adapter != null)
Adapter.OnInit (EventArgs.Empty);
else
int idx = -1;
if (HasControls ())
{
- int len = Controls.Count;
+ int len = _controls.Count;
for (int i=0;i<len;i++)
{
- Control ctrl = Controls[i];
+ Control ctrl = _controls[i];
object ctrlState = ctrl.SaveViewStateRecursive ();
idx++;
if (ctrlState == null)
#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
{
set { skinId = value; }
}
- /* This shouldnt be in 2.0, and I can't find it in 1.1
- * either, so leaving alone for now.
- */
- protected string GetWebResourceUrl (string resourceName)
- {
- return Page.ClientScript.GetWebResourceUrl (GetType(), resourceName);
- }
-
- string IUrlResolutionService.ResolveClientUrl (string url)
+ public string ResolveClientUrl (string url)
{
throw new NotImplementedException ();
}