TableRow.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // System.Web.UI.WebControls.TableRow.cs
  3. //
  4. // Author:
  5. // Sebastien Pouliot <[email protected]>
  6. //
  7. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System.ComponentModel;
  29. using System.Security.Permissions;
  30. namespace System.Web.UI.WebControls {
  31. // CAS
  32. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  33. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  34. // attributes
  35. [DefaultProperty ("Cells")]
  36. [ParseChildren (true, "Cells")]
  37. [ToolboxItem ("")]
  38. [Bindable (false)]
  39. [Designer ("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
  40. public class TableRow : WebControl
  41. {
  42. TableCellCollection cells;
  43. bool tableRowSectionSet;
  44. internal TableRowCollection Container { get; set; }
  45. public TableRow ()
  46. : base (HtmlTextWriterTag.Tr)
  47. {
  48. AutoID = false;
  49. }
  50. internal bool TableRowSectionSet {
  51. get { return tableRowSectionSet; }
  52. }
  53. [MergableProperty (false)]
  54. [PersistenceMode (PersistenceMode.InnerDefaultProperty)]
  55. [WebSysDescription ("")]
  56. [WebCategory("Layout")]
  57. public virtual TableCellCollection Cells {
  58. get {
  59. if (cells == null)
  60. cells = new TableCellCollection (this);
  61. return cells;
  62. }
  63. }
  64. [DefaultValue (HorizontalAlign.NotSet)]
  65. [WebSysDescription ("")]
  66. [WebCategory ("Layout")]
  67. public virtual HorizontalAlign HorizontalAlign {
  68. get {
  69. if (!ControlStyleCreated)
  70. return HorizontalAlign.NotSet; // default value
  71. return TableItemStyle.HorizontalAlign;
  72. }
  73. set { TableItemStyle.HorizontalAlign = value; }
  74. }
  75. [DefaultValue (VerticalAlign.NotSet)]
  76. [WebSysDescription ("")]
  77. [WebCategory ("Layout")]
  78. public virtual VerticalAlign VerticalAlign {
  79. get {
  80. if (!ControlStyleCreated)
  81. return VerticalAlign.NotSet; // default value
  82. return TableItemStyle.VerticalAlign;
  83. }
  84. set { TableItemStyle.VerticalAlign = value; }
  85. }
  86. TableItemStyle TableItemStyle {
  87. get { return (ControlStyle as TableItemStyle); }
  88. }
  89. public override bool SupportsDisabledAttribute {
  90. get { return RenderingCompatibilityLessThan40; }
  91. }
  92. protected override ControlCollection CreateControlCollection ()
  93. {
  94. return new CellControlCollection (this);
  95. }
  96. protected override Style CreateControlStyle ()
  97. {
  98. return new TableItemStyle (ViewState);
  99. }
  100. [DefaultValue (TableRowSection.TableBody)]
  101. public virtual TableRowSection TableSection {
  102. get {
  103. object o = ViewState ["TableSection"];
  104. return (o == null) ? TableRowSection.TableBody : (TableRowSection) o;
  105. }
  106. set {
  107. if ((value < TableRowSection.TableHeader) || (value > TableRowSection.TableFooter))
  108. throw new ArgumentOutOfRangeException ("TableSection");
  109. ViewState ["TableSection"] = (int) value;
  110. tableRowSectionSet = true;
  111. TableRowCollection container = Container;
  112. if (container != null)
  113. container.RowTableSectionSet ();
  114. }
  115. }
  116. // inner class
  117. protected class CellControlCollection : ControlCollection {
  118. internal CellControlCollection (TableRow owner)
  119. : base (owner)
  120. {
  121. }
  122. public override void Add (Control child)
  123. {
  124. if (child == null)
  125. throw new NullReferenceException ("null");
  126. if (!(child is TableCell))
  127. throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance."));
  128. base.Add (child);
  129. }
  130. public override void AddAt (int index, Control child)
  131. {
  132. if (child == null)
  133. throw new NullReferenceException ("null");
  134. if (!(child is TableCell))
  135. throw new ArgumentException ("child", Locale.GetText ("Must be an TableCell instance."));
  136. base.AddAt (index, child);
  137. }
  138. }
  139. }
  140. }