waba.ui
Class ToolTip

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.ToolTip

public class ToolTip
extends Control

ToolTip : Allows to display a tooltip when user keeps the pen in the control. The default popup delay is 1000ms and the amount of time it will be displayed is 2000ms (a pen up also hides the control). The tooltip must always be added after the control is added and had its bounds set; otherwise, you must call the added method to initialize the tip's bounds.

You can set the border color by changing the borderColor member (no border by default) and also the internal gap (see member insideGap).

The static members distX and distY lets you set the default distance from the control for all tooltips. It must be set before the tooltip is created.

 Example :
ToolTip.distX = 10; // 0 by default ToolTip.distY = 4; // 0 by default ToolTip.insideGap = 8; // 4 by default Button b; add(b = new Button("Hello Tooltip!"),CENTER,BOTTOM);
ToolTip t = new ToolTip(b, "Hi, this is a button");
t.borderColor = new Color(0,255,0); // null/none by default t.millisDelay = 500; // 1000 by default t.millisDisplay = 4000; // 2000 by default t.setBackColor(new Color(250,0,0)); // same as control's container by default
The tooltip can have multiple lines, separing them using the char '|' in your message.
Example :
 ToolTip t = new ToolTip(control, "Hi!|It's Me");
 
A ControlEvent.PRESSED event will be dispatched to the attached control right before the text is shown.


Field Summary
 Color borderColor
          The border color.
static int distX
          The x distance between the tip and the control, 0 by default.
static int distY
          The y distance between the tip and the control, 0 by default.
static int insideGap
          The gap between the border and the text.
 int millisDelay
          The amount of time that the pen must be down until the tip pops up (by default, 1000ms)
 int millisDisplay
          The mount of time that the tip will be shown (by default, 2000ms)
 
Fields inherited from class waba.ui.Control
AFTER, appId, appObj, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, clearValueInt, clearValueStr, enabled, FILL, FIT, fm, fmH, focusLess, focusTraversable, font, foreColor, foreDis, height, highlightRectsCount, isHighlighting, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, uiCE, uiFlat, uiPalm, uiVista, visible, width, x, x2, y, y2
 
Constructor Summary
ToolTip(Control control, java.lang.String message)
          Constructor
 
Method Summary
 void added()
          Set up the bounds for when we popup
 void onEvent(Event e)
          Called to process key, pen, control and other posted events.
 void setBackColor(Color c)
          Pass the color to the label, since we're invisible
 void setControlRect(Rect r)
          Change the control rect to the given one.
 void setForeColor(Color c)
          Pass the color to the label, since we're invisible
 void setText(java.lang.String newText)
          Sets the text of the tooltip.
 
Methods inherited from class waba.ui.Control
addTimer, changeHighlighted, clear, contains, createGraphics, drawHighlight, getAbsoluteRect, getBackColor, getFont, getFontMetrics, getForeColor, getNext, getParent, getParentWindow, getPos, getPreferredHeight, getPreferredWidth, getRect, getSize, isDisplayed, isEnabled, isVisible, onBoundsChanged, onColorsChanged, onFontChanged, onPaint, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, requestFocus, setBackForeColors, setEnabled, setFocusLess, setFont, setRect, setRect, setRect, setVisible, translateFromOrigin, uiStyleChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

insideGap

public static int insideGap
The gap between the border and the text. Common to all tooltips.

distX

public static int distX
The x distance between the tip and the control, 0 by default. Common to all tooltips.

distY

public static int distY
The y distance between the tip and the control, 0 by default. Common to all tooltips.

millisDelay

public int millisDelay
The amount of time that the pen must be down until the tip pops up (by default, 1000ms)

millisDisplay

public int millisDisplay
The mount of time that the tip will be shown (by default, 2000ms)

borderColor

public Color borderColor
The border color. By default, it is null and no border is shown
Constructor Detail

ToolTip

public ToolTip(Control control,
               java.lang.String message)
Constructor
Parameters:
control - the control which supports the tip
message - the message which will be written in the tip. You can make multiLine, using | character like in the Label control.
Method Detail

added

public void added()
Set up the bounds for when we popup

setForeColor

public void setForeColor(Color c)
Pass the color to the label, since we're invisible
Overrides:
setForeColor in class Control

setBackColor

public void setBackColor(Color c)
Pass the color to the label, since we're invisible
Overrides:
setBackColor in class Control

setText

public void setText(java.lang.String newText)
Sets the text of the tooltip. After calling this, you must set again the control's bounds by calling setControlRect(control.getAbsoluteRect());

setControlRect

public void setControlRect(Rect r)
Change the control rect to the given one. By default, its used the rect of the control passed in the constructor. The placement of the tooltip will be defined based on it, in a way that the control is not obscured.

onEvent

public void onEvent(Event e)
Description copied from class: Control
Called to process key, pen, control and other posted events.
Overrides:
onEvent in class Control
Tags copied from class: Control
Parameters:
event - the event to process
See Also:
Event, KeyEvent, PenEvent