|
From: <psn...@us...> - 2003-11-05 14:29:38
|
Update of /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac
In directory sc8-pr-cvs1:/tmp/cvs-serv21252
Modified Files:
MFileDialog.cpp
Log Message:
Integrated Marshall's fixes.
Index: MFileDialog.cpp
===================================================================
RCS file: /cvsroot/whisper2/Whisper/Source/BackEnd/Files/Source/Files/Mac/MFileDialog.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** MFileDialog.cpp 13 Oct 2003 04:23:33 -0000 1.18
--- MFileDialog.cpp 5 Nov 2003 14:27:45 -0000 1.19
***************
*** 10,13 ****
--- 10,16 ----
*
* $Log$
+ * Revision 1.19 2003/11/05 14:27:45 psnively
+ * Integrated Marshall's fixes.
+ *
* Revision 1.18 2003/10/13 04:23:33 psnively
* Relaxed a bit to let "Document" be the default menu type again.
***************
*** 596,599 ****
--- 599,620 ----
// ===================================================================================
+ static void InitNavServicesFields ( XFileDialogOptions &options ) {
+ options.version = 0;
+ options.optionFlags = kNavDefaultNavDlogOptions;
+ options.location.h = options.location.v = -1;
+ options.clientName = nil;
+ options.windowTitle = nil;
+ options.actionButtonLabel = nil;
+ options.cancelButtonLabel = nil;
+ options.saveFileName = nil;
+ options.message = nil;
+ options.preferenceKey = 0L;
+ options.popupExtension = nil;
+ options.modality = kWindowModalityAppModal;
+ options.parentWindow = nil;
+ for ( int i = 0; i < sizeof ( options.reserved ) / sizeof ( options.reserved[0] ); ++i )
+ options.reserved [ i ] = 0;
+ }
+
//---------------------------------------------------------------
//
***************
*** 603,616 ****
XFileDialogOptions::XFileDialogOptions()
{
! if (MSystemInfo::HasNavServices()) {
OSStatus err = NavGetDefaultDialogCreationOptions(this);
ThrowIfOSErr(err);
-
- } else {
- std::memset(this, 0, sizeof(*this));
-
- location.h = -1;
- location.v = -1;
- }
clientName = theAppName.Get();
--- 624,633 ----
XFileDialogOptions::XFileDialogOptions()
{
! // Init the parent stuff
! ASSERT(MSystemInfo::HasNavServices());
! InitNavServicesFields (*this);
!
OSStatus err = NavGetDefaultDialogCreationOptions(this);
ThrowIfOSErr(err);
clientName = theAppName.Get();
***************
*** 757,761 ****
PRECONDITION(types.size() > 0);
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 774,778 ----
PRECONDITION(types.size() > 0);
! ASSERT(MSystemInfo::HasNavServices ());
ASSERT(msEventCallback != nil);
***************
*** 775,779 ****
OSStatus err = NavCreatePutFileDialog(const_cast<const XFileDialogOptions*>(&options),
msSelectedType, // first type will be the default
! msSelectedCreator, // maybe kNavGenericSignature?
msEventsUPP,
(void *)&types,
--- 792,796 ----
OSStatus err = NavCreatePutFileDialog(const_cast<const XFileDialogOptions*>(&options),
msSelectedType, // first type will be the default
! kNavGenericSignature , // maybe kNavGenericSignature?
msEventsUPP,
(void *)&types,
***************
*** 819,826 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 836,839 ----
***************
*** 839,843 ****
PRECONDITION(types.size() > 0);
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 852,856 ----
PRECONDITION(types.size() > 0);
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 875,879 ****
nil,
msFilterUPP,
! nil,
&navDialog);
--- 888,892 ----
nil,
msFilterUPP,
! (void *)&types,
&navDialog);
***************
*** 907,913 ****
NavDialogDispose(navDialog);
- } else
- DEBUGSTR("How'd we wind up here?");
-
return reply;
}
--- 920,923 ----
***************
*** 923,927 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 933,937 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 962,966 ****
nil,
msFilterUPP,
! nil,
&navDialog);
--- 972,976 ----
nil,
msFilterUPP,
! (void *)&types,
&navDialog);
***************
*** 995,1001 ****
NavDialogDispose(navDialog);
- } else
- DEBUGSTR("How'd we wind up here?");
-
return reply;
}
--- 1005,1008 ----
***************
*** 1014,1018 ****
PRECONDITION(types.size() > 0);
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1021,1025 ----
PRECONDITION(types.size() > 0);
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1083,1089 ****
NavDialogDispose(navDialog);
- } else
- DEBUGSTR("How'd we wind up here?");
-
return reply;
}
--- 1090,1093 ----
***************
*** 1099,1103 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1103,1107 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1152,1159 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1156,1159 ----
***************
*** 1169,1173 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1169,1173 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1215,1222 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1215,1218 ----
***************
*** 1232,1236 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1228,1232 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1281,1288 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1277,1280 ----
***************
*** 1311,1315 ****
XOpenReply reply;
! if (MSystemInfo::HasNavServices()) {
// ASSERT(msEventCallback != nil); // isn't true when in XApplication::OnLocateDataFolders...
--- 1303,1307 ----
XOpenReply reply;
! ASSERT(MSystemInfo::HasNavServices());
// ASSERT(msEventCallback != nil); // isn't true when in XApplication::OnLocateDataFolders...
***************
*** 1359,1366 ****
NavDialogDispose(navDialog);
- } else {
- DEBUGSTR("How'd we wind up here?");
- }
-
return reply;
}
--- 1351,1354 ----
***************
*** 1380,1385 ****
EAskSaveResult result = kCancelSave;
! OSErr err = noErr;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1368,1372 ----
EAskSaveResult result = kCancelSave;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1430,1475 ****
default:
result = kCancelSave;
- }
- } else {
- int16 item = kSaveBtn;
-
- MCreateModalFilterUPP theFilter(msModalFilter);
-
- if (MSystemInfo::HasAppearanceMgr()) {
- std::wstring defaultText = LoadWhisperString(L"Save (Button)"); // need to keep these in locals so they're not deleted before StandardAlert completes
- std::wstring cancelText = LoadWhisperString(L"Cancel (Button)");
- std::wstring otherText = LoadWhisperString(L"Don't Save (Button)");
-
- PascalString defaultStr = ToPascalStr(defaultText);
- PascalString cancelStr = ToPascalStr(cancelText);
- PascalString otherStr = ToPascalStr(otherText);
-
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = theFilter;
- params.defaultText = (unsigned char*) defaultStr.c_str();
- params.cancelText = (unsigned char*) cancelStr.c_str();
- params.otherText = (unsigned char*) otherStr.c_str();
- params.defaultButton = kSaveBtn;
- params.cancelButton = kCancelBtn;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- std::wstring errorStr = LoadWhisperString(L"File Ò#1Ó not saved.", docName);
- std::wstring supplementalStr = LoadWhisperString(L"Changes made to the file Ò#1Ó will be discarded if this file is not saved. Do you want to save changes to this file before closing it?", docName);
-
- err = StandardAlert(kAlertStopAlert, (unsigned char*) ToPascalStr(errorStr).c_str(), (unsigned char*) ToPascalStr(supplementalStr).c_str(), ¶ms, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
-
- } else {
- ParamText(ToPascalStr(docName).c_str(), "\p", "\p", "\p");
-
- item = CautionAlert(kSaveChangesAlert, theFilter);
- }
-
- if (item == kSaveBtn)
- result = kSaveChanges;
- else if (item == kDontSaveBtn)
- result = kDontSave;
}
--- 1417,1420 ----
***************
*** 1489,1494 ****
ERevertResult result = kCancelRevert;
! OSErr err = noErr;
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventCallback != nil);
--- 1434,1438 ----
ERevertResult result = kCancelRevert;
! ASSERT(MSystemInfo::HasNavServices());
ASSERT(msEventCallback != nil);
***************
*** 1534,1569 ****
default:
result = kCancelRevert;
- }
- } else {
- int16 item = cancel;
-
- MCreateModalFilterUPP theFilter(msModalFilter);
-
- if (MSystemInfo::HasAppearanceMgr()) {
- AlertStdAlertParamRec params;
- params.movable = true;
- params.helpButton = false;
- params.filterProc = theFilter;
- params.defaultText = (StringPtr) -1L; // use default (ie "OK")
- params.cancelText = (StringPtr) -1L; // use default (ie "Cancel")
- params.otherText = nil;
- params.defaultButton = cancel;
- params.cancelButton = 0;
- params.position = kWindowAlertPositionParentWindowScreen;
-
- std::wstring errorStr = LoadWhisperString(L"Revert changes to file Ò#1Ó.", docName);
- std::wstring supplementalStr = LoadWhisperString(L"Reverting file Ò#1Ó will discard all changes made to this file since you last saved it. Do you want to discard all changes to this file?", docName);
-
- err = StandardAlert(kAlertStopAlert, (unsigned char*) ToPascalStr(errorStr).c_str(), (unsigned char*) ToPascalStr(supplementalStr).c_str(), ¶ms, &item);
- ASSERT(err == noErr); // seems kind of pointless to throw
-
- } else {
- ParamText(ToPascalStr(docName).c_str(), "\p", "\p", "\p");
-
- item = CautionAlert(kConfirmRevertAlert, theFilter);
- }
-
- if (item == ok)
- result = kDiscardChanges;
}
--- 1478,1481 ----
***************
*** 1580,1584 ****
void XFileDialog::DoInit()
{
! if (MSystemInfo::HasNavServices()) {
ASSERT(msEventsUPP == nil);
ASSERT(msFilterUPP == nil);
--- 1492,1496 ----
void XFileDialog::DoInit()
{
! ASSERT (MSystemInfo::HasNavServices());
ASSERT(msEventsUPP == nil);
ASSERT(msFilterUPP == nil);
***************
*** 1589,1593 ****
msFilterUPP = NewNavObjectFilterUPP(XFileDialog::DoFilter);
ThrowIfMemFail(msFilterUPP);
- }
}
--- 1501,1504 ----
|