00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SCROLLING_LIST_H
00019 #define SCROLLING_LIST_H
00020
00021 #include "../constants.h"
00022 #include "widget.h"
00023 #include "button.h"
00024 #include "window.h"
00025 #include "draganddrop.h"
00026
00031 class ScrollingList : public Widget {
00032 protected:
00033 int count;
00034 const char **list;
00035 const Color *colors;
00036 const GLuint *icons;
00037 int value;
00038 int scrollerWidth, scrollerHeight;
00039 int listHeight;
00040 float alpha, alphaInc;
00041 GLint lastTick;
00042 bool inside;
00043 int scrollerY;
00044 bool dragging;
00045 int dragX, dragY;
00046 int selectedLine;
00047 DragAndDropHandler *dragAndDropHandler;
00048 bool innerDrag;
00049 int innerDragX, innerDragY;
00050 bool highlightBorders;
00051 GLuint highlight;
00052 bool canGetFocusVar;
00053 int lineHeight;
00054 int eventType;
00055
00056 public:
00057
00058 enum {
00059 EVENT_DRAG=0,
00060 EVENT_ACTION
00061 };
00062
00063 bool debug;
00064
00065 ScrollingList(int x, int y, int w, int h, GLuint highlight, DragAndDropHandler *dragAndDropHandler = NULL, int lineHeight=15);
00066 virtual ~ScrollingList();
00067
00068 inline int getLineCount() { return count; }
00069 void setLines(int count, const char *s[], const Color *colors=NULL, const GLuint *icon=NULL);
00070 inline const char *getLine(int index) { return list[index]; }
00071
00072 inline int getSelectedLine() { return selectedLine; }
00073 void setSelectedLine(int n);
00074
00075 void drawWidget(Widget *parent);
00076
00077 inline int getEventType() { return eventType; }
00078
00084 bool handleEvent(Widget *parent, SDL_Event *event, int x, int y);
00085
00086 void removeEffects(Widget *parent);
00087
00088
00089 virtual inline bool hasSound() { return false; }
00090
00091 inline bool canGetFocus() { return canGetFocusVar; }
00092 inline void setCanGetFocus(bool b) { this->canGetFocusVar = b; }
00093
00094 private:
00095 void selectLine(int x, int y);
00096 void drawIcon( int x, int y, GLuint icon );
00097 };
00098
00099 #endif
00100