charva.awt
Class Toolkit

java.lang.Object
  extended bycharva.awt.Toolkit

public class Toolkit
extends java.lang.Object

Correct manage of FocusEvents public FocusEvent getLastFocusEvent() protected void setLastFocusEvent(FocusEvent ev_ )


Field Summary
static Color _defaultBackground
           
static Color _defaultForeground
           
static int A_ALTCHARSET
           
static int A_BLINK
           
static int A_BOLD
           
static int A_DIM
           
static int A_INVIS
           
static int A_NORMAL
           
static int A_REVERSE
           
static int A_STANDOUT
           
static int A_UNDERLINE
           
static int ACS_BTEE
           
static int ACS_BULLET
           
static int ACS_CKBOARD
           
static int ACS_DEGREE
           
static int ACS_DIAMOND
           
static int ACS_HLINE
           
static int ACS_LLCORNER
           
static int ACS_LRCORNER
           
static int ACS_LTEE
           
static int ACS_PLMINUS
           
static int ACS_PLUS
           
static int ACS_RTEE
           
static int ACS_S1
           
static int ACS_S9
           
static int ACS_TTEE
           
static int ACS_ULCORNER
           
static int ACS_URCORNER
           
static int ACS_VLINE
           
static char Auml
           
static int BLACK
           
static int BLUE
           
static int BUTTON1_CLICKED
           
static int BUTTON1_PRESSED
           
static int BUTTON1_RELEASED
           
static int BUTTON2_CLICKED
           
static int BUTTON2_PRESSED
           
static int BUTTON2_RELEASED
           
static int BUTTON3_CLICKED
           
static int BUTTON3_PRESSED
           
static int BUTTON3_RELEASED
           
static char Ccedil
           
static int CYAN
           
static char Eacute
           
static char Euml
           
static int GREEN
           
static boolean isColorEnabled
          This flag is true is the system property "charva.color" has been set.
static int KEY_MOUSE
           
static int MAGENTA
           
static char Ouml
           
static int RED
           
static char Uuml
           
static int WHITE
           
static int YELLOW
           
 
Method Summary
 void addChar(int chr, int attrib, int colorpair_)
          Add a character to the virtual terminal at the current cursor position.
 void addHorizontalLine(int length_, int attrib_, int colorpair)
          Draw a horizontal line of the specified length starting at the current cursor position.
 void addString(java.lang.String str_, int attrib_, int colorpair_)
          Add a string to the virtual terminal at the current cursor position.
 void addVerticalLine(int length_, int attrib_, int colorpair_)
          Draw a vertical line of the specified length starting at the current cursor position.
 void beep()
          Ring the terminal's bell.
 void blankBox(Point origin_, Dimension size_)
           
 void blankBox(Point origin_, Dimension size_, int colorpair_)
          Blank out a box using the specified color pair.
 void blankBoxNative(int left_, int top_, int right_, int bottom_, int colorpair_)
          Blank out the specified rectangle.
 void checkForKeystroke()
          Wait up to 100msec for a keystroke (or mouse-event).
 void clear()
          Clears the screen (calls the curses clear() function).
 void close()
          Close the terminal window and restore terminal settings (calls the curses endwin() function).
static int COLOR_PAIR_ATTRIBUTE(int pair_)
          Emulates the terminfo COLOR_PAIR macro.
 void drawBox(Point origin_, Dimension size_)
          Draw a box.
 void drawBox(Point origin_, Dimension size_, int colorpair_)
          Draw a box using the specified color pair.
 void drawBoxNative(int left_, int top_, int right_, int bottom_, int colorpair_)
           
 void fireKeystroke(int key_)
          Processes a keystroke that was pressed in the currently displayed window.
 void fireKeystroke(int key_, Component source_)
          Process a keystroke as if it was pressed while the focus was in the specified component.
 void fireMouseEvent(charva.awt.MouseEventInfo mouse_info)
          Processes the mouse-click specified by mouse_info.
 boolean getBooleanCapability(java.lang.String capname_)
          Provides an interface to the ncurses "tigetflag()" function.
 int getColorPairIndex(ColorPair pair_)
          Returns the color-pair index corresponding to the specified color-pair.
 Point getCursor()
          Get absolute cursor position
 Point getCursor(Point p_)
          Get absolute cursor position.
static Color getDefaultBackground()
          Returns the default background color.
static Color getDefaultForeground()
          Returns the default foreground color.
