Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

sdlmm_display.cpp

Go to the documentation of this file.
00001 /*
00002  * SDLmm - a C++ wrapper for SDL and related libraries
00003  * Copyright  2001 David Hedbor <david@hedbor.org>
00004  * 
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  */
00020 
00021 #include "sdlmm_config.h"
00022 
00023 #include <SDL.h>
00024 #include "sdlmm_global.h"
00025 #include "sdlmm_display.h"
00026 
00027 // The SDLmm::Display class.
00028 // This is the main video display surface, based on SDLmm::BaseSurface
00029 
00030 namespace SDLmm {
00031   // Update the screen
00032 
00033   Display& Display::GetDisplay()
00034   {
00035       static Display d;
00036       // In case we setup the display with another method, like using
00037       // ParaGUI or what not.
00038       if(!d.me) d.me = SDL_GetVideoSurface();
00039       return d;
00040   }
00041 
00042   void Display::UpdateRect(Sint32 x, Sint32 y, Sint32 w, Sint32 h) {
00043     SDL_UpdateRect(me, x, y, w, h);
00044   }     
00045   
00046   void Display::UpdateRect(SDL_Rect& rect) {
00047     SDL_UpdateRect(me, rect.x, rect.y, rect.w, rect.h);
00048   }
00049   
00050   void Display::UpdateRects(int numrects, SDL_Rect *rects) {
00051     SDL_UpdateRects(me, numrects, rects);
00052   }
00053 
00054   void Display::SetCaption(const char *title, const char *icon) {
00055     SDL_WM_SetCaption(title, icon);
00056   }
00057   
00058   void Display::SetCaption(const std::string& title, 
00059                                 const std::string& icon) {
00060     SDL_WM_SetCaption(title.c_str(), icon.c_str());
00061   }
00062   
00063   void Display::GetCaption(char **title, char **icon) {
00064     SDL_WM_GetCaption(title, icon);
00065   }
00066   
00067   void Display::GetCaption(std::string &title, std::string &icon) {
00068     char *_title, *_icon;
00069     SDL_WM_GetCaption(&_title, &_icon);
00070     title = _title;
00071     icon  = _icon;
00072   }
00073   
00074   void Display::SetIcon(BaseSurface& icon, Uint8 *mask) {
00075     SDL_WM_SetIcon(icon.GetSurface(), mask);
00076   }
00077   
00078   bool Display::Iconify() {
00079     return SDL_WM_IconifyWindow() != 0;
00080   }
00081   
00082   bool Display::ToggleFullScreen() {
00083     return SDL_WM_ToggleFullScreen(me) != 0;
00084   }
00085   
00086   SDL_GrabMode Display::GrabInput(SDL_GrabMode mode) {
00087     return SDL_WM_GrabInput(mode);
00088   }
00089 
00090   bool Display::SetVideoMode(int w, int h, int bpp, Uint32 flags) {
00091     SDL_Surface *tmp = SDL_SetVideoMode(w, h, bpp, flags);
00092     if(!tmp) return false;
00093     me = tmp;
00094     return true;
00095   }
00096   
00097   // Video mode stuff
00098   int Display::VideoModeOK(int w, int h, int bpp, Uint32 flags) {
00099     return SDL_VideoModeOK(w, h, bpp, flags);
00100   }
00101   
00102   SDL_Rect **Display::ListModes(SDL_PixelFormat *format, Uint32 flags) {
00103     return SDL_ListModes(format, flags);
00104   }
00105 
00106   bool Display::Init() {
00107     Uint32 wasinit = SDL_WasInit(SDL_INIT_EVERYTHING);
00108     bool init_success(true);
00109     if(!wasinit) {
00110       init_success = SDL_Init(SDL_INIT_VIDEO) == 0;
00111     } else if(!(wasinit & SDL_INIT_VIDEO)) {
00112       init_success = SDL_InitSubSystem(SDL_INIT_VIDEO) == 0;
00113     }
00114     return init_success;
00115   }
00116 
00117   void Display::Quit() {
00118     if(SDL_WasInit(SDL_INIT_VIDEO)) {
00119       SDL_QuitSubSystem(SDL_INIT_VIDEO);
00120     }
00121   }
00122 }
00123 
00124 

Documentation automatically generated by doxygen written by Dimitri van Heesch. Project hosted at
Hosted by SourceForge