//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AUDiskStreamingCheckbox::AUDiskStreamingCheckbox // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, Point inLocation, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inBase) { Rect r; r.top = inLocation.v; r.bottom = r.top; r.left = inLocation.h; r.right = r.left; // localize as necessary if (!sLocalized) { sLocalized = true; CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView); if (mainBundle) { kStringStreamFromDisk = CFCopyLocalizedStringFromTableInBundle( kAUViewLocalizedStringKey_StreamFromDisk, kLocalizedStringTable_AUView, mainBundle, CFSTR("'Stream From Disk' checkbox title string")); } } verify_noerr(CreateCheckBoxControl( GetCarbonWindow(), &r, kStringStreamFromDisk, 0, true, &mControl)); verify_noerr (SetControlFontStyle (mControl, &inFontStyle)); ControlSize smallSize = kControlSizeSmall; verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize)); AUCarbonViewControl::SizeControlToFit(mControl, NULL, &mHeight); if (mHeight < 0) mHeight = 0; EmbedControl(mControl); UInt32 value = 0; UInt32 size = sizeof(value); verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size)); HandlePropertyChange (value); RegisterEvents(); }
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, -12345, // DON'T GET MENU FROM RESOURCE mMenuID 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 }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AUDiskStreamingCheckbox::AUDiskStreamingCheckbox // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, Point inLocation, int inRightEdge, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inBase) { Rect r; r.top = inLocation.v; r.bottom = r.top + 16; r.left = inLocation.h; r.right = r.left + inRightEdge; verify_noerr(CreateCheckBoxControl(mView->GetCarbonWindow(), &r, CFSTR("Disk Streaming"), 0, true, &mControl)); verify_noerr (SetControlFontStyle (mControl, &inFontStyle)); ControlSize smallSize = kControlSizeSmall; verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize)); SInt16 baseLineOffset; verify_noerr (GetBestControlRect (mControl, &r, &baseLineOffset)); r.bottom += baseLineOffset; SInt16 difference = (r.left + inRightEdge) - r.right; r.right += difference; r.left += difference; SetControlBounds (mControl, &r); EmbedControl(mControl); verify_noerr (AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, DiskStreamingListener, this)); UInt32 value; UInt32 size = sizeof(value); verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size)); HandlePropertyChange (value); RegisterEvents(); }
void TkpDisplayMenuButton( ClientData clientData) /* Information about widget. */ { TkMenuButton *butPtr = (TkMenuButton *) clientData; Tk_Window tkwin = butPtr->tkwin; TkWindow * winPtr; Pixmap pixmap; MacMenuButton * mbPtr = (MacMenuButton *) butPtr; GWorldPtr dstPort; CGrafPtr saveWorld; GDHandle saveDevice; int hasImageOrBitmap = 0; int width, height; int err; ControlButtonGraphicAlignment theAlignment; Rect paneRect, cntrRect; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = ( Pixmap )Tk_WindowId(tkwin); GetGWorld(&saveWorld, &saveDevice); dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); SetGWorld(dstPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); winPtr=(TkWindow *)butPtr->tkwin; paneRect.left=winPtr->privatePtr->xOff; paneRect.top=winPtr->privatePtr->yOff; paneRect.right=paneRect.left+Tk_Width(butPtr->tkwin)-1; paneRect.bottom=paneRect.top+Tk_Height(butPtr->tkwin)-1; cntrRect=paneRect; cntrRect.left+=butPtr->inset; cntrRect.top+=butPtr->inset; cntrRect.right-=butPtr->inset; cntrRect.bottom-=butPtr->inset; if (mbPtr->userPane) { MenuButtonControlParams params; bzero(¶ms, sizeof(params)); ComputeMenuButtonControlParams(butPtr, ¶ms ); if (bcmp(¶ms,&mbPtr->params,sizeof(params))) { if (mbPtr->userPane) { DisposeControl(mbPtr->userPane); mbPtr->userPane = NULL; mbPtr->control = NULL; } } } if (!mbPtr->userPane) { if (MenuButtonInitControl(mbPtr,&paneRect,&cntrRect ) ) { fprintf(stderr,"Init Control failed\n" ); return; } } SetControlBounds(mbPtr->userPane,&paneRect); SetControlBounds(mbPtr->control,&cntrRect); /* * We need to cache the title and its style */ if (!(mbPtr->flags&2)) { ControlTitleParams titleParams; int titleChanged; int styleChanged; ComputeControlTitleParams(butPtr,&titleParams); CompareControlTitleParams(&titleParams,&mbPtr->titleParams, &titleChanged,&styleChanged); if (titleChanged) { CFStringRef cf; cf = CFStringCreateWithCString(NULL, titleParams.title, kCFStringEncodingUTF8); if (hasImageOrBitmap) { SetControlTitleWithCFString(mbPtr->control, cf); } else { SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf); } CFRelease(cf); bcopy(titleParams.title,mbPtr->titleParams.title,titleParams.len+1); mbPtr->titleParams.len = titleParams.len; } if ((titleChanged||styleChanged) && titleParams .len) { if (hasImageOrBitmap) { if ((err=SetControlFontStyle(mbPtr->control,&titleParams.style))!=noErr) { fprintf(stderr,"SetControlFontStyle failed %d\n", err); return; } } bcopy(&titleParams.style,&mbPtr->titleParams.style,sizeof(titleParams.style)); } } if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, &width, &height); hasImageOrBitmap = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); hasImageOrBitmap = 1; } if (hasImageOrBitmap) { mbPtr->picParams.srcRect.right = width; mbPtr->picParams.srcRect.bottom = height; /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */ tkPictureIsOpen = 1; if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) { fprintf(stderr,"OpenCPicture failed\n"); } /* * TO DO - There is one case where XCopyPlane calls CopyDeepMask, * which does not get recorded in the picture. So the bitmap code * will fail in that case. */ if (butPtr->image != NULL) { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0); } else { XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, NULL, 0, 0, (unsigned int) width, (unsigned int) height, 0, 0, 1); } ClosePicture(); tkPictureIsOpen = 0; if ( (err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), (char *) &mbPtr->bevelButtonContent)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err ); } switch (butPtr->anchor) { case TK_ANCHOR_N: theAlignment = kControlBevelButtonAlignTop; break; case TK_ANCHOR_NE: theAlignment = kControlBevelButtonAlignTopRight; break; case TK_ANCHOR_E: theAlignment = kControlBevelButtonAlignRight; break; case TK_ANCHOR_SE: theAlignment = kControlBevelButtonAlignBottomRight; break; case TK_ANCHOR_S: theAlignment = kControlBevelButtonAlignBottom; break; case TK_ANCHOR_SW: theAlignment = kControlBevelButtonAlignBottomLeft; break; case TK_ANCHOR_W: theAlignment = kControlBevelButtonAlignLeft; break; case TK_ANCHOR_NW: theAlignment = kControlBevelButtonAlignTopLeft; break; case TK_ANCHOR_CENTER: theAlignment = kControlBevelButtonAlignCenter; break; } if ((err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonGraphicAlignTag, sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err ); } } if (butPtr->flags & GOT_FOCUS) { HiliteControl(mbPtr->control,kControlButtonPart); } else { HiliteControl(mbPtr->control,kControlNoPart); } UpdateControlColors(mbPtr); if (mbPtr->flags&2) { ShowControl(mbPtr->control); ShowControl(mbPtr->userPane); mbPtr->flags ^= 2; } else { Draw1Control(mbPtr->userPane); SetControlVisibility(mbPtr->control, true, true); } if (hasImageOrBitmap) { KillPicture(mbPtr->bevelButtonContent.u.picture); } SetGWorld(saveWorld, saveDevice); }
void AboutDialog (void) { OSStatus err; IBNibRef nibRef; err = CreateNibReference(kMacS9XCFString, &nibRef); if (err == noErr) { WindowRef tWindowRef; err = CreateWindowFromNib(nibRef, CFSTR("About"), &tWindowRef); if (err == noErr) { EventHandlerRef eref; EventHandlerUPP eventUPP; EventTypeSpec windowEvents[] = { { kEventClassWindow, kEventWindowClose }, { kEventClassCommand, kEventCommandUpdateStatus } }; ControlFontStyleRec frec; HIViewRef ctl, root; HIViewID cid; char text[32]; err = ChangeWindowAttributes(tWindowRef, kWindowNoAttributes, kWindowInWindowMenuAttribute); if (systemVersion >= 0x1040) frec.font = FMGetFontFromATSFontRef(ATSFontFindFromName(CFSTR("Lucida Grande"), kATSOptionFlagsDefault)); #ifdef MAC_PANTHER_SUPPORT else frec.font = kThemeSystemFont; #endif frec.just = teCenter; root = HIViewGetRoot(tWindowRef); cid.id = 0; cid.signature = 'VERS'; HIViewFindByID(root, cid, &ctl); sprintf(text, "Version %s (%s)", VERSION, MAC_VERSION); SetStaticTextCStr(ctl, text, false); frec.flags = kControlUseFontMask | kControlUseSizeMask | kControlUseJustMask; frec.size = 10; err = SetControlFontStyle(ctl, &frec); cid.signature = 'NAME'; HIViewFindByID(root, cid, &ctl); frec.flags = kControlUseFontMask | kControlUseSizeMask | kControlUseFaceMask | kControlUseJustMask; frec.size = 14; frec.style = 1; err = SetControlFontStyle(ctl, &frec); eventUPP = NewEventHandlerUPP(DefaultEventHandler); err = InstallWindowEventHandler(tWindowRef, eventUPP, GetEventTypeCount(windowEvents), windowEvents, (void *) tWindowRef, &eref); MoveWindowPosition(tWindowRef, kWindowAbout, false); ShowWindow(tWindowRef); err = RunAppModalLoopForWindow(tWindowRef); HideWindow(tWindowRef); SaveWindowPosition(tWindowRef, kWindowAbout); err = RemoveEventHandler(eref); DisposeEventHandlerUPP(eventUPP); CFRelease(tWindowRef); } DisposeNibReference(nibRef); } }
AUVPresets::AUVPresets (AUCarbonViewBase* inParentView, CFArrayRef& inPresets, Point inLocation, int nameWidth, int controlWidth, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inParentView), mPresets (inPresets), mView (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); if (mainBundle) { kStringFactoryPreset = CFCopyLocalizedStringFromTableInBundle( kAUViewLocalizedStringKey_FactoryPreset, kLocalizedStringTable_AUView, mainBundle, CFSTR("FactoryPreset title string")); 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, -12345, // DON'T GET MENU FROM RESOURCE mMenuID,!!! 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(), kAudioUnitProperty_PresentPreset, kAudioUnitScope_Global, 0, &defaultPreset, &propertySize); mPropertyID = kAudioUnitProperty_PresentPreset; #endif #ifndef __LP64__ if (result != noErr) { // if the PresentPreset property is not implemented, fall back to the CurrentPreset property OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_CurrentPreset, kAudioUnitScope_Global, 0, &defaultPreset, &propertySize); mPropertyID = kAudioUnitProperty_CurrentPreset; if (result == noErr) CFRetain (defaultPreset.presetName); } #endif #if !__LP64__ EmbedControl (mControl); HandlePropertyChange(defaultPreset); RegisterEvents(); #endif }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // AURenderQualityPopup::AURenderQualityPopup // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AURenderQualityPopup::AURenderQualityPopup (AUCarbonViewBase *inBase, Point inLocation, int inRightEdge, ControlFontStyleRec & inFontStyle) : AUPropertyControl (inBase) { Rect r; r.top = inLocation.v; r.bottom = r.top + 17; r.left = inLocation.h; r.right = r.left + inRightEdge; ControlFontStyleRec fontStyle = inFontStyle; inFontStyle.just = teFlushRight; ControlRef ref; CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.audio.units.Components")); if (mainBundle != NULL) { CFMutableStringRef renderTitle = CFStringCreateMutable(NULL, 0); CFStringAppend(renderTitle, CFCopyLocalizedStringFromTableInBundle( CFSTR("Render Quality"), CFSTR("CustomUI"), mainBundle, CFSTR("The Render Quality Popup menu title"))); CFStringAppend(renderTitle, CFSTR(":")); OSErr theErr = CreateStaticTextControl (GetCarbonWindow(), &r, renderTitle, &inFontStyle, &ref); if (theErr == noErr) EmbedControl(ref); r.left = r.right + 8; r.right = r.left + 100; short bundleRef = CFBundleOpenBundleResourceMap (mainBundle); theErr = CreatePopupButtonControl (mView->GetCarbonWindow(), &r, NULL, /*kQualityMenuID*/ -12345, false, -1, 0, 0, &mControl); MenuRef menuRef; verify_noerr(CreateNewMenu(kQualityMenuID, 0, &menuRef)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Maximum"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("High"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Medium"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Low"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Minimum"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0)); verify_noerr(SetControlData(mControl, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef)); verify_noerr(SetControlFontStyle (mControl, &inFontStyle)); SetControl32BitMaximum(mControl, 5); UInt32 renderQuality; UInt32 size = sizeof(UInt32); AudioUnitGetProperty (mView->GetEditAudioUnit(), kAudioUnitProperty_RenderQuality, kAudioUnitScope_Global, 0, &renderQuality, &size); HandlePropertyChange(renderQuality); EmbedControl(mControl); theErr = AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kAudioUnitProperty_RenderQuality, RenderQualityListener, this); CFBundleCloseBundleResourceMap (mainBundle, bundleRef); CFRelease(renderTitle); } RegisterEvents(); }