Printing of documents from wxDocManager always used default page setup data,
allow the user to configure it now.
Add wxDocManager::m_pageSetupDialogData and add a handler for wxID_PRINT_SETUP
command to it.
Closes #11394.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64439
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
- wxImage handlers can now support multiple extensions (Ivan Krestinin).
- Added wxFileName::StripExtension() (troelsk).
- Added wxLOCALE_DATE/TIME_FMT support to wxLocale::GetInfo().
- wxImage handlers can now support multiple extensions (Ivan Krestinin).
- Added wxFileName::StripExtension() (troelsk).
- Added wxLOCALE_DATE/TIME_FMT support to wxLocale::GetInfo().
+- Store page setup data directly in wxDocManager (troelsk).
void OnFileRevert(wxCommandEvent& event);
void OnFileSave(wxCommandEvent& event);
void OnFileSaveAs(wxCommandEvent& event);
void OnFileRevert(wxCommandEvent& event);
void OnFileSave(wxCommandEvent& event);
void OnFileSaveAs(wxCommandEvent& event);
+#if wxUSE_PRINTING_ARCHITECTURE
void OnPrint(wxCommandEvent& event);
void OnPreview(wxCommandEvent& event);
void OnPrint(wxCommandEvent& event);
void OnPreview(wxCommandEvent& event);
+ void OnPageSetup(wxCommandEvent& event);
+#endif // wxUSE_PRINTING_ARCHITECTURE
void OnUndo(wxCommandEvent& event);
void OnRedo(wxCommandEvent& event);
void OnUndo(wxCommandEvent& event);
void OnRedo(wxCommandEvent& event);
wxDEPRECATED( size_t GetNoHistoryFiles() const );
#endif // WXWIN_COMPATIBILITY_2_6
wxDEPRECATED( size_t GetNoHistoryFiles() const );
#endif // WXWIN_COMPATIBILITY_2_6
protected:
#if wxUSE_PRINTING_ARCHITECTURE
virtual wxPreviewFrame* CreatePreviewFrame(wxPrintPreviewBase* preview,
protected:
#if wxUSE_PRINTING_ARCHITECTURE
virtual wxPreviewFrame* CreatePreviewFrame(wxPrintPreviewBase* preview,
wxString m_lastDirectory;
static wxDocManager* sm_docManager;
wxString m_lastDirectory;
static wxDocManager* sm_docManager;
+#if wxUSE_PRINTING_ARCHITECTURE
+ wxPageSetupDialogData m_pageSetupDialogData;
+#endif // wxUSE_PRINTING_ARCHITECTURE
+
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxDocManager)
wxDECLARE_NO_COPY_CLASS(wxDocManager);
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxDocManager)
wxDECLARE_NO_COPY_CLASS(wxDocManager);
#if wxUSE_PRINTING_ARCHITECTURE
EVT_MENU(wxID_PRINT, wxDocManager::OnPrint)
EVT_MENU(wxID_PREVIEW, wxDocManager::OnPreview)
#if wxUSE_PRINTING_ARCHITECTURE
EVT_MENU(wxID_PRINT, wxDocManager::OnPrint)
EVT_MENU(wxID_PREVIEW, wxDocManager::OnPreview)
+ EVT_MENU(wxID_PRINT_SETUP, wxDocManager::OnPageSetup)
EVT_UPDATE_UI(wxID_PRINT, wxDocManager::OnUpdateDisableIfNoDoc)
EVT_UPDATE_UI(wxID_PREVIEW, wxDocManager::OnUpdateDisableIfNoDoc)
EVT_UPDATE_UI(wxID_PRINT, wxDocManager::OnUpdateDisableIfNoDoc)
EVT_UPDATE_UI(wxID_PREVIEW, wxDocManager::OnUpdateDisableIfNoDoc)
+ EVT_UPDATE_UI(wxID_PRINT_SETUP, wxDocManager::OnUpdateDisableIfNoDoc)
+#endif // wxUSE_PRINTING_ARCHITECTURE
END_EVENT_TABLE()
wxDocManager* wxDocManager::sm_docManager = NULL;
END_EVENT_TABLE()
wxDocManager* wxDocManager::sm_docManager = NULL;
+#if wxUSE_PRINTING_ARCHITECTURE
+
void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
{
void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
{
-#if wxUSE_PRINTING_ARCHITECTURE
wxView *view = GetActiveView();
if (!view)
return;
wxView *view = GetActiveView();
if (!view)
return;
wxPrintout *printout = view->OnCreatePrintout();
if (printout)
{
wxPrintout *printout = view->OnCreatePrintout();
if (printout)
{
+ wxPrintDialogData printDialogData(m_pageSetupDialogData.GetPrintData());
+ wxPrinter printer(&printDialogData);
printer.Print(view->GetFrame(), printout, true);
delete printout;
}
printer.Print(view->GetFrame(), printout, true);
delete printout;
}
-#endif // wxUSE_PRINTING_ARCHITECTURE
-#if wxUSE_PRINTING_ARCHITECTURE
+void wxDocManager::OnPageSetup(wxCommandEvent& WXUNUSED(event))
+{
+ wxPageSetupDialog dlg(wxTheApp->GetTopWindow(), &m_pageSetupDialogData);
+ if ( dlg.ShowModal() == wxID_OK )
+ {
+ m_pageSetupDialogData = dlg.GetPageSetupData();
+ }
+}
+
wxPreviewFrame* wxDocManager::CreatePreviewFrame(wxPrintPreviewBase* preview,
wxWindow *parent,
const wxString& title)
{
return new wxPreviewFrame(preview, parent, title);
}
wxPreviewFrame* wxDocManager::CreatePreviewFrame(wxPrintPreviewBase* preview,
wxWindow *parent,
const wxString& title)
{
return new wxPreviewFrame(preview, parent, title);
}
-#endif // wxUSE_PRINTING_ARCHITECTURE
void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
{
void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
{
-#if wxUSE_PRINTING_ARCHITECTURE
wxBusyCursor busy;
wxView *view = GetActiveView();
if (!view)
wxBusyCursor busy;
wxView *view = GetActiveView();
if (!view)
wxPrintout *printout = view->OnCreatePrintout();
if (printout)
{
wxPrintout *printout = view->OnCreatePrintout();
if (printout)
{
+ wxPrintDialogData printDialogData(m_pageSetupDialogData.GetPrintData());
+
// Pass two printout objects: for preview, and possible printing.
wxPrintPreviewBase *
// Pass two printout objects: for preview, and possible printing.
wxPrintPreviewBase *
- preview = new wxPrintPreview(printout, view->OnCreatePrintout());
+ preview = new wxPrintPreview(printout,
+ view->OnCreatePrintout(),
+ &printDialogData);
if ( !preview->Ok() )
{
delete preview;
if ( !preview->Ok() )
{
delete preview;
frame->Initialize();
frame->Show(true);
}
frame->Initialize();
frame->Show(true);
}
-#endif // wxUSE_PRINTING_ARCHITECTURE
+#endif // wxUSE_PRINTING_ARCHITECTURE
void wxDocManager::OnUndo(wxCommandEvent& event)
{
void wxDocManager::OnUndo(wxCommandEvent& event)
{