-bool gUseNavServices = NavServicesAvailable() ;
-
-// the data we need to pass to our standard file hook routine
-// includes a pointer to the dialog, a pointer to the standard
-// file reply record (so we can inspect the current selection)
-// and a copy of the "previous" file spec of the reply record
-// so we can see if the selection has changed
-
-#if !TARGET_CARBON
-
-struct UserDataRec {
- StandardFileReply *sfrPtr;
- FSSpec oldSelectionFSSpec;
- DialogPtr theDlgPtr;
-};
-typedef struct UserDataRec
- UserDataRec, *UserDataRecPtr;
-
-enum {
- kSelectItem = 10, // select button item number
- kSFGetFolderDlgID = 250, // dialog resource number
- kStrListID = 250, // our strings
- kSelectStrNum = 1, // word 'Select: ' for button
- kDesktopStrNum = 2, // word 'Desktop' for button
- kSelectNoQuoteStrNum = 3, // word 'Select: ' for button
-
- kUseQuotes = true, // parameter for SetButtonName
- kDontUseQuotes = false
-};
-
-
-static void GetLabelString(StringPtr theStr, short stringNum)
-{
- GetIndString(theStr, kStrListID, stringNum);
-}
-
-static void CopyPStr(StringPtr src, StringPtr dest)
-{
- BlockMoveData(src, dest, 1 + src[0]);
-}
-
-static char GetSelectKey(void)
-{
- // this is the key used to trigger the select button
-
- // NOT INTERNATIONAL SAVVY; should at least grab it from resources
-
- return 's';
-}
-
-
-// SetButtonName sets the name of the Select button in the dialog
-//
-// To do this, we need to call the Script Manager to truncate the
-// label in the middle to fit the button and to merge the button
-// name with the word Select (possibly followed by quotes). Using
-// the Script Manager avoids all sorts of problems internationally.
-//
-// buttonName is the name to appear following the word Select
-// quoteFlag should be true if the name is to appear in quotes
-
-static void SetButtonName(DialogPtr theDlgPtr, short buttonID, StringPtr buttonName,
- Boolean quoteFlag)
-{
- short buttonType;
- Handle buttonHandle;
- Rect buttonRect;
- short textWidth;
- Handle labelHandle;
- Handle nameHandle;
- Str15 keyStr;
- Str255 labelStr;
- OSErr err;
-
- nameHandle = nil;
- labelHandle = nil;
-
- // get the details of the button from the dialog
-
- GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect);
-
- // get the string for the select button label, "Select ^0" or "Select Ò^0Ó"
-
- GetLabelString(labelStr, (quoteFlag == kUseQuotes) ? kSelectStrNum : kSelectNoQuoteStrNum);
-
- // make string handles containing the select button label and the
- // file name to be stuffed into the button
-
- err = PtrToHand(&labelStr[1], &labelHandle, labelStr[0]);
- if (err != noErr) goto Bail;
-
- // cut out the middle of the file name to fit the button
- //
- // we'll temporarily use labelStr here to hold the modified button name
- // since we don't own the buttonName string storage space
-
- textWidth = (buttonRect.right - buttonRect.left) - StringWidth(labelStr);
-
- CopyPStr(buttonName, labelStr);
- (void) TruncString(textWidth, labelStr, smTruncMiddle);
-
- err = PtrToHand(&labelStr[1], &nameHandle, labelStr[0]);
- if (err != noErr) goto Bail;
-
- // replace the ^0 in the Select string with the file name
-
- CopyPStr("\p^0", keyStr);
-
- (void) ReplaceText(labelHandle, nameHandle, keyStr);
-
- labelStr[0] = (unsigned char) GetHandleSize(labelHandle);
- BlockMoveData(*labelHandle, &labelStr[1], labelStr[0]);
-
- // now set the control title, and re-validate the area
- // above the control to avoid a needless redraw
-
- SetControlTitle((ControlHandle) buttonHandle, labelStr);
-
- ValidRect(&buttonRect);
-
-Bail:
- if (nameHandle) DisposeHandle(nameHandle);
- if (labelHandle) DisposeHandle(labelHandle);
-
-}
-
-// FlashButton briefly highlights the dialog button
-// as feedback for key equivalents
-
-static void FlashButton(DialogPtr theDlgPtr, short buttonID)