Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeButtonWidget Class Reference

a widget that implements a button More...

#include <cascade/widgets/CascadeButtonWidget.h>

Inheritance diagram for CascadeButtonWidget:

CascadeWidget CascadeWindow CascadeObject CascadeDirBrowser::BrowserButton List of all members.

Public Types

typedef void() StateChangeCallback (const CascadeButtonWidget *pButton, const State &newState, void *pClientData)
enum  State { kOff = 0, kOn = 1 }
enum  TextVAlign {
  kTextAlignAbove = 0, kTextAlignTop = 1, kTextAlignMiddle = 2, kTextAlignBottom = 3,
  kTextAlignBelow = 4
}
enum  { kVAlignSpacing = 2 }
enum  TextHAlign { kTextAlignLeft = 0, kTextAlignCenter = 1, kTextAlignRight = 2 }

Public Member Functions

 CascadeButtonWidget ()
virtual ~CascadeButtonWidget ()
State GetState ()
void SetState (const State &state)
void ToggleState ()
void SetBitmapUp (CascadeBitmap *pBitmap, CascadeWidget::Scheme scheme)
void SetBitmapDown (CascadeBitmap *pBitmap, CascadeWidget::Scheme scheme)
void SetText (const CascadeString &string)
void SetTextAlignment (TextVAlign vAlign, TextHAlign hAlign=kTextAlignCenter)
void RegisterStateChangeCallback (StateChangeCallback *pCallback, void *pClientData)

Protected Member Functions

virtual void OnStateChange (const State &newState)
virtual bool OnKeyDown (u32 nKey)
virtual void OnPaint (CascadeBitmap &bitmap)

Protected Attributes

State m_state
CascadeString m_text
CascadeBitmapm_pBitmapsUp [CascadeWidget::kNumSchemes]
CascadeBitmapm_pBitmapsDown [CascadeWidget::kNumSchemes]
StateChangeCallbackm_pCallback
void * m_pClientData
TextHAlign m_textHAlign
TextVAlign m_textVAlign

Detailed Description

a widget that implements a button

Skip the description

CascadeLabelWidget is a widget that implements a button.


class CascadeButtonWidget


Member Typedef Documentation

typedef void() CascadeButtonWidget::StateChangeCallback(const CascadeButtonWidget *pButton, const State &newState, void *pClientData)
 

Callback function for notification of button state changes

Clients may provide an optional StateChangeCallback to the RegisterStateChangeCallback() function. Your custom StateChangeCallback will get called back whenever the button state changes.

Parameters:
pButton the button whose state has changed
newState the new state of the button
pClientData the void * pClientData passed thru from RegisterStateChangeCallback()
Note:
Optionally you may use the virtual member function OnStateChange() to be notified of state change notifications in CascadeButtonWidget derived classes.
See also:
RegisterStateChangeCallback()

OnStateChange(), State


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
kVAlignSpacing 

enum CascadeButtonWidget::State
 

represents a button state

State is used by the GetState() and the SetState() functions.

See also:
GetState(), SetState()
Enumeration values:
kOff  the button/checkbox/switch is up or unchecked or unpushed or unflicked
kOn  the button/checkbox/switch is down or checked or pushed or flicked

enum CascadeButtonWidget::TextHAlign
 

used to specify horizontal alignment for optional button text

TextHAlign is used by the SetTextAlignment() function. It is used to specify horizontal alignment of optional button text.

See also:
SetTextAlignment()
Enumeration values:
kTextAlignLeft  associated text appears against the left side of the image(s)
kTextAlignCenter  associated text appears centered in the image(s)
kTextAlignRight  associated text appears against the right side of the image(s)

enum CascadeButtonWidget::TextVAlign
 

used to specify vertical alignment for optional button text

TextVAlign is used by the SetTextAlignment() function. It is used to specify vertical alignment of optional button text.

See also:
SetTextAlignment()
Enumeration values:
kTextAlignAbove  associated text appears just above the image(s)
kTextAlignTop  associated text appears against the top of the image(s)
kTextAlignMiddle  associated text appears in the middle (vertically) of the image(s)
kTextAlignBottom  associated text appears against the bottom of the image(s)
kTextAlignBelow  associated text appears just below the image(s)


Constructor & Destructor Documentation

CascadeButtonWidget::CascadeButtonWidget  ) 
 

The CascadeButtonWidget constructor - lightweight.

This constructor is lightweight.

virtual CascadeButtonWidget::~CascadeButtonWidget  )  [virtual]
 

Destructor.

The destructor.


Member Function Documentation

CascadeButtonWidget::State CascadeButtonWidget::GetState  )  [inline]
 

gets the state of the button

call GetState() to get the state of the button.

Returns:
the button state
See also:
SetState(), State

virtual bool CascadeButtonWidget::OnKeyDown u32  nKey  )  [protected, virtual]
 

key down handler for CascadeButtonWidget

The default OnKeyDown handler toggles the state of the button widget when CK_SELECT is received. Override this function in your derived classes to provide custom key down handling functionality.

Parameters:
nKey the key being dispatched
Returns:
true to mark the message handled, false otherwise

