CheckBox.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../UI/BorderImage.h"
  5. namespace Urho3D
  6. {
  7. /// %UI element that can be toggled between unchecked and checked state.
  8. class URHO3D_API CheckBox : public BorderImage
  9. {
  10. URHO3D_OBJECT(CheckBox, BorderImage);
  11. public:
  12. /// Construct.
  13. explicit CheckBox(Context* context);
  14. /// Destruct.
  15. ~CheckBox() override;
  16. /// Register object factory.
  17. /// @nobind
  18. static void RegisterObject(Context* context);
  19. /// Return UI rendering batches.
  20. void GetBatches(Vector<UIBatch>& batches, Vector<float>& vertexData, const IntRect& currentScissor) override;
  21. /// React to mouse click begin.
  22. void OnClickBegin
  23. (const IntVector2& position, const IntVector2& screenPosition, MouseButton button, MouseButtonFlags buttons, QualifierFlags qualifiers, Cursor* cursor) override;
  24. /// React to a key press.
  25. void OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifiers) override;
  26. /// Set checked state.
  27. /// @property
  28. void SetChecked(bool enable);
  29. /// Set checked image offset.
  30. /// @property
  31. void SetCheckedOffset(const IntVector2& offset);
  32. /// Set checked image offset.
  33. void SetCheckedOffset(int x, int y);
  34. /// Return whether is checked.
  35. /// @property
  36. bool IsChecked() const { return checked_; }
  37. /// Return checked image offset.
  38. /// @property
  39. const IntVector2& GetCheckedOffset() const { return checkedOffset_; }
  40. protected:
  41. /// Checked image offset.
  42. IntVector2 checkedOffset_;
  43. /// Current checked state.
  44. bool checked_;
  45. };
  46. }