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

CEGUIMultiLineEditbox.h

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIMultiLineEditbox.h
00003         created:        30/6/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to the Multi-lien edit box base class.
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 _CEGUIMultiLineEditbox_h_
00027 #define _CEGUIMultiLineEditbox_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "CEGUIFont.h"
00032 #include "elements/CEGUIMultiLineEditboxProperties.h"
00033 
00034 #include <vector>
00035 
00036 
00037 #if defined(_MSC_VER)
00038 #       pragma warning(push)
00039 #       pragma warning(disable : 4251)
00040 #endif
00041 
00042 
00043 // Start of CEGUI namespace section
00044 namespace CEGUI
00045 {
00050 class CEGUIBASE_API MultiLineEditbox : public Window
00051 {
00052 public:
00053         static const String EventNamespace;                             
00054 
00055 
00056         /*************************************************************************
00057                 Constants
00058         *************************************************************************/
00059         // event names
00060         static const String EventReadOnlyModeChanged;                   
00061         static const String EventWordWrapModeChanged;                   
00062         static const String EventMaximumTextLengthChanged;      
00063         static const String EventCaratMoved;                                    
00064         static const String EventTextSelectionChanged;          
00065         static const String EventEditboxFull;                                   
00066         static const String EventVertScrollbarModeChanged;      
00067         static const String EventHorzScrollbarModeChanged;      
00068 
00069         // default colours
00070         static const ulong      DefaultNormalTextColour;                        
00071         static const ulong      DefaultSelectedTextColour;                      
00072         static const ulong      DefaultNormalSelectionColour;           
00073         static const ulong      DefaultInactiveSelectionColour;         
00074 
00075 
00076         /*************************************************************************
00077                 Accessor Functions
00078         *************************************************************************/
00087         bool    hasInputFocus(void) const;
00088 
00089 
00098         bool    isReadOnly(void) const          {return d_readOnly;}
00099 
00100 
00108         ulong   getCaratIndex(void) const               {return d_caratPos;}
00109 
00110 
00119         ulong   getSelectionStartIndex(void) const;
00120 
00121 
00130         ulong   getSelectionEndIndex(void) const;
00131 
00132         
00140         ulong   getSelectionLength(void) const;
00141 
00142 
00150         ulong   getMaxTextLength(void) const            {return d_maxTextLen;}
00151 
00152 
00161         colour  getNormalTextColour(void) const                         {return d_normalTextColour;}
00162 
00163 
00172         colour  getSelectedTextColour(void) const                       {return d_selectTextColour;}
00173 
00174 
00183         colour  getNormalSelectBrushColour(void) const          {return d_selectBrushColour;}
00184 
00185 
00194         colour  getInactiveSelectBrushColour(void) const        {return d_inactiveSelectBrushColour;}
00195 
00196 
00205         bool    isWordWrapped(void) const;
00206 
00207 
00208         /*************************************************************************
00209                 Manipulators
00210         *************************************************************************/
00221         virtual void    initialise(void);
00222 
00223 
00235         void    setReadOnly(bool setting);
00236 
00237 
00249         void    setCaratIndex(ulong carat_pos);
00250 
00251 
00267         void    setSelection(ulong start_pos, ulong end_pos);
00268         
00269 
00280         void    setMaxTextLength(ulong max_len);
00281 
00282 
00293         void    setNormalTextColour(const colour& col);
00294 
00295 
00304         void    setSelectedTextColour(const colour& col);
00305 
00306 
00318         void    setNormalSelectBrushColour(const colour& col);
00319 
00320 
00332         void    setInactiveSelectBrushColour(const colour& col);
00333 
00334 
00339         void    ensureCaratIsVisible(void);
00340 
00341 
00353         void    setWordWrapping(bool setting);
00354 
00355 
00356         /*************************************************************************
00357                 Construction and Destruction
00358         *************************************************************************/
00363         MultiLineEditbox(const String& type, const String& name);
00364 
00365 
00370         virtual ~MultiLineEditbox(void);
00371 
00372 
00373 protected:
00374         /*************************************************************************
00375                 Implementation Methods (abstract)
00376         *************************************************************************/
00385         virtual Rect    getTextRenderArea(void) const           = 0;
00386 
00387 
00395         virtual Scrollbar*      createVertScrollbar(void) const         = 0;
00396  
00397 
00405         virtual Scrollbar*      createHorzScrollbar(void) const         = 0;
00406 
00407 
00415         virtual void    layoutComponentWidgets()        = 0;
00416 
00417 
00431         virtual void    renderEditboxBaseImagery(float z)               = 0;
00432 
00433 
00441         virtual void    renderCarat(float baseX, float baseY, const Rect& clipper)      = 0;
00442 
00443 
00444         /*************************************************************************
00445                 Implementation Methods
00446         *************************************************************************/
00451         void    addMultiLineEditboxEvents(void);
00452 
00453 
00458         void    renderTextLines(const Rect& dest_area, const Rect& clipper) const;
00459 
00460 
00465         void    formatText(void);
00466 
00467 
00478         uint    getNextTokenLength(const String& text, uint start_idx) const;
00479 
00480 
00491         virtual void    drawSelf(float z);
00492 
00493 
00498         void    configureScrollbars(void);
00499 
00500 
00511         uint    getTextIndexFromPosition(const Point& pt) const;
00512 
00513 
00519         uint    getLineNumberFromIndex(uint index) const;
00520 
00521 
00526         void    clearSelection(void);
00527 
00528 
00536         void    eraseSelectedText(bool modify_text = true);
00537 
00538 
00543         void    handleBackspace(void);
00544 
00545 
00550         void    handleDelete(void);
00551 
00552 
00557         void    handleCharLeft(uint sysKeys);
00558 
00559 
00564         void    handleWordLeft(uint sysKeys);
00565 
00566 
00571         void    handleCharRight(uint sysKeys);
00572 
00573 
00578         void    handleWordRight(uint sysKeys);
00579 
00580 
00585         void    handleDocHome(uint sysKeys);
00586 
00587 
00592         void    handleDocEnd(uint sysKeys);
00593 
00594 
00599         void    handleLineHome(uint sysKeys);
00600 
00601 
00606         void    handleLineEnd(uint sysKeys);
00607 
00608 
00613         void    handleLineUp(uint sysKeys);
00614 
00615 
00620         void    handleLineDown(uint sysKeys);
00621 
00622 
00627         void    handleNewLine(uint sysKeys);
00628 
00629 
00630         /*************************************************************************
00631                 New event handlers
00632         *************************************************************************/
00637         void    onReadOnlyChanged(WindowEventArgs& e);
00638 
00639 
00644         void    onWordWrapModeChanged(WindowEventArgs& e);
00645 
00646 
00651         void    onMaximumTextLengthChanged(WindowEventArgs& e);
00652 
00653 
00658         void    onCaratMoved(WindowEventArgs& e);
00659 
00660 
00665         void    onTextSelectionChanged(WindowEventArgs& e);
00666 
00667 
00672         void    onEditboxFullEvent(WindowEventArgs& e);
00673 
00674 
00679         void    onVertScrollbarModeChanged(WindowEventArgs& e);
00680 
00681 
00686         void    onHorzScrollbarModeChanged(WindowEventArgs& e);
00687 
00688 
00689         /*************************************************************************
00690                 Overridden event handlers
00691         *************************************************************************/
00692         virtual void    onMouseButtonDown(MouseEventArgs& e);
00693         virtual void    onMouseButtonUp(MouseEventArgs& e);
00694         virtual void    onMouseDoubleClicked(MouseEventArgs& e);
00695         virtual void    onMouseTripleClicked(MouseEventArgs& e);
00696         virtual void    onMouseMove(MouseEventArgs& e);
00697         virtual void    onCaptureLost(WindowEventArgs& e);
00698         virtual void    onCharacter(KeyEventArgs& e);
00699         virtual void    onKeyDown(KeyEventArgs& e);
00700         virtual void    onTextChanged(WindowEventArgs& e);
00701         virtual void    onSized(WindowEventArgs& e);
00702         virtual void    onMouseWheel(MouseEventArgs& e);
00703 
00704 
00705         /*************************************************************************
00706                 Implementation struct
00707         *************************************************************************/
00713         struct LineInfo
00714         {
00715                 ulong   d_startIdx;             
00716                 ulong   d_length;               
00717                 float   d_extent;               
00718         };
00719 
00720 
00721         /*************************************************************************
00722                 Implementation data
00723         *************************************************************************/
00724         bool    d_readOnly;                     
00725         ulong   d_maxTextLen;           
00726         ulong   d_caratPos;                     
00727         ulong   d_selectionStart;       
00728         ulong   d_selectionEnd;         
00729         bool    d_dragging;                     
00730         ulong   d_dragAnchorIdx;        
00731 
00732         typedef std::vector<LineInfo>   LineList;       
00733         static String d_lineBreakChars; 
00734         bool            d_wordWrap;                     
00735         LineList        d_lines;                        
00736         float           d_widestExtent;         
00737 
00738         // component widgets
00739         Scrollbar*      d_vertScrollbar;        
00740         Scrollbar*      d_horzScrollbar;        
00741         bool    d_forceVertScroll;              
00742         bool    d_forceHorzScroll;              
00743 
00744         // images
00745         const Image*    d_selectionBrush;       
00746 
00747         // basic rendering colours
00748         colour  d_normalTextColour;                             
00749         colour  d_selectTextColour;                             
00750         colour  d_selectBrushColour;                    
00751         colour  d_inactiveSelectBrushColour;    
00752 
00753 
00754 private:
00755         /*************************************************************************
00756                 Static Properties for this class
00757         *************************************************************************/
00758         static MultiLineEditboxProperties::ReadOnly                                     d_readOnlyProperty;
00759         static MultiLineEditboxProperties::WordWrap                                     d_wordWrapProperty;
00760         static MultiLineEditboxProperties::CaratIndex                           d_caratIndexProperty;
00761         static MultiLineEditboxProperties::SelectionStart                       d_selectionStartProperty;
00762         static MultiLineEditboxProperties::SelectionLength                      d_selectionLengthProperty;
00763         static MultiLineEditboxProperties::MaxTextLength                        d_maxTextLengthProperty;
00764         static MultiLineEditboxProperties::NormalTextColour                     d_normalTextColourProperty;
00765         static MultiLineEditboxProperties::SelectedTextColour           d_selectedTextColourProperty;
00766         static MultiLineEditboxProperties::ActiveSelectionColour        d_activeSelectionColourProperty;
00767         static MultiLineEditboxProperties::InactiveSelectionColour      d_inactiveSelectionColourProperty;
00768 
00769 
00770         /*************************************************************************
00771                 Private methods
00772         *************************************************************************/
00773         void    addMultiLineEditboxProperties(void);
00774 };
00775 
00776 } // End of  CEGUI namespace section
00777 
00778 #if defined(_MSC_VER)
00779 #       pragma warning(pop)
00780 #endif
00781 
00782 #endif  // end of guard _CEGUIMultiLineEditbox_h_

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