|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--waba.ui.Control
|
+--waba.ui.Container
|
+--waba.ui.TabPanel
TabPanel is a bar of text or image tabs.
It is assumed that all images will have the same height, but they may have different widths.
A scroll is automatically added when the total width of the titles is bigger than the control's width.
The panels are created automaticaly and switched when the user press the corresponding tab,
and a beep is heard.
Here is an example showing a tab bar being used:
public class MyProgram extends MainWindow
{
TabPanel tab;
public void onStart()
{
String nomes[] = {"Edition","Report"};
tab = new TabPanel(nomes);
add(tab);
tab.setGaps(2,2,2,2); // set it before setting the rect
tab.setRect(getClientRect());
tab.setPanel(0,new Edition()); // replace container 1 by a class that extends Container.
tab.getPanel(1).add(new Label("Not implemented"),CENTER,CENTER);
add(tab);
}
public void onEvent(Event event)
{
if (event.type == ControlEvent.PRESSED && event.target == tp)
{
int activeIndex = tp.getActiveTab();
... handle tab being pressed
}
}
}
Here's another sample that will show two TabPanels, one with images and another one with scrolling tabs.
Note that you must create img1.bmp and img2.bmp.
TabPanel tp1 = new TabPanel(new Image[]{new Image("img1.bmp"), new Image("img2.bmp")}, null);
add(tp1);
tp1.setRect(LEFT,TOP,Settings.screenWidth/2,Settings.screenHeight/2);
tp1.activeTabBackColor = new Color(222,222,222);
TabPanel tp2 = new TabPanel(new String[]{"verinha","marcelo","denise","guilherme","renato","michelle","rafael","barbara","lucas","ronaldo","nenem",});
add(tp2);
tp2.setRect(LEFT,AFTER+2,FILL,FILL);
Important: you CANNOT do a swap of a TabPanel to a Window. You must use the sample code above (add and setRect) instead.
| Field Summary | |
Color |
activeTabBackColor
This color is the one used to paint the background of the active tab. |
boolean |
beepOn
Set to off to disable the beep when a tab is clicked |
int |
lastActiveTab
Stores the last active tab index, or -1 if none was previously selected. |
static byte |
TABS_BOTTOM
|
static byte |
TABS_TOP
|
boolean |
useOnTabThePanelsColor
Sets the tabs with the same colors of the container. |
| Fields inherited from class waba.ui.Container |
BORDER_LOWERED,
BORDER_NONE,
BORDER_RAISED,
BORDER_SIMPLE,
children,
lastH,
lastW,
lastX,
lastY,
parentWindow,
started,
tabOrder,
tail |
| Fields inherited from class waba.ui.Control |
AFTER,
appId,
appObj,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
clearValueInt,
clearValueStr,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
focusTraversable,
font,
foreColor,
foreDis,
height,
highlightRectsCount,
isHighlighting,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
uiCE,
uiFlat,
uiPalm,
uiVista,
visible,
width,
x,
x2,
y,
y2 |
| Constructor Summary | |
TabPanel(Image[] imgCaptions,
Color transparentColor)
Constructs a tab bar control with images as captions, using the given color as transparent color. |
|
TabPanel(java.lang.String[] strCaptions)
Constructs a tab bar control with Strings as captions. |
|
| Method Summary | |
void |
changeHighlighted(Container p,
boolean forward)
Tranfer the focus between the containers on this TabPanel |
int |
getActiveTab()
Returns the index of the selected tab |
Color |
getCaptionColor()
Gets the text color of the captions. return a grayed value if this control is not enabled. |
Rect |
getClientRect()
Returns the area excluding the tabs and borders for this TabPanel. |
void |
getClientRect(Rect r)
Returns the area excluding the tabs and borders for this TabPanel. |
Container |
getPanel(int i)
Returns the Container for tab i |
int |
getPreferredHeight()
Returns the caption height for this TabPanel. |
int |
getPreferredWidth()
Returns the minimum width for this TabPanel |
protected void |
onBoundsChanged()
used internally. resizes all the containers and add the arrows if scroll is needed. |
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 by the system to pass events to the tab bar control. |
protected void |
onFontChanged()
Compute the rectangles of the tabs based on the selected (bolded) and unselected (plain) titles. |
void |
onPaint(Graphics g)
Called by the system to draw the tab bar. |
void |
setActiveTab(int tab)
Sets the currently active tab. |
void |
setBorderStyle(byte style)
Sets the type of border. see the waba.ui.Window xxx_BORDER constants. |
void |
setCaptionColor(Color capColor)
Sets the text color of the captions |
void |
setGaps(int gapL,
int gapR,
int gapT,
int gapB)
sets gaps between the containers and the TabPanel. |
void |
setHighlighting()
Only return to highlighting when we want |
void |
setPanel(int i,
Container container)
Replaces the default created Container with the given one. |
void |
setPanelsBackColor(Color[] backColors)
Deprecated. You may set the back color directly in the class that extends Container, or use getPanel(i).setBackColor(...). |
void |
setType(byte type)
Sets the position of the tabs. use constants TABS_TOP or TABS_BOTTOM. |
| Methods inherited from class waba.ui.Container |
add,
add,
add,
broadcastEvent,
clear,
findChild,
getChildren,
onAdd,
onRemove,
onStart,
paintChildren,
remove,
setEnabled,
swapToTopmostWindow |
| Methods inherited from class waba.ui.Control |
addTimer,
contains,
createGraphics,
drawHighlight,
getAbsoluteRect,
getBackColor,
getFont,
getFontMetrics,
getForeColor,
getNext,
getParent,
getParentWindow,
getPos,
getRect,
getSize,
isDisplayed,
isEnabled,
isVisible,
onWindowPaintFinished,
postEvent,
removeTimer,
repaint,
repaintNow,
requestFocus,
setBackColor,
setBackForeColors,
setFocusLess,
setFont,
setForeColor,
setRect,
setRect,
setRect,
setVisible,
translateFromOrigin,
uiStyleChanged |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public boolean beepOn
public Color activeTabBackColor
public boolean useOnTabThePanelsColor
public int lastActiveTab
public static final byte TABS_TOP
public static final byte TABS_BOTTOM
| Constructor Detail |
public TabPanel(java.lang.String[] strCaptions)
public TabPanel(Image[] imgCaptions,
Color transparentColor)
| Method Detail |
public void setPanelsBackColor(Color[] backColors)
getPanel(i).setBackColor(...).
public void setType(byte type)
public Container getPanel(int i)
public void setGaps(int gapL,
int gapR,
int gapT,
int gapB)
setRectpublic void setBorderStyle(byte style)
public void setPanel(int i,
Container container)
public void setActiveTab(int tab)
public int getActiveTab()
public int getPreferredHeight()
public int getPreferredWidth()
protected void onBoundsChanged()
protected void onFontChanged()
protected void onColorsChanged(boolean colorsChanged)
public void onPaint(Graphics g)
g - the graphics object for drawingGraphicspublic void setCaptionColor(Color capColor)
public Color getCaptionColor()
public Rect getClientRect()
public void getClientRect(Rect r)
public void onEvent(Event event)
event - the event to processEvent,
KeyEvent,
PenEvent
public void changeHighlighted(Container p,
boolean forward)
public void setHighlighting()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||