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.

29 lines
1012 B

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __SDL_SIMPLE_BUTTON_WIDGET_HEADER__
  2. #define __SDL_SIMPLE_BUTTON_WIDGET_HEADER__
  3. #include "../core/coreWidget.h"
  4. #include "../core/coreLabel.h"
  5. class classGUI_SDL;
  6. class sdlSimpleButtonWidget : public sdlCoreWidget {
  7. private:
  8. uint8_t m_bState;
  9. sdlLabel* m_pLabel;
  10. bool m_bToggleEnabled;
  11. bool m_bReadOnly;
  12. bool m_bUnderCursor;
  13. protected:
  14. virtual void drawBefore(SDL_Renderer* pRenderer);
  15. public:
  16. explicit sdlSimpleButtonWidget(CSTR text, int x, int y, int width, int height, sdlCoreWidget* pParent = NULL);
  17. ~sdlSimpleButtonWidget();
  18. virtual void dispatch(SDL_Event* pEvt);
  19. void setToggle(bool enable) { m_bToggleEnabled = enable; };
  20. void setReadOnly(bool a) { m_bReadOnly = a; };
  21. void setToggled(bool a) { if (m_bToggleEnabled && a) m_bState = 3; if (m_bToggleEnabled && !a) m_bState = 0; };
  22. /*emitters*/
  23. void (*Pushed)(void) = NULL;
  24. void (*Toggled)(void) = NULL;
  25. void (*UnToggled)(void) = NULL;
  26. friend classGUI_SDL;
  27. };
  28. #endif