WindowImpl.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_WINDOWIMPL_HPP
00026 #define SFML_WINDOWIMPL_HPP
00027 
00029 // Headers
00031 #include <SFML/Config.hpp>
00032 #include <SFML/System/NonCopyable.hpp>
00033 #include <SFML/Window/VideoMode.hpp>
00034 #include <SFML/Window/WindowHandle.hpp>
00035 #include <set>
00036 #include <string>
00037 
00038 
00039 namespace sf
00040 {
00041 class Event;
00042 class WindowListener;
00043 
00044 namespace priv
00045 {
00049 class WindowImpl : NonCopyable
00050 {
00051 public :
00052 
00057     enum Style
00058     {
00059         Resizable, 
00060         Fixed,     
00061         Fullscreen 
00062     };
00063 
00070     static WindowImpl* New();
00071 
00083     static WindowImpl* New(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, int AntialiasingLevel);
00084 
00094     static WindowImpl* New(WindowHandle Handle, int AntialiasingLevel = 0);
00095 
00096 public :
00097 
00102     virtual ~WindowImpl();
00103 
00110     void AddListener(WindowListener* Listener);
00111 
00118     void RemoveListener(WindowListener* Listener);
00119 
00126     unsigned int GetWidth() const;
00127 
00134     unsigned int GetHeight() const;
00135 
00142     unsigned int GetDepthBits() const;
00143 
00150     unsigned int GetStencilBits() const;
00151 
00156     void SetCurrent() const;
00157 
00162     virtual void Display() = 0;
00163 
00168     virtual void ProcessEvents() = 0;
00169 
00176     virtual void UseVerticalSync(bool Enabled) = 0;
00177 
00184     virtual void ShowMouseCursor(bool Show) = 0;
00185 
00193     virtual void SetPosition(int Left, int Top) = 0;
00194 
00195 protected :
00196 
00201     WindowImpl();
00202 
00209     void SendEvent(const Event& EventToSend);
00210 
00212     // Member data
00214     unsigned int myWidth;       
00215     unsigned int myHeight;      
00216     unsigned int myDepthBits;   
00217     unsigned int myStencilBits; 
00218 
00219 private :
00220 
00225     virtual void MakeCurrent() const = 0;
00226 
00228     // Static member data
00230     static const WindowImpl* ourCurrent; 
00231 
00233     // Member data
00235     std::set<WindowListener*> myListeners; 
00236 };
00237 
00238 } // namespace priv
00239 
00240 } // namespace sf
00241 
00242 
00243 #endif // SFML_WINDOWIMPL_HPP