1-----------------------------------------------------------------------
2--              GtkAda - Ada95 binding for Gtk+/Gnome                --
3--                                                                   --
4--                Copyright (C) 2006 AdaCore                         --
5--                                                                   --
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.  --
10--                                                                   --
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.                          --
15--                                                                   --
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.                                       --
20--                                                                   --
21-- As a special exception, if other files instantiate generics from  --
22-- this unit, or you link this unit with other files to produce an   --
23-- executable, this  unit  does not  by itself cause  the resulting  --
24-- executable to be covered by the GNU General Public License. This  --
25-- exception does not however invalidate any other reasons why the   --
26-- executable file  might be covered by the  GNU Public License.     --
27-----------------------------------------------------------------------
28
29--  <description>
30--  A Gtk_Combo_Box_Entry is a widget that allows the user to choose from a
31--  list of valid choices or enter a different value. It is very similar to
32--  Gtk_Combo_Box, but it displays the selected value in an entry to allow
33--  modifying it.
34--
35--  In contrast to a Gtk_Combo_Box, the underlying model of a
36--  Gtk_Combo_Box_Entry must always have a text column (see Set_Text_Column),
37--  and the entry will show the content of the text column in the selected row.
38--  To get the text from the entry, use Gtk.Combo_Box.Get_Active_Text.
39--
40--  The changed signal will be emitted while typing into a Gtk_Combo_Box_Entry,
41--  as well as when selecting an item from the Gtk_Combo_Box_Entry's list. Use
42--  Gtk.Combo_Box.Get_Active or Gtk.Combo_Box.Get_Active_Iter to discover
43--  whether an item was actually selected from the list.
44--
45--  Connect to the activate signal of the Gtk_Entry (use Gtk.Bin.Get_Child) to
46--  detect when the user actually finishes entering text.
47--
48--  The convenience API to construct simple text-only Gtk_Combo_Box can also be
49--  used with Gtk_Combo_Box_Entry which have been constructed with
50--  Gtk_New_Text.
51--  </description>
52--  </description>
53--  <c_version>2.8.17</c_version>
54--  <group>Trees and Lists</group>
55--  <screenshot>gtk-combo_box_entry</screenshot>
56
57with Glib.Properties;
58with Glib.Types;
59with Gtk.Cell_Editable;
60with Gtk.Cell_Layout;
61with Gtk.Combo_Box;
62with Gtk.Tree_Model;
63
64package Gtk.Combo_Box_Entry is
65
66   type Gtk_Combo_Box_Entry_Record is new Gtk.Combo_Box.Gtk_Combo_Box_Record
67      with null record;
68   type Gtk_Combo_Box_Entry is access all Gtk_Combo_Box_Entry_Record'Class;
69
70   procedure Gtk_New    (Combo : out Gtk_Combo_Box_Entry);
71   procedure Initialize (Combo : access Gtk_Combo_Box_Entry_Record'Class);
72   --  Creates a new combo entry which has a Gtk.Gentry.Gtk_Entry as child.
73   --  After construction, you should set a model using Gtk.Combo_Box.Set_Model
74   --  and text_column using Set_Text_Column.
75
76   procedure Gtk_New_Text    (Combo : out Gtk_Combo_Box_Entry);
77   procedure Initialize_Text (Combo : access Gtk_Combo_Box_Entry_Record'Class);
78   --  Convenience function which constructs a new editable text combo box,
79   --  which is an entry just displaying strings. If you use this function to
80   --  create a text combo box, you should only manipulate its data source with
81   --  the convenience functions Gtk.Combo_Box.Append_Text,
82   --  Gtk.Combo_Box.Insert_Text,...
83
84   procedure Gtk_New_With_Model
85     (Combo       : out Gtk_Combo_Box_Entry;
86      Model       : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class;
87      Text_Column : Gint);
88   procedure Initialize_With_Model
89     (Combo       : access Gtk_Combo_Box_Entry_Record'Class;
90      Model       : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class;
91      Text_Column : Gint);
92   --  Creates a new entry which has a Gtk_Entry as child and a list of strings
93   --  as popup. You can get the Gtk_Entry using Gtk.Bin.Get_Child. To add and
94   --  remove strings from the list, just modify Model
95
96   function Get_Type return Glib.GType;
97   --  Returns the internal value used for Gtk_Combo_Box_Entry widgets
98
99   procedure Set_Text_Column
100     (Entry_Box : access Gtk_Combo_Box_Entry_Record; Text_Column : Gint);
101   function Get_Text_Column
102     (Entry_Box : access Gtk_Combo_Box_Entry_Record)  return Gint;
103   --  Sets the model column which Entry_Box should use to get strings from
104   --  to be Text_Column.
105
106   ----------------
107   -- Interfaces --
108   ----------------
109   --  This class implements several interfaces. See Glib.Types
110   --
111   --  - "Gtk_Cell_Layout"
112   --    This interface should be used to add new renderers to the view, to
113   --    render various columns of the model
114   --  - "Gtk_Cell_Editable"
115   --    This interface should be used to edit the contents of a tree model
116   --    cell
117
118   package Implements_Cell_Layout is new Glib.Types.Implements
119     (Gtk.Cell_Layout.Gtk_Cell_Layout, Gtk_Combo_Box_Entry_Record,
120      Gtk_Combo_Box_Entry);
121   function "+"
122     (Box : access Gtk_Combo_Box_Entry_Record'Class)
123      return Gtk.Cell_Layout.Gtk_Cell_Layout
124      renames Implements_Cell_Layout.To_Interface;
125   function "-"
126     (Layout : Gtk.Cell_Layout.Gtk_Cell_Layout)
127      return Gtk_Combo_Box_Entry
128      renames Implements_Cell_Layout.To_Object;
129   --  Converts to and from the Gtk_Cell_Layout interface
130
131   package Implements_Cell_Editable is new Glib.Types.Implements
132     (Gtk.Cell_Editable.Gtk_Cell_Editable,
133      Gtk_Combo_Box_Entry_Record, Gtk_Combo_Box_Entry);
134   function "+"
135     (Box : access Gtk_Combo_Box_Entry_Record'Class)
136      return Gtk.Cell_Editable.Gtk_Cell_Editable
137      renames Implements_Cell_Editable.To_Interface;
138   function "-"
139     (Editable : Gtk.Cell_Editable.Gtk_Cell_Editable)
140      return Gtk_Combo_Box_Entry
141      renames Implements_Cell_Editable.To_Object;
142   --  Converts to and from the Gtk_Cell_Editable interface
143
144   ----------------
145   -- Properties --
146   ----------------
147   --  The following properties are defined for this widget. See
148   --  Glib.Properties for more information on properties.
149
150   --  <properties>
151   --  Name:  Text_Column_Property
152   --  Type:  Int
153   --  Descr: A column in the data source model to get the strings from
154   --  </properties>
155
156   Text_Column_Property : constant Glib.Properties.Property_Int;
157
158private
159   Text_Column_Property : constant Glib.Properties.Property_Int :=
160     Glib.Properties.Build ("text-column");
161
162   pragma Import (C, Get_Type, "gtk_combo_box_entry_get_type");
163end Gtk.Combo_Box_Entry;
164