TableLayoutSettings.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. //
  21. // Author:
  22. // Miguel de Icaza ([email protected])
  23. //
  24. // (C) 2004 Novell, Inc.
  25. //
  26. #if NET_2_0
  27. using System;
  28. using System.ComponentModel;
  29. using System.Collections;
  30. using System.Windows.Forms.Layout;
  31. namespace System.Windows.Forms {
  32. [Serializable]
  33. public sealed class TableLayoutSettings : LayoutSettings {
  34. //TableLayoutPanel panel;
  35. ColumnStyleCollection column_style;
  36. TableLayoutPanelGrowStyle grow_style;
  37. int column_count;
  38. int row_count;
  39. // Statics
  40. static LayoutEngine layout_engine = new TableLayout ();
  41. internal TableLayoutSettings (TableLayoutPanel panel)
  42. {
  43. //this.panel = panel;
  44. column_count = 0;
  45. row_count = 0;
  46. grow_style = TableLayoutPanelGrowStyle.AddRows;
  47. column_style = new ColumnStyleCollection (panel);
  48. }
  49. public int ColumnCount {
  50. get {
  51. return column_count;
  52. }
  53. set {
  54. column_count = value;
  55. }
  56. }
  57. public int RowCount {
  58. get {
  59. return row_count;
  60. }
  61. set {
  62. row_count = value;
  63. }
  64. }
  65. public TableLayoutPanelGrowStyle GrowStyle {
  66. get {
  67. return grow_style;
  68. }
  69. }
  70. public override LayoutEngine LayoutEngine {
  71. get {
  72. return layout_engine;
  73. }
  74. }
  75. public TableLayoutSettings.ColumnStyleCollection ColumnStyle {
  76. get {
  77. return column_style;
  78. }
  79. }
  80. public abstract class StyleCollection {
  81. ArrayList al = new ArrayList ();
  82. TableLayoutPanel table;
  83. internal StyleCollection (TableLayoutPanel table)
  84. {
  85. this.table = table;
  86. }
  87. public int Add (TableLayoutSettings.Style style)
  88. {
  89. return al.Add (style);
  90. }
  91. // FIXME; later this should be an override.
  92. public void Clear ()
  93. {
  94. al.Clear ();
  95. // FIXME: Need to investigate what happens when the style is gone.
  96. table.Relayout ();
  97. }
  98. #region IList methods
  99. //
  100. // The IList methods will later be implemeneted, this is to get us started
  101. //
  102. internal bool Contains (Style style)
  103. {
  104. return al.Contains (style);
  105. }
  106. internal int IndexOf (Style style)
  107. {
  108. return al.IndexOf (style);
  109. }
  110. internal void Insert (int index, Style style)
  111. {
  112. al.Insert (index, style);
  113. }
  114. internal void Remove (Style style)
  115. {
  116. al.Remove (style);
  117. }
  118. #endregion
  119. public Style this [int idx] {
  120. get {
  121. return (Style) al [idx];
  122. }
  123. set {
  124. al [idx] = value;
  125. }
  126. }
  127. }
  128. public class ColumnStyleCollection : StyleCollection {
  129. internal ColumnStyleCollection (TableLayoutPanel panel) : base (panel)
  130. {
  131. }
  132. public void Add (ColumnStyle style)
  133. {
  134. base.Add (style);
  135. }
  136. public bool Contains (ColumnStyle style)
  137. {
  138. return base.Contains (style);
  139. }
  140. public int IndexOf (ColumnStyle style)
  141. {
  142. return base.IndexOf (style);
  143. }
  144. public void Insert (int index, ColumnStyle style)
  145. {
  146. base.Insert (index, style);
  147. }
  148. public void Remove (ColumnStyle style)
  149. {
  150. base.Remove (style);
  151. }
  152. public new ColumnStyle this [int index] {
  153. get {
  154. return (ColumnStyle) base [index];
  155. }
  156. set {
  157. base [index] = value;
  158. }
  159. }
  160. }
  161. public class Style {
  162. internal SizeType size_type;
  163. public SizeType SizeType {
  164. get {
  165. return size_type;
  166. }
  167. set {
  168. size_type = value;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. #endif