1-----------------------------------------------------------------------
2--              GtkAda - Ada95 binding for Gtk+/Gnome                --
3--                                                                   --
4--                      Copyright (C) 2001-2006                      --
5--                               AdaCore                             --
6--                                                                   --
7-- This library is free software; you can redistribute it and/or     --
8-- modify it under the terms of the GNU General Public               --
9-- License as published by the Free Software Foundation; either      --
10-- version 2 of the License, or (at your option) any later version.  --
11--                                                                   --
12-- This library is distributed in the hope that it will be useful,   --
13-- but WITHOUT ANY WARRANTY; without even the implied warranty of    --
14-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
15-- General Public License for more details.                          --
16--                                                                   --
17-- You should have received a copy of the GNU General Public         --
18-- License along with this library; if not, write to the             --
19-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --
20-- Boston, MA 02111-1307, USA.                                       --
21--                                                                   --
22-- As a special exception, if other files instantiate generics from  --
23-- this unit, or you link this unit with other files to produce an   --
24-- executable, this  unit  does not  by itself cause  the resulting  --
25-- executable to be covered by the GNU General Public License. This  --
26-- exception does not however invalidate any other reasons why the   --
27-- executable file  might be covered by the  GNU Public License.     --
28-----------------------------------------------------------------------
29
30--  <description>
31--  This package implements a specific model to store your data in. Each
32--  item in the list will correspond to one line in the tree view. Multiple
33--  columns can be displayed for each line.
34--  </description>
35--  <c_version>2.8.17</c_version>
36--  <group>Trees and Lists</group>
37
38with Gdk.Pixbuf;
39with Glib.Types;
40with Glib.Values;
41with Gtk;
42with Gtk.Tree_Dnd;
43with Gtk.Tree_Model;
44with Gtk.Tree_Sortable;
45
46package Gtk.List_Store is
47
48   type Gtk_List_Store_Record is
49     new Gtk.Tree_Model.Gtk_Tree_Model_Record with null record;
50   type Gtk_List_Store is access all Gtk_List_Store_Record'Class;
51
52   procedure Gtk_New
53     (List_Store : out Gtk_List_Store;
54      Types      : GType_Array);
55   --  Creates a new list store using Types to fill the columns.
56
57   procedure Initialize
58     (List_Store : access Gtk_List_Store_Record'Class;
59      Types      : GType_Array);
60   --  Internal initialization function.
61   --  See the section "Creating your own widgets" in the documentation.
62
63   function Get_Type return Gtk.Gtk_Type;
64   --  Return the internal value associated with this widget.
65
66   procedure Set_Column_Types
67     (List_Store : access Gtk_List_Store_Record;
68      Types      : GType_Array);
69
70   procedure Set_Value
71     (List_Store : access Gtk_List_Store_Record;
72      Iter       : Gtk.Tree_Model.Gtk_Tree_Iter;
73      Column     : Gint;
74      Value      : Glib.Values.GValue);
75   --  Set the data in the cell specified by Iter and Column.
76   --  The type of Value must be convertible to the type of the column.
77
78   procedure Set
79     (Tree_Store : access Gtk_List_Store_Record;
80      Iter       : Gtk.Tree_Model.Gtk_Tree_Iter;
81      Column     : Gint;
82      Value      : UTF8_String);
83   --  Same as above, for an UTF8 string.
84
85   procedure Set
86     (Tree_Store : access Gtk_List_Store_Record;
87      Iter       : Gtk.Tree_Model.Gtk_Tree_Iter;
88      Column     : Gint;
89      Value      : Gint);
90   --  Same as above, for a Gint.
91
92   procedure Set
93     (Tree_Store : access Gtk_List_Store_Record;
94      Iter       : Gtk.Tree_Model.Gtk_Tree_Iter;
95      Column     : Gint;
96      Value      : Gdk.Pixbuf.Gdk_Pixbuf);
97   --  Same as above for a pixbuf
98
99   procedure Set
100     (Tree_Store : access Gtk_List_Store_Record;
101      Iter       : Gtk.Tree_Model.Gtk_Tree_Iter;
102      Column     : Gint;
103      Value      : Boolean);
104   --  Same as above for a boolean
105
106   procedure Remove
107     (List_Store : access Gtk_List_Store_Record;
108      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter);
109   --  Remove the given row from the list store.
110   --  After being removed, Iter is set to be the next valid row, or
111   --  invalidated if it pointed to the last row in List_Store.
112
113   procedure Insert
114     (List_Store : access Gtk_List_Store_Record;
115      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter;
116      Position   : Gint);
117   --  Create a new row at Position.
118   --  Iter will be changed to point to this new row.
119   --  If Position is larger than the number of rows on the list, then the new
120   --  row will be appended to the list. The row will be empty before this
121   --  function is called. To fill in values, you need to call Set_Value.
122
123   procedure Insert_Before
124     (List_Store : access Gtk_List_Store_Record;
125      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter;
126      Sibling    : Gtk.Tree_Model.Gtk_Tree_Iter);
127   --  Insert a new row before Sibling.
128   --  If Sibling is Null_Iter, then the row will be appended to the end of the
129   --  list. Iter will be changed to point to this new row. The row will be
130   --  empty before this function is called. To fill in values, you need to
131   --  call Set_Value.
132
133   procedure Insert_After
134     (List_Store : access Gtk_List_Store_Record;
135      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter;
136      Sibling    : Gtk.Tree_Model.Gtk_Tree_Iter);
137   --  Insert a new row after Sibling.
138   --  If Sibling is Null_Iter, then the row will be prepended to the beginning
139   --  of the list. Iter will be changed to point to this new row. The row will
140   --  be empty after this function is called. To fill in values, you need to
141   --  call Set_Value.
142
143   procedure Insert_With_Valuesv
144     (List_Store : access Gtk_List_Store_Record;
145      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter;
146      Position   : Glib.Gint;
147      Columns    : Glib.Gint_Array;
148      Values     : Glib.Values.GValue_Array);
149   --  Creates a new row at Position. Iter will be changed to point to this new
150   --  row. If Position is larger than the number of rows on the list, then the
151   --  new row will be appended to the list. The row will be filled with the
152   --  values given to this function.
153   --  Using this function is more efficient that calling Insert and then
154   --  Set for each column, since that will not emit the rows_reordered signal
155   --  when the model is sorted.
156
157   procedure Prepend
158     (List_Store : access Gtk_List_Store_Record;
159      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter);
160   --  Prepend a new row to List_Store.
161   --  Iter will be changed to point to this new row. The row will be empty
162   --  after this function is called. To fill in values, you need to call
163   --  Set_Value.
164
165   procedure Append
166     (List_Store : access Gtk_List_Store_Record;
167      Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter);
168   --  Append a new row to List_Store.
169   --  Iter will be changed to point to this new row. The row will be empty
170   --  after this function is called. To fill in values, you need to call
171   --  Set_Value.
172
173   procedure Clear (List_Store : access Gtk_List_Store_Record);
174   --  Remove all the rows in List_Store.
175
176   function Iter_Is_Valid
177     (List_Store : access Gtk_List_Store_Record;
178      Iter       : Gtk.Tree_Model.Gtk_Tree_Iter)
179      return Boolean;
180   --  WARNING: This function is slow. Only use it for debugging and/or testing
181   --  purposes.
182   --  Checks if the given iter is a valid iter for List_Store.
183
184   procedure Move_After
185     (Store    : access Gtk_List_Store_Record;
186      Iter     : Gtk.Tree_Model.Gtk_Tree_Iter;
187      Position : Gtk.Tree_Model.Gtk_Tree_Iter);
188   --  Moves the row pointed to by Iter to the position after Position. Note
189   --  that this function only works with unsorted stores. If Position is
190   --  Null_Iter, Iter will be moved to the start of the list.
191
192   procedure Move_Before
193     (Store    : access Gtk_List_Store_Record;
194      Iter     : Gtk.Tree_Model.Gtk_Tree_Iter;
195      Position : Gtk.Tree_Model.Gtk_Tree_Iter);
196   --  Moves the row pointed to by Iter to the position before Position. Note
197   --  that this function only works with unsorted stores. If Position is
198   --  Null_Iter, Iter will be moved to the end of the list.
199
200   procedure Reorder
201     (Store     : access Gtk_List_Store_Record;
202      New_Order : Glib.Gint_Array);
203   --  Reorders Store to follow the order indicated by New_order. Note that
204   --  this function only works with unsorted stores.
205   --  New_Order is an array of integers mapping the new position of each child
206   --  to its old position before the re-ordering,
207   --  i.e. New_Order[newpos] = oldpos
208
209   procedure Swap
210     (Store : access Gtk_List_Store_Record;
211      A     : Gtk.Tree_Model.Gtk_Tree_Iter;
212      B     : Gtk.Tree_Model.Gtk_Tree_Iter);
213   --  Swaps the rwos pointed to by A and B. Note that this function only works
214   --  with unsorted stores.
215
216   ----------------
217   -- Interfaces --
218   ----------------
219   --  This class implements several interfaces. See Glib.Types
220   --
221   --  - "Gtk_Tree_Sortable"
222   --    This interface allows you to specify your own sort function
223   --
224   --  - "Gtk_Tree_Drag_Source"
225   --    This interface allows this widget to act as a dnd source
226   --
227   --  - "Gtk_Tree_Drag_Dest"
228   --    This interface allows this widget to act as a dnd destination
229
230   package Implements_Tree_Sortable is new Glib.Types.Implements
231     (Gtk.Tree_Sortable.Gtk_Tree_Sortable,
232      Gtk_List_Store_Record,
233      Gtk_List_Store);
234   function "+"
235     (Model : access Gtk_List_Store_Record'Class)
236      return Gtk.Tree_Sortable.Gtk_Tree_Sortable
237      renames Implements_Tree_Sortable.To_Interface;
238   function "-"
239     (Sortable : Gtk.Tree_Sortable.Gtk_Tree_Sortable)
240      return Gtk_List_Store
241      renames Implements_Tree_Sortable.To_Object;
242   --  Converts to and from the Gtk_Tree_Sortable interface
243
244   package Implements_Drag_Source is new Glib.Types.Implements
245     (Gtk.Tree_Dnd.Gtk_Tree_Drag_Source,
246      Gtk_List_Store_Record,
247      Gtk_List_Store);
248   function "+"
249     (Model : access Gtk_List_Store_Record'Class)
250      return Gtk.Tree_Dnd.Gtk_Tree_Drag_Source
251      renames Implements_Drag_Source.To_Interface;
252   function "-"
253     (Drag_Source : Gtk.Tree_Dnd.Gtk_Tree_Drag_Source)
254      return Gtk_List_Store
255      renames Implements_Drag_Source.To_Object;
256   --  Converts to and from the Gtk_Tree_Drag_Source interface
257
258   package Implements_Drag_Dest is new Glib.Types.Implements
259     (Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest,
260      Gtk_List_Store_Record,
261      Gtk_List_Store);
262   function "+"
263     (Model : access Gtk_List_Store_Record'Class)
264      return Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest
265      renames Implements_Drag_Dest.To_Interface;
266   function "-"
267     (Drag_Dest : Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest)
268      return Gtk_List_Store
269      renames Implements_Drag_Dest.To_Object;
270   --  Converts to and from the Gtk_Tree_Drag_Source interface
271
272private
273
274   pragma Import (C, Get_Type, "gtk_list_store_get_type");
275end Gtk.List_Store;
276
277--  No binding: gtk_list_store_new
278--  No binding: gtk_list_store_set
279--  No binding: gtk_list_store_set_valist
280--  No binding: gtk_list_store_insert_with_values
281