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