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