]> git.saurik.com Git - wxWidgets.git/commitdiff
Use better title by default in wxDocPrintout.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Feb 2011 01:01:09 +0000 (01:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Feb 2011 01:01:09 +0000 (01:01 +0000)
Use the document name instead of the default "Printout" if no title is
explicitly specified when creating wxDocPrintout.

Closes #12885.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/docview.h
src/common/docview.cpp

index 78038deaeb1be5e41781d122d860529f21845959..6cf9441ad494ab68437a0b10ceb4f479b06d7717 100644 (file)
@@ -922,7 +922,7 @@ private:
 class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout
 {
 public:
-    wxDocPrintout(wxView *view = NULL, const wxString& title = _("Printout"));
+    wxDocPrintout(wxView *view = NULL, const wxString& title = wxString());
 
     // implement wxPrintout methods
     virtual bool OnPrintPage(int page);
index 86d1783490db08f66d384bde644ce2ca7aae9da0..162a1755174e2c0c2a7eef88487244e7db2ccf1a 100644 (file)
@@ -1976,8 +1976,27 @@ bool wxDocChildFrameAnyBase::CloseView(wxCloseEvent& event)
 
 #if wxUSE_PRINTING_ARCHITECTURE
 
+namespace
+{
+
+wxString GetAppropriateTitle(const wxView *view, const wxString& titleGiven)
+{
+    wxString title(titleGiven);
+    if ( title.empty() )
+    {
+        if ( view && view->GetDocument() )
+            title = view->GetDocument()->GetUserReadableName();
+        else
+            title = _("Printout");
+    }
+
+    return title;
+}
+
+} // anonymous namespace
+
 wxDocPrintout::wxDocPrintout(wxView *view, const wxString& title)
-             : wxPrintout(title)
+             : wxPrintout(GetAppropriateTitle(view, title))
 {
     m_printoutView = view;
 }