GUI
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
GUISystem Class Reference

Manages creating widgets and events and provides rutines governing GUI mechanisms. More...

#include <GUISystem.h>

Public Types

typedef std::map< EventType, CreateEventObjectMap
 

Public Member Functions

 GUISystem ()
 Constructor. More...
 
 ~GUISystem ()
 Destructor. More...
 
void setRenderer (Renderer *renderer)
 Sets Renderer object to be used. More...
 
RenderergetRenderer ()
 Returns associated Renderer object. More...
 
void render ()
 Renders the gui. More...
 
void addEventType (EventType eventType, CreateEventObject createFunc)
 Affililate event identifier with creating function. More...
 
void handleEvents ()
 Calls functions associated with events. More...
 
void mouseAxes (int x, int y)
 Updates gui state. To be called when mouse is moved. More...
 
void mouseButtonUp ()
 Updates gui state. To be called when mouse button is released. More...
 
void mouseButtonDown ()
 Updates gui state. To be called when mouse is pressed. More...
 
void keyChar (int unichar)
 Updates gui state. To be called when a character is typed or repeated. More...
 
void keyDown (int keyCode)
 Updates gui state. To be called when a key is pressed. More...
 
Handle< ButtonaddButton (int x, int y, int w, int h, std::string text)
 Creates Button widget and assings it to the gui. More...
 
Handle< TextFieldaddTextField (int x, int y, int w, int h, std::string text)
 Creates TextField widget and assings it to the gui. More...
 
Handle< EditBoxaddEditBox (int x, int y, int w, int h, bool multiline=false)
 Creates EditBox widget and assings it to the gui. More...
 
Handle< ScrollbaraddScrollbar (int x, int y, int w, int h)
 Creates Scrollbar widget and assings it to the gui. More...
 
Handle< WidgetaddWidget (CreateWidget createWidget, bool setEventQueue)
 Generic function for adding custom widgets. More...
 
Event createEvent (EventType eventType)
 Creates an event that can be emitted. More...
 
EventObjectcreateEventObject ()
 Creates an EventObject object. More...
 
EventObjectcreateMouseEvent ()
 Creates an MouseEvent object with default values. More...
 
EventObjectcreateKeyboardEvent ()
 Creates an KeyboardEvent object. More...
 

Public Attributes

int mouseX
 Mouse x coordinate. More...
 
int mouseY
 Mouse y coordinate. More...
 

Private Attributes

Rendererrenderer
 
std::forward_list< Widget * > widgets
 
Map createEvtObjFuncs
 
EventQueue eventQueue
 
Widgetfocus
 

Detailed Description

Manages creating widgets and events and provides rutines governing GUI mechanisms.

Definition at line 23 of file GUISystem.h.

Member Typedef Documentation

◆ Map

Definition at line 26 of file GUISystem.h.

Constructor & Destructor Documentation

◆ GUISystem()

GUISystem::GUISystem ( )

◆ ~GUISystem()

GUISystem::~GUISystem ( )

Destructor.

Definition at line 27 of file GUISystem.cpp.

Member Function Documentation

◆ addButton()

Handle< Button > GUISystem::addButton ( int  x,
int  y,
int  w,
int  h,
std::string  text 
)

Creates Button widget and assings it to the gui.

Parameters
xX coordinate
yY coordinate
wWidth
hHeight
textText to be desplayed.
Returns
Handle to the Button object.

Definition at line 147 of file GUISystem.cpp.

References EventQueue::addToQueue(), Renderer::color(), Button::downStateColor, eventQueue, Widget::guiSystem, Button::hoverStateColor, renderer, EventEmitter::setQueue(), Button::textColor, Button::upStateColor, and widgets.

◆ addEditBox()

Handle< EditBox > GUISystem::addEditBox ( int  x,
int  y,
int  w,
int  h,
bool  multiline = false 
)

Creates EditBox widget and assings it to the gui.

Parameters
xX coordinate
yY coordinate
wWidth
hHeight
multilineAre multiple lines allowed.
Returns
Handle to the EditBox object.

Definition at line 180 of file GUISystem.cpp.

References EventQueue::addToQueue(), EditBox::backgroundColor, Renderer::color(), EditBox::cursorColor, eventQueue, EditBox::frameColor, Widget::guiSystem, renderer, EditBox::setMultiline(), EventEmitter::setQueue(), EditBox::textColor, and widgets.

◆ addEventType()

void GUISystem::addEventType ( EventType  eventType,
CreateEventObject  createFunc 
)

Affililate event identifier with creating function.

Parameters
eventTypeEvent type identifier
createFuncFunction returning EventObject* pointer.

Definition at line 271 of file GUISystem.cpp.

References createEvtObjFuncs.

◆ addScrollbar()

Handle< Scrollbar > GUISystem::addScrollbar ( int  x,
int  y,
int  w,
int  h 
)

Creates Scrollbar widget and assings it to the gui.

Parameters
xX coordinate
yY coordinate
wWidth
hHeight
Returns
Handle to the Scrollbar object.

Definition at line 201 of file GUISystem.cpp.

