CheckBox.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #ifndef UI_CHECKBOX_H
  24. #define UI_CHECKBOX_H
  25. #include "BorderImage.h"
  26. //! An image that can be toggled between unchecked and checked state
  27. class CheckBox : public BorderImage
  28. {
  29. DEFINE_TYPE(CheckBox);
  30. public:
  31. //! Construct with name
  32. CheckBox(const std::string& name = std::string());
  33. //! Destruct
  34. virtual ~CheckBox();
  35. //! Set UI element style from XML data
  36. virtual void setStyle(const XMLElement& element, ResourceCache* cache);
  37. //! Return UI rendering batches
  38. virtual void getBatches(std::vector<UIBatch>& batches, std::vector<UIQuad>& quads, const IntRect& currentScissor);
  39. //! React to mouse click
  40. virtual void onClick(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers);
  41. //! Set checked state
  42. void setChecked(bool enable);
  43. //! Set checked image offset
  44. void setCheckedOffset(const IntVector2& rect);
  45. //! Set checked image offset
  46. void setCheckedOffset(int x, int y);
  47. //! Return whether is checked
  48. bool isChecked() const { return mChecked; }
  49. //! Return checked image offset
  50. const IntVector2& getCheckedOffset() const { return mCheckedOffset; }
  51. protected:
  52. //! Checked image offset
  53. IntVector2 mCheckedOffset;
  54. //! Current checked state
  55. bool mChecked;
  56. };
  57. #endif // UI_CHECKBOX_H