|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--waba.ui.Control
Control is the base class for user-interface objects.
Field Summary | |
static int |
AFTER
Constant used in param x/y in setRect. |
int |
appId
Application defined constant. |
protected Container |
asContainer
|
protected Window |
asWindow
|
protected Color |
backColor
Background color of this control. |
protected Color |
backDis
Disabled fore and back colors |
static int |
BEFORE
Constant used in param x/y in setRect. |
static int |
BOTTOM
Constant used in param y in setRect. |
static int |
CENTER
Constant used in params x and y in setRect. |
protected boolean |
enabled
True if the control is enabled (accepts events) or false if not |
static int |
FILL
Constant used in params width and height in setRect. |
static int |
FIT
Constant used in params width and height in setRect. |
FontMetrics |
fm
The fontMetrics corresponding to the controls font. |
protected int |
fmH
Equivalent to fm.getHeight(). |
protected boolean |
focusLess
If true, this control will receive pen and key events but will never gain focus |
protected Font |
font
The font used by the control. |
protected Color |
foreColor
Foreground color of this control. |
protected Color |
foreDis
Disabled fore and back colors |
protected int |
height
The control's height |
static int |
LEFT
Constant used in param x in setRect. |
protected Container |
parent
The parent of the control. |
static int |
PREFERRED
Constant used in params width and height in setRect. |
static int |
RANGE
|
static int |
RIGHT
Constant used in param x in setRect. |
static int |
SAME
Constant used in params x/y/width/height in setRect. |
static int |
TOP
Constant used in param y in setRect. |
protected boolean |
visible
True if the control is visible, false otherwise |
protected int |
width
The control's width |
protected int |
x
The control's x location |
protected int |
x2
x+width-1 |
protected int |
y
The control's y location |
protected int |
y2
y+height-1 |
Constructor Summary | |
protected |
Control()
creates the font for this control as the same font of the MainWindow. |
Method Summary | |
Timer |
addTimer(int millis)
Adds a timer to a control. |
boolean |
contains(int x,
int y)
Returns true if the given x and y coordinate in the parent's coordinate system is contained within this control. |
Graphics |
createGraphics()
Creates a Graphics object which can be used to draw in the control. |
Rect |
getAbsoluteRect()
Returns the absolute coordinates of this control relative to the MainWindow. |
Color |
getBackColor()
Get the desired background color of this control. |
Font |
getFont()
Gets the font of this conrol. |
FontMetrics |
getFontMetrics(Font font)
Returns the font metrics for a given font. |
Color |
getForeColor()
Get the desired foreground color of this control. |
Control |
getNext()
Returns the next child in the parent's list of controls. |
Container |
getParent()
Returns the control's parent container. |
Window |
getParentWindow()
Returns the control's parent Window or topMost if there's no parent (eg: the control still not added to any container). |
Coord |
getPos()
Returns the current position (x,y) of this control |
int |
getPreferredHeight()
Returns the preffered height of this control. |
int |
getPreferredWidth()
Returns the preffered width of this control. |
Rect |
getRect()
Returns a copy of the control's rectangle. |
Coord |
getSize()
Returns the current size (width,height) of this control |
boolean |
isDisplayed()
Return true if the parent of this Control is added to somewhere. |
boolean |
isEnabled()
Returns if this control can or not accept events |
boolean |
isVisible()
Returns true if this control is visible, false otherwise |
protected void |
onBoundsChanged()
Called after an setRect. |
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. |
void |
onEvent(Event event)
Called to process key, pen, control and other posted events. |
protected void |
onFontChanged()
Called after a setFont |
void |
onPaint(Graphics g)
Called to draw the control. |
protected void |
onWindowPaintFinished()
Called after the window has finished a paint. |
void |
postEvent(Event event)
Posts an event. |
boolean |
removeTimer(Timer timer)
Removes a timer from a control. |
void |
repaint()
Marks the control for repaint. |
void |
repaintNow()
Redraws the control immediately. |
void |
requestFocus()
Sets the focus to this control |
void |
setBackColor(Color c)
Set the background color of this control. |
void |
setBackForeColors(Color back,
Color fore)
Set the background and foreground colors at once |
void |
setEnabled(boolean enabled)
Sets if this control can or not accept events. |
void |
setFocusLess(boolean on)
Sets this control to be focusless. |
void |
setFont(Font font)
sets the font of this conrol. |
void |
setForeColor(Color c)
Set the foreground color of this control. |
void |
setRect(int x,
int y,
int width,
int height)
Sets or changes a control's position and size. |
void |
setRect(int x,
int y,
int width,
int height,
Control relative)
Sets or changes a control's position and size. |
void |
setRect(Rect r)
Sets or changes a control's position and size. |
void |
setVisible(boolean visible)
Shows or "hides" this control. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
protected int x
protected int y
protected int width
protected int height
protected Container parent
protected boolean enabled
protected Font font
public FontMetrics fm
protected boolean visible
protected Color foreColor
protected Color backColor
public int appId
public static final int PREFERRED
public static final int LEFT
public static final int CENTER
public static final int RIGHT
public static final int TOP
public static final int BOTTOM
public static final int FILL
public static final int BEFORE
public static final int SAME
public static final int AFTER
public static final int FIT
protected int fmH
protected Color foreDis
protected Color backDis
protected int x2
protected int y2
protected boolean focusLess
public static final int RANGE
protected Container asContainer
protected Window asWindow
Constructor Detail |
protected Control()
Method Detail |
public Timer addTimer(int millis)
millis
- the timer tick interval in millisecondsControlEvent
public boolean removeTimer(Timer timer)
public void setFont(Font font)
public Font getFont()
public int getPreferredWidth()
public int getPreferredHeight()
public FontMetrics getFontMetrics(Font font)
public void setRect(Rect r)
public void setRect(int x, int y, int width, int height)
add(new Label("1"),CENTER,CENTER); add(new Label("2"),AFTER,SAME); add(new Label("3"),SAME,AFTER); add(new Label("4"),BEFORE,SAME); add(new Label("5"),BEFORE,BEFORE);You will see this on screen:
512 43Note: add(control, x,y) does:
add(control); control.setRect(x,y,PREFERRED,PREFERRED);
Important! Always add the control to the container before doing a setRect.
The relative positioning does not work well if the control is placed outside screen bounds.
public void setRect(int x, int y, int width, int height, Control relative)
Important note: you can't use FILL/FIT with BEFORE/RIGHT/BOTTOM (for x,y).
add(new Label("1"),CENTER,CENTER); add(new Label("2"),AFTER,SAME); add(new Label("3"),SAME,AFTER); add(new Label("4"),BEFORE,SAME); add(new Label("5"),BEFORE,BEFORE);You will see this on screen:
512 43Note: add(control, x,y) does:
add(control); control.setRect(x,y,PREFERRED,PREFERRED);
Important! Always add the control to the container before doing a setRect.
The relative positioning does not work well if the control is placed outside screen bounds.
public Coord getSize()
public Coord getPos()
public void setVisible(boolean visible)
public boolean isVisible()
public Rect getRect()
public Rect getAbsoluteRect()
public Window getParentWindow()
public Container getParent()
public Control getNext()
public boolean contains(int x, int y)
public void repaint()
public void repaintNow()
public Graphics createGraphics()
public void postEvent(Event event)
Event
public void setEnabled(boolean enabled)
public boolean isEnabled()
public void onEvent(Event event)
event
- the event to processEvent
,
KeyEvent
,
PenEvent
public void onPaint(Graphics g)
g
- the graphics object for drawingGraphics
protected void onBoundsChanged()
protected void onColorsChanged(boolean colorsChanged)
protected void onWindowPaintFinished()
protected void onFontChanged()
public void setBackForeColors(Color back, Color fore)
public void setForeColor(Color c)
public void setBackColor(Color c)
public Color getForeColor()
public Color getBackColor()
public boolean isDisplayed()
public void requestFocus()
public void setFocusLess(boolean on)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |