/* 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. */ /** \file */ #pragma once #include NAMESPACE_BEGIN(nanogui) /** * \class CheckBox checkbox.h nanogui/checkbox.h * * \brief Two-state check box widget. */ 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) override; virtual Vector2i preferredSize(NVGcontext *ctx) const override; virtual void draw(NVGcontext *ctx) override; virtual void save(Serializer &s) const override; virtual bool load(Serializer &s) override; protected: std::string mCaption; bool mPushed, mChecked; std::function mCallback; }; NAMESPACE_END(nanogui)