1
-----------------------------------------------------------------------
2
-- GtkAda - Ada95 binding for Gtk+/Gnome --
4
-- Copyright (C) 2006-2007 AdaCore --
6
-- This library is free software; you can redistribute it and/or --
7
-- modify it under the terms of the GNU General Public --
8
-- License as published by the Free Software Foundation; either --
9
-- version 2 of the License, or (at your option) any later version. --
11
-- This library is distributed in the hope that it will be useful, --
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
14
-- General Public License for more details. --
16
-- You should have received a copy of the GNU General Public --
17
-- License along with this library; if not, write to the --
18
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
19
-- Boston, MA 02111-1307, USA. --
21
-----------------------------------------------------------------------
24
-- Gtk_Icon_View provides an alternative view on a list model. It displays the
25
-- model as a grid of icons with labels. Like Gtk_Tree_View, it allows to
26
-- select one or multiple items (depending on the selection mode, see
27
-- Set_Selection_Mode). In addition to selection with the arrow keys,
28
-- Gtk_Icon_View supports rubberband selection, which is controlled by
29
-- dragging the pointer.
31
-- <c_version>2.8.17</c_version>
32
-- <group>Trees and Lists</group>
33
-- <screenshot>icon-view</screenshot>
34
-- <testgtk>create_icon_view.adb</testgtk>
42
with Gtk.Cell_Renderer;
48
package Gtk.Icon_View is
50
type Gtk_Icon_View_Record is new Gtk.Container.Gtk_Container_Record with
52
type Gtk_Icon_View is access all Gtk_Icon_View_Record'Class;
54
type Gtk_Icon_View_Drop_Position is
61
-- An enum for determining where a dropped item goes.
62
-- If Drop_Into, then the drop item replaces the item.
64
procedure Gtk_New (Icon_View : out Gtk_Icon_View);
65
procedure Initialize (Icon_View : access Gtk_Icon_View_Record'Class);
66
-- Creates a new Gtk_Icon_View widget
68
procedure Gtk_New_With_Model
69
(Icon_View : out Gtk_Icon_View;
70
Model : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class);
71
procedure Initialize_With_Model
72
(Icon_View : access Gtk_Icon_View_Record'Class;
73
Model : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class);
74
-- Creates a new Gtk_Icon_View widget with the model Model.
76
function Get_Type return GType;
77
-- Return the internal type used for a Gtk_Icon_View.
79
procedure Set_Column_Spacing
80
(Icon_View : access Gtk_Icon_View_Record;
81
Column_Spacing : Glib.Gint);
82
function Get_Column_Spacing
83
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
84
-- Sets the ::column-spacing property which specifies the space
85
-- which is inserted between the columns of the icon view.
88
(Icon_View : access Gtk_Icon_View_Record;
91
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
92
-- Sets the ::columns property which determines in how many columns the
93
-- icons are arranged. If Columns is -1, the number of columns will be
94
-- chosen automatically to fill the available area.
97
(Icon_View : access Gtk_Icon_View_Record;
98
Path : Gtk.Tree_Model.Gtk_Tree_Path;
99
Cell : Gtk.Cell_Renderer.Gtk_Cell_Renderer := null;
100
Start_Editing : Boolean := False);
101
-- Sets the current keyboard focus to be at Path, and selects it. This is
102
-- useful when you want to focus the user's attention on a particular item.
103
-- If Cell is not null, then focus is given to the cell specified by it.
104
-- Additionally, if Start_Editing is True, then editing should be started
105
-- in the specified cell.
107
-- This function is often followed by Grab_Focus in order to give keyboard
108
-- focus to the widget. Please note that editing can only happen when the
109
-- widget is realized.
112
(Icon_View : access Gtk_Icon_View_Record;
113
Path : out Gtk.Tree_Model.Gtk_Tree_Path;
114
Cell : out Gtk.Cell_Renderer.Gtk_Cell_Renderer;
115
Cursor_Is_Set : out Boolean);
116
-- Fills in Path and Cell with the current cursor path and cell.
117
-- If the cursor isn't currently set, then Ppath will be null.
118
-- If no cell currently has focus, then Cell will be null.
119
-- The returned Path must be freed with Gtk.Tree_Model.Path_Free.
120
-- Cursor_Is_Set is set to True if the cursor is set.
122
procedure Set_Item_Width
123
(Icon_View : access Gtk_Icon_View_Record;
124
Item_Width : Glib.Gint);
125
function Get_Item_Width
126
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
127
-- Sets the ::item-width property which specifies the width to use for each
128
-- item. If it is set to -1, the icon view will automatically determine a
129
-- suitable item size.
132
(Icon_View : access Gtk_Icon_View_Record;
135
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
136
-- Sets the ::margin property which specifies the space which is inserted
137
-- at the top, bottom, left and right of the icon view.
139
procedure Set_Orientation
140
(Icon_View : access Gtk_Icon_View_Record;
141
Orientation : Gtk.Enums.Gtk_Orientation);
142
function Get_Orientation
143
(Icon_View : access Gtk_Icon_View_Record)
144
return Gtk.Enums.Gtk_Orientation;
145
-- Sets the ::orientation property which determines whether the labels
146
-- are drawn beside the icons instead of below.
148
procedure Set_Reorderable
149
(Icon_View : access Gtk_Icon_View_Record;
150
Reorderable : Boolean);
151
function Get_Reorderable
152
(Icon_View : access Gtk_Icon_View_Record) return Boolean;
153
-- This function is a convenience function to allow you to reorder models
154
-- that support the Gtk_Tree_Drag_Source interface and the
155
-- Gtk_Tree_Drag_Dest interface. Both Gtk_Tree_Store and Gtk_List_Store
156
-- support these. If Reorderable is True, then the user can reorder the
157
-- model by dragging and dropping rows. The developer can listen to these
158
-- changes by connecting to the model's row_inserted and row_deleted
161
-- This function does not give you any degree of control over the order --
162
-- any reordering is allowed. If more control is needed, you should
163
-- probably handle drag and drop manually.
165
procedure Set_Row_Spacing
166
(Icon_View : access Gtk_Icon_View_Record;
167
Row_Spacing : Glib.Gint);
168
function Get_Row_Spacing
169
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
170
-- Sets the ::row-spacing property which specifies the space
171
-- which is inserted between the rows of the icon view.
173
procedure Set_Spacing
174
(Icon_View : access Gtk_Icon_View_Record;
175
Spacing : Glib.Gint);
177
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
178
-- Sets the ::spacing property which specifies the space
179
-- which is inserted between the cells (i.e. the icon and
180
-- the text) of an item.
182
procedure Item_Activated
183
(Icon_View : access Gtk_Icon_View_Record;
184
Path : Gtk.Tree_Model.Gtk_Tree_Path);
185
-- Activates the item determined by Path.
191
procedure Get_Visible_Range
192
(Icon_View : access Gtk_Icon_View_Record;
193
Start_Path : out Gtk.Tree_Model.Gtk_Tree_Path;
194
End_Path : out Gtk.Tree_Model.Gtk_Tree_Path);
195
-- Sets Start_Path and End_Path to be the first and last visible path.
196
-- Note that there may be invisible paths in between.
197
-- Both paths should be freed with Path_Free after use.
199
procedure Scroll_To_Path
200
(Icon_View : access Gtk_Icon_View_Record;
201
Path : Gtk.Tree_Model.Gtk_Tree_Path;
202
Use_Align : Boolean := True;
203
Row_Align : Glib.Gfloat := 0.5;
204
Col_Align : Glib.Gfloat := 0.0);
205
-- Moves the alignments of Icon_View to the position specified by Path.
206
-- Row_Align determines where the row is placed, and Col_Align determines
207
-- where column is placed. Both are expected to be between 0.0 and 1.0.
208
-- 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5
211
-- If Use_Align is False, then the alignment arguments are ignored, and the
212
-- tree does the minimum amount of work to scroll the item onto the screen.
213
-- This means that the item will be scrolled to the edge closest to its
214
-- current position. If the item is currently visible on the screen,
217
-- This function only works if the model is set, and Path is a valid row on
218
-- the model. If the model changes before the Icon_View is realized, the
219
-- centered path will be modified to reflect this change.
226
(Icon_View : access Gtk_Icon_View_Record;
227
Model : Gtk.Tree_Model.Gtk_Tree_Model := null);
229
(Icon_View : access Gtk_Icon_View_Record)
230
return Gtk.Tree_Model.Gtk_Tree_Model;
231
-- Sets the model for a Gtk_Icon_View. If the Icon_View already has a
232
-- model set, it will remove it before setting the new model. If Model is
233
-- null, then it will unset the old model.
235
procedure Set_Text_Column
236
(Icon_View : access Gtk_Icon_View_Record;
238
function Get_Text_Column
239
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
240
-- Sets the column with text for Icon_View to be Column. The text
241
-- column must be of type GType_String.
243
procedure Set_Pixbuf_Column
244
(Icon_View : access Gtk_Icon_View_Record; Column : Glib.Gint);
245
function Get_Pixbuf_Column
246
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
247
-- Sets the column with pixbufs for Icon_View to be Column. The pixbuf
248
-- column must be of type Gdk.Pixbuf.Get_Type
250
procedure Set_Markup_Column
251
(Icon_View : access Gtk_Icon_View_Record;
253
function Get_Markup_Column
254
(Icon_View : access Gtk_Icon_View_Record) return Glib.Gint;
255
-- Sets the column with markup information for Icon_View to be
256
-- Column. The markup column must be of type GType_String.
257
-- If the markup column is set to something, it overrides
258
-- the text column set by Set_Text_Column.
260
function Get_Path_At_Pos
261
(Icon_View : access Gtk_Icon_View_Record;
263
Y : Glib.Gint) return Gtk.Tree_Model.Gtk_Tree_Path;
264
-- Finds the path at the point (X, Y), relative to widget coordinates. See
265
-- Get_Item_At_Pos, if you are also interested in the cell at the specified
268
procedure Get_Item_At_Pos
269
(Icon_View : access Gtk_Icon_View_Record;
272
Path : out Gtk.Tree_Model.Gtk_Tree_Path;
273
Cell : out Gtk.Cell_Renderer.Gtk_Cell_Renderer;
274
Has_Item : out Boolean);
275
-- Finds the path at the point (X, Y), relative to widget coordinates.
276
-- In contrast to Get_Path_At_Pos, this function also
277
-- obtains the cell at the specified position. The returned path should
278
-- be freed with Path_Free.
279
-- Has_Item is set to True if an item exists at the specified position.
285
procedure Set_Selection_Mode
286
(Icon_View : access Gtk_Icon_View_Record;
287
Mode : Gtk.Enums.Gtk_Selection_Mode);
288
function Get_Selection_Mode
289
(Icon_View : access Gtk_Icon_View_Record)
290
return Gtk.Enums.Gtk_Selection_Mode;
291
-- Sets the selection mode of the Icon_View.
293
procedure Select_All (Icon_View : access Gtk_Icon_View_Record);
294
procedure Unselect_All (Icon_View : access Gtk_Icon_View_Record);
295
-- Selects all the icons. Icon_View must has its selection mode set
296
-- to Selection_Multiple
298
procedure Select_Path
299
(Icon_View : access Gtk_Icon_View_Record;
300
Path : Gtk.Tree_Model.Gtk_Tree_Path);
301
procedure Unselect_Path
302
(Icon_View : access Gtk_Icon_View_Record;
303
Path : Gtk.Tree_Model.Gtk_Tree_Path);
304
-- Selects the row at Path.
306
function Get_Selected_Items
307
(Icon_View : access Gtk_Icon_View_Record)
308
return Gtk.Tree_Model.Gtk_Tree_Path_List.Glist;
309
-- Creates a list of paths of all selected items. Additionally, if you are
310
-- planning on modifying the model after calling this function, you may
311
-- want to convert the returned list into a list of Gtk_Tree_Row_Reference.
312
-- To free the returend value, use:
313
-- Foreach (List, Gtk.Tree_Model.Path_Free, Null);
316
function Path_Is_Selected
317
(Icon_View : access Gtk_Icon_View_Record;
318
Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean;
319
-- Returns True if the icon pointed to by Path is currently
320
-- selected. If Path does not point to a valid location, False is returned.
326
function Create_Drag_Icon
327
(Icon_View : access Gtk_Icon_View_Record;
328
Path : Gtk.Tree_Model.Gtk_Tree_Path) return Gdk.Gdk_Pixmap;
329
-- Creates a Gdk_Pixmap representation of the item at Path.
330
-- This image is used for a drag icon.
331
-- The returned value must be Unref'd by the caller.
333
procedure Enable_Model_Drag_Dest
334
(Icon_View : access Gtk_Icon_View_Record;
335
Targets : Gtk.Selection.Target_Entry_Array;
336
Actions : Gdk.Dnd.Drag_Action);
337
procedure Unset_Model_Drag_Dest
338
(Icon_View : access Gtk_Icon_View_Record);
339
-- Turns Icon_view into a drop destination for automatic DND.
340
-- Targets is the list of targets that the drag will support.
342
procedure Enable_Model_Drag_Source
343
(Icon_View : access Gtk_Icon_View_Record;
344
Start_Button_Mask : Gdk.Types.Gdk_Modifier_Type;
345
Targets : Gtk.Selection.Target_Entry_Array;
346
Actions : Gdk.Dnd.Drag_Action);
347
procedure Unset_Model_Drag_Source
348
(Icon_View : access Gtk_Icon_View_Record);
349
-- Turns Icon_view into a drag source for automatic DND.
350
-- Start_Button_Mask is the allowed buttons to start drag.
352
procedure Get_Dest_Item_At_Pos
353
(Icon_View : access Gtk_Icon_View_Record;
356
Path : out Gtk.Tree_Model.Gtk_Tree_Path;
357
Pos : out Gtk_Icon_View_Drop_Position;
358
Has_Item : out Boolean);
359
-- Determines the destination item for a given position.
360
-- Return value: whether there is an item at the given position.
362
procedure Set_Drag_Dest_Item
363
(Icon_View : access Gtk_Icon_View_Record;
364
Path : Gtk.Tree_Model.Gtk_Tree_Path;
365
Pos : Gtk_Icon_View_Drop_Position);
366
procedure Get_Drag_Dest_Item
367
(Icon_View : access Gtk_Icon_View_Record;
368
Path : out Gtk.Tree_Model.Gtk_Tree_Path;
369
Pos : out Gtk_Icon_View_Drop_Position);
370
-- Sets the item that is highlighted for feedback.
375
-- This class implements several interfaces. See Glib.Types
377
-- - "Gtk_Cell_Layout"
379
package Implements_Cell_Layout is new Glib.Types.Implements
380
(Gtk.Cell_Layout.Gtk_Cell_Layout, Gtk_Icon_View_Record, Gtk_Icon_View);
382
(Widget : access Gtk_Icon_View_Record'Class)
383
return Gtk.Cell_Layout.Gtk_Cell_Layout
384
renames Implements_Cell_Layout.To_Interface;
386
(Interf : Gtk.Cell_Layout.Gtk_Cell_Layout)
388
renames Implements_Cell_Layout.To_Object;
389
-- Converts to and from the Gtk_Cell_Layout interface
396
-- The following properties are defined for this widget. See
397
-- Glib.Properties for more information on properties.
399
-- Name: Column_Spacing_Property
401
-- Descr: Space which is inserted between grid column
403
-- Name: Columns_Property
405
-- Descr: Number of columns to display
407
-- Name: Item_Width_Property
409
-- Descr: The width used for each item
411
-- Name: Margin_Property
413
-- Descr: Space which is inserted at the edges of the icon view
415
-- Name: Markup_Column_Property
417
-- Descr: Model column used to retrieve the text if using Pango markup
419
-- Name: Model_Property
421
-- Descr: The model for the icon view
423
-- Name: Orientation_Property
425
-- Descr: How the text and icon of each item are positioned relative to
428
-- Name: Pixbuf_Column_Property
430
-- Descr: Model column used to retrieve the icon pixbuf from
432
-- Name: Reorderable_Property
434
-- Descr: View is reorderable
436
-- Name: Row_Spacing_Property
438
-- Descr: Space which is inserted between grid rows
440
-- Name: Selection_Mode_Property
442
-- Descr: The selection mode
444
-- Name: Spacing_Property
446
-- Descr: Space which is inserted between cells of an item
448
-- Name: Text_Column_Property
450
-- Descr: Model column used to retrieve the text from
454
Column_Spacing_Property : constant Glib.Properties.Property_Int;
455
Columns_Property : constant Glib.Properties.Property_Int;
456
Item_Width_Property : constant Glib.Properties.Property_Int;
457
Margin_Property : constant Glib.Properties.Property_Int;
458
Markup_Column_Property : constant Glib.Properties.Property_Int;
459
Model_Property : constant Glib.Properties.Property_Object;
460
Orientation_Property : constant Gtk.Enums.Property_Gtk_Orientation;
461
Pixbuf_Column_Property : constant Glib.Properties.Property_Int;
462
Reorderable_Property : constant Glib.Properties.Property_Boolean;
463
Row_Spacing_Property : constant Glib.Properties.Property_Int;
464
-- Selection_Mode_Property : constant Glib.Properties.Property_Enum;
465
Spacing_Property : constant Glib.Properties.Property_Int;
466
Text_Column_Property : constant Glib.Properties.Property_Int;
468
----------------------
469
-- Style Properties --
470
----------------------
471
-- The following properties can be changed through the gtk theme and
472
-- configuration files, and retrieved through Gtk.Widget.Style_Get_Property
474
-- <style_properties>
475
-- Name: Selection_Box_Alpha_Property
477
-- Descr: Opacity of the selection box
479
-- Name: Selection_Box_Color_Property
481
-- Descr: Color of the selection box
484
Selection_Box_Alpha_Property : constant Glib.Properties.Property_Uchar;
485
Selection_Box_Color_Property : constant Gdk.Color.Property_Gdk_Color;
492
-- The following new signals are defined for this widget:
494
-- - "activate_cursor_item"
495
-- - "item_activated"
498
-- - "select_cursor_item"
499
-- - "selection_changed"
500
-- - "set_scroll_adjustments"
501
-- - "toggle_cursor_item"
505
Signal_Activate_Cursor_Item : constant Glib.Signal_Name :=
506
"activate_cursor_item";
507
Signal_Item_Activated : constant Glib.Signal_Name :=
509
Signal_Move_Cursor : constant Glib.Signal_Name :=
511
Signal_Select_All : constant Glib.Signal_Name :=
513
Signal_Select_Cursor_Item : constant Glib.Signal_Name :=
514
"select_cursor_item";
515
Signal_Selection_Changed : constant Glib.Signal_Name :=
517
Signal_Set_Scroll_Adjustments : constant Glib.Signal_Name :=
518
"set_scroll_adjustments";
519
Signal_Toggle_Cursor_Item : constant Glib.Signal_Name :=
520
"toggle_cursor_item";
521
Signal_Unselect_All : constant Glib.Signal_Name :=
526
Selection_Box_Alpha_Property : constant Glib.Properties.Property_Uchar :=
527
Glib.Properties.Build ("selection-box-alpha");
528
Selection_Box_Color_Property : constant Gdk.Color.Property_Gdk_Color :=
529
Gdk.Color.Property_Gdk_Color (Glib.Build ("selection-box-color"));
531
Column_Spacing_Property : constant Glib.Properties.Property_Int :=
532
Glib.Properties.Build ("column-spacing");
533
Columns_Property : constant Glib.Properties.Property_Int :=
534
Glib.Properties.Build ("columns");
535
Item_Width_Property : constant Glib.Properties.Property_Int :=
536
Glib.Properties.Build ("item-width");
537
Margin_Property : constant Glib.Properties.Property_Int :=
538
Glib.Properties.Build ("margin");
539
Markup_Column_Property : constant Glib.Properties.Property_Int :=
540
Glib.Properties.Build ("markup-column");
541
Model_Property : constant Glib.Properties.Property_Object :=
542
Glib.Properties.Build ("model");
543
Orientation_Property : constant Gtk.Enums.Property_Gtk_Orientation :=
544
Gtk.Enums.Property_Gtk_Orientation (Glib.Build ("orientation"));
545
Pixbuf_Column_Property : constant Glib.Properties.Property_Int :=
546
Glib.Properties.Build ("pixbuf-column");
547
Reorderable_Property : constant Glib.Properties.Property_Boolean :=
548
Glib.Properties.Build ("reorderable");
549
Row_Spacing_Property : constant Glib.Properties.Property_Int :=
550
Glib.Properties.Build ("row-spacing");
551
-- Selection_Mode_Property : constant Glib.Properties.Property_Enum :=
552
-- Glib.Properties.Build ("selection-mode");
553
Spacing_Property : constant Glib.Properties.Property_Int :=
554
Glib.Properties.Build ("spacing");
555
Text_Column_Property : constant Glib.Properties.Property_Int :=
556
Glib.Properties.Build ("text-column");
558
pragma Import (C, Get_Type, "gtk_icon_view_get_type");
562
-- binding might be useful later:
563
-- No binding: gtk_icon_view_selected_foreach