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 #include <ScrnSave.h>
00039 #endif
00040
00041
00042 namespace cinder { namespace app {
00043
00044 class AppScreenSaver : public App {
00045 public:
00046 class Settings : public App::Settings {
00047 public:
00048 Settings() : App::Settings() {}
00049 };
00050
00051 void launch( const char *title, int argc, char * const argv[] ) { }
00052
00053 virtual void prepareSettings( Settings *settings ) {}
00054 const Settings& getSettings() const { return mSettings; }
00055
00057 virtual int getWindowWidth() const;
00059 void setWindowWidth( int windowWidth ) {}
00061 virtual int getWindowHeight() const;
00063 void setWindowHeight( int windowHeight ) {}
00065 void setWindowSize( int windowWidth, int windowHeight ) {}
00066
00068 virtual float getFrameRate() const;
00070 virtual void setFrameRate( float frameRate );
00072 virtual bool isFullScreen() const;
00074 virtual void setFullScreen( bool fullScreen ) {}
00075
00077 virtual void quit() {}
00078
00079 virtual std::string getAppPath();
00080
00081 #if defined( CINDER_MAC )
00082 static void executeLaunch( AppScreenSaver *app, class Renderer *renderer, const char *title ) { sInstance = app; App::executeLaunch( app, renderer, title, 0, 0 ); }
00083 #elif defined( CINDER_MSW )
00084 static void executeLaunch( AppScreenSaver *app, class Renderer *renderer, const char *title, ::HWND hwnd );
00085 #endif
00086
00087 #if defined( CINDER_MAC )
00088 void privateSetImpl__( void *impl ) { mImpl = reinterpret_cast<AppImplCocoaScreenSaver*>( impl ); }
00089 #elif defined( CINDER_MSW )
00090 void launch( ::HWND hwnd );
00091 virtual bool getsWindowsPaintEvents() { return false; }
00092 class AppImplMswScreenSaver* getImpl() { return mImpl; }
00093 #endif
00094
00095 virtual bool receivesEvents() const { return false; }
00096
00097 private:
00098 static AppScreenSaver *sInstance;
00099 #if defined( CINDER_MAC )
00100 AppImplCocoaScreenSaver *mImpl;
00101 #elif defined( CINDER_MSW )
00102 class AppImplMswScreenSaver *mImpl;
00103 #endif
00104 Settings mSettings;
00105 };
00106
00107 } }
00108
00109 #if defined( CINDER_MAC )
00110 extern "C" cinder::app::AppScreenSaver* ScreenSaverFactoryMethod( void *impl );
00111 #define CINDER_APP_SCREENSAVER( APP, RENDERER ) \
00112 extern "C" { \
00113 cinder::app::AppScreenSaver* ScreenSaverFactoryMethod( void *impl ) { \
00114 cinder::app::AppScreenSaver *app = new APP; \
00115 app->privateSetImpl__( impl ); \
00116 cinder::app::AppScreenSaver::executeLaunch( app, new RENDERER, #APP ); \
00117 return app; \
00118 } \
00119 }
00120 #elif defined( CINDER_MSW )
00121 #define CINDER_APP_SCREENSAVER( APP, RENDERER ) \
00122 cinder::app::AppScreenSaver *sScreenSaverMswInstance; \
00123 extern "C" LRESULT WINAPI ScreenSaverProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { \
00124 switch( message ) { \
00125 case WM_CREATE: \
00126 sScreenSaverMswInstance = new APP; \
00127 cinder::app::AppScreenSaver::executeLaunch( sScreenSaverMswInstance, new RENDERER, #APP, hWnd ); return 0; break; \
00128 default: if( sScreenSaverMswInstance ) return sScreenSaverMswInstance->getImpl()->eventHandler( hWnd, message, wParam, lParam ); \
00129 else return DefScreenSaverProc( hWnd, message, wParam, lParam ); \
00130 } \
00131 } \
00132 extern "C" BOOL WINAPI ScreenSaverConfigureDialog( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { return FALSE; } \
00133 extern "C" BOOL WINAPI RegisterDialogClasses(HANDLE hInst) { return TRUE; }
00134 #endif