waba.ui
Class Window

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.Container
              |
              +--waba.ui.Window
Direct Known Subclasses:
Calendar, Keyboard, MainWindow, MessageBox

public class Window
extends Container
implements ISurface

Window is a "floating" top-level window. This class IS functional like a modal window. The following example creates an popup window class:

class TestWindow extends Window
{
Button btnHi;
public TestWindow()
{
super("Test",true); // with caption and borders
setRect(CENTER,CENTER,100,50);
add(btnHi=new Button("Hi!"));
btnHi.setRect(CENTER,CENTER,PREFERRED,PREFERRED);
}
public void onEvent(Event event)
{
if (event.type == ControlEvent.PRESSED && event.target == btnHi)
unpop(); // a WINDOW_CLOSED event will be posted to this PARENT window by the Window class.
}
}
To use it:
class Main extends MainWindow
{
TestWindow tw;
public void onStart()
{
popupModal(tw = new TestWindow());
}
public void onEvent(Event event)
{
if (event.target == tw && event.type == ControlEvent.WINDOW_CLOSED)
{
tw = null; // or any other stuff
}
}
}


Field Summary
protected static ControlEvent _controlEvent
           
protected  Graphics _g
           
protected static KeyEvent _keyEvent
           
protected static PenEvent _penEvent
           
protected  boolean beepIfOut
           
 boolean flicker
           
protected  Graphics gbuf
           
static int HIDE_STATE
          used to hide the showing state
protected  Image imgBuf
           
protected  boolean needsPaint
           
static byte NO_BORDER
           
static byte RECT_BORDER
           
static byte ROUND_BORDER
           
protected  byte style
           
static byte TAB_BORDER
           
static byte TAB_ONLY_BORDER
           
protected  java.lang.String title
           
protected  Font titleFont
           
 
Fields inherited from class waba.ui.Container
children, tail
 
Fields inherited from class waba.ui.Control
BOTTOM, CENTER, controlCount, enabled, FILL, fm, font, height, LEFT, name, next, parent, PREFERRED, prev, RIGHT, TOP, width, x, y
 
Constructor Summary
Window()
          Constructs a window.
Window(java.lang.String title, boolean border)
          Deprecated.  
Window(java.lang.String title, byte style)
           
 
Method Summary
 void _doPaint()
          paints the top-level window. called by MainWindow
 void _doPaint(int x, int y, int width, int height)
          Called by the VM to repaint an area.
 void _postEvent(int type, int key, int x, int y, int modifiers, int timeStamp)
          Called by the VM to post key and pen events.
protected  void damageRect(int x, int y, int width, int height)
          Adds a damage rectangle to the current list of areas that need repainting.
 Rect getClientRect()
          returns the client rect, ie, the rect minus the border and title area
 Control getFocus()
          Returns the focus control for this window.
static Window getTopMost()
          returns the topmost window
protected  boolean isTopMost()
          returns true if this window is the top-level window
 boolean isVisible()
          true if this is the topmost window
protected  boolean onClickedOutside(int x, int y)
          called when the user clicks outside the bounds of this window. must return true if the event was handled, false otherwise. guich@1.2
protected  void onPopup()
          called imediatly before the popup began. the default implementation does nothing.
protected  void onUnpop()
          called imediatly before the unpop began. the default implementation does nothing.
 void paintTitle(java.lang.String title, Graphics gg)
          paints the title immediatly.
 void popupModal(Window another)
          popup a modal window, and make it child of this one. all events in the behind window are deactivated
protected  void postPopup()
          called after the popup is done and after the repaint of this window. the default implementation does nothing.
protected  void postUnpop()
          called after the unpop is done and after the repaint of the other window. the default implementation does nothing.
 void setBorderStyle(byte style)
          sets the border style. use the constants XXXX_BORDER. sets the flag border accordingly to the style.
 void setDoubleBuffer(boolean doubleBuf)
          Sets true if we have to use an double buffer to paint the screen. only works in palm os 3.0 or greater. it automatically sets to off if palm os 2.0 is running.
 void setFocus(Control c)
          Sets focus to the given control.
 void setStatePosition(int x, int y)
          used to set the position where the status chars will be displayed. the chars are 8x11 pixels. this method must be called so the status can be displayed. these positions must be relative to this window, because they are converted to absolute coordinates. use setStatePosition(Window.HIDE_STATE,Window.HIDE_STATE) to remove the display of the state.
 void setTitle(java.lang.String title)
          sets the title and call repaint. if you want a imediate repaint, call paintTitle.
 void setTitleFont(Font titleFont)
          sets the title font
 void setVisible(boolean visible)
          this method does nothing in this class
 java.lang.String toString()
          Returns the string representation of the object.
 void unpop()
          hides this window. if there are no more windows, exit is called.
 
