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