]> git.saurik.com Git - wxWidgets.git/commitdiff
Store page setup data in wxDocManager.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 May 2010 20:05:39 +0000 (20:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 May 2010 20:05:39 +0000 (20:05 +0000)
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

docs/changes.txt
include/wx/docview.h
src/common/docview.cpp

index 357c9534d8e122c9c115bf3c59527e13c8b56c72..80cd2d646fb3966ded2e680022f74756569083be 100644 (file)
@@ -629,6 +629,7 @@ All:
 - 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).
 
 All (Unix):
 
index ee7067b09d1cb11f17bfb22592d095dca886b4dc..0c929524671d5d1143120d622c26e5bddda8c073 100644 (file)
@@ -371,8 +371,11 @@ public:
     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 OnPageSetup(wxCommandEvent& event);
+#endif // wxUSE_PRINTING_ARCHITECTURE
     void OnUndo(wxCommandEvent& event);
     void OnRedo(wxCommandEvent& event);
 
@@ -479,6 +482,7 @@ public:
     wxDEPRECATED( size_t GetNoHistoryFiles() const );
 #endif // WXWIN_COMPATIBILITY_2_6
 
+
 protected:
 #if wxUSE_PRINTING_ARCHITECTURE
     virtual wxPreviewFrame* CreatePreviewFrame(wxPrintPreviewBase* preview,
@@ -507,6 +511,10 @@ protected:
     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);
index 03d455b528294f84b127986d1f948c1ca753aab0..fa23123c8df49729d538e4e913619e93ed9b1e8e 100644 (file)
@@ -897,10 +897,12 @@ BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler)
 #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)
-#endif
+    EVT_UPDATE_UI(wxID_PRINT_SETUP, wxDocManager::OnUpdateDisableIfNoDoc)
+#endif // wxUSE_PRINTING_ARCHITECTURE
 END_EVENT_TABLE()
 
 wxDocManager* wxDocManager::sm_docManager = NULL;
@@ -1080,9 +1082,10 @@ void wxDocManager::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
     doc->SaveAs();
 }
 
+#if wxUSE_PRINTING_ARCHITECTURE
+
 void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
 {
-#if wxUSE_PRINTING_ARCHITECTURE
     wxView *view = GetActiveView();
     if (!view)
         return;
@@ -1090,26 +1093,32 @@ void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
     wxPrintout *printout = view->OnCreatePrintout();
     if (printout)
     {
-        wxPrinter printer;
+        wxPrintDialogData printDialogData(m_pageSetupDialogData.GetPrintData());
+        wxPrinter printer(&printDialogData);
         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);
 }
-#endif // wxUSE_PRINTING_ARCHITECTURE
 
 void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
 {
-#if wxUSE_PRINTING_ARCHITECTURE
     wxBusyCursor busy;
     wxView *view = GetActiveView();
     if (!view)
@@ -1118,9 +1127,13 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
     wxPrintout *printout = view->OnCreatePrintout();
     if (printout)
     {
+        wxPrintDialogData printDialogData(m_pageSetupDialogData.GetPrintData());
+
         // 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;
@@ -1137,8 +1150,8 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
         frame->Initialize();
         frame->Show(true);
     }
-#endif // wxUSE_PRINTING_ARCHITECTURE
 }
+#endif // wxUSE_PRINTING_ARCHITECTURE
 
 void wxDocManager::OnUndo(wxCommandEvent& event)
 {