00001 #ifndef CSListbox_h 00002 #define CSListbox_h 00003 00004 // USES SDL_Surface 00005 // USES SDL_Rect 00006 00007 #ifdef WIN32 00008 #pragma warning(disable : 4786 ) 00009 #endif 00010 00011 #include <vector> 00012 #include <string> 00013 00014 #include "CSMessage.h" 00015 #include "CSGrafikElement.h" 00016 #include "CSScrollbar.h" 00017 #include "CSLog.h" 00018 #include "CSStringlist.h" 00019 00020 #include "CSIcon.h" 00021 00022 class CSListbox; 00023 00024 class CSListbox : public CSGrafikElement 00025 { 00026 private: 00027 //void paintArea(SDL_Surface *destination, SDL_Rect *parentViewport); 00028 // void paintBorder(SDL_Surface *destination, SDL_Rect *parentViewport); 00029 CSStringlist mItems; 00030 CSScrollbar *mScrollbar; 00031 CSBorder *mSelectionBorder; 00032 00033 int mNumberOfElementsDisplayed; 00034 int mSelectedItem; 00035 int mStart; 00036 int mEnd; 00037 int mDisplayLength; // maximal displayable items in viewport (without scrolling) 00038 int mHoverSelection; 00039 CSInset mListInset; // Insert of Text from "mInsert" 00040 00041 protected: 00042 GuiMessage MESSAGE_LIST_ITEM_SELECTED; 00043 void layoutSetupListbox(); 00044 virtual void rebuildElement(); 00045 00046 public: 00047 CSListbox(int numberOfElementsDisplayed, int width); 00048 virtual ~CSListbox(); 00049 static const char *CLASS; 00050 virtual std::string getType() {return (std::string) CLASS;} 00051 00052 void initListbox(); 00053 virtual void paint(SDL_Surface *destination, SDL_Rect *parentViewport); 00054 void reactOnMessageListbox(CSMessage *message); 00055 virtual void reactOnMessage(CSMessage *message); 00056 virtual void setGrafikCursor(int x, int y); 00057 virtual void setItems(const CSStringlist &list) 00058 { 00059 mItems = list; 00060 layoutChanged(); 00061 } 00062 virtual CSStringlist getItems() {return mItems;} 00063 virtual int getSelected() {return mSelectedItem;} 00064 virtual void setSelected(int i); 00065 virtual void setHoverSelection(bool b) {mHoverSelection = b;} 00066 virtual void setItemsShown(int numberOfElementsDisplayed); 00067 virtual void layoutSetup() {layoutSetupListbox();} 00068 }; 00069 00070 #endif // CSListbox_h