summaryrefslogtreecommitdiff
path: root/Widgets/Window.h
blob: 1bbe354eb10b0cc301084c2ab2679fc201fa1d5c (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
#pragma once

#include "Object.h"
#include "Rect.h"
#include "GraphicsBitmap.h"
#include <AK/AKString.h>
#include <AK/InlineLinkedList.h>

class Process;

class Window final : public Object, public InlineLinkedListNode<Window> {
public:
    Window(Process&, int window_id);
    virtual ~Window() override;

    int window_id() const { return m_window_id; }

    String title() const { return m_title; }
    void set_title(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 set_rect(const Rect&);
    void set_rect_without_repaint(const Rect& rect) { m_rect = rect; }

    Point position() const { return m_rect.location(); }
    void set_position_without_repaint(const Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }

    virtual void event(Event&) override;

    bool is_being_dragged() const { return m_is_being_dragged; }
    void set_is_being_dragged(bool b) { m_is_being_dragged = b; }

    bool is_visible() const;

    void close();

    GraphicsBitmap* backing() { return m_backing.ptr(); }

    // 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;
    bool m_is_being_dragged { false };

    RetainPtr<GraphicsBitmap> m_backing;
    Process& m_process;
    int m_window_id { -1 };
};