win32window.h

main 116 lines · 3.3 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1/*
2 * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#ifndef WIN32WINDOW_H
24#define WIN32WINDOW_H
25
26#include "platformwindow.h"
27
28#include <winsock2.h>
29#include <windows.h>
30
31#ifdef OPENGL_ES
32#include <EGL/egl.h>
33#endif
34
35struct WindowProcProxy;
36
37class WIN32Window : public PlatformWindow
38{
39 void internalSetupTimerAccuracy();
40 void internalCreateWindow();
41 void internalCreateGLContext();
42 void internalDestroyGLContext();
43 void internalRestoreGLContext();
44
45 void *getExtensionProcAddress(const char *ext);
46 bool isExtensionSupported(const char *ext);
47
48 LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
49 LRESULT dispatcherWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
50 friend struct WindowProcProxy;
51
52 Fw::Key retranslateVirtualKey(WPARAM wParam, LPARAM lParam);
53
54public:
55 WIN32Window();
56
57 void init();
58 void terminate();
59
60 void move(const Point& pos);
61 void resize(const Size& size);
62 void show();
63 void hide();
64 void minimize();
65 void maximize();
66 void poll();
67 void swapBuffers();
68 void showMouse();
69 void hideMouse();
70 void displayFatalError(const std::string& message);
71
72 void setMouseCursor(int cursorId);
73 void restoreMouseCursor();
74
75 void setTitle(const std::string& title);
76 void setMinimumSize(const Size& minimumSize);
77 void setFullscreen(bool fullscreen);
78 void setVerticalSync(bool enable);
79 void setIcon(const std::string& file);
80 void setClipboardText(const std::string& text);
81
82 Size getDisplaySize();
83 std::string getClipboardText();
84 std::string getPlatformType();
85
86 void flash() override;
87
88protected:
89 int internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot);
90
91private:
92 Rect getClientRect();
93 Rect getWindowRect();
94 Rect adjustWindowRect(const Rect& rect);
95
96 std::vector<HCURSOR> m_cursors;
97 HWND m_window;
98 HINSTANCE m_instance;
99 HDC m_deviceContext;
100 HCURSOR m_cursor;
101 HCURSOR m_defaultCursor;
102 UINT m_timerRes = 0;
103 bool m_hidden;
104
105#ifdef OPENGL_ES
106 EGLConfig m_eglConfig;
107 EGLContext m_eglContext;
108 EGLDisplay m_eglDisplay;
109 EGLSurface m_eglSurface;
110#else
111 HGLRC m_wglContext;
112#endif
113};
114
115#endif
116
Top