TableLayout.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. //
  2. // TableLayout.cs
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. // Copyright (c) 2006 Jonathan Pobst
  24. //
  25. // Authors:
  26. // Jonathan Pobst ([email protected])
  27. //
  28. #undef TABLE_DEBUG
  29. using System;
  30. using System.Drawing;
  31. namespace System.Windows.Forms.Layout
  32. {
  33. internal class TableLayout : LayoutEngine
  34. {
  35. private static Control dummy_control = new Control ("Dummy"); // Used as a placeholder for row/col spans
  36. public TableLayout () : base ()
  37. {
  38. }
  39. public override void InitLayout (object child, BoundsSpecified specified)
  40. {
  41. base.InitLayout (child, specified);
  42. }
  43. // There are 3 steps to doing a table layout:
  44. // 1) Figure out which row/column each control goes into
  45. // 2) Figure out the sizes of each row/column
  46. // 3) Size and position each control
  47. public override bool Layout (object container, LayoutEventArgs args)
  48. {
  49. TableLayoutPanel panel = container as TableLayoutPanel;
  50. TableLayoutSettings settings = panel.LayoutSettings;
  51. #if TABLE_DEBUG
  52. Console.WriteLine ("Beginning layout on panel: {0}, control count: {1}, col/row count: {2}x{3}", panel.Name, panel.Controls.Count, settings.ColumnCount, settings.RowCount);
  53. #endif
  54. // STEP 1:
  55. // - Figure out which row/column each control goes into
  56. // - Store data in the TableLayoutPanel.actual_positions
  57. panel.actual_positions = CalculateControlPositions (panel, Math.Max (settings.ColumnCount, 1), Math.Max (settings.RowCount, 1));
  58. // STEP 2:
  59. // - Figure out the sizes of each row/column
  60. // - Store data in the TableLayoutPanel.widths/heights
  61. CalculateColumnRowSizes (panel, panel.actual_positions.GetLength (0), panel.actual_positions.GetLength (1));
  62. // STEP 3:
  63. // - Size and position each control
  64. LayoutControls(panel);
  65. #if TABLE_DEBUG
  66. Console.WriteLine ("-- CalculatedPositions:");
  67. OutputControlGrid (panel.actual_positions, panel);
  68. Console.WriteLine ("Finished layout on panel: {0}", panel.Name);
  69. Console.WriteLine ();
  70. #endif
  71. return false;
  72. }
  73. internal Control[,] CalculateControlPositions (TableLayoutPanel panel, int columns, int rows)
  74. {
  75. Control[,] grid = new Control[columns, rows];
  76. TableLayoutSettings settings = panel.LayoutSettings;
  77. // First place all controls that have an explicit col/row
  78. foreach (Control c in panel.Controls) {
  79. int col = settings.GetColumn (c);
  80. int row = settings.GetRow (c);
  81. if (col >= 0 && row >= 0) {
  82. if (col >= columns)
  83. return CalculateControlPositions (panel, col + 1, rows);
  84. if (row >= rows)
  85. return CalculateControlPositions (panel, columns, row + 1);
  86. if (grid[col, row] == null) {
  87. int col_span = Math.Min (settings.GetColumnSpan (c), columns);
  88. int row_span = Math.Min (settings.GetRowSpan (c), rows);
  89. if (col + col_span > columns) {
  90. if (row + 1 < rows) {
  91. grid[col, row] = dummy_control;
  92. row++;
  93. col = 0;
  94. }
  95. else if (settings.GrowStyle == TableLayoutPanelGrowStyle.AddColumns)
  96. return CalculateControlPositions (panel, columns + 1, rows);
  97. else
  98. throw new ArgumentException ();
  99. }
  100. if (row + row_span > rows) {
  101. if (settings.GrowStyle == TableLayoutPanelGrowStyle.AddRows)
  102. return CalculateControlPositions (panel, columns, rows + 1);
  103. else
  104. throw new ArgumentException ();
  105. }
  106. grid[col, row] = c;
  107. // Fill in the rest of this control's row/column extent with dummy
  108. // controls, so that other controls don't get put there.
  109. for (int i = 0; i < col_span; i++)
  110. for (int j = 0; j < row_span; j++)
  111. if (i != 0 || j != 0)
  112. grid[col + i, row + j] = dummy_control;
  113. }
  114. }
  115. }
  116. int x_pointer = 0;
  117. int y_pointer = 0;
  118. // Fill in gaps with controls that do not have an explicit col/row
  119. foreach (Control c in panel.Controls) {
  120. int col = settings.GetColumn (c);
  121. int row = settings.GetRow (c);
  122. if ((col >= 0 && col < columns) && (row >= 0 && row < rows) && (grid[col, row] == c || grid[col, row] == dummy_control))
  123. continue;
  124. for (int y = y_pointer; y < rows; y++) {
  125. y_pointer = y;
  126. x_pointer = 0;
  127. for (int x = x_pointer; x < columns; x++) {
  128. x_pointer = x;
  129. if (grid[x, y] == null) {
  130. int col_span = Math.Min (settings.GetColumnSpan (c), columns);
  131. int row_span = Math.Min (settings.GetRowSpan (c), rows);
  132. if (x + col_span > columns) {
  133. if (y + 1 < rows)
  134. break;
  135. else if (settings.GrowStyle == TableLayoutPanelGrowStyle.AddColumns)
  136. return CalculateControlPositions (panel, columns + 1, rows);
  137. else
  138. throw new ArgumentException ();
  139. }
  140. if (y + row_span > rows) {
  141. if (x + 1 < columns)
  142. break;
  143. else if (settings.GrowStyle == TableLayoutPanelGrowStyle.AddRows)
  144. return CalculateControlPositions (panel, columns, rows + 1);
  145. else
  146. throw new ArgumentException ();
  147. }
  148. grid[x, y] = c;
  149. // Fill in the rest of this control's row/column extent with dummy
  150. // controls, so that other controls don't get put there.
  151. for (int i = 0; i < col_span; i++)
  152. for (int j = 0; j < row_span; j++)
  153. if (i != 0 || j != 0)
  154. grid[x + i, y + j] = dummy_control;
  155. // I know someone will kill me for using a goto, but
  156. // sometimes they really are the easiest way...
  157. goto Found;
  158. } else {
  159. // MS adds the controls only to the first row if
  160. // GrowStyle is AddColumns and RowCount is 0,
  161. // so interrupt the search for a free horizontal cell
  162. // beyond the first one in the given vertical
  163. if (settings.GrowStyle == TableLayoutPanelGrowStyle.AddColumns &&
  164. settings.RowCount == 0)
  165. break;
  166. }
  167. }
  168. }
  169. // MS adds rows instead of columns even when GrowStyle is AddColumns,
  170. // but RowCount is 0.
  171. TableLayoutPanelGrowStyle adjustedGrowStyle = settings.GrowStyle;
  172. if (settings.GrowStyle == TableLayoutPanelGrowStyle.AddColumns) {
  173. if (settings.RowCount == 0)
  174. adjustedGrowStyle = TableLayoutPanelGrowStyle.AddRows;
  175. }
  176. switch (adjustedGrowStyle) {
  177. case TableLayoutPanelGrowStyle.AddColumns:
  178. return CalculateControlPositions (panel, columns + 1, rows);
  179. case TableLayoutPanelGrowStyle.AddRows:
  180. default:
  181. return CalculateControlPositions (panel, columns, rows + 1);
  182. case TableLayoutPanelGrowStyle.FixedSize:
  183. throw new ArgumentException ();
  184. }
  185. Found: ;
  186. }
  187. return grid;
  188. }
  189. private void CalculateColumnRowSizes (TableLayoutPanel panel, int columns, int rows)
  190. {
  191. TableLayoutSettings settings = panel.LayoutSettings;
  192. panel.column_widths = new int[panel.actual_positions.GetLength (0)];
  193. panel.row_heights = new int[panel.actual_positions.GetLength (1)];
  194. int border_width = TableLayoutPanel.GetCellBorderWidth (panel.CellBorderStyle);
  195. Rectangle parentDisplayRectangle = panel.DisplayRectangle;
  196. TableLayoutColumnStyleCollection col_styles = new TableLayoutColumnStyleCollection (panel);
  197. foreach (ColumnStyle cs in settings.ColumnStyles)
  198. col_styles.Add( new ColumnStyle(cs.SizeType, cs.Width));
  199. TableLayoutRowStyleCollection row_styles = new TableLayoutRowStyleCollection (panel);
  200. foreach (RowStyle rs in settings.RowStyles)
  201. row_styles.Add (new RowStyle (rs.SizeType, rs.Height));
  202. // If we have more columns than columnstyles, temporarily add enough columnstyles
  203. if (columns > col_styles.Count)
  204. {
  205. for (int i = col_styles.Count; i < columns; i++)
  206. col_styles.Add(new ColumnStyle());
  207. }
  208. // Same for rows..
  209. if (rows > row_styles.Count)
  210. {
  211. for (int i = row_styles.Count; i < rows; i++)
  212. row_styles.Add (new RowStyle ());
  213. }
  214. while (row_styles.Count > rows)
  215. row_styles.RemoveAt (row_styles.Count - 1);
  216. while (col_styles.Count > columns)
  217. col_styles.RemoveAt (col_styles.Count - 1);
  218. // Find the largest column-span/row-span values.
  219. int max_colspan = 0, max_rowspan = 0;
  220. foreach (Control c in panel.Controls) {
  221. max_colspan = Math.Max (max_colspan, settings.GetColumnSpan (c));
  222. max_rowspan = Math.Max (max_rowspan, settings.GetRowSpan (c));
  223. }
  224. // Figure up all the column widths
  225. int total_width = parentDisplayRectangle.Width - (border_width * (columns + 1));
  226. int index = 0;
  227. // First assign all the Absolute sized columns..
  228. foreach (ColumnStyle cs in col_styles) {
  229. if (cs.SizeType == SizeType.Absolute) {
  230. panel.column_widths[index] = (int)cs.Width;
  231. total_width -= (int)cs.Width;
  232. }
  233. index++;
  234. }
  235. // Next, assign all the AutoSize columns to the width of their widest
  236. // control. If the table-layout is auto-sized, then make sure that
  237. // no column with Percent styling clips its contents.
  238. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx)
  239. for (int colspan = 0; colspan < max_colspan; ++colspan)
  240. {
  241. for (index = colspan; index < col_styles.Count - colspan; ++index)
  242. {
  243. ColumnStyle cs = col_styles[index];
  244. if (cs.SizeType == SizeType.AutoSize
  245. || (panel.AutoSize && cs.SizeType == SizeType.Percent))
  246. {
  247. int max_width = panel.column_widths[index];
  248. // Find the widest control in the column
  249. for (int i = 0; i < rows; i ++)
  250. {
  251. Control c = panel.actual_positions[index - colspan, i];
  252. if (c != null && c != dummy_control && c.VisibleInternal)
  253. {
  254. // Skip any controls not being sized in this pass.
  255. if (settings.GetColumnSpan (c) != colspan + 1)
  256. continue;
  257. // Calculate the maximum control width.
  258. if (c.AutoSize)
  259. max_width = Math.Max (max_width, c.PreferredSize.Width + c.Margin.Horizontal);
  260. else
  261. max_width = Math.Max (max_width, c.ExplicitBounds.Width + c.Margin.Horizontal);
  262. max_width = Math.Max (max_width, c.Width + c.Margin.Left + c.Margin.Right);
  263. }
  264. }
  265. // Subtract the width of prior columns, if any.
  266. for (int i = Math.Max (index - colspan, 0); i < index; ++i)
  267. max_width -= panel.column_widths[i];
  268. // If necessary, increase this column's width.
  269. if (max_width > panel.column_widths[index])
  270. {
  271. max_width -= panel.column_widths[index];
  272. panel.column_widths[index] += max_width;
  273. total_width -= max_width;
  274. }
  275. }
  276. }
  277. }
  278. index = 0;
  279. float total_percent = 0;
  280. // Finally, assign the remaining space to Percent columns, if any.
  281. if (total_width > 0)
  282. {
  283. int percent_width = total_width;
  284. // Find the total percent (not always 100%)
  285. foreach (ColumnStyle cs in col_styles)
  286. {
  287. if (cs.SizeType == SizeType.Percent)
  288. total_percent += cs.Width;
  289. }
  290. // Divvy up the space..
  291. foreach (ColumnStyle cs in col_styles)
  292. {
  293. if (cs.SizeType == SizeType.Percent)
  294. {
  295. int width_change = (int)(((cs.Width / total_percent) * percent_width)
  296. - panel.column_widths[index]);
  297. if (width_change > 0)
  298. {
  299. panel.column_widths[index] += width_change;
  300. total_width -= width_change;
  301. }
  302. }
  303. index++;
  304. }
  305. }
  306. if (total_width > 0)
  307. {
  308. // Find the last column that isn't an Absolute SizeType, and give it
  309. // all this free space. (Absolute sized columns need to retain their
  310. // absolute width if at all possible!)
  311. int col = col_styles.Count - 1;
  312. for (; col >= 0; --col)
  313. {
  314. if (col_styles[col].SizeType != SizeType.Absolute)
  315. break;
  316. }
  317. if (col < 0)
  318. col = col_styles.Count - 1;
  319. panel.column_widths[col] += total_width;
  320. }
  321. // Figure up all the row heights
  322. int total_height = parentDisplayRectangle.Height - (border_width * (rows + 1));
  323. index = 0;
  324. // First assign all the Absolute sized rows..
  325. foreach (RowStyle rs in row_styles) {
  326. if (rs.SizeType == SizeType.Absolute) {
  327. panel.row_heights[index] = (int)rs.Height;
  328. total_height -= (int)rs.Height;
  329. }
  330. index++;
  331. }
  332. index = 0;
  333. // Next, assign all the AutoSize rows to the height of their tallest
  334. // control. If the table-layout is auto-sized, then make sure that
  335. // no row with Percent styling clips its contents.
  336. // (per http://msdn.microsoft.com/en-us/library/ms171690.aspx)
  337. for (int rowspan = 0; rowspan < max_rowspan; ++rowspan)
  338. {
  339. for (index = rowspan; index < row_styles.Count - rowspan; ++index)
  340. {
  341. RowStyle rs = row_styles[index];
  342. if (rs.SizeType == SizeType.AutoSize
  343. || (panel.AutoSize && rs.SizeType == SizeType.Percent))
  344. {
  345. int max_height = panel.row_heights[index];
  346. // Find the tallest control in the row
  347. for (int i = 0; i < columns; i++) {
  348. Control c = panel.actual_positions[i, index - rowspan];
  349. if (c != null && c != dummy_control && c.VisibleInternal)
  350. {
  351. // Skip any controls not being sized in this pass.
  352. if (settings.GetRowSpan (c) != rowspan + 1)
  353. continue;
  354. // Calculate the maximum control height.
  355. if (c.AutoSize)
  356. max_height = Math.Max (max_height, c.PreferredSize.Height + c.Margin.Vertical);
  357. else
  358. max_height = Math.Max (max_height, c.ExplicitBounds.Height + c.Margin.Vertical);
  359. max_height = Math.Max (max_height, c.Height + c.Margin.Top + c.Margin.Bottom);
  360. }
  361. }
  362. // Subtract the height of prior rows, if any.
  363. for (int i = Math.Max (index - rowspan, 0); i < index; ++i)
  364. max_height -= panel.row_heights[i];
  365. // If necessary, increase this row's height.
  366. if (max_height > panel.row_heights[index])
  367. {
  368. max_height -= panel.row_heights[index];
  369. panel.row_heights[index] += max_height;
  370. total_height -= max_height;
  371. }
  372. }
  373. }
  374. }
  375. index = 0;
  376. total_percent = 0;
  377. // Finally, assign the remaining space to Percent rows, if any.
  378. if (total_height > 0) {
  379. int percent_height = total_height;
  380. // Find the total percent (not always 100%)
  381. foreach (RowStyle rs in row_styles) {
  382. if (rs.SizeType == SizeType.Percent)
  383. total_percent += rs.Height;
  384. }
  385. // Divvy up the space..
  386. foreach (RowStyle rs in row_styles) {
  387. if (rs.SizeType == SizeType.Percent) {
  388. int height_change = (int)(((rs.Height / total_percent) * percent_height)
  389. - panel.row_heights[index]);
  390. if (height_change > 0)
  391. {
  392. panel.row_heights[index] += height_change;
  393. total_height -= height_change;
  394. }
  395. }
  396. index++;
  397. }
  398. }
  399. if (total_height > 0)
  400. {
  401. // Find the last row that isn't an Absolute SizeType, and give it
  402. // all this free space. (Absolute sized rows need to retain their
  403. // absolute height if at all possible!)
  404. int row = row_styles.Count - 1;
  405. for (; row >= 0; --row)
  406. {
  407. if (row_styles[row].SizeType != SizeType.Absolute)
  408. break;
  409. }
  410. if (row < 0)
  411. row = row_styles.Count - 1;
  412. panel.row_heights[row] += total_height;
  413. }
  414. }
  415. private void LayoutControls (TableLayoutPanel panel)
  416. {
  417. TableLayoutSettings settings = panel.LayoutSettings;
  418. int border_width = TableLayoutPanel.GetCellBorderWidth (panel.CellBorderStyle);
  419. int columns = panel.actual_positions.GetLength(0);
  420. int rows = panel.actual_positions.GetLength(1);
  421. Point current_pos = new Point (panel.DisplayRectangle.Left + border_width, panel.DisplayRectangle.Top + border_width);
  422. for (int y = 0; y < rows; y++)
  423. {
  424. for (int x = 0; x < columns; x++)
  425. {
  426. Control c = panel.actual_positions[x,y];
  427. if(c != null && c != dummy_control) {
  428. Size preferred;
  429. if (c.AutoSize)
  430. preferred = c.PreferredSize;
  431. else
  432. preferred = c.ExplicitBounds.Size;
  433. int new_x = 0;
  434. int new_y = 0;
  435. int new_width = 0;
  436. int new_height = 0;
  437. // Figure out the width of the control
  438. int column_width = panel.column_widths[x];
  439. for (int i = 1; i < Math.Min (settings.GetColumnSpan(c), panel.column_widths.Length); i++)
  440. column_width += panel.column_widths[x + i];
  441. if (c.Dock == DockStyle.Fill || c.Dock == DockStyle.Top || c.Dock == DockStyle.Bottom || ((c.Anchor & AnchorStyles.Left) == AnchorStyles.Left && (c.Anchor & AnchorStyles.Right) == AnchorStyles.Right))
  442. new_width = column_width - c.Margin.Left - c.Margin.Right;
  443. else
  444. new_width = Math.Min (preferred.Width, column_width - c.Margin.Left - c.Margin.Right);
  445. // Figure out the height of the control
  446. int column_height = panel.row_heights[y];
  447. for (int i = 1; i < Math.Min (settings.GetRowSpan (c), panel.row_heights.Length); i++)
  448. column_height += panel.row_heights[y + i];
  449. if (c.Dock == DockStyle.Fill || c.Dock == DockStyle.Left || c.Dock == DockStyle.Right || ((c.Anchor & AnchorStyles.Top) == AnchorStyles.Top && (c.Anchor & AnchorStyles.Bottom) == AnchorStyles.Bottom))
  450. new_height = column_height - c.Margin.Top - c.Margin.Bottom;
  451. else
  452. new_height = Math.Min (preferred.Height, column_height - c.Margin.Top - c.Margin.Bottom);
  453. // Figure out the left location of the control
  454. if (c.Dock == DockStyle.Left || c.Dock == DockStyle.Fill || (c.Anchor & AnchorStyles.Left) == AnchorStyles.Left)
  455. new_x = current_pos.X + c.Margin.Left;
  456. else if (c.Dock == DockStyle.Right || (c.Anchor & AnchorStyles.Right) == AnchorStyles.Right)
  457. new_x = (current_pos.X + column_width) - new_width - c.Margin.Right;
  458. else // (center control)
  459. new_x = (current_pos.X + (column_width - c.Margin.Left - c.Margin.Right) / 2) + c.Margin.Left - (new_width / 2);
  460. // Figure out the top location of the control
  461. if (c.Dock == DockStyle.Top || c.Dock == DockStyle.Fill || (c.Anchor & AnchorStyles.Top) == AnchorStyles.Top)
  462. new_y = current_pos.Y + c.Margin.Top;
  463. else if (c.Dock == DockStyle.Bottom || (c.Anchor & AnchorStyles.Bottom) == AnchorStyles.Bottom)
  464. new_y = (current_pos.Y + column_height) - new_height - c.Margin.Bottom;
  465. else // (center control)
  466. new_y = (current_pos.Y + (column_height - c.Margin.Top - c.Margin.Bottom) / 2) + c.Margin.Top - (new_height / 2);
  467. c.SetBoundsInternal (new_x, new_y, new_width, new_height, BoundsSpecified.None);
  468. }
  469. current_pos.Offset (panel.column_widths[x] + border_width, 0);
  470. }
  471. current_pos.Offset ((-1 * current_pos.X) + border_width + panel.DisplayRectangle.Left, panel.row_heights[y] + border_width);
  472. }
  473. }
  474. #if TABLE_DEBUG
  475. private void OutputControlGrid (Control[,] grid, TableLayoutPanel panel)
  476. {
  477. Console.WriteLine (" Size: {0}x{1}", grid.GetLength (0), grid.GetLength (1));
  478. Console.Write (" ");
  479. foreach (int i in panel.column_widths)
  480. Console.Write (" {0}px ", i.ToString ().PadLeft (3));
  481. Console.WriteLine ();
  482. for (int y = 0; y < grid.GetLength (1); y++) {
  483. Console.Write (" {0}px |", panel.row_heights[y].ToString ().PadLeft (3));
  484. for (int x = 0; x < grid.GetLength (0); x++) {
  485. if (grid[x, y] == null)
  486. Console.Write (" --- |");
  487. else if (string.IsNullOrEmpty (grid[x, y].Name))
  488. Console.Write (" ??? |");
  489. else
  490. Console.Write (" {0} |", grid[x, y].Name.PadRight (5).Substring (0, 5));
  491. }
  492. Console.WriteLine ();
  493. }
  494. }
  495. #endif
  496. }
  497. }