00001 #ifndef CSCombobox_h 00002 #define CSCombobox_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 "CSMessage.h" 00015 #include "CSLog.h" 00016 #include "CSStringlist.h" 00017 00018 class CSCombobox; 00019 class CSTextfield; 00020 class CSButton; 00021 class CSListbox; 00022 typedef std::vector<CSCombobox *> CSComboboxs; 00023 00024 class CSCombobox : public CSGrafikElement 00025 { 00026 private: 00027 std::string mString; 00028 std::string mWorkingString; 00029 float mTickTimeNext; 00030 float mCursorRate; 00031 bool mCursorShown; 00032 00033 CSInset mComboBoxInset; // Insert of "Textfield" from mInsert 00034 00035 CSTextfield *mTextfield; 00036 CSButton *mMore; 00037 CSListbox *mListbox; 00038 bool mListboxActive; 00039 bool mIsEditable; 00040 bool mIsEditing; 00041 int mTextOffset; 00042 00043 void init(const std::string &text); 00044 void setListActive(bool active); 00045 00046 00047 protected: 00048 GuiMessage MESSAGE_COMBOBOX_ITEM_SELECTED; 00049 void layoutSetupCombobox(); 00050 void rebuildElement(); 00051 00052 public: 00053 CSCombobox(int witdh); 00054 virtual ~CSCombobox(); 00055 static const char *CLASS; 00056 virtual std::string getType() {return (std::string) CLASS;} 00057 00058 void reactOnMessageCombobox(CSMessage *message); 00059 virtual void reactOnMessage(CSMessage *message); 00060 00061 virtual void paint(SDL_Surface *destination, SDL_Rect *parentViewport); 00062 virtual void putString(SDL_Surface *destination, SDL_Rect *parentViewport, int x1, int y1, const std::string &string); 00063 virtual void setItems(const CSStringlist &list); 00064 virtual CSStringlist getItems(); 00065 virtual std::string getSelectedString(); 00066 virtual void setEditable(bool e) {mIsEditable = e;} 00067 virtual void *getSelectedObject(); 00068 virtual void setSelected(const std::string &text) {mString = text;} 00069 virtual void setSelected(int i); 00070 virtual void layoutSetup() {layoutSetupCombobox();} 00071 }; 00072 00073 #endif // CSCombobox_h