References EventQueue::addToQueue(), Scrollbar::backgroundColor, Renderer::color(), eventQueue, Scrollbar::frameColor, Widget::guiSystem, renderer, EventEmitter::setQueue(), and widgets.

◆ addTextField()

Handle< TextField > GUISystem::addTextField ( int  x,
int  y,
int  w,
int  h,
std::string  text 
)

Creates TextField widget and assings it to the gui.

Parameters
xX coordinate
yY coordinate
wWidth
hHeight
textText to be desplayed.
Returns
Handle to the TextField object.

Definition at line 165 of file GUISystem.cpp.

References EventQueue::addToQueue(), Renderer::color(), eventQueue, Widget::guiSystem, renderer, EventEmitter::setQueue(), TextField::textColor, and widgets.

◆ addWidget()

Handle< Widget > GUISystem::addWidget ( CreateWidget  createWidget,
bool  setEventQueue 
)

Generic function for adding custom widgets.

Parameters
createWidgetX Function creating widget.
setEventQueueIf true, sets widget's addToQueue function.
Returns
Handle to the widget

Definition at line 217 of file GUISystem.cpp.

References EventQueue::addToQueue(), eventQueue, Widget::guiSystem, EventEmitter::setQueue(), and widgets.

◆ createEvent()

Event GUISystem::createEvent ( EventType  eventType)

Creates an event that can be emitted.

Parameters
eventTypeType of event
Returns
Event object

Definition at line 233 of file GUISystem.cpp.

References createEvtObjFuncs.

◆ createEventObject()

EventObject * GUISystem::createEventObject ( )

Creates an EventObject object.

Returns
Pointer to the created object.

Definition at line 248 of file GUISystem.cpp.

◆ createKeyboardEvent()

EventObject * GUISystem::createKeyboardEvent ( )

Creates an KeyboardEvent object.

Returns
Pointer to the created object.

Definition at line 264 of file GUISystem.cpp.

◆ createMouseEvent()

EventObject * GUISystem::createMouseEvent ( )

Creates an MouseEvent object with default values.

Returns
Pointer to the created object.

Definition at line 255 of file GUISystem.cpp.

References MouseEvent::mouseX, mouseX, MouseEvent::mouseY, and mouseY.

◆ getRenderer()

Renderer* GUISystem::getRenderer ( )
inline

◆ handleEvents()

void GUISystem::handleEvents ( )

Calls functions associated with events.

Definition at line 49 of file GUISystem.cpp.

References EventQueue::empty(), eventQueue, and EventQueue::getNextEvent().

◆ keyChar()

void GUISystem::keyChar ( int  unichar)

Updates gui state. To be called when a character is typed or repeated.

Definition at line 131 of file GUISystem.cpp.

References focus, and Widget::keyChar().

◆ keyDown()

void GUISystem::keyDown ( int  keyCode)

Updates gui state. To be called when a key is pressed.

Definition at line 139 of file GUISystem.cpp.

References focus, and Widget::keyDown().

◆ mouseAxes()

void GUISystem::mouseAxes ( int  x,
int  y 
)

Updates gui state. To be called when mouse is moved.

Definition at line 62 of file GUISystem.cpp.

References mouseX, mouseY, Widget::STATE_HOVER, Widget::STATE_UP, and widgets.

◆ mouseButtonDown()

void GUISystem::mouseButtonDown ( )

Updates gui state. To be called when mouse is pressed.

Definition at line 101 of file GUISystem.cpp.

References focus, Widget::focusIn(), Widget::focusOut(), mouseX, mouseY, Widget::STATE_DOWN, Widget::stateChange(), and widgets.

◆ mouseButtonUp()

void GUISystem::mouseButtonUp ( )

Updates gui state. To be called when mouse button is released.

Definition at line 90 of file GUISystem.cpp.

References Widget::STATE_UP, and widgets.

◆ render()

void GUISystem::render ( )

Renders the gui.

Definition at line 37 of file GUISystem.cpp.

References Renderer::clear(), renderer, Renderer::setTarget(), and widgets.

◆ setRenderer()

void GUISystem::setRenderer ( Renderer renderer)

Sets Renderer object to be used.

Parameters
rendererRenderer* pointer

Definition at line 32 of file GUISystem.cpp.

References renderer.

Member Data Documentation

◆ createEvtObjFuncs

Map GUISystem::createEvtObjFuncs
private

Definition at line 188 of file GUISystem.h.

◆ eventQueue

EventQueue GUISystem::eventQueue
private

Definition at line 189 of file GUISystem.h.

◆ focus

Widget* GUISystem::focus
private

Definition at line 191 of file GUISystem.h.

◆ mouseX

int GUISystem::mouseX

Mouse x coordinate.

Definition at line 177 of file GUISystem.h.

◆ mouseY

int GUISystem::mouseY

Mouse y coordinate.

Definition at line 181 of file GUISystem.h.

◆ renderer

Renderer* GUISystem::renderer
private

Definition at line 186 of file GUISystem.h.

◆ widgets

std::forward_list<Widget*> GUISystem::widgets
private

Definition at line 187 of file GUISystem.h.


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