Window.hpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 #ifndef GOSU_WINDOW_HPP
00005 #define GOSU_WINDOW_HPP
00006 
00007 #include <Gosu/Fwd.hpp>
00008 #include <Gosu/Platform.hpp>
00009 #include <Gosu/Input.hpp>
00010 #include <Gosu/TR1.hpp>
00011 #include <memory>
00012 #include <string>
00013 
00014 #ifdef GOSU_IS_WIN
00015 #ifndef NOMINMAX
00016 #define NOMINMAX
00017 #endif
00018 #include <windows.h>
00019 #endif
00020 
00021 namespace Gosu
00022 {
00028     class Window
00029     {
00030         struct Impl;
00031         const std::auto_ptr<Impl> pimpl;
00032     
00033     public:
00037         Window(unsigned width, unsigned height, bool fullscreen,
00038             double updateInterval = 16.666666);
00039         virtual ~Window();
00040 
00041         std::wstring caption() const;
00042         void setCaption(const std::wstring& caption);
00043         
00044         double updateInterval() const;
00045 
00047         void show();
00049         void close();
00050 
00053         virtual void update() {}
00056         virtual void draw() {}
00057         
00062         virtual bool needsRedraw() const { return true; }
00063 
00066         virtual bool needsCursor() const { return false; }
00067         
00071         virtual void loseFocus() {}
00072         
00075         virtual void releaseMemory() {}
00076         
00079         virtual void buttonDown(Gosu::Button) {}
00081         virtual void buttonUp(Gosu::Button) {}
00082         
00083         // Ignore when SWIG is wrapping this class for Ruby/Gosu.
00084         #ifndef SWIG
00085         
00086         const Graphics& graphics() const;
00087         Graphics& graphics();
00088         
00089         const Input& input() const;
00090         Input& input();
00091         
00092         #ifdef GOSU_IS_WIN
00093         // Only on Windows, used for integrating with GUI toolkits.
00094         HWND handle() const;
00095         virtual LRESULT handleMessage(UINT message, WPARAM wparam,
00096             LPARAM lparam);
00097         #endif
00098         
00099         #ifdef GOSU_IS_UNIX
00100         // Context for creating shared contexts.
00101         // Only on Unices (so far).
00102         typedef std::tr1::shared_ptr<std::tr1::function<void()> > SharedContext;
00103         SharedContext createSharedContext();
00104         #endif
00105         
00106         #ifdef GOSU_IS_IPHONE
00107         // iPhone-only callbacks for touch events.
00108         // Note that it does not hurt to override them even if you compile
00109         // for another platform; if you don't specify "virtual" the code
00110         // should even be stripped away cleanly.
00111         virtual void touchBegan(Touch touch) {}
00112         virtual void touchMoved(Touch touch) {}
00113         virtual void touchEnded(Touch touch) {}
00114         #endif        
00115         
00116         const Audio& audio() const;
00117         Audio& audio();
00118 
00119         #endif
00120     };
00121 }
00122 
00123 #endif