net.rim.blackberry.api.bbm.platform.ui.chat.component
Class SmileyButton

java.lang.Object
  |
  +--net.rim.device.api.ui.Field
        |
        +--net.rim.device.api.ui.component.ButtonField
              |
              +--net.rim.blackberry.api.bbm.platform.ui.chat.component.SmileyButton
All Implemented Interfaces:
DrawStyle, FieldLabelProvider, IComponent, InputMethodListener

public final class SmileyButton
extends ButtonField

Smiley Button that can be used to display available emoticons. This field can be used together with the ReplyField inside a ReplyFieldManager.

Since:
BBM SDK 1.0

Field Summary
protected  Runnable _clickedRunnable
          Executes when the button is clicked.
protected  ActiveAutoTextEditField _fieldToGiveFocusTo
          If the smiley button has focus and the user starts typing, this field is given focus.
protected  Bitmap _focusBackground
          Image used for drawing the focus background.
protected  Bitmap _smiley
          Smiley image
 
Constructor Summary
SmileyButton()
          Creates an instance of the field with default images.
SmileyButton(Bitmap focusBackground, Bitmap smiley)
          Creates an instance of the field with provided bitmaps.
 
Method Summary
 void click()
          Posts the runnable on the event thread.
protected  void drawFocus(Graphics graphics, boolean on)
          Draws focus for the field.
 Runnable getClickRunnable()
          Returns the runnable which will be executed when the user clicks on the button.
 int getPreferredHeight()
          Returns preferred height which is the smiley size.
 int getPreferredWidth()
          Returns preferred width which is the smiley size.
protected  boolean keyChar(char key, int status, int time)
          Overrides to invoke the runnable when the field is clicked or to give focus away to the previously specified field.
protected  void layout(int width, int height)
          Sets the extent.
protected  boolean navigationUnclick(int status, int time)
          Overrides to invoke click().
protected  void paint(Graphics graphics)
          Paints the smiley button.
 void setClickRunnable(Runnable runnable)
          Sets the runnable.
 void setFieldToGiveFocusTo(ActiveAutoTextEditField field)
          Sets the field which will gain focus if the user starts typing while the smiley button has focus.
protected  boolean touchEvent(TouchEvent message)
          Overrides to invoke the runnable when the field is clicked or to give focus away to the previously specified field.
 

Field Detail

_clickedRunnable

protected Runnable _clickedRunnable
Executes when the button is clicked.
Since:
BBM SDK 1.0

_fieldToGiveFocusTo

protected ActiveAutoTextEditField _fieldToGiveFocusTo
If the smiley button has focus and the user starts typing, this field is given focus.
Since:
BBM SDK 1.0

_focusBackground

protected Bitmap _focusBackground
Image used for drawing the focus background.
Since:
BBM SDK 1.0

_smiley

protected Bitmap _smiley
Smiley image
Since:
BBM SDK 1.0
Constructor Detail

SmileyButton

public SmileyButton()
Creates an instance of the field with default images.
Since:
BBM SDK 1.0

SmileyButton

public SmileyButton(Bitmap focusBackground,
                    Bitmap smiley)
Creates an instance of the field with provided bitmaps. Both images must be of the same dimensions (heights must match, widths must match).
Parameters:
focusBackground - image used for drawing the smiley background when button has focus
smiley - smiley image
Throws:
IllegalArgumentException - if dimensions do not match (heights must match, widths must match)
NullPointerException - if a null bitmap is provided
Since:
BBM SDK 1.0
Method Detail

click

public void click()
Posts the runnable on the event thread.
Since:
BBM SDK 1.0

drawFocus

protected void drawFocus(Graphics graphics,
                         boolean on)
Draws focus for the field.
Parameters:
graphics - graphics context for drawing the focus
on - true if the focus should be set; otherwise, false
Since:
BBM SDK 1.0

getClickRunnable

public Runnable getClickRunnable()
Returns the runnable which will be executed when the user clicks on the button.
Returns:
runnable which will be executed when the user clicks on the button
Since:
BBM SDK 1.0

getPreferredHeight

public int getPreferredHeight()
Returns preferred height which is the smiley size.
Returns:
preferred height
Since:
BBM SDK 1.0

getPreferredWidth

public int getPreferredWidth()
Returns preferred width which is the smiley size.
Returns:
preferred width
Since:
BBM SDK 1.0

keyChar

protected boolean keyChar(char key,
                          int status,
                          int time)
Overrides to invoke the runnable when the field is clicked or to give focus away to the previously specified field.
Since:
BBM SDK 1.0
See Also:
ButtonField#keyChar(char key, int status, int time)

layout

protected void layout(int width,
                      int height)
Sets the extent.
Parameters:
width - Amount of available horizontal space
height - Amount of available vertical space
Since:
BBM SDK 1.0

navigationUnclick

protected boolean navigationUnclick(int status,
                                    int time)
Overrides to invoke click().
Returns:
true
Since:
BBM SDK 1.0
See Also:
ButtonField#navigationUnclick(int status, int time)

paint

protected void paint(Graphics graphics)
Paints the smiley button.
Parameters:
graphics - graphics context for drawing in this field
Since:
BBM SDK 1.0

setClickRunnable

public void setClickRunnable(Runnable runnable)
Sets the runnable.
Since:
BBM SDK 1.0

setFieldToGiveFocusTo

public void setFieldToGiveFocusTo(ActiveAutoTextEditField field)
Sets the field which will gain focus if the user starts typing while the smiley button has focus.
Parameters:
field - field to give focus to
Since:
BBM SDK 1.0

touchEvent

protected boolean touchEvent(TouchEvent message)
Overrides to invoke the runnable when the field is clicked or to give focus away to the previously specified field.
Returns:
true in case of TouchEvent.UNCLICK and the super implementation otherwise
Since:
BBM SDK 1.0
See Also:
ButtonField#touchEvent(TouchEvent message)



Copyright 1999- Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.