routing all apple events to the document manager instance if present, fully supporting launch by document double click, print by draging the document onto the printer icon

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18669 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2003-01-10 17:56:24 +00:00
parent 72625f830b
commit 738a6daa71
2 changed files with 74 additions and 8 deletions

View File

@ -36,6 +36,8 @@
#include "wx/tooltip.h"
#include "wx/textctrl.h"
#include "wx/menu.h"
#include "wx/docview.h"
#if wxUSE_WX_RESOURCES
# include "wx/resource.h"
#endif
@ -73,6 +75,8 @@ extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList;
static bool s_inYield = FALSE;
wxApp *wxTheApp = NULL;
#if !USE_SHARED_LIBRARY
@ -136,12 +140,39 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX
}
// new virtual public method in wxApp
void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) )
void wxApp::MacOpenFile(const wxString & fileName )
{
wxDocManager* dm = wxDocManager::GetDocumentManager() ;
if ( dm )
dm->CreateDocument(fileName , wxDOC_SILENT ) ;
}
void wxApp::MacPrintFile(const wxString & WXUNUSED(fileName) )
void wxApp::MacPrintFile(const wxString & fileName )
{
wxDocManager* dm = wxDocManager::GetDocumentManager() ;
if ( dm )
{
wxDocument *doc = dm->CreateDocument(fileName , wxDOC_SILENT ) ;
if ( doc )
{
wxView* view = doc->GetFirstView() ;
if( view )
{
wxPrintout *printout = view->OnCreatePrintout();
if (printout)
{
wxPrinter printer;
printer.Print(view->GetFrame(), printout, TRUE);
delete printout;
}
}
if (doc->Close())
{
doc->DeleteAllViews();
dm->RemoveDocument(doc) ;
}
}
}
}
void wxApp::MacNewFile()
@ -1322,8 +1353,6 @@ void wxCYield()
bool wxApp::Yield(bool onlyIfNeeded)
{
static bool s_inYield = FALSE;
if (s_inYield)
{
if ( !onlyIfNeeded )
@ -1560,8 +1589,12 @@ void wxApp::MacHandleOneEvent( WXEVENTREF evr )
void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr )
{
// we must avoid reentrancy problems when processing high level events eg printing
bool former = s_inYield ;
s_inYield = TRUE ;
EventRecord* ev = (EventRecord*) evr ;
::AEProcessAppleEvent( ev ) ;
s_inYield = former ;
}
bool s_macIsInModalLoop = false ;

View File

@ -36,6 +36,8 @@
#include "wx/tooltip.h"
#include "wx/textctrl.h"
#include "wx/menu.h"
#include "wx/docview.h"
#if wxUSE_WX_RESOURCES
# include "wx/resource.h"
#endif
@ -73,6 +75,8 @@ extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList;
static bool s_inYield = FALSE;
wxApp *wxTheApp = NULL;
#if !USE_SHARED_LIBRARY
@ -136,12 +140,39 @@ pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WX
}
// new virtual public method in wxApp
void wxApp::MacOpenFile(const wxString & WXUNUSED(fileName) )
void wxApp::MacOpenFile(const wxString & fileName )
{
wxDocManager* dm = wxDocManager::GetDocumentManager() ;
if ( dm )
dm->CreateDocument(fileName , wxDOC_SILENT ) ;
}
void wxApp::MacPrintFile(const wxString & WXUNUSED(fileName) )
void wxApp::MacPrintFile(const wxString & fileName )
{
wxDocManager* dm = wxDocManager::GetDocumentManager() ;
if ( dm )
{
wxDocument *doc = dm->CreateDocument(fileName , wxDOC_SILENT ) ;
if ( doc )
{
wxView* view = doc->GetFirstView() ;
if( view )
{
wxPrintout *printout = view->OnCreatePrintout();
if (printout)
{
wxPrinter printer;
printer.Print(view->GetFrame(), printout, TRUE);
delete printout;
}
}
if (doc->Close())
{
doc->DeleteAllViews();
dm->RemoveDocument(doc) ;
}
}
}
}
void wxApp::MacNewFile()
@ -1322,8 +1353,6 @@ void wxCYield()
bool wxApp::Yield(bool onlyIfNeeded)
{
static bool s_inYield = FALSE;
if (s_inYield)
{
if ( !onlyIfNeeded )
@ -1560,8 +1589,12 @@ void wxApp::MacHandleOneEvent( WXEVENTREF evr )
void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr )
{
// we must avoid reentrancy problems when processing high level events eg printing
bool former = s_inYield ;
s_inYield = TRUE ;
EventRecord* ev = (EventRecord*) evr ;
::AEProcessAppleEvent( ev ) ;
s_inYield = former ;
}
bool s_macIsInModalLoop = false ;