00001 // /////////////////////////////////////////////////////////////////////////// 00002 // xrb_screen.hpp by Victor Dods, created 2004/06/08 00003 // /////////////////////////////////////////////////////////////////////////// 00004 // Unless a different license was explicitly granted in writing by the 00005 // copyright holder (Victor Dods), this software is freely distributable under 00006 // the terms of the GNU General Public License, version 2. Any works deriving 00007 // from this work must also be released under the GNU GPL. See the included 00008 // file LICENSE for details. 00009 // /////////////////////////////////////////////////////////////////////////// 00010 00011 #if !defined(_XRB_SCREEN_HPP_) 00012 #define _XRB_SCREEN_HPP_ 00013 00014 #include "xrb.hpp" 00015 00016 #include "xrb_containerwidget.hpp" 00017 00018 namespace Xrb 00019 { 00020 00021 class EventQueue; 00022 00023 // The Screen class implements screen-specific drawing functionality 00024 // (i.e. setting resolution, coping with conversion from right-handed world 00025 // coordinates to left-handed screen coordinates, etc). It inherits from 00026 // Transform2, which serves as the view-to-screen transformation. 00027 // The Screen is post-translated. 00028 class Screen : public ContainerWidget 00029 { 00030 public: 00031 00032 virtual ~Screen (); 00033 00034 static Screen *Create ( 00035 ScreenCoord width, 00036 ScreenCoord height, 00037 Uint32 bit_depth, 00038 bool fullscreen); 00039 00040 SignalSender0 const *SenderQuitRequested () { return &m_sender_quit_requested; } 00041 00042 SignalReceiver0 const *ReceiverRequestQuit () { return &m_receiver_request_quit; } 00043 00044 bool IsQuitRequested () const { return m_is_quit_requested; } 00045 ScreenCoord SizeRatioBasis () const { return Min(Width(), Height()); } 00046 00047 // if the is-quit-requested flag is false, sets it to true and signals. 00048 void RequestQuit (); 00049 // draws the whole fucking thing. 00050 void Draw () const; 00051 00052 protected: 00053 00054 // protected constructor so that you must use Create 00055 Screen (); 00056 00057 // this calculates one frame, called by the game loop 00058 virtual void HandleFrame (); 00059 // processes an event, returning true if the event was captured, 00060 // otherwise it will pass the event to VirtualScreen::ProcessEvent() 00061 // and return that function's return value. 00062 virtual bool HandleEvent (Event const *e); 00063 00064 private: 00065 00066 // quit condition (maybe temporary) 00067 bool m_is_quit_requested; 00068 // the current video mode resolution 00069 ScreenCoordVector2 m_current_video_resolution; 00070 00071 SignalSender0 m_sender_quit_requested; 00072 00073 SignalReceiver0 m_receiver_request_quit; 00074 }; // end of class Screen 00075 00076 } // end of namespace Xrb 00077 00078 #endif // !defined(_XRB_SCREEN_HPP_) 00079