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/Window.h>
00029 #include <SFML/Window/Window.hpp>
00030 #include <SFML/Window/Input.h>
00031 #include <SFML/Internal.h>
00032
00033
00034
00035 struct sfInput
00036 {
00037 const sf::Input* This;
00038 };
00039 struct sfWindow
00040 {
00041 sf::Window This;
00042 sfInput Input;
00043 };
00044
00045
00049 sfWindow* sfWindow_Create(sfVideoMode Mode, const char* Title, unsigned long Style, int AntialiasingLevel)
00050 {
00051
00052 sf::VideoMode VideoMode(Mode.Width, Mode.Height, Mode.BitsPerPixel);
00053
00054
00055 sfWindow* Window = new sfWindow;
00056 Window->This.Create(VideoMode, Title, Style, AntialiasingLevel);
00057 Window->Input.This = &Window->This.GetInput();
00058
00059 return Window;
00060 }
00061
00062
00066 sfWindow* sfWindow_CreateFromHandle(sfWindowHandle Handle, int AntialiasingLevel)
00067 {
00068 sfWindow* Window = new sfWindow;
00069 Window->This.Create(Handle, AntialiasingLevel);
00070 Window->Input.This = &Window->This.GetInput();
00071
00072 return Window;
00073 }
00074
00075
00079 void sfWindow_Destroy(sfWindow* Window)
00080 {
00081 delete Window;
00082 }
00083
00084
00088 unsigned int sfWindow_GetWidth(sfWindow* Window)
00089 {
00090 CSFML_CALL_RETURN(Window, GetWidth(), 0)
00091 }
00092
00093
00097 unsigned int sfWindow_GetHeight(sfWindow* Window)
00098 {
00099 CSFML_CALL_RETURN(Window, GetHeight(), 0)
00100 }
00101
00102
00106 unsigned int sfWindow_GetDepthBits(sfWindow* Window)
00107 {
00108 CSFML_CALL_RETURN(Window, GetDepthBits(), 0)
00109 }
00110
00111
00115 unsigned int sfWindow_GetStencilBits(sfWindow* Window)
00116 {
00117 CSFML_CALL_RETURN(Window, GetStencilBits(), 0)
00118 }
00119
00120
00124 sfBool sfWindow_GetEvent(sfWindow* Window, sfEvent* Event)
00125 {
00126 CSFML_CHECK_RETURN(Window, sfFalse);
00127 CSFML_CHECK_RETURN(Event, sfFalse);
00128
00129
00130 sf::Event SFMLEvent;
00131 sfBool Ret = Window->This.GetEvent(SFMLEvent);
00132
00133
00134 if (!Ret)
00135 return sfFalse;
00136
00137
00138 Event->Type = static_cast<sfEventType>(SFMLEvent.Type);
00139
00140
00141 switch (Event->Type)
00142 {
00143 case sfEvtResized :
00144 Event->Size.Width = SFMLEvent.Size.Width;
00145 Event->Size.Height = SFMLEvent.Size.Height;
00146 break;
00147
00148 case sfEvtTextEntered :
00149 Event->Text.Unicode = SFMLEvent.Text.Unicode;
00150 break;
00151
00152 case sfEvtKeyReleased :
00153 case sfEvtKeyPressed :
00154 Event->Key.Code = static_cast<sfKeyCode>(SFMLEvent.Key.Code);
00155 Event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse;
00156 Event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse;
00157 Event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse;
00158 break;
00159
00160 case sfEvtMouseWheelMoved :
00161 Event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta;
00162 break;
00163
00164 case sfEvtMouseButtonPressed :
00165 case sfEvtMouseButtonReleased :
00166 Event->MouseButton.Button = static_cast<sfMouseButton>(SFMLEvent.MouseButton.Button);
00167 break;
00168
00169 case sfEvtMouseMoved :
00170 Event->MouseMove.X = SFMLEvent.MouseMove.X;
00171 Event->MouseMove.Y = SFMLEvent.MouseMove.Y;
00172 break;
00173
00174 case sfEvtJoyButtonPressed :
00175 case sfEvtJoyButtonReleased :
00176 Event->JoyButton.JoystickId = SFMLEvent.JoyButton.JoystickId;
00177 Event->JoyButton.Button = SFMLEvent.JoyButton.Button;
00178 break;
00179
00180 case sfEvtJoyMoved :
00181 Event->JoyMove.JoystickId = SFMLEvent.JoyMove.JoystickId;
00182 Event->JoyMove.Axis = static_cast<sfJoyAxis>(SFMLEvent.JoyMove.Axis);
00183 Event->JoyMove.Position = SFMLEvent.JoyMove.Position;
00184 break;
00185
00186 default :
00187 break;
00188 }
00189
00190 return sfTrue;
00191 }
00192
00193
00197 void sfWindow_UseVerticalSync(sfWindow* Window, sfBool Enabled)
00198 {
00199 CSFML_CALL(Window, UseVerticalSync(Enabled == sfTrue))
00200 }
00201
00202
00206 void sfWindow_ShowMouseCursor(sfWindow* Window, sfBool Show)
00207 {
00208 CSFML_CALL(Window, ShowMouseCursor(Show == sfTrue))
00209 }
00210
00211
00215 void sfWindow_SetCursorPosition(sfWindow* Window, unsigned int Left, unsigned int Top)
00216 {
00217 CSFML_CALL(Window, SetCursorPosition(Left, Top))
00218 }
00219
00220
00225 void sfWindow_SetPosition(sfWindow* Window, int Left, int Top)
00226 {
00227 CSFML_CALL(Window, SetPosition(Left, Top))
00228 }
00229
00230
00234 void sfWindow_Show(sfWindow* Window, sfBool State)
00235 {
00236 CSFML_CALL(Window, Show(State == sfTrue))
00237 }
00238
00239
00243 sfBool sfWindow_SetCurrent(sfWindow* Window)
00244 {
00245 CSFML_CALL_RETURN(Window, SetCurrent(), sfFalse)
00246 }
00247
00248
00252 void sfWindow_Display(sfWindow* Window)
00253 {
00254 CSFML_CALL(Window, Display())
00255 }
00256
00257
00261 sfInput* sfWindow_GetInput(sfWindow* Window)
00262 {
00263 CSFML_CHECK_RETURN(Window, NULL);
00264
00265 return &Window->Input;
00266 }
00267
00268
00272 void sfWindow_SetFramerateLimit(sfWindow* Window, unsigned int Limit)
00273 {
00274 CSFML_CALL(Window, SetFramerateLimit(Limit))
00275 }
00276
00277
00281 float sfWindow_GetFrameTime(sfWindow* Window)
00282 {
00283 CSFML_CALL_RETURN(Window, GetFrameTime(), 0.f)
00284 }
00285
00293 void sfWindow_SetJoystickThreshold(sfWindow* Window, float Threshold)
00294 {
00295 CSFML_CALL(Window, SetJoystickThreshold(Threshold))
00296 }