00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00026
00028 #include <SFML/Window/WindowImpl.hpp>
00029 #include <SFML/Window/Event.hpp>
00030 #include <SFML/Window/OpenGLCaps.hpp>
00031 #include <SFML/Window/WindowListener.hpp>
00032 #include <algorithm>
00033
00034 #if defined(SFML_SYSTEM_WINDOWS)
00035
00036 #include <SFML/Window/Win32/WindowImplWin32.hpp>
00037
00038 #elif defined(SFML_SYSTEM_LINUX)
00039
00040 #include <SFML/Window/Linux/WindowImplX11.hpp>
00041
00042 #elif defined(SFML_SYSTEM_MACOS)
00043
00044 #include <SFML/Window/OSX/WindowImplCarbon.hpp>
00045
00046 #endif
00047
00048
00049 namespace sf
00050 {
00051 namespace priv
00052 {
00054
00056 const WindowImpl* WindowImpl::ourCurrent = NULL;
00057
00058
00062 WindowImpl* WindowImpl::New()
00063 {
00064 WindowImpl* Window = NULL;
00065
00066 #if defined(SFML_SYSTEM_WINDOWS)
00067
00068
00069 Window = new WindowImplWin32();
00070
00071 #elif defined(SFML_SYSTEM_LINUX)
00072
00073
00074 Window = new WindowImplX11();
00075
00076 #elif defined(SFML_SYSTEM_MACOS)
00077
00078
00079 Window = new WindowImplCarbon();
00080
00081 #endif
00082
00083
00084
00085 OpenGLCaps::Initialize();
00086
00087 return Window;
00088 }
00089
00090
00094 WindowImpl* WindowImpl::New(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, int AntialiasingLevel)
00095 {
00096 #if defined(SFML_SYSTEM_WINDOWS)
00097
00098
00099 return new WindowImplWin32(Mode, Title, WindowStyle, AntialiasingLevel);
00100
00101 #elif defined(SFML_SYSTEM_LINUX)
00102
00103
00104 return new WindowImplX11(Mode, Title, WindowStyle, AntialiasingLevel);
00105
00106 #elif defined(SFML_SYSTEM_MACOS)
00107
00108
00109 return new WindowImplCarbon(Mode, Title, WindowStyle, AntialiasingLevel);
00110
00111 #endif
00112 }
00113
00114
00118 WindowImpl* WindowImpl::New(WindowHandle Handle, int AntialiasingLevel)
00119 {
00120 #if defined(SFML_SYSTEM_WINDOWS)
00121
00122
00123 return new WindowImplWin32(Handle, AntialiasingLevel);
00124
00125 #elif defined(SFML_SYSTEM_LINUX)
00126
00127
00128 return new WindowImplX11(Handle, AntialiasingLevel);
00129
00130 #elif defined(SFML_SYSTEM_MACOS)
00131
00132
00133 return new WindowImplCarbon(Handle, AntialiasingLevel);
00134
00135 #endif
00136 }
00137
00138
00142 WindowImpl::WindowImpl() :
00143 myWidth (0),
00144 myHeight (0),
00145 myDepthBits (0),
00146 myStencilBits(0)
00147 {
00148
00149 }
00150
00151
00155 WindowImpl::~WindowImpl()
00156 {
00157
00158 }
00159
00160
00164 void WindowImpl::AddListener(WindowListener* Listener)
00165 {
00166 if (Listener)
00167 myListeners.insert(Listener);
00168 }
00169
00170
00174 void WindowImpl::RemoveListener(WindowListener* Listener)
00175 {
00176 myListeners.erase(Listener);
00177 }
00178
00179
00183 unsigned int WindowImpl::GetWidth() const
00184 {
00185 return myWidth;
00186 }
00187
00188
00192 unsigned int WindowImpl::GetHeight() const
00193 {
00194 return myHeight;
00195 }
00196
00197
00201 unsigned int WindowImpl::GetDepthBits() const
00202 {
00203 return myDepthBits;
00204 }
00205
00206
00210 unsigned int WindowImpl::GetStencilBits() const
00211 {
00212 return myStencilBits;
00213 }
00214
00215
00219 void WindowImpl::SetCurrent() const
00220 {
00221 if (ourCurrent != this)
00222 {
00223 MakeCurrent();
00224 ourCurrent = this;
00225 }
00226 }
00227
00228
00232 void WindowImpl::SendEvent(const Event& EventToSend)
00233 {
00234 for (std::set<WindowListener*>::iterator i = myListeners.begin(); i != myListeners.end(); ++i)
00235 {
00236 (*i)->OnEvent(EventToSend);
00237 }
00238 }
00239
00240 }
00241
00242 }