2019-01-20 03:49:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
#include <AK/Weakable.h>
|
|
|
|
|
|
|
|
class GEvent;
|
2019-03-15 15:12:06 +00:00
|
|
|
class GChildEvent;
|
2019-01-20 03:49:48 +00:00
|
|
|
class GTimerEvent;
|
|
|
|
|
|
|
|
class GObject : public Weakable<GObject> {
|
|
|
|
public:
|
|
|
|
GObject(GObject* parent = nullptr);
|
|
|
|
virtual ~GObject();
|
|
|
|
|
|
|
|
virtual const char* class_name() const { return "GObject"; }
|
|
|
|
|
|
|
|
virtual void event(GEvent&);
|
|
|
|
|
|
|
|
Vector<GObject*>& children() { return m_children; }
|
|
|
|
|
|
|
|
GObject* parent() { return m_parent; }
|
|
|
|
const GObject* parent() const { return m_parent; }
|
|
|
|
|
2019-01-31 16:31:23 +00:00
|
|
|
void start_timer(int ms);
|
|
|
|
void stop_timer();
|
|
|
|
bool has_timer() const { return m_timer_id; }
|
2019-01-20 03:49:48 +00:00
|
|
|
|
2019-01-31 16:31:23 +00:00
|
|
|
void add_child(GObject&);
|
|
|
|
void remove_child(GObject&);
|
2019-01-20 03:49:48 +00:00
|
|
|
|
2019-01-30 19:03:52 +00:00
|
|
|
void delete_later();
|
2019-01-20 03:49:48 +00:00
|
|
|
|
2019-03-15 15:12:06 +00:00
|
|
|
virtual bool is_widget() const { return false; }
|
|
|
|
|
|
|
|
protected:
|
2019-01-31 15:37:43 +00:00
|
|
|
virtual void timer_event(GTimerEvent&);
|
2019-03-15 15:12:06 +00:00
|
|
|
virtual void child_event(GChildEvent&);
|
2019-01-20 03:49:48 +00:00
|
|
|
|
2019-03-15 15:12:06 +00:00
|
|
|
private:
|
2019-01-20 03:49:48 +00:00
|
|
|
GObject* m_parent { nullptr };
|
2019-01-31 16:31:23 +00:00
|
|
|
int m_timer_id { 0 };
|
2019-01-20 03:49:48 +00:00
|
|
|
Vector<GObject*> m_children;
|
|
|
|
};
|