33
33
package org.gnome.gtk;
35
import org.gnome.gdk.Pixbuf;
35
36
import org.gnome.glib.Object;
40
* @author Thomas Schmitz
41
* @author Vreixo Formoso
44
* FIXME this is a placeholder stub for what will become the public API for
45
* this type. Replace this comment with appropriate javadoc including author
46
* and since tags. Note that the class may need to be made abstract, implement
47
* interfaces, or even have its parent changed. No API stability guarantees
48
* are made about this class until it has been reviewed by a hacker and this
49
* comment has been replaced.
39
* Displaying a tooltip when a user hovers the mouse over the widget or when
40
* the widget receives notification the cursor is at it when in keyboard mode.
43
* By default you can set text to show as a tooltip by using
44
* {@link Widget#setTooltipText(java.lang.String) } and
45
* {@link Widget#setTooltipMarkup(java.lang.String) } . However that is for
46
* basic text and only text. If you want more then that you can hookup your
47
* own tooltip query handler which in turn will provide an object of this
48
* class for you to use.
51
* In order to get an object of this class you first have to connect a
52
* queryTooltip Handler.
55
* // any widget will do
56
* widget = new Button();
57
* widget.connect(new Widget.queryTooltip() {
59
* public boolean onQueryTooltip(Widget source, int x, int y, boolean keyboardMode, Tooltip tooltip) {
60
* // setup your tooltip.
66
* Inside the method you can create your tooltip. You also receive the X and Y
67
* values at which you can determine whether to show the tooltip or not. Which
68
* is needed for example a TreeView which has a method to help you with. See
69
* {@link TreeView#hasTooltipContext(int, int, boolean) } for more information
70
* on how a TreeView handles tooltips.
73
* KeyboardMode indicates that the application is run by only the keyboard and
77
* When you want to show your tooltip return true, otherwise false.
80
* There are two modes of displaying your tooltip contents. The first is the
81
* basic Icon and String. You can set this up in anyway you want. Please do
82
* note that both are on the same line and that the icon will always be on the
86
* If you want something more fancy or display more information you set any
87
* widget to show. Suggested is a container of course. Where you have full
88
* freedom to place all your tooltip contents.
90
* @author Sarah Leibbrand
51
93
public class Tooltip extends Object
53
95
protected Tooltip(long pointer) {
100
* The text to display in the tooltip.
104
public void setText(String text) {
105
GtkTooltip.setText(this, text);
109
* The text in pango markup to display in the tooltip.
113
public void setMarkup(String markup) {
114
GtkTooltip.setMarkup(this, markup);
118
* The icon to display in your tooltip.
122
public void setIcon(Pixbuf icon) {
123
GtkTooltip.setIcon(this, icon);
127
* The stock icon with the requested size to display in the tooltip.
131
public void setStockIcon(Stock stock, IconSize size) {
132
GtkTooltip.setIcon(this, stock.getStockId(), size);
136
* The widget to display in the tooltip.
138
* This can be any widget but containers such as {@link Grid} are
143
public void setCustomWidget(Widget widget) {
144
GtkTooltip.setCustom(this, widget);