TabBarButton Class Reference

In a TabbedButtonBar, this component is used for each of the buttons. More...

Inherits Button.

List of all members.

Public Member Functions

 TabBarButton (const String &name, TabbedButtonBar *const ownerBar, const int tabIndex)
 Creates the tab button.
 ~TabBarButton ()
 Destructor.
virtual int getBestTabLength (const int depth)
 Chooses the best length for the tab, given the specified depth.
void paintButton (Graphics &g, bool isMouseOverButton, bool isButtonDown)
 Subclasses should override this to actually paint the button's contents.
void clicked (const ModifierKeys &mods)
 This method is called when the button has been clicked.
bool hitTest (int x, int y)
 Tests whether a given point inside the component.

Protected Member Functions

void getActiveArea (int &x, int &y, int &w, int &h)
 Returns an area of the component that's safe to draw in.

Protected Attributes

TabbedButtonBar *const owner
int tabIndex
int overlapPixels
DropShadowEffect shadow


Detailed Description

In a TabbedButtonBar, this component is used for each of the buttons.

If you want to create a TabbedButtonBar with custom tab components, derive your component from this class, and override the TabbedButtonBar::createTabButton() method to create it instead of the default one.

See also:
TabbedButtonBar

Constructor & Destructor Documentation

TabBarButton::TabBarButton ( const String name,
TabbedButtonBar *const   ownerBar,
const int  tabIndex 
)

Creates the tab button.

TabBarButton::~TabBarButton (  ) 

Destructor.


Member Function Documentation

virtual int TabBarButton::getBestTabLength ( const int  depth  )  [virtual]

Chooses the best length for the tab, given the specified depth.

If the tab is horizontal, this should return its width, and the depth specifies its height. If it's vertical, it should return the height, and the depth is actually its width.

void TabBarButton::paintButton ( Graphics g,
bool  isMouseOverButton,
bool  isButtonDown 
) [virtual]

Subclasses should override this to actually paint the button's contents.

It's better to use this than the paint method, because it gives you information about the over/down state of the button.

Parameters:
g the graphics context to use
isMouseOverButton true if the button is either in the 'over' or 'down' state
isButtonDown true if the button should be drawn in the 'down' position

Implements Button.

void TabBarButton::clicked ( const ModifierKeys modifiers  )  [virtual]

This method is called when the button has been clicked.

By default it just calls clicked(), but you might want to override it to handle things like clicking when a modifier key is pressed, etc.

See also:
ModifierKeys

Reimplemented from Button.

bool TabBarButton::hitTest ( int  x,
int  y 
) [virtual]

Tests whether a given point inside the component.

Overriding this method allows you to create components which only intercept mouse-clicks within a user-defined area.

This is called to find out whether a particular x, y co-ordinate is considered to be inside the component or not, and is used by methods such as contains() and getComponentAt() to work out which component the mouse is clicked on.

Components with custom shapes will probably want to override it to perform some more complex hit-testing.

The default implementation of this method returns either true or false, depending on the value that was set by calling setInterceptsMouseClicks() (true is the default return value).

Note that the hit-test region is not related to the opacity with which areas of a component are painted.

Applications should never call hitTest() directly - instead use the contains() method, because this will also test for occlusion by the component's parent.

Note that for components on the desktop, this method will be ignored, because it's not always possible to implement this behaviour on all platforms.

Parameters:
x the x co-ordinate to test, relative to the left hand edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's width
y the y co-ordinate to test, relative to the top edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's height
Returns:
true if the click is considered to be inside the component
See also:
setInterceptsMouseClicks, contains

Reimplemented from Component.

void TabBarButton::getActiveArea ( int &  x,
int &  y,
int &  w,
int &  h 
) [protected]

Returns an area of the component that's safe to draw in.

This deals with the orientation of the tabs, which affects which side is touching the tabbed box's content component.


Member Data Documentation

int TabBarButton::tabIndex [protected]

int TabBarButton::overlapPixels [protected]


The documentation for this class was generated from the following file:

Generated on Fri Nov 20 12:00:50 2009 for JUCE by  doxygen 1.5.9