diff options
author | crupest <crupest@outlook.com> | 2019-04-10 19:42:46 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-10 19:42:46 +0800 |
commit | 7351020a582d70a1495249fba87d342c8a1fb634 (patch) | |
tree | e80f225041dc3816b3dce21c7e15aadbb211602e /src/platform_win/window_manager.cpp | |
parent | a94a806f69586e08a30fff0cdb3e52b0ce7acfa5 (diff) | |
download | cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.gz cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.bz2 cru-7351020a582d70a1495249fba87d342c8a1fb634.zip |
Refactor.
Diffstat (limited to 'src/platform_win/window_manager.cpp')
-rw-r--r-- | src/platform_win/window_manager.cpp | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/src/platform_win/window_manager.cpp b/src/platform_win/window_manager.cpp deleted file mode 100644 index e6c255c3..00000000 --- a/src/platform_win/window_manager.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "window_manager.hpp" - -#include "cru/platform/win/win_application.hpp" -#include "cru/platform/win/win_native_window.hpp" -#include "cru/platform/win/window_class.hpp" - -#include <assert.h> - -namespace cru::platform::win { -LRESULT __stdcall GeneralWndProc(HWND hWnd, UINT Msg, WPARAM wParam, - LPARAM lParam) { - auto window = - WinApplication::GetInstance()->GetWindowManager()->FromHandle(hWnd); - - LRESULT result; - if (window != nullptr && - window->HandleNativeWindowMessage(hWnd, Msg, wParam, lParam, &result)) - return result; - - return DefWindowProc(hWnd, Msg, wParam, lParam); -} - -WindowManager::WindowManager(WinApplication* application) { - application_ = application; - general_window_class_ = std::make_shared<WindowClass>( - L"CruUIWindowClass", GeneralWndProc, application->GetInstanceHandle()); -} - -void WindowManager::RegisterWindow(HWND hwnd, WinNativeWindow* window) { - assert(window_map_.count(hwnd) == 0); // The hwnd is already in the map. - window_map_.emplace(hwnd, window); -} - -void WindowManager::UnregisterWindow(HWND hwnd) { - const auto find_result = window_map_.find(hwnd); - assert(find_result != window_map_.end()); // The hwnd is not in the map. - window_map_.erase(find_result); - if (window_map_.empty()) application_->Quit(0); -} - -WinNativeWindow* WindowManager::FromHandle(HWND hwnd) { - const auto find_result = window_map_.find(hwnd); - if (find_result == window_map_.end()) - return nullptr; - else - return find_result->second; -} - -std::vector<WinNativeWindow*> WindowManager::GetAllWindows() const { - std::vector<WinNativeWindow*> windows; - for (auto [key, value] : window_map_) windows.push_back(value); - return windows; -} -} // namespace cru::platform::win |