2019-04-04 01:44:35 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-05-28 11:53:16 +02:00
|
|
|
#include "WindowIdentifier.h"
|
2019-09-06 15:34:26 +02:00
|
|
|
#include <AK/String.h>
|
2019-04-04 01:44:35 +02:00
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <LibGUI/GButton.h>
|
2019-07-18 10:15:00 +02:00
|
|
|
#include <LibDraw/Rect.h>
|
2019-04-04 01:44:35 +02:00
|
|
|
|
|
|
|
class Window {
|
|
|
|
public:
|
|
|
|
explicit Window(const WindowIdentifier& identifier)
|
|
|
|
: m_identifier(identifier)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~Window()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowIdentifier identifier() const { return m_identifier; }
|
|
|
|
|
|
|
|
String title() const { return m_title; }
|
|
|
|
void set_title(const String& title) { m_title = title; }
|
|
|
|
|
|
|
|
Rect rect() const { return m_rect; }
|
|
|
|
void set_rect(const Rect& rect) { m_rect = rect; }
|
|
|
|
|
|
|
|
GButton* button() { return m_button; }
|
|
|
|
void set_button(GButton* button) { m_button = button; }
|
|
|
|
|
2019-04-04 13:19:26 +02:00
|
|
|
void set_active(bool active) { m_active = active; }
|
|
|
|
bool is_active() const { return m_active; }
|
|
|
|
|
2019-04-06 00:57:51 +02:00
|
|
|
void set_minimized(bool minimized) { m_minimized = minimized; }
|
|
|
|
bool is_minimized() const { return m_minimized; }
|
|
|
|
|
2019-04-13 16:59:55 +02:00
|
|
|
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
|
|
|
|
2019-04-04 01:44:35 +02:00
|
|
|
private:
|
|
|
|
WindowIdentifier m_identifier;
|
|
|
|
String m_title;
|
|
|
|
Rect m_rect;
|
2019-09-22 00:17:53 +02:00
|
|
|
RefPtr<GButton> m_button;
|
2019-06-21 18:37:47 +02:00
|
|
|
RefPtr<GraphicsBitmap> m_icon;
|
2019-04-04 13:19:26 +02:00
|
|
|
bool m_active { false };
|
2019-04-06 00:57:51 +02:00
|
|
|
bool m_minimized { false };
|
2019-04-04 01:44:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class WindowList {
|
|
|
|
public:
|
2019-04-23 23:14:14 +02:00
|
|
|
static WindowList& the();
|
|
|
|
|
2019-05-28 11:53:16 +02:00
|
|
|
template<typename Callback>
|
|
|
|
void for_each_window(Callback callback)
|
2019-04-04 01:44:35 +02:00
|
|
|
{
|
|
|
|
for (auto& it : m_windows)
|
|
|
|
callback(*it.value);
|
|
|
|
}
|
|
|
|
|
2019-04-18 00:39:11 +02:00
|
|
|
Window* window(const WindowIdentifier&);
|
2019-04-04 01:44:35 +02:00
|
|
|
Window& ensure_window(const WindowIdentifier&);
|
|
|
|
void remove_window(const WindowIdentifier&);
|
|
|
|
|
2019-09-22 00:17:53 +02:00
|
|
|
Function<NonnullRefPtr<GButton>(const WindowIdentifier&)> aid_create_button;
|
2019-04-04 13:19:26 +02:00
|
|
|
|
2019-04-04 01:44:35 +02:00
|
|
|
private:
|
2019-07-24 08:42:55 +02:00
|
|
|
HashMap<WindowIdentifier, NonnullOwnPtr<Window>> m_windows;
|
2019-04-04 01:44:35 +02:00
|
|
|
};
|