ladybird/LibGUI/GButton.h

36 lines
1,010 B
C
Raw Normal View History

#pragma once
#include "GWidget.h"
#include <AK/AKString.h>
#include <AK/Function.h>
#include <SharedGraphics/GraphicsBitmap.h>
class GButton final : public GWidget {
public:
explicit GButton(GWidget* parent);
virtual ~GButton() override;
String caption() const { return m_caption; }
void set_caption(String&&);
void set_icon(RetainPtr<GraphicsBitmap>&& icon) { m_icon = move(icon); }
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
GraphicsBitmap* icon() { return m_icon.ptr(); }
Function<void(GButton&)> on_click;
private:
2019-01-21 00:46:08 +01:00
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
2019-01-20 08:16:02 +01:00
virtual const char* class_name() const override { return "GButton"; }
String m_caption;
RetainPtr<GraphicsBitmap> m_icon;
bool m_being_pressed { false };
bool m_tracking_cursor { false };
};