1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2007 AdaCore                    -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  This widget displays any given text that can be manipulated by 
  27. --  both the user and the programmer. 
  28. --  The text can optionally be interactively modified by the user. 
  29. --  Different colors and fonts can be used for any given part of the 
  30. --  text. The background can have any color, or even be a pixmap. 
  31. --  </description> 
  32. --  <c_version>2.8.17</c_version> 
  33. --  <group>Obsolescent widgets</group> 
  34.  
  35. with Glib.Properties; 
  36. with Gdk.Color; 
  37. with Gdk.Font; 
  38. with Gtk.Adjustment; 
  39. pragma Warnings (Off); 
  40. with Gtk.Old_Editable; 
  41. pragma Warnings (On); 
  42. with Gdk.Window; 
  43.  
  44. package Gtk.Text is 
  45.    pragma Obsolescent; 
  46.  
  47.    type Gtk_Text_Record is new 
  48.      Gtk.Old_Editable.Gtk_Old_Editable_Record with private; 
  49.    type Gtk_Text is access all Gtk_Text_Record'Class; 
  50.  
  51.    procedure Gtk_New 
  52.      (Text : out Gtk_Text; 
  53.       Hadj : in Adjustment.Gtk_Adjustment := null; 
  54.       Vadj : in Adjustment.Gtk_Adjustment := null); 
  55.    --  Create a new text widget with the given adjustments. 
  56.    --  If either or both scrollbars is not provided, the text widget will 
  57.    --  create its own. 
  58.    --  You need to insert the Gtk_Text in a Gtk_Scrolled_Window to make 
  59.    --  the scrollbars visible. Not also that this widget does not currently 
  60.    --  support horizontal scrollbars. 
  61.  
  62.    procedure Initialize 
  63.      (Text : access Gtk_Text_Record'Class; 
  64.       Hadj : in Adjustment.Gtk_Adjustment := null; 
  65.       Vadj : in Adjustment.Gtk_Adjustment := null); 
  66.    --  Internal initialization function. 
  67.    --  See the section "Creating your own widgets" in the documentation. 
  68.  
  69.    function Get_Type return Gtk.Gtk_Type; 
  70.    --  Return the internal value associated with a Gtk_Text. 
  71.  
  72.    function Get_Text_Area (Text : access Gtk_Text_Record) 
  73.      return Gdk.Window.Gdk_Window; 
  74.    --  Return the specific window into which the text is displayed. 
  75.    --  Note that a Gtk_Text is in fact a complex widget, which includes borders 
  76.    --  on the sides. Thus, whenever you want to convert the mouse coordinates 
  77.    --  to a position in the text, you should use the Gdk.Window.Get_Pointer 
  78.    --  function, passing it this text area as the origin window, rather than 
  79.    --  directly Get_Window (Text). 
  80.    --  Note that null will be returned while Text hasn't been realized. 
  81.  
  82.    function Backward_Delete (Text : access Gtk_Text_Record; 
  83.                              Nchars : in Guint) 
  84.                             return Boolean; 
  85.    --  Backward delete Nchars characters from the current cursor position. 
  86.    --  There must be at least Nchars characters to delete before the 
  87.    --  pointer, or the operation will not be performed. 
  88.    --  Return True if the operation was successful, False otherwise. 
  89.  
  90.    function Forward_Delete (Text : access Gtk_Text_Record; 
  91.                             Nchars : in Guint) 
  92.                            return Boolean; 
  93.    --  Forward delete Nchars characters from the current point position. 
  94.    --  There must be at least Nchars characters to delete after the 
  95.    --  pointer, or the operation will not be performed. 
  96.    --  Return True if the operation was successful, False otherwise. 
  97.  
  98.    procedure Freeze (Text : access Gtk_Text_Record); 
  99.    --  Freeze the Gtk_Text widget. 
  100.    --  In other words, stop any redrawing of the widget until the Thaw 
  101.    --  operation is called. This operation is useful when 
  102.    --  a large number of changes need to be made within the widget. 
  103.    --  Freezing it during the updates will avoid some flicker seen by 
  104.    --  the user. 
  105.    --  Note also that an internal counter is incremented. The updates will 
  106.    --  be performed only when the same numbers of calls to Thaw has been 
  107.    --  performed. 
  108.    -- 
  109.    --  Note that you can not call Set_Position while the widget is frozen. 
  110.    --  This will create a Storage_Error otherwise. 
  111.  
  112.    procedure Thaw (Text : access Gtk_Text_Record); 
  113.    --  Cancel the previous call to Freeze. 
  114.    --  Allow the widget to be redrawn again, when Thaw has been called as 
  115.    --  many times as Freeze. 
  116.  
  117.    --  <doc_ignore> 
  118.    function Get_Gap_Position (Text : access Gtk_Text_Record) return Guint; 
  119.    function Get_Gap_Size (Text : access Gtk_Text_Record) return Guint; 
  120.    function Get_Text_End (Text : access Gtk_Text_Record) return Guint; 
  121.    --  Those 2 functions should probably be deleted. 
  122.    --  </doc_ignore> 
  123.  
  124.    function Get_Hadj (Text : access Gtk_Text_Record) 
  125.                      return Gtk.Adjustment.Gtk_Adjustment; 
  126.    --  Return the horizontal scrollbar associated with Text. 
  127.  
  128.    function Get_Vadj (Text : access Gtk_Text_Record) 
  129.                      return Gtk.Adjustment.Gtk_Adjustment; 
  130.    --  Return the vertical scrollbar associated to the given text widget. 
  131.  
  132.    function Get_Length (Text : access Gtk_Text_Record) return Guint; 
  133.    --  Return the total length of the text contained within the text widget. 
  134.  
  135.    function Get_Point (Text : access Gtk_Text_Record) return Guint; 
  136.    --  Get the current position of the insertion point (cursor). 
  137.    --  Return the number of characters from the upper left corner of the 
  138.    --  widget. 
  139.  
  140.    procedure Set_Point (Text  : access Gtk_Text_Record; 
  141.                         Index : in Guint); 
  142.    --  Set the insertion point position. 
  143.    --  This does not modify the position of the visible cursor (see 
  144.    --  Gtk.Editable.Set_Position instead). 
  145.  
  146.    --  <doc_ignore> 
  147.    function Get_Text (Text : access Gtk_Text_Record) return UTF8_String; 
  148.    --  Should probably be deleted (does not work, fails to capture 
  149.    --  user changes). Use Gtk.Editable.Get_Chars instead. 
  150.    --  </doc_ignore> 
  151.  
  152.    procedure Insert 
  153.      (Text   : access Gtk_Text_Record; 
  154.       Font   : in Gdk.Font.Gdk_Font := Gdk.Font.Null_Font; 
  155.       Fore   : in Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  156.       Back   : in Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 
  157.       Chars  : in UTF8_String := ""; 
  158.       Length : in Gint := -1); 
  159.    --  Insert the given string (Chars) inside the text of the text widget. 
  160.    --  Use the specified Font, foreground (Fore) and background 
  161.    --  (Back) colors. Only the first "Length" characters are inserted, 
  162.    --  unless Length is set to -1, in which case the complete string is 
  163.    --  inserted. 
  164.    --  Note that the colors must be allocated first, and the font loaded. 
  165.    --  If the default parameters are passed for font and colors, the text 
  166.    --  widget will use the ones defined in the style for Text (see Gtk.Style 
  167.    --  for more information about styles). 
  168.  
  169.    procedure Set_Adjustments (Text : access Gtk_Text_Record; 
  170.                               Hadj : Gtk.Adjustment.Gtk_Adjustment; 
  171.                               Vadj : Gtk.Adjustment.Gtk_Adjustment); 
  172.    --  Set the horizontal and vertical adjustments associated with Text. 
  173.  
  174.    procedure Set_Editable (Text     : access Gtk_Text_Record; 
  175.                            Editable : in Boolean := True); 
  176.    --  Toggle the editable state of the given text widget. 
  177.    --  This determines whether the user can edit the text or not. Note that 
  178.    --  the programmer can still perform any update. 
  179.  
  180.    procedure Set_Line_Wrap (Text      : access Gtk_Text_Record; 
  181.                             Line_Wrap : in Boolean := True); 
  182.    --  Set the Line_Wrap state of the given text widget. 
  183.    --  If set to True, the line is broken when it reaches the extent of the 
  184.    --  widget viewing area and the rest is displayed on the next line. If set 
  185.    --  to false, the line continues regardless of the size of current 
  186.    --  viewing area. 
  187.  
  188.    procedure Set_Word_Wrap (Text      : access Gtk_Text_Record; 
  189.                             Word_Wrap : in Boolean := True); 
  190.    --  Set the Word_Wrap state of the given text widget. 
  191.    --  If set to True, words are wrapped down to the next line if they can't 
  192.    --  be completed on the current line. 
  193.  
  194.    ------------- 
  195.    -- Signals -- 
  196.    ------------- 
  197.  
  198.    --  <signals> 
  199.    --  The following new signals are defined for this widget: 
  200.    -- 
  201.    --  </signals> 
  202.  
  203.    Signal_Set_Scroll_Adjustments : constant Glib.Signal_Name := 
  204.                                      "set_scroll_adjustments"; 
  205.  
  206.    ---------------- 
  207.    -- Properties -- 
  208.    ---------------- 
  209.  
  210.    --  <properties> 
  211.    --  The following properties are defined for this widget. See 
  212.    --  Glib.Properties for more information on properties. 
  213.    -- 
  214.    --  Name:  Hadjustment_Property 
  215.    --  Type:  Object 
  216.    --  Descr: Horizontal adjustment for the text widget 
  217.    -- 
  218.    --  Name:  Line_Wrap_Property 
  219.    --  Type:  Boolean 
  220.    --  Descr: Whether lines are wrapped at widget edges 
  221.    -- 
  222.    --  Name:  Vadjustment_Property 
  223.    --  Type:  Object 
  224.    --  Descr: Vertical adjustment for the text widget 
  225.    -- 
  226.    --  Name:  Word_Wrap_Property 
  227.    --  Type:  Boolean 
  228.    --  Descr: Whether words are wrapped at widget edges 
  229.    -- 
  230.    --  </properties> 
  231.  
  232.    Line_Wrap_Property   : constant Glib.Properties.Property_Boolean; 
  233.    Vadjustment_Property : constant Glib.Properties.Property_Object; 
  234.    Word_Wrap_Property   : constant Glib.Properties.Property_Boolean; 
  235.  
  236. private 
  237.    type Gtk_Text_Record is new Gtk.Old_Editable.Gtk_Old_Editable_Record 
  238.      with null record; 
  239.  
  240.    Hadjustment_Property : constant Glib.Properties.Property_Object := 
  241.      Glib.Properties.Build ("hadjustment"); 
  242.    Line_Wrap_Property : constant Glib.Properties.Property_Boolean := 
  243.      Glib.Properties.Build ("line-wrap"); 
  244.    Vadjustment_Property : constant Glib.Properties.Property_Object := 
  245.      Glib.Properties.Build ("vadjustment"); 
  246.    Word_Wrap_Property : constant Glib.Properties.Property_Boolean := 
  247.      Glib.Properties.Build ("word-wrap"); 
  248.  
  249.    pragma Import (C, Get_Type, "gtk_text_get_type"); 
  250. end Gtk.Text;