00001 /* 00002 Copyright (c) 2012, The Cinder Project, All rights reserved. 00003 00004 This code is intended for use with the Cinder C++ library: http://libcinder.org 00005 00006 Redistribution and use in source and binary forms, with or without modification, are permitted provided that 00007 the following conditions are met: 00008 00009 * Redistributions of source code must retain the above copyright notice, this list of conditions and 00010 the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 00012 the following disclaimer in the documentation and/or other materials provided with the distribution. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 00015 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00016 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00017 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00018 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00019 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00020 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00021 POSSIBILITY OF SUCH DAMAGE. 00022 */ 00023 00024 #pragma once 00025 00026 #include <windows.h> 00027 #undef min 00028 #undef max 00029 00030 #include "cinder/app/AppImplMsw.h" 00031 #include "cinder/app/AppImplMswRenderer.h" 00032 #include "cinder/Display.h" 00033 #include "cinder/app/Window.h" 00034 00035 namespace cinder { namespace app { 00036 00037 class WindowImplMswBasic; 00038 00039 class AppImplMswBasic : public AppImplMsw { 00040 public: 00041 AppImplMswBasic( class AppBasic *aApp ); 00042 void run(); 00043 00044 class AppBasic* getApp() { return mApp; } 00045 00046 void quit() { mShouldQuit = true; } 00047 00048 float setFrameRate( float aFrameRate ); 00049 void disableFrameRate(); 00050 bool isFrameRateEnabled() const; 00051 00052 size_t getNumWindows() const; 00053 WindowRef getWindowIndex( size_t index ); 00054 WindowRef getForegroundWindow() const; 00055 fs::path getAppPath() const; 00056 00057 void setupBlankingWindows( DisplayRef fullScreenDisplay ); 00058 void destroyBlankingWindows(); 00059 00060 private: 00061 void sleep( double seconds ); 00062 00063 WindowRef createWindow( Window::Format format ); 00064 virtual void closeWindow( class WindowImplMsw *windowImpl ) override; 00065 virtual void setForegroundWindow( WindowRef window ) override; 00066 00067 bool mShouldQuit; 00068 class AppBasic *mApp; 00069 00070 00071 HINSTANCE mInstance; 00072 double mNextFrameTime; 00073 bool mFrameRateEnabled; 00074 00075 std::list<class WindowImplMswBasic*> mWindows; 00076 std::list<BlankingWindowRef> mBlankingWindows; 00077 WindowRef mForegroundWindow; 00078 00079 friend LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); 00080 friend class AppBasic; 00081 }; 00082 00083 class WindowImplMswBasic : public WindowImplMsw { 00084 public: 00085 WindowImplMswBasic( const Window::Format &format, RendererRef sharedRenderer, AppImplMswBasic *appImpl ) 00086 : WindowImplMsw( format, sharedRenderer, appImpl ), mAppImplBasic( appImpl ) {} 00087 00088 virtual void WindowImplMswBasic::toggleFullScreen( const app::FullScreenOptions &options ); 00089 00090 protected: 00091 AppImplMswBasic *mAppImplBasic; 00092 friend AppImplMswBasic; 00093 }; 00094 00095 } } // namespace cinder::app