# Cinder

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# include/cinder/app/AppCocoaTouch.h

Go to the documentation of this file.

    00001 /*
    00002  Copyright (c) 2010, The Barbarian Group
    00003  All rights reserved.
    00004
    00005  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
    00006  the following conditions are met:
    00007
    00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and
    00009     the following disclaimer.
    00010     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
    00011     the following disclaimer in the documentation and/or other materials provided with the distribution.
    00012
    00013  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
    00014  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
    00015  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
    00016  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
    00017  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    00018  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00019  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    00020  POSSIBILITY OF SUCH DAMAGE.
    00021 */
    00022
    00023 #pragma once
    00024
    00025 #include "cinder/App/App.h"
    00026 #include "cinder/cocoa/CinderCocoaTouch.h"
    00027
    00028 namespace cinder { namespace app {
    00029
    00030 struct AppCocoaTouchState;
    00031
    00032 class AppCocoaTouch : public App {
    00033   public:
    00034     class Settings : public App::Settings {
    00035       public:
    00036         Settings()
    00037             : App::Settings() {}
    00038     };
    00039
    00040     AppCocoaTouch();
    00041     virtual ~AppCocoaTouch() {}
    00042
    00044     virtual int     getWindowWidth() const;
    00046     virtual int     getWindowHeight() const;
    00048     void            setWindowWidth( int windowWidth ) {}
    00050     void            setWindowHeight( int windowHeight ) {}
    00052     void            setWindowSize( int windowWidth, int windowHeight ) {}
    00053
    00055     virtual float       getFrameRate() const;
    00057     virtual void        setFrameRate( float aFrameRate );
    00059     virtual bool        isFullScreen() const;
    00061     virtual void        setFullScreen( bool aFullScreen );
    00062
    00063     virtual double      getElapsedSeconds() const;
    00064
    00066     virtual std::string         getAppPath();
    00067
    00069     virtual void    quit();
    00070
    00072     static AppCocoaTouch*   get() { return sInstance; }
    00073
    00075     // These are called by application instantation macros and are only used in the launch process
    00076     static void     prepareLaunch() { App::prepareLaunch(); }
    00077     static void     executeLaunch( AppCocoaTouch *app, class Renderer *renderer, const char *title, int argc, char * const argv[] ) { sInstance = app; App::executeLaunch( app, renderer, title, argc, argv ); }
    00078     static void     cleanupLaunch() { App::cleanupLaunch(); }
    00079
    00080     virtual void    launch( const char *title, int argc, char * const argv[] );
    00082
    00083   private:
    00084     friend void     setupCocoaTouchWindow( AppCocoaTouch *app );
    00085
    00086     // The state is contained in a struct in order to avoid this .h needing to be compiled as Objective-C++
    00087     shared_ptr<AppCocoaTouchState>      mState;
    00088
    00089     static AppCocoaTouch    *sInstance;
    00090 };
    00091
    00092 } } // namespace cinder::app
    00093
    00094 #define CINDER_APP_COCOA_TOUCH( APP, RENDERER )                             \
    00095 int main( int argc, char *argv[] ) {                                        \
    00096     cinder::app::AppCocoaTouch::prepareLaunch();                            \
    00097     cinder::app::AppCocoaTouch *app = new APP;                              \
    00098     cinder::app::Renderer *ren = new RENDERER;                              \
    00099     cinder::app::AppCocoaTouch::executeLaunch( app, ren, #APP, argc, argv );\
    00100     cinder::app::AppCocoaTouch::cleanupLaunch();                            \
    00101     return 0;                                                               \
    00102 }