Made protected methods virtual to allow subclassing to customize more aspects of the window setup.

This commit is contained in:
Robert Osfield 2014-01-22 17:29:44 +00:00
parent 4fef6a3c2f
commit 405cb0d828

View File

@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
* *
* This library is open source and may be redistributed and/or modified under * This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file * (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website. * included with this distribution, and on the openscenegraph.org website.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details. * OpenSceneGraph Public License for more details.
*/ */
@ -30,15 +30,15 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
public: public:
GraphicsWindowWin32(osg::GraphicsContext::Traits* traits); GraphicsWindowWin32(osg::GraphicsContext::Traits* traits);
~GraphicsWindowWin32(); ~GraphicsWindowWin32();
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindowWin32*>(object)!=0; } virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindowWin32*>(object)!=0; }
virtual const char* libraryName() const { return "osgViewer"; } virtual const char* libraryName() const { return "osgViewer"; }
virtual const char* className() const { return "GraphicsWindowWin32"; } virtual const char* className() const { return "GraphicsWindowWin32"; }
virtual bool valid() const { return _valid; } virtual bool valid() const { return _valid; }
/** Realize the GraphicsContext.*/ /** Realize the GraphicsContext.*/
virtual bool realizeImplementation(); virtual bool realizeImplementation();
@ -56,7 +56,7 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
/** Swap the front and back buffers.*/ /** Swap the front and back buffers.*/
virtual void swapBuffersImplementation(); virtual void swapBuffersImplementation();
/** Check to see if any events have been generated.*/ /** Check to see if any events have been generated.*/
virtual bool checkEvents(); virtual bool checkEvents();
@ -68,10 +68,10 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
/** Get focus.*/ /** Get focus.*/
virtual void grabFocus(); virtual void grabFocus();
/** Get focus on if the pointer is in this window.*/ /** Get focus on if the pointer is in this window.*/
virtual void grabFocusIfPointerInWindow(); virtual void grabFocusIfPointerInWindow();
/** Override from GUIActionAdapter.*/ /** Override from GUIActionAdapter.*/
virtual void requestWarpPointer(float x,float y); virtual void requestWarpPointer(float x,float y);
@ -80,10 +80,10 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
/** Set the name of the window */ /** Set the name of the window */
virtual void setWindowName(const std::string& /*name*/); virtual void setWindowName(const std::string& /*name*/);
/** Switch on/off the cursor.*/ /** Switch on/off the cursor.*/
virtual void useCursor(bool /*cursorOn*/); virtual void useCursor(bool /*cursorOn*/);
/** Set mouse cursor to a specific shape.*/ /** Set mouse cursor to a specific shape.*/
virtual void setCursor(MouseCursor cursor); virtual void setCursor(MouseCursor cursor);
@ -95,35 +95,35 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
/** Handle a native (Win32) windowing event as received from the system */ /** Handle a native (Win32) windowing event as received from the system */
virtual LRESULT handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); virtual LRESULT handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
/** WindowData is used to pass in the Win32 window handle attached the GraphicsContext::Traits structure.*/ /** WindowData is used to pass in the Win32 window handle attached the GraphicsContext::Traits structure.*/
struct WindowData : public osg::Referenced struct WindowData : public osg::Referenced
{ {
WindowData(HWND window, bool installEventHandler = true): WindowData(HWND window, bool installEventHandler = true):
_hwnd(window), _installEventHandler(installEventHandler) {} _hwnd(window), _installEventHandler(installEventHandler) {}
HWND _hwnd; HWND _hwnd;
bool _installEventHandler; bool _installEventHandler;
}; };
protected:
void init();
void registerWindow(); protected:
void unregisterWindow();
virtual void init();
bool registerWindowProcedure();
bool unregisterWindowProcedure(); virtual void registerWindow();
virtual void unregisterWindow();
HGLRC createContextImplementation();
bool createWindow(); virtual bool registerWindowProcedure();
bool setWindow( HWND handle ); virtual bool unregisterWindowProcedure();
void destroyWindow( bool deleteNativeWindow = true ); virtual HGLRC createContextImplementation();
void recreateWindow(); virtual bool createWindow();
virtual bool setWindow( HWND handle );
bool determineWindowPositionAndStyle( unsigned int screenNum,
virtual void destroyWindow( bool deleteNativeWindow = true );
virtual void recreateWindow();
virtual bool determineWindowPositionAndStyle( unsigned int screenNum,
int clientAreaX, int clientAreaX,
int clientAreaY, int clientAreaY,
unsigned int clientAreaWidth, unsigned int clientAreaWidth,
@ -135,41 +135,41 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
unsigned int& h, unsigned int& h,
unsigned int& style, unsigned int& style,
unsigned int& extendedStyle ); unsigned int& extendedStyle );
bool setPixelFormat();
void adaptKey( WPARAM wParam, LPARAM lParam, int& keySymbol, unsigned int& modifierMask, int& unmodifiedKeySymbol );
void transformMouseXY(float& x, float& y);
void setCursorImpl(MouseCursor cursor);
HCURSOR getOrCreateCursor(MouseCursor mouseShape); virtual bool setPixelFormat();
virtual void adaptKey( WPARAM wParam, LPARAM lParam, int& keySymbol, unsigned int& modifierMask, int& unmodifiedKeySymbol );
virtual void transformMouseXY(float& x, float& y);
virtual void setCursorImpl(MouseCursor cursor);
virtual HCURSOR getOrCreateCursor(MouseCursor mouseShape);
HCURSOR _currentCursor; HCURSOR _currentCursor;
WNDPROC _windowProcedure; WNDPROC _windowProcedure;
double _timeOfLastCheckEvents; double _timeOfLastCheckEvents;
int _screenOriginX; int _screenOriginX;
int _screenOriginY; int _screenOriginY;
unsigned int _screenWidth; unsigned int _screenWidth;
unsigned int _screenHeight; unsigned int _screenHeight;
int _windowOriginXToRealize; int _windowOriginXToRealize;
int _windowOriginYToRealize; int _windowOriginYToRealize;
unsigned int _windowWidthToRealize; unsigned int _windowWidthToRealize;
unsigned int _windowHeightToRealize; unsigned int _windowHeightToRealize;
bool _initialized; bool _initialized;
bool _valid; bool _valid;
bool _realized; bool _realized;
bool _ownsWindow; bool _ownsWindow;
bool _closeWindow; bool _closeWindow;
bool _destroyWindow; bool _destroyWindow;
bool _destroying; bool _destroying;
@ -178,7 +178,7 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
/// Persist which mouse cursor was used before switching to the resize cursors. /// Persist which mouse cursor was used before switching to the resize cursors.
MouseCursor _appMouseCursor; MouseCursor _appMouseCursor;
std::map<MouseCursor,HCURSOR> _mouseCursorMap; std::map<MouseCursor,HCURSOR> _mouseCursorMap;
std::map<std::pair<int, int>, bool> _keyMap; std::map<std::pair<int, int>, bool> _keyMap;