1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2010, 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. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  A Gtk_Cell_View displays a single row of a Gtk_Tree_Model, using cell 
  26. --  renderers just like Gtk_Tree_View. Gtk_Cell_View doesn't support some of 
  27. --  the more complex features of Gtk_Tree_View, like cell editing and drag and 
  28. --  drop. 
  29. --  </description> 
  30. --  <c_version>2.14</c_version> 
  31. --  <group>Trees and Lists</group> 
  32. --  <testgtk>create_cell_view.adb</testgtk> 
  33.  
  34. with Glib.Properties; 
  35. with Glib.Types; 
  36. with Gdk.Color; 
  37. with Gdk.Pixbuf; 
  38. with Gtk.Cell_Renderer; 
  39. with Gtk.Cell_Layout; 
  40. with Gtk.Tree_Model; 
  41. with Gtk.Widget; 
  42.  
  43. package Gtk.Cell_View is 
  44.    type Gtk_Cell_View_Record is new Gtk.Widget.Gtk_Widget_Record 
  45.       with null record; 
  46.    type Gtk_Cell_View is access all Gtk_Cell_View_Record'Class; 
  47.  
  48.    procedure Gtk_New    (View : out Gtk_Cell_View); 
  49.    procedure Initialize (View : access Gtk_Cell_View_Record'Class); 
  50.    --  Creates or initializes a new Gtk_Cell_View 
  51.  
  52.    procedure Gtk_New_With_Text (View : out Gtk_Cell_View; Text : String); 
  53.    procedure Initialize_With_Text 
  54.      (View : access Gtk_Cell_View_Record'Class; Text : String); 
  55.    --  Creates a new Gtk_Cell_View widget, adds a Gtk_Cell_Renderer_Text to it, 
  56.    --  and makes it show Text. 
  57.  
  58.    procedure Gtk_New_With_Markup (View : out Gtk_Cell_View; Markup : String); 
  59.    procedure Initialize_With_Markup 
  60.      (View : access Gtk_Cell_View_Record'Class; Markup : String); 
  61.    --  Creates a new Gtk_Cell_View widget, adds a Gtk_Cell_Renderer_Text to it, 
  62.    --  and makes its show Markup. The text can be marked up with the Pango text 
  63.    --  markup language. 
  64.  
  65.    procedure Gtk_New_With_Pixbuf 
  66.      (View : out Gtk_Cell_View; Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  67.    procedure Initialize_With_Pixbuf 
  68.      (View   : access Gtk_Cell_View_Record'Class; 
  69.       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  70.    --  Creates a new Gtk_Cell_View widget, adds a Gtk_Cell_Renderer_Pixbuf 
  71.    --  to it, and makes its show Pixbuf. 
  72.  
  73.    function Get_Type return Glib.GType; 
  74.    --  Returns the internal value used for Gtk_Cell_View 
  75.  
  76.    procedure Set_Displayed_Row 
  77.      (Cell_View : access Gtk_Cell_View_Record; 
  78.       Path      : Gtk.Tree_Model.Gtk_Tree_Path); 
  79.    --  Sets the row of the model that is currently displayed by the 
  80.    --  Gtk_Cell_View. If the path is unset, then the contents of the cellview 
  81.    --  "stick" at their last value; this is not normally a desired result, but 
  82.    --  may be a needed intermediate state if say, the model for the 
  83.    --  Gtk_Cell_View becomes temporarily empty. 
  84.  
  85.    function Get_Displayed_Row 
  86.      (Cell_View : access Gtk_Cell_View_Record) 
  87.       return Gtk.Tree_Model.Gtk_Tree_Path; 
  88.    --  Returns a Gtk_Tree_Path referring to the currently displayed row. If no 
  89.    --  row is currently displayed, null is returned. 
  90.  
  91.    function Get_Size_Of_Row 
  92.      (Cell_View   : access Gtk_Cell_View_Record; 
  93.       Path        : Gtk.Tree_Model.Gtk_Tree_Path) 
  94.       return Gtk.Widget.Gtk_Requisition; 
  95.    --  Return the size needed by Cell_View to display the model row pointed to 
  96.    --  by Path. 
  97.  
  98.    procedure Set_Background_Color 
  99.      (Cell_View : access Gtk_Cell_View_Record; 
  100.       Color     : Gdk.Color.Gdk_Color); 
  101.    --  Sets the background color of View. 
  102.  
  103.    procedure Set_Model 
  104.      (Cell_View : access Gtk_Cell_View_Record; 
  105.       Model     : Gtk.Tree_Model.Gtk_Tree_Model); 
  106.    --  Sets the model for Cell_View.  If Cell_View already has a model 
  107.    --  set, it will remove it before setting the new model.  If Model is 
  108.    --  null, then it will unset the old model. 
  109.  
  110.    function Get_Model 
  111.      (Cell_View : access Gtk_Cell_View_Record) 
  112.       return Gtk.Tree_Model.Gtk_Tree_Model; 
  113.    --  Returns the model for Cell_View.  If no model is used, null is 
  114.    --  returned. 
  115.  
  116.    function Get_Cell_Renderers 
  117.      (Cell_View : access Gtk_Cell_View_Record) 
  118.      return Gtk.Cell_Renderer.Cell_Renderer_List.Glist; 
  119.    --  Returns the cell renderers which have been added to Cell_View. 
  120.    --  Return value: a list of cell renderers. 
  121.    --  The list must be freed by the caller. 
  122.  
  123.    ---------------- 
  124.    -- Interfaces -- 
  125.    ---------------- 
  126.    --  This class implements several interfaces. See Glib.Types 
  127.    -- 
  128.    --  - "Gtk_Cell_Layout" 
  129.    --    This interface should be used to add new renderers to the view, to 
  130.    --    render various columns of the model 
  131.  
  132.    package Implements_Cell_Layout is new Glib.Types.Implements 
  133.      (Gtk.Cell_Layout.Gtk_Cell_Layout, Gtk_Cell_View_Record, Gtk_Cell_View); 
  134.    function "+" 
  135.      (View : access Gtk_Cell_View_Record'Class) 
  136.       return Gtk.Cell_Layout.Gtk_Cell_Layout 
  137.       renames Implements_Cell_Layout.To_Interface; 
  138.    function "-" 
  139.      (Layout : Gtk.Cell_Layout.Gtk_Cell_Layout) 
  140.       return Gtk_Cell_View 
  141.       renames Implements_Cell_Layout.To_Object; 
  142.    --  Converts to and from the Gtk_Cell_Layout 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:  Background_Property 
  152.    --  Type:  String` 
  153.    --  Descr: Background color as a string 
  154.    -- 
  155.    --  Name:  Background_Gdk_Property 
  156.    --  Type:  Boxed 
  157.    --  Descr: Background color as a GdkColor 
  158.    -- 
  159.    --  Name:  Model_Property 
  160.    --  Type:  Object 
  161.    --  Descr: The model for cell view 
  162.    --  </properties> 
  163.  
  164.    Background_Property     : constant Glib.Properties.Property_String; 
  165.    --  Background_Gdk_Property : constant Glib.Properties.Property_Boxed; 
  166.    Model_Property : constant Glib.Properties.Property_Object; 
  167.  
  168. private 
  169.    pragma Import (C, Get_Type, "gtk_cell_view_get_type"); 
  170.  
  171.    Background_Property : constant Glib.Properties.Property_String := 
  172.      Glib.Properties.Build ("background"); 
  173.    Model_Property : constant Glib.Properties.Property_Object := 
  174.      Glib.Properties.Build ("model"); 
  175. --     Background_Gdk_Property : constant Glib.Properties.Property_Boxed := 
  176. --       Glib.Properties.Build ("background-gdk"); 
  177.  
  178. end Gtk.Cell_View;