Crazy Eddie's GUI System  0.8.7
widgets/Editbox.h
1 /***********************************************************************
2  created: 13/4/2004
3  author: Paul D Turner
4 
5  purpose: Interface to base class for Editbox widget
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIEditbox_h_
30 #define _CEGUIEditbox_h_
31 
32 #include "CEGUI/Base.h"
33 #include "CEGUI/Window.h"
34 #include "CEGUI/RegexMatcher.h"
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
45 class CEGUIEXPORT EditboxWindowRenderer : public WindowRenderer
46 {
47 public:
50 
63  virtual size_t getTextIndexFromPosition(const Vector2f& pt) const = 0;
64 };
65 
66 //----------------------------------------------------------------------------//
67 
69 class CEGUIEXPORT Editbox : public Window
70 {
71 public:
73 
75  static const String EventNamespace;
77  static const String WidgetTypeName;
128  static const String EventCaretMoved;
140  static const String EventEditboxFull;
147  static const String EventTextAccepted;
148 
157  bool hasInputFocus(void) const;
158 
167  bool isReadOnly(void) const
168  {return d_readOnly;}
169 
179  bool isTextMasked(void) const
180  {return d_maskText;}
181 
202 
221  const String& getValidationString(void) const
222  {return d_validationString;}
223 
231  size_t getCaretIndex(void) const;
232 
242  size_t getSelectionStartIndex(void) const;
243 
252  size_t getSelectionEndIndex(void) const;
253 
263  size_t getSelectionLength(void) const;
264 
275  { return d_maskCodePoint; }
276 
290  size_t getMaxTextLength(void) const
291  {return d_maxTextLen;}
292 
304  void setReadOnly(bool setting);
305 
318  void setTextMasked(bool setting);
319 
341  void setValidationString(const String& validation_string);
342 
355  void setCaretIndex(size_t caret_pos);
356 
374  void setSelection(size_t start_pos, size_t end_pos);
375 
387  void setSelectionStart(size_t start_pos);
388 
399  void setSelectionLength(size_t length);
400 
414 
431  void setMaxTextLength(size_t max_len);
432 
450  void setValidator(RegexMatcher* matcher);
451 
453  virtual bool performCopy(Clipboard& clipboard);
454 
456  virtual bool performCut(Clipboard& clipboard);
457 
459  virtual bool performPaste(Clipboard& clipboard);
460 
462  Editbox(const String& type, const String& name);
463 
465  virtual ~Editbox(void);
466 
467 protected:
480  size_t getTextIndexFromPosition(const Vector2f& pt) const;
481 
483  void clearSelection(void);
484 
493  void eraseSelectedText(bool modify_text = true);
494 
501 
511 
513  void handleBackspace(void);
514 
516  void handleDelete(void);
517 
519  void handleCharLeft(uint sysKeys);
520 
522  void handleWordLeft(uint sysKeys);
523 
525  void handleCharRight(uint sysKeys);
526 
528  void handleWordRight(uint sysKeys);
529 
531  void handleHome(uint sysKeys);
532 
534  void handleEnd(uint sysKeys);
535 
537  virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
538 
544 
551 
558 
564 
570 
577 
582  virtual void onCaretMoved(WindowEventArgs& e);
583 
589 
596 
603 
604  // Overridden event handlers
614 
622  size_t d_maxTextLen;
624  size_t d_caretPos;
643 
644 private:
645 
646  void addEditboxProperties(void);
647 };
648 
649 } // End of CEGUI namespace section
650 
651 #if defined(_MSC_VER)
652 # pragma warning(pop)
653 #endif
654 
655 #endif // end of guard _CEGUIEditbox_h_
CEGUI::Clipboard
Defines a clipboard handling class.
Definition: Clipboard.h:84
CEGUI::Editbox::onCharacter
void onCharacter(KeyEventArgs &e)
Handler called when a character-key has been pressed while this window has input focus.
CEGUI::Editbox::isTextMasked
bool isTextMasked(void) const
return true if the text for the Editbox will be rendered masked.
Definition: widgets/Editbox.h:179
CEGUI::Editbox::getMaskCodePoint
String::value_type getMaskCodePoint(void) const
return the code point used when rendering masked text.
Definition: widgets/Editbox.h:274
CEGUI::Editbox::d_caretPos
size_t d_caretPos
Position of the caret / insert-point.
Definition: widgets/Editbox.h:624
CEGUI::Editbox::handleHome
void handleHome(uint sysKeys)
Processing to move caret to the start of the text.
CEGUI::Editbox::d_dragging
bool d_dragging
true when a selection is being dragged.
Definition: widgets/Editbox.h:636
CEGUI::Editbox::d_maskText
bool d_maskText
True if the editbox text should be rendered masked.
Definition: widgets/Editbox.h:618
CEGUI::Editbox::getSelectionEndIndex
size_t getSelectionEndIndex(void) const
return the current selection end point.
CEGUI::Editbox::onValidationStringChanged
virtual void onValidationStringChanged(WindowEventArgs &e)
Event fired internally when the validation string is changed.
CEGUI::Editbox::setCaretIndex
void setCaretIndex(size_t caret_pos)
Set the current position of the caret.
CEGUI::EditboxWindowRenderer
Base class for the EditboxWindowRenderer class.
Definition: widgets/Editbox.h:46
CEGUI::Editbox::onMouseMove
void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
CEGUI::Editbox::setMaskCodePoint
void setMaskCodePoint(String::value_type code_point)
set the code point used when rendering masked text.
CEGUI::Editbox::handleWordLeft
void handleWordLeft(uint sysKeys)
Processing to move caret one word left.
CEGUI::Editbox::getTextIndexFromPosition
size_t getTextIndexFromPosition(const Vector2f &pt) const
Return the text code point index that is rendered closest to screen position pt.
CEGUI::Editbox::getValidationString
const String & getValidationString(void) const
return the currently set validation string
Definition: widgets/Editbox.h:221
CEGUI::Editbox::onCaretMoved
virtual void onCaretMoved(WindowEventArgs &e)
Handler called when the caret (insert point) position changes.
CEGUI::Editbox::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition: widgets/Editbox.h:77
CEGUI::Editbox::handleBackspace
void handleBackspace(void)
Processing for backspace key.
CEGUI::Editbox::setSelectionStart
void setSelectionStart(size_t start_pos)
Define the current selection start for the Editbox.
CEGUI::EditboxWindowRenderer::EditboxWindowRenderer
EditboxWindowRenderer(const String &name)
Constructor.
CEGUI::Editbox::setMaxTextLength
void setMaxTextLength(size_t max_len)
set the maximum text length for this Editbox.
CEGUI::Editbox::setValidationString
void setValidationString(const String &validation_string)
Set the text validation string.
CEGUI::Editbox::handleEnd
void handleEnd(uint sysKeys)
Processing to move caret to the end of the text.
CEGUI::Editbox::onMouseButtonUp
void onMouseButtonUp(MouseEventArgs &e)
Handler called when a mouse button has been released within this window's area.
CEGUI::Editbox::setSelection
void setSelection(size_t start_pos, size_t end_pos)
Define the current selection for the Editbox.
CEGUI::Editbox::d_validatorMatchState
MatchState d_validatorMatchState
Current match state of EditboxText.
Definition: widgets/Editbox.h:640
CEGUI::Editbox::d_validator
RegexMatcher * d_validator
Pointer to class used for validation of text.
Definition: widgets/Editbox.h:632
CEGUI::Editbox::d_maskCodePoint
String::value_type d_maskCodePoint
Code point to use when rendering masked text.
Definition: widgets/Editbox.h:620
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Editbox::getTextMatchState
MatchState getTextMatchState() const
return the validation MatchState for the current Editbox text, given the currently set validation str...
CEGUI::Editbox::onTextSelectionChanged
virtual void onTextSelectionChanged(WindowEventArgs &e)
Handler called when the current text selection changes.
CEGUI::Editbox::performPaste
virtual bool performPaste(Clipboard &clipboard)
Asks the widget to perform a clipboard paste from the provided clipboard.
CEGUI::Editbox::hasInputFocus
bool hasInputFocus(void) const
return true if the Editbox has input focus.
CEGUI::Editbox::EventTextSelectionChanged
static const String EventTextSelectionChanged
Definition: widgets/Editbox.h:134
CEGUI::MouseEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
CEGUI::Editbox::setTextMasked
void setTextMasked(bool setting)
Specify whether the text for the Editbox will be rendered masked.
CEGUI::Editbox::EventEditboxFull
static const String EventEditboxFull
Definition: widgets/Editbox.h:140
CEGUI::RegexMatcher
Interface for Regex matching support classes.
Definition: RegexMatcher.h:41
CEGUI::Editbox::getStringMatchState
MatchState getStringMatchState(const String &str) const
return the match state of the given string for the validation regular expression.
CEGUI::Editbox::isReadOnly
bool isReadOnly(void) const
return true if the Editbox is read-only.
Definition: widgets/Editbox.h:167
CEGUI::Vector2< float >
CEGUI::RegexMatchStateEventArgs
Definition: RegexMatcher.h:70
CEGUI::Editbox::getCaretIndex
size_t getCaretIndex(void) const
return the current position of the caret.
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::Editbox::onEditboxFullEvent
virtual void onEditboxFullEvent(WindowEventArgs &e)
Handler called when the edit box text has reached the set maximum length.
CEGUI::Editbox::onTextAcceptedEvent
virtual void onTextAcceptedEvent(WindowEventArgs &e)
Handler called when the user accepts the edit box text by pressing Return, Enter, or Tab.
CEGUI::Editbox::onReadOnlyChanged
virtual void onReadOnlyChanged(WindowEventArgs &e)
Handler called when the read only state of the Editbox has been changed.
CEGUI::Editbox::onMaskCodePointChanged
virtual void onMaskCodePointChanged(WindowEventArgs &e)
Handler called when the code point to use for masked rendering has been changed.
CEGUI::Editbox::handleDelete
void handleDelete(void)
Processing for Delete key.
CEGUI::Editbox::d_weOwnValidator
bool d_weOwnValidator
specifies whether validator was created by us, or supplied by user.
Definition: widgets/Editbox.h:634
CEGUI::Editbox::d_readOnly
bool d_readOnly
True if the editbox is in read-only mode.
Definition: widgets/Editbox.h:616
CEGUI::Editbox
Base class for an Editbox widget.
Definition: widgets/Editbox.h:70
CEGUI::KeyEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning keyboard inp...
Definition: InputEvent.h:315
CEGUI::Editbox::clearSelection
void clearSelection(void)
Clear the currently defined selection (just the region, not the text).
CEGUI::Editbox::eraseSelectedText
void eraseSelectedText(bool modify_text=true)
Erase the currently selected text.
CEGUI::Editbox::d_maxTextLen
size_t d_maxTextLen
Maximum number of characters for this Editbox.
Definition: widgets/Editbox.h:622
CEGUI::Editbox::handleValidityChangeForString
bool handleValidityChangeForString(const String &str)
CEGUI::RegexMatcher::MatchState
MatchState
Enumeration of possible states when cosidering a regex match.
Definition: RegexMatcher.h:45
CEGUI::Editbox::d_dragAnchorIdx
size_t d_dragAnchorIdx
Selection index for drag selection anchor point.
Definition: widgets/Editbox.h:638
CEGUI::String::value_type
utf32 value_type
Basic 'code point' type used for String (utf32)
Definition: String.h:69
CEGUI::Editbox::getSelectionStartIndex
size_t getSelectionStartIndex(void) const
return the current selection start point.
CEGUI::Editbox::performCopy
virtual bool performCopy(Clipboard &clipboard)
Asks the widget to perform a clipboard copy to the provided clipboard.
CEGUI::Editbox::Editbox
Editbox(const String &type, const String &name)
Constructor for Editbox class.
CEGUI::Editbox::EventReadOnlyModeChanged
static const String EventReadOnlyModeChanged
Definition: widgets/Editbox.h:83
CEGUI::Editbox::onMaximumTextLengthChanged
virtual void onMaximumTextLengthChanged(WindowEventArgs &e)
Handler called when the maximum text length for the edit box is changed.
CEGUI::Editbox::handleCharRight
void handleCharRight(uint sysKeys)
Processing to move caret one character right.
CEGUI::Editbox::EventTextAccepted
static const String EventTextAccepted
Definition: widgets/Editbox.h:147
CEGUI::Editbox::onMouseTripleClicked
void onMouseTripleClicked(MouseEventArgs &e)
Handler called when a mouse button has been triple-clicked within this window's area.
CEGUI::Editbox::getSelectionLength
size_t getSelectionLength(void) const
return the length of the current selection (in code points / characters).
CEGUI::Editbox::EventMaximumTextLengthChanged
static const String EventMaximumTextLengthChanged
Definition: widgets/Editbox.h:108
CEGUI::Editbox::onTextChanged
void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
CEGUI::Editbox::onCaptureLost
void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
CEGUI::Window
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
CEGUI::Editbox::onKeyDown
void onKeyDown(KeyEventArgs &e)
Handler called when a key as been depressed while this window has input focus.
CEGUI::Editbox::~Editbox
virtual ~Editbox(void)
Destructor for Editbox class.
CEGUI::Editbox::onMouseButtonDown
void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
CEGUI::Editbox::getMaxTextLength
size_t getMaxTextLength(void) const
return the maximum text length set for this Editbox.
Definition: widgets/Editbox.h:290
CEGUI::WindowRenderer
Base-class for the assignable WindowRenderer object.
Definition: WindowRenderer.h:52
CEGUI::Editbox::setValidator
void setValidator(RegexMatcher *matcher)
Set the RegexMatcher based validator for this Editbox.
CEGUI::Editbox::EventMaskedRenderingModeChanged
static const String EventMaskedRenderingModeChanged
Definition: widgets/Editbox.h:89
CEGUI::Editbox::EventValidationStringChanged
static const String EventValidationStringChanged
Definition: widgets/Editbox.h:102
CEGUI::Editbox::EventTextValidityChanged
static const String EventTextValidityChanged
Definition: widgets/Editbox.h:122
CEGUI::Editbox::d_previousValidityChangeResponse
bool d_previousValidityChangeResponse
Previous match state change response.
Definition: widgets/Editbox.h:642
CEGUI::Editbox::performCut
virtual bool performCut(Clipboard &clipboard)
Asks the widget to perform a clipboard cut to the provided clipboard.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::EditboxWindowRenderer::getTextIndexFromPosition
virtual size_t getTextIndexFromPosition(const Vector2f &pt) const =0
Return the text code point index that is rendered closest to screen position pt.
CEGUI::Editbox::onMaskedRenderingModeChanged
virtual void onMaskedRenderingModeChanged(WindowEventArgs &e)
Handler called when the masked rendering mode (password mode) has been changed.
CEGUI::Editbox::EventMaskCodePointChanged
static const String EventMaskCodePointChanged
Definition: widgets/Editbox.h:96
CEGUI::Editbox::d_validationString
String d_validationString
Copy of validation reg-ex string.
Definition: widgets/Editbox.h:630
CEGUI::Editbox::handleCharLeft
void handleCharLeft(uint sysKeys)
Processing to move caret one character left.
CEGUI::Editbox::setSelectionLength
void setSelectionLength(size_t length)
Define the current selection for the Editbox.
CEGUI::Editbox::onMouseDoubleClicked
void onMouseDoubleClicked(MouseEventArgs &e)
Handler called when a mouse button has been double-clicked within this window's area.
CEGUI::Editbox::handleWordRight
void handleWordRight(uint sysKeys)
Processing to move caret one word right.
CEGUI::Editbox::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: widgets/Editbox.h:75
CEGUI::Editbox::validateWindowRenderer
virtual bool validateWindowRenderer(const WindowRenderer *renderer) const
validate window renderer
CEGUI::Editbox::setReadOnly
void setReadOnly(bool setting)
Specify whether the Editbox is read-only.
CEGUI::Editbox::onTextValidityChanged
virtual void onTextValidityChanged(RegexMatchStateEventArgs &e)
Handler called when something has caused the validity state of the current text to change.
CEGUI::Editbox::d_selectionEnd
size_t d_selectionEnd
End of selection area.
Definition: widgets/Editbox.h:628
CEGUI::Editbox::d_selectionStart
size_t d_selectionStart
Start of selection area.
Definition: widgets/Editbox.h:626
CEGUI::Editbox::EventCaretMoved
static const String EventCaretMoved
Definition: widgets/Editbox.h:128