ladybird/LibGUI/GCheckBox.h
Andreas Kling 35c06f1520 LibGUI: More work on GCheckBox.
- Make it track the mouse cursor just like GButton does so that changes only
  get committed if the mouseup event happens while inside the widget rect.

- Draw a focus rect around the box when appropriate.

- When focused, support toggling the checked state with the space bar.
2019-01-27 20:22:06 +01:00

32 lines
905 B
C++

#pragma once
#include "GWidget.h"
#include <AK/AKString.h>
class GCheckBox final : public GWidget {
public:
explicit GCheckBox(GWidget* parent);
virtual ~GCheckBox() override;
String caption() const { return m_caption; }
void set_caption(String&&);
bool is_checked() const { return m_checked; }
void set_checked(bool);
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual const char* class_name() const override { return "GCheckBox"; }
virtual bool accepts_focus() const override { return true; }
String m_caption;
bool m_checked { false };
bool m_being_modified { false };
bool m_tracking_cursor { false };
};