Fix windows compilation.
This commit is contained in:
parent
b45385e8c7
commit
b17ba8b3a7
23 changed files with 85 additions and 53 deletions
|
@ -2,18 +2,19 @@
|
|||
|
||||
#include <Windows.h>
|
||||
|
||||
Win32UIInterface::Win32UIInterface()
|
||||
: mWindowInterface(std::make_unique<Win32WindowInterface>())
|
||||
Win32UIInterface::Win32UIInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware)
|
||||
: AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware),
|
||||
mWindowInterface(std::make_unique<Win32WindowInterface>())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Win32UIInterface::Initialize(DesktopManager* desktopManager)
|
||||
void Win32UIInterface::initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Win32UIInterface::Loop(DesktopManager* desktopManager)
|
||||
void Win32UIInterface::loop()
|
||||
{
|
||||
// Run the message loop.
|
||||
MSG msg = { };
|
||||
|
@ -24,17 +25,17 @@ void Win32UIInterface::Loop(DesktopManager* desktopManager)
|
|||
}
|
||||
}
|
||||
|
||||
void Win32UIInterface::ShutDown()
|
||||
void Win32UIInterface::shutDown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Win32UIInterface::ShowWindow(mt::Window* window)
|
||||
void Win32UIInterface::showWindow(mt::Window* window)
|
||||
{
|
||||
mWindowInterface->Show(window);
|
||||
}
|
||||
|
||||
void Win32UIInterface::AddWindow(mt::Window* window, DesktopManager* desktopManager)
|
||||
void Win32UIInterface::addWindow(mt::Window* window)
|
||||
{
|
||||
mWindowInterface->Add(window, desktopManager);
|
||||
mWindowInterface->Add(window, mDesktopManager);
|
||||
}
|
|
@ -3,25 +3,26 @@
|
|||
#include "Window.h"
|
||||
|
||||
#include "Win32WindowInterface.h"
|
||||
#include "AbstractUiInterface.h"
|
||||
|
||||
class DesktopManager;
|
||||
|
||||
class Win32UIInterface
|
||||
class Win32UIInterface : public AbstractUIInterface
|
||||
{
|
||||
public:
|
||||
Win32UIInterface();
|
||||
Win32UIInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = false);
|
||||
|
||||
~Win32UIInterface() = default;
|
||||
|
||||
void Initialize(DesktopManager* desktopManager);
|
||||
void initialize() override;
|
||||
|
||||
void Loop(DesktopManager* desktopManager);
|
||||
void loop() override;
|
||||
|
||||
void ShutDown();
|
||||
void shutDown() override;
|
||||
|
||||
void ShowWindow(mt::Window* window);
|
||||
void showWindow(mt::Window* window) override;
|
||||
|
||||
void AddWindow(mt::Window* window, DesktopManager* desktopManager);
|
||||
void addWindow(mt::Window* window) override;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -11,14 +11,15 @@
|
|||
|
||||
LRESULT CALLBACK FreeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
Win32Window::Win32Window()
|
||||
Win32Window::Win32Window(mt::Window* window)
|
||||
: IPlatformWindow(window)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<Win32Window> Win32Window::Create()
|
||||
std::unique_ptr<Win32Window> Win32Window::Create(mt::Window* window)
|
||||
{
|
||||
return std::make_unique<Win32Window>();
|
||||
return std::make_unique<Win32Window>(window);
|
||||
}
|
||||
|
||||
HWND Win32Window::GetHandle() const
|
||||
|
@ -85,11 +86,11 @@ LRESULT CALLBACK Win32Window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa
|
|||
case WM_CHAR:
|
||||
{
|
||||
auto key_event = std::make_unique<KeyboardEvent>();
|
||||
key_event->SetAction(KeyboardEvent::Action::Pressed);
|
||||
key_event->setAction(KeyboardEvent::Action::Pressed);
|
||||
|
||||
auto keyChar = (wchar_t)wParam;
|
||||
key_event->SetKeyString(StringUtils::convert(std::wstring(1, keyChar)));
|
||||
mDesktopManager->OnUiEvent(std::move(key_event));
|
||||
key_event->setKeyString(StringUtils::convert(std::wstring(1, keyChar)));
|
||||
mDesktopManager->onUiEvent(std::move(key_event));
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
|
|
|
@ -9,10 +9,10 @@ class DesktopManager;
|
|||
class Win32Window : public IPlatformWindow
|
||||
{
|
||||
public:
|
||||
Win32Window();
|
||||
Win32Window(mt::Window* window);
|
||||
virtual ~Win32Window() = default;
|
||||
|
||||
static std::unique_ptr<Win32Window> Create();
|
||||
static std::unique_ptr<Win32Window> Create(mt::Window* window);
|
||||
|
||||
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
@ -35,6 +35,24 @@ public:
|
|||
|
||||
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:
|
||||
HWND mHandle{ 0 };
|
||||
int mCmdShow{ 0 };
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <Windows.h>
|
||||
|
||||
#include "DesktopManager.h"
|
||||
#include "DrawingContext.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
|
||||
|
@ -15,18 +16,18 @@ Win32WindowInterface::Win32WindowInterface()
|
|||
|
||||
void Win32WindowInterface::Show(mt::Window* window)
|
||||
{
|
||||
auto platformWindow = dynamic_cast<Win32Window*>(window->GetPlatformWindow());
|
||||
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)
|
||||
{
|
||||
auto context = dynamic_cast<Win32ApplicationContext*>(desktopManager->GetMainApp()->GetApplicationContext());
|
||||
auto context = dynamic_cast<Win32ApplicationContext*>(desktopManager->getMainApp()->GetApplicationContext());
|
||||
|
||||
auto win32_window = Win32Window::Create();
|
||||
auto win32_window = Win32Window::Create(window);
|
||||
win32_window->CreateNative(context, desktopManager);
|
||||
win32_window->SetCmdShow(context->nCmdShow);
|
||||
window->SetPlatformWindow(std::move(win32_window));
|
||||
window->setPlatformWindow(std::move(win32_window), nullptr, DrawingMode::GRAPH);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <memory>
|
||||
|
||||
class DesktopManager;
|
||||
class FontsManager;
|
||||
|
||||
class Win32ApplicationContext : public IApplicationContext
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue