#pragma once #include "DrawingSurface.h" #include #include #include #include #include class PaintEvent; class MouseEvent; class KeyboardEvent; class DrawingContext; class FontsManager; enum class DrawingMode; class Widget; using WidgetPtr = std::unique_ptr; class IPlatformWindow; using IPlatformWindowPtr = std::unique_ptr; namespace mt { class Screen; class Window : public DrawingSurface { public: using onPopupFunc = std::function popup)>; Window(); ~Window(); static std::unique_ptr Create(); void setWidget(WidgetPtr widget); void onPaint(const PaintEvent* event); void onMouseEvent(const MouseEvent* event); void onKeyboardEvent(const KeyboardEvent* event); IPlatformWindow* getPlatformWindow() const; void setPlatformWindow(IPlatformWindowPtr window, FontsManager* fontsManager, DrawingMode drawingMode); void map(); void show(); void doPaint(mt::Screen* screen); void clear(); void clearPlatformWindow(); void setSize(unsigned width, unsigned height) override; bool isDirty() const; void setTitle(const std::string& title) { mTitle = title; } const std::string& getTitle() const { return mTitle; } void addPopup(std::unique_ptr popupWidget) { if (mPopupFunc) { mPopupFunc(this, std::move(popupWidget)); } } void setPopupHandler(onPopupFunc func) { mPopupFunc = func; } void setParent(Window* parent) { mParent = parent; } Window* getParent() const { return mParent; } DrawingContext* getDrawingContent() const; private: WidgetPtr mWidget {nullptr}; std::string mTitle; IPlatformWindowPtr mPlatformWindow {nullptr}; std::unique_ptr mDrawingContext; onPopupFunc mPopupFunc; Window* mParent{nullptr}; }; } using WindowUPtr = std::unique_ptr;