/* nanogui/checkbox.h -- Two-state check box widget NanoGUI was developed by Wenzel Jakob . The widget drawing code is based on the NanoVG demo application by Mikko Mononen. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.txt file. */ #pragma once #include NAMESPACE_BEGIN(nanogui) class NANOGUI_EXPORT CheckBox : public Widget { public: CheckBox(Widget *parent, const std::string &caption = "Untitled", const std::function &callback = std::function()); const std::string &caption() const { return mCaption; } void setCaption(const std::string &caption) { mCaption = caption; } const bool &checked() const { return mChecked; } void setChecked(const bool &checked) { mChecked = checked; } const bool &pushed() const { return mPushed; } void setPushed(const bool &pushed) { mPushed = pushed; } std::function callback() const { return mCallback; } void setCallback(const std::function &callback) { mCallback = callback; } virtual bool mouseButtonEvent(const Vector2i &p, int button, bool down, int modifiers); virtual Vector2i preferredSize(NVGcontext *ctx) const; virtual void draw(NVGcontext *ctx); virtual void save(Serializer &s) const; virtual bool load(Serializer &s); protected: std::string mCaption; bool mPushed, mChecked; std::function mCallback; }; NAMESPACE_END(nanogui)