WindowImplWin32.hpp

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_WINDOWIMPLWIN32_HPP
00026 #define SFML_WINDOWIMPLWIN32_HPP
00027 
00029 // Headers
00031 #include <SFML/Window/Event.hpp>
00032 #include <SFML/Window/WindowImpl.hpp>
00033 #include <set>
00034 #include <string>
00035 
00036 
00037 namespace sf_private
00038 {
00042 class sfWindowImplWin32 : public sfWindowImpl
00043 {
00044 public :
00045 
00051     sfWindowImplWin32();
00052 
00059     sfWindowImplWin32(sfWindowHandle Handle);
00060 
00069     sfWindowImplWin32(sfVideoMode Mode, const std::string& Title, bool Fullscreen);
00070 
00075     ~sfWindowImplWin32();
00076 
00077 private :
00078 
00083     virtual void Display();
00084 
00089     virtual void ProcessEvents();
00090 
00095     virtual void MakeCurrent() const;
00096 
00101     virtual void UseVerticalSync(bool Enabled);
00102 
00107     virtual void ShowMouseCursor(bool Show);
00108 
00113     void RegisterWindowClass();
00114 
00122     void CreateContext(sfVideoMode Mode, bool Fullscreen);
00123 
00128     void Cleanup();
00129 
00138     void ProcessEvent(UINT Message, WPARAM WParam, LPARAM LParam);
00139 
00143     void SetupJoysticks();
00144 
00153     static sfKey::Code VirtualKeyCodeToSF(WPARAM VirtualKey);
00154 
00166     static LRESULT CALLBACK GlobalOnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam);
00167 
00171     struct JoyCaps
00172     {
00173         int CenterX; 
00174         int CenterY; 
00175         int CenterZ; 
00176         int RangeX;  
00177         int RangeY;  
00178         int RangeZ;  
00179     };
00180 
00182     // Static member data
00184     static unsigned int       ourWindowCount;      
00185     static const wchar_t*     ourClassName;        
00186     static sfWindowImplWin32* ourDummyWindow;      
00187     static sfWindowImplWin32* ourFullscreenWindow; 
00188 
00190     // Member data
00192     HWND    myHandle;          
00193     HDC     myDeviceContext;   
00194     HGLRC   myGLContext;       
00195     long    myCallback;        
00196     JoyCaps myJoystickCaps[2]; 
00197 };
00198 
00199 } // namespace sf_private
00200 
00201 #endif // SFML_WINDOWIMPLWIN32_HPP