Visual Servoing Platform  version 3.0.0
vpWin32Window.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Bruno Renier
35  * Anthony Saunier
36  *
37  *****************************************************************************/
38 
39 #include <visp3/core/vpConfig.h>
40 
41 #if ( defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) )
42 #ifndef vpWin32Window_HH
43 #define vpWin32Window_HH
44 
45 
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 
48 #include <windows.h>
49 #include <visp3/gui/vpWin32Renderer.h>
50 #include <visp3/core/vpGDIRenderer.h>
51 #include <visp3/core/vpDisplay.h>
52 #include <visp3/core/vpDisplayException.h>
53 
54 
55 //ViSP-defined messages for window's callback function
56 #define vpWM_GETCLICK WM_USER+1
57 #define vpWM_DISPLAY WM_USER+2
58 #define vpWM_GETCLICKUP WM_USER+3
59 #define vpWM_CLOSEDISPLAY WM_USER+4
60 #define vpWM_GETPOINTERMOTIONEVENT WM_USER+5
61 #define vpWM_DISPLAY_ROI WM_USER+6
62 
63 //No specific mouse button query
64 #define vpNO_BUTTON_QUERY -1
65 
66 class vpDisplayWin32;
67 
68 class VISP_EXPORT vpWin32Window
69 {
70 private :
71 
72  HINSTANCE hInst;
73 
75  HWND hWnd;
76 
78  bool initialized;
80  HANDLE semaInit;
81 
83  HANDLE semaClick;
85  HANDLE semaClickUp;
87  HANDLE semaKey;
89  HANDLE semaMove;
90 
92  int clickX;
93  int clickXUp;
95  int clickY;
96  int clickYUp;
98  int coordX;
100  int coordY;
101  // Keyboard key
102  char lpString[10];
105  vpMouseButton::vpMouseButtonType clickButtonUp;
106 
108  static bool registered;
109 
111  vpWin32Renderer * renderer;
112 
113 
114  public:
115 
116  vpWin32Window(vpWin32Renderer * rend = NULL);
117  virtual ~vpWin32Window();
118 
120  unsigned int getImageWidth(){ return renderer->getImageWidth(); }
122  unsigned int getImageHeight(){ return renderer->getImageHeight(); }
124  HWND getHWnd(){ return hWnd;}
125 
127  bool isInitialized(){ return initialized; }
128 
130  void initWindow(const char* title, int posx, int posy, unsigned int w, unsigned int h);
131 
132  // Friend classes
133  friend class vpDisplayWin32;
134  friend class vpDisplayD3D;
135  friend class vpDisplayGDI;
136 
138  friend LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
139  WPARAM wParam, LPARAM lParam);
140 };
141 
142 #endif
143 #endif
144 #endif
Display for windows using GDI (available on any windows 32 platform).
Definition: vpDisplayGDI.h:128
Display for windows using Direct3D.
Definition: vpDisplayD3D.h:105
Base abstract class for Windows 32 displays. Implements the window creation in a separate thread and ...