added new default handlers for open/print events, removing the need for using private headers in the specific application

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2002-08-24 22:04:04 +00:00
parent d8a2af5091
commit 2072fbbbc9
3 changed files with 147 additions and 10 deletions

View File

@ -160,6 +160,13 @@ public:
virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
// in response of an open-document apple event
virtual void MacOpenFile(const wxString &fileName) ;
// in response of a print-document apple event
virtual void MacPrintFile(const wxString &fileName) ;
// in response of a open-application apple event
virtual void MacNewFile() ;
DECLARE_EVENT_TABLE()
};

View File

@ -133,23 +133,88 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
}
short wxApp::MacHandleAEODoc(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
// new virtual public method in wxApp
void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) )
{
SysBeep(40) ;
}
void wxApp::MacPrintFile(const wxString & WXUNUSED(fileName) )
{
}
void wxApp::MacNewFile()
{
}
// new implementation, which parses the event and calls
// MacOpenFile on each of the files it's passed
short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
{
AEDescList docList;
AEKeyword keywd;
DescType returnedType;
Size actualSize;
long itemsInList;
FSSpec theSpec;
OSErr err;
short i;
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
if (err != noErr)
return err;
err = AECountItems(&docList, &itemsInList);
if (err != noErr)
return err;
ProcessSerialNumber PSN ;
PSN.highLongOfPSN = 0 ;
PSN.lowLongOfPSN = kCurrentProcess ;
SetFrontProcess( &PSN ) ;
return noErr ;
for (i = 1; i <= itemsInList; i++) {
AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
(Ptr) & theSpec, sizeof(theSpec), &actualSize);
wxString fName = wxMacFSSpec2MacFilename(&theSpec);
MacOpenFile(fName);
}
return noErr;
}
short wxApp::MacHandleAEPDoc(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply))
{
return noErr ;
AEDescList docList;
AEKeyword keywd;
DescType returnedType;
Size actualSize;
long itemsInList;
FSSpec theSpec;
OSErr err;
short i;
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
if (err != noErr)
return err;
err = AECountItems(&docList, &itemsInList);
if (err != noErr)
return err;
ProcessSerialNumber PSN ;
PSN.highLongOfPSN = 0 ;
PSN.lowLongOfPSN = kCurrentProcess ;
SetFrontProcess( &PSN ) ;
for (i = 1; i <= itemsInList; i++) {
AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
(Ptr) & theSpec, sizeof(theSpec), &actualSize);
wxString fName = wxMacFSSpec2MacFilename(&theSpec);
MacPrintFile(fName);
}
return noErr;
}
short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
{
MacNewFile() ;
return noErr ;
}

View File

@ -133,23 +133,88 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
}
short wxApp::MacHandleAEODoc(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
// new virtual public method in wxApp
void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) )
{
SysBeep(40) ;
}
void wxApp::MacPrintFile(const wxString & WXUNUSED(fileName) )
{
}
void wxApp::MacNewFile()
{
}
// new implementation, which parses the event and calls
// MacOpenFile on each of the files it's passed
short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
{
AEDescList docList;
AEKeyword keywd;
DescType returnedType;
Size actualSize;
long itemsInList;
FSSpec theSpec;
OSErr err;
short i;
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
if (err != noErr)
return err;
err = AECountItems(&docList, &itemsInList);
if (err != noErr)
return err;
ProcessSerialNumber PSN ;
PSN.highLongOfPSN = 0 ;
PSN.lowLongOfPSN = kCurrentProcess ;
SetFrontProcess( &PSN ) ;
return noErr ;
for (i = 1; i <= itemsInList; i++) {
AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
(Ptr) & theSpec, sizeof(theSpec), &actualSize);
wxString fName = wxMacFSSpec2MacFilename(&theSpec);
MacOpenFile(fName);
}
return noErr;
}
short wxApp::MacHandleAEPDoc(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply))
{
return noErr ;
AEDescList docList;
AEKeyword keywd;
DescType returnedType;
Size actualSize;
long itemsInList;
FSSpec theSpec;
OSErr err;
short i;
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
if (err != noErr)
return err;
err = AECountItems(&docList, &itemsInList);
if (err != noErr)
return err;
ProcessSerialNumber PSN ;
PSN.highLongOfPSN = 0 ;
PSN.lowLongOfPSN = kCurrentProcess ;
SetFrontProcess( &PSN ) ;
for (i = 1; i <= itemsInList; i++) {
AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
(Ptr) & theSpec, sizeof(theSpec), &actualSize);
wxString fName = wxMacFSSpec2MacFilename(&theSpec);
MacPrintFile(fName);
}
return noErr;
}
short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
{
MacNewFile() ;
return noErr ;
}