1 // 2 // Copyright (c) 2015 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // OSXWindow.h: Definition of the implementation of OSWindow for OSX 8 9 #ifndef UTIL_OSX_WINDOW_H_ 10 #define UTIL_OSX_WINDOW_H_ 11 12 #import <Cocoa/Cocoa.h> 13 14 #include "OSWindow.h" 15 16 class OSXWindow; 17 18 @interface WindowDelegate : NSObject 19 { 20 OSXWindow *mWindow; 21 } 22 - (id) initWithWindow: (OSXWindow*) window; 23 @end 24 25 @interface ContentView : NSView 26 { 27 OSXWindow *mWindow; 28 NSTrackingArea *mTrackingArea; 29 int mCurrentModifier; 30 } 31 - (id) initWithWindow: (OSXWindow*) window; 32 @end 33 34 class OSXWindow : public OSWindow 35 { 36 public: 37 OSXWindow(); 38 ~OSXWindow(); 39 40 bool initialize(const std::string &name, size_t width, size_t height) override; 41 void destroy() override; 42 43 EGLNativeWindowType getNativeWindow() const override; 44 EGLNativeDisplayType getNativeDisplay() const override; 45 void* getFramebufferNativeWindow() const override; 46 float getDevicePixelRatio() const override; 47 48 void messageLoop() override; 49 50 void setMousePosition(int x, int y) override; 51 bool setPosition(int x, int y) override; 52 bool resize(int width, int height) override; 53 void setVisible(bool isVisible) override; 54 55 void signalTestEvent() override; 56 57 NSWindow *getNSWindow() const; 58 59 private: 60 CALayer *mLayer; 61 NSWindow *mWindow; 62 WindowDelegate *mDelegate; 63 ContentView *mView; 64 }; 65 66 #endif // UTIL_OSX_WINDOW_H_ 67