1 // Crimson Fields -- a game of tactical warfare
2 // Copyright (C) 2000-2007 Jens Granseuer
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
19 ///////////////////////////////////////////////////////////////
20 // view.h
21 ///////////////////////////////////////////////////////////////
22 
23 #ifndef _INCLUDE_VIEW_H
24 #define _INCLUDE_VIEW_H
25 
26 #include "SDL.h"
27 #include "window.h"
28 
29 typedef GUI_Status (*GUIEventFilter)( SDL_Event &event, Window *window );
30 
31 class View : public Surface {
32 public:
33   View( unsigned short w, unsigned short h, short bpp, unsigned long flags );
34   ~View( void );
35 
36   void SetVideoMode( unsigned short w, unsigned short h, short bpp,
37                      unsigned long flags );
38   void Update( void );
39   void Update( const Rect &rect );
40   void Refresh( void );
41   void Refresh( const Rect &refresh );
42   void AddWindow( Window *window );
43   void SelectWindow( Window *window );
44   Window *CloseWindow( Window *window );
45   void CloseAllWindows( void );
46 
DisableUpdates(void)47   void DisableUpdates( void ) { allow_updates = false; }
EnableUpdates(void)48   void EnableUpdates( void ) { allow_updates = true; }
49 
50   GUI_Status HandleEvents( void );
51   GUI_Status FetchEvent( SDL_Event &event );
52   GUI_Status PeekEvent( SDL_Event &event );
SetEventFilter(GUIEventFilter efilter)53   void SetEventFilter( GUIEventFilter efilter ) { filter = efilter; }
54   int ToggleFullScreen( void );
IsFullScreen(void)55   bool IsFullScreen( void ) const { return (s_surface->flags & SDL_FULLSCREEN) != 0; }
ScreenBPP(void)56   unsigned char ScreenBPP( void ) const { return s_surface->format->BitsPerPixel; }
57 
SetSmallFont(Font * font)58   void SetSmallFont( Font *font ) { sfont = font; }
SetLargeFont(Font * font)59   void SetLargeFont( Font *font ) { lfont = font; }
SmallFont(void)60   Font *SmallFont( void ) const { return sfont; }
LargeFont(void)61   Font *LargeFont( void ) const { return lfont; }
SetSystemIcons(Surface * icons)62   void SetSystemIcons( Surface *icons ) { delete sys_icons; sys_icons = icons; }
GetSystemIcons(void)63   Surface *GetSystemIcons( void ) const { return sys_icons; }
SetFGPen(const Color & fg)64   void SetFGPen( const Color &fg ) { colors[0] = fg; }
SetBGPen(const Color & bg)65   void SetBGPen( const Color &bg ) { colors[1] = bg; }
GetFGPen(void)66   const Color &GetFGPen( void ) const { return colors[0]; }
GetBGPen(void)67   const Color &GetBGPen( void ) const { return colors[1]; }
68 
69 private:
70   GUI_Status SystemFilter( const SDL_Event &event );
71 
72   List windows;
73   Font *sfont, *lfont;  // small and large fonts
74   bool allow_updates;
75 
76   Color colors[2];
77   Surface *sys_icons;
78 
79   GUIEventFilter filter;
80 };
81 
82 #endif	/* _INCLUDE_VIEW_H */
83 
84