#pragma once

#include "IPlatformWindow.h"
#include <Windows.h>

class Win32ApplicationContext;
class Win32DxWindowInterface;
class DesktopManager;
class DirectXInterface;

class Win32Window : public IPlatformWindow
{
public:
    Win32Window(mt::Window* window, DirectXInterface* dxInterface = nullptr);
    virtual ~Win32Window() = default;

    static std::unique_ptr<Win32Window> Create(mt::Window* window, DirectXInterface* dxInterface = nullptr);

    LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

    HWND getHandle() const;

    void setHandle(HWND handle)
    {
        mHandle = handle;
    }

    int getCmdShow() const
    {
        return mCmdShow;
    }

    void setCmdShow(int cmdShow)
    {
        mCmdShow = cmdShow;
    }

    void createNative(Win32ApplicationContext* context, DesktopManager* desktopManager);

    void show() {};

    void map() {};

    void clear() {};

    void onResize(unsigned width, unsigned height);

    void beforePaint(mt::Screen* screen);

    void afterPaint(mt::Screen* screen);

private:
    void onMouseDownMessage(int x, int y);

    void onMouseUpMessage(int x, int y);

    void onPaintMessage();

    HWND mHandle{ 0 };
    int mCmdShow{ 0 };
    DesktopManager* mDesktopManager{ nullptr };
    std::unique_ptr<Win32DxWindowInterface> mDxInterface;
};