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) || defined(SFML_SYSTEM_MACOS)
00039
00040 #include <SFML/Window/Unix/WindowImplUnix.hpp>
00041
00042 #endif
00043
00044
00045 namespace sf_private
00046 {
00048
00050 const sfWindowImpl* sfWindowImpl::ourCurrent = NULL;
00051
00052
00056 sfWindowImpl* sfWindowImpl::New()
00057 {
00058 sfWindowImpl* Window = NULL;
00059
00060 #if defined(SFML_SYSTEM_WINDOWS)
00061
00062
00063 Window = new sfWindowImplWin32();
00064
00065 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
00066
00067
00068 Window = new sfWindowImplUnix();
00069
00070 #endif
00071
00072
00073
00074 sfOpenGLCaps::Initialize();
00075
00076 return Window;
00077 }
00078
00079
00083 sfWindowImpl* sfWindowImpl::New(sfVideoMode Mode, const std::string& Title, bool Fullscreen)
00084 {
00085 #if defined(SFML_SYSTEM_WINDOWS)
00086
00087
00088 return new sfWindowImplWin32(Mode, Title, Fullscreen);
00089
00090 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
00091
00092
00093 return new sfWindowImplUnix(Mode, Title, Fullscreen);
00094
00095 #endif
00096 }
00097
00098
00102 sfWindowImpl* sfWindowImpl::New(sfWindowHandle Handle)
00103 {
00104 #if defined(SFML_SYSTEM_WINDOWS)
00105
00106
00107 return new sfWindowImplWin32(Handle);
00108
00109 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
00110
00111
00112 return new sfWindowImplUnix(Handle);
00113
00114 #endif
00115 }
00116
00117
00121 sfWindowImpl::sfWindowImpl() :
00122 myWidth (0),
00123 myHeight (0),
00124 myDepthBits (0),
00125 myStencilBits(0)
00126 {
00127
00128 }
00129
00130
00134 sfWindowImpl::~sfWindowImpl()
00135 {
00136
00137 }
00138
00139
00143 void sfWindowImpl::AddListener(sfWindowListener* Listener)
00144 {
00145 if (Listener)
00146 myListeners.insert(Listener);
00147 }
00148
00149
00153 void sfWindowImpl::RemoveListener(sfWindowListener* Listener)
00154 {
00155 myListeners.erase(Listener);
00156 }
00157
00158
00162 unsigned int sfWindowImpl::GetWidth() const
00163 {
00164 return myWidth;
00165 }
00166
00167
00171 unsigned int sfWindowImpl::GetHeight() const
00172 {
00173 return myHeight;
00174 }
00175
00176
00180 unsigned int sfWindowImpl::GetDepthBits() const
00181 {
00182 return myDepthBits;
00183 }
00184
00185
00189 unsigned int sfWindowImpl::GetStencilBits() const
00190 {
00191 return myStencilBits;
00192 }
00193
00194
00198 void sfWindowImpl::SetCurrent() const
00199 {
00200 if (ourCurrent != this)
00201 {
00202 MakeCurrent();
00203 ourCurrent = this;
00204 }
00205 }
00206
00207
00211 void sfWindowImpl::SendEvent(const sfEvent& Event)
00212 {
00213 for (std::set<sfWindowListener*>::iterator i = myListeners.begin(); i != myListeners.end(); ++i)
00214 {
00215 (*i)->OnEvent(Event);
00216 }
00217 }
00218
00219 }