GUI
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
gui::EditBox Class Reference

EditBox widget. You can type into it. More...

#include <EditBox.h>

Inherits gui::Widget.

Public Member Functions

 EditBox (GUISystem *guiSystem, int x, int y, int w, int h)
 
virtual ~EditBox ()
 
void render (Renderer *renderer)
 
void keyChar (int unichar)
 
void keyDown (int keyCode)
 
void setMultiline ()
 
void setText (const std::string &text)
 
std::string getText ()
 
- Public Member Functions inherited from gui::Widget
 Widget ()
 
 Widget (int x, int y, int w, int h)
 
virtual ~Widget ()
 
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 gui::EventEmitter
 EventEmitter ()
 
virtual ~EventEmitter ()
 
void setQueue (AddToQueue addFunction)
 Assigns 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)
 Emits an event. More...
 

Protected Attributes

Color textColor
 
Color frameColor
 
Color backgroundColor
 
Color cursorColor
 
int backspaceCode
 
- Protected Attributes inherited from gui::Widget
int x
 
int y
 
int w
 
int h
 
int xAbs
 
int yAbs
 
int state
 
bool focused
 
bool visible
 
- Protected Attributes inherited from gui::EventEmitter
GUISystemguiSystem
 

Private Member Functions

void updateScrollbars ()
 
void getCursorXY (Renderer *renderer, int &cursorX, int &cursorY)
 
void findCursorLine ()
 
void countLines ()
 

Private Attributes

Handle< ScrollbarvScrollbar
 
Handle< ScrollbarhScrollbar
 
std::string text
 
unsigned int cursorPos
 
unsigned int cursorLine
 
int lines
 
float lineHeight
 
bool multiline
 
bool vScroll
 
bool hScroll
 

Friends

class GUISystem
 

Additional Inherited Members

- Public Types inherited from gui::Widget
enum  states { STATE_HOVER, STATE_DOWN, STATE_UP }
 
typedef char State
 
- Public Types inherited from gui::EventEmitter
typedef std::multimap< EventType, EventListenerMap
 

Detailed Description

EditBox widget. You can type into it.

Definition at line 22 of file EditBox.h.

Constructor & Destructor Documentation

◆ EditBox()

EditBox::EditBox ( GUISystem guiSystem,
int  x,
int  y,
int  w,
int  h 
)

Definition at line 14 of file EditBox.cpp.

References hScrollbar, and vScrollbar.

◆ ~EditBox()

virtual gui::EditBox::~EditBox ( )
inlinevirtual

Definition at line 26 of file EditBox.h.

References getText(), keyChar(), keyDown(), render(), setMultiline(), setText(), and text.

Member Function Documentation

◆ countLines()

void EditBox::countLines ( )
private

Definition at line 174 of file EditBox.cpp.

References lines, and text.

◆ findCursorLine()

void EditBox::findCursorLine ( )
private

Definition at line 163 of file EditBox.cpp.

References cursorLine, cursorPos, and text.

◆ getCursorXY()

void EditBox::getCursorXY ( Renderer renderer,
int &  cursorX,
int &  cursorY 
)
private

Definition at line 143 of file EditBox.cpp.

References cursorLine, cursorPos, gui::Renderer::getTextWidth(), lineHeight, and text.

◆ getText()

std::string EditBox::getText ( )

Definition at line 116 of file EditBox.cpp.

References text.

◆ keyChar()

void EditBox::keyChar ( int  unichar)
virtual

Reimplemented from gui::Widget.

Definition at line 60 of file EditBox.cpp.

References countLines(), cursorPos, findCursorLine(), text, and updateScrollbars().

◆ keyDown()

void EditBox::keyDown ( int  keyCode)
virtual

◆ render()

void EditBox::render ( Renderer renderer)
virtual

◆ setMultiline()

void EditBox::setMultiline ( )

Definition at line 105 of file EditBox.cpp.

References multiline.

◆ setText()

void EditBox::setText ( const std::string &  text)

Definition at line 110 of file EditBox.cpp.

References countLines(), and text.

◆ updateScrollbars()

void EditBox::updateScrollbars ( )
private

Definition at line 121 of file EditBox.cpp.

References gui::Widget::h, lineHeight, lines, vScroll, and vScrollbar.

Friends And Related Function Documentation

◆ GUISystem

friend class GUISystem
friend

Definition at line 62 of file EditBox.h.

Member Data Documentation

◆ backgroundColor

Color gui::EditBox::backgroundColor
protected

Definition at line 39 of file EditBox.h.

◆ backspaceCode

int gui::EditBox::backspaceCode
protected

Definition at line 42 of file EditBox.h.

◆ cursorColor

Color gui::EditBox::cursorColor
protected

Definition at line 40 of file EditBox.h.

◆ cursorLine

unsigned int gui::EditBox::cursorLine
private

Definition at line 55 of file EditBox.h.

◆ cursorPos

unsigned int gui::EditBox::cursorPos
private

Definition at line 54 of file EditBox.h.

◆ frameColor

Color gui::EditBox::frameColor
protected

Definition at line 38 of file EditBox.h.

◆ hScroll

bool gui::EditBox::hScroll
private

Definition at line 60 of file EditBox.h.

◆ hScrollbar

Handle<Scrollbar> gui::EditBox::hScrollbar
private

Definition at line 51 of file EditBox.h.

◆ lineHeight

float gui::EditBox::lineHeight
private

Definition at line 57 of file EditBox.h.

◆ lines

int gui::EditBox::lines
private

Definition at line 56 of file EditBox.h.

◆ multiline

bool gui::EditBox::multiline
private

Definition at line 58 of file EditBox.h.

◆ text

std::string gui::EditBox::text
private

Definition at line 53 of file EditBox.h.

◆ textColor

Color gui::EditBox::textColor
protected

Definition at line 37 of file EditBox.h.

◆ vScroll

bool gui::EditBox::vScroll
private

Definition at line 59 of file EditBox.h.

◆ vScrollbar

Handle<Scrollbar> gui::EditBox::vScrollbar
private

Definition at line 50 of file EditBox.h.


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