GUI
Public Types | Public Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
Widget Class Reference

Base class for widgets. Inherits EventEmitter. More...

#include <Widget.h>

Inherits EventEmitter.

Inherited by Button, EditBox, Scrollbar, and TextField.

Public Types

enum  states { STATE_HOVER, STATE_DOWN, STATE_UP }
 
typedef char State
 
- Public Types inherited from EventEmitter
typedef std::multimap< EventType, EventListener > Map
 

Public Member Functions

 Widget ()
 
 Widget (int x, int y, int w, int h)
 
virtual ~Widget ()
 
virtual void render (Renderer *renderer)
 
virtual void keyChar (int uchar)
 
virtual void keyDown (int keyCode)
 
virtual void mouseMove (int x, int y)
 
virtual void stateChange (State state)
 
virtual void focusIn ()
 
virtual void focusOut ()
 
void addChild (Widget *widget)
 
void removeChild (Widget *widget)
 
void setParent (Widget *widget)
 
void resize (int x, int y, int w, int h)
 
void updateAbs ()
 
void setVisibility (bool visible)
 
bool contain (int posX, int posY)
 
bool isFocused ()
 
State getState ()
 
- Public Member Functions inherited from EventEmitter
 EventEmitter ()
 
virtual ~EventEmitter ()
 
void setQueue (AddToQueue addFunction)
 Assings addToQueue function so the events can be sent to the queue. More...
 
EventListener::Id addEventListener (EventType eventType, EventListener::Function listenerFunc)
 Adds an event listener. More...
 
void removeEventListener (EventListener::Id listenerId)
 Removes an event listener. More...
 
void emitEvent (Event event)
 Emitts an event. More...
 

Protected Attributes

int x
 
int y
 
int w
 
int h
 
int xAbs
 
int yAbs
 
int state
 
bool focused
 
bool visible
 
GUISystemguiSystem
 

Private Attributes

Widgetparent
 
std::forward_list< Widget * > children
 

Friends

class GUISystem
 

Detailed Description

Base class for widgets. Inherits EventEmitter.

Definition at line 17 of file Widget.h.

Member Typedef Documentation

◆ State

typedef char Widget::State

Definition at line 20 of file Widget.h.

Member Enumeration Documentation

◆ states

Enumerator
STATE_HOVER 
STATE_DOWN 
STATE_UP 

Definition at line 21 of file Widget.h.

Constructor & Destructor Documentation

◆ Widget() [1/2]

Widget::Widget ( )

Definition at line 5 of file Widget.cpp.

References updateAbs().

◆ Widget() [2/2]

Widget::Widget ( int  x,
int  y,
int  w,
int  h 
)

Definition at line 18 of file Widget.cpp.

References updateAbs().

◆ ~Widget()

Widget::~Widget ( )
virtual

Definition at line 31 of file Widget.cpp.

Member Function Documentation

◆ addChild()

void Widget::addChild ( Widget widget)

Definition at line 108 of file Widget.cpp.

References children.

◆ contain()

bool Widget::contain ( int  posX,
int  posY 
)

Definition at line 130 of file Widget.cpp.

References h, xAbs, and yAbs.

◆ focusIn()

void Widget::focusIn ( )
virtual

Definition at line 88 of file Widget.cpp.

References focused.

◆ focusOut()

void Widget::focusOut ( )
virtual

Definition at line 93 of file Widget.cpp.

References focused.

◆ getState()

State Widget::getState ( )
inline

Definition at line 45 of file Widget.h.

◆ isFocused()

bool Widget::isFocused ( )
inline

Definition at line 44 of file Widget.h.

References focused.

◆ keyChar()

void Widget::keyChar ( int  uchar)
virtual

Reimplemented in EditBox.

Definition at line 40 of file Widget.cpp.

◆ keyDown()

void Widget::keyDown ( int  keyCode)
virtual

Reimplemented in EditBox.

Definition at line 44 of file Widget.cpp.

◆ mouseMove()

void Widget::mouseMove ( int  x,
int  y 
)
virtual

Definition at line 48 of file Widget.cpp.

References GUISystem::createEvent(), EventEmitter::emitEvent(), guiSystem, and MOUSE_MOVE.

◆ removeChild()

void Widget::removeChild ( Widget widget)

Definition at line 113 of file Widget.cpp.

References setParent().

◆ render()

void Widget::render ( Renderer renderer)
virtual

Reimplemented in EditBox, Button, Scrollbar, and TextField.

Definition at line 36 of file Widget.cpp.

◆ resize()

void Widget::resize ( int  x,
int  y,
int  w,
int  h 
)

Definition at line 59 of file Widget.cpp.

References h, updateAbs(), w, x, and y.

◆ setParent()

void Widget::setParent ( Widget widget)

Definition at line 119 of file Widget.cpp.

References addChild(), parent, removeChild(), and updateAbs().

◆ setVisibility()

void Widget::setVisibility ( bool  visible)

Definition at line 98 of file Widget.cpp.

References children, and visible.

◆ stateChange()

void Widget::stateChange ( State  state)
virtual

Reimplemented in Button.

Definition at line 54 of file Widget.cpp.

References state.

◆ updateAbs()

void Widget::updateAbs ( )

Definition at line 69 of file Widget.cpp.

References children, parent, x, xAbs, y, and yAbs.

Friends And Related Function Documentation

◆ GUISystem

friend class GUISystem
friend

Definition at line 60 of file Widget.h.

Member Data Documentation

◆ children

std::forward_list<Widget*> Widget::children
private

Definition at line 58 of file Widget.h.

◆ focused

bool Widget::focused
protected

Definition at line 51 of file Widget.h.

◆ guiSystem

GUISystem* Widget::guiSystem
protected

Definition at line 54 of file Widget.h.

◆ h

int Widget::h
protected

Definition at line 45 of file Widget.h.

◆ parent

Widget* Widget::parent
private

Definition at line 57 of file Widget.h.

◆ state

int Widget::state
protected

Definition at line 50 of file Widget.h.

◆ visible

bool Widget::visible
protected

Definition at line 52 of file Widget.h.

◆ w

int Widget::w
protected

Definition at line 45 of file Widget.h.

◆ x

int Widget::x
protected

Definition at line 45 of file Widget.h.

◆ xAbs

int Widget::xAbs
protected

Definition at line 49 of file Widget.h.

◆ y

int Widget::y
protected

Definition at line 45 of file Widget.h.

◆ yAbs

int Widget::yAbs
protected

Definition at line 49 of file Widget.h.


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