You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SDL_SCROLLING_LIST_WIDGET_HEADER__
  2. #define __SDL_SCROLLING_LIST_WIDGET_HEADER__
  3. #include "../gui_sdl.h"
  4. #include "../core/coreWidget.h"
  5. #include "../core/coreLabel.h"
  6. #define WHEEL_MOVES_LINE
  7. //#ifdef WHEEL_REVERSE_CONTROLL
  8. class ScrollListItem: public sdlLabel{
  9. private:
  10. bool m_bSelected;
  11. public:
  12. explicit ScrollListItem(CSTR text, int fontSize = 10 );
  13. virtual ~ScrollListItem();
  14. void setSelected(bool a);
  15. };
  16. typedef std::vector<ScrollListItem*> vectorListItems;
  17. class sdlScrollListWidget : public sdlCoreWidget {
  18. private:
  19. int m_nFontSize;
  20. int m_nLineSize;
  21. vectorListItems m_vLines;
  22. bool m_bHScroll;
  23. bool m_bVScroll;
  24. bool m_bUnderCursor;
  25. int m_nXOffset;
  26. int m_nYOffset;
  27. int m_nContentX;
  28. int m_nContentY;
  29. int m_nSelectedID;
  30. int m_nPreSelectedID;
  31. CSTR m_pFillParameter;
  32. protected:
  33. virtual bool create(void);
  34. virtual void dispatch(SDL_Event* pEvt);
  35. virtual void drawBefore(SDL_Renderer* pRenderer);
  36. virtual void drawAfter(SDL_Renderer* pRenderer);
  37. public:
  38. sdlScrollListWidget(int x, int y, int w, int h, int fontsize, bool deco, sdlCoreWidget *pPtr = NULL);
  39. ~sdlScrollListWidget();
  40. int addItem(ScrollListItem *ptr);
  41. int addItem(CSTR text);
  42. virtual void selectItem(int index);
  43. int getSelectedIndex();
  44. ScrollListItem * getSelectedItem();
  45. ScrollListItem * getItem(int index);
  46. void setParamPtr(CSTR ptr);
  47. };
  48. #endif