Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIEditbox.h

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIEditbox.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for Editbox widget
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUIEditbox_h_
00027 #define _CEGUIEditbox_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "elements/CEGUIEditboxProperties.h"
00032 
00033 
00034 #if defined(_MSC_VER)
00035 #       pragma warning(push)
00036 #       pragma warning(disable : 4251)
00037 #endif
00038 
00039 
00040 // Start of CEGUI namespace section
00041 namespace CEGUI
00042 {
00043 // forward declare implementation data type
00044 struct RegexValidator;
00045 
00046 
00051 class CEGUIBASE_API Editbox : public Window
00052 {
00053 public:
00054         static const String EventNamespace;                             
00055 
00056 
00057         /*************************************************************************
00058                 Constants
00059         *************************************************************************/
00060         // default colours
00061         static const ulong      DefaultNormalTextColour;                        
00062         static const ulong      DefaultSelectedTextColour;                      
00063         static const ulong      DefaultNormalSelectionColour;           
00064         static const ulong      DefaultInactiveSelectionColour;         
00065 
00066 
00067         /*************************************************************************
00068                 Event name constants
00069         *************************************************************************/
00070         static const String EventReadOnlyModeChanged;                   
00071         static const String EventMaskedRenderingModeChanged;    
00072         static const String EventMaskCodePointChanged;          
00073         static const String EventValidationStringChanged;               
00074         static const String EventMaximumTextLengthChanged;      
00075         static const String EventTextInvalidated;                               
00076         static const String EventInvalidEntryAttempted;         
00077         static const String EventCaratMoved;                                    
00078         static const String EventTextSelectionChanged;          
00079         static const String EventEditboxFull;                                   
00080         static const String EventTextAccepted;                          
00081 
00082 
00083         /*************************************************************************
00084                 Accessor Functions
00085         *************************************************************************/
00093         bool    hasInputFocus(void) const;
00094 
00095 
00104         bool    isReadOnly(void) const          {return d_readOnly;}
00105 
00106 
00115         bool    isTextMasked(void) const        {return d_maskText;}
00116 
00117 
00134         bool    isTextValid(void) const;
00135 
00136 
00148         const String&   getValidationString(void) const         {return d_validationString;}
00149 
00150 
00158         ulong   getCaratIndex(void) const               {return d_caratPos;}
00159 
00160 
00169         ulong   getSelectionStartIndex(void) const;
00170 
00171 
00180         ulong   getSelectionEndIndex(void) const;
00181 
00182         
00190         ulong   getSelectionLength(void) const;
00191 
00192 
00201         utf32   getMaskCodePoint(void) const            {return d_maskCodePoint;}
00202 
00203 
00215         ulong   getMaxTextLength(void) const            {return d_maxTextLen;}
00216 
00217 
00226         colour  getNormalTextColour(void) const                         {return d_normalTextColour;}
00227 
00228 
00237         colour  getSelectedTextColour(void) const                       {return d_selectTextColour;}
00238 
00239 
00248         colour  getNormalSelectBrushColour(void) const          {return d_selectBrushColour;}
00249 
00250 
00259         colour  getInactiveSelectBrushColour(void) const        {return d_inactiveSelectBrushColour;}
00260 
00261 
00262         /*************************************************************************
00263                 Manipulators
00264         *************************************************************************/
00276         void    setReadOnly(bool setting);
00277 
00278 
00290         void    setTextMasked(bool setting);
00291 
00292 
00307         void    setValidationString(const String& validation_string);
00308 
00309 
00321         void    setCaratIndex(ulong carat_pos);
00322 
00323 
00339         void    setSelection(ulong start_pos, ulong end_pos);
00340         
00341 
00353         void    setMaskCodePoint(utf32 code_point);
00354 
00355 
00370         void    setMaxTextLength(ulong max_len);
00371 
00372 
00383         void    setNormalTextColour(const colour& col);
00384 
00385 
00394         void    setSelectedTextColour(const colour& col);
00395 
00396 
00408         void    setNormalSelectBrushColour(const colour& col);
00409 
00410 
00422         void    setInactiveSelectBrushColour(const colour& col);
00423 
00424 
00425         /*************************************************************************
00426                 Construction / Destruction
00427         *************************************************************************/
00432         Editbox(const String& type, const String& name);
00433 
00434 
00439         virtual ~Editbox(void);
00440 
00441 
00442 protected:
00443         /*************************************************************************
00444                 Implementation functions
00445         *************************************************************************/
00450         void    addEditboxEvents(void);
00451 
00452 
00463         virtual ulong   getTextIndexFromPosition(const Point& pt) const         = 0;
00464 
00465 
00470         void    clearSelection(void);
00471 
00472 
00480         void    eraseSelectedText(bool modify_text = true);
00481 
00482 
00487         bool    isStringValid(const String& str) const;
00488 
00489 
00490 
00495         void    handleBackspace(void);
00496 
00497 
00502         void    handleDelete(void);
00503 
00504 
00509         void    handleCharLeft(uint sysKeys);
00510 
00511 
00516         void    handleWordLeft(uint sysKeys);
00517 
00518 
00523         void    handleCharRight(uint sysKeys);
00524 
00525 
00530         void    handleWordRight(uint sysKeys);
00531 
00532 
00537         void    handleHome(uint sysKeys);
00538 
00539 
00544         void    handleEnd(uint sysKeys);
00545 
00546 
00547         /*************************************************************************
00548                 New event handlers
00549         *************************************************************************/
00554         virtual void    onReadOnlyChanged(WindowEventArgs& e);
00555 
00556 
00561         virtual void    onMaskedRenderingModeChanged(WindowEventArgs& e);
00562 
00563 
00568         virtual void    onMaskCodePointChanged(WindowEventArgs& e);
00569 
00570 
00575         virtual void    onValidationStringChanged(WindowEventArgs& e);
00576 
00577 
00582         virtual void    onMaximumTextLengthChanged(WindowEventArgs& e);
00583 
00584 
00592         virtual void    onTextInvalidatedEvent(WindowEventArgs& e);
00593 
00594 
00600         virtual void    onInvalidEntryAttempted(WindowEventArgs& e);
00601 
00602 
00607         virtual void    onCaratMoved(WindowEventArgs& e);
00608 
00609 
00614         virtual void    onTextSelectionChanged(WindowEventArgs& e);
00615 
00616 
00621         virtual void    onEditboxFullEvent(WindowEventArgs& e);
00622 
00623 
00628         virtual void    onTextAcceptedEvent(WindowEventArgs& e);
00629 
00630         
00631         /*************************************************************************
00632                 Overridden event handlers
00633         *************************************************************************/
00634         virtual void    onMouseButtonDown(MouseEventArgs& e);
00635         virtual void    onMouseButtonUp(MouseEventArgs& e);
00636         virtual void    onMouseDoubleClicked(MouseEventArgs& e);
00637         virtual void    onMouseTripleClicked(MouseEventArgs& e);
00638         virtual void    onMouseMove(MouseEventArgs& e);
00639         virtual void    onCaptureLost(WindowEventArgs& e);
00640         virtual void    onCharacter(KeyEventArgs& e);
00641         virtual void    onKeyDown(KeyEventArgs& e);
00642         virtual void    onTextChanged(WindowEventArgs& e);
00643 
00644 
00645         /*************************************************************************
00646                 Implementation data
00647         *************************************************************************/
00648         bool    d_readOnly;                     
00649         bool    d_maskText;                     
00650         utf32   d_maskCodePoint;        
00651         ulong   d_maxTextLen;           
00652         ulong   d_caratPos;                     
00653         ulong   d_selectionStart;       
00654         ulong   d_selectionEnd;         
00655         String  d_validationString;     
00656         RegexValidator* d_validator;            
00657         bool    d_dragging;                     
00658         ulong   d_dragAnchorIdx;        
00659 
00660         // basic rendering colours
00661         colour  d_normalTextColour;                             
00662         colour  d_selectTextColour;                             
00663         colour  d_selectBrushColour;                    
00664         colour  d_inactiveSelectBrushColour;    
00665 
00666 
00667 private:
00668         /*************************************************************************
00669                 Static Properties for this class
00670         *************************************************************************/
00671         static EditboxProperties::ReadOnly                                      d_readOnlyProperty;
00672         static EditboxProperties::MaskText                                      d_maskTextProperty;
00673         static EditboxProperties::MaskCodepoint                         d_maskCodepointProperty;
00674         static EditboxProperties::ValidationString                      d_validationStringProperty;
00675         static EditboxProperties::CaratIndex                            d_caratIndexProperty;
00676         static EditboxProperties::SelectionStart                        d_selectionStartProperty;
00677         static EditboxProperties::SelectionLength                       d_selectionLengthProperty;
00678         static EditboxProperties::MaxTextLength                         d_maxTextLengthProperty;
00679         static EditboxProperties::NormalTextColour                      d_normalTextColourProperty;
00680         static EditboxProperties::SelectedTextColour            d_selectedTextColourProperty;
00681         static EditboxProperties::ActiveSelectionColour         d_activeSelectionColourProperty;
00682         static EditboxProperties::InactiveSelectionColour       d_inactiveSelectionColourProperty;
00683 
00684 
00685         /*************************************************************************
00686                 Private methods
00687         *************************************************************************/
00688         void    addEditboxProperties(void);
00689 };
00690 
00691 } // End of  CEGUI namespace section
00692 
00693 
00694 #if defined(_MSC_VER)
00695 #       pragma warning(pop)
00696 #endif
00697 
00698 #endif  // end of guard _CEGUIEditbox_h_

Generated on Wed Feb 16 12:41:06 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1