/src/wrappers/gtk/library/gtk_box.e

http://github.com/tybor/Liberty · Specman e · 277 lines · 88 code · 60 blank · 129 comment · 1 complexity · 820c3c5f240e0c6caf9f129e6e7f5dd1 MD5 · raw file

  1. indexing
  2. description: "GtkBox - Base class for box containers."
  3. copyright: "(C) 2006 Paolo Redaelli "
  4. license: "LGPL v2 or later"
  5. date: "$Date:$"
  6. revision: "$Revision:$"
  7. deferred class GTK_BOX
  8. -- Gtkbox is an abstract widget which encapsulates functionallity
  9. -- for a particular kind of container, one that organizes a
  10. -- variable number of widgets into a rectangular area. GtkBox
  11. -- currently has two derived classes, GtkHBox and GtkVBox.
  12. -- The rectangular area of a GtkBox is organized into either a
  13. -- single row or a single column of child widgets depending upon
  14. -- whether the box is of type GtkHBox or GtkVBox,
  15. -- respectively. Thus, all children of a GtkBox are allocated one
  16. -- dimension in common, which is the height of a row, or the width
  17. -- of a column.
  18. -- GtkBox uses a notion of packing. Packing refers to adding
  19. -- widgets with reference to a particular position in a
  20. -- GtkContainer. For a GtkBox, there are two reference positions:
  21. -- the start and the end of the box. For a GtkVBox, the start is
  22. -- defined as the top of the box and the end is defined as the
  23. -- bottom. For a GtkHBox the start is defined as the left side and
  24. -- the end is defined as the right side.
  25. -- Use repeated calls to `pack_start' to pack widgets into a GtkBox
  26. -- from start to end. Use `pack_end' to add widgets from
  27. -- end to start. You may intersperse these calls and add widgets
  28. -- from both ends of the same GtkBox.
  29. -- Use `pack_start_defaults' or `pack_end_defaults' to pack widgets
  30. -- into a GtkBox if you do not need to specify the expand, fill, or
  31. -- padding attributes of the child to be added.
  32. -- Because GtkBox is a GtkContainer, you may also use `add' to
  33. -- insert widgets into the box, and they will be packed as if with
  34. -- `pack_start_defaults'. Use `remove' to remove widgets from the
  35. -- GtkBox.
  36. -- Use `set_homogeneous' and `unset_homogeneous' to specify whether
  37. -- or not all children of the GtkBox are forced to get the same
  38. -- amount of space.
  39. -- Use `set_spacing' to determine how much space will be minimally
  40. -- placed between all children in the GtkBox.
  41. -- Use `reorder_child' to move a GtkBox child to a different place
  42. -- in the box.
  43. -- Use `set_child_packing_start' and `set_child_packing_end' to
  44. -- reset the expand, fill, and padding attributes of any GtkBox
  45. -- child. Use `child_packing' to query these fields.
  46. inherit
  47. GTK_CONTAINER
  48. -- TODO: GtkBox implements AtkImplementorIface.
  49. insert GTK_BOX_EXTERNALS
  50. feature {} -- Hack to avoid warnings
  51. -- make_container is
  52. -- obsolete "Hack to avoid warnings. It will never be called"
  53. -- do
  54. -- check this_should_not_be_called: False end
  55. -- end
  56. feature
  57. pack_start (a_widget: GTK_WIDGET; expand,fill: BOOLEAN; a_padding: INTEGER) is
  58. -- Add `a_widget' to box, packed with reference to the start
  59. -- of box. The child is packed after any other child packed
  60. -- with reference to the start of box. When `expand' is True
  61. -- the new child is to be given extra space allocated to
  62. -- box. The extra space will be divided evenly between all
  63. -- children of box that use this option. When `fill' is True
  64. -- the space given to child by the expand option is actually
  65. -- allocated to child, rather than just padding it. This
  66. -- parameter has no effect if expand is set to False. A child
  67. -- is always allocated the full height of a GtkHBox and the
  68. -- full width of a GtkVBox. This option affects the other
  69. -- dimension. `padding' is the extra space in pixels to put
  70. -- between this child and its neighbors, over and above the
  71. -- global amount specified by spacing in GtkBox-struct. If
  72. -- child is a widget at one of the reference ends of box,
  73. -- then padding pixels are also put between child and the
  74. -- reference edge of box.
  75. require
  76. a_widget /= Void
  77. do
  78. gtk_box_pack_start (handle,a_widget.handle,
  79. expand.to_integer, fill.to_integer,
  80. a_padding);
  81. end
  82. pack_end (a_widget: GTK_WIDGET; expand,fill: BOOLEAN; a_padding: INTEGER) is
  83. -- Adds `a_widget' to box, packed with reference to the end
  84. -- of box. The child is packed after (away from end of) any
  85. -- other child packed with reference to the end of box. See pack_end
  86. require
  87. a_widget /= Void
  88. do
  89. gtk_box_pack_end (handle,a_widget.handle,
  90. expand.to_integer, fill.to_integer,
  91. a_padding);
  92. end
  93. pack_start_defaults (a_widget: GTK_WIDGET) is
  94. -- Add `a_widget' to box, packed with reference to the start
  95. -- of box. The child is packed after any other child packed
  96. -- with reference to the start of box. Parameters for how to
  97. -- pack the child widget, expand, fill, and padding in
  98. -- GtkBoxChild-struct, are given their default values, TRUE,
  99. -- TRUE, and 0, respectively.
  100. require
  101. a_widget /= Void
  102. do
  103. gtk_box_pack_start_defaults (handle, a_widget.handle)
  104. end
  105. pack_end_defaults (a_widget: GTK_WIDGET) is
  106. -- Add `a_widget' to box, packed with reference to the end
  107. -- of box. The child is packed after any other child packed
  108. -- with reference to the end of box. Parameters for how to
  109. -- pack the child widget, expand, fill, and padding in
  110. -- GtkBoxChild-struct, are given their default values, TRUE,
  111. -- TRUE, and 0, respectively.
  112. require
  113. a_widget /= Void
  114. do
  115. gtk_box_pack_end_defaults (handle, a_widget.handle)
  116. end
  117. is_homogeneous: BOOLEAN is
  118. -- Is the box homogeneous? It means that all children are the same size
  119. do
  120. Result:=(gtk_box_get_homogeneous(handle)).to_boolean
  121. end
  122. set_homogeneous is
  123. -- Give all children of box equal space in the box.
  124. do
  125. gtk_box_set_homogeneous (handle,1)
  126. end
  127. unset_homogeneous is
  128. -- Give children of box variable space in the box.
  129. do
  130. gtk_box_set_homogeneous (handle,0)
  131. end
  132. spacing: INTEGER is
  133. do
  134. Result:= gtk_box_get_spacing (handle)
  135. end
  136. set_spacing (a_spacing: INTEGER) is
  137. -- Sets the spacing field of GTK_BOX, which is the number of
  138. -- pixels to place between children of box.
  139. do
  140. gtk_box_set_spacing (handle,a_spacing)
  141. end
  142. reorder_child (a_child: GTK_WIDGET; a_position: INTEGER) is
  143. -- Moves `a_child' to a new position in the list of box
  144. -- children. The list is the children field of GtkBox-struct,
  145. -- and contains both widgets packed GTK_PACK_START as well as
  146. -- widgets packed GTK_PACK_END, in the order that these
  147. -- widgets were added to box. A widget's position in the box
  148. -- children list determines where the widget is packed into
  149. -- box. A child widget at some position in the list will be
  150. -- packed just after all other widgets of the same packing
  151. -- type that appear earlier in the list. `a_position' is the
  152. -- new position for child in the children list of
  153. -- GtkBox-struct, starting from 0. If negative, indicates the
  154. -- end of the list.
  155. require valid_child: a_child/=Void
  156. do
  157. gtk_box_reorder_child (handle, a_child.handle,a_position)
  158. end
  159. child_packing (a_child: GTK_WIDGET): TUPLE[BOOLEAN,BOOLEAN,INTEGER,INTEGER] is
  160. -- informations about how child is packed into box, with format
  161. -- [expand, fill, padding, pack_type]
  162. require valid_child: a_child/=Void
  163. local expand,fill: BOOLEAN; padding,pack_type: INTEGER
  164. do
  165. gtk_box_query_child_packing (handle,a_child.handle,
  166. $expand,$fill,$padding,$pack_type)
  167. Result := [expand,fill, padding,pack_type]
  168. ensure valid_packing: is_valid_gtk_pack_type (Result.item_4)
  169. end
  170. set_child_packing_start (a_child: GTK_WIDGET; expand,fill: BOOLEAN; a_padding: INTEGER) is
  171. -- Sets the way child is packed into box. From the start
  172. require valid_child: a_child/=Void
  173. do
  174. gtk_box_set_child_packing (handle, a_child.handle, expand.to_integer, fill.to_integer,
  175. a_padding, gtk_pack_start)
  176. end
  177. set_child_packing_end (a_child: GTK_WIDGET; expand,fill: BOOLEAN; a_padding: INTEGER) is
  178. -- Sets the way child is packed into box. From the end
  179. require valid_child: a_child/=Void
  180. do
  181. gtk_box_set_child_packing (handle, a_child.handle, expand.to_integer, fill.to_integer,
  182. a_padding, gtk_pack_end)
  183. end
  184. feature -- Property Details TODO
  185. -- The "homogeneous" property
  186. -- "homogeneous" gboolean : Read / Write
  187. -- Whether the children should all be the same size.
  188. -- Default value: FALSE
  189. -- The "spacing" property
  190. -- "spacing" gint : Read / Write
  191. -- The amount of space between children.
  192. -- Allowed values: >= 0
  193. -- Default value: 0
  194. -- Child Property Details
  195. -- The "expand" child property
  196. -- "expand" gboolean : Read / Write
  197. -- Whether the child should receive extra space when the parent grows.
  198. -- Default value: TRUE
  199. -- The "fill" child property
  200. -- "fill" gboolean : Read / Write
  201. -- Whether extra space given to the child should be allocated to the child or used as padding.
  202. -- Default value: TRUE
  203. -- The "pack-type" child property
  204. -- "pack-type" GtkPackType : Read / Write
  205. -- A GtkPackType indicating whether the child is packed with reference to the start or end of the parent.
  206. -- Default value: GTK_PACK_START
  207. -- The "padding" child property
  208. -- "padding" guint : Read / Write
  209. -- Extra space to put between the child and its neighbors, in pixels.
  210. -- Allowed values: <= G_MAXINT
  211. -- Default value: 0
  212. -- The "position" child property
  213. -- "position" gint : Read / Write
  214. -- The index of the child in the parent.
  215. -- Allowed values: >= -1
  216. -- Default value: 0
  217. end