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