1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo renders text in a cell 
  26. --  like Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text from which it is 
  27. --  derived. But while Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text offers a 
  28. --  simple entry to edit the text, 
  29. --  Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo offers a 
  30. --  Gtk.Combo_Box.Gtk_Combo_Box widget to edit the text. The values to display 
  31. --  in the combo box are taken from the tree model specified in the 
  32. --  Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo:model property. 
  33. -- 
  34. --  The combo cell renderer takes care of adding a text cell renderer to the 
  35. --  combo box and sets it to display the column specified by its 
  36. --  Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo:text-column property. 
  37. --  Further properties of the combo box can be set in a handler for the 
  38. --  Gtk.Cell_Renderer.Gtk_Cell_Renderer::editing-started signal. 
  39. -- 
  40. --  The Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo cell renderer was 
  41. --  added in GTK+ 2.6. 
  42. -- 
  43. --  </description> 
  44. pragma Ada_2005; 
  45.  
  46. pragma Warnings (Off, "*is already use-visible*"); 
  47. with Glib;                   use Glib; 
  48. with Glib.Object;            use Glib.Object; 
  49. with Glib.Properties;        use Glib.Properties; 
  50. with Gtk.Cell_Renderer_Text; use Gtk.Cell_Renderer_Text; 
  51. with Gtk.Tree_Model;         use Gtk.Tree_Model; 
  52.  
  53. package Gtk.Cell_Renderer_Combo is 
  54.  
  55.    type Gtk_Cell_Renderer_Combo_Record is new Gtk_Cell_Renderer_Text_Record with null record; 
  56.    type Gtk_Cell_Renderer_Combo is access all Gtk_Cell_Renderer_Combo_Record'Class; 
  57.  
  58.    ------------------ 
  59.    -- Constructors -- 
  60.    ------------------ 
  61.  
  62.    procedure Gtk_New (Self : out Gtk_Cell_Renderer_Combo); 
  63.    procedure Initialize 
  64.       (Self : not null access Gtk_Cell_Renderer_Combo_Record'Class); 
  65.    --  Creates a new Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo. Adjust 
  66.    --  how text is drawn using object properties. Object properties can be set 
  67.    --  globally (with g_object_set). Also, with 
  68.    --  Gtk.Tree_View_Column.Gtk_Tree_View_Column, you can bind a property to a 
  69.    --  value in a Gtk.Tree_Model.Gtk_Tree_Model. For example, you can bind the 
  70.    --  "text" property on the cell renderer to a string value in the model, 
  71.    --  thus rendering a different string in each row of the 
  72.    --  Gtk.Tree_View.Gtk_Tree_View. 
  73.    --  Since: gtk+ 2.6 
  74.  
  75.    function Gtk_Cell_Renderer_Combo_New return Gtk_Cell_Renderer_Combo; 
  76.    --  Creates a new Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo. Adjust 
  77.    --  how text is drawn using object properties. Object properties can be set 
  78.    --  globally (with g_object_set). Also, with 
  79.    --  Gtk.Tree_View_Column.Gtk_Tree_View_Column, you can bind a property to a 
  80.    --  value in a Gtk.Tree_Model.Gtk_Tree_Model. For example, you can bind the 
  81.    --  "text" property on the cell renderer to a string value in the model, 
  82.    --  thus rendering a different string in each row of the 
  83.    --  Gtk.Tree_View.Gtk_Tree_View. 
  84.    --  Since: gtk+ 2.6 
  85.  
  86.    function Get_Type return Glib.GType; 
  87.    pragma Import (C, Get_Type, "gtk_cell_renderer_combo_get_type"); 
  88.  
  89.    ---------------- 
  90.    -- Properties -- 
  91.    ---------------- 
  92.    --  The following properties are defined for this widget. See 
  93.    --  Glib.Properties for more information on properties) 
  94.  
  95.    Has_Entry_Property : constant Glib.Properties.Property_Boolean; 
  96.    --  If True, the cell renderer will include an entry and allow to enter 
  97.    --  values other than the ones in the popup list. 
  98.  
  99.    Model_Property : constant Glib.Properties.Property_Interface; 
  100.    --  Type: Gtk.Tree_Model.Gtk_Tree_Model 
  101.    --  Holds a tree model containing the possible values for the combo box. 
  102.    --  Use the text_column property to specify the column holding the values. 
  103.  
  104.    Text_Column_Property : constant Glib.Properties.Property_Int; 
  105.    --  Specifies the model column which holds the possible values for the 
  106.    --  combo box. 
  107.    -- 
  108.    --  Note that this refers to the model specified in the model property, 
  109.    --  *not* the model backing the tree view to which this cell renderer is 
  110.    --  attached. 
  111.    -- 
  112.    --  Gtk.Cell_Renderer_Combo.Gtk_Cell_Renderer_Combo automatically adds a 
  113.    --  text cell renderer for this column to its combo box. 
  114.  
  115.    ------------- 
  116.    -- Signals -- 
  117.    ------------- 
  118.  
  119.    type Cb_Gtk_Cell_Renderer_Combo_UTF8_String_Gtk_Tree_Iter_Void is not null access procedure 
  120.      (Self        : access Gtk_Cell_Renderer_Combo_Record'Class; 
  121.       Path_String : UTF8_String; 
  122.       New_Iter    : Gtk.Tree_Model.Gtk_Tree_Iter); 
  123.  
  124.    type Cb_GObject_UTF8_String_Gtk_Tree_Iter_Void is not null access procedure 
  125.      (Self        : access Glib.Object.GObject_Record'Class; 
  126.       Path_String : UTF8_String; 
  127.       New_Iter    : Gtk.Tree_Model.Gtk_Tree_Iter); 
  128.  
  129.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  130.    procedure On_Changed 
  131.       (Self  : not null access Gtk_Cell_Renderer_Combo_Record; 
  132.        Call  : Cb_Gtk_Cell_Renderer_Combo_UTF8_String_Gtk_Tree_Iter_Void; 
  133.        After : Boolean := False); 
  134.    procedure On_Changed 
  135.       (Self  : not null access Gtk_Cell_Renderer_Combo_Record; 
  136.        Call  : Cb_GObject_UTF8_String_Gtk_Tree_Iter_Void; 
  137.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  138.        After : Boolean := False); 
  139.    --  This signal is emitted each time after the user selected an item in the 
  140.    --  combo box, either by using the mouse or the arrow keys. Contrary to 
  141.    --  GtkComboBox, GtkCellRendererCombo::changed is not emitted for changes 
  142.    --  made to a selected item in the entry. The argument New_Iter corresponds 
  143.    --  to the newly selected item in the combo box and it is relative to the 
  144.    --  GtkTreeModel set via the model property on GtkCellRendererCombo. 
  145.    -- 
  146.    --  Note that as soon as you change the model displayed in the tree view, 
  147.    --  the tree view will immediately cease the editing operating. This means 
  148.    --  that you most probably want to refrain from changing the model until the 
  149.    --  combo cell renderer emits the edited or editing_canceled signal. 
  150.    --  
  151.    --  Callback parameters: 
  152.    --    --  "path_string": a string of the path identifying the edited cell 
  153.    --    --  (relative to the tree view model) 
  154.    --    --  "new_iter": the new iter selected in the combo box (relative to the 
  155.    --    --  combo box model) 
  156.  
  157. private 
  158.    Text_Column_Property : constant Glib.Properties.Property_Int := 
  159.      Glib.Properties.Build ("text-column"); 
  160.    Model_Property : constant Glib.Properties.Property_Interface := 
  161.      Glib.Properties.Build ("model"); 
  162.    Has_Entry_Property : constant Glib.Properties.Property_Boolean := 
  163.      Glib.Properties.Build ("has-entry"); 
  164. end Gtk.Cell_Renderer_Combo;