[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Gtk.Tooltips

Tooltips are the small text windows that popup when the mouse rests over a widget, and that provide a quick help for the user.

In GtkAda, all tooltips belong to a group (a Gtk_Tooltips). All the individual tooltips in a group can be disabled or enabled at the same time. Likewise, the colors and style of a tooltip can be set on a group basis.

See the example at the end for how to change the default colors used for tooltips.

- Gtk.Tooltips Widget Hierarchy
- Gtk.Tooltips Subprograms
- Gtk.Tooltips Example

## Widget Hierarchy

    Gtk_Object                    (see section Package Gtk.Object)
       \___ Gtk_Data              (see section Package Gtk.Data)
          \___ Gtk_Tooltips       (see section Package Gtk.Tooltips)

## Subprograms

    procedure Gtk_New
      (Widget             : out    Gtk_Tooltips);
| Create a new group of tooltips.
    procedure Force_Window
      (Widget             : access Gtk_Tooltips_Record);
| Make sure the window in which the tooltips will be displayed is created. This is useful if you want to modify some characteristics of that window.
    function Get_Type              return Gtk.Gtk_Type;
| Return the internal value associated with a Gtk_Tooltips.
    procedure Enable
      (Tooltips           : access Gtk_Tooltips_Record);
| Enable all the tooltips in the group. From now on, when the mouse rests over a widget for a short period of time, the help text is automatically displayed.
    procedure Disable
      (Tooltips           : access Gtk_Tooltips_Record);
| Disable all the tooptips in the group. From now on, no tooltips in this group will appear, unless they are re-enabled.
    procedure Set_Delay
      (Tooltips           : access Gtk_Tooltips_Record;
       Duration           : in     Guint := 500);
| Set the delay between the user moving the mouse over a widget and the text appearing. Duration is in milli-seconds.
    procedure Set_Tip
      (Tooltips           : access Gtk_Tooltips_Record;
       Widget             : access Gtk.Widget.Gtk_Widget_Record'Class;
       Tip_Text           : in     String;
       Tip_Private        : in     String := "");
| Add a new tooltip to Widget. The message that appears in the tooltip is Tip_Text, and the tooltip belongs to the group Tooltips. Tip_Private contains more information, that can be displayed by a Gtk_Tips_Query widget through the "widget_selected" signal. In most cases, Tip_Private should simply keep its default empty value.
    function Get_Data
      (Widget             : access Gtk.Widget.Gtk_Widget_Record'Class)
       return Tooltips_Data;
| Return the tooltip data associated with the Widget. If there is none, the two text fields in the returned structure have a length 0.

## Example

     --  This example demonstrates how you can change the color scheme used
     --  for tooltips.
     --  This is of course done through styles. However, you can not directly
     --  associate a Gtk_Tooltips with a style, so you have to do the following.

     --  Note also that this choice should probably left to the user, who can
     --  modify it through a RC file that contains the following:
     --      style "postie"
     --      {
     --         bg[NORMAL]={1.0, 0.93, 0.22}
     --      }
     --      widget "gtk-tooltips*" style "postie"

     with Gtk.Tooltips, Gtk.Style, Gtk.Widget, Gtk.Enums, Gdk.Color;
     use Gtk.Tooltips, Gtk.Style, Gtk.Widget, Gtk.Enums, Gdk.Color;

     procedure Tooltips is
        Style : Gtk_Style;
        Tips  : Gtk_Tooltips;
        Color : Gdk_Color;
     begin
        Gtk_New (Style);

        --  blue foreground
        Set_Rgb (Color, 255, 255, 65535);
        Alloc (Gdk.Color.Get_System, Color);
        Set_Foreground (Style, State_Normal, Color);

        --  green background
        Set_Rgb (Color, 255, 65535, 255);
        Alloc (Gdk.Color.Get_System, Color);
        Set_Background (Style, State_Normal, Color);

        --  temporarily change the default style while creating the tooltips.
        Push_Style (Style);
        Gtk_New (tips);
        Force_Window (Tips);
        Pop_Style;

     end Tooltips;

[Contents] [Back] [Prev] [Up] [Next] [Forward]