Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AppImplCocoaBasic.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012, The Cinder Project, All rights reserved.
3 
4  This code is intended for use with the Cinder C++ library: http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 #include "cinder/gl/gl.h" // necessary to give GLee the jump on Cocoa.h
25 
26 #import <Cocoa/Cocoa.h>
27 
28 #import "cinder/app/AppBasic.h"
30 #import "cinder/Stream.h"
31 #import "cinder/Display.h"
32 
33 #include "cinder/app/TouchEvent.h"
34 
35 #include <list>
36 
37 @class CinderWindow; // inherits from NSWindow
39 
40 @interface AppImplCocoaBasic : NSObject <NSApplicationDelegate,NSWindowDelegate> {
41  @public
42  NSTimer *mAnimationTimer;
44 
47  float mFrameRate;
48 
49  NSMutableArray *mWindows;
51 }
52 
53 @property(retain, nonatomic) NSMutableArray *windows;
54 
55 - (id)init:(cinder::app::AppBasic*)aApp;
56 - (void)setApplicationMenu: (NSString*) applicationName;
57 - (void)startAnimationTimer;
58 - (void)applicationWillTerminate:(NSNotification *)notification;
59 - (void)applicationDidBecomeActive:(NSNotification *)notification;
60 - (void)applicationWillResignActive:(NSNotification *)notification;
61 - (void)quit;
62 
63 - (cinder::app::WindowRef)createWindow:(cinder::app::Window::Format)format;
64 
65 - (float)getFrameRate;
66 - (void)setFrameRate:(float)aFrameRate;
68 - (bool)isFrameRateEnabled;
69 - (std::string)getAppPath;
70 - (void)quit;
71 
72 - (cinder::app::RendererRef)findSharedRenderer:(cinder::app::RendererRef)match;
73 - (cinder::app::WindowRef)getWindow;
74 - (cinder::app::WindowRef)getForegroundWindow;
75 - (size_t)getNumWindows;
76 - (cinder::app::WindowRef)getWindowIndex:(size_t)index;
77 - (void)setActiveWindow:(WindowImplBasicCocoa*)win;
78 - (WindowImplBasicCocoa*)findWindowImpl:(NSWindow*)window;
79 
80 @end
81 
83 
84 @interface WindowImplBasicCocoa : NSObject<NSWindowDelegate,CinderViewDelegate,WindowImplCocoa> {
85  @public
87  NSWindow *mWin;
93 }
94 
95 
96 // WindowImplCocoa methods
97 - (void)dealloc;
98 - (BOOL)isFullScreen;
99 - (void)setFullScreen:(BOOL)fullScreen options:(const cinder::app::FullScreenOptions *)options;
100 - (cinder::Vec2i)getSize;
101 - (void)setSize:(cinder::Vec2i)size;
102 - (cinder::Vec2i)getPos;
103 - (float)getContentScale;
104 - (void)setPos:(cinder::Vec2i)pos;
105 - (float)getContentScale;
106 - (void)close;
107 - (NSString *)getTitle;
108 - (void)setTitle:(NSString *)title;
109 - (BOOL)isBorderless;
110 - (void)setBorderless:(BOOL)borderless;
111 - (bool)isAlwaysOnTop;
112 - (void)setAlwaysOnTop:(bool)alwaysOnTop;
113 - (void)hide;
114 - (void)show;
115 - (BOOL)isHidden;
116 - (cinder::DisplayRef)getDisplay;
117 - (cinder::app::RendererRef)getRenderer;
118 - (void*)getNative;
119 
120 - (void)windowMovedNotification:(NSNotification*)inNotification;
121 - (void)windowWillCloseNotification:(NSNotification*)inNotification;
122 
123 // CinderViewDelegate methods
124 - (void)resize;
125 - (void)draw;
126 - (void)mouseDown:(cinder::app::MouseEvent*)event;
127 - (void)mouseDrag:(cinder::app::MouseEvent*)event;
128 - (void)mouseUp:(cinder::app::MouseEvent*)event;
129 - (void)mouseMove:(cinder::app::MouseEvent*)event;
130 - (void)mouseWheel:(cinder::app::MouseEvent*)event;
131 - (void)keyDown:(cinder::app::KeyEvent*)event;
132 - (void)keyUp:(cinder::app::KeyEvent*)event;
133 - (void)touchesBegan:(cinder::app::TouchEvent*)event;
134 - (void)touchesMoved:(cinder::app::TouchEvent*)event;
135 - (void)touchesEnded:(cinder::app::TouchEvent*)event;
136 - (const std::vector<cinder::app::TouchEvent::Touch>&)getActiveTouches;
137 - (void)fileDrop:(cinder::app::FileDropEvent*)event;
138 - (cinder::app::WindowRef)getWindowRef;
139 
140 + (WindowImplBasicCocoa*)instantiate:(cinder::app::Window::Format)winFormat withAppImpl:(AppImplCocoaBasic*)appImpl withRetina:(BOOL)retinaEnabled;
141 
142 @end
NSString * getTitle()
Definition: AppCocoaTouch.mm:1005
virtual void quit()
Ceases execution of the application.
Definition: AppBasic.cpp:271
void hide()
Definition: AppCocoaTouch.mm:1028
void * getNative()
Definition: AppCocoaTouch.mm:1051
BOOL isAlwaysOnTop()
Definition: AppCocoaTouch.mm:1019
void dealloc()
Definition: AppCocoaTouch.mm:741
void close()
Definition: AppCocoaTouch.mm:1001
virtual bool isFrameRateEnabled() const
Returns whether frameRate limiting is enabled.
Definition: AppBasic.cpp:187
float getContentScale()
Definition: AppCocoaTouch.mm:996
BOOL isHidden()
Definition: AppCocoaTouch.mm:1036
typedef void(APIENTRYP GLEEPFNGLBLENDCOLORPROC)(GLclampf red
Definition: AppImplCocoaBasic.h:84
BOOL isFullScreen()
Definition: AppCocoaTouch.mm:969
AppBasic()
Definition: AppBasic.cpp:45
cinder::Vec2i mSize
Definition: AppImplCocoaBasic.h:91
std::shared_ptr< Window > WindowRef
Definition: Event.h:49
virtual void disableFrameRate()
Disables frameRate limiting.
Definition: AppBasic.cpp:178
NSTimer * mAnimationTimer
Definition: AppImplCocoaBasic.h:42
NSMutableArray * mWindows
Definition: AppImplCocoaBasic.h:49
cinder::Vec2i mPos
Definition: AppImplCocoaBasic.h:91
BOOL mNeedsUpdate
Definition: AppImplCocoaBasic.h:45
float mFrameRate
Definition: AppImplCocoaBasic.h:47
cinder::app::WindowRef mWindowRef
Definition: AppImplCocoaBasic.h:89
BOOL isBorderless()
Definition: AppCocoaTouch.mm:1010
void resize()
Definition: AppCocoaTouch.mm:1075
BOOL mBorderless
Definition: AppImplCocoaBasic.h:92
std::shared_ptr< class Renderer > RendererRef
Definition: Renderer.h:85
void setFrameRate(float frameRate)
Sets the maximum frame-rate the active App will attempt to maintain.
Definition: App.h:603
void show()
Definition: AppCocoaTouch.mm:1032
Definition: AppBasic.h:49
BOOL mAlwaysOnTop
Definition: AppImplCocoaBasic.h:92
cinder::DisplayRef mDisplay
Definition: AppImplCocoaBasic.h:90
AppImplCocoaBasic * mAppImpl
Definition: AppImplCocoaBasic.h:86
std::shared_ptr< class Display > DisplayRef
Definition: Display.h:53
NSWindow * mWin
Definition: AppImplCocoaBasic.h:87
GLXDrawable draw
Definition: GLee.h:16766
Definition: AppImplCocoaBasic.h:40
size_t getNumWindows()
Returns the number of Windows the app has open.
Definition: App.h:572
class cinder::app::AppBasic * mApp
Definition: AppImplCocoaBasic.h:43
GLuint id
Definition: GLee.h:2035
Definition: CinderView.h:36
BOOL mFrameRateEnabled
Definition: AppImplCocoaBasic.h:46
BOOL mHidden
Definition: AppImplCocoaBasic.h:92
float getFrameRate()
Returns the maximum frame-rate the active App will attempt to maintain.
Definition: App.h:601
Definition: CinderView.h:54
BOOL mResizable
Definition: AppImplCocoaBasic.h:92
CinderView * mCinderView
Definition: AppImplCocoaBasic.h:88
Vec2< int > Vec2i
Definition: Vector.h:1313
WindowImplBasicCocoa * mActiveWindow
Definition: AppImplCocoaBasic.h:50
void setFullScreen(bool fullScreen=true)
Sets whether the active App is in full-screen mode based on fullScreen.
Definition: App.h:607