PageRenderTime 21ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

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