org.kobjects.kui
Class KForm

java.lang.Object
  extended by org.kobjects.kui.KForm

public class KForm
extends java.lang.Object


Field Summary
 boolean center
          Center content vertically
static Command DISMISS_COMMAND
          Dismiss command (for alerts, see KDisplay.createAlert)
protected  int h
          Content height; -1 indicates that a relayout is necessary.
static Command SELECT_COMMAND
          Select command for Lists
 
Constructor Summary
KForm(java.lang.String title)
          Creates an empty KForm with the given title.
 
Method Summary
 void addCommand(Command cmd)
          Add the given command to this form.
 void append(KItem item)
          Append the given item at the end of this KForm.
 void append(java.lang.String text)
          Shortcut for append(new KStringItem(null, text));
protected  void drawSoftKeys(Graphics g)
          Draws the soft keys and the option menu
protected  void drawTitle(Graphics g)
          Draws the title area of this form
 KItem get(int i)
          Returns the item with the given index
 int getFocusIndex()
          Returns the index of the focussed item
 KItem getFocussedItem()
          Returns the focussed item, or null if none is focussed.
 int getHeight()
          Calculates the height of the content area (excluding title, softkeys)
 Style getStyle(int index)
          Returns the style with the given identification.
 java.lang.String getTitle()
          Returns the title of this form, as set in the constructor or by setTitle().
 int getWidth()
          Calculates the width of the content area (excluding title, softkeys)
 void insert(int index, KItem item)
          insert the given item at the given index.
 void keyPressed(int code)
          Called when a key was pressed, but there is no focussed item to consume the event.
 void keyReleased(int code)
          Called when a key was released, but there is no focussed item to consume the event.
 void keyRepeated(int code)
          Called when a key was repeated, but there is no focussed item to consume the event.
 void paint(Graphics g)
          Draws the content area of this form.
 void pointerDragged(int x, int y)
          Indicates that the pointer was dragged to the given location.
 void pointerPressed(int x, int y)
          Indicates that the pointer was pressed at the given location.
 void pointerReleased(int x, int y)
          Indicates that the pointer was released at the given location.
 void removeCommand(Command cmd)
          Remove the given command.
 void repaint()
          Request a repaint of the form.
 void setBackgroundImage(Image img)
           
 void setCommandListener(KCommandListener listener)
          Set the command listener for this form
 boolean setFocusIndex(int i, int dir)
          Set the focus to the given item index
 void setInfo(java.lang.String text)
          Sets a short text in the right corner of the title bar.
 void setStyle(int index, Style style)
          Sets the style with the given identification for this form.
 void setTitle(java.lang.String title)
          Sets the form title and requests a relayout
 void setTitleIcon(Image icon)
          Set the title icon, displayed to the left of the title
 int size()
          Returns the number of items in this form
protected  void tick()
          Called by the display every 100 ms if the form is visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISMISS_COMMAND

public static final Command DISMISS_COMMAND
Dismiss command (for alerts, see KDisplay.createAlert)


SELECT_COMMAND

public static final Command SELECT_COMMAND
Select command for Lists


h

protected int h
Content height; -1 indicates that a relayout is necessary.


center

public boolean center
Center content vertically

Constructor Detail

KForm

public KForm(java.lang.String title)
Creates an empty KForm with the given title. If null, no title bar is drawn.

Parameters:
title - Title of the form
Method Detail

append

public void append(java.lang.String text)
Shortcut for append(new KStringItem(null, text));


append

public void append(KItem item)
Append the given item at the end of this KForm.


getStyle

public Style getStyle(int index)
Returns the style with the given identification. If no form specific style is set, the corresponding KDisplay style is returned.

See Also:
KDisplay.getStyle(int)

setStyle

public void setStyle(int index,
                     Style style)
Sets the style with the given identification for this form.

See Also:
KDisplay.setStyle(int,Style)

removeCommand

public void removeCommand(Command cmd)
Remove the given command. If the command is not attached to this form, nothing happens.


setTitleIcon

public void setTitleIcon(Image icon)
Set the title icon, displayed to the left of the title


drawTitle

protected void drawTitle(Graphics g)
Draws the title area of this form


paint

public void paint(Graphics g)
Draws the content area of this form. Overwrite this method if you intend to use this form like a MIDP Canvas.


drawSoftKeys

protected void drawSoftKeys(Graphics g)
Draws the soft keys and the option menu


setFocusIndex

public boolean setFocusIndex(int i,
                             int dir)
Set the focus to the given item index


get

public KItem get(int i)
Returns the item with the given index


getFocusIndex

public int getFocusIndex()
Returns the index of the focussed item


pointerPressed

public void pointerPressed(int x,
                           int y)
Indicates that the pointer was pressed at the given location. Only called if the pointer is not located on an item.

Parameters:
x - x-coordinate
y - y-coordinate

pointerReleased

public void pointerReleased(int x,
                            int y)
Indicates that the pointer was released at the given location. Only called if the pointer is not located on an item.

Parameters:
x - x-coordinate
y - y-coordinate

pointerDragged

public void pointerDragged(int x,
                           int y)
Indicates that the pointer was dragged to the given location. Only called if the pointer is not located on an item.

Parameters:
x - x-coordinate
y - y-coordinate

keyPressed

public void keyPressed(int code)
Called when a key was pressed, but there is no focussed item to consume the event.

Parameters:
code - normalized keycode

keyRepeated

public void keyRepeated(int code)
Called when a key was repeated, but there is no focussed item to consume the event.

Parameters:
code - normalized keycode

keyReleased

public void keyReleased(int code)
Called when a key was released, but there is no focussed item to consume the event.

Parameters:
code - normalized keycode

addCommand

public void addCommand(Command cmd)
Add the given command to this form.


setCommandListener

public void setCommandListener(KCommandListener listener)
Set the command listener for this form


size

public int size()
Returns the number of items in this form


insert

public void insert(int index,
                   KItem item)
insert the given item at the given index.


setTitle

public void setTitle(java.lang.String title)
Sets the form title and requests a relayout


getTitle

public java.lang.String getTitle()
Returns the title of this form, as set in the constructor or by setTitle().


getFocussedItem

public KItem getFocussedItem()
Returns the focussed item, or null if none is focussed.


repaint

public void repaint()
Request a repaint of the form.


tick

protected void tick()
Called by the display every 100 ms if the form is visible. If you override this method, please call super to make sure it will take care of cursor blinking.


getWidth

public int getWidth()
Calculates the width of the content area (excluding title, softkeys)

Returns:
width in pixels

getHeight

public int getHeight()
Calculates the height of the content area (excluding title, softkeys)

Returns:
height in pixels

setBackgroundImage

public void setBackgroundImage(Image img)

setInfo

public void setInfo(java.lang.String text)
Sets a short text in the right corner of the title bar. The title is automatically aligned to the right in this case.

Parameters:
text - Text to be displayed in the top right area