//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 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(); }
bool AUDiskStreamingCheckbox::HandlePropertyChange (const AudioUnitProperty &inProp) { if (inProp.mPropertyID == kMusicDeviceProperty_StreamFromDisk) { UInt32 propVal; UInt32 theSize = sizeof (UInt32); ComponentResult result = AudioUnitGetProperty(inProp.mAudioUnit, inProp.mPropertyID, inProp.mScope, inProp.mElement, &propVal, &theSize); if (result == noErr) { HandlePropertyChange(propVal); return true; } } return false; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 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(); }
bool AUVPresets::HandlePropertyChange (const AudioUnitProperty &inProp) { if (inProp.mPropertyID == mPropertyID) { UInt32 theSize = sizeof(AUPreset); AUPreset currentPreset; 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) CFRetain (currentPreset.presetName); #endif HandlePropertyChange(currentPreset); return true; } } return false; }
bool wxApp::ProcessXEvent(WXEvent* _event) { XEvent* event = (XEvent*) _event; wxWindow* win = NULL; Window window = XEventGetWindow(event); #if 0 Window actualWindow = window; #endif // Find the first wxWindow that corresponds to this event window // Because we're receiving events after a window // has been destroyed, assume a 1:1 match between // Window and wxWindow, so if it's not in the table, // it must have been destroyed. win = wxGetWindowFromTable(window); if (!win) { #if wxUSE_TWO_WINDOWS win = wxGetClientWindowFromTable(window); if (!win) #endif return false; } switch (event->type) { case Expose: { #if wxUSE_TWO_WINDOWS && !wxUSE_NANOX if (event->xexpose.window != (Window)win->GetClientAreaWindow()) { XEvent tmp_event; wxExposeInfo info; info.window = event->xexpose.window; info.found_non_matching = false; while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, wxX11ExposePredicate, (XPointer) &info )) { // Don't worry about optimizing redrawing the border etc. } win->NeedUpdateNcAreaInIdle(); } else #endif { win->GetUpdateRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event), XExposeEventGetWidth(event), XExposeEventGetHeight(event)); win->GetClearRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event), XExposeEventGetWidth(event), XExposeEventGetHeight(event)); #if !wxUSE_NANOX XEvent tmp_event; wxExposeInfo info; info.window = event->xexpose.window; info.found_non_matching = false; while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, wxX11ExposePredicate, (XPointer) &info )) { win->GetUpdateRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y, tmp_event.xexpose.width, tmp_event.xexpose.height ); win->GetClearRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y, tmp_event.xexpose.width, tmp_event.xexpose.height ); } #endif // This simplifies the expose and clear areas to simple // rectangles. win->GetUpdateRegion() = win->GetUpdateRegion().GetBox(); win->GetClearRegion() = win->GetClearRegion().GetBox(); // If we only have one X11 window, always indicate // that borders might have to be redrawn. if (win->X11GetMainWindow() == win->GetClientAreaWindow()) win->NeedUpdateNcAreaInIdle(); // Only erase background, paint in idle time. win->SendEraseEvents(); // EXPERIMENT //win->Update(); } return true; } #if !wxUSE_NANOX case GraphicsExpose: { wxLogTrace( wxT("expose"), wxT("GraphicsExpose from %s"), win->GetName().c_str()); win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y, event->xgraphicsexpose.width, event->xgraphicsexpose.height); win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y, event->xgraphicsexpose.width, event->xgraphicsexpose.height); if (event->xgraphicsexpose.count == 0) { // Only erase background, paint in idle time. win->SendEraseEvents(); // win->Update(); } return true; } #endif case KeyPress: { if (!win->IsEnabled()) return false; wxKeyEvent keyEvent(wxEVT_KEY_DOWN); wxTranslateKeyEvent(keyEvent, win, window, event); // wxLogDebug( "OnKey from %s", win->GetName().c_str() ); // We didn't process wxEVT_KEY_DOWN, so send wxEVT_CHAR if (win->HandleWindowEvent( keyEvent )) return true; keyEvent.SetEventType(wxEVT_CHAR); // Do the translation again, retaining the ASCII // code. if (wxTranslateKeyEvent(keyEvent, win, window, event, true) && win->HandleWindowEvent( keyEvent )) return true; if ( (keyEvent.m_keyCode == WXK_TAB) && win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) ) { wxNavigationKeyEvent new_event; new_event.SetEventObject( win->GetParent() ); /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */ new_event.SetDirection( (keyEvent.m_keyCode == WXK_TAB) ); /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ new_event.SetWindowChange( keyEvent.ControlDown() ); new_event.SetCurrentFocus( win ); return win->GetParent()->HandleWindowEvent( new_event ); } return false; } case KeyRelease: { if (!win->IsEnabled()) return false; wxKeyEvent keyEvent(wxEVT_KEY_UP); wxTranslateKeyEvent(keyEvent, win, window, event); return win->HandleWindowEvent( keyEvent ); } case ConfigureNotify: { #if wxUSE_NANOX if (event->update.utype == GR_UPDATE_SIZE) #endif { wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow); if ( tlw ) { tlw->SetConfigureGeometry( XConfigureEventGetX(event), XConfigureEventGetY(event), XConfigureEventGetWidth(event), XConfigureEventGetHeight(event) ); } if ( tlw && tlw->IsShown() ) { tlw->SetNeedResizeInIdle(); } else { wxSizeEvent sizeEvent( wxSize(XConfigureEventGetWidth(event), XConfigureEventGetHeight(event)), win->GetId() ); sizeEvent.SetEventObject( win ); return win->HandleWindowEvent( sizeEvent ); } } return false; } #if !wxUSE_NANOX case PropertyNotify: return HandlePropertyChange(_event); case ClientMessage: { if (!win->IsEnabled()) return false; Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True); Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True); if (event->xclient.message_type == wm_protocols) { if ((Atom) (event->xclient.data.l[0]) == wm_delete_window) { win->Close(false); return true; } } return false; } #if 0 case DestroyNotify: { printf( "destroy from %s\n", win->GetName().c_str() ); break; } case CreateNotify: { printf( "create from %s\n", win->GetName().c_str() ); break; } case MapRequest: { printf( "map request from %s\n", win->GetName().c_str() ); break; } case ResizeRequest: { printf( "resize request from %s\n", win->GetName().c_str() ); Display *disp = (Display*) wxGetDisplay(); XEvent report; // to avoid flicker report = * event; while( XCheckTypedWindowEvent (disp, actualWindow, ResizeRequest, &report)); wxSize sz = win->GetSize(); wxSizeEvent sizeEvent(sz, win->GetId()); sizeEvent.SetEventObject(win); return win->HandleWindowEvent( sizeEvent ); } #endif #endif #if wxUSE_NANOX case GR_EVENT_TYPE_CLOSE_REQ: { if (win) { win->Close(false); return true; } return false; break; } #endif case EnterNotify: case LeaveNotify: case ButtonPress: case ButtonRelease: case MotionNotify: { if (!win->IsEnabled()) return false; // Here we check if the top level window is // disabled, which is one aspect of modality. wxWindow *tlw = win; while (tlw && !tlw->IsTopLevel()) tlw = tlw->GetParent(); if (tlw && !tlw->IsEnabled()) return false; if (event->type == ButtonPress) { if ((win != wxWindow::FindFocus()) && win->CanAcceptFocus()) { // This might actually be done in wxWindow::SetFocus() // and not here. TODO. g_prevFocus = wxWindow::FindFocus(); g_nextFocus = win; wxLogTrace( wxT("focus"), wxT("About to call SetFocus on %s of type %s due to button press"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() ); // Record the fact that this window is // getting the focus, because we'll need to // check if its parent is getting a bogus // focus and duly ignore it. // TODO: may need to have this code in SetFocus, too. extern wxWindow* g_GettingFocus; g_GettingFocus = win; win->SetFocus(); } } #if !wxUSE_NANOX if (event->type == LeaveNotify || event->type == EnterNotify) { // Throw out NotifyGrab and NotifyUngrab if (event->xcrossing.mode != NotifyNormal) return false; } #endif wxMouseEvent wxevent; wxTranslateMouseEvent(wxevent, win, window, event); return win->HandleWindowEvent( wxevent ); } case FocusIn: #if !wxUSE_NANOX if ((event->xfocus.detail != NotifyPointer) && (event->xfocus.mode == NotifyNormal)) #endif { wxLogTrace( wxT("focus"), wxT("FocusIn from %s of type %s"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() ); extern wxWindow* g_GettingFocus; if (g_GettingFocus && g_GettingFocus->GetParent() == win) { // Ignore this, this can be a spurious FocusIn // caused by a child having its focus set. g_GettingFocus = NULL; wxLogTrace( wxT("focus"), wxT("FocusIn from %s of type %s being deliberately ignored"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() ); return true; } else { wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId()); focusEvent.SetEventObject(win); focusEvent.SetWindow( g_prevFocus ); g_prevFocus = NULL; return win->HandleWindowEvent(focusEvent); } } return false; case FocusOut: #if !wxUSE_NANOX if ((event->xfocus.detail != NotifyPointer) && (event->xfocus.mode == NotifyNormal)) #endif { wxLogTrace( wxT("focus"), wxT("FocusOut from %s of type %s"), win->GetName().c_str(), win->GetClassInfo()->GetClassName() ); wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId()); focusEvent.SetEventObject(win); focusEvent.SetWindow( g_nextFocus ); g_nextFocus = NULL; return win->HandleWindowEvent(focusEvent); } return false; } return false; }
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(); }