diff options
Diffstat (limited to 'libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase')
9 files changed, 315 insertions, 315 deletions
diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.cpp index 332475335d..d3394ee19d 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.cpp +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.cpp @@ -2,14 +2,14 @@ File: AUCarbonViewBase.cpp Abstract: AUCarbonViewBase.h Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #include "AUCarbonViewBase.h" #include "AUCarbonViewControl.h" @@ -59,11 +59,11 @@ AUCarbonViewBase::AUCarbonViewBase(AudioUnitCarbonView inInstance, Float32 inNot mTimerUPP (NULL), mCarbonWindow(NULL), mCarbonPane(NULL), - mXOffset(0), + mXOffset(0), mYOffset(0) { AUEventListenerCreate (ParameterListener, this, - CFRunLoopGetCurrent(), kCFRunLoopCommonModes, + CFRunLoopGetCurrent(), kCFRunLoopCommonModes, inNotificationInterval, inNotificationInterval, &mParameterListener); } @@ -82,12 +82,12 @@ AUCarbonViewBase::~AUCarbonViewBase() if (mTimerRef) ::RemoveEventLoopTimer (mTimerRef); - + if (mTimerUPP) DisposeEventLoopTimerUPP (mTimerUPP); #endif } - + void AUCarbonViewBase::AddControl(AUCarbonViewControl *control) { ControlList::iterator it = find(mControlList.begin(), mControlList.end(), control); @@ -126,7 +126,7 @@ void AUCarbonViewBase::ParameterListener(void * inCallbackRefCon, } } - + OSStatus AUCarbonViewBase::CreateCarbonView(AudioUnit inAudioUnit, WindowRef inWindow, ControlRef inParentControl, const Float32Point &inLocation, const Float32Point &inSize, ControlRef &outParentControl) { #if !__LP64__ @@ -140,19 +140,19 @@ OSStatus AUCarbonViewBase::CreateCarbonView(AudioUnit inAudioUnit, WindowRef i Rect area; area.left = short(inLocation.x); area.top = short(inLocation.y); area.right = short(area.left + inSize.x); area.bottom = short(area.top + inSize.y); - OSStatus err = ::CreateUserPaneControl(inWindow, &area, + OSStatus err = ::CreateUserPaneControl(inWindow, &area, kControlSupportsEmbedding, &mCarbonPane); // subclass can resize mCarbonPane to taste verify_noerr(err); if (err) return err; outParentControl = mCarbonPane; - + // register for mouse-down in our pane -- we want to clear focus EventTypeSpec paneEvents[] = { { kEventClassControl, kEventControlClick } }; WantEventTypes(GetControlEventTarget(mCarbonPane), GetEventTypeCount(paneEvents), paneEvents); - + if (IsCompositWindow()) { verify_noerr(::HIViewAddSubview(inParentControl, mCarbonPane)); mXOffset = 0; @@ -164,7 +164,7 @@ OSStatus AUCarbonViewBase::CreateCarbonView(AudioUnit inAudioUnit, WindowRef i mYOffset = inLocation.y; } mBottomRight.h = mBottomRight.v = 0; - + SizeControl(mCarbonPane, 0, 0); if (err = CreateUI(mXOffset, mYOffset)) return err; @@ -187,12 +187,12 @@ OSStatus AUCarbonViewBase::CreateCarbonView(AudioUnit inAudioUnit, WindowRef i { kEventClassScrollable, kEventScrollableGetInfo }, { kEventClassScrollable, kEventScrollableScrollTo } }; - + WantEventTypes(GetControlEventTarget(mCarbonPane), GetEventTypeCount(scrollEvents), scrollEvents); - + mCurrentScrollPoint.x = mCurrentScrollPoint.y = 0.0f; } - + return err; #else return noErr; @@ -212,10 +212,10 @@ OSStatus AUCarbonViewBase::EmbedControl(ControlRef ctl) if (r.right > mBottomRight.h) mBottomRight.h = r.right; if (r.bottom > mBottomRight.v) mBottomRight.v = r.bottom; - if (IsCompositWindow()) + if (IsCompositWindow()) return ::HIViewAddSubview(mCarbonPane, ctl); - else - return ::EmbedControl(ctl, mCarbonPane); + else + return ::EmbedControl(ctl, mCarbonPane); #else return noErr; #endif @@ -224,19 +224,19 @@ OSStatus AUCarbonViewBase::EmbedControl(ControlRef ctl) void AUCarbonViewBase::AddCarbonControl(AUCarbonViewControl::ControlType type, const CAAUParameter ¶m, ControlRef control) { verify_noerr(EmbedControl(control)); - + AUCarbonViewControl *auvc = new AUCarbonViewControl(this, mParameterListener, type, param, control); auvc->Bind(); AddControl(auvc); } bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event) -{ +{ #if !__LP64__ UInt32 eclass = GetEventClass(event); UInt32 ekind = GetEventKind(event); ControlRef control; - + switch (eclass) { case kEventClassControl: { @@ -250,7 +250,7 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev } } break; - + case kEventClassScrollable: { switch (ekind) { @@ -262,7 +262,7 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev */ HISize originalSize = { mBottomRight.h, mBottomRight.v }; verify_noerr(SetEventParameter(event, kEventParamImageSize, typeHISize, sizeof(HISize), &originalSize)); - + // [2/4] /* <-- kEventParamViewSize (out, typeHISize) * On exit, contains the amount of the scrollable view that is @@ -274,7 +274,7 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev //HISize windowSize = { float(windowBounds.right - windowBounds.left), // float(windowBounds.bottom - windowBounds.top) }; verify_noerr(SetEventParameter(event, kEventParamViewSize, typeHISize, sizeof(HISize), &(parentBounds.size))); - + // [3/4] /* <-- kEventParamLineSize (out, typeHISize) * On exit, contains the amount that should be scrolled in @@ -282,7 +282,7 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev */ HISize scrollIncrementSize = { 16.0f, float(20) }; verify_noerr(SetEventParameter(event, kEventParamLineSize, typeHISize, sizeof(HISize), &scrollIncrementSize)); - + // [4/4] /* <-- kEventParamOrigin (out, typeHIPoint) * On exit, contains the scrollable viewÕs current origin (the @@ -294,17 +294,17 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev verify_noerr(SetEventParameter(event, kEventParamOrigin, typeHIPoint, sizeof(HIPoint), &mCurrentScrollPoint)); } return true; - + case kEventScrollableScrollTo: { /* * kEventClassScrollable / kEventScrollableScrollTo - * + * * Summary: * Requests that an HIScrollViewÕs scrollable view should scroll to * a particular origin. */ - + /* --> kEventParamOrigin (in, typeHIPoint) * The new origin for the scrollable view. The origin * coordinates will vary from (0,0) to scrollable viewÕs image @@ -312,24 +312,24 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev */ HIPoint pointToScrollTo; verify_noerr(GetEventParameter(event, kEventParamOrigin, typeHIPoint, NULL, sizeof(HIPoint), NULL, &pointToScrollTo)); - + float xDelta = mCurrentScrollPoint.x - pointToScrollTo.x; float yDelta = mCurrentScrollPoint.y - pointToScrollTo.y; // move visible portion the appropriate amount verify_noerr(HIViewScrollRect(mCarbonPane, NULL, xDelta, yDelta)); // set new content to be drawn verify_noerr(HIViewSetBoundsOrigin(mCarbonPane, pointToScrollTo.x, pointToScrollTo.y)); - + mCurrentScrollPoint = pointToScrollTo; } return true; - + default: break; } } break; - + default: break; } @@ -352,7 +352,7 @@ void AUCarbonViewBase::TellListener (const CAAUParameter &auvp, AudioUnitCarbonV } else { auEvent.mEventType = kAudioUnitEvent_EndParameterChangeGesture; } - AUEventListenerNotify(mParameterListener, this, &auEvent); + AUEventListenerNotify(mParameterListener, this, &auEvent); } @@ -370,34 +370,34 @@ pascal void AUCarbonViewBase::TheTimerProc (EventLoopTimerRef inTimer, void *in This->RespondToEventTimer (inTimer); } -void AUCarbonViewBase::RespondToEventTimer (EventLoopTimerRef inTimer) +void AUCarbonViewBase::RespondToEventTimer (EventLoopTimerRef inTimer) {} -/* +/* THESE are reasonable values for these two times - 0.005 // delay + 0.005 // delay 0.050 // interval */ -OSStatus AUCarbonViewBase::CreateEventLoopTimer (Float32 inDelay, Float32 inInterval) +OSStatus AUCarbonViewBase::CreateEventLoopTimer (Float32 inDelay, Float32 inInterval) { if (mTimerUPP) return noErr; - + mTimerUPP = NewEventLoopTimerUPP(TheTimerProc); - + EventLoopRef mainEventLoop = GetMainEventLoop(); - + //doesn't seem to like too small a value if (inDelay < 0.005) inDelay = 0.005; - + OSStatus timerResult = ::InstallEventLoopTimer( mainEventLoop, inDelay, inInterval, mTimerUPP, this, - &mTimerRef); + &mTimerRef); return timerResult; } diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.h index 910e53ffa6..0afc5fc074 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.h +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewBase.h @@ -2,14 +2,14 @@ File: AUCarbonViewBase.h Abstract: Part of CoreAudio Utility Classes Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #ifndef __AUCarbonViewBase_h__ #define __AUCarbonViewBase_h__ @@ -62,7 +62,7 @@ public: Float32 inNotificationInterval = kDefaultNotificationInterval /* in seconds */); /*! @dtor ~AUCarbonViewBase */ virtual ~AUCarbonViewBase(); - + // AUViewBase overrides /*! @method CreateCarbonView */ virtual OSStatus CreateCarbonView (AudioUnit inAudioUnit, WindowRef inWindow, ControlRef inParentControl, const Float32Point &inLocation, const Float32Point &inSize, ControlRef &outParentControl); @@ -73,7 +73,7 @@ public: /*! @method HandleEvent */ virtual bool HandleEvent (EventHandlerCallRef inHandlerRef, EventRef event); - + /*! @method GetEditAudioUnit */ const AudioUnit GetEditAudioUnit () const { return mEditAudioUnit; } // @@ -84,8 +84,8 @@ public: /*! @method AddCarbonControl */ void AddCarbonControl ( - AUCarbonViewControl::ControlType type, - const CAAUParameter & param, + AUCarbonViewControl::ControlType type, + const CAAUParameter & param, ControlRef control); /*! @method GetCarbonWindow */ @@ -94,27 +94,27 @@ public: ControlRef GetCarbonPane () { return mCarbonPane; } /*! @method EmbedControl */ OSStatus EmbedControl (ControlRef ctl); - + /*! @method TellListener */ void TellListener (const CAAUParameter &auvp, AudioUnitCarbonViewEventID event, void *evpar); - + // pass in true if wanting an update to the view and you're calling this from a thread // that is safe to do UI in. // If you don't know, pass in false! /*! @method Update */ void Update (bool inUIThread); - + /*! @method GetXOffset */ Float32 GetXOffset () { return mXOffset; } /*! @method GetYOffset */ Float32 GetYOffset () { return mYOffset; } - + /*! @method ClearControls */ void ClearControls (); - + /*! @method IsCompositWindow */ bool IsCompositWindow () const { return mCompositWindow; } - + protected: #if !__LP64__ /*! @method SetEventListener */ @@ -131,15 +131,15 @@ protected: void RemoveControl (AUCarbonViewControl *control); OSStatus CreateEventLoopTimer (Float32 inDelay, Float32 inInterval); - + /*! @method ParameterListener */ static void ParameterListener (void * inCallbackRefCon, void * inObject, const AudioUnitEvent * inEvent, UInt64 inEventHostTime, Float32 inParameterValue); - - static pascal void TheTimerProc ( EventLoopTimerRef inTimer, + + static pascal void TheTimerProc ( EventLoopTimerRef inTimer, void * inUserData); virtual void RespondToEventTimer (EventLoopTimerRef inTimer); diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.cpp index 981347b0f1..c22c50c4a3 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.cpp +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.cpp @@ -2,14 +2,14 @@ File: AUCarbonViewControl.cpp Abstract: AUCarbonViewControl.h Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #include "AUCarbonViewControl.h" #include "AUCarbonViewBase.h" @@ -74,11 +74,11 @@ void AUCarbonViewControl::Bind() mInControlInitialization = 1; // true AUListenerAddParameter(mListener, this, &mParam); // will cause an almost-immediate callback - + EventTypeSpec events[] = { { kEventClassControl, kEventControlValueFieldChanged } // N.B. OS X only }; - + WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events); if (mType == kTypeContinuous || mType == kTypeText || mType == kTypeDiscrete) { @@ -88,18 +88,18 @@ void AUCarbonViewControl::Bind() { kEventClassControl, kEventControlTrack } }; WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events); - } + } if (mType == kTypeText) { EventTypeSpec events[] = { { kEventClassControl, kEventControlSetFocusPart } }; - WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events); + WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events); ControlKeyFilterUPP proc = mParam.ValuesHaveStrings() ? StdKeyFilterCallback : NumericKeyFilterCallback; // this will fail for a static text field SetControlData(mControl, 0, kControlEditTextKeyFilterTag, sizeof(proc), &proc); } - + Update(true); mInControlInitialization = 0; // false #endif @@ -116,7 +116,7 @@ void AUCarbonViewControl::ParameterToControl(Float32 paramValue) case kTypeDiscrete: { long value = long(paramValue); - + // special case [1] -- menu parameters if (mParam.HasNamedParams()) { // if we're dealing with menus they behave differently! @@ -124,17 +124,17 @@ void AUCarbonViewControl::ParameterToControl(Float32 paramValue) // first menu item always reports a control value of 1 ControlKind ctrlKind; if (GetControlKind(mControl, &ctrlKind) == noErr) { - if ((ctrlKind.kind == kControlKindPopupArrow) - || (ctrlKind.kind == kControlKindPopupButton)) + if ((ctrlKind.kind == kControlKindPopupArrow) + || (ctrlKind.kind == kControlKindPopupButton)) { value = value - long(mParam.ParamInfo().minValue) + 1; } } } - + // special case [2] -- Write-only boolean parameters AudioUnitParameterInfo AUPI = mParam.ParamInfo(); - + bool isWriteOnlyBoolParameter = ( (AUPI.unit == kAudioUnitParameterUnit_Boolean) && (AUPI.flags & kAudioUnitParameterFlag_IsWritable) && !(AUPI.flags & kAudioUnitParameterFlag_IsReadable) ); @@ -148,7 +148,7 @@ void AUCarbonViewControl::ParameterToControl(Float32 paramValue) CFStringRef cfstr = mParam.GetStringFromValueCopy(¶mValue); if ( !(mParam.ParamInfo().flags & kAudioUnitParameterFlag_IsWritable) //READ ONLY PARAMS - && (mParam.ParamInfo().flags & kAudioUnitParameterFlag_IsReadable)) + && (mParam.ParamInfo().flags & kAudioUnitParameterFlag_IsReadable)) { if (mParam.GetParamTag()) { CFMutableStringRef str = CFStringCreateMutableCopy(NULL, 256, cfstr); @@ -184,7 +184,7 @@ void AUCarbonViewControl::ControlToParameter() case kTypeDiscrete: { long value = GetValue(); - + // special case [1] -- Menus if (mParam.HasNamedParams()) { // if we're dealing with menus they behave differently! @@ -192,24 +192,24 @@ void AUCarbonViewControl::ControlToParameter() // first menu item always reports a control value of 1 ControlKind ctrlKind; if (GetControlKind(mControl, &ctrlKind) == noErr) { - if ((ctrlKind.kind == kControlKindPopupArrow) - || (ctrlKind.kind == kControlKindPopupButton)) + if ((ctrlKind.kind == kControlKindPopupArrow) + || (ctrlKind.kind == kControlKindPopupButton)) { value = value + long(mParam.ParamInfo().minValue) - 1; } } } - + // special case [2] -- Write-only boolean parameters AudioUnitParameterInfo AUPI = mParam.ParamInfo(); - + bool isWriteOnlyBoolParameter = ( (AUPI.unit == kAudioUnitParameterUnit_Boolean) && (AUPI.flags & kAudioUnitParameterFlag_IsWritable) && !(AUPI.flags & kAudioUnitParameterFlag_IsReadable) ); if (isWriteOnlyBoolParameter) { value = 1; } - + mParam.SetValue (mListener, this, value); } break; @@ -284,25 +284,25 @@ long AUCarbonViewControl::GetValue() #endif } -/* Notes on event handling - +/* Notes on event handling + Button (Click and release on button) kEventControlClick received kEventControlTrack received kEventControlValueFieldChanged received kEventControlHit received - + Button (Click and release outside of button bounds) kEventControlClick received kEventControlTrack received - + Slider (Click, drag, and release) kEventControlClick received kEventControlTrack received kEventControlValueFieldChanged received kEventControlValueFieldChanged received kEventControlHit received - + Slider (Click, release without changing value) kEventControlClick received kEventControlTrack received @@ -313,16 +313,16 @@ bool AUCarbonViewControl::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef UInt32 ekind = GetEventKind(event); ControlRef control; bool handled = true; - + switch (eclass) { case kEventClassControl: { AudioUnitParameterInfo AUPI = mParam.ParamInfo(); - + bool isWriteOnlyBoolParameter = ( (AUPI.unit == kAudioUnitParameterUnit_Boolean) && (AUPI.flags & kAudioUnitParameterFlag_IsWritable) && !(AUPI.flags & kAudioUnitParameterFlag_IsReadable) ); - + switch (ekind) { case kEventControlSetFocusPart: // tab handled = !handled; // fall through to next case @@ -331,7 +331,7 @@ bool AUCarbonViewControl::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control); verify(control == mControl); ControlToParameter(); - return handled; + return handled; case kEventControlClick: if (isWriteOnlyBoolParameter) { GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control); @@ -341,7 +341,7 @@ bool AUCarbonViewControl::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef if (mLastControl != NULL) { mLastControl->Update(false); } - mLastControl = this; + mLastControl = this; } mOwnerView->TellListener(mParam, kAudioUnitCarbonViewEvent_MouseDownInControl, NULL); break; // don't return true, continue normal processing @@ -349,17 +349,17 @@ bool AUCarbonViewControl::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef if (mLastControl != this) { if (mLastControl != NULL) mLastControl->Update(false); - mLastControl = this; - } + mLastControl = this; + } mOwnerView->TellListener(mParam, kAudioUnitCarbonViewEvent_MouseUpInControl, NULL); break; // don't return true, continue normal processing - case kEventControlTrack: + case kEventControlTrack: if (mLastControl != this) { if (mLastControl != NULL) mLastControl->Update(false); - mLastControl = this; + mLastControl = this; } - + CallNextEventHandler(inHandlerRef, event); ControlToParameter(); // new code mOwnerView->TellListener(mParam, kAudioUnitCarbonViewEvent_MouseUpInControl, NULL); @@ -379,8 +379,8 @@ pascal void AUCarbonViewControl::SliderTrackProc(ControlRef theControl, ControlP // AUCarbonViewControl *This = (AUCarbonViewControl *)GetControlReference(theControl); } -pascal ControlKeyFilterResult AUCarbonViewControl::StdKeyFilterCallback(ControlRef theControl, - SInt16 *keyCode, SInt16 *charCode, +pascal ControlKeyFilterResult AUCarbonViewControl::StdKeyFilterCallback(ControlRef theControl, + SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers) { #if !__LP64__ @@ -397,8 +397,8 @@ pascal ControlKeyFilterResult AUCarbonViewControl::StdKeyFilterCallback(ControlR return kControlKeyFilterBlockKey; } -pascal ControlKeyFilterResult AUCarbonViewControl::NumericKeyFilterCallback(ControlRef theControl, - SInt16 *keyCode, SInt16 *charCode, +pascal ControlKeyFilterResult AUCarbonViewControl::NumericKeyFilterCallback(ControlRef theControl, + SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers) { #if !__LP64__ @@ -420,43 +420,43 @@ Boolean AUCarbonViewControl::SizeControlToFit(ControlRef inControl, SInt16 *outW { #if !__LP64__ if (inControl == 0) return false; - + Boolean bValue = false; // this only works on text controls -- returns an error for other controls, but doesn't do anything, // so the error is irrelevant SetControlData(inControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue); - + SInt16 baseLineOffset; Rect bestRect; - OSErr err = GetBestControlRect(inControl, &bestRect, &baseLineOffset); + OSErr err = GetBestControlRect(inControl, &bestRect, &baseLineOffset); if (err != noErr) return false; - + int width = (bestRect.right - bestRect.left) + 1; int height = (bestRect.bottom - bestRect.top) + 1; - + Rect boundsRect; GetControlBounds (inControl, &boundsRect); - + Rect newRect; newRect.top = boundsRect.top; newRect.bottom = newRect.top + height; newRect.left = boundsRect.left; newRect.right = newRect.left + width; - + SetControlBounds (inControl, &newRect); - + if (outWidth) *outWidth = width; - + if (outHeight) *outHeight = height; -#endif +#endif return true; } #pragma mark ___AUPropertyControl bool AUPropertyControl::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event) -{ +{ UInt32 eclass = GetEventClass(event); UInt32 ekind = GetEventKind(event); switch (eclass) { @@ -477,14 +477,14 @@ void AUPropertyControl::RegisterEvents () EventTypeSpec events[] = { { kEventClassControl, kEventControlValueFieldChanged } // N.B. OS X only }; - + WantEventTypes(GetControlEventTarget(mControl), GetEventTypeCount(events), events); #endif } -void AUPropertyControl::EmbedControl (ControlRef theControl) -{ - mView->EmbedControl (theControl); +void AUPropertyControl::EmbedControl (ControlRef theControl) +{ + mView->EmbedControl (theControl); } WindowRef AUPropertyControl::GetCarbonWindow() @@ -498,11 +498,11 @@ static CFStringRef kStringFactoryPreset = kAUViewLocalizedStringKey_FactoryPrese static bool sAUVPresetLocalized = false; #endif -AUVPresets::AUVPresets (AUCarbonViewBase* inParentView, +AUVPresets::AUVPresets (AUCarbonViewBase* inParentView, CFArrayRef& inPresets, - Point inLocation, - int nameWidth, - int controlWidth, + Point inLocation, + int nameWidth, + int controlWidth, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inParentView), mPresets (inPresets), @@ -510,13 +510,13 @@ AUVPresets::AUVPresets (AUCarbonViewBase* inParentView, { #if !__LP64__ Rect r; - + // ok we now have an array of factory presets // get their strings and display them r.top = inLocation.v; r.bottom = r.top; r.left = inLocation.h; r.right = r.left; - + // localize as necessary if (!sAUVPresetLocalized) { CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); @@ -527,86 +527,86 @@ AUVPresets::AUVPresets (AUCarbonViewBase* inParentView, sAUVPresetLocalized = true; } } - + // create localized title string CFMutableStringRef factoryPresetsTitle = CFStringCreateMutable(NULL, 0); CFStringAppend(factoryPresetsTitle, kStringFactoryPreset); CFStringAppend(factoryPresetsTitle, kAUViewUnlocalizedString_TitleSeparator); - + ControlRef theControl; verify_noerr(CreateStaticTextControl(mView->GetCarbonWindow(), &r, factoryPresetsTitle, &inFontStyle, &theControl)); SInt16 width = 0; AUCarbonViewControl::SizeControlToFit(theControl, &width, &mHeight); CFRelease(factoryPresetsTitle); EmbedControl(theControl); - + r.top -= 2; r.left += width + 10; r.right = r.left; r.bottom = r.top; - - verify_noerr(CreatePopupButtonControl ( mView->GetCarbonWindow(), &r, NULL, + + verify_noerr(CreatePopupButtonControl ( mView->GetCarbonWindow(), &r, NULL, -12345, // DON'T GET MENU FROM RESOURCE mMenuID,!!! - FALSE, // variableWidth, - 0, // titleWidth, - 0, // titleJustification, - 0, // titleStyle, + FALSE, // variableWidth, + 0, // titleWidth, + 0, // titleJustification, + 0, // titleStyle, &mControl)); - + MenuRef menuRef; verify_noerr(CreateNewMenu(1, 0, &menuRef)); - + int numPresets = CFArrayGetCount(mPresets); - + for (int i = 0; i < numPresets; ++i) { AUPreset* preset = (AUPreset*) CFArrayGetValueAtIndex (mPresets, i); verify_noerr(AppendMenuItemTextWithCFString (menuRef, preset->presetName, 0, 0, 0)); } - + verify_noerr(SetControlData(mControl, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef)); verify_noerr (SetControlFontStyle (mControl, &inFontStyle)); - + SetControl32BitMaximum (mControl, numPresets); - + // size popup SInt16 height = 0; - + AUCarbonViewControl::SizeControlToFit(mControl, &width, &height); - + if (height > mHeight) mHeight = height; if (mHeight < 0) mHeight = 0; - + // find which menu item is the Default preset UInt32 propertySize = sizeof(AUPreset); AUPreset defaultPreset; - OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), + OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_PresentPreset, - kAudioUnitScope_Global, - 0, - &defaultPreset, + kAudioUnitScope_Global, + 0, + &defaultPreset, &propertySize); - + mPropertyID = kAudioUnitProperty_PresentPreset; -#endif +#endif #ifndef __LP64__ if (result != noErr) { // if the PresentPreset property is not implemented, fall back to the CurrentPreset property - OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), + OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_CurrentPreset, - kAudioUnitScope_Global, - 0, - &defaultPreset, + kAudioUnitScope_Global, + 0, + &defaultPreset, &propertySize); mPropertyID = kAudioUnitProperty_CurrentPreset; if (result == noErr) CFRetain (defaultPreset.presetName); - } + } #endif -#if !__LP64__ +#if !__LP64__ EmbedControl (mControl); - + HandlePropertyChange(defaultPreset); - + RegisterEvents(); #endif } @@ -620,7 +620,7 @@ void AUVPresets::AddInterest (AUEventListenerRef inListener, e.mArgument.mProperty.mPropertyID = mPropertyID; e.mArgument.mProperty.mScope = kAudioUnitScope_Global; e.mArgument.mProperty.mElement = 0; - + AUEventListenerAddEventType(inListener, inObject, &e); } @@ -644,14 +644,14 @@ void AUVPresets::HandleControlChange () if (i > 0) { AUPreset* preset = (AUPreset*) CFArrayGetValueAtIndex (mPresets, i-1); - - verify_noerr(AudioUnitSetProperty (mView->GetEditAudioUnit(), + + verify_noerr(AudioUnitSetProperty (mView->GetEditAudioUnit(), mPropertyID, // either currentPreset or PresentPreset depending on which is supported - kAudioUnitScope_Global, - 0, - preset, + kAudioUnitScope_Global, + 0, + preset, sizeof(AUPreset))); - + // when we change a preset we can't expect the AU to update its state // as it isn't meant to know that its being viewed! // so we broadcast a notification to all listeners that all parameters on this AU have changed @@ -663,12 +663,12 @@ void AUVPresets::HandleControlChange () #endif } -void AUVPresets::HandlePropertyChange(AUPreset &preset) +void AUVPresets::HandlePropertyChange(AUPreset &preset) { #if !__LP64__ // check to see if the preset is in our menu int numPresets = CFArrayGetCount(mPresets); - if (preset.presetNumber < 0) { + if (preset.presetNumber < 0) { SetControl32BitValue (mControl, 0); //controls are one-based } else { for (SInt32 i = 0; i < numPresets; ++i) { @@ -679,7 +679,7 @@ void AUVPresets::HandlePropertyChange(AUPreset &preset) } } } - + if (preset.presetName) CFRelease (preset.presetName); #endif @@ -687,16 +687,16 @@ void AUVPresets::HandlePropertyChange(AUPreset &preset) bool AUVPresets::HandlePropertyChange (const AudioUnitProperty &inProp) { - if (inProp.mPropertyID == mPropertyID) + if (inProp.mPropertyID == mPropertyID) { UInt32 theSize = sizeof(AUPreset); AUPreset currentPreset; - - OSStatus result = AudioUnitGetProperty(inProp.mAudioUnit, - inProp.mPropertyID, - inProp.mScope, + + OSStatus result = AudioUnitGetProperty(inProp.mAudioUnit, + inProp.mPropertyID, + inProp.mScope, inProp.mElement, ¤tPreset, &theSize); - + if (result == noErr) { #ifndef __LP64__ if (inProp.mPropertyID == kAudioUnitProperty_CurrentPreset && currentPreset.presetName) diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.h index 3d5f975614..b22e992ede 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.h +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewControl.h @@ -2,14 +2,14 @@ File: AUCarbonViewControl.h Abstract: Part of CoreAudio Utility Classes Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #ifndef __AUCarbonViewControl_h__ #define __AUCarbonViewControl_h__ @@ -69,7 +69,7 @@ public: kTypeDiscrete, // e.g. pop-up menu kTypeText }; - + AUCarbonViewControl(AUCarbonViewBase *ownerView, AUParameterListenerRef listener, ControlType type, const CAAUParameter ¶m, ControlRef control); ~AUCarbonViewControl(); @@ -80,7 +80,7 @@ public: virtual void ControlToParameter(); /*! @method ParameterToControl */ virtual void ParameterToControl(Float32 newValue); - + /*! @method SetValueFract */ virtual void SetValueFract(double value); /*! @method GetValueFract */ @@ -93,34 +93,34 @@ public: virtual void SetValue(long value); /*! @method GetValue */ virtual long GetValue(); - + /*! @method GetOwnerView */ AUCarbonViewBase * GetOwnerView() {return mOwnerView;} /*! @method Update */ - void Update (bool inUIThread) - { + void Update (bool inUIThread) + { if (inUIThread) ParameterToControl (mParam.GetValue()); else AUParameterListenerNotify (mListener, this, &mParam); } - - + + // CarbonEventHandler overrides /*! @method HandleEvent */ virtual bool HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event); - + /*! @method ControlRef */ operator ControlRef() { return mControl; } - + /*! @method SizeControlToFit */ static Boolean SizeControlToFit(ControlRef inControl, SInt16 *outWidth = NULL, SInt16 *outHeight = NULL); - + /*! @method SliderTrackProc */ static pascal void SliderTrackProc(ControlRef theControl, ControlPartCode partCode); /*! @method NumericKeyFilterCallback */ - static pascal ControlKeyFilterResult NumericKeyFilterCallback(ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, + static pascal ControlKeyFilterResult NumericKeyFilterCallback(ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers); protected: /*! @method ParamInfo */ @@ -137,12 +137,12 @@ protected: /*! @var mControl */ ControlRef mControl; - + /*! @method StdKeyFilterCallback */ - static pascal ControlKeyFilterResult StdKeyFilterCallback(ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, + static pascal ControlKeyFilterResult StdKeyFilterCallback(ControlRef theControl, SInt16 *keyCode, SInt16 *charCode, EventModifiers *modifiers); SInt16 mInControlInitialization; - + static AUCarbonViewControl* mLastControl; }; @@ -151,34 +151,34 @@ class AUPropertyControl : public CarbonEventHandler { public: /*! @ctor AUPropertyControl */ AUPropertyControl (AUCarbonViewBase * inBase) : mControl(0), mView (inBase), mHeight(0) {} - + /*! @method HandleEvent */ virtual bool HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event); /*! @method HandlePropertyChange */ virtual bool HandlePropertyChange (const AudioUnitProperty &inProp) = 0; - + /*! @method AddInterest */ virtual void AddInterest (AUEventListenerRef inListener, void * inObject) = 0; - + /*! @method RemoveInterest */ virtual void RemoveInterest (AUEventListenerRef inListener, void * inObject) = 0; - + /*! @method GetHeight */ int GetHeight() { return mHeight;} - + protected: /*! @method HandleControlChange */ - virtual void HandleControlChange () = 0; + virtual void HandleControlChange () = 0; /*! @method RegisterEvents */ void RegisterEvents (); /*! @method EmbedControl */ void EmbedControl (ControlRef theControl); - + /*! @method GetCarbonWindow */ WindowRef GetCarbonWindow(); @@ -194,30 +194,30 @@ protected: class AUVPresets : public AUPropertyControl { public: /*! @ctor HandleControlChange */ - AUVPresets (AUCarbonViewBase * inBase, + AUVPresets (AUCarbonViewBase * inBase, CFArrayRef& inPresets, - Point inLocation, - int nameWidth, - int controlWidth, + Point inLocation, + int nameWidth, + int controlWidth, ControlFontStyleRec & inFontStyle); virtual ~AUVPresets () { CFRelease (mPresets); } /*! @method HandlePropertyChange */ virtual bool HandlePropertyChange (const AudioUnitProperty &inProp); - + /*! @method AddInterest */ virtual void AddInterest (AUEventListenerRef inListener, void * inObject); - + /*! @method RemoveInterest */ virtual void RemoveInterest (AUEventListenerRef inListener, void * inObject); protected: /*! @method HandleControlChange */ - virtual void HandleControlChange (); - + virtual void HandleControlChange (); + /*! @var mPresets */ CFArrayRef mPresets; /*! @var mView */ diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewDispatch.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewDispatch.cpp index 15a04e827e..2762a675d1 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewDispatch.cpp +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUCarbonViewDispatch.cpp @@ -2,14 +2,14 @@ File: AUCarbonViewDispatch.cpp Abstract: AUCarbonViewDispatch.h Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #include "AUCarbonViewBase.h" @@ -93,7 +93,7 @@ OSStatus AUCarbonViewBase::ComponentEntryDispatch(ComponentParameters *p, AUCar if (This == NULL) return paramErr; OSStatus result = noErr; - + switch (p->what) { case kAudioUnitCarbonViewCreateSelect: { @@ -104,7 +104,7 @@ OSStatus AUCarbonViewBase::ComponentEntryDispatch(ComponentParameters *p, AUCar CheckNull(pb->inSize); CheckNull(pb->inLocation); CheckNull(pb->outControl); - result = This->CreateCarbonView(pb->inAudioUnit, pb->inWindow, pb->inParentControl, + result = This->CreateCarbonView(pb->inAudioUnit, pb->inWindow, pb->inParentControl, *pb->inLocation, *pb->inSize, *pb->outControl); } break; @@ -116,7 +116,7 @@ OSStatus AUCarbonViewBase::ComponentEntryDispatch(ComponentParameters *p, AUCar } break; #endif - + default: result = ComponentBase::ComponentEntryDispatch(p, This); break; diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.cpp index 8976b401c0..d0b7b4107a 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.cpp +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.cpp @@ -2,14 +2,14 @@ File: AUControlGroup.cpp Abstract: AUControlGroup.h Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #include <Carbon/Carbon.h> #include "AUCarbonViewBase.h" @@ -59,10 +59,10 @@ static bool sLocalized = false; #endif void AUControlGroup::CreateLabelledSlider( - AUCarbonViewBase * auView, - const CAAUParameter & auvp, - const Rect & area, - Point labelSize, + AUCarbonViewBase * auView, + const CAAUParameter & auvp, + const Rect & area, + Point labelSize, const ControlFontStyleRec & inFontStyle) { #if !__LP64__ @@ -73,14 +73,14 @@ void AUControlGroup::CreateLabelledSlider( CFStringRef cfstr; int sliderValueMax, sliderValueMin, sliderValueDefault; AUCarbonViewControl::ControlType sliderType; - + bool horizontal = (width > height); if (horizontal) { maxValRect.top = minValRect.top = area.top + (height - labelSize.v) / 2; minValRect.left = area.left; maxValRect.left = area.right - labelSize.h; - + minValRect.bottom = minValRect.top + labelSize.v; minValRect.right = minValRect.left + labelSize.h; maxValRect.bottom = maxValRect.top + labelSize.v; @@ -104,12 +104,12 @@ void AUControlGroup::CreateLabelledSlider( maxValRect.left = minValRect.left = area.left + (width - labelSize.h) / 2; maxValRect.top = area.top; minValRect.top = area.bottom - labelSize.v; - + minValRect.bottom = minValRect.top + labelSize.v; minValRect.right = minValRect.left + labelSize.h; maxValRect.bottom = maxValRect.top + labelSize.v; maxValRect.right = maxValRect.left + labelSize.h; - + sliderRect.left = area.left + (width - kSliderThinDimension) / 2; sliderRect.right = sliderRect.left + kSliderThinDimension + 4; sliderRect.top = maxValRect.bottom + kLabelAndSliderSpacing; @@ -117,7 +117,7 @@ void AUControlGroup::CreateLabelledSlider( if (auvp.IsIndexedParam ()) { sliderValueMin = sliderValueDefault = int(auvp.ParamInfo().minValue); - sliderValueMax = int(auvp.ParamInfo().maxValue); + sliderValueMax = int(auvp.ParamInfo().maxValue); sliderType = AUCarbonViewControl::kTypeDiscrete; } else { sliderValueMin = sliderValueDefault = 0; @@ -134,7 +134,7 @@ void AUControlGroup::CreateLabelledSlider( verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &minValRect, cfstr, &fontStyle, &newControl)); CFRelease(cfstr); verify_noerr(auView->EmbedControl(newControl)); - + // maximum value label cfstr = auvp.GetStringFromValueCopy(&auvp.ParamInfo().maxValue); fontStyle.just = horizontal ? teFlushLeft : teCenter; @@ -142,7 +142,7 @@ void AUControlGroup::CreateLabelledSlider( CFRelease(cfstr); verify_noerr(auView->EmbedControl(newControl)); } - + // slider verify_noerr(CreateSliderControl(auView->GetCarbonWindow(), &sliderRect, sliderValueDefault, sliderValueMin, sliderValueMax, kControlSliderDoesNotPoint, 0, true, AUCarbonViewControl::SliderTrackProc, &newControl)); @@ -154,10 +154,10 @@ void AUControlGroup::CreateLabelledSlider( } void AUControlGroup::CreateLabelledSliderAndEditText( - AUCarbonViewBase * auView, - const CAAUParameter & auvp, - const Rect & area, - Point labelSize, + AUCarbonViewBase * auView, + const CAAUParameter & auvp, + const Rect & area, + Point labelSize, Point editTextSize, const ControlFontStyleRec & inFontStyle) { @@ -166,7 +166,7 @@ void AUControlGroup::CreateLabelledSliderAndEditText( Rect sliderArea, textArea; ControlRef newControl; int width = area.right - area.left, height = area.bottom - area.top; - + bool horizontal = (width > height); sliderArea = area; @@ -188,55 +188,55 @@ void AUControlGroup::CreateLabelledSliderAndEditText( textArea.right = textArea.left + editTextSize.h; } CreateLabelledSlider(auView, auvp, sliderArea, labelSize, fontStyle); - - verify_noerr(CreateEditUnicodeTextControl(auView->GetCarbonWindow(), &textArea, CFSTR(""), false, + + verify_noerr(CreateEditUnicodeTextControl(auView->GetCarbonWindow(), &textArea, CFSTR(""), false, &fontStyle, &newControl)); auView->AddCarbonControl(AUCarbonViewControl::kTypeText, auvp, newControl); #endif } -void AUControlGroup::CreatePopupMenu (AUCarbonViewBase * auView, - const CAAUParameter & auvp, - const Rect & area, +void AUControlGroup::CreatePopupMenu (AUCarbonViewBase * auView, + const CAAUParameter & auvp, + const Rect & area, const ControlFontStyleRec & inFontStyle, const bool inSizeToFit) { #if !__LP64__ ControlRef thePopUp; - - verify_noerr(CreatePopupButtonControl (auView->GetCarbonWindow(), &area, NULL, + + verify_noerr(CreatePopupButtonControl (auView->GetCarbonWindow(), &area, NULL, -12345, // DON'T GET MENU FROM RESOURCE mMenuID - FALSE, // variableWidth, - 0, // titleWidth, - 0, // titleJustification, - 0, // titleStyle, + FALSE, // variableWidth, + 0, // titleWidth, + 0, // titleJustification, + 0, // titleStyle, &thePopUp)); - + ControlSize small = kControlSizeSmall; SetControlData(thePopUp, kControlEntireControl, kControlSizeTag, sizeof(ControlSize), &small); - + MenuRef menuRef; verify_noerr(CreateNewMenu( 1, 0, &menuRef)); - + for (int i = 0; i < auvp.GetNumIndexedParams(); ++i) { verify_noerr(AppendMenuItemTextWithCFString (menuRef, auvp.GetParamName(i), kMenuItemAttrIgnoreMeta, 0, 0)); } - + verify_noerr(SetControlData(thePopUp, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef)); SetControl32BitMaximum(thePopUp, auvp.GetNumIndexedParams()); verify_noerr (SetControlFontStyle (thePopUp, &inFontStyle)); - + if (inSizeToFit) { AUCarbonViewControl::SizeControlToFit(thePopUp); } - + auView->AddCarbonControl(AUCarbonViewControl::kTypeDiscrete, auvp, thePopUp); #endif } -void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, - const Point & inLocation, +void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, + const Point & inLocation, const SInt16 inRightOffset, const SInt16 inTotalWidth) { @@ -245,14 +245,14 @@ void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, ComponentDescription desc; Handle h1 = NewHandleClear(4); OSStatus err = GetComponentInfo ((Component)auView->GetEditAudioUnit(), &desc, h1, 0, 0); - - if (err == noErr) { + + if (err == noErr) { // Get the manufacturer's name... look for the ':' character convention HLock(h1); char* ptr1 = *h1; int len = *ptr1++; char* displayStr = 0; - + for (int i = 0; i < len; ++i) { if (ptr1[i] == ':') { // found the name ptr1[i++] = 0; @@ -260,7 +260,7 @@ void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, break; } } - + // localize as necessary: if (!sLocalized) { CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); @@ -271,7 +271,7 @@ void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, sLocalized = true; } } - + // display strings ControlRef newControl; Rect r; @@ -279,7 +279,7 @@ void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, ControlFontStyleRec fontStyle; fontStyle.flags = kControlUseFontMask | kControlUseJustMask; fontStyle.font = kControlFontSmallBoldSystemFont; - + // display manufacturer string if (displayStr) { CFMutableStringRef mfrstring = CFStringCreateMutable(NULL, 0); @@ -291,15 +291,15 @@ void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, CFStringAppend(mfrstring, mfrname); // "Manufacturer: MFRName" CFRelease (mfrname); } - - r.left = inLocation.h + inRightOffset; + + r.left = inLocation.h + inRightOffset; r.right = inLocation.h + inTotalWidth - 28; fontStyle.just = teFlushRight; - + verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, mfrstring, &fontStyle, &newControl)); verify_noerr(auView->EmbedControl(newControl)); CFRelease (mfrstring); - + //move displayStr ptr past the manu, to the name // we move the characters down an index, because the handle doesn't have any room // at the end for the \0 @@ -316,42 +316,42 @@ void AUControlGroup::AddAUInfo ( AUCarbonViewBase * auView, displayStr[j] = displayStr[i]; ++j; ++i; } while (i < len); - + displayStr[j] = 0; } - + // display AudioUnit string r.left = inLocation.h; r.right = r.left + inRightOffset; fontStyle.just = 0; - + CFMutableStringRef cfstr = CFStringCreateMutable(NULL, 0); CFStringAppend(cfstr, kAUViewLocalizedStringKey_AudioUnit); // "Audio Unit" CFStringAppend(cfstr, kAUViewUnlocalizedString_TitleSeparator); // "Audio Unit: " - + CFStringRef auname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8); CFStringAppend(cfstr, auname); // "Audio Unit: AUName" CFRelease (auname); - + verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, cfstr, &fontStyle, &newControl)); - + // size text control correctly Boolean bValue = false; SetControlData(newControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue); SInt16 baseLineOffset; Rect bestRect; - err = GetBestControlRect(newControl, &bestRect, &baseLineOffset); + err = GetBestControlRect(newControl, &bestRect, &baseLineOffset); if (err == noErr) { int width = (bestRect.right - bestRect.left) + 1; int height = (bestRect.bottom - bestRect.top) + 1; SizeControl (newControl, width, height); } - + verify_noerr(auView->EmbedControl(newControl)); CFRelease (cfstr); } - + DisposeHandle (h1); #endif } diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.h index 0e16100d2a..89ef4f29b7 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.h +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/AUControlGroup.h @@ -2,14 +2,14 @@ File: AUControlGroup.h Abstract: Part of CoreAudio Utility Classes Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #ifndef __AUControlGroup_h__ #define __AUControlGroup_h__ @@ -57,31 +57,31 @@ class CAAUParameter; class AUControlGroup { public: /*! @method CreateLabelledSlider */ - static void CreateLabelledSlider( AUCarbonViewBase * auView, - const CAAUParameter & auvp, - const Rect & area, - Point labelSize, + static void CreateLabelledSlider( AUCarbonViewBase * auView, + const CAAUParameter & auvp, + const Rect & area, + Point labelSize, const ControlFontStyleRec & fontStyle); /*! @method CreateLabelledSliderAndEditText */ static void CreateLabelledSliderAndEditText( - AUCarbonViewBase * auView, - const CAAUParameter & auvp, - const Rect & area, - Point labelSize, + AUCarbonViewBase * auView, + const CAAUParameter & auvp, + const Rect & area, + Point labelSize, Point editTextSize, const ControlFontStyleRec & fontStyle); /*! @method CreatePopupMenu */ - static void CreatePopupMenu ( AUCarbonViewBase * auView, - const CAAUParameter & auvp, - const Rect & area, + static void CreatePopupMenu ( AUCarbonViewBase * auView, + const CAAUParameter & auvp, + const Rect & area, const ControlFontStyleRec & inFontStyle, const bool inSizeToFit = false); /*! @method AddAUInfo */ - static void AddAUInfo ( AUCarbonViewBase * auView, - const Point & inLocation, + static void AddAUInfo ( AUCarbonViewBase * auView, + const Point & inLocation, const SInt16 inRightOffset, const SInt16 inTotalWidth); }; diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.cpp b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.cpp index fe9a731d1d..c935e3351b 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.cpp +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.cpp @@ -2,14 +2,14 @@ File: CarbonEventHandler.cpp Abstract: CarbonEventHandler.h Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #include "CarbonEventHandler.h" @@ -65,22 +65,22 @@ CarbonEventHandler::~CarbonEventHandler() int count = static_cast<int>(CFDictionaryGetCount(mHandlers)); EventHandlerRef *theHandlers = (EventHandlerRef*) malloc(count * sizeof(EventHandlerRef)); CFDictionaryGetKeysAndValues(mHandlers, NULL, (const void **)theHandlers); - + for (int i = 0; i < count; i++) RemoveEventHandler(theHandlers[i]); CFDictionaryRemoveAllValues(mHandlers); CFRelease (mHandlers); free(theHandlers); - } + } } void CarbonEventHandler::WantEventTypes(EventTargetRef target, UInt32 inNumTypes, const EventTypeSpec *inList) { if (mHandlers == NULL) mHandlers = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); - + EventHandlerRef handler; - + if (CFDictionaryGetValueIfPresent (mHandlers, target, (const void **)&handler)) // if there is already a handler for the target, add the type verify_noerr(AddEventTypesToHandler(handler, inNumTypes, inList)); else { diff --git a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.h b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.h index 9225e1acd7..b3231a8182 100644 --- a/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.h +++ b/libs/appleutility/CoreAudio/AudioUnits/AUPublic/AUCarbonViewBase/CarbonEventHandler.h @@ -2,14 +2,14 @@ File: CarbonEventHandler.h Abstract: Part of CoreAudio Utility Classes Version: 1.1 - + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. - + In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the @@ -25,13 +25,13 @@ implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. - + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. - + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -40,9 +40,9 @@ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + Copyright (C) 2014 Apple Inc. All Rights Reserved. - + */ #ifndef __CarbonEventHandler_h__ #define __CarbonEventHandler_h__ @@ -56,7 +56,7 @@ public: CarbonEventHandler(); /*! @dtor ~CarbonEventHandler */ virtual ~CarbonEventHandler(); - + /*! @method WantEventTypes */ virtual void WantEventTypes(EventTargetRef target, UInt32 inNumTypes, const EventTypeSpec *inList); |