waba.ui
Class PushButtonGroup

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.PushButtonGroup

public class PushButtonGroup
extends Control

group of pushbuttons in just one control. created by guich from the original WExtras class Pushbutton of Stefan Kellner.


Field Summary
protected  boolean actLikeButton
           
protected  boolean actLikeCheck
           
protected  boolean atLastOne
           
static byte BUTTON
          the button will be selected and de-selected immediatly, acting like an real button
static byte CHECK
          one click in the button will select it and another click will de-select it. perhaps, only one button can be clicked at a time
protected  int cols
           
protected  int gap
           
 int id
          not used. can be useful if you have a group of PushButtonGroup and want to know easily which group was pressed.
protected  int insideGap
           
 int maxWidth
           
protected  java.lang.String[] names
           
static byte NORMAL
          normal: only one selected at a time
protected  int rows
           
protected  int selectedIndex
           
protected  int[] widths
           
 
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
PushButtonGroup(java.lang.String[] names, boolean atLastOne, int selected, int gap, int insideGap, int rows, boolean allSameWidth, byte type)
          create the buttons.
 
Method Summary
protected  void drawComponent(Graphics g)
           
 int getPreferredHeight()
          returns the preffered height of this control. added by guich
 int getPreferredWidth()
          returns the preffered width of this control. added by guich
 int getSelected()
          returns the index of the selected button
 void onBoundsChanged()
          called after an setRect. added by guich
 void onEvent(Event event)
          Called to process key, pen, control and other posted events.
 void onEvent(int type, int x, int y)
           
 void onPaint(Graphics g)
          Called to draw the control.
 void setSelected(int ind)
          sets the selected button index
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, getAbsoluteRect, getFontMetrics, getNext, getParent, getRect, isEnabled, isVisible, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, setEnabled, setFont, setRect, setRect, setVisible
 
Methods inherited from class java.lang.Object
hashCode, toString
 

Field Detail

NORMAL

public static final byte NORMAL
normal: only one selected at a time

BUTTON

public static final byte BUTTON
the button will be selected and de-selected immediatly, acting like an real button

CHECK

public static final byte CHECK
one click in the button will select it and another click will de-select it. perhaps, only one button can be clicked at a time

names

protected java.lang.String[] names

widths

protected int[] widths

selectedIndex

protected int selectedIndex

gap

protected int gap

insideGap

protected int insideGap

rows

protected int rows

cols

protected int cols

atLastOne

protected boolean atLastOne

actLikeButton

protected boolean actLikeButton

actLikeCheck

protected boolean actLikeCheck

id

public int id
not used. can be useful if you have a group of PushButtonGroup and want to know easily which group was pressed. Used in the Keyboard class.

maxWidth

public int maxWidth
Constructor Detail

PushButtonGroup

public PushButtonGroup(java.lang.String[] names,
                       boolean atLastOne,
                       int selected,
                       int gap,
                       int insideGap,
                       int rows,
                       boolean allSameWidth,
                       byte type)
create the buttons.
Parameters:
names - captions of the buttons
atLastOne - if true, at least one button must be selected
selected - default index to appear selected, or -1 if none
gap - space between the buttons, -1 glue them.
insideGap - space between the text and the button border. the ideal is 6.
rows - if > 1, creates an button matrix
allSameWidth - if true, all the buttons will have the width if the most large one.
type - can be NORMAL, BUTTON or CHECK
Method Detail

onBoundsChanged

public void onBoundsChanged()
Description copied from class: Control
called after an setRect. added by guich
Overrides:
onBoundsChanged in class Control

getSelected

public int getSelected()
returns the index of the selected button

getPreferredWidth

public int getPreferredWidth()
Description copied from class: Control
returns the preffered width of this control. added by guich
Overrides:
getPreferredWidth in class Control

getPreferredHeight

public int getPreferredHeight()
Description copied from class: Control
returns the preffered height of this control. added by guich
Overrides:
getPreferredHeight in class Control

onPaint

public void onPaint(Graphics g)
Description copied from class: Control
Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted. The background is painted by the top-level window control.
Overrides:
onPaint in class Control
Tags copied from class: Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

drawComponent

protected void drawComponent(Graphics g)

setSelected

public void setSelected(int ind)
sets the selected button index

onEvent

public void onEvent(int type,
                    int x,
                    int y)

onEvent

public void onEvent(Event event)
Description copied from class: Control
Called to process key, pen, control and other posted events.
Overrides:
onEvent in class Control
Tags copied from class: Control
Parameters:
event - the event to process
See Also:
Event, KeyEvent, PenEvent