static Toolkit getDefaultToolkit()
          This static method instantiates a Toolkit object if it does not already exist; and returns a reference to the instantiated Toolkit.
 FocusEvent getLastFocusEvent()
           
 int getMaxColorPairs()
          Returns the maximum number of color-pairs (provides an interface to the ncurses COLOR_PAIRS global variable).
 charva.awt.MouseEventInfo getMouseEventInfo()
          Get information about a mouse event (i.e the coordinates, and which button was clicked).
 int getNumericCapability(java.lang.String capname_)
          Provides an interface to the ncurses "tigetnum()" function.
 int getScreenColumns()
           
 int getScreenRows()
           
 Dimension getScreenSize()
           
 java.lang.String getStringCapability(java.lang.String capname_)
          Provides an interface to the ncurses "tigetstr()" function.
 EventQueue getSystemEventQueue()
           
 Window getTopWindow()
          Get the top window of the window stack.
 java.lang.String getTtyName()
          Returns the tty device name (provides an interface to the Unix C function "ttyname()").
 boolean hasColors()
          Returns true if the terminal is capable of displaying colours.
 void initColorPair(int pair_, int fgnd_, int bgnd_)
          Provides an interface to the terminfo "init_pair()" function.
static boolean isActionKey(int _key)
          Returns true if the key code is greater than 255, indicating that it is a function key.
 boolean isWindowDisplayed(Window window_)
          Returns true if the specified window is currently displayed.
static java.lang.String key2ASCII(int key_)
          Convert the integer representation of a keystroke to an ASCII string.
 void print(java.lang.String str_)
          Provides an interface to the ncurses "mcprint()" function to ship the specified string to a printer attached to the terminal.
 void putp(java.lang.String str_)
          Provides an interface to the ncurses "putp()" function, to write a string to the terminal; the string must be a return value from getStringCapability().
 void redrawWin()
          Indicate to ncurses that all the lines on the screen have changed and need to be redrawn the next time Toolkit.sync() is called.
 void resetClipRect()
          Reset the clipping rectangle to the screen size.
 void setClipRect(Rectangle clip_)
          Set a clipping rectangle.
 void setClipRectNative(int left_, int top_, int right_, int bottom_)
          Set a clipping rectangle.
 void setCursor(int x_, int y_)
          Set absolute cursor position
 void setCursor(Point p)
          Set absolute cursor position
static void setDefaultBackground(Color color_)
          Changes the default background color.
static void setDefaultForeground(Color color_)
          Changes the default foreground color.
protected  void setLastFocusEvent(FocusEvent ev_)
           
 void startColors()
          An interface to the terminfo "start_colors()" function.
 void sync()
          Synchronize the state of the physical terminal with the state of the virtual terminal maintained by curses (ie provides an interface to the curses refresh() function).
 void triggerGarbageCollection(Component source_)
          Trigger garbage collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Auml

public static final char Auml
See Also:
Constant Field Values

Ccedil

public static final char Ccedil
See Also:
Constant Field Values

Eacute

public static final char Eacute
See Also:
Constant Field Values

Euml

public static final char Euml
See Also:
Constant Field Values

Ouml

public static final char Ouml
See Also:
Constant Field Values

Uuml

public static final char Uuml
See Also:
Constant Field Values

isColorEnabled

public static final boolean isColorEnabled
This flag is true is the system property "charva.color" has been set.


A_NORMAL

public static final int A_NORMAL

A_STANDOUT

public static final int A_STANDOUT

A_UNDERLINE

public static final int A_UNDERLINE

A_REVERSE

public static final int A_REVERSE

A_BLINK

public static final int A_BLINK

A_DIM

public static final int A_DIM

A_BOLD

public static final int A_BOLD

A_ALTCHARSET

public static final int A_ALTCHARSET

A_INVIS

public static final int A_INVIS

ACS_ULCORNER

public static final int ACS_ULCORNER

ACS_LLCORNER

public static final int ACS_LLCORNER

ACS_URCORNER

public static final int ACS_URCORNER

ACS_LRCORNER

public static final int ACS_LRCORNER

ACS_LTEE

public static final int ACS_LTEE

ACS_RTEE

public static final int ACS_RTEE

ACS_BTEE

public static final int ACS_BTEE

ACS_TTEE

public static final int ACS_TTEE

ACS_HLINE

public static final int ACS_HLINE

ACS_VLINE

public static final int ACS_VLINE

ACS_PLUS

public static final int ACS_PLUS

ACS_S1

public static final int ACS_S1

ACS_S9

public static final int ACS_S9

ACS_DIAMOND

public static final int ACS_DIAMOND

ACS_CKBOARD

public static final int ACS_CKBOARD

ACS_DEGREE

public static final int ACS_DEGREE

ACS_PLMINUS

public static final int ACS_PLMINUS

ACS_BULLET

public static final int ACS_BULLET

BLACK

public static final int BLACK

RED

public static final int RED

GREEN

public static final int GREEN

YELLOW

public static final int YELLOW

BLUE

public static final int BLUE

