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

wftk::Button Class Reference

Button Class. More...

#include <button.h>

Inheritance diagram for wftk::Button:

wftk::SingleContainer wftk::Widget wftk::ScreenArea wftk::PushButton wftk::ToggleButton List of all members.

Public Member Functions

 Button (const std::string &text, const Font &font=Font::registry.find("button_font"))
 Explicit Constructor.
void press ()
 press the button by calling a function
void release ()
 release the button by calling a function
void repeat ()
 repeat the click on the button
void toggle ()
 toggle the button, i.e.
bool isPressed () const
 check if the button is pressed right now
void setRepeat (unsigned repeat=100)
 set the repeat interval
void setRepeat (bool repeat)
 turn repeating on or off
virtual bool buttonEvent (Mouse::Button button, bool pressed_val, const Point &pos)
 triggered when a button event happens
virtual bool keyEvent (const SDL_keysym &sym, bool pressed_val)
 triggered when a keyboard event happens
virtual void lostMouse ()
 called if the user moves the mouse off the button after pressing it
virtual void lostFocus ()
 called if the window loses focus

Public Attributes

ButtonSignal pressed
 SigC signal triggered when button is pressed, also plays the named Sample "press".
ButtonSignal released
 SigC signal triggered when button is released, also plays the named Sample "release".
ButtonSignal clicked
 SigC signal triggered when button is clicked.

Detailed Description

Button Class.


Constructor & Destructor Documentation

wftk::Button::Button const std::string &  text,
const Font font = Font::registry.find("button_font")
[explicit]
 

Explicit Constructor.

This creates a Button type object. It's not really inteded to be used as standalone object, but it's a parent for other buttons, eg. the PushButton class.

Parameters:
text the text the button should have, defaults to an empty string
font the font the button text should have, defaults to button_font


Member Function Documentation

bool wftk::Button::buttonEvent Mouse::Button  button,
bool  pressed_val,
const Point pos
[virtual]
 

triggered when a button event happens

Parameters:
button which mouse button is producing the event
pressed_val is the button pressed or released
pos position of the cursor (I think)
Returns:
true on a handled button even, false if it's unhandled, I think

Reimplemented from wftk::Widget.

Reimplemented in wftk::ToggleButton.

bool wftk::Button::isPressed  )  const [inline]
 

check if the button is pressed right now

Returns:
true if the button is pressed, false otherwise

bool wftk::Button::keyEvent const SDL_keysym &  sym,
bool  pressed_val
[virtual]
 

triggered when a keyboard event happens

Parameters:
sym SDL_keysym type, i.e. the key that triggered the event
pressed_val is the key pressed or released
Returns:
true on handled key even, false otherwise

Reimplemented from wftk::Widget.

Reimplemented in wftk::ToggleButton.

virtual void wftk::Button::lostFocus  )  [inline, virtual]
 

called if the window loses focus

It unsets the pressed state without triggering a released signal

Reimplemented from wftk::Widget.

Reimplemented in wftk::ToggleButton.

void wftk::Button::lostMouse  )  [virtual]
 

called if the user moves the mouse off the button after pressing it

it unsets the pressed state of the button and triggers a released signal

Reimplemented from wftk::ScreenArea.

Reimplemented in wftk::ToggleButton.

void wftk::Button::press  ) 
 

press the button by calling a function

This is used if the programmer for some reason needs to press a button without the user doing so

void wftk::Button::release  ) 
 

release the button by calling a function

This is used to release a key without user input (e.g. for unsetting buttons in a radio-button group)

void wftk::Button::repeat  ) 
 

repeat the click on the button

This is called if the the click needs to be repeated.

void wftk::Button::setRepeat bool  repeat  ) 
 

turn repeating on or off

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
repeat true to turn on repeating, false to turn it off

void wftk::Button::setRepeat unsigned  repeat = 100  ) 
 

set the repeat interval

Parameters:
repeat new interval in ms, 0 turns of repeating

void wftk::Button::toggle  ) 
 

toggle the button, i.e.

set it to pressed if it isn't, and vice versa


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

Generated Mon Sep 6 21:58:16 2004.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.