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

Gewi::GButton Class Reference

#include <GewiButton.h>

Inherits Gewi::GWidget.

Inherited by Gewi::GTextButton.

List of all members.

Detailed Description

GButton simple button widget, derived from GWidget.

Public Member Functions

 GButton (GContainer *parent=NULL)
 Simple constructor for GButton.

virtual void Create (float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, GButtonType type=GBT_PRESS)
 GButton's create function, must be called to set up actual button.

virtual void Message (SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)
 Overload of Message, used to recieve messages.

virtual void Show ()
 Draws this button to the screen.

bool IsPressed ()
 Returns button state.

void SetState (bool pressed)
 Sets button state (pressed/unpressed).

Protected Attributes

bool rPressed
 Boolean holding if button is currently pressed or not.

GButtonType rType
 Enum for type of button.

ResourceID rNormalImage
 Resource ID for the non-pressed image.

ResourceID rPressedImage
 Resource ID for the pressed (or hover) image.

Constructor & Destructor Documentation

Gewi::GButton::GButton GContainer parent = NULL  ) 

Constructor for GButton, can take a parent.

parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.

Member Function Documentation

void Gewi::GButton::Create float  x,
float  y,
float  width,
float  height,
ResourceID  normalImg,
ResourceID  pressImg,
GButtonType  type = GBT_PRESS

Every widget has a create function which must be called to define the button's appearance and settings.

x X position of widget within it's container (entire screen if no parent)
y Y position of widget within it's container (entire screen if no parent)
width Width of widget.
height Height of widget.
normalImg Image for button when not pressed.
pressImg Image for button when pressed (or hovered if type is GBT_HOVER).
type GButtonType, either the default, GBT_PRESS (normal button), or GBT_HOVER (a button which responds to the hovering mouse).

void Gewi::GButton::Message SDL_Event *  rawEvent,
GewiEvent  event,
Uint16  mouseX,
Uint16  mouseY,
char  ch

Recieves and processes a message, required overload for all widgets.

rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
event GewiEvent enum, description of event recieved.
mouseX Mouse x position in event, if not mouse event may be incorrect.
mouseY Mouse y position in event, if not mouse event may be incorrect.
ch Character pressed in event, may be 0 if not a keypress event.

Implements Gewi::GWidget.

void Gewi::GButton::Show  )  [virtual]

Draws widget to the screen, required overload for all widgets.

Implements Gewi::GWidget.

Reimplemented in Gewi::GTextButton.

bool Gewi::GButton::IsPressed  ) 

Returns true if buttons is pressed, false otherwise. (GBT_HOVER can only be pressed once, after that they stay down.)

button pressed state

void Gewi::GButton::SetState bool  pressed  ) 

Sets button to pressed (true) or unpressed (false).

pressed true means pressed, false means unpressed.

The documentation for this class was generated from the following files:
Generated on Fri Aug 1 17:17:30 2003 for Gewi by doxygen1.3