/src/wrappers/gtk/library/gtk_table.e

http://github.com/tybor/Liberty · Specman e · 548 lines · 196 code · 151 blank · 201 comment · 2 complexity · dfee253b068be68c4c3da8f9aa91f37a MD5 · raw file

  1. indexing
  2. description: "GtkTable -- Pack widgets in regular patterns."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_TABLE
  21. -- The GTK_TABLE functions allow the programmer to arrange widgets in
  22. -- rows and columns, making it easy to align many widgets next to each
  23. -- other, horizontally and vertically.
  24. -- Tables are created with a call to `make,' the size of which
  25. -- can later be changed with `resize'.
  26. -- Widgets can be added to a table using `attach' or the more
  27. -- convenient (but slightly less flexible) `attach_defaults'.
  28. -- To alter the space next to a specific row, use `set_row_spacing'
  29. -- and for a column, `set_col_spacing'.
  30. -- The gaps between all rows or columns can be changed by calling
  31. -- `set_row_spacings' or `set_col_spacings' respectively.
  32. -- `set_homogeneous', can be used to set whether all cells in the
  33. -- table will resize themselves to the size of the largest widget
  34. -- in the table.
  35. -- TODO: provide access to underlying data, as described here: The
  36. -- GTK_TABLE structure holds the data for the actual table itself.
  37. -- children is a G_LIST of all the widgets the table contains. rows
  38. -- and columns are pointers to GTK_TABLE_ROW_COL structures, which
  39. -- contain the default spacing and expansion details for the
  40. -- GtkTable's rows and columns, respectively.
  41. -- nrows and ncols are 16bit integers storing the number of rows and
  42. -- columns the table has.
  43. -- See Also: GTK_HBOX and GTK_VBOX and for packing widgets
  44. -- horizontally and vertically only.
  45. -- TODO: wrap read-only access to the content of children, rows and
  46. -- columns fields of the GtkTable C structure.
  47. inherit GTK_CONTAINER -- rename make as make_c_struct end
  48. -- TODO: GtkTable implements AtkImplementorIface interface
  49. insert GTK_ATTACH_OPTIONS
  50. creation make, from_external_pointer
  51. feature {} -- Creation
  52. make (rows, columns: INTEGER; homogeneous: BOOLEAN) is
  53. -- Used to create a new table widget. An initial size must be given by
  54. -- specifying how many rows and columns the table should have, although
  55. -- this can be changed later with `resize'. rows and columns must both
  56. -- be in the range 0 .. 65535.
  57. -- rows : The number of rows the new table should have.
  58. -- columns : The number of columns the new table should have.
  59. -- homogeneous : If set to TRUE, all table cells are resized to the
  60. -- size of the cell containing the largest widget.
  61. -- Note: rows and columns shall be a NATURAL_16
  62. require
  63. gtk_initialized: gtk.is_initialized
  64. rows_fits_natural_16: rows.in_range (0,65535)
  65. columns_fits_natural_16: columns.in_range (0,65535)
  66. do
  67. handle :=gtk_table_new (rows, columns, homogeneous.to_integer)
  68. store_eiffel_wrapper
  69. end
  70. feature
  71. resize (rows, columns: INTEGER) is
  72. -- If you need to change a table's size after it has been created, this
  73. -- function allows you to do so.
  74. -- rows : The new number of rows.
  75. -- columns : The new number of columns.
  76. require
  77. rows_fits_natural_16: rows.in_range (0,65535)
  78. columns_fits_natural_16: columns.in_range (0,65535)
  79. do
  80. gtk_table_resize (handle, rows, columns)
  81. end
  82. attach (a_child: GTK_WIDGET; left_attach, right_attach, top_attach, bottom_attach: INTEGER;
  83. xoptions, yoptions: INTEGER; xpadding, ypadding: INTEGER) is
  84. -- Adds a widget to a table. The number of 'cells' that a widget will
  85. -- occupy is specified by left_attach, right_attach, top_attach and
  86. -- bottom_attach. These each represent the leftmost, rightmost,
  87. -- uppermost and lowest column and row numbers of the table. (Columns
  88. -- and rows are indexed from zero).
  89. -- `a_child': The widget to add.
  90. -- `left_attach': the column number to attach the left side of a child
  91. -- widget to.
  92. -- `right_attach': the column number to attach the right side of a
  93. -- child widget to.
  94. -- `top_attach': the row number to attach the top of a child widget to.
  95. -- `bottom_attach': the row number to attach the bottom of a child
  96. -- widget to.
  97. -- `xoptions' : Used to specify the properties of the child widget when
  98. -- the table is resized.
  99. -- `yoptions': The same as xoptions, except this field determines
  100. -- behaviour of vertical resizing.
  101. -- `xpadding': An integer value specifying the padding on the left and
  102. -- right of the widget being added to the table.
  103. -- `ypadding': The amount of padding above and below the child widget.
  104. require
  105. valid_child: a_child /= Void
  106. valid_x_options: are_valid_attach_options(xoptions)
  107. valid_y_options: are_valid_attach_options(yoptions)
  108. left_attach_fits_natural_16: left_attach.in_range (0,65535)
  109. right_attach_fits_natural_16: right_attach.in_range (0,65535)
  110. top_attach_fits_natural_16: top_attach.in_range (0,65535)
  111. bottom_attach_fits_natural_16: bottom_attach.in_range (0,65535)
  112. do
  113. gtk_table_attach (handle, a_child.handle,
  114. left_attach, right_attach, top_attach, bottom_attach,
  115. xoptions, yoptions,
  116. xpadding, ypadding)
  117. end
  118. attach_defaults (a_child: GTK_WIDGET; left_attach, right_attach, top_attach, bottom_attach: INTEGER) is
  119. -- As there are many options associated with `attach'), this
  120. -- convenience function provides the programmer with a means to add
  121. -- children to a table with identical padding and expansion
  122. -- options. The values used for the GtkAttachOptions are gtk_expand and
  123. -- gtk_fill, and the padding is set to 0.
  124. -- `a_child': The child widget to add.
  125. -- `left_attach': The column number to attach the left side of the
  126. -- child widget to.
  127. -- `right_attach': The column number to attach the right side of the
  128. -- child widget to.
  129. -- `top_attach': The row number to attach the top of the child widget
  130. -- to.
  131. -- `bottom_attach' : The row number to attach the bottom of the child
  132. -- widget to.
  133. require
  134. valid_child: a_child /= Void
  135. left_attach_fits_natural_16: left_attach.in_range (0,65535)
  136. right_attach_fits_natural_16: right_attach.in_range (0,65535)
  137. top_attach_fits_natural_16: top_attach.in_range (0,65535)
  138. bottom_attach_fits_natural_16: bottom_attach.in_range (0,65535)
  139. do
  140. gtk_table_attach_defaults (handle, a_child.handle,
  141. left_attach, right_attach, top_attach, bottom_attach)
  142. end
  143. set_row_spacing (a_row, a_spacing: INTEGER) is
  144. -- Changes the space between a given table row and its surrounding
  145. -- rows. `a_row': row number whose spacing will be
  146. -- changed. `a_spacing': number of pixels that the spacing should take
  147. -- up.
  148. require
  149. row_fits_natural_16: a_row.in_range (0,65535)
  150. spacing_fits_natural_16: a_spacing.in_range (0,65535)
  151. do
  152. gtk_table_set_row_spacing (handle, a_row, a_spacing)
  153. end
  154. set_col_spacing (a_column, a_spacing: INTEGER) is
  155. -- Alters the amount of space between a given table column and the
  156. -- adjacent columns.
  157. -- `a_column' : the column whose spacing should be changed.
  158. -- `a_spacing' : number of pixels that the spacing should take up.
  159. require
  160. column_fits_natural_16: a_column.in_range (0,65535)
  161. spacing_fits_natural_16: a_spacing.in_range (0,65535)
  162. do
  163. gtk_table_set_col_spacing (handle, a_column, a_spacing)
  164. end
  165. set_row_spacings (a_spacing: INTEGER) is
  166. -- Sets the space between every row in table equal to spacing.
  167. -- `a_spacing': the number of pixels of space to place between every
  168. -- row in the table.
  169. do
  170. gtk_table_set_row_spacings(handle, a_spacing)
  171. end
  172. set_col_spacings (a_spacing: INTEGER) is
  173. -- Sets the space between every column in table equal to spacing.
  174. -- `a_spacing': the number of pixels of space to place between every
  175. -- column in the table.
  176. do
  177. gtk_table_set_col_spacings(handle, a_spacing)
  178. end
  179. set_homogeneous is
  180. -- Ensure all table cells are the same size.
  181. do
  182. gtk_table_set_homogeneous (handle,1)
  183. ensure homogeneus: is_homogeneous
  184. end
  185. unset_homogeneous is
  186. -- Allow table cells to have different sizes.
  187. do
  188. gtk_table_set_homogeneous (handle,0)
  189. ensure unhomogeneus: not is_homogeneous
  190. end
  191. default_row_spacing: INTEGER is
  192. -- the default row spacing for the table. This is the spacing that will
  193. -- be used for newly added rows. (See `set_row_spacings').
  194. -- Note: should be NATURAL, perhaps even NATURAL_16, since it's a
  195. -- guint constrained to be in 0..65535 interval
  196. do
  197. Result:=gtk_table_get_default_row_spacing (handle)
  198. ensure fits_natural_16: Result.in_range(0,65535)
  199. end
  200. is_homogeneous: BOOLEAN is
  201. -- Are the table cells all constrained to the same width and height?
  202. -- (See `set_homogenous')
  203. do
  204. Result:=gtk_table_get_homogeneous(handle).to_boolean
  205. end
  206. row_spacing (a_row: INTEGER): INTEGER is
  207. -- The amount of space between `a_row', and its next row. See
  208. -- `set_row_spacing'. 0 indicates the first row
  209. -- Note: both a_row and Result shall be NATURAL since they're
  210. -- guint. Perhaps `a_row' shall be even NATURAL_16, since it
  211. -- should fit 0.65535
  212. require row_fits_natural_16: a_row.in_range (0,65535)
  213. do
  214. Result:=gtk_table_get_row_spacing (handle, a_row)
  215. ensure positive: Result>=0
  216. end
  217. col_spacing (a_column: INTEGER): INTEGER is
  218. -- The amount of space between `a_column', and its next row. See
  219. -- `set_row_spacing'. 0 indicates the first column
  220. -- Note: both a_column and Result shall be NATURAL since they're
  221. -- guint. Perhaps `a_column' shall be even NATURAL_16, since it
  222. -- should fit 0.65535
  223. require row_fits_natural_16: a_column.in_range (0,65535)
  224. do
  225. Result:=gtk_table_get_row_spacing (handle, a_column)
  226. ensure positive: Result>=0
  227. end
  228. default_col_spacing: INTEGER is
  229. -- The default column spacing for the table. This is the
  230. -- spacing that will be used for newly added columns. (See
  231. -- `set_col_spacings')
  232. do
  233. Result := gtk_table_get_default_col_spacing (handle)
  234. ensure positive: Result>=0
  235. end
  236. -- Properties
  237. -- "column-spacing" guint : Read / Write
  238. -- "homogeneous" gboolean : Read / Write
  239. -- "n-columns" guint : Read / Write
  240. -- "n-rows" guint : Read / Write
  241. -- "row-spacing" guint : Read / Write
  242. -- Child Properties
  243. -- "bottom-attach" guint : Read / Write
  244. -- "left-attach" guint : Read / Write
  245. -- "right-attach" guint : Read / Write
  246. -- "top-attach" guint : Read / Write
  247. -- "x-options" GtkAttachOptions : Read / Write
  248. -- "x-padding" guint : Read / Write
  249. -- "y-options" GtkAttachOptions : Read / Write
  250. -- "y-padding" guint : Read / Write
  251. -- Property Details
  252. -- The "column-spacing" property
  253. -- "column-spacing" guint : Read / Write
  254. -- The amount of space between two consecutive columns.
  255. -- Default value: 0
  256. -- --------------------------------------------------------------------------
  257. -- The "homogeneous" property
  258. -- "homogeneous" gboolean : Read / Write
  259. -- If TRUE this means the table cells are all the same width/height.
  260. -- Default value: FALSE
  261. -- --------------------------------------------------------------------------
  262. -- The "n-columns" property
  263. -- "n-columns" guint : Read / Write
  264. -- The number of columns in the table.
  265. -- Default value: 0
  266. -- --------------------------------------------------------------------------
  267. -- The "n-rows" property
  268. -- "n-rows" guint : Read / Write
  269. -- The number of rows in the table.
  270. -- Default value: 0
  271. -- --------------------------------------------------------------------------
  272. -- The "row-spacing" property
  273. -- "row-spacing" guint : Read / Write
  274. -- The amount of space between two consecutive rows.
  275. -- Default value: 0
  276. -- Child Property Details
  277. -- The "bottom-attach" child property
  278. -- "bottom-attach" guint : Read / Write
  279. -- The row number to attach the bottom of the child to.
  280. -- Allowed values: [1,65535]
  281. -- Default value: 1
  282. -- --------------------------------------------------------------------------
  283. -- The "left-attach" child property
  284. -- "left-attach" guint : Read / Write
  285. -- The column number to attach the left side of the child to.
  286. -- Allowed values: <= 65535
  287. -- Default value: 0
  288. -- --------------------------------------------------------------------------
  289. -- The "right-attach" child property
  290. -- "right-attach" guint : Read / Write
  291. -- The column number to attach the right side of a child widget to.
  292. -- Allowed values: [1,65535]
  293. -- Default value: 1
  294. -- --------------------------------------------------------------------------
  295. -- The "top-attach" child property
  296. -- "top-attach" guint : Read / Write
  297. -- The row number to attach the top of a child widget to.
  298. -- Allowed values: <= 65535
  299. -- Default value: 0
  300. -- --------------------------------------------------------------------------
  301. -- The "x-options" child property
  302. -- "x-options" GtkAttachOptions : Read / Write
  303. -- Options specifying the horizontal behaviour of the child.
  304. -- Default value: GTK_EXPAND|GTK_FILL
  305. -- --------------------------------------------------------------------------
  306. -- The "x-padding" child property
  307. -- "x-padding" guint : Read / Write
  308. -- Extra space to put between the child and its left and right neighbors, in
  309. -- pixels.
  310. -- Allowed values: <= 65535
  311. -- Default value: 0
  312. -- --------------------------------------------------------------------------
  313. -- The "y-options" child property
  314. -- "y-options" GtkAttachOptions : Read / Write
  315. -- Options specifying the vertical behaviour of the child.
  316. -- Default value: GTK_EXPAND|GTK_FILL
  317. -- --------------------------------------------------------------------------
  318. -- The "y-padding" child property
  319. -- "y-padding" guint : Read / Write
  320. -- Extra space to put between the child and its upper and lower neighbors, in
  321. -- pixels.
  322. -- Allowed values: <= 65535
  323. -- Default value: 0
  324. feature -- size
  325. struct_size: INTEGER is
  326. external "C inline use <gtk/gtk.h>"
  327. alias "sizeof(GtkTable)"
  328. end
  329. feature {} -- External calls
  330. -- #include <gtk/gtk.h>
  331. -- GtkTable;
  332. -- GtkTableChild;
  333. -- GtkTableRowCol;
  334. gtk_table_new (rows, columns, homogeneous: INTEGER): POINTER is -- GtkWidget*
  335. external "C use <gtk/gtk.h>"
  336. end
  337. gtk_table_resize (a_table: POINTER; rows, columns: INTEGER) is
  338. external "C use <gtk/gtk.h>"
  339. end
  340. gtk_table_attach (a_table, a_child: POINTER;
  341. left_attach, right_attach, top_attach, bottom_attach: INTEGER; -- Note those all all guint, therefore should be NATURAL
  342. xoptions, yoptions: INTEGER; -- GtkAttachOptions
  343. xpadding, ypadding: INTEGER -- Note: these are guint, therefore should be NATURAL
  344. ) is
  345. external "C use <gtk/gtk.h>"
  346. end
  347. gtk_table_attach_defaults (a_table: POINTER; a_widget: POINTER;
  348. left_attach, right_attach,
  349. top_attach, bottom_attach: INTEGER -- Note: these are guint, therefore should be NATURAL
  350. ) is
  351. external "C use <gtk/gtk.h>"
  352. end
  353. gtk_table_set_row_spacing (a_table: POINTER;
  354. a_row, a_spacing: INTEGER; -- shall be NATURAL, since they are guint
  355. ) is
  356. external "C use <gtk/gtk.h>"
  357. end
  358. gtk_table_set_col_spacing (a_table: POINTER;
  359. a_column, spacing: INTEGER; -- shall be NATURAL, since it's guint
  360. ) is
  361. external "C use <gtk/gtk.h>"
  362. end
  363. gtk_table_set_row_spacings (a_table: POINTER;
  364. a_spacing: INTEGER; -- shall be NATURAL, since it's guint
  365. ) is
  366. external "C use <gtk/gtk.h>"
  367. end
  368. gtk_table_set_col_spacings (a_table: POINTER;
  369. a_spacing: INTEGER; -- shall be NATURAL, since it's guint
  370. ) is
  371. external "C use <gtk/gtk.h>"
  372. end
  373. gtk_table_set_homogeneous (a_table: POINTER;
  374. homogeneous: INTEGER -- gboolean
  375. ) is
  376. external "C use <gtk/gtk.h>"
  377. end
  378. gtk_table_get_default_row_spacing (a_table: POINTER): INTEGER is -- guint
  379. external "C use <gtk/gtk.h>"
  380. end
  381. gtk_table_get_homogeneous (a_table: POINTER): INTEGER is -- gboolean
  382. external "C use <gtk/gtk.h>"
  383. end
  384. gtk_table_get_row_spacing (a_table: POINTER;
  385. a_row: INTEGER; -- shall be NATURAL, since it's guint
  386. ): INTEGER is -- guint
  387. external "C use <gtk/gtk.h>"
  388. end
  389. gtk_table_get_col_spacing (a_table: POINTER;
  390. a_column: INTEGER; -- shall be NATURAL, since it's guint
  391. ): INTEGER is -- guint
  392. external "C use <gtk/gtk.h>"
  393. end
  394. gtk_table_get_default_col_spacing (a_table: POINTER): INTEGER is -- guint
  395. external "C use <gtk/gtk.h>"
  396. end
  397. end