Methods inherited from class waba.ui.Container
add, findChild, paintChildren, remove
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, getAbsoluteRect, getFontMetrics, getNext, getParent, getPreferredHeight, getPreferredWidth, getRect, isEnabled, onBoundsChanged, onEvent, onPaint, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, setEnabled, setFont, setRect, setRect
 
Methods inherited from class java.lang.Object
hashCode
 

Field Detail

NO_BORDER

public static final byte NO_BORDER

RECT_BORDER

public static final byte RECT_BORDER

ROUND_BORDER

public static final byte ROUND_BORDER

TAB_BORDER

public static final byte TAB_BORDER

TAB_ONLY_BORDER

public static final byte TAB_ONLY_BORDER

HIDE_STATE

public static final int HIDE_STATE
used to hide the showing state

_keyEvent

protected static KeyEvent _keyEvent

_penEvent

protected static PenEvent _penEvent

_controlEvent

protected static ControlEvent _controlEvent

needsPaint

protected boolean needsPaint

_g

protected Graphics _g

imgBuf

protected Image imgBuf

gbuf

protected Graphics gbuf

title

protected java.lang.String title

beepIfOut

protected boolean beepIfOut

titleFont

protected Font titleFont

flicker

public boolean flicker

style

protected byte style
Constructor Detail

Window

public Window()
Constructs a window.

Window

public Window(java.lang.String title,
              boolean border)
Deprecated.  


Window

public Window(java.lang.String title,
              byte style)
Method Detail

setTitleFont

public void setTitleFont(Font titleFont)
sets the title font

setTitle

public void setTitle(java.lang.String title)
sets the title and call repaint. if you want a imediate repaint, call paintTitle.

setBorderStyle

public void setBorderStyle(byte style)
sets the border style. use the constants XXXX_BORDER. sets the flag border accordingly to the style.

setDoubleBuffer

public void setDoubleBuffer(boolean doubleBuf)
Sets true if we have to use an double buffer to paint the screen. only works in palm os 3.0 or greater. it automatically sets to off if palm os 2.0 is running.

setFocus

public void setFocus(Control c)
Sets focus to the given control. When a user types a key, the control with focus get the key event. At any given time, only one control in a window can have focus. Calling this method will cause a FOCUS_OUT control event to be posted to the window's current focus control (if one exists) and will cause a FOCUS_IN control event to be posted to the new focus control.

getFocus

public Control getFocus()
Returns the focus control for this window.
See Also:
setFocus(waba.ui.Control)

damageRect

protected void damageRect(int x,
                          int y,
                          int width,
                          int height)
Adds a damage rectangle to the current list of areas that need repainting.

onClickedOutside

protected boolean onClickedOutside(int x,
                                   int y)
called when the user clicks outside the bounds of this window. must return true if the event was handled, false otherwise. guich@1.2

_postEvent

public void _postEvent(int type,
                       int key,
                       int x,
                       int y,
                       int modifiers,
                       int timeStamp)
Called by the VM to post key and pen events.

getClientRect

public Rect getClientRect()
returns the client rect, ie, the rect minus the border and title area

paintTitle

public void paintTitle(java.lang.String title,
                       Graphics gg)
paints the title immediatly.

_doPaint

public void _doPaint(int x,
                     int y,
                     int width,
                     int height)
Called by the VM to repaint an area. If doubleBuf is true, paints the whole screen in a buffer and draws it on screen.

popupModal

public final void popupModal(Window another)
popup a modal window, and make it child of this one. all events in the behind window are deactivated

unpop

public final void unpop()
hides this window. if there are no more windows, exit is called.

_doPaint

public void _doPaint()
paints the top-level window. called by MainWindow

isTopMost

protected boolean isTopMost()
returns true if this window is the top-level window

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Returns the string representation of the object.
Overrides:
toString in class java.lang.Object

getTopMost

public static Window getTopMost()
returns the topmost window

onPopup

protected void onPopup()
called imediatly before the popup began. the default implementation does nothing.

postPopup

protected void postPopup()
called after the popup is done and after the repaint of this window. the default implementation does nothing.

onUnpop

protected void onUnpop()
called imediatly before the unpop began. the default implementation does nothing.

postUnpop

protected void postUnpop()
called after the unpop is done and after the repaint of the other window. the default implementation does nothing.

setVisible

public void setVisible(boolean visible)
this method does nothing in this class
Overrides:
setVisible in class Control

isVisible

public boolean isVisible()
true if this is the topmost window
Overrides:
isVisible in class Control

setStatePosition

public void setStatePosition(int x,
                             int y)
used to set the position where the status chars will be displayed. the chars are 8x11 pixels. this method must be called so the status can be displayed. these positions must be relative to this window, because they are converted to absolute coordinates. use setStatePosition(Window.HIDE_STATE,Window.HIDE_STATE) to remove the display of the state.