ASPiK SDK
nsviewframe.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __nsviewframe__
6 #define __nsviewframe__
7 
8 #include "../../../vstguifwd.h"
9 
10 #if MAC_COCOA
11 
12 #include "../../platform_macos.h"
13 #include "../../../cview.h"
14 #include "../../../idatapackage.h"
15 #include <list>
16 
17 #ifdef __OBJC__
18 #import <Cocoa/Cocoa.h>
19 #else
20 struct NSView;
21 struct NSRect;
22 #endif
23 
24 namespace VSTGUI {
25 class CocoaTooltipWindow;
26 
27 //-----------------------------------------------------------------------------
28 class NSViewFrame : public IPlatformFrame, public ICocoaPlatformFrame, public IPlatformFrameTouchBarExtension
29 {
30 public:
31  NSViewFrame (IPlatformFrameCallback* frame, const CRect& size, NSView* parent, IPlatformFrameConfig* config);
32  ~NSViewFrame () noexcept override;
33 
34  NSView* getNSView () const override { return nsView; }
35  IPlatformFrameCallback* getFrame () const { return frame; }
36  void* makeTouchBar () const;
37 
38  void setLastDragOperationResult (DragResult result) { lastDragOperationResult = result; }
39  void setIgnoreNextResignFirstResponder (bool state) { ignoreNextResignFirstResponder = state; }
40  bool getIgnoreNextResignFirstResponder () const { return ignoreNextResignFirstResponder; }
41 
42  void setDragDataPackage (SharedPointer<IDataPackage>&& package) { dragDataPackage = std::move (package); }
43  const SharedPointer<IDataPackage>& getDragDataPackage () const { return dragDataPackage; }
44 
45  void initTrackingArea ();
46  void scaleFactorChanged (double newScaleFactor);
47  void cursorUpdate ();
48  virtual void drawRect (NSRect* rect);
49 
50  // IPlatformFrame
51  bool getGlobalPosition (CPoint& pos) const override;
52  bool setSize (const CRect& newSize) override;
53  bool getSize (CRect& size) const override;
54  bool getCurrentMousePosition (CPoint& mousePosition) const override;
55  bool getCurrentMouseButtons (CButtonState& buttons) const override;
56  bool setMouseCursor (CCursorType type) override;
57  bool invalidRect (const CRect& rect) override;
58  bool scrollRect (const CRect& src, const CPoint& distance) override;
59  bool showTooltip (const CRect& rect, const char* utf8Text) override;
60  bool hideTooltip () override;
61  void* getPlatformRepresentation () const override { return nsView; }
62  SharedPointer<IPlatformTextEdit> createPlatformTextEdit (IPlatformTextEditCallback* textEdit) override;
63  SharedPointer<IPlatformOptionMenu> createPlatformOptionMenu () override;
64 #if VSTGUI_OPENGL_SUPPORT
65  SharedPointer<IPlatformOpenGLView> createPlatformOpenGLView () override;
66 #endif
67  SharedPointer<IPlatformViewLayer> createPlatformViewLayer (IPlatformViewLayerDelegate* drawDelegate, IPlatformViewLayer* parentLayer = nullptr) override;
68  SharedPointer<COffscreenContext> createOffscreenContext (CCoord width, CCoord height, double scaleFactor) override;
69  DragResult doDrag (IDataPackage* source, const CPoint& offset, CBitmap* dragBitmap) override;
70  void setClipboard (const SharedPointer<IDataPackage>& data) override;
71  SharedPointer<IDataPackage> getClipboard () override;
72  PlatformType getPlatformType () const override { return PlatformType::kNSView; }
73 
74  // IPlatformFrameTouchBarExtension
75  void setTouchBarCreator (const SharedPointer<ITouchBarCreator>& creator) override;
76  void recreateTouchBar () override;
77 
78 //-----------------------------------------------------------------------------
79 protected:
80  static void initClass ();
81 
82  NSView* nsView;
83  CocoaTooltipWindow* tooltipWindow;
84  SharedPointer<IDataPackage> dragDataPackage;
85  SharedPointer<ITouchBarCreator> touchBarCreator;
86 
87  DragResult lastDragOperationResult;
88  bool ignoreNextResignFirstResponder;
89  bool trackingAreaInitialized;
90  bool inDraw;
91  CCursorType cursor;
92 };
93 
94 } // namespace
95 
96 #endif // MAC_COCOA
97 #endif // __nsviewframe__
Definition: customcontrols.cpp:8