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/WindowListener.hpp>
00031 #include <algorithm>
00032
00033 #if defined(SFML_SYSTEM_WINDOWS)
00034
00035 #include <SFML/Window/Win32/WindowImplWin32.hpp>
00036
00037 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
00038
00039 #include <SFML/Window/Unix/WindowImplUnix.hpp>
00040
00041 #endif
00042
00043 namespace sf_private
00044 {
00046
00048 const sfWindowImpl* sfWindowImpl::ourCurrent = NULL;
00049
00050
00054 sfWindowImpl* sfWindowImpl::New(sfVideoMode Mode, const std::string& Title, bool Fullscreen)
00055 {
00056 #if defined(SFML_SYSTEM_WINDOWS)
00057
00058
00059 return new sfWindowImplWin32(Mode, Title, Fullscreen);
00060
00061 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
00062
00063
00064 return new sfWindowImplUnix(Mode, Title, Fullscreen);
00065
00066 #endif
00067 }
00068
00069
00073 sfWindowImpl* sfWindowImpl::New(void* Handle)
00074 {
00075 #if defined(SFML_SYSTEM_WINDOWS)
00076
00077
00078 return new sfWindowImplWin32(Handle);
00079
00080 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_MACOS)
00081
00082
00083 return new sfWindowImplUnix(Handle);
00084
00085 #endif
00086 }
00087
00088
00092 sfWindowImpl::~sfWindowImpl()
00093 {
00094
00095 }
00096
00097
00101 void sfWindowImpl::AddListener(sfWindowListener* Listener)
00102 {
00103 if (Listener)
00104 myListeners.insert(Listener);
00105 }
00106
00107
00111 void sfWindowImpl::RemoveListener(sfWindowListener* Listener)
00112 {
00113 myListeners.erase(Listener);
00114 }
00115
00116
00120 unsigned int sfWindowImpl::GetWidth() const
00121 {
00122 return myWidth;
00123 }
00124
00125
00129 unsigned int sfWindowImpl::GetHeight() const
00130 {
00131 return myHeight;
00132 }
00133
00134
00138 void sfWindowImpl::SetCurrent() const
00139 {
00140 if (ourCurrent != this)
00141 {
00142 MakeCurrent();
00143 ourCurrent = this;
00144 }
00145 }
00146
00147
00151 float sfWindowImpl::Display()
00152 {
00153
00154 float ElapsedTime = myClock.GetElapsedTime();
00155 myClock.Reset();
00156
00157
00158 SwapBuffers();
00159
00160 return ElapsedTime;
00161 }
00162
00163
00167 void sfWindowImpl::SendEvent(const sfEvent& Event)
00168 {
00169 for (std::set<sfWindowListener*>::iterator i = myListeners.begin(); i != myListeners.end(); ++i)
00170 {
00171 (*i)->OnEvent(Event);
00172 }
00173 }
00174
00175 }