glictButton Class Reference

#include <button.h>

Inheritance diagram for glictButton:

glictContainer

List of all members.


Detailed Description

Button class widget.

Buttons are clickable widgets that have a text written on the center of it, with settable background color. Upon click on a button, the function specified as OnClick function is called.

Examples:

examples/memory/main.cpp, and examples/memory_sdl/main.cpp.

Definition at line 41 of file button.h.


Public Member Functions

bool CastEvent (glictEvents evt, void *wparam, long lparam, void *returnvalue)
 Event processing for button widget.
 glictButton ()
 Constructor for the button widget.
void Paint ()
 Paints the button.
void SetBGColor (float r, float g, float b, float a)
 Sets the background color of the button.
void SetFGColor (float r, float g, float b, float a)
 Sets the foreground color of the button.
 ~glictButton ()
 Destructor for the button widget.

Private Attributes

glictColor bgcolor
 Stores the background color.
glictColor fgcolor
 Stores the foreground color.
bool highlighted
 Is mouse pressed or not.

Constructor & Destructor Documentation

glictButton::glictButton (  ) 

Constructor for the button widget.

It fills up the class with default infos.

Definition at line 36 of file button.cpp.

References glictColor::a, glictColor::b, bgcolor, glictContainer::caption, fgcolor, glictContainer::focusable, glictColor::g, highlighted, glictContainer::parent, and glictColor::r.

glictButton::~glictButton (  ) 

Destructor for the button widget.

Currently does nothing.

Definition at line 62 of file button.cpp.


Member Function Documentation

bool glictButton::CastEvent ( glictEvents  evt,
void *  wparam,
long  lparam,
void *  returnvalue 
) [virtual]

Event processing for button widget.

Parameters:
evt Event to process. Processed are GLICT_MOUSEUP, GLICT_MOUSEDOWN and GLICT_MOUSECLICK.
*wparam Pointer parameter depending on event processed
lparam Numeric parameter depending on event processed.
returnvalue Not filled up with any currently processed event.
Returns:
Boolean value, true if event processed
If evt is mouse-related, then this function understands *wparam as a pointer to glictPos. If these coordinates are within clipping boundaries, then different actions are taken depending on the precise event. Even if they are not, in case the event is a mouse release we dehighlight the button, yet we still trick the parents that the event was not processed.

See also:
glictContainer::CastEvent()

Reimplemented from glictContainer.

Definition at line 82 of file button.cpp.

References glictContainer::DefaultCastEvent(), glictContainer::Focus(), glictContainer::GetEnabled(), glictContainer::GetVisible(), GLICT_KEYPRESS, GLICT_MOUSECLICK, GLICT_MOUSEDOWN, GLICT_MOUSEUP, highlighted, glictContainer::next, and glictContainer::x.

void glictButton::Paint (  )  [virtual]

Paints the button.

Paints a button. Button is a square thing rendered within boundaries specified by SetRect(). The square's color is specified with SetBGColor(). Upon rendering the square, white text specified with SetCaption() is placed on center of the widget.

Reimplemented from glictContainer.

Definition at line 148 of file button.cpp.

References glictColor::a, glictColor::b, bgcolor, glictGlobalsClass::buttonHighlightSkin, glictGlobalsClass::buttonHighlightTextColor, glictGlobalsClass::buttonSkin, glictGlobalsClass::buttonTextColor, glictContainer::CPaint(), glictGlobalsClass::debugCallback, glictContainer::fontname, glictContainer::fontsize, glictColor::g, glictContainer::GetVisible(), glictFontNumberOfLines(), glictFontRender(), glictFontSize(), glictContainer::height, highlighted, glictSkinner::Paint(), glictGlobalsClass::PaintRect(), glictGlobalsClass::PaintRectLines(), glictColor::r, glictGlobalsClass::SetColor(), glictContainer::SetScissor(), glictGlobalsClass::Translatef(), glictGlobalsClass::translation, glictContainer::width, glictContainer::x, glictPos::x, and glictPos::y.

void glictButton::SetBGColor ( float  r,
float  g,
float  b,
float  a 
)

Sets the background color of the button.

Parameters:
r Red element of the color.
g Green element of the color.
b Blue element of the color.
a Alpha element of the color.
Sets the background color of the button that'll be used in Paint().
Examples:
examples/memory/main.cpp, and examples/memory_sdl/main.cpp.

Definition at line 245 of file button.cpp.

References glictColor::a, glictColor::b, bgcolor, glictColor::g, and glictColor::r.

Referenced by glictMessageBox::glictMessageBox().

void glictButton::SetFGColor ( float  r,
float  g,
float  b,
float  a 
)

Sets the foreground color of the button.

Parameters:
r Red element of the color.
g Green element of the color.
b Blue element of the color.
a Alpha element of the color.
Sets the foreground color of the button that'll be used in Paint(). Namely, the text color.

Definition at line 261 of file button.cpp.

References glictColor::a, glictColor::b, fgcolor, glictColor::g, and glictColor::r.


The documentation for this class was generated from the following files:
SourceForge.net Logo
generated with doxygen 1.5.3 on Mon Oct 29 18:09:27 2007