include/cinder/app/AppImplCocoaBasic.h
Go to the documentation of this file.
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 #include "cinder/gl/gl.h" // necessary to give GLee the jump on Cocoa.h
00025 
00026 #import <Cocoa/Cocoa.h>
00027 
00028 #import "cinder/app/AppBasic.h"
00029 #import "cinder/app/CinderView.h"
00030 #import "cinder/Stream.h"
00031 #import "cinder/Display.h"
00032 
00033 #include "cinder/app/TouchEvent.h"
00034 
00035 #include <list>
00036 
00037 @class CinderWindow; // inherits from NSWindow
00038 @class WindowImplBasicCocoa;
00039 
00040 @interface AppImplCocoaBasic : NSObject <NSApplicationDelegate,NSWindowDelegate> {
00041   @public
00042     NSTimer                         *mAnimationTimer;
00043     class cinder::app::AppBasic     *mApp;
00044     
00045     BOOL                            mNeedsUpdate;
00046     BOOL                            mFrameRateEnabled;
00047     float                           mFrameRate;
00048     
00049     NSMutableArray                  *mWindows;
00050     WindowImplBasicCocoa            *mActiveWindow;
00051 }
00052 
00053 @property(retain, nonatomic) NSMutableArray *windows;
00054 
00055 - (id)init:(cinder::app::AppBasic*)aApp;
00056 - (void)setApplicationMenu: (NSString*) applicationName;
00057 - (void)startAnimationTimer;
00058 - (void)applicationWillTerminate:(NSNotification *)notification;
00059 - (void)quit;
00060 
00061 - (cinder::app::WindowRef)createWindow:(cinder::app::Window::Format)format;
00062 
00063 - (float)getFrameRate;
00064 - (void)setFrameRate:(float)aFrameRate;
00065 - (void)disableFrameRate;
00066 - (bool)isFrameRateEnabled;
00067 - (std::string)getAppPath;
00068 - (void)quit;
00069 
00070 - (cinder::app::RendererRef)findSharedRenderer:(cinder::app::RendererRef)match;
00071 - (cinder::app::WindowRef)getWindow;
00072 - (cinder::app::WindowRef)getForegroundWindow;
00073 - (size_t)getNumWindows;
00074 - (cinder::app::WindowRef)getWindowIndex:(size_t)index;
00075 - (void)setActiveWindow:(WindowImplBasicCocoa*)win;
00076 - (WindowImplBasicCocoa*)findWindowImpl:(NSWindow*)window;
00077 
00078 @end
00079 
00081 
00082 @interface WindowImplBasicCocoa : NSObject<NSWindowDelegate,CinderViewDelegate,WindowImplCocoa> {
00083   @public
00084     AppImplCocoaBasic                   *mAppImpl;
00085     NSWindow                            *mWin;
00086     CinderView                          *mCinderView;
00087     cinder::app::WindowRef              mWindowRef;
00088     cinder::DisplayRef                  mDisplay;
00089     cinder::Vec2i                       mSize, mPos;
00090     BOOL                                mResizable, mBorderless, mAlwaysOnTop, mHidden;
00091 }
00092 
00093 
00094 // WindowImplCocoa methods
00095 - (void)dealloc;
00096 - (BOOL)isFullScreen;
00097 - (void)setFullScreen:(BOOL)fullScreen options:(const cinder::app::FullScreenOptions *)options;
00098 - (cinder::Vec2i)getSize;
00099 - (void)setSize:(cinder::Vec2i)size;
00100 - (cinder::Vec2i)getPos;
00101 - (float)getContentScale;
00102 - (void)setPos:(cinder::Vec2i)pos;
00103 - (float)getContentScale;
00104 - (void)close;
00105 - (NSString *)getTitle;
00106 - (void)setTitle:(NSString *)title;
00107 - (BOOL)isBorderless;
00108 - (void)setBorderless:(BOOL)borderless;
00109 - (bool)isAlwaysOnTop;
00110 - (void)setAlwaysOnTop:(bool)alwaysOnTop;
00111 - (void)hide;
00112 - (void)show;
00113 - (BOOL)isHidden;
00114 - (cinder::DisplayRef)getDisplay;
00115 - (cinder::app::RendererRef)getRenderer;
00116 - (void*)getNative;
00117 
00118 - (void)windowMovedNotification:(NSNotification*)inNotification;
00119 - (void)windowWillCloseNotification:(NSNotification*)inNotification;
00120 
00121 // CinderViewDelegate methods
00122 - (void)resize;
00123 - (void)draw;
00124 - (void)mouseDown:(cinder::app::MouseEvent*)event;
00125 - (void)mouseDrag:(cinder::app::MouseEvent*)event;
00126 - (void)mouseUp:(cinder::app::MouseEvent*)event;
00127 - (void)mouseMove:(cinder::app::MouseEvent*)event;
00128 - (void)mouseWheel:(cinder::app::MouseEvent*)event;
00129 - (void)keyDown:(cinder::app::KeyEvent*)event;
00130 - (void)keyUp:(cinder::app::KeyEvent*)event;
00131 - (void)touchesBegan:(cinder::app::TouchEvent*)event;
00132 - (void)touchesMoved:(cinder::app::TouchEvent*)event;
00133 - (void)touchesEnded:(cinder::app::TouchEvent*)event;
00134 - (const std::vector<cinder::app::TouchEvent::Touch>&)getActiveTouches;
00135 - (void)fileDrop:(cinder::app::FileDropEvent*)event;
00136 - (cinder::app::WindowRef)getWindowRef;
00137 
00138 + (WindowImplBasicCocoa*)instantiate:(cinder::app::Window::Format)winFormat withAppImpl:(AppImplCocoaBasic*)appImpl withRetina:(BOOL)retinaEnabled;
00139 
00140 @end