1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2000-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. --  Tooltips are the small text windows that popup when the mouse rests over 
  31. --  a widget, and that provide a quick help for the user. 
  32. -- 
  33. --  In GtkAda, all tooltips belong to a group (a Gtk_Tooltips). All the 
  34. --  individual tooltips in a group can be disabled or enabled at the same 
  35. --  time. Likewise, the colors and style of a tooltip can be set on a group 
  36. --  basis. 
  37. -- 
  38. --  See the example at the end for how to change the default colors used 
  39. --  for tooltips. 
  40. --  </description> 
  41. --  <c_version>2.8.17</c_version> 
  42. --  <testgtk>create_tooltips.adb</testgtk> 
  43.  
  44. with Glib; 
  45. with Glib.Object; 
  46. with Gtk.Enums; 
  47. with Gtk.Widget; 
  48.  
  49. package Gtk.Tooltips is 
  50.  
  51.    type Gtk_Tooltips_Record is new Glib.Object.GObject_Record with private; 
  52.    type Gtk_Tooltips is access all Gtk_Tooltips_Record'Class; 
  53.  
  54.    --  <doc_ignore> 
  55.    type Tooltips_Data 
  56.      (Text_Length : Natural; Private_Length : Natural) is 
  57.    record 
  58.       Tooltips     : Gtk_Tooltips;    -- the group of the tooltip 
  59.       Widget       : Gtk.Widget.Gtk_Widget; -- the widget to which it applies 
  60.       Text         : UTF8_String (1 .. Text_Length); -- the text of the tooltip 
  61.       Text_Private : UTF8_String (1 .. Private_Length); -- the private text 
  62.    end record; 
  63.    --  </doc_ignore> 
  64.  
  65.    procedure Gtk_New (Widget : out Gtk_Tooltips); 
  66.    --  Create a new group of tooltips. 
  67.  
  68.    procedure Initialize (Widget : access Gtk_Tooltips_Record'Class); 
  69.    --  Internal initialization function. 
  70.    --  See the section "Creating your own widgets" in the documentation. 
  71.  
  72.    function Get_Type return Glib.GType; 
  73.    --  Return the internal value associated with a Gtk_Tooltips. 
  74.  
  75.    procedure Enable (Tooltips : access Gtk_Tooltips_Record); 
  76.    --  Enable all the tooltips in the group. 
  77.    --  From now on, when the mouse rests over a widget for a short period of 
  78.    --  time, the help text is automatically displayed. 
  79.  
  80.    procedure Disable (Tooltips : access Gtk_Tooltips_Record); 
  81.    --  Disable all the tooptips in the group. 
  82.    --  From now on, no tooltips in this group will appear, unless they are 
  83.    --  re-enabled. 
  84.  
  85.    procedure Set_Tip 
  86.      (Tooltips    : access Gtk_Tooltips_Record; 
  87.       Widget      : access Gtk.Widget.Gtk_Widget_Record'Class; 
  88.       Tip_Text    : UTF8_String; 
  89.       Tip_Private : UTF8_String := ""); 
  90.    --  Add a new tooltip to Widget. 
  91.    --  The message that appears in the tooltip is Tip_Text, and the tooltip 
  92.    --  belongs to the group Tooltips. 
  93.    --  Tip_Private contains more information, that can be displayed by a 
  94.    --  Gtk_Tips_Query widget through the "widget_selected" signal. 
  95.    --  In most cases, Tip_Private should simply keep its default empty value. 
  96.  
  97.    function Get_Data 
  98.      (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return Tooltips_Data; 
  99.    --  Return the tooltip data associated with the Widget. 
  100.    --  If there is none, the two text fields in the returned structure have 
  101.    --  a length 0. 
  102.  
  103.    procedure Force_Window (Widget : access Gtk_Tooltips_Record); 
  104.    --  Make sure the window in which the tooltips will be displayed is 
  105.    --  created. 
  106.    --  This is useful if you want to modify some characteristics of that 
  107.    --  window. 
  108.  
  109.    procedure Set_Markup 
  110.      (Tooltips : access Gtk_Tooltips_Record; 
  111.       Text     : UTF8_String); 
  112.    --  Sets the text of the tooltip to be markup, which is marked up with the 
  113.    --  Pango text markup language. If markup is empty string, the label will be 
  114.    --  hidden. 
  115.  
  116.    procedure Set_Icon_From_Stock 
  117.      (Tooltips : access Gtk_Tooltips_Record; 
  118.       Stock_Id : String; 
  119.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  120.    --  Sets the icon of the tooltip (which is in front of the text) to be the 
  121.    --  stock item indicated by stock_id with the size indicated by size. If 
  122.    --  stock_id is emtry string, the image will be hidden. 
  123.  
  124.    ----------------- 
  125.    -- Obsolescent -- 
  126.    ----------------- 
  127.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  128.    --  from future versions of gtk+ (and therefore GtkAda). 
  129.    --  To find out whether your code uses any of these, we recommend compiling 
  130.    --  with the -gnatwj switch 
  131.    --  <doc_ignore> 
  132.  
  133.    procedure Set_Delay 
  134.      (Tooltips : access Gtk_Tooltips_Record; 
  135.       Duration : Guint := 500); 
  136.    pragma Obsolescent;  --  Set_Delay 
  137.    --  Set the delay between the user moving the mouse over a widget and the 
  138.    --  text appearing. Duration is in milli-seconds. 
  139.  
  140.    --  </doc_ignore> 
  141.  
  142.    ---------------- 
  143.    -- Properties -- 
  144.    ---------------- 
  145.  
  146.    --  <properties> 
  147.    --  The following properties are defined for this widget. See 
  148.    --  Glib.Properties for more information on properties. 
  149.    -- 
  150.    --  </properties> 
  151.  
  152.    ------------- 
  153.    -- Signals -- 
  154.    ------------- 
  155.  
  156.    --  <signals> 
  157.    --  The following new signals are defined for this widget: 
  158.    --  </signals> 
  159.  
  160. private 
  161.    type Gtk_Tooltips_Record is 
  162.      new Glib.Object.GObject_Record with null record; 
  163.  
  164.    pragma Import (C, Get_Type, "gtk_tooltips_get_type"); 
  165. end Gtk.Tooltips; 
  166.  
  167. --  <example> 
  168. --  <include>../examples/documentation/tooltips.adb</include> 
  169. --  </example> 
  170.  
  171. --  No binding: gtk_tooltips_get_info_from_tip_window