ASPiK SDK
hiviewframe.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 __hiviewframe__
6 #define __hiviewframe__
7 
8 #include "../../../cframe.h"
9 
10 #if MAC_CARBON
11 
12 #include "../../iplatformframe.h"
13 #include <Carbon/Carbon.h>
14 
15 namespace VSTGUI {
16 
17 extern bool isWindowComposited (WindowRef window);
18 
19 //-----------------------------------------------------------------------------
20 class HIViewFrame : public IPlatformFrame
21 {
22 public:
23  static void setAddToContentView (bool addToContentView); // defaults to true
24 
25  HIViewFrame (IPlatformFrameCallback* frame, const CRect& size, WindowRef parent);
26  ~HIViewFrame () noexcept;
27 
28  HIViewRef getPlatformControl () const { return controlRef; }
29  const CPoint& getScrollOffset () const { return hiScrollOffset; }
30 
31  // IPlatformFrame
32  bool getGlobalPosition (CPoint& pos) const override;
33  bool setSize (const CRect& newSize) override;
34  bool getSize (CRect& size) const override;
35  bool getCurrentMousePosition (CPoint& mousePosition) const override;
36  bool getCurrentMouseButtons (CButtonState& buttons) const override;
37  bool setMouseCursor (CCursorType type) override;
38  bool invalidRect (const CRect& rect) override;
39  bool scrollRect (const CRect& src, const CPoint& distance) override;
40  bool showTooltip (const CRect& rect, const char* utf8Text) override;
41  bool hideTooltip () override;
42  void* getPlatformRepresentation () const override { return controlRef; }
43  SharedPointer<IPlatformTextEdit> createPlatformTextEdit (IPlatformTextEditCallback* textEdit) override;
44  SharedPointer<IPlatformOptionMenu> createPlatformOptionMenu () override;
45 #if VSTGUI_OPENGL_SUPPORT
46  SharedPointer<IPlatformOpenGLView> createPlatformOpenGLView () override { return nullptr; } // not supported
47 #endif
48  SharedPointer<IPlatformViewLayer> createPlatformViewLayer (IPlatformViewLayerDelegate* drawDelegate, IPlatformViewLayer* parentLayer = nullptr) override { return 0; } // not supported
49  SharedPointer<COffscreenContext> createOffscreenContext (CCoord width, CCoord height, double scaleFactor = 1.) override;
50  DragResult doDrag (IDataPackage* source, const CPoint& offset, CBitmap* dragBitmap) override;
51  void setClipboard (const SharedPointer<IDataPackage>& data) override;
52  SharedPointer<IDataPackage> getClipboard () override;
53  PlatformType getPlatformType () const override { return PlatformType::kWindowRef; }
54 
55 //-----------------------------------------------------------------------------
56 protected:
57  static pascal OSStatus carbonMouseEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
58  static pascal OSStatus carbonEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
59 
60  WindowRef window;
61  HIViewRef controlRef;
62  bool hasFocus;
63  bool isInMouseTracking;
64  EventHandlerRef mouseEventHandler;
65  EventHandlerRef keyboardEventHandler;
66  CPoint hiScrollOffset;
67 };
68 
69 } // namespace
70 
71 #endif // MAC_CARBON
72 #endif // __hiviewframe__
Definition: customcontrols.cpp:8