Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## waba.ui
Class TabPanel

    java.lang.Object
      |
      +--waba.ui.Control
            |
            +--waba.ui.Container
                  |
                  +--waba.ui.TabPanel

public class TabPanel
extends Container

TabPanel is a bar of tabs. (Very) Modified by Guich. The panels are created automaticaly and switched when the user press the corresponding tab. Makes an sound when the tab is pressed.

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
           }
        }
     }

Field Summary
`boolean` | `beepOn`
`static byte` | `TABS_BOTTOM`
`static byte` | `TABS_TOP`

Fields inherited from class waba.ui.Container
`BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, lastH, lastW, lastX, lastY, parentWindow, tail`

Fields inherited from class waba.ui.Control
`AFTER, appId, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, enabled, FILL, FIT, fm, fmH, focusLess, font, foreColor, foreDis, height, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, visible, width, x, x2, y, y2`

Constructor Summary
`TabPanel(String[] tabCaptions)` Constructs a tab bar control.

Method Summary
`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.
`Container` | `getPanel(int i)` Returns the Container for tab i
`int` | `getPreferredHeight()` Returns the minimum height for this TabPanel
`int` | `getPreferredWidth()` Returns the minimum width for this TabPanel
`protected void` | `onBoundsChanged()` used internally. resizes all the containers.
`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.
`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` | `setPanel(int i, Container container)` Sets this tabpanel container of index i to the given container.
`void` | `setPanelsBackColor(Color[] backColors)` Sets the colors of the panels.
`void` | `setType(byte type)` Sets the position of the tabs. use constants TAB_TOP or TAB_BOTTOM.

Methods inherited from class waba.ui.Container
`add, add, add, broadcastEvent, findChild, getChildren, onStart, paintChildren, remove, setEnabled`

Methods inherited from class waba.ui.Control
`addTimer, contains, createGraphics, getAbsoluteRect, getBackColor, getFont, getFontMetrics, getForeColor, getNext, getParent, getParentWindow, getPos, getRect, getSize, isDisplayed, isEnabled, isVisible, onFontChanged, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, requestFocus, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setVisible`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, toString, wait, wait`

Field Detail

### beepOn

    public boolean beepOn

### TABS_TOP

    public static final byte TABS_TOP

### TABS_BOTTOM

    public static final byte TABS_BOTTOM

Constructor Detail

### TabPanel

    public TabPanel(String[] tabCaptions)

  Constructs a tab bar control.

Method Detail

### setPanelsBackColor

    public void setPanelsBackColor(Color[] backColors)

  Sets the colors of the panels. The number of colors must match the number of panels.

### setType

    public void setType(byte type)

  Sets the position of the tabs. use constants TAB_TOP or TAB_BOTTOM. Since the tabs are not changed dinamicaly, this method must be called after the constructor.

### getPanel

    public Container getPanel(int i)

  Returns the Container for tab i

### setGaps

    public void setGaps(int gapL,
                        int gapR,
                        int gapT,
                        int gapB)

  sets gaps between the containers and the TabPanel. Must be called before `setRect`

### setBorderStyle

    public void setBorderStyle(byte style)

  Sets the type of border. see the waba.ui.Window xxx_BORDER constants. PS: currently, only the NO_BORDER and RECT_BORDER are supported. NO_BORDER only draws the line under the tabs.
  Overrides:
    setBorderStyle in class Container

### setPanel

    public void setPanel(int i,
                         Container container)

  Sets this tabpanel container of index i to the given container. This way you can avoid adding a container to a container and as such waste memory. Note that you must do this before the first setRect for this tabPanel; otherwise, you must explicitly call setRect again to update the added container bounds

### setActiveTab

    public void setActiveTab(int tab)

  Sets the currently active tab. A PRESSED event will be posted to the given tab if it is not the currently active tab. the panels will be switched.

### getActiveTab

    public int getActiveTab()

  Returns the index of the selected tab

### onEvent

    public void onEvent(Event event)

  Called by the system to pass events to the tab bar control.
  Overrides:
    onEvent in class Control
  Tags copied from class: Control
  Parameters:
    `event` - the event to process
  See Also:
    `Event`, `KeyEvent`, `PenEvent`

### getPreferredHeight

    public int getPreferredHeight()

  Returns the minimum height for this TabPanel
  Overrides:
    getPreferredHeight in class Control

### getPreferredWidth

    public int getPreferredWidth()

  Returns the minimum width for this TabPanel
  Overrides:
    getPreferredWidth in class Control

### onBoundsChanged

    protected void onBoundsChanged()

  used internally. resizes all the containers.
  Overrides:
    onBoundsChanged in class Control

### onColorsChanged

    protected void onColorsChanged(boolean colorsChanged)

  Description copied from class: Control
  Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled
  Overrides:
    onColorsChanged in class Container

### onPaint

    public void onPaint(Graphics g)

  Called by the system to draw the tab bar.
  Overrides:
    onPaint in class Container
  Tags copied from class: Control
  Parameters:
    `g` - the graphics object for drawing
  See Also:
    `Graphics`

### setCaptionColor

    public void setCaptionColor(Color capColor)

  Sets the text color of the captions

### getCaptionColor

    public Color getCaptionColor()

  Gets the text color of the captions. return a grayed value if this control is not enabled.

### getClientRect

    public Rect getClientRect()

  Returns the area excluding the tabs and borders for this TabPanel. Note: do not change the returning rect object !
  Overrides:
    getClientRect in class Container

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD