Sophie

Sophie

distrib > Fedora > 15 > x86_64 > by-pkgid > 0d2c760c00774fa1d350bb3c66520f68 > files > 391

GtkAda-doc-2.14.1-4.fc15.noarch.rpm

<?xml version='1.0' encoding='utf-8' />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
 <title>GtkAda: Gtk.Tooltips</title>
 <link rel='stylesheet' href='gtkada_rm.css' type='text/css'>
 <script src='gtkada_rm.js' type='text/javascript'></script>
</head><body>
<div id='objectName'>
 <span><a href='index.html'><img src='home.png' alt='Toc' title='Table of Contents'/></a> <a href='gallery.html'><img src='gallery.png' alt='Gallery' title='Widgets gallery'/></a>
 <a href='entities.html'><img src='entities.png' alt='Index' title='Global Index'/></a>
 <a href='tree.html'><img src='tree.png' alt='Tree' title='Widgets Inheritance Tree'/></a>
  </span>
Gtk.Tooltips
</div> <!--  objectName -->

<div id='leftSide'>
  <div id='classHierarchy'>
   <h2>Hierarchy</h2>
<ul class='top'>
  <li><img src='childtree.png' alt='_' /><a class='tree' onclick='treetoggle(this)'><img src='treeopen.png' alt='[-]' /></a><a href='glib-object.html'>GObject_Record</a></li><ul>
  <li><img src='childtree2.png' alt='  '/><img src='childtree.png' alt='_' /><a class='tree' onclick='treetoggle(this)'><img src='treeopen.png' alt='[-]' /></a><a href='gtk-object.html'>Gtk_Object_Record</a></li><ul>
  <li><img src='childtree2.png' alt='  '/><img src='childtree2.png' alt='  '/><img src='childtree.png' alt='_' />Gtk_Tooltips_Record</li></ul>
</ul>
</ul>
  </div> <!--  classHierarchy -->

  <div id='navigation'>
   <h2>Navigation</h2>
   <ul>
     <li><a href='#Description' onclick='return switchPage("page1")'>Description</a></li>
     <li><a href='#Types' onclick='return switchPage("page1")'>Types</a></li>
     <li><a href='#Subprograms' onclick='return switchPage("page1")'>Subprograms</a>
       <ul>
        <li><a href='#Subprograms__General' onclick='return switchPage("page1")'>General</a></li>
       </ul>
   </li>
     <li><a href='#Signals' onclick='return switchPage("page2")'>Signals</a></li>
     <li><a href='#Properties' onclick='return switchPage("page3")'>Properties</a></li>
     <li><a href='#Examples' onclick='return switchPage("page4")'>Examples</a></li>
     <li><a href='#Testgtk' onclick='return switchPage("page5")'>Testgtk</a></li>
   </ul>
  </div> <!--  navigation -->

</div>  <!--  leftSide -->

<div id='documentation'>
  <ul id='notebook'>
   <li id='tab_page1' class='current'><a href='' onclick='return !switchPage("page1")'>Entities</a></li>
   <li id='tab_page2'><a href='#Signals' onclick='return !switchPage("page2")'>Signals</a></li>
   <li id='tab_page3'><a href='#Properties' onclick='return !switchPage("page3")'>Properties</a></li>
  <li id='tab_page4'><a href='#Examples' onclick='return !switchPage("page4")'>Examples</a></li>
  <li id='tab_page5'><a href='#Testgtk' onclick='return !switchPage("page5")'>Testgtk</a></li>
  </ul>  <!-- notebook --> 

  <div id='notebook_page1' class='notebookPage'>
  <a name='Description'></a>
  <div class='description'>
   <h2>Description</h2>
