#include "Win32WindowInterface.h"

#include "Win32Window.h"
#include "DesktopManager.h"
#include "DrawingContext.h"
#include "DirectXInterface.h"
#include "Widget.h"

#include "FileLogger.h"

#include <Windows.h>

Win32WindowInterface::Win32WindowInterface()
{

}

void Win32WindowInterface::show(mt::Window* window)
{
    auto platformWindow = dynamic_cast<Win32Window*>(window->getPlatformWindow());
    MLOG_INFO("Showing platform window: " << platformWindow->getHandle());
    ::ShowWindow(platformWindow->getHandle(), platformWindow->getCmdShow());
}

void Win32WindowInterface::add(mt::Window* window, DesktopManager* desktopManager, DirectXInterface* dxInterface)
{
    auto context = dynamic_cast<Win32ApplicationContext*>(desktopManager->getMainApp()->GetApplicationContext());

    auto win32_window = Win32Window::Create(window, dxInterface);
    win32_window->createNative(context, desktopManager);
    win32_window->setCmdShow(context->nCmdShow);
    window->setPlatformWindow(std::move(win32_window));

    window->getPlatformWindow()->beforePaint(nullptr);
}

