1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2013, 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. --  Gtk_Cell_Layout is an interface to be implemented by all objects which want 
  31. --  to provide a Gtk_Tree_View_Column like API for packing cells, setting 
  32. --  attributes and data funcs. 
  33. --  The rendering of the widget is done through various Gtk_Cell_Renderer, and 
  34. --  by reading data from a Gtk_Tree_Model. 
  35. --  </description> 
  36. --  <c_version>2.8.17</c_version> 
  37. --  <group>Trees and Lists</group> 
  38. --  <testgtk>create_cell_view.adb</testgtk> 
  39.  
  40. with Glib.Types; 
  41. with Gtk.Cell_Renderer; 
  42. with Gtk.Tree_Model; 
  43.  
  44. package Gtk.Cell_Layout is 
  45.  
  46.    type Gtk_Cell_Layout is new Glib.Types.GType_Interface; 
  47.    --  An interface (similar to Java's interfaces) that can be implemented by 
  48.    --  tagged types derived from Glib.Object.GObject. 
  49.  
  50.    function Get_Type return Glib.GType; 
  51.    --  Returns the internal type used for a Gtk_Cell_Layout interface 
  52.  
  53.    procedure Pack_Start 
  54.      (Cell_Layout : Gtk_Cell_Layout; 
  55.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  56.       Expand      : Boolean); 
  57.    procedure Pack_End 
  58.      (Cell_Layout : Gtk_Cell_Layout; 
  59.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  60.       Expand      : Boolean); 
  61.    --  Adds Cell to the beginning or end of Cell_Layout. If Expand is False, 
  62.    --  then the Cell is allocated no more space than it needs. Any unused space 
  63.    --  is divided evenly between cells for which Expand is True. Note that 
  64.    --  reusing the same cell renderer is not supported. 
  65.  
  66.    procedure Add_Attribute 
  67.      (Cell_Layout : Gtk_Cell_Layout; 
  68.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  69.       Attribute   : String; 
  70.       Column      : Gint); 
  71.    --  Adds an attribute mapping to the list in Cell_Layout. Column is the 
  72.    --  column of the model to get a value from, and Attribute is the parameter 
  73.    --  on Cell to be set from the value. So for example if column of the model 
  74.    --  contains strings, you could have the "text" attribute of 
  75.    --  Gtk_Cell_Renderer_Text get its values from column 2. 
  76.    --  To mark rows as insensitive, create a column containing booleans in 
  77.    --  your model, and add an attribute "sensitive" to your renderer that 
  78.    --  points to this column. 
  79.  
  80.    procedure Clear (Cell_Layout : Gtk_Cell_Layout); 
  81.    --  Unsets all the mappings on all renderers on Cell_Layout and 
  82.    --  removes all renderers from Cell_Layout. 
  83.  
  84.    procedure Clear_Attributes 
  85.      (Cell_Layout : Gtk_Cell_Layout; 
  86.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class); 
  87.    --  Clears all existing attributes previously set with Add_Attribute. 
  88.  
  89.    procedure Reorder 
  90.      (Cell_Layout : Gtk_Cell_Layout; 
  91.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  92.       Position    : Gint); 
  93.    --  Re-inserts Cell at Position. Note that Cell has already to be packed 
  94.    --  into Cell_layout for this to function properly. 
  95.  
  96.    type Cell_Data_Func is access procedure 
  97.      (Cell_Layout : Gtk_Cell_Layout; 
  98.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  99.       Model       : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class; 
  100.       Iter        : Gtk.Tree_Model.Gtk_Tree_Iter); 
  101.    --  This subprogram can be used to globally modify an attribute of the 
  102.    --  Cell renderer. 
  103.    --  It should set the attributes of Cell as appropriate for this tree iter. 
  104.  
  105.    procedure Set_Cell_Data_Func 
  106.      (Cell_Layout : Gtk_Cell_Layout; 
  107.       Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  108.       Func        : Cell_Data_Func); 
  109.    --  Sets the Cell_Data_Func to use for Cell_Layout. This function is used 
  110.    --  instead of the standard attributes mapping for setting the column value, 
  111.    --  and should set the value of Cell_layout's cell renderer(s) as 
  112.    --  appropriate. Func may be null to remove and older one. 
  113.    --  This allows you to compute the attributes dynamically from several 
  114.    --  columns of the model for instance 
  115.  
  116.    generic 
  117.       type Data_Type (<>) is private; 
  118.    package Cell_Data_Functions is 
  119.       type Cell_Data_Func is access procedure 
  120.         (Cell_Layout : Gtk_Cell_Layout; 
  121.          Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  122.          Model       : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class; 
  123.          Iter        : Gtk.Tree_Model.Gtk_Tree_Iter; 
  124.          Data        : Data_Type); 
  125.  
  126.       type Destroy_Notify is access procedure (Data : in out Data_Type); 
  127.       --  Free the memory used by Data 
  128.  
  129.       procedure Set_Cell_Data_Func 
  130.         (Cell_Layout : Gtk_Cell_Layout; 
  131.          Cell        : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; 
  132.          Func        : Cell_Data_Func; 
  133.          Data        : Data_Type; 
  134.          Destroy     : Destroy_Notify := null); 
  135.       --  Same as the other Set_Cell_Data_Func, but passes an addition user 
  136.       --  data to the callback. 
  137.  
  138.    private 
  139.       --  <doc_ignore> 
  140.       type Data_Type_Access is access Data_Type; 
  141.  
  142.       type Data_Type_Record is record 
  143.          Func    : Cell_Data_Func; 
  144.          Destroy : Destroy_Notify; 
  145.          Data    : Data_Type_Access; 
  146.       end record; 
  147.       type Data_Type_Record_Access is access Data_Type_Record; 
  148.       pragma Convention (C, Data_Type_Record_Access); 
  149.  
  150.       procedure Internal_Destroy_Notify (Data : Data_Type_Record_Access); 
  151.       pragma Convention (C, Internal_Destroy_Notify); 
  152.  
  153.       procedure Internal_Data_Cell_Data_Func 
  154.         (Cell_Layout       : Gtk_Cell_Layout; 
  155.          Cell, Model, Iter : System.Address; 
  156.          Data              : Data_Type_Record_Access); 
  157.       pragma Convention (C, Internal_Data_Cell_Data_Func); 
  158.       --  </doc_ignore> 
  159.    end Cell_Data_Functions; 
  160.  
  161. private 
  162.    pragma Import (C, Get_Type, "gtk_cell_layout_get_type"); 
  163.    pragma Import (C, Clear, "gtk_cell_layout_clear"); 
  164. end Gtk.Cell_Layout; 
  165.  
  166. --  No binding: gtk_cell_layout_set_attributes