Tooltips are the small text windows that popup when the mouse rests over
a widget, and that provide a quick help for the user.
<p>
In GtkAda, all tooltips belong to a group (a <a href='gtk-tooltips.html'>Gtk_Tooltips</a>). 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.
<p>
See the example at the end for how to change the default colors used
for tooltips.
  </div> <!-- description -->

  <a name='Types'></a>
  <div id='types'>
   <h2>Types</h2>
   <ul>
     <li><a name='Gtk_Tooltips_'></a>
         <div class='profile'><b>type</b> Gtk_Tooltips <b>is</b> <b>access</b> <b>all</b> Gtk_Tooltips_Record'Class;</div>
         <div class='comment'></div></li>
     <li><a name='Gtk_Tooltips_Record_'></a>
         <div class='profile'><b>type</b> Gtk_Tooltips_Record <b>is</b> <b>new</b> <a href='gtk-object.html'>Gtk.Object.Gtk_Object_Record</a> <b>with</b> <b>private</b>;</div>
         <div class='comment'></div></li>
   </ul>
  </div> <!-- types -->

  <a name='Subprograms'> </a>
  <a name='Subprograms__General'> </a>
  <div id='subprograms'>
   <h2>Subprograms</h2>
   <ul>
     <li><a name='Gtk_New_1_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Gtk_New</span> (Widget : <b>out</b> Gtk_Tooltips);</div>
<div class='comment'>Create a new group of tooltips.
</div></li>
     <li><a name='Initialize_2_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Initialize</span> (Widget : <b>access</b> Gtk_Tooltips_Record'Class);</div>
<div class='comment'>Internal initialization function.
See the section "Creating your own widgets" in the documentation.
</div></li>
     <li><a name='Get_Type_3_'></a>
<div class='profile'><b>function</b> <span class='name'>Get_Type</span> <b>return</b> <a href='glib.html'>Glib.GType</a>;</div>
<div class='comment'>Return the internal value associated with a <a href='gtk-tooltips.html'>Gtk_Tooltips</a>.
</div></li>
     <li><a name='Enable_4_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Enable</span> (Tooltips : <b>access</b> Gtk_Tooltips_Record);</div>
<div class='comment'><a href='gtk-tooltips.html#Enable_4_'>Enable</a> 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.
</div></li>
     <li><a name='Disable_5_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Disable</span> (Tooltips : <b>access</b> Gtk_Tooltips_Record);</div>
<div class='comment'><a href='gtk-tooltips.html#Disable_5_'>Disable</a> all the tooptips in the group.
From now on, no tooltips in this group will appear, unless they are
re-enabled.
</div></li>
     <li><a name='Set_Tip_6_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Set_Tip</span>
  (Tooltips    : <b>access</b> Gtk_Tooltips_Record;
   Widget      : <b>access</b> <a href='gtk-widget.html'>Gtk.Widget.Gtk_Widget_Record</a>'Class;
   Tip_Text    : UTF8_String;
   Tip_Private : UTF8_String := "");</div>
<div class='comment'>Add a new tooltip to <tt>Widget</tt>.
The message that appears in the tooltip is <tt>Tip_Text</tt>, and the tooltip
belongs to the group <tt>Tooltips</tt>.
<tt>Tip_Private</tt> contains more information, that can be displayed by a
Gtk_Tips_Query widget through the "widget_selected" signal.
In most cases, <tt>Tip_Private</tt> should simply keep its default empty value.
</div></li>
     <li><a name='Get_Data_7_'></a>
