Lugdunum  0.1.0
WindowImplWin32.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef WIN32_LEAN_AND_MEAN
4  #define WIN32_LEAN_AND_MEAN
5 #endif
6 #define NOMINMAX
7 #include <Windows.h>
8 #include <lug/Math/Vector.hpp>
9 #include <lug/Window/Window.hpp>
10 
11 
12 namespace lug {
13 namespace Window {
14 namespace priv {
15 
16 class LUG_WINDOW_API WindowImpl {
17 public:
18  WindowImpl(Window*);
19  ~WindowImpl();
20 
21  WindowImpl(const WindowImpl&) = delete;
22  WindowImpl(WindowImpl&&) = delete;
23  WindowImpl& operator=(const WindowImpl&) = delete;
24  WindowImpl& operator=(WindowImpl&&) = delete;
25 
26  bool init(const Window::InitInfo& initInfo);
27  void close();
28 
29  bool pollEvent(lug::Window::Event&);
30  void setKeyRepeat(bool state);
31  void setMouseCursorVisible(bool visible);
32  void setMousePos(const Math::Vec2i& mousePosition);
33 
34  HWND getHandle() const;
35  HINSTANCE getHinstance() const;
36 
37 private:
38  void processWindowEvents(UINT message, WPARAM wParam, LPARAM lParam);
39  void registerWindow() const;
40  bool activateFullscreen();
41  Keyboard::Key getKeyCode(WPARAM wParam, LPARAM lParam);
42  void configKeyEvent(KeyEvent& key, WPARAM wParam, LPARAM lParam);
43  void configMouseEvent(MouseEvent& mouse, WPARAM wParam, LPARAM lParam);
44  void getMouseEventModifier(MouseEvent& mouse, WPARAM wParam);
45  void getMouseCoord(MouseEvent& mouse, LPARAM lParam);
46  void configMouseButtonEvent(MouseEvent& mouse, UINT message, WPARAM wParam, LPARAM lParam);
47  void configMouseWheelEvent(MouseEvent& mouse, UINT message, WPARAM wParam);
48 
49  static LRESULT CALLBACK onEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);
50 
51 private:
52  const wchar_t* className{L"LUG_Window"};
53 
54  Window* _parent{nullptr};
55  std::queue<lug::Window::Event> _events;
56 
57  HWND _handle{nullptr};
58  HINSTANCE _hinstance{nullptr};
59  LONG_PTR _callback{0};
60  HCURSOR _cursor{nullptr};
61  HICON _icon{nullptr};
62  bool _fullscreen{false};
63 
64  static uint8_t _windowCount;
66  bool _keyRepeat{true};
67 
68  bool _mouseIsIn{false};
69 };
70 
71 } // namespace priv
72 } // namespace Window
73 } // namespace lug
Represents an event.
Definition: Event.hpp:89
Class for window.
Definition: Window.hpp:59
Key
Abstraction of keyboard keys.
Definition: Keyboard.hpp:23
static lug::Window::priv::WindowImpl * _fullscreenWindow
#define LUG_WINDOW_API
Definition: Export.hpp:11
void close(Handle handle)
Definition: Library.inl:48
std::queue< lug::Window::Event > _events