Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

ApplicationEnding.h

Go to the documentation of this file.
00001 /*
00002 12345678901234567890123456789012345678901234567890123456789012345678901234567890
00003 */
00004 #ifndef Impala_Application_SDash_ApplicationEnding_h
00005 #define Impala_Application_SDash_ApplicationEnding_h
00006 
00007 #include <time.h>
00008 
00009 namespace Impala {
00010 namespace Application {
00011 namespace SDash {
00012 
00013 using namespace OglGui;
00014 
00015 class ApplicationEnding:   public Window
00016 {
00017 public:
00018     ApplicationEnding(Window *parent, strconst str,
00019                       int secs=10, ULONG col=0x00ff8080) :
00020         Window(parent, 0, 0, parent->W(), parent->H())
00021     {
00022         mParent = parent;
00023         Init(str, secs, col);
00024         ConnectTo(parent);
00025     }
00026 
00027     virtual void DisplayFunc()
00028     {
00029         if (!mInitialized)
00030         {
00031             mInitialized = true;
00032             mStartTime = clock();
00033         }
00034         clock_t cpuTime = clock();
00035         int elapsedTime = ((cpuTime-mStartTime) / CLOCKS_PER_SEC);
00036 
00037         int sW, sH;
00038         oglSys.GetTextExtent(mOglWnd, mEndingString.c_str(), &sW, &sH);
00039 
00040         oglSys.PosColPrintf(mOglWnd, W()/2-sW/2, H()/2, oglWHITE, "%s %d seconds",
00041                             mEndingString.c_str(), mSeconds-elapsedTime);
00042         if (elapsedTime >= mSeconds)
00043         {
00044             delete mParent;
00045             exit(0);
00046         }
00047 
00048         if (mOpacity < 220)
00049             mOpacity += 5;
00050         ChangeBackground();
00051 
00052         Window::DisplayFunc();
00053     }
00054 
00055     void ChangeBackground()
00056     {
00057         ULONG bg = GetBackground();
00058         bg = ((bg&0x00ffffff) | (mOpacity<<24));
00059         SetBackground(bg);
00060     }
00061 
00062     void StartApplicationEnding()
00063     {
00064         SetVisible(true);
00065     }
00066 
00067 private:
00068     void Init(strconst str, int seconds, ULONG col)
00069     {
00070         mInitialized = false;
00071         mEndingString = str;
00072         mSeconds = seconds;
00073         SetBackground(col);
00074         SetVisible(false);
00075         mOpacity = 0;
00076     }
00077 
00078     clock_t     mStartTime;
00079     std::string mEndingString;
00080     bool        mInitialized;
00081     int         mSeconds;
00082     ULONG       mOpacity;
00083     Window*     mParent;
00084 
00085 };
00086 
00087 }
00088 }
00089 }
00090 #endif

Generated on Fri Mar 19 09:30:37 2010 for ImpalaSrc by  doxygen 1.5.1