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

TextEntry.h

00001 00002 00003 #ifndef MOD_TEXTENTRY_H 00004 #define MOD_TEXTENTRY_H 00005 00006 //Licence: LGPL 00007 //Copyright: Visti Andresen 00008 00009 #include <string> 00010 #include "MenuItem.h" 00011 #include "Font.h" 00012 00013 /**A menu item that allows the user to enter a text string. 00014 The text value is saved along with the TextEntry when save is called. */ 00015 class TextEntry : public MenuItem 00016 { 00017 public: 00018 /**Defines the type of TextEntry*/ 00019 enum TextEntryType { 00020 NORMAL ///Normal TextEntry with both uppercase and lowercase letters. 00021 ,UPPERCASE ///Uppercase only TextEntry. 00022 ,LOWERCASE ///Lowercase only TextEntry. 00023 }; 00024 /**Constructor 00025 00026 lable is the name the user can see on screen. 00027 00028 name is the name of the TextEntry in the config file. 00029 00030 font is the Font to use when rendering. 00031 00032 type is the type of the TextEntry. 00033 00034 defaultValue is the value to use if no entry is found in the config file 00035 or the config file is't loaded. 00036 00037 maxLength is the maximal length of the text the user can enter, 0 for 00038 unlimited. 00039 Currently only 0 is implemented. 00040 */ 00041 TextEntry(const string &label, const string &name, Font *font, 00042 TextEntryType type = NORMAL, const string &defaultValue="", 00043 int maxLength_=0); 00044 ~TextEntry(); 00045 void load(ifstream &file); 00046 void save(ofstream &file); 00047 void draw(float x, float y, float zoom); 00048 Type getType(){return CONTROL;} 00049 float getWidth(float zoom); 00050 float getHeight(float zoom); 00051 string &getName(){return name_;} 00052 /**Returns the text string that the user has typed in the TextEntry.*/ 00053 string &getValue(){return value_;} 00054 bool handleKeyEvent(SDL_Event *event); 00055 private: 00056 string getVisualString(); 00057 00058 string value_; 00059 TextEntryType type_; 00060 bool grabbingKey_; 00061 int maxLength_; 00062 00063 Font *font_; 00064 string label_; 00065 string name_; 00066 }; 00067 00068 #endif

Generated on Wed Sep 1 14:46:57 2004 by doxygen 1.3.7