Files
mono/mcs/class/System.Web/System.Web.UI.WebControls/Table.cs
T
Gaurav Vaish f3ceded673 2002-01-10 Gaurav Vaish <[email protected]>
* HyperLinkControlBuilder.cs, Table.cs, TableCell.cs, TableCellControlBuilder.cs, TableRowCollection.cs, TableCellCollection.cs --- Completed all except one. Don't recall which one. See TODO for details.

* HyperLinkColumn.cs, ButtonColumn.cs -- *Columns and *ControlBuilder are proving to be rather simple classes to be implemented. :))

* TODO  -- Updated

* ChangeLog -- Oops! Not here.. Will update it :(

svn path=/trunk/mcs/; revision=1946
2002-01-10 13:41:08 +00:00

171 lines
3.5 KiB
C#

/**
* Namespace: System.Web.UI.WebControls
* Class: Table
*
* Author: Gaurav Vaish
* Maintainer: [email protected]
* Contact: <[email protected]>, <[email protected]>
* Implementation: yes
* Status: 100%
*
* (C) Gaurav Vaish (2002)
*/
using System;
using System.Drawing;
using System.Globalization;
using System.Web;
using System.Web.UI;
namespace System.Web.UI.WebControls
{
public class Table: WebControl
{
private TableRowCollection rows;
private class TableRowControlCollection : ControlCollection
{
public TableRowControlCollection(Control owner): base(owner)
{
}
public override void Add(Control child)
{
if(child is TableRow)
{
Add(child);
return;
}
throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "Table", child.GetType().Name.ToString()));
}
public override void AddAt(int index, Control child)
{
if(child is TableRow)
{
Add(child);
return;
}
throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "Table", child.GetType().Name.ToString()));
}
}
public Table(): base(HtmlTextWriterTag.Table)
{
}
public virtual string BackImageUrl
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).BackImageUrl;
}
set
{
((TableStyle)ControlStyle).BackImageUrl = value;
}
}
public virtual int CellPadding
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).CellPadding;
}
set
{
((TableStyle)ControlStyle).CellPadding = value;
}
}
public virtual int CellSpacing
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).CellSpacing;
}
set
{
((TableStyle)ControlStyle).CellSpacing = value;
}
}
public virtual GridLines GridLines
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).GridLines;
}
set
{
((TableStyle)ControlStyle).GridLines = value;
}
}
public virtual HorizontalAlign HorizontalAlign
{
get
{
if(ControlStyleCreated)
return ((TableStyle)ControlStyle).HorizontalAlign;
}
set
{
((TableStyle)ControlStyle).HorizontalAlign = value;
}
}
public virtual TableRowCollection Rows
{
get
{
if(rows == null)
{
rows = new TableRowCollection(this);
}
return rows;
}
}
protected override void AddAttributesToRender(HtmlTextWriter writer): AddAttributesToRender(writer)
{
if(!BorderColor.IsEmpty)
{
writer.AddAttribute(HtmlTextWriterAttribute.Bordercolor, ColorTranslator.ToHtml(BorderColor));
}
Unit bw = BorderWidth;
if(GridLines == GridLines.None)
{
bw = Unit.Pixel(0);
} else if(!bw.IsEmpty && bw.Type == UnitType.Pixel)
{
bw = Unit.Pixel(1);
}
writer.AddAttribute(HtmlTextWriterAttribute.Border, ((int)bw.Value).ToString(NumberFormatInfo.InvariantInfo));
}
protected override ControlCollection CreateControlCollection()
{
return new TableRowControlCollection(this);
}
protected override Style CreateControlStyle()
{
return new TableStyle(ViewState);
}
protected override void RenderContents(HtmlTextWriter writer)
{
foreach(object current in Rows)
{
((TableRow)current).RenderControl(writer);
}
}
}
}