TableLayoutSettings.cs 4.2 KB

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