2 File: AUCarbonViewBase.h
3 Abstract: Part of CoreAudio Utility Classes
6 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7 Inc. ("Apple") in consideration of your agreement to the following
8 terms, and your use, installation, modification or redistribution of
9 this Apple software constitutes acceptance of these terms. If you do
10 not agree with these terms, please do not use, install, modify or
11 redistribute this Apple software.
13 In consideration of your agreement to abide by the following terms, and
14 subject to these terms, Apple grants you a personal, non-exclusive
15 license, under Apple's copyrights in this original Apple software (the
16 "Apple Software"), to use, reproduce, modify and redistribute the Apple
17 Software, with or without modifications, in source and/or binary forms;
18 provided that if you redistribute the Apple Software in its entirety and
19 without modifications, you must retain this notice and the following
20 text and disclaimers in all such redistributions of the Apple Software.
21 Neither the name, trademarks, service marks or logos of Apple Inc. may
22 be used to endorse or promote products derived from the Apple Software
23 without specific prior written permission from Apple. Except as
24 expressly stated in this notice, no other rights or licenses, express or
25 implied, are granted by Apple herein, including but not limited to any
26 patent rights that may be infringed by your derivative works or by other
27 works in which the Apple Software may be incorporated.
29 The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30 MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31 THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33 OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39 MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40 AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41 STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42 POSSIBILITY OF SUCH DAMAGE.
44 Copyright (C) 2014 Apple Inc. All Rights Reserved.
47 #ifndef __AUCarbonViewBase_h__
48 #define __AUCarbonViewBase_h__
51 #include "AUCarbonViewControl.h"
52 #include "ComponentBase.h"
54 static const Float32 kDefaultNotificationInterval = 0.100;
56 /*! @class AUCarbonViewBase */
57 class AUCarbonViewBase : public ComponentBase, public CarbonEventHandler
60 /*! @ctor AUCarbonViewBase */
61 AUCarbonViewBase ( AudioUnitCarbonView inInstance,
62 Float32 inNotificationInterval = kDefaultNotificationInterval /* in seconds */);
63 /*! @dtor ~AUCarbonViewBase */
64 virtual ~AUCarbonViewBase();
66 // AUViewBase overrides
67 /*! @method CreateCarbonView */
68 virtual OSStatus CreateCarbonView (AudioUnit inAudioUnit, WindowRef inWindow, ControlRef inParentControl, const Float32Point &inLocation, const Float32Point &inSize, ControlRef &outParentControl);
70 // our own virtual methods
71 /*! @method CreateUI */
72 virtual OSStatus CreateUI (Float32 inXOffset, Float32 inYOffset);
74 /*! @method HandleEvent */
75 virtual bool HandleEvent (EventHandlerCallRef inHandlerRef, EventRef event);
77 /*! @method GetEditAudioUnit */
78 const AudioUnit GetEditAudioUnit () const { return mEditAudioUnit; }
80 /*! @method ComponentEntryDispatch */
81 static OSStatus ComponentEntryDispatch (
82 ComponentParameters * params,
83 AUCarbonViewBase * This);
85 /*! @method AddCarbonControl */
86 void AddCarbonControl (
87 AUCarbonViewControl::ControlType type,
88 const CAAUParameter & param,
91 /*! @method GetCarbonWindow */
92 WindowRef GetCarbonWindow () { return mCarbonWindow; }
93 /*! @method GetCarbonPane */
94 ControlRef GetCarbonPane () { return mCarbonPane; }
95 /*! @method EmbedControl */
96 OSStatus EmbedControl (ControlRef ctl);
98 /*! @method TellListener */
99 void TellListener (const CAAUParameter &auvp, AudioUnitCarbonViewEventID event, void *evpar);
101 // pass in true if wanting an update to the view and you're calling this from a thread
102 // that is safe to do UI in.
103 // If you don't know, pass in false!
104 /*! @method Update */
105 void Update (bool inUIThread);
107 /*! @method GetXOffset */
108 Float32 GetXOffset () { return mXOffset; }
109 /*! @method GetYOffset */
110 Float32 GetYOffset () { return mYOffset; }
112 /*! @method ClearControls */
113 void ClearControls ();
115 /*! @method IsCompositWindow */
116 bool IsCompositWindow () const { return mCompositWindow; }
120 /*! @method SetEventListener */
121 void SetEventListener (AudioUnitCarbonViewEventListener listener, void *userData)
123 mEventListener = listener;
124 mEventListenerUserData = userData;
128 /*! @method AddControl */
129 void AddControl (AUCarbonViewControl *control);
130 /*! @method RemoveControl */
131 void RemoveControl (AUCarbonViewControl *control);
133 OSStatus CreateEventLoopTimer (Float32 inDelay, Float32 inInterval);
135 /*! @method ParameterListener */
136 static void ParameterListener (void * inCallbackRefCon,
138 const AudioUnitEvent * inEvent,
139 UInt64 inEventHostTime,
140 Float32 inParameterValue);
142 static pascal void TheTimerProc ( EventLoopTimerRef inTimer,
145 virtual void RespondToEventTimer (EventLoopTimerRef inTimer);
147 /*! @var mEditAudioUnit */
148 AudioUnit mEditAudioUnit; // the AU we're controlling
149 /*! @var mParameterListener */
150 AUEventListenerRef mParameterListener;
153 /*! @var mEventListener */
154 AudioUnitCarbonViewEventListener
158 /*! @var mEventListenerUserData */
159 void * mEventListenerUserData;
162 typedef std::vector<AUCarbonViewControl *> ControlList;
163 /*! @var mControlList */
164 ControlList mControlList;
166 EventLoopTimerRef mTimerRef;
168 EventLoopTimerUPP mTimerUPP;
171 /*! @var mCarbonWindow */
172 WindowRef mCarbonWindow;
173 /*! @var mCarbonPane */
174 ControlRef mCarbonPane; // user pane, contains all other controls
175 /*! @var mBottomRight */
176 Point mBottomRight; // largest width and height of child controls
181 /*! @var mCompositWindow */
182 bool mCompositWindow;
183 /*! @var mCurrentScrollPoint */
184 HIPoint mCurrentScrollPoint; // needed for scrolling
188 #endif // __AUCarbonViewBase_h__