MAGENTA

public static final int MAGENTA

CYAN

public static final int CYAN

WHITE

public static final int WHITE

_defaultForeground

public static Color _defaultForeground

_defaultBackground

public static Color _defaultBackground

KEY_MOUSE

public static final int KEY_MOUSE
See Also:
Constant Field Values

BUTTON1_RELEASED

public static final int BUTTON1_RELEASED
See Also:
Constant Field Values

BUTTON1_PRESSED

public static final int BUTTON1_PRESSED
See Also:
Constant Field Values

BUTTON1_CLICKED

public static final int BUTTON1_CLICKED
See Also:
Constant Field Values

BUTTON2_RELEASED

public static final int BUTTON2_RELEASED
See Also:
Constant Field Values

BUTTON2_PRESSED

public static final int BUTTON2_PRESSED
See Also:
Constant Field Values

BUTTON2_CLICKED

public static final int BUTTON2_CLICKED
See Also:
Constant Field Values

BUTTON3_RELEASED

public static final int BUTTON3_RELEASED
See Also:
Constant Field Values

BUTTON3_PRESSED

public static final int BUTTON3_PRESSED
See Also:
Constant Field Values

BUTTON3_CLICKED

public static final int BUTTON3_CLICKED
See Also:
Constant Field Values
Method Detail

getDefaultToolkit

public static Toolkit getDefaultToolkit()
This static method instantiates a Toolkit object if it does not already exist; and returns a reference to the instantiated Toolkit.


getSystemEventQueue

public EventQueue getSystemEventQueue()

getTopWindow

public Window getTopWindow()
Get the top window of the window stack.


isWindowDisplayed

public boolean isWindowDisplayed(Window window_)
Returns true if the specified window is currently displayed.


fireKeystroke

public void fireKeystroke(int key_)
Processes a keystroke that was pressed in the currently displayed window.

Parameters:
key_ - the keystroke that was pressed. If it is less than 256, it is a ASCII or ISO8859-1 code; otherwise it is a function key as defined in the "VK_*" values.

fireKeystroke

public void fireKeystroke(int key_,
                          Component source_)
Process a keystroke as if it was pressed while the focus was in the specified component.

Parameters:
key_ - the keystroke that was pressed. If it is less than 256, it is an ASCII or ISO8859-1 code; otherwise it is a function key as defined in the "VK_*" values.

getLastFocusEvent

public FocusEvent getLastFocusEvent()

setLastFocusEvent

protected void setLastFocusEvent(FocusEvent ev_)

fireMouseEvent

public void fireMouseEvent(charva.awt.MouseEventInfo mouse_info)
Processes the mouse-click specified by mouse_info. Note that we disable mouse-click resolution in the ncurses library by setting "mouse_interval" to 0, because it doesn't appear to work properly. Instead we do it in this method.


checkForKeystroke

public void checkForKeystroke()
Wait up to 100msec for a keystroke (or mouse-event).


key2ASCII

public static java.lang.String key2ASCII(int key_)
Convert the integer representation of a keystroke to an ASCII string.


close

public void close()
Close the terminal window and restore terminal settings (calls the curses endwin() function).


clear

public void clear()
Clears the screen (calls the curses clear() function).


setCursor

public void setCursor(Point p)
Set absolute cursor position


setCursor

public void setCursor(int x_,
                      int y_)
Set absolute cursor position


getCursor

public Point getCursor()
Get absolute cursor position


getCursor

public Point getCursor(Point p_)
Get absolute cursor position. Use this overloaded version to avoid allocating a new Point on the heap.


addChar

public void addChar(int chr,
                    int attrib,
                    int colorpair_)
Add a character to the virtual terminal at the current cursor position.


addHorizontalLine

public void addHorizontalLine(int length_,
                              int attrib_,
                              int colorpair)
Draw a horizontal line of the specified length starting at the current cursor position.


addVerticalLine

public void addVerticalLine(int length_,
                            int attrib_,
                            int colorpair_)
Draw a vertical line of the specified length starting at the current cursor position.


addString

public void addString(java.lang.String str_,
                      int attrib_,
                      int colorpair_)
Add a string to the virtual terminal at the current cursor position.


drawBox

public void drawBox(Point origin_,
                    Dimension size_)
Draw a box.


drawBox

public void drawBox(Point origin_,
                    Dimension size_,
                    int colorpair_)
Draw a box using the specified color pair.


drawBoxNative

public void drawBoxNative(int left_,
                          int top_,
                          int right_,
                          int bottom_,
                          int colorpair_)

blankBox

public void blankBox(Point origin_,
                     Dimension size_)

blankBox

public void blankBox(Point origin_,
                     Dimension size_,
                     int colorpair_)
