mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibGUI: Add a GRadioButton widget.
Radio buttons are automagically exclusive with other radio button children of the same parent. :^)
This commit is contained in:
parent
00075b1c8a
commit
36d8b9e89b
8 changed files with 157 additions and 0 deletions
32
LibGUI/GRadioButton.h
Normal file
32
LibGUI/GRadioButton.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class GRadioButton : public GWidget {
|
||||
public:
|
||||
GRadioButton(const String& label, GWidget* parent);
|
||||
virtual ~GRadioButton() override;
|
||||
|
||||
void set_label(const String&);
|
||||
String label() const { return m_label; }
|
||||
|
||||
bool is_checked() const { return m_checked; }
|
||||
void set_checked(bool);
|
||||
|
||||
protected:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
|
||||
private:
|
||||
virtual bool is_radio_button() const final { return true; }
|
||||
|
||||
template<typename Callback> void for_each_in_group(Callback);
|
||||
static Size circle_size();
|
||||
|
||||
String m_label;
|
||||
bool m_checked { false };
|
||||
bool m_changing { false };
|
||||
bool m_tracking { false };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue