![[]](/images/special/trans.gif)
LibN2L-4 Library Code ReferenceClassesCompounds Files Members Method Index Full Reference cGuiTextInput.hGo to the documentation of this file.00001 /************************************************************************ 00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library 00003 Copyright (C) 2002 Aaron Cameron 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 A copy of the GNU Lesser General Public License has been provided with 00020 this library in the file 'COPYING'. 00021 00022 Contact information for the author of this library has been provided 00023 with this library in the file 'AUTHOR'. 00024 ************************************************************************/ 00025 #ifndef _n2l4_cGuiTextInput_H 00026 #define _n2l4_cGuiTextInput_H 00027 00028 #include "n2l/n2l.h" 00029 00030 #include "gui/cGuiInteractive.h" 00031 #include "gui/cGuiTextStyle.h" 00032 #include "gui/cGuiFill.h" 00033 #include "gui/types.h" 00034 00035 /******************************************************************************/ 00036 namespace n2l 00037 { 00038 class cVfsNodeInterface; 00039 class cDynVar; 00040 class cAudioChunk; 00041 class cGLTexture; 00042 class cFontInterface; 00043 00046 class cGuiTextInput : public cGuiInteractive 00047 { 00048 public: 00049 typedef tString tValue; 00050 00051 typedef const tBool (*tValValFunc)( const tValue &iVal ); 00052 00053 typedef enum { 00054 State_Normal, 00055 State_Focused, 00056 00057 State_NumStates 00058 } tState; 00059 00060 typedef enum { 00061 Prop_Background, 00062 Prop_Text, 00063 Prop_Cursor, 00064 00065 Prop_NumProps 00066 } tProp; 00067 00068 cGuiTextInput(); 00069 cGuiTextInput( const cVfsNodeInterface & iNode ); 00070 cGuiTextInput( const cDynVar & iDefinition ); 00071 00072 virtual ~cGuiTextInput(); 00073 00074 virtual void load( const cVfsNodeInterface & iNode ); 00075 virtual void load( const cDynVar & iDefinition ); 00076 00077 virtual void fill( const tState &iState, const tProp &iProp, 00078 const cGuiFill &iFill ); 00079 00080 virtual void textStyle( const tState &iState, 00081 const cGuiTextStyle &iStyle ); 00082 00083 virtual void draw() const; 00084 00085 virtual void valValFunc( const tValValFunc &iFunc ); 00086 00087 virtual void value( const tValue & iValue ); 00088 virtual const tValue & value() const; 00089 00090 virtual const tBool wantsFocus() const; 00091 00092 virtual const cAutoPtr<cGuiElement> clone() const; 00093 00094 protected: 00095 void dimensionChanged(); 00096 00097 virtual void cloneInto( 00098 const cAutoPtr<cGuiTextInput> &i_ioElement ) const; 00099 00100 private: 00101 00102 tValue mValue; 00103 tUint mCursor; 00104 00105 tUint mFirstCharIndex; 00106 tUint mEndCharIndex; 00107 00108 tValValFunc mValValFunc; 00109 00110 cGuiTextStyle mTextStyle[State_NumStates]; 00111 cGuiFill mFill[State_NumStates][Prop_NumProps]; 00112 00113 # ifdef N2L_PASSIVE_GUI_REG 00114 static tBool smRegistered; 00115 # endif 00116 00117 void init(); 00118 00119 virtual void processKey( const tKey &iKey, const tKeyMods &iMods ); 00120 00121 void calculatePropPositions(); 00122 00123 static void focusChangeCallback( cGuiElement * const i_ioElement, 00124 const tGuiActionType iType, const tActionData & iData ); 00125 00126 static void clickedCallback( cGuiElement * const i_ioElement, 00127 const tGuiActionType iType, const tActionData & iData ); 00128 00129 static void keystrokeCallback( cGuiElement * const i_ioElement, 00130 const tGuiActionType iType, const tActionData & iData ); 00131 00132 void boundCheckState( const tState &iState, 00133 const tString &iFrom ); 00134 void boundCheckProp( const tProp &iProp, 00135 const tString &iFrom ); 00136 00137 }; // class 00138 00139 } // namespace n2l 00140 00141 #endif |