Pyrogenesis
trunk
|
Text field where you can input and edit the text. More...
#include <CInput.h>
Classes | |
struct | SRow |
Public Member Functions | |
CInput () | |
virtual | ~CInput () |
virtual void | ResetStates () |
int | GetMouseHoveringTextPosition () const |
int | GetXTextPosition (const std::list< SRow >::const_iterator &c, const float &x, float &wanted) const |
Public Member Functions inherited from IGUIScrollBarOwner | |
IGUIScrollBarOwner () | |
virtual | ~IGUIScrollBarOwner () |
virtual const SGUIScrollBarStyle * | GetScrollBarStyle (const CStr &style) const |
Interface for the m_ScrollBar to use. More... | |
virtual void | AddScrollBar (IGUIScrollBar *scrollbar) |
Add a scroll-bar. More... | |
virtual IGUIScrollBar & | GetScrollBar (const int &index) |
Get Scroll Bar reference (it should be transparent it's actually pointers). More... | |
virtual float | GetScrollBarPos (const int index) const |
Get the position of the scroll bar at. More... | |
Public Member Functions inherited from IGUIObject | |
IGUIObject () | |
virtual | ~IGUIObject () |
virtual bool | MouseOver () |
Checks if mouse is hovering this object. More... | |
virtual bool | MouseOverIcon () |
Test if mouse position is over an icon. More... | |
const CStr & | GetName () const |
Get object name, name is unique. More... | |
void | SetName (const CStr &Name) |
Get object name. More... | |
CStr | GetPresentableName () const |
void | AddToPointersMap (map_pObjects &ObjectMap) |
Adds object and its children to the map, it's name being the first part, and the second being itself. More... | |
void | AddChild (IGUIObject *pChild) |
Notice nothing will be returned or thrown if the child hasn't been inputted into the GUI yet. More... | |
vector_pObjects::iterator | begin () |
vector_pObjects::iterator | end () |
bool | SettingExists (const CStr &Setting) const |
Checks if settings exists, only available for derived classes that has this set up, that's why the base class just returns false. More... | |
PSRETURN | SetSetting (const CStr &Setting, const CStrW &Value, const bool &SkipMessage=false) |
Set a setting by string, regardless of what type it is. More... | |
PSRETURN | GetSettingType (const CStr &Setting, EGUISettingType &Type) const |
Retrieves the type of a named setting. More... | |
void | RegisterScriptHandler (const CStr &Action, const CStr &Code, CGUI *pGUI) |
Set the script handler for a particular object-specific action. More... | |
JSObject * | GetJSObject () |
Retrieves the JSObject representing this GUI object. More... | |
CGUI * | GetGUI () |
const CGUI * | GetGUI () const |
void | SetFocus () |
Take focus! More... | |
Protected Member Functions | |
virtual void | HandleMessage (SGUIMessage &Message) |
virtual InReaction | ManuallyHandleEvent (const SDL_Event_ *ev) |
Handle events manually to catch keyboard inputting. More... | |
virtual InReaction | ManuallyHandleHotkeyEvent (const SDL_Event_ *ev) |
Handle hotkey events (called by ManuallyHandleEvent) More... | |
virtual void | UpdateCachedSize () |
virtual void | Draw () |
Draws the Text. More... | |
void | UpdateText (int from=0, int to_before=-1, int to_after=-1) |
Calculate m_CharacterPosition the main task for this function is to perfom word-wrapping You input from which character it has been changed, because if we add a character to the very last end, we don't want process everything all over again! Also notice you can specify a 'to' also, it will only be used though if a ' ' appears, because then the word-wrapping won't change after that. More... | |
void | DeleteCurSelection () |
Delete the current selection. More... | |
bool | SelectingText () const |
Is text selected? It can be denote two ways, m_iBufferPos_Tail being -1 or the same as m_iBufferPos. More... | |
float | GetTextAreaWidth () |
Get area of where text can be drawn. More... | |
void | UpdateAutoScroll () |
Called every time the auto-scrolling should be checked. More... | |
void | ClearComposedText () |
Clear composed IME input when supported (SDL2 only). More... | |
void | UpdateBufferPositionSetting () |
Updates the buffer (cursor) position exposed to JS. More... | |
Protected Member Functions inherited from IGUIObject | |
void | AddSetting (const EGUISettingType &Type, const CStr &Name) |
Add a setting to m_Settings. More... | |
virtual void | Destroy () |
Calls Destroy on all children, and deallocates all memory. More... | |
void | LoadStyle (CGUI &GUIinstance, const CStr &StyleName) |
Loads a style. More... | |
void | LoadStyle (const SGUIStyle &Style) |
Loads a style. More... | |
virtual float | GetBufferedZ () const |
Returns not the Z value, but the actual buffered Z value, i.e. More... | |
void | SetGUI (CGUI *const &pGUI) |
void | SetParent (IGUIObject *pParent) |
Set parent of this object. More... | |
bool | IsFocused () const |
Check if object is focused. More... | |
IGUIObject * | GetParent () const |
NOTE! This will not just return m_pParent, when that is need use it! There is one exception to it, when the parent is the top-node (the object that isn't a real object), this will return NULL, so that the top-node's children are seemingly parentless. More... | |
CPos | GetMousePos () const |
Get Mouse from CGUI. More... | |
virtual bool | HandleAdditionalChildren (const XMBElement &child, CXeromyces *pFile) |
Handle additional children to the <object>-tag. More... | |
InReaction | SendEvent (EGUIMessageType type, const CStr &EventName) |
Send event to this GUI object (HandleMessage and ScriptEvent) More... | |
void | ScriptEvent (const CStr &Action) |
Execute the script for a particular action. More... | |
void | ScriptEvent (const CStr &Action, JS::HandleValue Argument) |
Execute the script for a particular action. More... | |
void | SetScriptHandler (const CStr &Action, JS::HandleObject Function) |
void | UpdateMouseOver (IGUIObject *const &pMouseOver) |
Inputes the object that is currently hovered, this function updates this object accordingly (i.e. More... | |
Protected Attributes | |
int | m_iBufferPos |
Cursor position. More... | |
int | m_iBufferPos_Tail |
Cursor position we started to select from. More... | |
bool | m_ComposingText |
If we're composing text with an IME. More... | |
int | m_iComposedLength |
The length and position of the current IME composition. More... | |
int | m_iComposedPos |
int | m_iInsertPos |
The position to insert committed text. More... | |
std::list< SRow > | m_CharacterPositions |
List of rows to ease changing its size, so iterators stay valid. More... | |
float | m_WantedX |
When you change row with up/down, and the row you jump to does not have anything at that X position, then it will keep the m_WantedX position in mind when switching to the next row. More... | |
bool | m_SelectingText |
If we are in the process of selecting a larger selection of text using the mouse click (hold) and drag, this is true. More... | |
float | m_HorizontalScroll |
double | m_PrevTime |
Used to store the previous time for flashing the cursor. More... | |
double | m_CursorBlinkRate |
Cursor blink rate in seconds, if greater than 0.0. More... | |
bool | m_CursorVisState |
If the cursor should be drawn or not. More... | |
Protected Attributes inherited from IGUIScrollBarOwner | |
std::vector< IGUIScrollBar * > | m_ScrollBars |
Predominately you will only have one, but you can have as many as you like. More... | |
Protected Attributes inherited from IGUIObject | |
CRect | m_CachedActualSize |
Cached size, real size m_Size is actually dependent on resolution and can have different real outcomes, this is the real outcome cached to avoid slow calculations in real time. More... | |
CStr | m_Name |
vector_pObjects | m_Children |
IGUIObject * | m_pParent |
double | m_LastClickTime [6] |
bool | m_MouseHovering |
This is an array of true or false, each element is associated with a string representing a setting. More... | |
Additional Inherited Members | |
Public Attributes inherited from IGUIObject | |
std::map< CStr, SGUISetting > | m_Settings |
Settings pool, all an object's settings are located here If a derived object has got more settings that the base settings, it's because they have a new version of the function SetupSettings(). More... | |
Text field where you can input and edit the text.
It doesn't use IGUITextOwner, because we don't need any other features than word-wrapping, and we need to be able to rapidly change the string.
CInput::CInput | ( | ) |
|
virtual |
|
protected |
Clear composed IME input when supported (SDL2 only).
|
protected |
Delete the current selection.
Also places the pointer at the crack between the two segments kept.
|
protectedvirtual |
Draws the Text.
Reimplemented from IGUIScrollBarOwner.
int CInput::GetMouseHoveringTextPosition | ( | ) | const |
|
protected |
Get area of where text can be drawn.
int CInput::GetXTextPosition | ( | const std::list< SRow >::const_iterator & | c, |
const float & | x, | ||
float & | wanted | ||
) | const |
|
protectedvirtual |
Reimplemented from IGUIScrollBarOwner.
|
protectedvirtual |
Handle events manually to catch keyboard inputting.
Conventions for Left/Right when text is selected:
References:
Visual Studio Visual Studio has the 'newer' approach, used by newer versions of things, and in newer applications. A left press will always place the pointer on the left edge of the selection, and then of course remove the selection. Right will do the exact same thing. If you have the pointer on the right edge and press right, it will in other words just remove the selection.
Windows (eg. Notepad) A left press always takes the pointer a step to the left and removes the selection as if it were never there in the first place. Right of course does the same thing but to the right.
I chose the Visual Studio convention. Used also in Word, gtk 2.0, MSN Messenger.
Conventions for Up/Down when text is selected:
References:
Visual Studio Visual Studio has a very strange approach, down takes you below the selection to the next row, and up to the one prior to the whole selection. The weird part is that it is always aligned as the 'pointer'. I decided this is to much work for something that is a bit arbitrary
Windows (eg. Notepad) Just like with left/right, the selection is destroyed and it moves just as if there never were a selection.
I chose the Notepad convention even though I use the VS convention with left/right.
Reimplemented from IGUIObject.
|
protectedvirtual |
Handle hotkey events (called by ManuallyHandleEvent)
|
inlinevirtual |
Reimplemented from IGUIScrollBarOwner.
|
protected |
Is text selected? It can be denote two ways, m_iBufferPos_Tail being -1 or the same as m_iBufferPos.
This makes for clearer code.
|
protected |
Called every time the auto-scrolling should be checked.
|
protected |
Updates the buffer (cursor) position exposed to JS.
|
protectedvirtual |
Reimplemented from IGUIObject.
|
protected |
Calculate m_CharacterPosition the main task for this function is to perfom word-wrapping You input from which character it has been changed, because if we add a character to the very last end, we don't want process everything all over again! Also notice you can specify a 'to' also, it will only be used though if a '
' appears, because then the word-wrapping won't change after that.
|
protected |
List of rows to ease changing its size, so iterators stay valid.
For one-liners only one row is used.
|
protected |
If we're composing text with an IME.
|
protected |
Cursor blink rate in seconds, if greater than 0.0.
|
protected |
If the cursor should be drawn or not.
|
protected |
|
protected |
Cursor position.
|
protected |
Cursor position we started to select from.
(-1 if not selecting) (NB: Can be larger than m_iBufferPos if selecting from back to front.)
|
protected |
The length and position of the current IME composition.
|
protected |
|
protected |
The position to insert committed text.
|
protected |
Used to store the previous time for flashing the cursor.
|
protected |
If we are in the process of selecting a larger selection of text using the mouse click (hold) and drag, this is true.
|
protected |
When you change row with up/down, and the row you jump to does not have anything at that X position, then it will keep the m_WantedX position in mind when switching to the next row.
It will keep on being used until it reach a row which meets the requirements. 0.0f means not in use.