Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #pragma once
00024
00025 #include "cinder/Cinder.h"
00026 #include "cinder/gl/gl.h"
00027 #include "cinder/app/App.h"
00028
00029 #if defined( CINDER_MAC )
00030 #ifdef __OBJC__
00031 @class AppImplCocoaScreenSaver;
00032 #else
00033 class AppImplCocoaScreenSaver;
00034 #endif
00035 #elif defined( CINDER_MSW )
00036 #include "cinder/app/AppImplMswScreenSaver.h"
00037 #include <windows.h>
00038 #undef min
00039 #undef max
00040 #include <ScrnSave.h>
00041 #endif
00042
00043
00044 namespace cinder { namespace app {
00045
00046 class AppScreenSaver : public App {
00047 public:
00048 class Settings : public App::Settings {
00049 public:
00050 Settings() : App::Settings() {}
00051 };
00052
00053 void launch( const char *title, int argc, char * const argv[] ) { }
00054
00055 virtual void prepareSettings( Settings *settings ) {}
00056 const Settings& getSettings() const { return mSettings; }
00057
00059 virtual int getWindowWidth() const;
00061 void setWindowWidth( int windowWidth ) {}
00063 virtual int getWindowHeight() const;
00065 void setWindowHeight( int windowHeight ) {}
00067 void setWindowSize( int windowWidth, int windowHeight ) {}
00068
00070 virtual float getFrameRate() const;
00072 virtual void setFrameRate( float frameRate );
00074 virtual bool isFullScreen() const;
00076 virtual void setFullScreen( bool fullScreen ) {}
00077
00079 virtual void quit() {}
00080
00081 virtual fs::path getAppPath();
00082
00083 #if defined( CINDER_MAC )
00084 static void executeLaunch( AppScreenSaver *app, class Renderer *renderer, const char *title ) { sInstance = app; App::executeLaunch( app, renderer, title, 0, 0 ); }
00085 #elif defined( CINDER_MSW )
00086 static void executeLaunch( AppScreenSaver *app, class Renderer *renderer, const char *title, ::HWND hwnd );
00087 #endif
00088
00089 #if defined( CINDER_MAC )
00090 void privateSetImpl__( void *impl ) { mImpl = reinterpret_cast<AppImplCocoaScreenSaver*>( impl ); }
00091 #elif defined( CINDER_MSW )
00092 void launch( ::HWND hwnd );
00093 virtual bool getsWindowsPaintEvents() { return false; }
00094 class AppImplMswScreenSaver* getImpl() { return mImpl; }
00095 #endif
00096
00097 virtual bool receivesEvents() const { return false; }
00098
00099 private:
00100 static AppScreenSaver *sInstance;
00101 #if defined( CINDER_MAC )
00102 AppImplCocoaScreenSaver *mImpl;
00103 #elif defined( CINDER_MSW )
00104 class AppImplMswScreenSaver *mImpl;
00105 #endif
00106 Settings mSettings;
00107 };
00108
00109 } }
00110
00111 #if defined( CINDER_MAC )
00112 extern "C" cinder::app::AppScreenSaver* ScreenSaverFactoryMethod( void *impl );
00113 #define CINDER_APP_SCREENSAVER( APP, RENDERER ) \
00114 extern "C" { \
00115 cinder::app::AppScreenSaver* ScreenSaverFactoryMethod( void *impl ) { \
00116 cinder::app::AppScreenSaver *app = new APP; \
00117 app->privateSetImpl__( impl ); \
00118 cinder::app::AppScreenSaver::executeLaunch( app, new RENDERER, #APP ); \
00119 return app; \
00120 } \
00121 }
00122 #elif defined( CINDER_MSW )
00123 #define CINDER_APP_SCREENSAVER( APP, RENDERER ) \
00124 cinder::app::AppScreenSaver *sScreenSaverMswInstance; \
00125 extern "C" LRESULT WINAPI ScreenSaverProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { \
00126 switch( message ) { \
00127 case WM_CREATE: \
00128 sScreenSaverMswInstance = new APP; \
00129 cinder::app::AppScreenSaver::executeLaunch( sScreenSaverMswInstance, new RENDERER, #APP, hWnd ); return 0; break; \
00130 default: if( sScreenSaverMswInstance ) return sScreenSaverMswInstance->getImpl()->eventHandler( hWnd, message, wParam, lParam ); \
00131 else return DefScreenSaverProc( hWnd, message, wParam, lParam ); \
00132 } \
00133 } \
00134 extern "C" BOOL WINAPI ScreenSaverConfigureDialog( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { return FALSE; } \
00135 extern "C" BOOL WINAPI RegisterDialogClasses(HANDLE hInst) { return TRUE; }
00136 #endif