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

otk::Button Class Reference

#include <button.hh>

Inheritance diagram for otk::Button:

Inheritance graph
[legend]
Collaboration diagram for otk::Button:

Collaboration graph
[legend]
List of all members.

Public Methods

 Button (Widget *parent)
 ~Button ()
const RenderTexturegetPressedFocusTexture (void) const
void setPressedFocusTexture (RenderTexture *texture)
const RenderTexturegetPressedUnfocusTexture (void) const
void setPressedUnfocusTexture (RenderTexture *texture)
void setTexture (RenderTexture *texture)
void setUnfocusTexture (RenderTexture *texture)
bool isPressed (void) const
void press (unsigned int mouse_button)
void release (unsigned int mouse_button)
void buttonPressHandler (const XButtonEvent &e)
 Called whenever a button of the pointer is pressed.

void buttonReleaseHandler (const XButtonEvent &e)
 Called whenever a button of the pointer is released.

virtual void setStyle (RenderStyle *style)

Private Attributes

bool _pressed
unsigned int _mouse_button
RenderTexture_pressed_focus_tx
RenderTexture_pressed_unfocus_tx
RenderTexture_unpr_focus_tx
RenderTexture_unpr_unfocus_tx

Constructor & Destructor Documentation

otk::Button::Button Widget   parent
 

Definition at line 11 of file button.cc.

References setStyle().

00012   : FocusLabel(parent), _pressed(false), _pressed_focus_tx(0),
00013     _pressed_unfocus_tx(0), _unpr_focus_tx(0), _unpr_unfocus_tx(0)
00014 {
00015   setStyle(_style);
00016 }

otk::Button::~Button  
 

Definition at line 18 of file button.cc.

00019 {
00020 }


Member Function Documentation

void otk::Button::buttonPressHandler const XButtonEvent &    e [virtual]
 

Called whenever a button of the pointer is pressed.

Reimplemented from otk::EventHandler.

Definition at line 67 of file button.cc.

References press(), and otk::FocusLabel::update().

00068 {
00069   press(e.button);
00070   update();
00071   FocusWidget::buttonPressHandler(e);
00072 }

void otk::Button::buttonReleaseHandler const XButtonEvent &    e [virtual]
 

Called whenever a button of the pointer is released.

Reimplemented from otk::EventHandler.

Definition at line 74 of file button.cc.

References release(), and otk::FocusLabel::update().

00075 {
00076   release(e.button);
00077   update();
00078   FocusWidget::buttonReleaseHandler(e);
00079 }

const RenderTexture* otk::Button::getPressedFocusTexture void    const [inline]
 

Definition at line 16 of file button.hh.

References _pressed_focus_tx.

00017   { return _pressed_focus_tx; }

const RenderTexture* otk::Button::getPressedUnfocusTexture void    const [inline]
 

Definition at line 21 of file button.hh.

References _pressed_unfocus_tx.

00022   { return _pressed_unfocus_tx; }

bool otk::Button::isPressed void    const [inline]
 

Definition at line 29 of file button.hh.

References _pressed.

00029 { return _pressed; }

void otk::Button::press unsigned int    mouse_button
 

Definition at line 34 of file button.cc.

References _mouse_button, and _pressed.

Referenced by buttonPressHandler().

00035 {
00036   if (_pressed) return;
00037 
00038   if (_pressed_focus_tx)
00039     FocusWidget::setTexture(_pressed_focus_tx);
00040   if (_pressed_unfocus_tx)
00041     FocusWidget::setUnfocusTexture(_pressed_unfocus_tx);
00042   _pressed = true;
00043   _mouse_button = mouse_button;
00044 }

void otk::Button::release unsigned int    mouse_button
 

Definition at line 46 of file button.cc.

References _mouse_button, and _pressed.

Referenced by buttonReleaseHandler().

00047 {
00048   if (_mouse_button != mouse_button) return; // wrong button
00049 
00050   FocusWidget::setTexture(_unpr_focus_tx);
00051   FocusWidget::setUnfocusTexture(_unpr_unfocus_tx);
00052   _pressed = false;
00053 }

void otk::Button::setPressedFocusTexture RenderTexture   texture [inline]
 

Definition at line 18 of file button.hh.

References _pressed_focus_tx.

00019   { _pressed_focus_tx = texture; }

void otk::Button::setPressedUnfocusTexture RenderTexture   texture [inline]
 

Definition at line 23 of file button.hh.

References _pressed_unfocus_tx.

00024   { _pressed_unfocus_tx = texture; }

void otk::Button::setStyle RenderStyle   style [virtual]
 

Reimplemented from otk::FocusLabel.

Definition at line 23 of file button.cc.

References _pressed_focus_tx, _pressed_unfocus_tx, otk::RenderStyle::buttonPressFocusBackground(), otk::RenderStyle::buttonPressUnfocusBackground(), otk::RenderStyle::buttonUnpressFocusBackground(), otk::RenderStyle::buttonUnpressUnfocusBackground(), setTexture(), and setUnfocusTexture().

Referenced by Button().

00024 {
00025   FocusLabel::setStyle(style);
00026 
00027   setTexture(style->buttonUnpressFocusBackground());
00028   setUnfocusTexture(style->buttonUnpressUnfocusBackground());
00029   _pressed_focus_tx = style->buttonPressFocusBackground();
00030   _pressed_unfocus_tx = style->buttonPressUnfocusBackground();
00031 }

void otk::Button::setTexture RenderTexture   texture [virtual]
 

Reimplemented from otk::FocusWidget.

Definition at line 55 of file button.cc.

References _unpr_focus_tx.

Referenced by setStyle().

00056 {
00057   FocusWidget::setTexture(texture);
00058   _unpr_focus_tx = texture;
00059 }

void otk::Button::setUnfocusTexture RenderTexture   texture
 

Reimplemented from otk::FocusWidget.

Definition at line 61 of file button.cc.

References _unpr_unfocus_tx.

Referenced by setStyle().

00062 {
00063   FocusWidget::setUnfocusTexture(texture);
00064   _unpr_unfocus_tx = texture;
00065 }


Member Data Documentation

unsigned int otk::Button::_mouse_button [private]
 

Definition at line 41 of file button.hh.

Referenced by press(), and release().

bool otk::Button::_pressed [private]
 

Definition at line 40 of file button.hh.

Referenced by isPressed(), press(), and release().

RenderTexture* otk::Button::_pressed_focus_tx [private]
 

Definition at line 43 of file button.hh.

Referenced by getPressedFocusTexture(), setPressedFocusTexture(), and setStyle().

RenderTexture* otk::Button::_pressed_unfocus_tx [private]
 

Definition at line 44 of file button.hh.

Referenced by getPressedUnfocusTexture(), setPressedUnfocusTexture(), and setStyle().

RenderTexture* otk::Button::_unpr_focus_tx [private]
 

Definition at line 46 of file button.hh.

Referenced by setTexture().

RenderTexture* otk::Button::_unpr_unfocus_tx [private]
 

Definition at line 47 of file button.hh.

Referenced by setUnfocusTexture().


The documentation for this class was generated from the following files:
Generated on Tue Feb 4 23:00:24 2003 for Openbox by doxygen1.3-rc2