Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpWin32Window.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Windows 32 display's window class
32 */
33
34#ifndef VP_WIN32_WINDOW_H
35#define VP_WIN32_WINDOW_H
36
37#include <visp3/core/vpConfig.h>
38
39#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9))
40
41#ifndef DOXYGEN_SHOULD_SKIP_THIS
42
43// Mute warning with clang-cl
44// warning : non-portable path to file '<WinSock2.h>'; specified path differs in case from file name on disk [-Wnonportable-system-include-path]
45// warning : non-portable path to file '<Windows.h>'; specified path differs in case from file name on disk [-Wnonportable-system-include-path]
46#if defined(__clang__)
47# pragma clang diagnostic push
48# pragma clang diagnostic ignored "-Wnonportable-system-include-path"
49#endif
50
51// Include WinSock2.h before windows.h to ensure that winsock.h is not
52// included by windows.h since winsock.h and winsock2.h are incompatible
53#include <WinSock2.h>
54#include <visp3/core/vpDisplay.h>
55#include <visp3/core/vpDisplayException.h>
56#include <visp3/gui/vpGDIRenderer.h>
57#include <visp3/gui/vpWin32Renderer.h>
58
59#include <windows.h>
60
61#if defined(__clang__)
62# pragma clang diagnostic pop
63#endif
64
66
67// ViSP-defined messages for window's callback function
68#define vpWM_GETCLICK WM_USER + 1
69#define vpWM_DISPLAY WM_USER + 2
70#define vpWM_GETCLICKUP WM_USER + 3
71#define vpWM_CLOSEDISPLAY WM_USER + 4
72#define vpWM_GETPOINTERMOTIONEVENT WM_USER + 5
73#define vpWM_DISPLAY_ROI WM_USER + 6
74
75// No specific mouse button query
76#define vpNO_BUTTON_QUERY -1
77
78class vpDisplayWin32;
79
80class VISP_EXPORT vpWin32Window
81{
82private:
83 HINSTANCE hInst;
84
86 HWND hWnd;
87
89 bool initialized;
91 HANDLE semaInit;
92
94 HANDLE semaClick;
96 HANDLE semaClickUp;
98 HANDLE semaKey;
100 HANDLE semaMove;
101
103 int clickX;
104 int clickXUp;
106 int clickY;
107 int clickYUp;
109 int coordX;
111 int coordY;
112 // Keyboard key
113 char lpString[10];
117
119 static bool registered;
120
122 vpWin32Renderer *renderer;
123
124public:
125 VP_EXPLICIT vpWin32Window(vpWin32Renderer *rend = nullptr);
126 vpWin32Window(const vpWin32Window &window);
127 virtual ~vpWin32Window();
128 vpWin32Window &operator=(const vpWin32Window &window);
129
130 HWND getHWnd() { return hWnd; }
131
133 bool isInitialized() { return initialized; }
134
136 void initWindow(const char *title, int posx, int posy, unsigned int w, unsigned int h);
137
138 void setScale(unsigned int scale) { renderer->setScale(scale); }
139
140 // Friend classes
141 friend class vpDisplayWin32;
142 friend class vpDisplayD3D;
143 friend class vpDisplayGDI;
144
146 friend LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
147};
148
149END_VISP_NAMESPACE
150#endif
151#endif
152#endif
Base abstract class for Windows 32 displays. Implements the window creation in a separate thread and ...