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. --  A Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text renders a given text in 
  26. --  its cell, using the font, color and style information provided by its 
  27. --  properties. The text will be ellipsized if it is too long and the 
  28. --  Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text:ellipsize property allows it. 
  29. -- 
  30. --  If the Gtk.Cell_Renderer.Gtk_Cell_Renderer:mode is 
  31. --  Gtk.Cell_Renderer.Cell_Renderer_Mode_Editable, the 
  32. --  Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text allows to edit its text using 
  33. --  an entry. 
  34. -- 
  35. --  </description> 
  36. pragma Ada_2005; 
  37.  
  38. pragma Warnings (Off, "*is already use-visible*"); 
  39. with Gdk.Color;         use Gdk.Color; 
  40. with Gdk.RGBA;          use Gdk.RGBA; 
  41. with Glib;              use Glib; 
  42. with Glib.Object;       use Glib.Object; 
  43. with Glib.Properties;   use Glib.Properties; 
  44. with Gtk.Cell_Renderer; use Gtk.Cell_Renderer; 
  45. with Pango.Enums;       use Pango.Enums; 
  46. with Pango.Font;        use Pango.Font; 
  47. with Pango.Layout;      use Pango.Layout; 
  48.  
  49. package Gtk.Cell_Renderer_Text is 
  50.  
  51.    type Gtk_Cell_Renderer_Text_Record is new Gtk_Cell_Renderer_Record with null record; 
  52.    type Gtk_Cell_Renderer_Text is access all Gtk_Cell_Renderer_Text_Record'Class; 
  53.  
  54.    ------------------ 
  55.    -- Constructors -- 
  56.    ------------------ 
  57.  
  58.    procedure Gtk_New (Self : out Gtk_Cell_Renderer_Text); 
  59.    procedure Initialize 
  60.       (Self : not null access Gtk_Cell_Renderer_Text_Record'Class); 
  61.    --  Creates a new Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text. Adjust how 
  62.    --  text is drawn using object properties. Object properties can be set 
  63.    --  globally (with g_object_set). Also, with 
  64.    --  Gtk.Tree_View_Column.Gtk_Tree_View_Column, you can bind a property to a 
  65.    --  value in a Gtk.Tree_Model.Gtk_Tree_Model. For example, you can bind the 
  66.    --  "text" property on the cell renderer to a string value in the model, 
  67.    --  thus rendering a different string in each row of the 
  68.    --  Gtk.Tree_View.Gtk_Tree_View 
  69.  
  70.    function Gtk_Cell_Renderer_Text_New return Gtk_Cell_Renderer_Text; 
  71.    --  Creates a new Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text. Adjust how 
  72.    --  text is drawn using object properties. Object properties can be set 
  73.    --  globally (with g_object_set). Also, with 
  74.    --  Gtk.Tree_View_Column.Gtk_Tree_View_Column, you can bind a property to a 
  75.    --  value in a Gtk.Tree_Model.Gtk_Tree_Model. For example, you can bind the 
  76.    --  "text" property on the cell renderer to a string value in the model, 
  77.    --  thus rendering a different string in each row of the 
  78.    --  Gtk.Tree_View.Gtk_Tree_View 
  79.  
  80.    function Get_Type return Glib.GType; 
  81.    pragma Import (C, Get_Type, "gtk_cell_renderer_text_get_type"); 
  82.  
  83.    ------------- 
  84.    -- Methods -- 
  85.    ------------- 
  86.  
  87.    procedure Set_Fixed_Height_From_Font 
  88.       (Self           : not null access Gtk_Cell_Renderer_Text_Record; 
  89.        Number_Of_Rows : Gint); 
  90.    --  Sets the height of a renderer to explicitly be determined by the "font" 
  91.    --  and "y_pad" property set on it. Further changes in these properties do 
  92.    --  not affect the height, so they must be accompanied by a subsequent call 
  93.    --  to this function. Using this function is unflexible, and should really 
  94.    --  only be used if calculating the size of a cell is too slow (ie, a 
  95.    --  massive number of cells displayed). If Number_Of_Rows is -1, then the 
  96.    --  fixed height is unset, and the height is determined by the properties 
  97.    --  again. 
  98.    --  "number_of_rows": Number of rows of text each cell renderer is 
  99.    --  allocated, or -1 
  100.  
  101.    ---------------- 
  102.    -- Properties -- 
  103.    ---------------- 
  104.    --  The following properties are defined for this widget. See 
  105.    --  Glib.Properties for more information on properties) 
  106.  
  107.    Align_Set_Property : constant Glib.Properties.Property_Boolean; 
  108.  
  109.    Alignment_Property : constant Pango.Enums.Property_Alignment; 
  110.    --  Type: Pango.Enums.Alignment 
  111.    --  Specifies how to align the lines of text with respect to each other. 
  112.    -- 
  113.    --  Note that this property describes how to align the lines of text in 
  114.    --  case there are several of them. The "xalign" property of 
  115.    --  Gtk.Cell_Renderer.Gtk_Cell_Renderer, on the other hand, sets the 
  116.    --  horizontal alignment of the whole text. 
  117.  
  118.    Attributes_Property : constant Glib.Properties.Property_Object; 
  119.    --  Type: Pango.Attributes.Pango_Attr_List 
  120.  
  121.    Background_Property : constant Glib.Properties.Property_String; 
  122.    --  Flags: write 
  123.  
  124.    Background_Gdk_Property : constant Gdk.Color.Property_Gdk_Color; 
  125.    --  Type: Gdk.Color.Gdk_Color 
  126.    --  Background color as a Gdk.Color.Gdk_Color 
  127.  
  128.    Background_Rgba_Property : constant Gdk.RGBA.Property_RGBA; 
  129.    --  Type: Gdk.RGBA.Gdk_RGBA 
  130.    --  Background color as a Gdk.RGBA.Gdk_RGBA 
  131.  
  132.    Background_Set_Property : constant Glib.Properties.Property_Boolean; 
  133.  
  134.    Editable_Property : constant Glib.Properties.Property_Boolean; 
  135.  
  136.    Editable_Set_Property : constant Glib.Properties.Property_Boolean; 
  137.  
  138.    Ellipsize_Property : constant Pango.Layout.Property_Pango_Ellipsize_Mode; 
  139.    --  Type: Pango.Layout.Pango_Ellipsize_Mode 
  140.    --  Specifies the preferred place to ellipsize the string, if the cell 
  141.    --  renderer does not have enough room to display the entire string. Setting 
  142.    --  it to Pango.Layout.Ellipsize_None turns off ellipsizing. See the 
  143.    --  wrap-width property for another way of making the text fit into a given 
  144.    --  width. 
  145.  
  146.    Ellipsize_Set_Property : constant Glib.Properties.Property_Boolean; 
  147.  
  148.    Family_Property : constant Glib.Properties.Property_String; 
  149.  
  150.    Family_Set_Property : constant Glib.Properties.Property_Boolean; 
  151.  
  152.    Font_Property : constant Glib.Properties.Property_String; 
  153.  
  154.    Font_Desc_Property : constant Pango.Font.Property_Font_Description; 
  155.    --  Type: Pango.Font.Pango_Font_Description 
  156.  
  157.    Foreground_Property : constant Glib.Properties.Property_String; 
  158.    --  Flags: write 
  159.  
  160.    Foreground_Gdk_Property : constant Gdk.Color.Property_Gdk_Color; 
  161.    --  Type: Gdk.Color.Gdk_Color 
  162.    --  Foreground color as a Gdk.Color.Gdk_Color 
  163.  
  164.    Foreground_Rgba_Property : constant Gdk.RGBA.Property_RGBA; 
  165.    --  Type: Gdk.RGBA.Gdk_RGBA 
  166.    --  Foreground color as a Gdk.RGBA.Gdk_RGBA 
  167.  
  168.    Foreground_Set_Property : constant Glib.Properties.Property_Boolean; 
  169.  
  170.    Language_Property : constant Glib.Properties.Property_String; 
  171.  
  172.    Language_Set_Property : constant Glib.Properties.Property_Boolean; 
  173.  
  174.    Markup_Property : constant Glib.Properties.Property_String; 
  175.    --  Flags: write 
  176.  
  177.    Max_Width_Chars_Property : constant Glib.Properties.Property_Int; 
  178.    --  The desired maximum width of the cell, in characters. If this property 
  179.    --  is set to -1, the width will be calculated automatically. 
  180.    -- 
  181.    --  For cell renderers that ellipsize or wrap text; this property controls 
  182.    --  the maximum reported width of the cell. The cell should not receive any 
  183.    --  greater allocation unless it is set to expand in its 
  184.    --  Gtk.Cell_Layout.Gtk_Cell_Layout and all of the cell's siblings have 
  185.    --  received their natural width. 
  186.  
  187.    Placeholder_Text_Property : constant Glib.Properties.Property_String; 
  188.    --  The text that will be displayed in the 
  189.    --  Gtk.Cell_Renderer.Gtk_Cell_Renderer if 
  190.    --  Gtk.Cell_Renderer_Text.Gtk_Cell_Renderer_Text:editable is True and the 
  191.    --  cell is empty. 
  192.    -- 
  193.    --  Since 3.6 
  194.  
  195.    Rise_Property : constant Glib.Properties.Property_Int; 
  196.  
  197.    Rise_Set_Property : constant Glib.Properties.Property_Boolean; 
  198.  
  199.    Scale_Property : constant Glib.Properties.Property_Double; 
  200.    --  Type: Gdouble 
  201.  
  202.    Scale_Set_Property : constant Glib.Properties.Property_Boolean; 
  203.  
  204.    Single_Paragraph_Mode_Property : constant Glib.Properties.Property_Boolean; 
  205.  
  206.    Size_Property : constant Glib.Properties.Property_Int; 
  207.  
  208.    Size_Points_Property : constant Glib.Properties.Property_Double; 
  209.    --  Type: Gdouble 
  210.  
  211.    Size_Set_Property : constant Glib.Properties.Property_Boolean; 
  212.  
  213.    Stretch_Property : constant Pango.Enums.Property_Stretch; 
  214.    --  Type: Pango.Enums.Stretch 
  215.  
  216.    Stretch_Set_Property : constant Glib.Properties.Property_Boolean; 
  217.  
  218.    Strikethrough_Property : constant Glib.Properties.Property_Boolean; 
  219.  
  220.    Strikethrough_Set_Property : constant Glib.Properties.Property_Boolean; 
  221.  
  222.    Style_Property : constant Pango.Enums.Property_Style; 
  223.    --  Type: Pango.Enums.Style 
  224.  
  225.    Style_Set_Property : constant Glib.Properties.Property_Boolean; 
  226.  
  227.    Text_Property : constant Glib.Properties.Property_String; 
  228.  
  229.    Underline_Property : constant Pango.Enums.Property_Underline; 
  230.    --  Type: Pango.Enums.Underline 
  231.  
  232.    Underline_Set_Property : constant Glib.Properties.Property_Boolean; 
  233.  
  234.    Variant_Property : constant Pango.Enums.Property_Variant; 
  235.    --  Type: Pango.Enums.Variant 
  236.  
  237.    Variant_Set_Property : constant Glib.Properties.Property_Boolean; 
  238.  
  239.    Weight_Property : constant Pango.Enums.Property_Weight; 
  240.    --  Type: Pango.Enums.Weight 
  241.  
  242.    Weight_Set_Property : constant Glib.Properties.Property_Boolean; 
  243.  
  244.    Width_Chars_Property : constant Glib.Properties.Property_Int; 
  245.    --  The desired width of the cell, in characters. If this property is set 
  246.    --  to -1, the width will be calculated automatically, otherwise the cell 
  247.    --  will request either 3 characters or the property value, whichever is 
  248.    --  greater. 
  249.  
  250.    Wrap_Mode_Property : constant Pango.Enums.Property_Wrap_Mode; 
  251.    --  Type: Pango.Enums.Wrap_Mode 
  252.    --  Specifies how to break the string into multiple lines, if the cell 
  253.    --  renderer does not have enough room to display the entire string. This 
  254.    --  property has no effect unless the wrap-width property is set. 
  255.  
  256.    Wrap_Width_Property : constant Glib.Properties.Property_Int; 
  257.    --  Specifies the minimum width at which the text is wrapped. The wrap-mode 
  258.    --  property can be used to influence at what character positions the line 
  259.    --  breaks can be placed. Setting wrap-width to -1 turns wrapping off. 
  260.  
  261.    ------------- 
  262.    -- Signals -- 
  263.    ------------- 
  264.  
  265.    type Cb_Gtk_Cell_Renderer_Text_UTF8_String_UTF8_String_Void is not null access procedure 
  266.      (Self     : access Gtk_Cell_Renderer_Text_Record'Class; 
  267.       Path     : UTF8_String; 
  268.       New_Text : UTF8_String); 
  269.  
  270.    type Cb_GObject_UTF8_String_UTF8_String_Void is not null access procedure 
  271.      (Self     : access Glib.Object.GObject_Record'Class; 
  272.       Path     : UTF8_String; 
  273.       New_Text : UTF8_String); 
  274.  
  275.    Signal_Edited : constant Glib.Signal_Name := "edited"; 
  276.    procedure On_Edited 
  277.       (Self  : not null access Gtk_Cell_Renderer_Text_Record; 
  278.        Call  : Cb_Gtk_Cell_Renderer_Text_UTF8_String_UTF8_String_Void; 
  279.        After : Boolean := False); 
  280.    procedure On_Edited 
  281.       (Self  : not null access Gtk_Cell_Renderer_Text_Record; 
  282.        Call  : Cb_GObject_UTF8_String_UTF8_String_Void; 
  283.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  284.        After : Boolean := False); 
  285.    --  This signal is emitted after Renderer has been edited. 
  286.    -- 
  287.    --  It is the responsibility of the application to update the model and 
  288.    --  store New_Text at the position indicated by Path. 
  289.    --  
  290.    --  Callback parameters: 
  291.    --    --  "path": the path identifying the edited cell 
  292.    --    --  "new_text": the new text 
  293.  
  294. private 
  295.    Wrap_Width_Property : constant Glib.Properties.Property_Int := 
  296.      Glib.Properties.Build ("wrap-width"); 
  297.    Wrap_Mode_Property : constant Pango.Enums.Property_Wrap_Mode := 
  298.      Pango.Enums.Build ("wrap-mode"); 
  299.    Width_Chars_Property : constant Glib.Properties.Property_Int := 
  300.      Glib.Properties.Build ("width-chars"); 
  301.    Weight_Set_Property : constant Glib.Properties.Property_Boolean := 
  302.      Glib.Properties.Build ("weight-set"); 
  303.    Weight_Property : constant Pango.Enums.Property_Weight := 
  304.      Pango.Enums.Build ("weight"); 
  305.    Variant_Set_Property : constant Glib.Properties.Property_Boolean := 
  306.      Glib.Properties.Build ("variant-set"); 
  307.    Variant_Property : constant Pango.Enums.Property_Variant := 
  308.      Pango.Enums.Build ("variant"); 
  309.    Underline_Set_Property : constant Glib.Properties.Property_Boolean := 
  310.      Glib.Properties.Build ("underline-set"); 
  311.    Underline_Property : constant Pango.Enums.Property_Underline := 
  312.      Pango.Enums.Build ("underline"); 
  313.    Text_Property : constant Glib.Properties.Property_String := 
  314.      Glib.Properties.Build ("text"); 
  315.    Style_Set_Property : constant Glib.Properties.Property_Boolean := 
  316.      Glib.Properties.Build ("style-set"); 
  317.    Style_Property : constant Pango.Enums.Property_Style := 
  318.      Pango.Enums.Build ("style"); 
  319.    Strikethrough_Set_Property : constant Glib.Properties.Property_Boolean := 
  320.      Glib.Properties.Build ("strikethrough-set"); 
  321.    Strikethrough_Property : constant Glib.Properties.Property_Boolean := 
  322.      Glib.Properties.Build ("strikethrough"); 
  323.    Stretch_Set_Property : constant Glib.Properties.Property_Boolean := 
  324.      Glib.Properties.Build ("stretch-set"); 
  325.    Stretch_Property : constant Pango.Enums.Property_Stretch := 
  326.      Pango.Enums.Build ("stretch"); 
  327.    Size_Set_Property : constant Glib.Properties.Property_Boolean := 
  328.      Glib.Properties.Build ("size-set"); 
  329.    Size_Points_Property : constant Glib.Properties.Property_Double := 
  330.      Glib.Properties.Build ("size-points"); 
  331.    Size_Property : constant Glib.Properties.Property_Int := 
  332.      Glib.Properties.Build ("size"); 
  333.    Single_Paragraph_Mode_Property : constant Glib.Properties.Property_Boolean := 
  334.      Glib.Properties.Build ("single-paragraph-mode"); 
  335.    Scale_Set_Property : constant Glib.Properties.Property_Boolean := 
  336.      Glib.Properties.Build ("scale-set"); 
  337.    Scale_Property : constant Glib.Properties.Property_Double := 
  338.      Glib.Properties.Build ("scale"); 
  339.    Rise_Set_Property : constant Glib.Properties.Property_Boolean := 
  340.      Glib.Properties.Build ("rise-set"); 
  341.    Rise_Property : constant Glib.Properties.Property_Int := 
  342.      Glib.Properties.Build ("rise"); 
  343.    Placeholder_Text_Property : constant Glib.Properties.Property_String := 
  344.      Glib.Properties.Build ("placeholder-text"); 
  345.    Max_Width_Chars_Property : constant Glib.Properties.Property_Int := 
  346.      Glib.Properties.Build ("max-width-chars"); 
  347.    Markup_Property : constant Glib.Properties.Property_String := 
  348.      Glib.Properties.Build ("markup"); 
  349.    Language_Set_Property : constant Glib.Properties.Property_Boolean := 
  350.      Glib.Properties.Build ("language-set"); 
  351.    Language_Property : constant Glib.Properties.Property_String := 
  352.      Glib.Properties.Build ("language"); 
  353.    Foreground_Set_Property : constant Glib.Properties.Property_Boolean := 
  354.      Glib.Properties.Build ("foreground-set"); 
  355.    Foreground_Rgba_Property : constant Gdk.RGBA.Property_RGBA := 
  356.      Gdk.RGBA.Build ("foreground-rgba"); 
  357.    Foreground_Gdk_Property : constant Gdk.Color.Property_Gdk_Color := 
  358.      Gdk.Color.Build ("foreground-gdk"); 
  359.    Foreground_Property : constant Glib.Properties.Property_String := 
  360.      Glib.Properties.Build ("foreground"); 
  361.    Font_Desc_Property : constant Pango.Font.Property_Font_Description := 
  362.      Pango.Font.Build ("font-desc"); 
  363.    Font_Property : constant Glib.Properties.Property_String := 
  364.      Glib.Properties.Build ("font"); 
  365.    Family_Set_Property : constant Glib.Properties.Property_Boolean := 
  366.      Glib.Properties.Build ("family-set"); 
  367.    Family_Property : constant Glib.Properties.Property_String := 
  368.      Glib.Properties.Build ("family"); 
  369.    Ellipsize_Set_Property : constant Glib.Properties.Property_Boolean := 
  370.      Glib.Properties.Build ("ellipsize-set"); 
  371.    Ellipsize_Property : constant Pango.Layout.Property_Pango_Ellipsize_Mode := 
  372.      Pango.Layout.Build ("ellipsize"); 
  373.    Editable_Set_Property : constant Glib.Properties.Property_Boolean := 
  374.      Glib.Properties.Build ("editable-set"); 
  375.    Editable_Property : constant Glib.Properties.Property_Boolean := 
  376.      Glib.Properties.Build ("editable"); 
  377.    Background_Set_Property : constant Glib.Properties.Property_Boolean := 
  378.      Glib.Properties.Build ("background-set"); 
  379.    Background_Rgba_Property : constant Gdk.RGBA.Property_RGBA := 
  380.      Gdk.RGBA.Build ("background-rgba"); 
  381.    Background_Gdk_Property : constant Gdk.Color.Property_Gdk_Color := 
  382.      Gdk.Color.Build ("background-gdk"); 
  383.    Background_Property : constant Glib.Properties.Property_String := 
  384.      Glib.Properties.Build ("background"); 
  385.    Attributes_Property : constant Glib.Properties.Property_Object := 
  386.      Glib.Properties.Build ("attributes"); 
  387.    Alignment_Property : constant Pango.Enums.Property_Alignment := 
  388.      Pango.Enums.Build ("alignment"); 
  389.    Align_Set_Property : constant Glib.Properties.Property_Boolean := 
  390.      Glib.Properties.Build ("align-set"); 
  391. end Gtk.Cell_Renderer_Text;