2018-10-11 01:48:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Widget.h"
|
2018-12-21 02:18:16 +01:00
|
|
|
#include <AK/AKString.h>
|
2019-01-09 02:06:04 +01:00
|
|
|
#include <AK/Function.h>
|
2018-10-11 01:48:09 +02:00
|
|
|
|
|
|
|
class Button final : public Widget {
|
|
|
|
public:
|
|
|
|
explicit Button(Widget* parent);
|
|
|
|
virtual ~Button() override;
|
|
|
|
|
|
|
|
String caption() const { return m_caption; }
|
|
|
|
void setCaption(String&&);
|
|
|
|
|
2019-01-09 02:06:04 +01:00
|
|
|
Function<void(Button&)> onClick;
|
2018-10-13 23:01:06 +02:00
|
|
|
|
2018-10-11 01:48:09 +02:00
|
|
|
private:
|
2018-10-13 22:51:50 +02:00
|
|
|
virtual void paintEvent(PaintEvent&) override;
|
|
|
|
virtual void mouseDownEvent(MouseEvent&) override;
|
|
|
|
virtual void mouseUpEvent(MouseEvent&) override;
|
2018-10-11 01:48:09 +02:00
|
|
|
|
2018-11-15 15:36:35 +01:00
|
|
|
virtual const char* class_name() const override { return "Button"; }
|
2018-10-11 01:48:09 +02:00
|
|
|
|
|
|
|
String m_caption;
|
2018-10-12 15:52:41 +02:00
|
|
|
bool m_beingPressed { false };
|
2018-10-11 01:48:09 +02:00
|
|
|
};
|
|
|
|
|