Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
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 // Include WinSock2.h before windows.h to ensure that winsock.h is not
44 // included by windows.h since winsock.h and winsock2.h are incompatible
45 #include <WinSock2.h>
46 #include <visp3/core/vpDisplay.h>
47 #include <visp3/core/vpDisplayException.h>
48 #include <visp3/gui/vpGDIRenderer.h>
49 #include <visp3/gui/vpWin32Renderer.h>
50 #include <windows.h>
51 
53 
54 // ViSP-defined messages for window's callback function
55 #define vpWM_GETCLICK WM_USER + 1
56 #define vpWM_DISPLAY WM_USER + 2
57 #define vpWM_GETCLICKUP WM_USER + 3
58 #define vpWM_CLOSEDISPLAY WM_USER + 4
59 #define vpWM_GETPOINTERMOTIONEVENT WM_USER + 5
60 #define vpWM_DISPLAY_ROI WM_USER + 6
61 
62 // No specific mouse button query
63 #define vpNO_BUTTON_QUERY -1
64 
65 class vpDisplayWin32;
66 
67 class VISP_EXPORT vpWin32Window
68 {
69 private:
70  HINSTANCE hInst;
71 
73  HWND hWnd;
74 
76  bool initialized;
78  HANDLE semaInit;
79 
81  HANDLE semaClick;
83  HANDLE semaClickUp;
85  HANDLE semaKey;
87  HANDLE semaMove;
88 
90  int clickX;
91  int clickXUp;
93  int clickY;
94  int clickYUp;
96  int coordX;
98  int coordY;
99  // Keyboard key
100  char lpString[10];
103  vpMouseButton::vpMouseButtonType clickButtonUp;
104 
106  static bool registered;
107 
109  vpWin32Renderer *renderer;
110 
111 public:
112  VP_EXPLICIT vpWin32Window(vpWin32Renderer *rend = nullptr);
113  virtual ~vpWin32Window();
114 
115  HWND getHWnd() { return hWnd; }
116 
118  bool isInitialized() { return initialized; }
119 
121  void initWindow(const char *title, int posx, int posy, unsigned int w, unsigned int h);
122 
123  void setScale(unsigned int scale) { renderer->setScale(scale); };
124 
125  // Friend classes
126  friend class vpDisplayWin32;
127  friend class vpDisplayD3D;
128  friend class vpDisplayGDI;
129 
131  friend LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
132 };
133 
134 END_VISP_NAMESPACE
135 #endif
136 #endif
137 #endif
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Definition: vpDisplayD3D.h:106
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:130
Base abstract class for Windows 32 displays. Implements the window creation in a separate thread and ...