4 #if defined(__APPLE__) && defined(__LP64__) && !defined(IPLUG_NO_CARBON_SUPPORT)
5 #define IPLUG_NO_CARBON_SUPPORT
8 // carbon support uses quickdraw methods that have been removed in SDKs > 10.6
9 #if __MAC_OS_X_VERSION_MAX_ALLOWED > 1060
10 #warning Carbon GUIs work best with the 10.6 sdk
13 #include "IGraphics.h"
14 #include "../swell/swell.h"
17 #define _UINT32 // this is necessary to get VST3 to compile with the 10.6 SDK due to a conflict
20 #include <Carbon/Carbon.h>
22 #ifndef DEFAULT_PATH_OSX
23 #define DEFAULT_PATH_OSX "~/Desktop"
26 #ifndef IPLUG_NO_CARBON_SUPPORT
27 class IGraphicsCarbon
;
31 #define COCOA_PREFIX vOliLarkin
38 #elif defined(RTAS_API)
40 #elif defined(AAX_API)
42 #elif defined(VST3_API)
48 #define CONCAT3(a,b,c) a##b##c
49 #define CONCAT2(a,b,c) CONCAT3(a,b,c)
50 #define CONCAT(cname) CONCAT2(cname,COCOA_PREFIX,API)
52 #define IGRAPHICS_COCOA CONCAT(IGraphicsCocoa_)
53 #define IGRAPHICS_NSMENU CONCAT(IGraphicsNSMenu_)
54 #define IGRAPHICS_MENU_RCVR CONCAT(IGraphicsMenuRcvr_)
55 #define CUSTOM_COCOA_WINDOW CONCAT(CustomCocoaWindow_)
56 #define COCOA_FORMATTER CONCAT(CocoaFormatter_)
58 class IGraphicsMac
: public IGraphics
61 IGraphicsMac(IPlugBase
* pPlug
, int w
, int h
, int refreshFPS
);
62 virtual ~IGraphicsMac();
64 void SetBundleID(const char* bundleID
) { mBundleID
.Set(bundleID
); }
66 bool DrawScreen(IRECT
* pR
);
67 bool MeasureIText(IText
* pTxt
, char* str
, IRECT
* pR
);
69 void* OpenWindow(void* pWindow
);
70 #ifndef IPLUG_NO_CARBON_SUPPORT
71 void* OpenWindow(void* pWindow
, void* pControl
, short leftOffset
= 0, short topOffset
= 0);
74 void* OpenCocoaWindow(void* pParentView
);
75 #ifndef IPLUG_NO_CARBON_SUPPORT
76 void* OpenCarbonWindow(void* pParentWnd
, void* pParentControl
, short leftOffset
, short topOffset
);
79 void AttachSubWindow(void* hostWindowRef
);
80 void RemoveSubWindow();
84 void Resize(int w
, int h
);
86 void HideMouseCursor();
87 void ShowMouseCursor();
89 int ShowMessageBox(const char* pText
, const char* pCaption
, int type
);
90 void ForceEndUserEdit();
92 const char* GetGUIAPI();
94 void UpdateTooltips();
96 void HostPath(WDL_String
* pPath
);
97 void PluginPath(WDL_String
* pPath
);
98 void DesktopPath(WDL_String
* pPath
);
99 void AppSupportPath(WDL_String
* pPath
);
101 void PromptForFile(WDL_String
* pFilename
, EFileAction action
= kFileOpen
, WDL_String
* pDir
= 0, char* extensions
= ""); // extensions = "txt wav" for example.
102 bool PromptForColor(IColor
* pColor
, char* prompt
= "");
104 IPopupMenu
* CreateIPopupMenu(IPopupMenu
* pMenu
, IRECT
* pTextRect
);
105 void CreateTextEntry(IControl
* pControl
, IText
* pText
, IRECT
* pTextRect
, const char* pString
, IParam
* pParam
);
107 bool OpenURL(const char* url
, const char* msgWindowTitle
= 0, const char* confirmMsg
= 0, const char* errMsgOnFailure
= 0);
111 const char* GetBundleID() { return mBundleID
.Get(); }
112 static int GetUserOSVersion(); // Returns a number like 0x1050 (10.5).
115 virtual LICE_IBitmap
* OSLoadBitmap(int ID
, const char* name
);
118 #ifndef IPLUG_NO_CARBON_SUPPORT
119 IGraphicsCarbon
* mGraphicsCarbon
;
121 void* mGraphicsCocoa
; // Can't forward-declare IGraphicsCocoa because it's an obj-C object.
123 WDL_String mBundleID
;
125 friend int GetMouseOver(IGraphicsMac
* pGraphics
);
127 #ifndef IPLUG_NO_CARBON_SUPPORT
128 friend class IGraphicsCarbon
;
131 public: //TODO: make this private
135 inline CFStringRef
MakeCFString(const char* cStr
)
137 return CFStringCreateWithCString(0, cStr
, kCFStringEncodingUTF8
);
143 CFStrLocal(const char* cStr
)
145 mCFStr
= MakeCFString(cStr
);
156 CStrLocal(CFStringRef cfStr
)
158 int n
= CFStringGetLength(cfStr
) + 1;
159 mCStr
= (char*) malloc(n
);
160 CFStringGetCString(cfStr
, mCStr
, n
, kCFStringEncodingUTF8
);
168 inline CGRect
ToCGRect(int h
, IRECT
* pR
)
171 return CGRectMake(pR
->L
, B
, pR
->W(), B
+ pR
->H());
174 inline int AdjustFontSize(int size
)
176 return int(0.9 * (double)size
);