40 namespace cinder {
namespace app {
43 struct FullScreenOptions;
44 typedef std::shared_ptr<Window>
WindowRef;
48 #if defined( CINDER_COCOA ) && defined( __OBJC__ )
49 #import <Foundation/Foundation.h>
50 #if defined( CINDER_COCOA_TOUCH )
51 @class UIViewController;
54 @protocol WindowImplCocoa
57 - (
void)
setFullScreen:(BOOL)fullScreen options:(const cinder::app::FullScreenOptions *)options;
58 - (cinder::Vec2i)getSize;
60 - (cinder::Vec2i)getPos;
65 - (
void)setTitle:(NSString *)title;
67 - (
void)setBorderless:(BOOL)borderless;
69 - (
void)setAlwaysOnTop:(BOOL)alwaysOnTop;
73 - (cinder::DisplayRef)getDisplay;
74 - (cinder::app::RendererRef)getRenderer;
75 - (const std::vector<cinder::app::TouchEvent::Touch>&)getActiveTouches;
77 #if defined( CINDER_COCOA_TOUCH )
81 #elif defined( CINDER_COCOA )
82 class WindowImplCocoa;
83 #if defined( CINDER_COCOA_TOUCH )
84 class UIViewController;
86 #elif defined( CINDER_WINRT )
87 namespace cinder {
namespace app {
88 class WindowImplWinRT;
90 #elif defined( CINDER_MSW )
91 namespace cinder {
namespace app {
96 namespace cinder {
namespace app {
98 typedef signals::signal<void(MouseEvent&),EventCombiner<MouseEvent> >
EventSignalMouse;
99 typedef signals::signal<void(TouchEvent&),EventCombiner<TouchEvent> >
EventSignalTouch;
100 typedef signals::signal<void(KeyEvent&),EventCombiner<KeyEvent> >
EventSignalKey;
102 typedef signals::signal<void()> EventSignalWindow;
106 virtual const char * what()
const throw() {
return "Invalid Window"; }
111 FullScreenOptions() : mKioskMode( true ), mSecondaryDisplayBlanking( false ), mExclusive( false )
134 bool mKioskMode, mSecondaryDisplayBlanking, mExclusive;
137 class Window :
public std::enable_shared_from_this<Window> {
143 mResizable( true ), mBorderless( false ), mAlwaysOnTop( false ), mFullScreenButtonEnabled( false ),
144 mTitleSpecified( false ), mTitle(
"" )
145 #if defined( CINDER_COCOA_TOUCH )
146 , mRootViewController( NULL )
182 void setPos( int32_t
x, int32_t
y ) { mPos =
Vec2i( x, y ); mPosSpecified =
true; }
186 Format&
pos( int32_t
x, int32_t
y ) { mPos =
Vec2i( x, y ); mPosSpecified =
true;
return *
this; }
199 #if defined( CINDER_COCOA_TOUCH )
200 UIViewController* getRootViewController()
const {
return mRootViewController;}
203 void setRootViewController( UIViewController *
v ) { mRootViewController =
v; }
205 Format& rootViewController( UIViewController *
v ) { mRootViewController =
v;
return *
this; }
252 bool mResizable, mBorderless, mAlwaysOnTop, mFullScreenButtonEnabled;
254 bool mTitleSpecified;
256 #if defined( CINDER_COCOA_TOUCH )
257 UIViewController *mRootViewController;
343 #if defined( CINDER_COCOA_TOUCH )
346 #elif defined( CINDER_WINRT )
347 DX_WINDOW_TYPE getNativeCoreWindow();
349 #if defined( CINDER_MSW )
350 HDC getDc()
const {
return getRenderer()->getDc(); }
356 template<
typename T,
typename Y>
361 template<
typename T,
typename Y>
366 template<
typename T,
typename Y>
371 template<
typename T,
typename Y>
376 template<
typename T,
typename Y>
381 template<
typename T,
typename Y>
386 template<
typename T,
typename Y>
391 template<
typename T,
typename Y>
399 template<
typename T,
typename Y>
404 template<
typename T,
typename Y>
410 template<
typename T,
typename Y>
415 template<
typename T,
typename Y>
420 template<
typename T,
typename Y>
425 template<
typename T,
typename Y>
430 template<
typename T,
typename Y>
437 template<
typename T,
typename Y>
442 template<
typename T,
typename Y>
458 #if defined( CINDER_COCOA ) && defined( __OBJC__ )
460 #elif defined( CINDER_MSW )
462 #elif defined( CINDER_WINRT )
465 static WindowRef privateCreate__( WindowImplCocoa *impl,
App *app )
469 result->setImpl( impl );
470 result->setApp( app );
488 #if defined( CINDER_COCOA )
489 #if defined( __OBJC__ )
492 void setImpl( WindowImplCocoa *impl ) { mImpl = impl; }
494 #elif defined( CINDER_MSW )
495 void setImpl( WindowImplMsw *impl ) { mImpl = impl; }
496 #elif defined( CINDER_WINRT )
497 void setImpl( WindowImplWinRT *impl ) { mImpl = impl; }
510 #if defined( CINDER_COCOA )
511 #if defined( __OBJC__ )
514 WindowImplCocoa *mImpl;
516 #elif defined( CINDER_MSW )
518 #elif defined( CINDER_WINRT )
void setSize(int32_t width, int32_t height)
Sets the size of the Window to ( width, height ) measured in points.
Definition: Window.h:276
void emitTouchesMoved(TouchEvent *event)
Definition: Window.cpp:356
GLdouble GLdouble GLdouble r
Definition: GLee.h:1474
NSString * getTitle()
Definition: AppCocoaTouch.mm:1005
int32_t getHeight() const
Returns the height of the Window in points.
Definition: Window.h:268
EventSignalMouse mSignalMouseMove
Definition: Window.h:504
void emitKeyUp(KeyEvent *event)
Definition: Window.cpp:397
void setBorderless(bool borderless=true)
Sets whether the window has a border (chrome/frame)
Definition: Window.cpp:167
EventSignalWindow & getSignalClose()
Returns the Signal emitted whenever a Window is closing. The WindowRef parameter is still valid at th...
Definition: Window.h:434
void emitMouseMove(MouseEvent *event)
Definition: Window.cpp:338
GLenum GLint GLint y
Definition: GLee.h:987
void emitTouchesEnded(TouchEvent *event)
Definition: Window.cpp:365
Vec2f toPixels(Vec2f s) const
Returns a Vec2f mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:295
void hide()
Definition: AppCocoaTouch.mm:1028
void emitKeyDown(KeyEvent *event)
Definition: Window.cpp:388
GLdouble GLdouble GLdouble GLdouble top
Definition: GLee.h:13559
void * getNative()
Definition: AppCocoaTouch.mm:1051
Vec2i toPoints(Vec2i s) const
Returns a Vec2i mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:307
void * getNative() const
Returns the associated NSView on Mac OS X, UIView on iOS, or HWND on MSW.
Definition: Window.cpp:255
EventSignalTouch & getSignalTouchesEnded()
Definition: Window.h:389
FullScreenOptions & kioskMode(bool enable=true)
(OS X only) Sets the fullscreen mode to 'kiosk', which means don't use the 10.7 way of animating to f...
Definition: Window.h:115
bool isBorderless() const
Returns whether the window has a border (chrome/frame)
Definition: Window.cpp:156
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: dx.h:198
signals::connection connectMouseWheel(T fn, Y *inst)
Definition: Window.h:377
Represents a mouse event.
Definition: MouseEvent.h:34
BOOL isAlwaysOnTop()
Definition: AppCocoaTouch.mm:1019
EventSignalMouse mSignalMouseWheel
Definition: Window.h:504
EventSignalMouse mSignalMouseUp
Definition: Window.h:504
Vec2< float > Vec2f
Definition: Vector.h:1314
signals::connection connectMouseDown(T fn, Y *inst)
Definition: Window.h:357
GLsizei const GLchar ** string
Definition: GLee.h:2427
void setUserData(T *userData)
Sets the window-specific data associated with this Window. The variable is deleted upon destruction o...
Definition: Window.h:450
Rectf toPixels(const Rectf &a) const
Returns a Rectf mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:301
int32_t y2
Definition: Area.h:101
void close()
Definition: AppCocoaTouch.mm:1001
FullScreenOptions & display(DisplayRef display)
Sets the display which will be used in fullscreen mode. Defaults to the Window's current Display...
Definition: Window.h:121
static DisplayRef getMainDisplay()
Returns the system's primary display.
Definition: Display.cpp:302
Options passed when entering fullscreen.
Definition: Window.h:110
T * getUserData()
Returns the window-specific data associated with this Window.
Definition: Window.h:447
EventSignalMouse & getSignalMouseDrag()
Definition: Window.h:359
Vec2f getCenter() const
Returns the center of the Window in its own coordinate system measured in points. ...
Definition: Window.h:286
void setFullScreen(bool fullScreen=true, const FullScreenOptions &options=FullScreenOptions())
Sets the Window to be full-screen or not.
Definition: Window.cpp:48
float getContentScale()
Definition: AppCocoaTouch.mm:996
GLenum GLsizei width
Definition: GLee.h:969
void setApp(App *app)
Definition: Window.h:486
Area getBounds() const
Returns the bounding Area of the Window in points: [0,0]-(width,height)
Definition: Window.h:272
bool isAlwaysOnTop() const
Returns whether the window always remains above all other windows.
Definition: Window.cpp:178
signals::connection connectResize(T fn, Y *inst)
Definition: Window.h:426
BOOL isHidden()
Definition: AppCocoaTouch.mm:1036
static Vec2< int > zero()
Definition: Vector.h:295
signals::connection connectMove(T fn, Y *inst)
Definition: Window.h:421
signals::connection connectClose(T fn, Y *inst)
Definition: Window.h:438
T x
Definition: Vector.h:71
EventSignalWindow mSignalClose
Definition: Window.h:507
EventSignalWindow mSignalDisplayChange
Definition: Window.h:507
EventSignalWindow mSignalResize
Definition: Window.h:507
EventSignalWindow mSignalPostDraw
Definition: Window.h:507
typedef void(APIENTRYP GLEEPFNGLBLENDCOLORPROC)(GLclampf red
bool isValid() const
Returns whether this Window is valid. false means it should no longer be used (neither read nor write...
Definition: Window.h:453
signals::connection connectPostDraw(T fn, Y *inst)
Definition: Window.h:416
EventSignalTouch mSignalTouchesEnded
Definition: Window.h:505
GLuint res
Definition: GLee.h:10843
signals::connection connectMouseUp(T fn, Y *inst)
Definition: Window.h:367
BOOL isFullScreen()
Definition: AppCocoaTouch.mm:969
Rectf toPoints(const Rectf &a) const
Returns a Rectf mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:311
EventSignalKey mSignalKeyUp
Definition: Window.h:506
void emitMouseDrag(MouseEvent *event)
Definition: Window.cpp:311
const std::vector< TouchEvent::Touch > & getActiveTouches() const
Returns a std::vector of all active touches.
Definition: Window.cpp:375
EventSignalWindow & getSignalMove()
Definition: Window.h:418
EventSignalKey & getSignalKeyDown()
Definition: Window.h:397
FullScreenOptions & exclusive(bool enable=true)
(OS X only) Sets whether the Window related to these options is the only accessible window...
Definition: Window.h:119
std::shared_ptr< Window > WindowRef
Definition: Event.h:49
signals::connection connectTouchesEnded(T fn, Y *inst)
Definition: Window.h:392
EventSignalKey & getSignalKeyUp()
Definition: Window.h:402
void setPos(int32_t x, int32_t y) const
Sets the position of the Window's upper-left corner relative to the primary display's upper-left corn...
Definition: Window.h:282
signals::connection connectKeyUp(T fn, Y *inst)
Definition: Window.h:405
float toPixels(float s) const
Returns a scalar mapped from points to pixels by multiplying by getContentScale() ...
Definition: Window.h:293
void emitMove()
Definition: Window.cpp:282
float getContentScale() const
Returns the multiplier (typically 2 on high-density (Retina) displays, 1 otherwise) mapping points to...
Definition: Window.cpp:111
void show()
Shows a window that was hidden with hide()
Definition: Window.cpp:211
RendererRef getRenderer() const
Returns the Renderer associated with the Window.
Definition: Window.cpp:244
Window()
Definition: Window.h:479
Area toPoints(const Area &a) const
Returns an Area mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:309
Area toPixels(const Area &a) const
Returns an Area mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:299
Definition: AppImplMsw.h:103
FullScreenOptions & secondaryDisplayBlanking(bool enable=true)
Sets whether secondary displays should be blanked (made black). Default is false. ...
Definition: Window.h:117
void emitMouseDown(MouseEvent *event)
Definition: Window.cpp:302
EventSignalWindow & getSignalPostDraw()
Returns the signal which is emitted after the draw signal and app's draw() virtual method...
Definition: Window.h:414
void emitDraw()
Fires the 'draw' signal. Note in general this should not be called directly as it doesn't perform all...
Definition: Window.cpp:406
GLenum GLsizei GLsizei height
Definition: GLee.h:1029
float toPoints(float s) const
Returns a scalar mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:303
UIViewController * getNativeViewController()
Definition: AppCocoaTouch.mm:1056
EventSignalTouch & getSignalTouchesMoved()
Definition: Window.h:384
BOOL isBorderless()
Definition: AppCocoaTouch.mm:1010
App * mApp
Definition: Window.h:500
bool isExclusive() const
Returns whether the Window related to these options is the only accessible window.
Definition: Window.h:130
EventSignalMouse mSignalMouseDrag
Definition: Window.h:504
EventSignalMouse & getSignalMouseUp()
Definition: Window.h:364
EventSignalFileDrop mSignalFileDrop
Definition: Window.h:508
GLenum GLint x
Definition: GLee.h:987
int32_t x1
Definition: Area.h:101
void emitFileDrop(FileDropEvent *event)
Definition: Window.cpp:413
std::string getTitle() const
Returns the Window's title as a UTF-8 string.
Definition: Window.cpp:133
int32_t x2
Definition: Area.h:101
std::shared_ptr< class Renderer > RendererRef
Definition: Renderer.h:85
EventSignalTouch & getSignalTouchesBegan()
Definition: Window.h:379
void testValid() const
Definition: Window.h:481
void show()
Definition: AppCocoaTouch.mm:1032
EventCombiner< MouseEvent > EventSignalMouse
Definition: Window.h:98
EventSignalMouse & getSignalMouseWheel()
Definition: Window.h:374
EventSignalMouse & getSignalMouseDown()
Definition: Window.h:354
std::shared_ptr< void > mUserData
Definition: Window.h:502
Vec2f toPoints(Vec2f s) const
Returns a Vec2f mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:305
EventSignalKey mSignalKeyDown
Definition: Window.h:506
const GLdouble * v
Definition: GLee.h:1384
EventCombiner< KeyEvent > EventSignalKey
Definition: Window.h:100
signals::connection connectDraw(T fn, Y *inst)
Definition: Window.h:411
bool mValid
Definition: Window.h:501
FullScreenOptions()
Definition: Window.h:111
void spanAllDisplays()
Sets the position and size of the Window so that it spans all connected displays. ...
Definition: Window.cpp:103
void emitDisplayChange()
Definition: Window.cpp:296
int32_t getWidth() const
Returns the width of the Window in points.
Definition: Window.h:266
DisplayRef getDisplay() const
Returns the Display on which the Window resides.
Definition: Window.cpp:233
Definition: AppImplWinRT.h:95
void setAlwaysOnTop(bool alwaysOnTop=true)
Sets whether the window always remains above all other windows.
Definition: Window.cpp:189
EventSignalWindow & getSignalDisplayChange()
Definition: Window.h:428
T y
Definition: Vector.h:71
App * getApp() const
Definition: Window.h:476
void setTitle(const std::string &title)
Sets the Window's title as a UTF-8 string.
Definition: Window.cpp:145
std::shared_ptr< class Display > DisplayRef
Definition: Display.h:53
EventCombiner< TouchEvent > EventSignalTouch
Definition: Window.h:99
void hide()
Hides the window but does not destroy it.
Definition: Window.cpp:200
EventSignalMouse mSignalMouseDown
Definition: Window.h:504
signals::connection connectTouchesBegan(T fn, Y *inst)
Definition: Window.h:382
signals::connection connectMouseDrag(T fn, Y *inst)
Definition: Window.h:362
DisplayRef getDisplay() const
Returns the display on which the fullscreen should occur. A NULL value implies the default...
Definition: Window.h:124
bool isFullScreen() const
Returns whether the Window is full-screen or not.
Definition: Window.cpp:37
signals::connection connectFileDrop(T fn, Y *inst)
Definition: Window.h:443
Represents a file-drop event, typically received from Windows Explorer or Mac OS X Finder...
Definition: FileDropEvent.h:36
bool isKioskModeEnabled() const
Returns whether kiosk mode is enabled.
Definition: Window.h:126
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
void emitResize()
Definition: Window.cpp:288
EventCombiner< FileDropEvent > EventSignalFileDrop
Definition: Window.h:101
EventSignalTouch mSignalTouchesMoved
Definition: Window.h:505
float getAspectRatio() const
Returns the Window aspect ratio, which is its width / height.
Definition: Window.h:270
bool isSecondaryDisplayBlankingEnabled() const
Returns whether blanking of secondary displays in enabled. Default is false.
Definition: Window.h:128
int32_t y1
Definition: Area.h:101
Vec2i toPixels(Vec2i s) const
Returns a Vec2i mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:297
void emitClose()
Fires the 'close' signal.
Definition: Window.cpp:277
signals::connection connectTouchesMoved(T fn, Y *inst)
Definition: Window.h:387
EventSignalWindow mSignalMove
Definition: Window.h:507
signals::connection connectKeyDown(T fn, Y *inst)
Definition: Window.h:400
Definition: Exception.h:32
signals::connection connectDisplayChange(T fn, Y *inst)
Definition: Window.h:431
EventSignalFileDrop & getSignalFileDrop()
Definition: Window.h:440
bool isHidden() const
Returns whether the window has been hidden with hide()
Definition: Window.cpp:222
GLuint id
Definition: GLee.h:2035
EventSignalMouse & getSignalMouseMove()
Definition: Window.h:369
Vec2i getPos() const
Gets the position of the Window's upper-left corner measured in points, relative to the primary displ...
Definition: Window.cpp:81
void emitMouseWheel(MouseEvent *event)
Definition: Window.cpp:329
Represents a touch event.
Definition: TouchEvent.h:34
EventSignalWindow mSignalDraw
Definition: Window.h:507
GLdouble GLdouble t
Definition: GLee.h:1426
GLdouble s
Definition: GLee.h:1378
GLclampf f
Definition: GLee.h:15307
EventSignalWindow & getSignalResize()
Definition: Window.h:423
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: GLee.h:1161
void emitTouchesBegan(TouchEvent *event)
Definition: Window.cpp:347
void close()
Closes and destroys the Window.
Definition: Window.cpp:122
Represents a keyboard event.
Definition: KeyEvent.h:32
void emitMouseUp(MouseEvent *event)
Definition: Window.cpp:320
GLsizeiptr size
Definition: GLee.h:2089
EventSignalTouch mSignalTouchesBegan
Definition: Window.h:505
signals::connection connectMouseMove(T fn, Y *inst)
Definition: Window.h:372
virtual Vec2i getSize() const
Gets the size of the Window measured in points.
Definition: Window.cpp:59
void setInvalid()
Definition: Window.h:454
Thrown when an operation is performed on a WindowRef which refers to an invalid Window.
Definition: Window.h:105
Vec2< int > Vec2i
Definition: Vector.h:1313
EventSignalWindow & getSignalDraw()
Definition: Window.h:407
void setFullScreen(bool fullScreen=true)
Sets whether the active App is in full-screen mode based on fullScreen.
Definition: App.h:607