Add some comments to GfxMode / CurrentGfxModeGuard.

This commit is contained in:
David Capello 2010-09-17 23:28:05 -03:00
parent 955ec830cc
commit 7a099e23f9

View File

@ -19,6 +19,7 @@
#ifndef GFXMODE_H_INCLUDED #ifndef GFXMODE_H_INCLUDED
#define GFXMODE_H_INCLUDED #define GFXMODE_H_INCLUDED
// Holds settings about a graphics mode.
class GfxMode class GfxMode
{ {
public: public:
@ -46,19 +47,40 @@ private:
int m_scaling; int m_scaling;
}; };
// Tries a new graphics mode, and restores it back in the
// destructor. If the keep() method is used, the mode is not
// restored.
class CurrentGfxModeGuard class CurrentGfxModeGuard
{ {
public: public:
// Saves the current graphics mode as "the original" one.
CurrentGfxModeGuard(); CurrentGfxModeGuard();
// Restores the graphics mode to its original in case we have used
// tryGfxMode() and we did not call keep(). After calling keep(),
// this destructor will do just nothing.
~CurrentGfxModeGuard(); ~CurrentGfxModeGuard();
// Changes the current graphics mode. Returns true if the mode was
// changed successfully. If the function cannot change the new mode
// and cannot restore the original one, it finishes the program
// (with exit()).
bool tryGfxMode(const GfxMode& newMode); bool tryGfxMode(const GfxMode& newMode);
// Keeps the last graphics mode set with tryGfxMode(). Indicates
// that the destructor should not restore the graphics mode to the
// original one.
void keep(); void keep();
// It is the original graphics mode configured when the constructor
// of this class was called.
const GfxMode& getOriginal() const; const GfxMode& getOriginal() const;
private: private:
// The original gfx mode.
GfxMode m_oldMode; GfxMode m_oldMode;
// True if we should keep any mode set with tryGfxMode() method.
bool m_keep; bool m_keep;
}; };