OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GraphicsWindowWin32.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 /* Note, elements of GraphicsWindowX11 have used Prodcer/RenderSurface_X11.cpp as both
15  * a guide to use of X11/GLX and copiying directly in the case of setBorder().
16  * These elements are license under OSGPL as above, with Copyright (C) 2001-2004 Don Burns.
17  */
18 
19 #ifndef OSGVIEWER_GRAPHICSWINDOWWIN32
20 #define OSGVIEWER_GRAPHICSWINDOWWIN32 1
21 
22 #include <osgViewer/GraphicsWindow>
23 #include <osgViewer/api/Win32/GraphicsHandleWin32>
24 
25 namespace osgViewer
26 {
27 
29 {
30  public:
31 
33 
35 
36  virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindowWin32*>(object)!=0; }
37  virtual const char* libraryName() const { return "osgViewer"; }
38  virtual const char* className() const { return "GraphicsWindowWin32"; }
39 
40  virtual bool valid() const { return _valid; }
41 
43  virtual bool realizeImplementation();
44 
46  virtual bool isRealizedImplementation() const { return _realized; }
47 
49  virtual void closeImplementation();
50 
52  virtual bool makeCurrentImplementation();
53 
55  virtual bool releaseContextImplementation();
56 
58  virtual void swapBuffersImplementation();
59 
61  virtual bool checkEvents();
62 
64  virtual bool setWindowRectangleImplementation(int x, int y, int width, int height);
65 
67  virtual bool setWindowDecorationImplementation(bool flag);
68 
70  virtual void grabFocus();
71 
73  virtual void grabFocusIfPointerInWindow();
74 
76  virtual void requestWarpPointer(float x,float y);
77 
79  virtual void raiseWindow();
80 
82  virtual void setWindowName(const std::string& /*name*/);
83 
85  virtual void useCursor(bool /*cursorOn*/);
86 
88  virtual void setCursor(MouseCursor cursor);
89 
91  virtual void setSyncToVBlank(bool on);
92 
94  virtual void setSwapGroup(bool on, GLuint group, GLuint barrier);
95 
97  virtual LRESULT handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
98 
100  struct WindowData : public osg::Referenced
101  {
102  WindowData(HWND window, bool installEventHandler = true):
103  _hwnd(window), _installEventHandler(installEventHandler) {}
104 
105  HWND _hwnd;
107  };
108 
109  protected:
110 
111  virtual void init();
112 
113  virtual void registerWindow();
114  virtual void unregisterWindow();
115 
116  virtual bool registerWindowProcedure();
117  virtual bool unregisterWindowProcedure();
118 
119  virtual HGLRC createContextImplementation();
120  virtual bool createWindow();
121  virtual bool setWindow( HWND handle );
122 
123  virtual void destroyWindow( bool deleteNativeWindow = true );
124 
125  virtual bool determineWindowPositionAndStyle( unsigned int screenNum,
126  int clientAreaX,
127  int clientAreaY,
128  unsigned int clientAreaWidth,
129  unsigned int clientAreaHeight,
130  bool decorated,
131  int& x,
132  int& y,
133  unsigned int& w,
134  unsigned int& h,
135  unsigned int& style,
136  unsigned int& extendedStyle );
137 
138  virtual bool setPixelFormat();
139 
140  virtual void adaptKey( WPARAM wParam, LPARAM lParam, int& keySymbol, unsigned int& modifierMask, int& unmodifiedKeySymbol );
141 
142  virtual void transformMouseXY(float& x, float& y);
143 
144  virtual void setCursorImpl(MouseCursor cursor);
145 
146  virtual HCURSOR getOrCreateCursor(MouseCursor mouseShape);
147 
148  HCURSOR _currentCursor;
149 
151 
153 
154 
155 
156 
159  unsigned int _screenWidth;
160  unsigned int _screenHeight;
161 
164  unsigned int _windowWidthToRealize;
166 
168  bool _valid;
169  bool _realized;
170 
175 
177 
180 
181  std::map<MouseCursor,HCURSOR> _mouseCursorMap;
182 
183  std::map<std::pair<int, int>, bool> _keyMap;
184 
185  std::set<int> _capturedMouseButtons;
186 
188 };
189 
190 }
191 
192 #endif
MouseCursor _appMouseCursor
Persist which mouse cursor was used before switching to the resize cursors.
virtual const char * className() const
#define OSGVIEWER_EXPORT
Definition: Export.h:40
virtual bool isSameKindAs(const Object *object) const
GLint GLenum GLsizei width
Definition: GLU.h:71
std::map< MouseCursor, HCURSOR > _mouseCursorMap
std::map< std::pair< int, int >, bool > _keyMap
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
WindowData(HWND window, bool installEventHandler=true)
virtual const char * libraryName() const
virtual bool isRealizedImplementation() const