blob: 4a6199008498c30948e6d39698e057d7d1530bf6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include <AK/Function.h>
#include <AK/Vector.h>
#include <AK/Weakable.h>
class GEvent;
class GChildEvent;
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; }
void start_timer(int ms);
void stop_timer();
bool has_timer() const { return m_timer_id; }
void add_child(GObject&);
void remove_child(GObject&);
void delete_later();
void dump_tree(int indent = 0);
void deferred_invoke(Function<void(GObject&)>);
virtual bool is_widget() const { return false; }
virtual bool is_window() const { return false; }
protected:
virtual void timer_event(GTimerEvent&);
virtual void child_event(GChildEvent&);
private:
GObject* m_parent { nullptr };
int m_timer_id { 0 };
Vector<GObject*> m_children;
};
|