00001 #ifndef CSTextfield_h 00002 #define CSTextfield_h 00003 00004 // USES SDL_Surface 00005 00006 #ifdef WIN32 00007 #pragma warning(disable : 4786 ) 00008 #endif 00009 00010 #include <vector> 00011 #include <string> 00012 00013 #include "CSGrafikElement.h" 00014 #include "CSLog.h" 00015 00016 class CSTextfield; 00017 typedef std::vector<CSTextfield *> CSTextfields; 00018 00019 class CSTextfield : public CSGrafikElement 00020 { 00021 private: 00022 GuiMessage MESSAGE_TEXT_CHANGED; 00023 std::string mString; 00024 std::string mWorkingString; 00025 init(const std::string &text); 00026 float mTickTimeNext; 00027 float mCursorRate; 00028 bool mCursorShown; 00029 00030 protected: 00031 virtual void layoutSetupTextfield(); 00032 public: 00033 CSTextfield(); 00034 CSTextfield(int width); 00035 CSTextfield(const std::string &string); 00036 virtual ~CSTextfield() {} 00037 static const char *CLASS; 00038 virtual std::string getType() {return (std::string) CLASS;} 00039 00040 void reactOnMessageTextField(CSMessage *message); 00041 virtual void reactOnMessage(CSMessage *message); 00042 00043 virtual void paint(SDL_Surface *destination, SDL_Rect *parentViewport); 00044 virtual void putString(SDL_Surface *destination, SDL_Rect *parentViewport, int x1, int y1, const std::string &string); 00045 virtual std::string getText() {return mString;} 00046 virtual void setText(std::string s) {mString = s;} 00047 virtual void layoutSetup() {layoutSetupTextfield();} 00048 }; 00049 00050 #endif // CSTextfield_h