Blank out a box using the specified color pair.

Parameters:
origin_ - The top left corner of the rectangle.
size_ - The dimensions of the rectangle to blank out.
colorpair_ - The number of the color-pair (foreground+background) to use for blanking the rectangle.

blankBoxNative

public void blankBoxNative(int left_,
                           int top_,
                           int right_,
                           int bottom_,
                           int colorpair_)
Blank out the specified rectangle.


setClipRect

public void setClipRect(Rectangle clip_)
Set a clipping rectangle.


setClipRectNative

public void setClipRectNative(int left_,
                              int top_,
                              int right_,
                              int bottom_)
Set a clipping rectangle.


resetClipRect

public void resetClipRect()
Reset the clipping rectangle to the screen size.


beep

public void beep()
Ring the terminal's bell.


getScreenRows

public int getScreenRows()

getScreenColumns

public int getScreenColumns()

getScreenSize

public Dimension getScreenSize()

hasColors

public boolean hasColors()
Returns true if the terminal is capable of displaying colours.


getMaxColorPairs

public int getMaxColorPairs()
Returns the maximum number of color-pairs (provides an interface to the ncurses COLOR_PAIRS global variable).


startColors

public void startColors()
An interface to the terminfo "start_colors()" function.


getColorPairIndex

public int getColorPairIndex(ColorPair pair_)
                      throws TerminfoCapabilityException
Returns the color-pair index corresponding to the specified color-pair. If the color pair does not exist yet, it is created using the ncurses "init_pair" function. If all the available color-pairs are already in use, a TerminfoCapabilityException is thrown.

Throws:
TerminfoCapabilityException

sync

public void sync()
Synchronize the state of the physical terminal with the state of the virtual terminal maintained by curses (ie provides an interface to the curses refresh() function).


redrawWin

public void redrawWin()
Indicate to ncurses that all the lines on the screen have changed and need to be redrawn the next time Toolkit.sync() is called. This just calls the ncurses function "redrawwin(stdscr)".


getStringCapability

public java.lang.String getStringCapability(java.lang.String capname_)
                                     throws TerminfoCapabilityException
Provides an interface to the ncurses "tigetstr()" function.

Throws:
TerminfoCapabilityException

getNumericCapability

public int getNumericCapability(java.lang.String capname_)
                         throws TerminfoCapabilityException
Provides an interface to the ncurses "tigetnum()" function.

Throws:
TerminfoCapabilityException

getBooleanCapability

public boolean getBooleanCapability(java.lang.String capname_)
                             throws TerminfoCapabilityException
Provides an interface to the ncurses "tigetflag()" function.

Throws:
TerminfoCapabilityException

putp

public void putp(java.lang.String str_)
Provides an interface to the ncurses "putp()" function, to write a string to the terminal; the string must be a return value from getStringCapability().


print

public void print(java.lang.String str_)
           throws TerminfoCapabilityException
Provides an interface to the ncurses "mcprint()" function to ship the specified string to a printer attached to the terminal. Makes use of the "mc4" and "mc5" capabilities of the terminal (see "man curs_print").

Throws:
TerminfoCapabilityException

initColorPair

public void initColorPair(int pair_,
                          int fgnd_,
                          int bgnd_)
                   throws TerminfoCapabilityException
Provides an interface to the terminfo "init_pair()" function.

Throws:
TerminfoCapabilityException

COLOR_PAIR_ATTRIBUTE

public static int COLOR_PAIR_ATTRIBUTE(int pair_)
Emulates the terminfo COLOR_PAIR macro.


getTtyName

public java.lang.String getTtyName()
Returns the tty device name (provides an interface to the Unix C function "ttyname()").


setDefaultForeground

public static void setDefaultForeground(Color color_)
Changes the default foreground color.


getDefaultForeground

public static Color getDefaultForeground()
Returns the default foreground color.


setDefaultBackground

public static void setDefaultBackground(Color color_)
Changes the default background color.


getDefaultBackground

public static Color getDefaultBackground()
Returns the default background color.


triggerGarbageCollection

public void triggerGarbageCollection(Component source_)
Trigger garbage collection. This method can be called inside an event handler, but the call to System.gc() will be made after the event handler has completed (i.e. after drawing is completed). This is a convenient, but OPTIONAL, way of ensuring that the heap does not grow too large. Some experts say that it is better not to call System.gc() explicitly from inside an application; you take your pick.

Parameters:
source_ - the component that triggered the garbage collection (not important).

getMouseEventInfo

public charva.awt.MouseEventInfo getMouseEventInfo()
Get information about a mouse event (i.e the coordinates, and which button was clicked).


isActionKey

public static boolean isActionKey(int _key)
Returns true if the key code is greater than 255, indicating that it is a function key.