PageRenderTime 23ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/src/wrappers/gtk/library/gtk_toolbar.e

http://github.com/tybor/Liberty
Specman e | 522 lines | 146 code | 154 blank | 222 comment | 2 complexity | 68430ed655b6ac756c316c4ef8c0cf78 MD5 | raw file
  1indexing
  2	description: "GtkToolbar -- Create bars of buttons and other widgets."
  3	copyright: "[
  4					Copyright (C) 2006 Paolo Redaelli, 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 hopeOA 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
 22class GTK_TOOLBAR
 23	-- A toolbar can contain instances of a subclass of GtkToolItem. To
 24	-- add a GtkToolItem to the a toolbar, use `insert_item'. To remove
 25	-- an item from the toolbar use GTK_CONTAINER's `remove'. To add a
 26	-- button to the toolbar, add an instance of GtkToolButton.
 27			
 28	-- Toolbar items can be visually grouped by adding instances of
 29	-- GtkSeparatorToolItem to the toolbar. If a GtkSeparatorToolItem
 30	-- has the "expand" property set to TRUE and the "draw" property
 31	-- set to FALSE the effect is to force all following items to the
 32	-- end of the toolbar.
 33	
 34	-- Creating a context menu for the toolbar can be done by
 35	-- connecting to the GtkToolbar::popup-context-menu signal.
 36
 37inherit
 38	GTK_CONTAINER
 39		rename
 40			style as container_style
 41			set_style as set_container_style
 42		end
 43
 44	-- TODO: GtkToolbar implements AtkImplementorIface.
 45
 46insert
 47	GTK_TOOLBAR_EXTERNALS
 48	GTK_ORIENTATION
 49	GTK_TOOLBAR_STYLE
 50
 51creation make, from_external_pointer
 52
 53feature {} -- Creation
 54
 55	make is
 56			-- Creates a new toolbar.
 57		do
 58			from_external_pointer (gtk_toolbar_new)
 59		end
 60
 61feature
 62	prepend (an_item: GTK_TOOL_ITEM) is
 63			-- Prepend `an_item' into Current toolbar to the start of
 64			-- the toolbar. 
 65		require item_not_void: an_item /= Void
 66		do
 67			gtk_toolbar_insert (handle, an_item.handle, 0)
 68		end
 69
 70	append (an_item: GTK_TOOL_ITEM) is
 71			-- Append `an_item' into Current toolbar to the end of the
 72			-- toolbar.
 73		require item_not_void: an_item /= Void
 74		do
 75			gtk_toolbar_insert (handle, an_item.handle, -1)
 76		end
 77
 78	insert_item (an_item: GTK_TOOL_ITEM; a_position: INTEGER) is
 79			-- Insert `an_item' into Current toolbar at `a_position'. If
 80			-- `a_position' is 0 `an_item' is prepended to the start of
 81			-- the toolbar. If 'a_position' is negative, the item is
 82			-- appended to the end of the toolbar.
 83
 84			-- TODO: provide prepend and append (pos<0 and pos=0)
 85			-- features
 86		require
 87			item_not_void: an_item /= Void
 88			valid_index: is_valid_index(a_position)
 89		do
 90			gtk_toolbar_insert (handle, an_item.handle, a_position)
 91		end
 92
 93	index_of (an_item: GTK_TOOL_ITEM): INTEGER is
 94			-- the position of `an_item' on the toolbar, starting from
 95			-- 0. It is an error if item is not a child of the toolbar.
 96		require
 97			item_not_void: an_item /= Void
 98			valid_item: -- TODO: an_item must be a child of Current toolbar
 99		do
100			Result := gtk_toolbar_get_item_index(handle,an_item.handle)
101		end
102
103	count: INTEGER is
104			-- the number of items on the toolbar.
105			
106			-- Note: C name of this feature is gtk_toolbar_get_n_items.
107		do
108			Result := gtk_toolbar_get_n_items(handle)
109		end
110
111	is_valid_index(an_index: INTEGER): BOOLEAN is
112			-- Is `an_index' valid to access GTK_TOOLBAR's items?.
113		do
114			Result:=(gtk_toolbar_get_nth_item(handle, an_index).is_not_null)
115		end
116	
117	item (an_index: INTEGER): GTK_TOOL_ITEM is
118			-- then item on toolbar at `an_index'; Void if `an_index' is
119			-- not valid.
120		local factory: G_OBJECT_EXPANDED_FACTORY[GTK_TOOL_ITEM]
121		do
122			Result := factory.wrapper_or_void (gtk_toolbar_get_nth_item(handle, an_index))
123		end
124
125	drop_index (an_x, an_y: INTEGER): INTEGER is
126			-- the position corresponding to the indicated point
127			-- (`an_x',`an_y') on toolbar. This is useful when dragging
128			-- items to the toolbar: this is the position a new item
129			-- should be inserted.
130		do
131			Result := gtk_toolbar_get_drop_index (handle, an_x,an_y)
132		end
133
134	set_drop_highlight_item (an_item: GTK_TOOL_ITEM; an_index: INTEGER) is
135			-- Highlights toolbar to give an idea of what it would look
136			-- like if item was added to toolbar at the position
137			-- indicated by `an_index'. 
138			
139			-- `an_item' must not be part of any widget hierarchy. When
140			-- an item is set as drop highlight item it can not added to
141			-- any widget hierarchy or used as highlight item for another
142			-- toolbar.
143		require
144			item_not_void: an_item /= Void
145			item_not_part_any_hierarchy: -- TODO 
146		do
147			gtk_toolbar_set_drop_highlight_item (handle, an_item.handle, an_index)
148		end
149
150	disable_highlighting is
151			-- Turn off highlighting during dropping.
152		do
153			gtk_toolbar_set_drop_highlight_item (handle, default_pointer, 0)
154		end
155
156	set_show_arrow (a_setting: BOOLEAN) is
157			-- Sets whether to show an overflow menu when toolbar doesn't
158			-- have room for all items on it. If TRUE, items that there
159			-- are not room are available through an overflow menu.
160		do
161			gtk_toolbar_set_show_arrow (handle, a_setting.to_integer)
162		end
163
164	set_orientation (an_orientation: INTEGER) is
165			-- Sets whether a toolbar should appear horizontally or
166			-- vertically.
167		require valid_orientation: is_valid_gtk_orientation (an_orientation)
168		do
169			gtk_toolbar_set_orientation (handle, an_orientation)
170		end
171
172	set_tooltips (a_setting: BOOLEAN) is
173			-- Sets if the tooltips of a toolbar should be active or
174			-- not. Set `a_setting' to False to disable the tooltips, or
175			-- True to enable them.
176		do
177			gtk_toolbar_set_tooltips(handle, a_setting.to_integer)
178		end
179
180	does_show_arrow: BOOLEAN is
181			-- Does the toolbar have an overflow menu?
182		do
183			Result:=(gtk_toolbar_get_show_arrow(handle).to_boolean)
184		end
185
186	orientation: INTEGER is
187			-- the current orientation of the toolbar.
188		do
189			Result := gtk_toolbar_get_orientation (handle)
190		ensure is_valid_orientation: is_valid_gtk_orientation(orientation)
191		end
192
193	style: INTEGER is
194			-- the current style of toolbar
195		do
196			Result:=gtk_toolbar_get_style(handle)
197		ensure is_valid_toolbar_style: is_valid_gtk_toolbar_style(Result)
198		end
199
200	icon_size: INTEGER is
201			-- the current icon size for the icons on the toolbar.
202		do
203			Result := gtk_toolbar_get_icon_size (handle)
204		ensure is_valid_icon_size: is_valid_gtk_icon_size (Result)
205		end
206
207	are_tooltips_enabled: BOOLEAN is
208			-- Are tooltips enabled?
209		do
210			Result := (gtk_toolbar_get_tooltips(handle).to_boolean)
211		end
212
213	relief_style: INTEGER is
214			-- The relief style of buttons on toolbar.
215		do
216			Result := gtk_toolbar_get_relief_style (handle)
217		ensure is_valid_relief_style: is_valid_gtk_relief_style (Result)
218		end
219
220	set_style (a_style: INTEGER) is
221			-- Alters the view of toolbar to display either icons only,
222			-- text only, or both.
223		require is_valid_relief_style: is_valid_gtk_relief_style (a_style)
224		do
225			gtk_toolbar_set_style (handle, a_style)
226		ensure set: relief_style = a_style
227		end
228
229	unset_style is
230			-- Unsets a toolbar style set with `set_style', so that user
231			-- preferences will be used to determine the toolbar style.
232		do
233			gtk_toolbar_unset_style (handle)
234		end
235
236feature -- Properties
237
238	--    "icon-size"            GtkIconSize           : Read / Write
239	--    "icon-size-set"        gboolean              : Read / Write
240	--    "orientation"          GtkOrientation        : Read / Write
241	--    "show-arrow"           gboolean              : Read / Write
242	--    "toolbar-style"        GtkToolbarStyle       : Read / Write
243	--    "tooltips"             gboolean              : Read / Write
244
245	-- Child Properties
246
247
248	--    "expand"               gboolean              : Read / Write
249	--    "homogeneous"          gboolean              : Read / Write
250
251	-- Style Properties
252
253
254	--    "button-relief"        GtkReliefStyle        : Read
255	--    "internal-padding"     gint                  : Read
256	--    "max-child-expand"     gint                  : Read
257	--    "shadow-type"          GtkShadowType         : Read
258	--    "space-size"           gint                  : Read
259	--    "space-style"          GtkToolbarSpaceStyle  : Read
260
261	-- Property Details
262
263	--   The "icon-size" property
264
265	--    "icon-size"            GtkIconSize           : Read / Write
266
267	--    The size of the icons in a toolbar is normally determined by the
268	--    toolbar-icon-size setting. When this property is set, it overrides the
269	--    setting.
270
271	--    This should only be used for special-purpose toolbars, normal application
272	--    toolbars should respect the user preferences for the size of icons.
273
274	--    Default value: GTK_ICON_SIZE_LARGE_TOOLBAR
275
276	--    Since 2.10
277
278	--    --------------------------------------------------------------------------
279
280	--   The "icon-size-set" property
281
282	--    "icon-size-set"        gboolean              : Read / Write
283
284	--    Is TRUE if the icon-size property has been set.
285
286	--    Default value: FALSE
287
288	--    Since 2.10
289
290	--    --------------------------------------------------------------------------
291
292	--   The "orientation" property
293
294	--    "orientation"          GtkOrientation        : Read / Write
295
296	--    The orientation of the toolbar.
297
298	--    Default value: GTK_ORIENTATION_HORIZONTAL
299
300	--    --------------------------------------------------------------------------
301
302	--   The "show-arrow" property
303
304	--    "show-arrow"           gboolean              : Read / Write
305
306	--    If an arrow should be shown if the toolbar doesn't fit.
307
308	--    Default value: TRUE
309
310	--    --------------------------------------------------------------------------
311
312	--   The "toolbar-style" property
313
314	--    "toolbar-style"        GtkToolbarStyle       : Read / Write
315
316	--    How to draw the toolbar.
317
318	--    Default value: GTK_TOOLBAR_ICONS
319
320	--    --------------------------------------------------------------------------
321
322	--   The "tooltips" property
323
324	--    "tooltips"             gboolean              : Read / Write
325
326	--    If the tooltips of the toolbar should be active or not.
327
328	--    Default value: TRUE
329
330	--    Since 2.8
331
332	-- Child Property Details
333
334	--   The "expand" child property
335
336	--    "expand"               gboolean              : Read / Write
337
338	--    Whether the item should receive extra space when the toolbar grows.
339
340	--    Default value: TRUE
341
342	--    --------------------------------------------------------------------------
343
344	--   The "homogeneous" child property
345
346	--    "homogeneous"          gboolean              : Read / Write
347
348	--    Whether the item should be the same size as other homogeneous items.
349
350	--    Default value: TRUE
351
352	-- Style Property Details
353
354	--   The "button-relief" style property
355
356	--    "button-relief"        GtkReliefStyle        : Read
357
358	--    Type of bevel around toolbar buttons.
359
360	--    Default value: GTK_RELIEF_NONE
361
362	--    --------------------------------------------------------------------------
363
364	--   The "internal-padding" style property
365
366	--    "internal-padding"     gint                  : Read
367
368	--    Amount of border space between the toolbar shadow and the buttons.
369
370	--    Allowed values: >= 0
371
372	--    Default value: 0
373
374	--    --------------------------------------------------------------------------
375
376	--   The "max-child-expand" style property
377
378	--    "max-child-expand"     gint                  : Read
379
380	--    Maximum amount of space an expandable item will be given.
381
382	--    Allowed values: >= 0
383
384	--    Default value: 2147483647
385
386	--    --------------------------------------------------------------------------
387
388	--   The "shadow-type" style property
389
390	--    "shadow-type"          GtkShadowType         : Read
391
392	--    Style of bevel around the toolbar.
393
394	--    Default value: GTK_SHADOW_OUT
395
396	--    --------------------------------------------------------------------------
397
398	--   The "space-size" style property
399
400	--    "space-size"           gint                  : Read
401
402	--    Size of spacers.
403
404	--    Allowed values: >= 0
405
406	--    Default value: 12
407
408	--    --------------------------------------------------------------------------
409
410	--   The "space-style" style property
411
412	--    "space-style"          GtkToolbarSpaceStyle  : Read
413
414	--    Whether spacers are vertical lines or just blank.
415
416	--    Default value: GTK_TOOLBAR_SPACE_LINE
417
418feature -- Signals
419
420	-- "focus-home-or-end" gboolean user_function (GtkToolbar *toolbar,
421	-- gboolean focus_home, gpointer user_data) : Run last / Action
422	
423	-- "move-focus" gboolean user_function (GtkToolbar *toolbar,
424	-- GtkDirectionType dir, gpointer user_data) : Run last / Action
425	
426	-- "orientation-changed" void user_function (GtkToolbar *toolbar,
427	-- GtkOrientation orientation, gpointer user_data) : Run first
428	
429	-- "popup-context-menu" gboolean user_function (GtkToolbar
430	-- *toolbar, gint x, gint y, gint button, gpointer user_data) : Run
431	-- last
432	
433	-- "style-changed" void user_function (GtkToolbar *toolbar,
434	-- GtkToolbarStyle style, gpointer user_data) : Run first
435
436	-- Signal Details
437
438	--   The "focus-home-or-end" signal
439
440	--  gboolean user_function (GtkToolbar *toolbar, gboolean
441	--  focus_home, gpointer user_data) : Run last / Action
442
443	-- A keybinding signal used internally by GTK+. This signal can't
444	-- be used in application code
445
446	--    toolbar :    the GtkToolbar which emitted the signal
447	--    focus_home : TRUE if the first item should be focused
448	--    user_data :  user data set when the signal handler was connected.
449	--    Returns :    TRUE if the signal was handled, FALSE if not
450
451	--   The "move-focus" signal
452
453	--  gboolean user_function (GtkToolbar *toolbar, GtkDirectionType
454	--  dir, gpointer user_data) : Run last / Action
455
456	--    A keybinding signal used internally by GTK+. This signal can't be used in
457	--    application code.
458
459	--    toolbar :   the GtkToolbar which emitted the signal
460	--    dir :       a GtkDirection
461	--    user_data : user data set when the signal handler was connected.
462	--    Returns :   TRUE if the signal was handled, FALSE if not
463
464	--   The "orientation-changed" signal
465
466	--  void user_function (GtkToolbar *toolbar, GtkOrientation
467	--  orientation, gpointer user_data) : Run first
468
469	--    Emitted when the orientation of the toolbar changes.
470
471	--    toolbar :     the object which emitted the signal
472	--    orientation : the new GtkOrientation of the toolbar
473	--    user_data :   user data set when the signal handler was connected.
474
475	--    --------------------------------------------------------------------------
476
477	--   The "popup-context-menu" signal
478
479	--  gboolean    user_function                  (GtkToolbar *toolbar,
480	--                                              gint        x,
481	--                                              gint        y,
482	--                                              gint        button,
483	--                                              gpointer    user_data)      : Run last
484
485	--    Emitted when the user right-clicks the toolbar or uses the keybinding to
486	--    display a popup menu.
487
488	--    Application developers should handle this signal if they want to display a
489	--    context menu on the toolbar. The context-menu should appear at the
490	--    coordinates given by x and y. The mouse button number is given by the
491	--    button parameter. If the menu was popped up using the keybaord, button is
492	--    -1.
493
494	--    toolbar :   the GtkToolbar which emitted the signal
495	--    x :         the x coordinate of the point where the menu should appear
496	--    y :         the y coordinate of the point where the menu should appear
497	--    button :    the mouse button the user pressed, or -1
498	--    user_data : user data set when the signal handler was connected.
499	--    Returns :   return TRUE if the signal was handled, FALSE if not
500
501	--    --------------------------------------------------------------------------
502
503	--   The "style-changed" signal
504
505	--  void        user_function                  (GtkToolbar     *toolbar,
506	--                                              GtkToolbarStyle style,
507	--                                              gpointer        user_data)      : Run first
508
509	--    Emitted when the style of the toolbar changes.
510
511	--    toolbar :   The GtkToolbar which emitted the signal
512	--    style :     the new GtkToolbarStyle of the toolbar
513	--    user_data : user data set when the signal handler was connected.
514
515feature -- size
516
517	struct_size: INTEGER is
518		external "C inline use <gtk/gtk.h>"
519		alias "sizeof(GtkToolbar)"
520		end
521
522end -- class GTK_TOOLBAR