pm_switch.h 945 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * File : pm_switch.h
  3. * COPYRIGHT (C) 2012-2017, Shanghai Real-Thread Technology Co., Ltd
  4. *
  5. * Change Logs:
  6. * Date Author Notes
  7. * 2017-11-05 realthread the first version
  8. */
  9. #pragma once
  10. #include <pm_image.h>
  11. #include <pm_widget.h>
  12. #include <sigslot.h>
  13. namespace Persimmon
  14. {
  15. class Switch : public Widget
  16. {
  17. public:
  18. Switch(Image* on, Image* off, bool status = false);
  19. virtual ~Switch();
  20. bool getStatus()
  21. {
  22. return on;
  23. }
  24. void setStatus(bool on);
  25. virtual void render(struct rtgui_dc* dc, const Point &dcPoint = Point(),
  26. const Rect &srcRect = Rect(),
  27. RenderFlag flags = DrawNormal);
  28. virtual bool handleGestureEvent(struct rtgui_event_gesture *gev,
  29. const struct rtgui_gesture *gest);
  30. Signal<bool> changed;
  31. private:
  32. Image *image_on;
  33. Image *image_off;
  34. bool on;
  35. };
  36. }