1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2010, 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. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  Gtk.Tooltip belongs to the new tooltips API that was introduced in 
  26. --  GTK+ 2.12 and which deprecates the old Gtk.Tooltips API. 
  27. -- 
  28. --  Basic tooltips can be realized simply by using Set_Tooltip_Text or 
  29. --  Set_Tooltip_Markup without any explicit tooltip object. 
  30. -- 
  31. --  When you need a tooltip with a little more fancy contents, like adding 
  32. --  an image, or you want the tooltip to have different contents per 
  33. --  Gtk_Tree_View row or cell, you will have to do a little more work: 
  34. -- 
  35. --  Set the "has-tooltip" property to True, this will make GTK+ monitor the 
  36. --  widget for motion and related events which are needed to determine when 
  37. --  and where to show a tooltip. 
  38. -- 
  39. --  Connect to the "query-tooltip" signal. This signal will be emitted when a 
  40. --  tooltip is supposed to be shown. One of the arguments passed to the signal 
  41. --  handler is a Gtk_Tooltip object. This is the object that we are about to 
  42. --  display as a tooltip, and can be manipulated in your callback using 
  43. --  functions like Set_Icon.  There are functions for setting the tooltip's 
  44. --  markup, setting an image from a stock icon, or even putting in a custom 
  45. --  widget. 
  46. -- 
  47. --  Return True from your query-tooltip handler. This causes the tooltip to 
  48. --  be shown. If you return False, it will not be shown. 
  49. -- 
  50. --  In the probably rare case where you want to have even more control over 
  51. --  the tooltip that is about to be shown, you can set your own Gtk_Window 
  52. --  which will be used as tooltip window. This works as follows: 
  53. -- 
  54. --  Set "has-tooltip" and connect to "query-tooltip" as before. 
  55. -- 
  56. --  Use Gtk.Widget.Set_Tooltip_Window to set a Gtk_Window created by you as 
  57. --  tooltip window. 
  58. -- 
  59. --  In the ::query-tooltip callback you can access your window using 
  60. --  Gtk.Widget.Get_Tooltip_Window and manipulate as you wish. The semantics 
  61. --  of the return value are exactly as before, return True to show the window, 
  62. --  False to not show it. 
  63. --  </description> 
  64. --  <c_version>2.16.6</c_version> 
  65.  
  66. with Glib; 
  67. with Glib.Object; 
  68. with Gdk.Display; 
  69. with Gdk.Pixbuf; 
  70. with Gdk.Rectangle; 
  71. with Gtk.Enums; 
  72. with Gtk.Widget;    use Gtk.Widget; 
  73.  
  74. package Gtk.Tooltip is 
  75.  
  76.    type Gtk_Tooltip_Record is new Glib.Object.GObject_Record with private; 
  77.    type Gtk_Tooltip is access all Gtk_Tooltip_Record'Class; 
  78.  
  79.    function Get_Type return GType; 
  80.  
  81.    procedure Set_Custom 
  82.      (Tooltip       : access Gtk_Tooltip_Record; 
  83.       Custom_Widget : access Gtk_Widget_Record'Class); 
  84.    --  Replaces the widget packed into the tooltip with Custom_widget. 
  85.    --  By default a box with a Gtk_Image and Gtk_Label is embedded in 
  86.    --  the tooltip, which can be configured using Set_Markup and Set_Icon. 
  87.  
  88.    procedure Set_Icon 
  89.      (Tooltip : access Gtk_Tooltip_Record; 
  90.       Pixbuf  : Gdk.Pixbuf.Gdk_Pixbuf); 
  91.    --  Sets the icon of the tooltip (which is in front of the text) to be 
  92.    --  Pixbuf.  If Pixbuf is null, the image will be hidden. 
  93.  
  94.    procedure Set_Icon_From_Icon_Name 
  95.      (Tooltip   : access Gtk_Tooltip_Record; 
  96.       Icon_Name : String; 
  97.       Size      : Gtk.Enums.Gtk_Icon_Size); 
  98.    --  Sets the icon of the tooltip (which is in front of the text) to be 
  99.    --  the icon indicated by Icon_Name with the size indicated by Size. 
  100.    --  If Icon_Name is "", the image will be hidden. 
  101.  
  102.    procedure Set_Icon_From_Stock 
  103.      (Tooltip  : access Gtk_Tooltip_Record; 
  104.       Stock_Id : String; 
  105.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  106.    --  Sets the icon of the tooltip (which is in front of the text) to be 
  107.    --  the stock item indicated by Stock_Id with the size indicated by Size. 
  108.    --  If Stock_Id is "", the image will be hidden. 
  109.  
  110.    procedure Set_Markup 
  111.      (Tooltip : access Gtk_Tooltip_Record; 
  112.       Markup  : UTF8_String); 
  113.    --  Sets the text of the tooltip to be Markup, which is marked up with 
  114.    --  the Pango text markup language.  If Markup is "", the label will be 
  115.    --  hidden. 
  116.  
  117.    procedure Set_Text 
  118.      (Tooltip : access Gtk_Tooltip_Record; 
  119.       Text    : UTF8_String); 
  120.    --  Sets the text of the tooltip to be Text. If Text is "", the label 
  121.    --  will be hidden. See also Set_Markup. 
  122.  
  123.    procedure Set_Tip_Area 
  124.      (Tooltip : access Gtk_Tooltip_Record; 
  125.       Rect    : Gdk.Rectangle.Gdk_Rectangle); 
  126.    --  Sets the area of the widget, where the contents of this tooltip apply, 
  127.    --  to be Rect (in widget coordinates).  This is especially useful for 
  128.    --  properly setting tooltips on Gtk_Tree_View rows and cells, 
  129.    --  Gtk_Icon_Views, etc. 
  130.    -- 
  131.    --  For setting tooltips on Gtk_Tree_View, please refer to the convenience 
  132.    --  functions for this: Gtk.Tree_View.Set_Tooltip_Row and 
  133.    --  Gtk.Tree_View.Set_Tooltip_Cell. 
  134.  
  135.    procedure Trigger_Tooltip_Query 
  136.      (Display : access Gdk.Display.Gdk_Display_Record); 
  137.    --  Triggers a new tooltip query on Display, in order to update the current 
  138.    --  visible tooltip, or to show/hide the current tooltip.  This function is 
  139.    --  useful to call when, for example, the state of the widget changed by a 
  140.    --  key press. 
  141.  
  142. private 
  143.    type Gtk_Tooltip_Record is new Glib.Object.GObject_Record with null record; 
  144.  
  145.    pragma Import (C, Get_Type, "gtk_tooltip_get_type"); 
  146. end Gtk.Tooltip;