es.prodevelop.gvsig.mobile.gui.tool
Class ToolBar

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.gui.tool.ToolBar
All Implemented Interfaces:
IToolContainer

public class ToolBar
extends java.lang.Object
implements IToolContainer

Element of the GUI which represents a container of buttons displayed for allowing the user to access specific actions.

A ToolBar contains:

Note: This class is not intended to be subclassed

Author:
jldominguez, mmontesinos

Field Summary
static int MAX_BUTTON_COUNT
           
 
Constructor Summary
ToolBar(MainWindow _mw, ToolBarGroupButton gButton, int _index)
          Creates a new instance of a ToolBar given the window to be included in, a ToolBarGroupButton representing the new Tool Bar, the index order of this new ToolBar among all existing ToolBars, and the name of this toolbar
 
Method Summary
 void addButton(TBButton button, int index)
          Adds a button in the toolbar.
 void createMenu()
          Create a Drop-down menu associated to the ToolBar with the buttons visible in the ToolBar as the items list
 TBButton[] getAllButtons()
          Returns the array of all buttons of type TBButton that the ToolBar contains, including the ones in a combo list For a TBActionButton or TBSelectableButton it returns that button.
 int getButtonCount()
          Returns the number of buttons existing in the toolbar.
 TBButton[] getButtons()
          Returns the array of visible buttons of type TBButton that the ToolBar contains.
 ToolBarGroupButton getGroupButton()
          Gets the group button associated to the toolbar
 TBHelpButton getHelpButton()
          Gets the help button of the toolbar
 TBMenu getMenu()
           
 int getToolXOrigin(int position, int screenWidth)
          Calculates the X position of a TBButton in the screen, given the order (number) of the button for which we want to know the X position and the size of the Window
static int getToolYOrigin(int position, int screenWidth)
          Calculates the Y position of a TBButton in the screen, given the order (number) of the button for which we want to know the Y position and the size of the Window
 MainWindow getWindow()
          Returns the MainWindow of the toolbar
 boolean isSelected()
           
 void paintEmptyButtons(java.awt.Graphics g)
          Add empty button images.
 void removeMenu()
          Removes the menu displayed associated to the help button of the tool bar
 void reorder(int width)
          Reconfigures the toolbar after adding new buttons.
 void repaint()
          Stub method.
 void setActiveTool(int index)
          Stub method.
 void setButtonsVisible(boolean visibility)
          Sets all buttons in the ToolBar to Visible or Invisible
 void unselectAllButtons()
          Unselects all buttons in the ToolBar It doesn't change other widgets but TBButton's
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BUTTON_COUNT

public static final int MAX_BUTTON_COUNT
See Also:
Constant Field Values
Constructor Detail

ToolBar

public ToolBar(MainWindow _mw,
               ToolBarGroupButton gButton,
               int _index)
Creates a new instance of a ToolBar given the window to be included in, a ToolBarGroupButton representing the new Tool Bar, the index order of this new ToolBar among all existing ToolBars, and the name of this toolbar

Parameters:
_mw - MainWindow of the app
gButton - A ToolBarGroupButton representing the Tool Bar
_index - Index (order) number of the toolbar
Method Detail

paintEmptyButtons

public void paintEmptyButtons(java.awt.Graphics g)
Add empty button images. This is called from the MapControl paint method.

Parameters:
g -

addButton

public void addButton(TBButton button,
                      int index)
               throws GvsigMobileException
Adds a button in the toolbar. The button must be of type TBButton

Specified by:
addButton in interface IToolContainer
Parameters:
button - TBButton to be added to the ToolBar
index - number of the position that the new button will have in the array of buttons that the ToolBar contains. It must be an int between 0 and the actual size of the array.
Throws:
GvsigMobileException

getButtonCount

public int getButtonCount()
Returns the number of buttons existing in the toolbar.

Specified by:
getButtonCount in interface IToolContainer
Returns:
the number of buttons

getButtons

public TBButton[] getButtons()
Returns the array of visible buttons of type TBButton that the ToolBar contains. For a TBActionButton or TBSelectableButton it returns that button. For a TBComboButton it returns the active button in the list

Specified by:
getButtons in interface IToolContainer
Returns:
array of buttons of type TBButton

getAllButtons

public TBButton[] getAllButtons()
Returns the array of all buttons of type TBButton that the ToolBar contains, including the ones in a combo list For a TBActionButton or TBSelectableButton it returns that button. For a TBComboButton it returns the active button in the list

Returns:
array of buttons of type TBButton

getToolXOrigin

public int getToolXOrigin(int position,
                          int screenWidth)
Calculates the X position of a TBButton in the screen, given the order (number) of the button for which we want to know the X position and the size of the Window

Parameters:
position - Order number of the button in the buttons array of the ToolBar (display order from left to right)
screenWidth - Screen width in pixels of the MapControl
Returns:
X position of the left pixel of the button

getToolYOrigin

public static int getToolYOrigin(int position,
                                 int screenWidth)
Calculates the Y position of a TBButton in the screen, given the order (number) of the button for which we want to know the Y position and the size of the Window

Parameters:
position - Order number of the button in the buttons array of the ToolBar (display order from left to right)
screenWidth - Screen width in pixels of the Window
Returns:
Y position of the top left pixel of the button

getGroupButton

public ToolBarGroupButton getGroupButton()
Gets the group button associated to the toolbar

Returns:
the ToolBarGroupButton of the toolbar

reorder

public void reorder(int width)
Reconfigures the toolbar after adding new buttons.

It should be called after all the buttons in a ToolBar have been added

Parameters:
width - of the screen

getHelpButton

public TBHelpButton getHelpButton()
Gets the help button of the toolbar

Returns:
TBHelpButton of the ToolBar

setButtonsVisible

public void setButtonsVisible(boolean visibility)
Sets all buttons in the ToolBar to Visible or Invisible

Parameters:
visibility - Visibility end state:
true: Set all buttons to visible
false: Set all buttons to invisible

unselectAllButtons

public void unselectAllButtons()
Unselects all buttons in the ToolBar It doesn't change other widgets but TBButton's


getWindow

public MainWindow getWindow()
Returns the MainWindow of the toolbar

Specified by:
getWindow in interface IToolContainer
Returns:
MainWindow where the toolbar has been placed

setActiveTool

public void setActiveTool(int index)
Stub method. Not used

Specified by:
setActiveTool in interface IToolContainer
Parameters:
index - of the new tool to be set to active in the container

repaint

public void repaint()
Stub method. Not used

Specified by:
repaint in interface IToolContainer

createMenu

public void createMenu()
Create a Drop-down menu associated to the ToolBar with the buttons visible in the ToolBar as the items list


getMenu

public TBMenu getMenu()
Returns:
Returns the menu.

removeMenu

public void removeMenu()
Removes the menu displayed associated to the help button of the tool bar


isSelected

public boolean isSelected()