completing OnInit rework for getURL and printFiles callback

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74954 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2013-10-07 11:12:41 +00:00
parent 62fe7a015a
commit c902d81d44
3 changed files with 41 additions and 7 deletions

View File

@@ -129,13 +129,15 @@ public:
virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
#endif #endif
// in response of an openFiles message with Cocoa and an // in response of an openFiles message with Cocoa and an
// open-document apple event with Carbon // open-document apple event
virtual void MacOpenFiles(const wxArrayString &fileNames) ; virtual void MacOpenFiles(const wxArrayString &fileNames) ;
// called by MacOpenFiles for each file. // called by MacOpenFiles for each file.
virtual void MacOpenFile(const wxString &fileName) ; virtual void MacOpenFile(const wxString &fileName) ;
// in response of a get-url apple event // in response of a get-url apple event
virtual void MacOpenURL(const wxString &url) ; virtual void MacOpenURL(const wxString &url) ;
// in response of a print-document apple event // in response of a print-document apple event
virtual void MacPrintFiles(const wxArrayString &fileNames) ;
// called by MacPrintFiles for each file
virtual void MacPrintFile(const wxString &fileName) ; virtual void MacPrintFile(const wxString &fileName) ;
// in response of a open-application apple event // in response of a open-application apple event
virtual void MacNewFile() ; virtual void MacNewFile() ;
@@ -155,10 +157,14 @@ private:
bool m_onInitResult; bool m_onInitResult;
bool m_inited; bool m_inited;
wxArrayString m_openFiles; wxArrayString m_openFiles;
wxArrayString m_printFiles;
wxString m_getURL;
public: public:
bool OSXInitWasCalled() { return m_inited; } bool OSXInitWasCalled() { return m_inited; }
void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; } void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; }
void OSXStorePrintFiles(const wxArrayString &files ) { m_printFiles = files ; }
void OSXStoreOpenURL(const wxString &url ) { m_getURL = url ; }
#endif #endif
// Hide the application windows the same as the system hide command would do it. // Hide the application windows the same as the system hide command would do it.

View File

@@ -230,6 +230,8 @@ short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply)
wxString fName ; wxString fName ;
FSRef theRef ; FSRef theRef ;
wxArrayString fileNames;
for (i = 1; i <= itemsInList; i++) for (i = 1; i <= itemsInList; i++)
{ {
err = AEGetNthPtr( err = AEGetNthPtr(
@@ -240,10 +242,11 @@ short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply)
return err; return err;
fName = wxMacFSRefToPath( &theRef ) ; fName = wxMacFSRefToPath( &theRef ) ;
files += fName;
MacPrintFile(fName);
} }
MacPrintFiles(fileNames);
return noErr; return noErr;
} }
@@ -307,6 +310,16 @@ void wxApp::MacOpenURL(const wxString & WXUNUSED(url) )
{ {
} }
void wxApp::MacPrintFiles(const wxArrayString & fileNames )
{
size_t i;
const size_t fileCount = fileNames.GetCount();
for (i = 0; i < fileCount; i++)
{
MacPrintFile(fileNames[i]);
}
}
void wxApp::MacPrintFile(const wxString & fileName ) void wxApp::MacPrintFile(const wxString & fileName )
{ {
#if wxUSE_DOC_VIEW_ARCHITECTURE #if wxUSE_DOC_VIEW_ARCHITECTURE

View File

@@ -86,12 +86,23 @@ void wxBell()
wxTheApp->OSXStoreOpenFiles(fileList); wxTheApp->OSXStoreOpenFiles(fileList);
} }
- (BOOL)application:(NSApplication *)sender printFile:(NSString *)filename - (NSApplicationPrintReply)application:(NSApplication *)sender printFiles:(NSArray *)fileNames withSettings:(NSDictionary *)printSettings showPrintPanels:(BOOL)showPrintPanels
{ {
wxUnusedVar(sender); wxUnusedVar(sender);
wxCFStringRef cf(wxCFRetain(filename)); wxArrayString fileList;
wxTheApp->MacPrintFile(cf.AsString()) ; size_t i;
return YES; const size_t count = [fileNames count];
for (i = 0; i < count; i++)
{
fileList.Add( wxCFStringRef::AsStringWithNormalizationFormC([fileNames objectAtIndex:i]) );
}
if ( wxTheApp->OSXInitWasCalled() )
wxTheApp->MacPrintFiles(fileList);
else
wxTheApp->OSXStorePrintFiles(fileList);
return NSPrintingSuccess;
} }
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
@@ -325,6 +336,10 @@ bool wxApp::CallOnInit()
{ {
if ( m_openFiles.GetCount() > 0 ) if ( m_openFiles.GetCount() > 0 )
MacOpenFiles(m_openFiles); MacOpenFiles(m_openFiles);
else if ( m_printFiles.GetCount() > 0 )
MacPrintFiles(m_printFiles);
else if ( m_getURL.Len() > 0 )
MacOpenURL(m_getURL);
else else
MacNewFile(); MacNewFile();
} }