Reimplemented from CascadeWindow.

Reimplemented in CascadeDirBrowser::BrowserButton.

virtual void CascadeButtonWidget::OnPaint CascadeBitmap bitmap  )  [protected, virtual]
 

paint handler for CascadeButtonWidget

The default implementation renders the button using the appropriate bitmap if it is set, or with line-drawing and rect fills to render the button in the standard widget ui scheme colors. If the button has text set, the text is rendered according to the text alignment settings.

Parameters:
bitmap the bitmap to draw on
See also:
SetBitmapUp(), SetBitmapDown()

SetText(), SetTextAlignment()

Reimplemented from CascadeWindow.

Reimplemented in CascadeDirBrowser::BrowserButton.

virtual void CascadeButtonWidget::OnStateChange const State newState  )  [protected, virtual]
 

notifies when the button state has changed

OnStateChange() is called whenever the state is changed. The default behavior is to do nothing. Override this method in CascadeButtonWidget derived classes to be notified of button state changes.

Parameters:
newState the new state of the button
See also:
State

void CascadeButtonWidget::RegisterStateChangeCallback StateChangeCallback pCallback,
void *  pClientData
 

registers an optional state change callback

call RegisterStateChangeCallback() to register an optional callback function which will be called whenever the state changes. Alternatively, you can override OnStateChange() in your CascadeButtonWidget derived classes.

Parameters:
pCallback the callback
pClientData a void * that will be passed straight through to pCallback
See also:
StateChangeCallback

OnStateChange(), State

void CascadeButtonWidget::SetBitmapDown CascadeBitmap pBitmap,
CascadeWidget::Scheme  scheme
 

sets the bitmap to use for the kOn state

SetBitmapDown() may be used to set an optional bitmap for the down (kOn) button state. If, during the default OnPaint(), the required bitmap is not set (set to NULL) then the button is rendered in a 3d style using the ui scheme colors for widgets.

Parameters:
pBitmap the bitmap to set
scheme the scheme for which the bitmap is to be used
See also:
SetBitmapUp()

CascadeWidget::Scheme

void CascadeButtonWidget::SetBitmapUp CascadeBitmap pBitmap,
CascadeWidget::Scheme  scheme
 

sets the bitmap to use for the kOff state

SetBitmapUp() may be used to set an optional bitmap for the up (kOff) button state. If, during the default OnPaint(), the required bitmap is not set (set to NULL) then the button is rendered in a 3d style using the ui scheme colors for widgets.

Parameters:
pBitmap the bitmap to set
scheme the scheme for which the bitmap is to be used
See also:
SetBitmapDown()

CascadeWidget::Scheme

void CascadeButtonWidget::SetState const State state  )  [inline]
 

sets the state of the button

call SetState() to set the state of the button.

Parameters:
state the button state to set
See also:
GetState(), State

void CascadeButtonWidget::SetText const CascadeString string  ) 
 

sets optional text for the button

SetText() may be used to set optional text for the button to render.

Parameters:
string the text to set
See also:
SetTextAlignment()

void CascadeButtonWidget::SetTextAlignment TextVAlign  vAlign,
TextHAlign  hAlign = kTextAlignCenter
[inline]
 

sets the text alignment for optional text

SetTextAlignment sets the horizontal and vertical text alignment for optional text.

Parameters:
vAlign the vertical alignment
hAlign the horizontal alignment
See also:
TextVAlign, TextHAlign

SetText()

void CascadeButtonWidget::ToggleState  ) 
 

gets the state of the button

call GetState() to get the state of the button.

Returns:
the button state
See also:
SetState(), State


Member Data Documentation

CascadeBitmap* CascadeButtonWidget::m_pBitmapsDown[CascadeWidget::kNumSchemes] [protected]
 

the array of bitmaps to use for rendering the kOn state

m_pBitmapsDown is an array of pointers to bitmaps to use for rendering the kOn state, zero or all of which may be NULL

CascadeBitmap* CascadeButtonWidget::m_pBitmapsUp[CascadeWidget::kNumSchemes] [protected]
 

the array of bitmaps to use for rendering the kOff state

m_pBitmapsUp is an array of pointers to bitmaps to use for rendering the kOff state, zero or all of which may be NULL

StateChangeCallback* CascadeButtonWidget::m_pCallback [protected]
 

the state change callback function, if any

m_pCallback stores the state change callback function, or NULL if no callback function has been registered

void* CascadeButtonWidget::m_pClientData [protected]
 

the state change callback clientdata, if any

m_pClientData stores the state change callback client data, or NULL if no clientdata has been registered

State CascadeButtonWidget::m_state [protected]
 

the current button state

m_state stores the current button state

CascadeString CascadeButtonWidget::m_text [protected]
 

the button text

m_text stores the button text, if any

TextHAlign CascadeButtonWidget::m_textHAlign [protected]
 

the current text horizontal alignment

m_textHAlign stores the horizontal alignment for text rendering

TextVAlign CascadeButtonWidget::m_textVAlign [protected]
 

the current text vertical alignment

m_textHAlign stores the vertical alignment for text rendering


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:18 2005 for Cascade Library by  doxygen 1.4.1