2018-10-12 02:03:22 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Object.h"
|
|
|
|
#include "Rect.h"
|
2018-10-13 18:52:47 +03:00
|
|
|
#include <AK/String.h>
|
|
|
|
#include <AK/WeakPtr.h>
|
2018-10-12 02:03:22 +03:00
|
|
|
|
|
|
|
class Widget;
|
|
|
|
|
2018-10-12 02:26:20 +03:00
|
|
|
class Window final : public Object {
|
2018-10-12 02:03:22 +03:00
|
|
|
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&);
|
2018-10-14 02:23:01 +03:00
|
|
|
void setRectWithoutRepaint(const Rect& rect) { m_rect = rect; }
|
2018-10-12 02:03:22 +03:00
|
|
|
|
2018-10-12 03:24:05 +03:00
|
|
|
Point position() const { return m_rect.location(); }
|
|
|
|
void setPosition(const Point& position) { setRect({ position.x(), position.y(), width(), height() }); }
|
2018-10-14 02:23:01 +03:00
|
|
|
void setPositionWithoutRepaint(const Point& position) { setRectWithoutRepaint({ position.x(), position.y(), width(), height() }); }
|
2018-10-12 03:24:05 +03:00
|
|
|
|
2018-10-12 02:03:22 +03:00
|
|
|
Widget* mainWidget() { return m_mainWidget; }
|
|
|
|
const Widget* mainWidget() const { return m_mainWidget; }
|
|
|
|
|
|
|
|
void setMainWidget(Widget*);
|
|
|
|
|
2018-10-12 02:26:20 +03:00
|
|
|
virtual void event(Event&) override;
|
|
|
|
|
2018-10-12 13:18:59 +03:00
|
|
|
bool isBeingDragged() const { return m_isBeingDragged; }
|
|
|
|
void setIsBeingDragged(bool b) { m_isBeingDragged = b; }
|
|
|
|
|
2018-10-12 20:39:48 +03:00
|
|
|
void repaint();
|
|
|
|
|
2018-10-13 18:42:24 +03:00
|
|
|
bool isActive() const;
|
|
|
|
|
2018-10-13 18:52:47 +03:00
|
|
|
Widget* focusedWidget() { return m_focusedWidget.ptr(); }
|
2018-10-13 21:59:25 +03:00
|
|
|
const Widget* focusedWidget() const { return m_focusedWidget.ptr(); }
|
2018-10-13 18:52:47 +03:00
|
|
|
void setFocusedWidget(Widget*);
|
|
|
|
|
2018-10-14 02:23:01 +03:00
|
|
|
bool isVisible() const;
|
|
|
|
|
2018-10-14 01:21:42 +03:00
|
|
|
void close();
|
|
|
|
|
2018-10-12 02:03:22 +03:00
|
|
|
private:
|
|
|
|
String m_title;
|
|
|
|
Rect m_rect;
|
|
|
|
Widget* m_mainWidget { nullptr };
|
2018-10-12 13:18:59 +03:00
|
|
|
bool m_isBeingDragged { false };
|
2018-10-13 18:52:47 +03:00
|
|
|
|
|
|
|
WeakPtr<Widget> m_focusedWidget;
|
2018-10-12 02:03:22 +03:00
|
|
|
};
|
|
|
|
|