blob: be53f0fccc31838097b2432dccb3ab764353ca64 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#pragma once
#include "Object.h"
#include "Rect.h"
#include "GraphicsBitmap.h"
#include <AK/AKString.h>
#include <AK/InlineLinkedList.h>
#include <AK/WeakPtr.h>
class Widget;
class Window final : public Object, public InlineLinkedListNode<Window> {
public:
explicit Window(Object* parent = nullptr);
virtual ~Window() override;
String title() const { return m_title; }
void setTitle(String&&);
int x() const { return m_rect.x(); }
int y() const { return m_rect.y(); }
int width() const { return m_rect.width(); }
int height() const { return m_rect.height(); }
const Rect& rect() const { return m_rect; }
void setRect(const Rect&);
void setRectWithoutRepaint(const Rect& rect) { m_rect = rect; }
Point position() const { return m_rect.location(); }
void setPosition(const Point& position) { setRect({ position.x(), position.y(), width(), height() }); }
void setPositionWithoutRepaint(const Point& position) { setRectWithoutRepaint({ position.x(), position.y(), width(), height() }); }
Widget* mainWidget() { return m_mainWidget; }
const Widget* mainWidget() const { return m_mainWidget; }
void setMainWidget(Widget*);
virtual void event(Event&) override;
bool isBeingDragged() const { return m_isBeingDragged; }
void setIsBeingDragged(bool b) { m_isBeingDragged = b; }
void repaint(const Rect& = Rect());
void update(const Rect& = Rect());
bool isActive() const;
Widget* focusedWidget() { return m_focusedWidget.ptr(); }
const Widget* focusedWidget() const { return m_focusedWidget.ptr(); }
void setFocusedWidget(Widget*);
bool isVisible() const;
void close();
GraphicsBitmap* backing() { return m_backing.ptr(); }
void did_paint();
// For InlineLinkedList.
// FIXME: Maybe make a ListHashSet and then WindowManager can just use that.
Window* m_next { nullptr };
Window* m_prev { nullptr };
private:
String m_title;
Rect m_rect;
Widget* m_mainWidget { nullptr };
bool m_isBeingDragged { false };
WeakPtr<Widget> m_focusedWidget;
RetainPtr<GraphicsBitmap> m_backing;
};
|