<div class='profile'><b>function</b> <span class='name'>Get_Data</span>
  (Widget : <b>access</b> <a href='gtk-widget.html'>Gtk.Widget.Gtk_Widget_Record</a>'Class) <b>return</b> Tooltips_Data;</div>
<div class='comment'>Return the tooltip data associated with the <tt>Widget</tt>.
If there is none, the two text fields in the returned structure have
a length 0.
</div></li>
     <li><a name='Force_Window_8_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Force_Window</span> (Widget : <b>access</b> Gtk_Tooltips_Record);</div>
<div class='comment'>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.
</div></li>
     <li><a name='Set_Markup_9_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Set_Markup</span>
  (Tooltips : <b>access</b> Gtk_Tooltips_Record;
   Text     : UTF8_String);</div>
<div class='comment'>Sets the text of the tooltip to be markup, which is marked up with the
<a href='pango.html'>Pango</a> text markup language. If markup is empty string, the label will be
hidden.
</div></li>
     <li><a name='Set_Icon_From_Stock_10_'></a>
<div class='profile'><b>procedure</b> <span class='name'>Set_Icon_From_Stock</span>
  (Tooltips : <b>access</b> Gtk_Tooltips_Record;
   Stock_Id : String;
   Size     : <a href='gtk-enums.html'>Gtk.Enums.Gtk_Icon_Size</a>);</div>
<div class='comment'>Sets the icon of the tooltip (which is in front of the text) to be the
stock item indicated by stock_id with the size indicated by size. If
stock_id is emtry string, the image will be hidden.
</div></li>
    </ul>
   </div> <!--  subprograms -->

  </div> <!--  notebook_page1 --> 
  <div id='notebook_page2' class='notebookPage'>
    <a name='Signals'></a>
    <div id='signals'>
      <h2>Signals</h2>
   <ul>
   </ul>
    </div> <!-- signals -->
  </div> <!--  notebook_page2 -->

  <div id='notebook_page3' class='notebookPage'>
    <a name='Properties'></a>
    <div class='properties'>
      <h2>Properties</h2>
      <ul>
      </ul>
    </div> <!-- properties -->
  </div> <!-- notebook_page3 -->

  <div id='notebook_page4' class='notebookPage'>
   <a name='Example'></a>
   <div id='example'><h2>Example</h2>  This example demonstrates how you can change the color scheme used
  <b>for</b> tooltips.
  This <b>is</b> <b>of</b> course done through styles. However, you can <b>not</b> directly
  associate a Gtk_Tooltips <b>with</b> a style, so you have to <b>do</b> 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"

<b>with</b> Gtk.Tooltips, Gtk.Style, Gtk.Enums, Gtk.Widget, Gdk.Color;
<b>use</b> Gtk.Tooltips, Gtk.Style, Gtk.Enums, Gtk.Widget, Gdk.Color;

<b>procedure</b> Tooltips <b>is</b>
   Style : Gtk_Style;
   Tips  : Gtk_Tooltips;
   Color : Gdk_Color;
<b>begin</b>
   Gtk_New (Style);
  blue foreground
   Set_Rgb (Color, 255, 255, 65535);
   Alloc (Get_Default_Colormap, Color);
   Set_Foreground (Style, State_Normal, Color);
  green background
   Set_Rgb (Color, 255, 65535, 255);
   Alloc (Get_Default_Colormap, Color);
   Set_Background (Style, State_Normal, Color);

   Gtk_New (Tips);
   Force_Window (Tips);
<b>end</b> Tooltips;
</div> <!-- example -->
  </div> <!-- notebook_page4 -->

  <div id='notebook_page5' class='notebookPage'>
   <a name='Testgtk'></a>
   <div id='testgtk'><h2>Testgtk source code</h2><div class='description'>This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda</div><i>-----------------------------------------------------------------------</i>
<i>--          GtkAda - Ada95 binding for the Gimp Toolkit              --</i>
<i>--                                                                   --</i>
<i>--   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   --</i>
<i>--                Copyright (C) 2000-2002 ACT-Europe                 --</i>
<i>--                                                                   --</i>
<i>-- This library is free software; you can redistribute it and/or     --</i>
<i>-- modify it under the terms of the GNU General Public               --</i>
<i>-- License as published by the Free Software Foundation; either      --</i>
<i>-- version 2 of the License, or (at your option) any later version.  --</i>
<i>--                                                                   --</i>
<i>-- This library is distributed in the hope that it will be useful,   --</i>
<i>-- but WITHOUT ANY WARRANTY; without even the implied warranty of    --</i>
<i>-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --</i>
<i>-- General Public License for more details.                          --</i>
<i>--                                                                   --</i>
<i>-- You should have received a copy of the GNU General Public         --</i>
<i>-- License along with this library; if not, write to the             --</i>
<i>-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --</i>
<i>-- Boston, MA 02111-1307, USA.                                       --</i>
<i>--                                                                   --</i>
<i>--                                                                          --</i>
<i>--                                                                          --</i>
<i>--                                                                          --</i>
<i>--                                                                          --</i>
<i>--                                                                          --</i>
<i>--                                                                          --</i>
<i>--                                                                          --</i>
<i>-----------------------------------------------------------------------</i>

<b>with</b> Glib;              <b>use</b> Glib;
<b>with</b> Glib.Object;       <b>use</b> Glib.Object;
<b>with</b> Gtk.Arguments;     <b>use</b> Gtk.Arguments;
<b>with</b> Gtk.Box;           <b>use</b> Gtk.Box;
<b>with</b> Gtk.Button;        <b>use</b> Gtk.Button;
<b>with</b> Gtk.Handlers;      <b>use</b> Gtk.Handlers;
<b>pragma</b> Warnings (Off);  --  Gtk.Tips_Query <b>is</b> obsolescent
<b>with</b> Gtk.Tips_Query;    <b>use</b> Gtk.Tips_Query;
<b>pragma</b> Warnings (On);
<b>with</b> Gtk.Toggle_Button; <b>use</b> Gtk.Toggle_Button;
<b>with</b> Gtk.Tooltips;      <b>use</b> Gtk.Tooltips;
<b>with</b> Gtk.Widget;        <b>use</b> Gtk.Widget;
<b>with</b> Gtk;               <b>use</b> Gtk;
<b>with</b> Ada.Text_IO;

<b>package</b> <b>body</b> Create_Tooltips <b>is</b>

   <b>package</b> Tooltips_Data <b>is</b> <b>new</b> User_Data (Gtk_Tooltips);
<i>   --  This is required to set tooltips for a widget.</i>

   <b>package</b> Query_Cb <b>is</b> <b>new</b> Handlers.Callback (Gtk_Tips_Query_Record);
   <b>package</b> Entered_Cb <b>is</b> <b>new</b> Handlers.User_Callback
     (Gtk_Tips_Query_Record, Gtk_Toggle_Button);
   <b>package</b> Selected_Cb <b>is</b> <b>new</b> Handlers.Return_Callback
     (Gtk_Tips_Query_Record, Gint);
   <b>package</b> Button_Cb <b>is</b> <b>new</b> Handlers.Callback (Gtk_Button_Record);

<i>   ----------</i>
<i>   -- Help --</i>
<i>   ----------</i>

   <b>function</b> Help <b>return</b> String <b>is</b>
   <b>begin</b>
      <b>return</b> "@bGtk_Tooltips@B allow you to provide short help texts to the"
        & " user. This also requires a @bGtk_Tips_Query@B widget, that"
        & " displays tooltips <b>and</b> has a ""What's this"" functionnality."
        & " Through the @bwidget_entered@B <b>and</b> @bwidget_selected@B signals,"
        & " you can decide to display some extensive help.";
   <b>end</b> Help;

<i>   --------------------</i>
<i>   -- Widget_Entered --</i>
<i>   --------------------</i>

   <b>procedure</b> Widget_Entered (Tips_Query  : <b>access</b> Gtk_Tips_Query_Record'Class;
                             Params      : <b>in</b> Gtk.Arguments.Gtk_Args;
                             Toggle      : <b>in</b> Gtk_Toggle_Button)
   <b>is</b>
<i>      --  Widget    : Gtk_Widget := Gtk_Widget (To_Object (Params, 1));</i>
      Tip_Text    : <b>constant</b> String := To_String (Params, 2);
<i>      --  Tip_Private : String := To_String (Params, 3);</i>

   <b>begin</b>
      <b>if</b> Get_Active (Toggle) <b>then</b>
         <b>if</b> Tip_Text'Length /= 0 <b>then</b>
            Set_Text (Tips_Query, "There <b>is</b> a Tip!");
         <b>else</b>
            Set_Text (Tips_Query, "There <b>is</b> no Tip!");
         <b>end</b> <b>if</b>;
<i>         --  Don't let GtkTipsQuery reset it's label</i>
         Emit_Stop_By_Name (Tips_Query, "widget_entered");
      <b>end</b> <b>if</b>;
   <b>end</b> Widget_Entered;

<i>   ---------------------</i>
<i>   -- Widget_Selected --</i>
<i>   ---------------------</i>

   <b>function</b> Widget_Selected (Tips_Query  : <b>access</b> Gtk_Tips_Query_Record'Class;
                             Params      : <b>in</b> Gtk.Arguments.Gtk_Args)
                            <b>return</b> Gint
   <b>is</b>
      Widget    : <b>constant</b> Gtk_Widget := Gtk_Widget (To_Object (Params, 1));
<i>      --  Tip_Text    : String := To_String (Params, 2);</i>
      Tip_Private : <b>constant</b> String := To_String (Params, 3);
      <b>pragma</b> Warnings (Off, Tips_Query);
   <b>begin</b>
      <b>if</b> Is_Created (Widget.<b>all</b>) <b>then</b>
         Ada.Text_IO.Put ("Help ");
         <b>if</b> Tip_Private'Length = 0 <b>then</b>
            Ada.Text_IO.Put ("None");
         <b>else</b>
            Ada.Text_IO.Put (Tip_Private);
         <b>end</b> <b>if</b>;
         Ada.Text_IO.Put_Line (" requested <b>for</b> "
                               & Type_Name (Get_Type (Widget)));
      <b>end</b> <b>if</b>;
      <b>return</b> 0;
   <b>end</b> Widget_Selected;

<i>   -----------------</i>
<i>   -- Start_Query --</i>
<i>   -----------------</i>

   <b>procedure</b> Start_Query (Tips_Query : <b>access</b> Gtk_Tips_Query_Record'Class) <b>is</b>
   <b>begin</b>
      Gtk.Tips_Query.Start_Query (Tips_Query);
   <b>end</b> Start_Query;

<i>   -----------------</i>
<i>   -- Get_Data_Cb --</i>
<i>   -----------------</i>

   <b>procedure</b> Get_Data_Cb (Button : <b>access</b> Gtk_Button_Record'Class) <b>is</b>
      Data : <b>constant</b> Gtk.Tooltips.Tooltips_Data :=
        Gtk.Tooltips.Get_Data (Button);
   <b>begin</b>
      Ada.Text_IO.Put_Line ("Result <b>of</b> call to Gtk.Tooltips.Get_Data:");
      Ada.Text_IO.Put_Line ("   Text=" & Data.Text);
      Ada.Text_IO.Put_Line ("   Text_Private=" & Data.Text_Private);
   <b>end</b> Get_Data_Cb;

<i>   ---------</i>
<i>   -- Run --</i>
<i>   ---------</i>

   <b>procedure</b> Run (Frame : <b>access</b> Gtk.Frame.Gtk_Frame_Record'Class) <b>is</b>
      Box1,
        Box2,
        Box3     : Gtk_Box;
      Button     : Gtk_Button;
      Tooltips   : Gtk_Tooltips;
      Toggle     : Gtk_Toggle_Button;
      Tips_Query : Gtk_Tips_Query;
      Frame2     : Gtk_Frame;
      Vbox       : Gtk_Box;

   <b>begin</b>
      Set_Label (Frame, "Tooltips");
      Gtk_New_Vbox (Vbox, Homogeneous => False, Spacing => 0);
      Add (Frame, Vbox);

      Gtk_New (Tooltips);
      Tooltips_Data.Set (Vbox, Tooltips, "tooltips");

      Gtk_New_Vbox (Box1, False, 0);
      Pack_Start (Vbox, Box1, Expand => False, Fill => False);

      Gtk_New_Vbox (Box2, False, 10);
      Set_Border_Width (Box2, 10);
      Pack_Start (Box1, Box2, True, True, 0);

      Gtk_New (Button, "Button1");
      Show (Button);
      Pack_Start (Box2, Button, False, False, 0);
      Set_Tip (Tooltips, Button, "This <b>is</b> button 1",
               "ContextHelp/buttons/1");

      Gtk_New (Button, "(Print result <b>of</b> Get_Data)");
      Pack_Start (Box2, Button, False, False, 0);
      Set_Tip (Tooltips, Button,
               "This <b>is</b> button 2. This <b>is</b> also a really long tool tip which"
               &" probably won't fit on a single line <b>and</b> will therefore "
               & "need to be wrapped. Hopefully the wrapping will work "
               & "correctly.", "ContextHelp/buttons/2");
      Button_Cb.Connect (Button, "clicked",
                         Button_Cb.To_Marshaller (Get_Data_Cb'Access));

      Gtk_New (Toggle, "Override TipsQuery Label");
      Pack_Start (Box2, Toggle, False, False, 0);
      Set_Tip (Tooltips, Toggle, "Toggle TipsQuery view.", "Hi!");

      Gtk_New_Vbox (Box3, False, 5);
      Set_Border_Width (Box3, 5);

      Gtk_New (Tips_Query);

      Gtk_New (Button, "[?]");
      Pack_Start (Box3, Button, False, False, 0);
      Query_Cb.Object_Connect
        (Button, "clicked",
         Query_Cb.To_Marshaller (Start_Query'Access),
         Slot_Object => Tips_Query);
      Set_Tip (Tooltips, Button, "Start the Tooltips Inspector",
               "ContextHelp/buttons/?");

      Pack_Start (Box3, Tips_Query, False, False, 0);
      Set_Caller (Tips_Query, Button);
      Entered_Cb.Connect (Tips_Query, "widget_entered",
                          Widget_Entered'Access, Toggle);
      Selected_Cb.Connect (Tips_Query, "widget_selected",
                           Widget_Selected'Access);

      Gtk_New (Frame2, "Tooltips Inspector");
      Set_Border_Width (Frame2, 0);
      Pack_Start (Box2, Frame2, True, True, 10);

      Add (Frame2, Box3);

      Show_All (Frame);
   <b>end</b> Run;

<b>end</b> Create_Tooltips;

</div> <!-- testgtk -->
  </div> <!-- notebook_page4 -->

</div> <!-- documentation -->

<div id='rightSide'>
 <div id='Index'>
  <h2>Alphabetical Index</h2>
  <ul>
   <li><a href='#Disable_5_' onclick='return switchPage("page1")'>Disable</a></li>
   <li><a href='#Enable_4_' onclick='return switchPage("page1")'>Enable</a></li>
   <li><a href='#Force_Window_8_' onclick='return switchPage("page1")'>Force_Window</a></li>
   <li><a href='#Get_Data_7_' onclick='return switchPage("page1")'>Get_Data</a></li>
   <li><a href='#Get_Type_3_' onclick='return switchPage("page1")'>Get_Type</a></li>
   <li><a href='#Gtk_New_1_' onclick='return switchPage("page1")'>Gtk_New</a></li>
   <li><a href='#Initialize_2_' onclick='return switchPage("page1")'>Initialize</a></li>
   <li><a href='#Set_Icon_From_Stock_10_' onclick='return switchPage("page1")'>Set_Icon_From_Stock</a></li>
   <li><a href='#Set_Markup_9_' onclick='return switchPage("page1")'>Set_Markup</a></li>
   <li><a href='#Set_Tip_6_' onclick='return switchPage("page1")'>Set_Tip</a></li>
  </ul>
 </div> <!-- Index -->
</div> <!-- rightSide -->

   <script language='javascript'>switchPage('page1');
adjust_height()</script>
 </body>
</html>