OSStatus CreateMouseTrackingView(HIViewRef parentView, const Rect* inBounds, HIViewID* inViewID) { #define kCanvasClassID CFSTR( "com.apple.sample.canvasview" ) OSStatus err; EventRef event; HIViewRef theView; // Register this class err = MyMTViewRegister(kCanvasClassID); require_noerr( err, CantRegister ); // Make an initialization event err = CreateEvent( NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, &event ); require_noerr( err, CantCreateEvent ); // If bounds were specified, push them into the initialization event // so that they can be used in the initialization handler. if ( inBounds != NULL ) { err = SetEventParameter(event, kCanvasBoundsParam, typeQDRectangle, sizeof(Rect), inBounds); require_noerr( err, CantSetParameter ); } err = HIObjectCreate(kCanvasClassID, event, (HIObjectRef*)&theView); require_noerr(err, CantCreate); if (parentView != NULL) { err = HIViewAddSubview(parentView, theView); } SetControlID(theView, inViewID); // useful if a handler needs to call GetControlByID() HIViewSetVisible(theView, true); CantCreate: CantSetParameter: CantCreateEvent: ReleaseEvent( event ); CantRegister: return err; }
/* Handle the initialization event for a star-shaped frame. This routine creates the content view, installs its event handler, and sets its initial location. */ OSStatus HandleStarFrameInitialize( EventHandlerCallRef inCallRef, EventRef inEvent, StarFrameData *frameData) { OSStatus retVal = eventNotHandledErr; HIViewRef contentView; // The frame view must support embedding HIViewChangeFeatures(frameData->hiSelf, kHIViewAllowsSubviews, kHIViewIsOpaque); // Create the content view for the frame. retVal = HIObjectCreate(kHIViewClassID, NULL, (HIObjectRef *)&contentView); if(noErr == retVal && NULL != contentView) { HIViewChangeFeatures(contentView, kHIViewAllowsSubviews, kHIViewIsOpaque); SetControlID(contentView, &kHIViewWindowContentID); // content view must be visible. verify_noerr(HIViewSetVisible(contentView, true)); // Make sure the content view is handling events verify_noerr(InstallControlEventHandler( contentView, gContentViewHandlerUPP, GetEventTypeCount(gContentViewHandledEvents), gContentViewHandledEvents, NULL, NULL)); // set the location of the content view appropriately PositionContentViewWithMetrics(frameData->hiSelf, contentView); // add the content view as a subview of me. verify_noerr(HIViewAddSubview(frameData->hiSelf, contentView)); retVal = noErr; } return retVal; }
// -------------------------------------------------------------------------------------- void OpenPrefsDialog(void) { ListDefSpec listSpec; DialogRef dialog; WindowRef dialogWindow; EventTypeSpec dialogEvents[] = { {kEventClassControl, kEventControlHit} }; ControlID controlID = {kAppSignature, 0}; ControlRef control; EventTypeSpec listBoxControlEvents[] = { {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent} }; ListHandle iconList; Cell theCell; listSpec.defType = kListDefUserProcType; listSpec.u.userProc = NewListDefUPP(IconListDef); // this is automatically disposed // when the program exits RegisterListDefinition(kIconListLDEF, &listSpec); dialog = GetNewDialog(rPrefsDialog, NULL, kFirstWindowOfClass); if (dialog == NULL) ExitToShell(); SetPortDialogPort(dialog); dialogWindow = GetDialogWindow(dialog); // install window handlers ChangeWindowAttributes(dialogWindow, kWindowStandardHandlerAttribute, kWindowNoAttributes); gDialogEventHandler = NewEventHandlerUPP(dialogEventHandler); InstallWindowEventHandler(dialogWindow, gDialogEventHandler, GetEventTypeCount(dialogEvents), dialogEvents, (void *)dialog, NULL); GetDialogItemAsControl(dialog, kStdOkItemIndex, &control); // set control IDs to controlID.id = kStdOkItemIndex; // match dialog item SetControlID(control, &controlID); // indices which are SetWindowDefaultButton(dialogWindow, control); // not tracked by any // standard handlers GetDialogItemAsControl(dialog, kStdCancelItemIndex, &control); // also set the default controlID.id = kStdCancelItemIndex; // and cancel buttons (because Mac OS 8/9 SetControlID(control, &controlID); // under CarbonLib doesn't respect the SetWindowCancelButton(dialogWindow, control); // dialog's default and cancel buttons) GetDialogItemAsControl(dialog, iIconList, &control); controlID.id = iIconList; SetControlID(control, &controlID); /* We need to postprocess keyboard events on the icon list so that we can change panels after the user changes the selected cell by using the keyboard. */ gListBoxControlEventHandler = NewEventHandlerUPP(listBoxControlEventHandler); InstallControlEventHandler(control, gListBoxControlEventHandler, GetEventTypeCount(listBoxControlEvents), listBoxControlEvents, (void *)dialog, NULL); GetControlData(control, kControlEntireControl, kControlListBoxListHandleTag, sizeof(ListHandle), &iconList, NULL); AddRowsAndDataToIconList(iconList, rIconListIconBaseID); SetListSelectionFlags(iconList, lOnlyOne); SetPt(&theCell, 0, 0); LSetSelect(true, theCell, iconList); SetKeyboardFocus(dialogWindow, control, kControlFocusNextPart); gPanelNumber = 0; SetPrefsDialogHelpTags(dialog); DisableMenuItem(GetMenuRef(mDemonstration), iPrefsDialog); ShowWindow(dialogWindow); } // OpenPrefsDialog
void MusicBoxDialog(void) { OSStatus err; IBNibRef nibRef; if (!cartOpen) return; err = CreateNibReference(kMacS9XCFString, &nibRef); if (err == noErr) { CFURLRef iconURL; FSRef iconFSRef; IconRef actIcon; WindowRef tWindowRef; actIcon = nil; if (musicboxmode == kMBXSoundEmulation) iconURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("musicbox_ledoff"), CFSTR("icns"), nil); else iconURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("musicbox_ledon" ), CFSTR("icns"), nil); if (iconURL) { if (CFURLGetFSRef(iconURL, &iconFSRef)) err = RegisterIconRefFromFSRef('~9X~', 'micn', &iconFSRef, &actIcon); CFRelease(iconURL); } err = CreateWindowFromNib(nibRef, CFSTR("MusicBox"), &tWindowRef); if (err == noErr) { EventHandlerRef mboxRef, paneRef; EventHandlerUPP mboxUPP, paneUPP; EventLoopTimerRef timeRef; EventLoopTimerUPP timeUPP; EventTypeSpec mboxEvents[] = { { kEventClassCommand, kEventCommandProcess }, { kEventClassCommand, kEventCommandUpdateStatus } }, paneEvents[] = { { kEventClassControl, kEventControlDraw } }; CFStringRef sref; CGDataProviderRef prov; CGImageRef ipng; CFURLRef iurl; HIViewRef ctl, root, paneView, imageView, contentView; HIViewID cid; HIRect bounds; Rect windowRect, barRect; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; mboxPause = false; mbxFinished = false; showIndicator = false; so.stereo_switch = ~0; for (int i = 0; i < MAC_MAX_PLAYERS; i++) controlPad[i] = 0; switch (drawingMethod) { case kDrawingOpenGL: Settings.OpenGLEnable = true; break; case kDrawingDirect: case kDrawingBlitGL: Settings.OpenGLEnable = false; } // 107's enhanced SPC player root = HIViewGetRoot(tWindowRef); cid.id = 0; if (musicboxmode == kMBXSoundEmulation) { cid.signature = 'HEAD'; HIViewFindByID(root, cid, &ctl); EnableControl(ctl); StoredAPU = new SAPU; StoredAPURegisters = new SAPURegisters; StoredSoundData = new SSoundData; StoredIAPURAM = new uint8 [0x10000]; SPCPlayFreeze(); } else MusicBoxForceFreeze(); cid.signature = 'Kart'; HIViewFindByID(root, cid, &ctl); SetStaticTextTrunc(ctl, truncEnd, false); _splitpath(Memory.ROMFilename, drive, dir, fname, ext); sref = CFStringCreateWithCString(kCFAllocatorDefault, fname, MAC_PATH_ENCODING); if (sref) { SetStaticTextCFString(ctl, sref, false); CFRelease(sref); } ipng = nil; iurl = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("musicbox_indicator"), CFSTR("png"), nil); if (iurl) { prov = CGDataProviderCreateWithURL(iurl); if (prov) { ipng = CGImageCreateWithPNGDataProvider(prov, nil, false, kCGRenderingIntentDefault); CGDataProviderRelease(prov); } CFRelease(iurl); } imageView = nil; if (ipng) { HIViewFindByID(root, kHIViewWindowContentID, &contentView); err = HIImageViewCreate(ipng, &imageView); if (err == noErr) { bounds = CGRectMake(30, 64, CGImageGetWidth(ipng), CGImageGetHeight(ipng)); HIViewSetFrame(imageView, &bounds); HIImageViewSetOpaque(imageView, false); HIViewSetVisible(imageView, true); HIViewAddSubview(contentView, imageView); cid.signature = 'iMaG'; SetControlID(imageView, &cid); } CGImageRelease(ipng); } cid.signature = 'Pane'; HIViewFindByID(root, cid, &paneView); HIViewGetBounds(paneView, &bounds); mbxViewWidth = bounds.size.width; mbxViewHeight = bounds.size.height; mbxMarginY = (mbxViewHeight - mbxBarHeight) / 2.0; mbxMarginX = (mbxViewWidth - ((mbxBarWidth * 8.0 + mbxBarSpace * 7.0) * 2.0 + mbxLRSpace)) / 2.0; if (imageView) { HIViewSetZOrder(imageView, kHIViewZOrderBelow, paneView); HIViewAddSubview(imageView, paneView); } cid.signature = 'Tr_i'; HIViewFindByID(root, cid, &ctl); HIViewGetFrame(ctl, &bounds); GetWindowBounds(tWindowRef, kWindowTitleBarRgn, &barRect); mbxClosedHeight = (short) (bounds.origin.y + bounds.size.height + 7.0) + (barRect.bottom - barRect.top); GetWindowBounds(tWindowRef, kWindowStructureRgn, &windowRect); mbxOpenedHeight = windowRect.bottom - windowRect.top; windowRect.bottom = windowRect.top + mbxClosedHeight; SetWindowBounds(tWindowRef, kWindowStructureRgn, &windowRect); paneUPP = NewEventHandlerUPP(IndicatorEventHandler); err = InstallControlEventHandler(paneView, paneUPP, GetEventTypeCount(paneEvents), paneEvents, (void *) paneView, &paneRef); mboxUPP = NewEventHandlerUPP(MusicBoxEventHandler); err = InstallWindowEventHandler(tWindowRef, mboxUPP, GetEventTypeCount(mboxEvents), mboxEvents, (void *) tWindowRef, &mboxRef); timeUPP = NewEventLoopTimerUPP(MusicBoxTimerHandler); err = InstallEventLoopTimer(GetCurrentEventLoop(), kEventDurationNoWait, kEventDurationSecond * 2.0 / (double) Memory.ROMFramesPerSecond, timeUPP, (void *) paneView, &timeRef); MusicBoxInitIndicator(); stopNow = false; MacStartSound(); pthread_create(&mbxThread, nil, SoundTask, nil); MoveWindowPosition(tWindowRef, kWindowMusicBox, true); GetWindowBounds(tWindowRef, kWindowStructureRgn, &windowRect); if (windowRect.bottom - windowRect.top > mbxClosedHeight) { showIndicator = true; SetControl32BitValue(ctl, 1); // Tr_i } ShowWindow(tWindowRef); err = RunAppModalLoopForWindow(tWindowRef); HideWindow(tWindowRef); SaveWindowPosition(tWindowRef, kWindowMusicBox); stopNow = true; pthread_join(mbxThread, nil); MacStopSound(); err = RemoveEventLoopTimer(timeRef); DisposeEventLoopTimerUPP(timeUPP); err = RemoveEventHandler(mboxRef); DisposeEventHandlerUPP(mboxUPP); err = RemoveEventHandler(paneRef); DisposeEventHandlerUPP(paneUPP); ReleaseWindow(tWindowRef); so.stereo_switch = ~0; mbxFinished = true; if (musicboxmode == kMBXSoundEmulation) { SPCPlayDefrost(); delete StoredAPU; delete StoredAPURegisters; delete StoredSoundData; delete [] StoredIAPURAM; } else MusicBoxForceDefrost(); Settings.OpenGLEnable = false; } if (actIcon) err = UnregisterIconRef('~9X~', 'micn'); DisposeNibReference(nibRef); } }
/*----------------------------------------------------------------------------------------------------------*/ pascal OSStatus ScrollingTextViewHandler(EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon) { OSStatus result = eventNotHandledErr; ScrollingTextBoxData* myData = (ScrollingTextBoxData*)inRefcon; switch (GetEventClass(inEvent)) { case kEventClassHIObject: switch (GetEventKind(inEvent)) { case kEventHIObjectConstruct: { // allocate some instance data myData = (ScrollingTextBoxData*) calloc(1, sizeof(ScrollingTextBoxData)); // get our superclass instance HIViewRef epView; GetEventParameter(inEvent, kEventParamHIObjectInstance, typeHIObjectRef, NULL, sizeof(epView), NULL, &epView); // remember our superclass in our instance data and initialize other fields myData->view = epView; // set the control ID so that we can find it later with HIViewFindByID result = SetControlID(myData->view, &kScrollingTextBoxViewID); // store our instance data into the event result = SetEventParameter(inEvent, kEventParamHIObjectInstance, typeVoidPtr, sizeof(myData), &myData); break; } case kEventHIObjectDestruct: { if (myData->theTimer != NULL) RemoveEventLoopTimer(myData->theTimer); CFRelease(myData->theText); free(myData); result = noErr; break; } case kEventHIObjectInitialize: { // always begin kEventHIObjectInitialize by calling through to the previous handler result = CallNextEventHandler(inCaller, inEvent); // if that succeeded, do our own initialization if (result == noErr) { GetEventParameter(inEvent, kEventParamScrollingText, typeCFStringRef, NULL, sizeof(myData->theText), NULL, &myData->theText); CFRetain(myData->theText); GetEventParameter(inEvent, kEventParamAutoScroll, typeBoolean, NULL, sizeof(myData->autoScroll), NULL, &myData->autoScroll); GetEventParameter(inEvent, kEventParamDelayBeforeAutoScroll, typeUInt32, NULL, sizeof(myData->delayBeforeAutoScroll), NULL, &myData->delayBeforeAutoScroll); GetEventParameter(inEvent, kEventParamDelayBetweenAutoScroll, typeUInt32, NULL, sizeof(myData->delayBetweenAutoScroll), NULL, &myData->delayBetweenAutoScroll); GetEventParameter(inEvent, kEventParamAutoScrollAmount, typeSInt16, NULL, sizeof(myData->autoScrollAmount), NULL, &myData->autoScrollAmount); myData->theTimer = NULL; } break; } default: break; } break; case kEventClassScrollable: switch (GetEventKind(inEvent)) { case kEventScrollableGetInfo: { // we're being asked to return information about the scrolled view that we set as Event Parameters HISize imageSize = {50.0, myData->height}; SetEventParameter(inEvent, kEventParamImageSize, typeHISize, sizeof(imageSize), &imageSize); HISize lineSize = {50.0, 20.0}; SetEventParameter(inEvent, kEventParamLineSize, typeHISize, sizeof(lineSize), &lineSize); HIRect bounds; HIViewGetBounds(myData->view, &bounds); SetEventParameter(inEvent, kEventParamViewSize, typeHISize, sizeof(bounds.size), &bounds.size); SetEventParameter(inEvent, kEventParamOrigin, typeHIPoint, sizeof(myData->originPoint), &myData->originPoint); result = noErr; break; } case kEventScrollableScrollTo: { // we're being asked to scroll, we just do a sanity check and ask for a redraw HIPoint where; GetEventParameter(inEvent, kEventParamOrigin, typeHIPoint, NULL, sizeof(where), NULL, &where); HIViewSetNeedsDisplay(myData->view, true); myData->originPoint.y = (where.y < 0.0)?0.0:where.y; HIViewSetBoundsOrigin(myData->view, 0, myData->originPoint.y); break; } default: break; } break; case kEventClassControl: switch (GetEventKind(inEvent)) { // sets the feature of the view. case kEventControlInitialize: { result = CallNextEventHandler(inCaller, inEvent); if (result != noErr) break; UInt32 features = 0; result = GetEventParameter(inEvent, kEventParamControlFeatures, typeUInt32, NULL, sizeof(features), NULL, &features); if (result == noErr) features |= kControlSupportsEmbedding; else features = kControlSupportsEmbedding; result = SetEventParameter(inEvent, kEventParamControlFeatures, typeUInt32, sizeof features, &features); break; } // Our parent view just changed dimensions, so we determined our new height. case kEventControlSetData: CFRelease(myData->theText); CFStringRef *p; GetEventParameter(inEvent, kEventParamControlDataBuffer, typePtr, NULL, sizeof(p), NULL, &p); myData->theText = *p; CFRetain(myData->theText); // fallthrough case kEventControlBoundsChanged: { HIRect bounds; HIViewGetBounds(myData->view, &bounds); // // If we're building on Panther (or later) then HIThemeGetTextDimensions is available, else we use GetThemeTextDimensions // #if PANTHER_BUILD // // Furthermore, if we're running on Panther then we can call HIThemeGetTextDimensions else we call GetThemeTextDimensions // if (GetHIToolboxVersion() >= Panther_HIToolbox_Version) { HIThemeTextInfo textInfo = {0, kThemeStateActive, kScrollingTextBoxFontID, kHIThemeTextHorizontalFlushLeft, kHIThemeTextVerticalFlushTop, kHIThemeTextBoxOptionStronglyVertical, kHIThemeTextTruncationNone, 0, false}; HIThemeGetTextDimensions(myData->theText, bounds.size.width - kMargin - kMargin, &textInfo, NULL, &myData->height, NULL); } else #endif { Point pointBounds; pointBounds.h = (int)(bounds.size.width - kMargin - kMargin); GetThemeTextDimensions(myData->theText, kScrollingTextBoxFontID, kThemeStateActive, true, &pointBounds, NULL); myData->height = pointBounds.v; } myData->height += 2.0 * kMargin; HIViewSetNeedsDisplay(myData->view, true); result = eventNotHandledErr; break; } // Draw the view. case kEventControlDraw: { CGContextRef context; result = GetEventParameter(inEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof(context), NULL, &context); HIRect bounds; HIViewGetBounds(myData->view, &bounds); CGContextSaveGState(context); CGAffineTransform transform = CGAffineTransformIdentity; // adjust the transform so the text doesn't draw upside down transform = CGAffineTransformScale(transform, 1, -1); CGContextSetTextMatrix(context, transform); // now that the proper parameters and configurations have been dealt with, let's draw result = ScrollingTextBoxDraw(context, &bounds, myData); CGContextRestoreGState(context); if (myData->autoScroll) CGContextStrokeRect(context, bounds); // we postpone starting the autoscroll timer until after we do our first drawing if ( (myData->autoScroll) && (myData->theTimer == NULL) ) InstallEventLoopTimer(GetCurrentEventLoop(), TicksToEventTime(myData->delayBeforeAutoScroll), TicksToEventTime(myData->delayBetweenAutoScroll), myScrollingTextTimeProc, myData, &myData->theTimer); result = noErr; break; } default: break; } break; default: break; } return result; }
int FileDialog::ShowModal() { OSErr err; NavDialogCreationOptions dialogCreateOptions; // set default options ::NavGetDefaultDialogCreationOptions(&dialogCreateOptions); // this was always unset in the old code dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation; wxMacCFStringHolder message(m_message, GetFont().GetEncoding()); dialogCreateOptions.windowTitle = message; wxMacCFStringHolder defaultFileName(m_fileName, GetFont().GetEncoding()); dialogCreateOptions.saveFileName = defaultFileName; NavDialogRef dialog; NavObjectFilterUPP navFilterUPP = NULL; CustomData myData; SetRect(&myData.bounds, 0, 0, 0, 0); myData.me = this; myData.window = NULL; myData.defaultLocation = m_dir; myData.userpane = NULL; myData.choice = NULL; myData.button = NULL; myData.saveMode = false; myData.showing = true; Rect r; SInt16 base; SInt16 margin = 3; SInt16 gap = 0; MakeUserDataRec(&myData , m_wildCard); myData.currentfilter = m_filterIndex; size_t numFilters = myData.extensions.GetCount(); if (numFilters) { CreateNewMenu(0, 0, &myData.menu); for ( size_t i = 0 ; i < numFilters ; ++i ) { ::AppendMenuItemTextWithCFString(myData.menu, wxMacCFStringHolder(myData.name[i], GetFont().GetEncoding()), 4, i, NULL); } SetRect(&r, 0, margin, 0, 0); CreatePopupButtonControl(NULL, &r, CFSTR("Format:"), -12345, true, -1, teJustLeft, normal, &myData.choice); SetControlID(myData.choice, &kChoiceID); SetControlPopupMenuRef(myData.choice, myData.menu); SetControl32BitMinimum(myData.choice, 1); SetControl32BitMaximum(myData.choice, myData.name.GetCount()); SetControl32BitValue(myData.choice, myData.currentfilter + 1); GetBestControlRect(myData.choice, &r, &base); SizeControl(myData.choice, r.right - r.left, r.bottom - r.top); UnionRect(&myData.bounds, &r, &myData.bounds); gap = 15; HIObjectSetAuxiliaryAccessibilityAttribute((HIObjectRef)myData.choice, 0, kAXDescriptionAttribute, CFSTR("Format")); } if (!m_buttonlabel.IsEmpty()) { wxMacCFStringHolder cfString(wxStripMenuCodes(m_buttonlabel).c_str(), wxFONTENCODING_DEFAULT); SetRect(&r, myData.bounds.right + gap, margin, 0, 0); CreatePushButtonControl(NULL, &r, cfString, &myData.button); SetControlID(myData.button, &kButtonID); GetBestControlRect(myData.button, &r, &base); SizeControl(myData.button, r.right - r.left, r.bottom - r.top); UnionRect(&myData.bounds, &r, &myData.bounds); } // Expand bounding rectangle to include a top and bottom margin myData.bounds.top -= margin; myData.bounds.bottom += margin; dialogCreateOptions.optionFlags |= kNavNoTypePopup; if (m_dialogStyle & wxFD_SAVE) { dialogCreateOptions.modality = kWindowModalityWindowModal; dialogCreateOptions.parentWindow = (WindowRef) GetParent()->MacGetTopLevelWindowRef(); myData.saveMode = true; if (!numFilters) { dialogCreateOptions.optionFlags |= kNavNoTypePopup; } dialogCreateOptions.optionFlags |= kNavDontAutoTranslate; dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems; // The extension is important if (numFilters < 2) dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension; #if TARGET_API_MAC_OSX if (!(m_dialogStyle & wxFD_OVERWRITE_PROMPT)) { dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement; } #endif err = ::NavCreatePutFileDialog(&dialogCreateOptions, // Suppresses the 'Default' (top) menu item kNavGenericSignature, kNavGenericSignature, sStandardNavEventFilter, &myData, // for defaultLocation &dialog); } else { //let people select bundles/programs in dialogs dialogCreateOptions.optionFlags |= kNavSupportPackages; navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback); err = ::NavCreateGetFileDialog(&dialogCreateOptions, NULL, // NavTypeListHandle sStandardNavEventFilter, NULL, // NavPreviewUPP navFilterUPP, (void *) &myData, // inClientData &dialog); } if (err == noErr) err = ::NavDialogRun(dialog); if (err == noErr) { myData.window = NavDialogGetWindow(dialog); Rect r; // This creates our "fake" dialog with the same dimensions as the sheet so // that Options dialogs will center properly on the sheet. The "fake" dialog // is never actually seen. GetWindowBounds(myData.window, kWindowStructureRgn, &r); wxDialog::Create(NULL, // no parent...otherwise strange things happen wxID_ANY, wxEmptyString, wxPoint(r.left, r.top), wxSize(r.right - r.left, r.bottom - r.top)); BeginAppModalStateForWindow(myData.window); while (myData.showing) { wxTheApp->MacDoOneEvent(); } EndAppModalStateForWindow(myData.window); } // clean up filter related data, etc. if (navFilterUPP) ::DisposeNavObjectFilterUPP(navFilterUPP); if (err != noErr) return wxID_CANCEL; NavReplyRecord navReply; err = ::NavDialogGetReply(dialog, &navReply); if (err == noErr && navReply.validRecord) { AEKeyword theKeyword; DescType actualType; Size actualSize; FSRef theFSRef; wxString thePath ; m_filterIndex = myData.currentfilter; long count; ::AECountItems(&navReply.selection , &count); for (long i = 1; i <= count; ++i) { err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType, &theFSRef, sizeof(theFSRef), &actualSize); if (err != noErr) break; if (m_dialogStyle & wxFD_SAVE) thePath = wxMacFSRefToPath( &theFSRef , navReply.saveFileName ) ; else thePath = wxMacFSRefToPath( &theFSRef ) ; if (!thePath) { ::NavDisposeReply(&navReply); return wxID_CANCEL; } m_path = ConvertSlashInFileName(thePath); m_paths.Add(m_path); m_fileName = wxFileNameFromPath(m_path); m_fileNames.Add(m_fileName); } // set these to the first hit m_path = m_paths[0]; m_fileName = wxFileNameFromPath(m_path); m_dir = wxPathOnly(m_path); } ::NavDisposeReply(&navReply); return (err == noErr) ? wxID_OK : wxID_CANCEL; }