ladybird/LibGUI/GCheckBox.h
Andreas Kling b4da451c9a WindowServer+LibGUI: Implement automatic cursor tracking.
When a mouse button is pressed inside a window, put that window into an
automatic mouse tracking state where all mouse events are sent to that
window until all mouse buttons are released.

This might feel even better if it only cared about the mouse buttons you
actually pressed while *inside* the windows to get released, I don't know.
I'll have to use it for a while and see how it's like.
2019-03-24 15:01:56 +01:00

35 lines
942 B
C++

#pragma once
#include "GWidget.h"
#include <AK/AKString.h>
#include <AK/Function.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);
Function<void(GCheckBox&, bool)> on_change;
virtual const char* class_name() const override { return "GCheckBox"; }
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 bool accepts_focus() const override { return true; }
String m_caption;
bool m_checked { false };
bool m_being_modified { false };
};