Use better title by default in wxDocPrintout.

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
This commit is contained in:
Vadim Zeitlin
2011-02-06 01:01:09 +00:00
parent a5c468483d
commit 302674fe17
2 changed files with 21 additions and 2 deletions

View File

@@ -922,7 +922,7 @@ private:
class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout class WXDLLIMPEXP_CORE wxDocPrintout : public wxPrintout
{ {
public: public:
wxDocPrintout(wxView *view = NULL, const wxString& title = _("Printout")); wxDocPrintout(wxView *view = NULL, const wxString& title = wxString());
// implement wxPrintout methods // implement wxPrintout methods
virtual bool OnPrintPage(int page); virtual bool OnPrintPage(int page);

View File

@@ -1976,8 +1976,27 @@ bool wxDocChildFrameAnyBase::CloseView(wxCloseEvent& event)
#if wxUSE_PRINTING_ARCHITECTURE #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) wxDocPrintout::wxDocPrintout(wxView *view, const wxString& title)
: wxPrintout(title) : wxPrintout(GetAppropriateTitle(view, title))
{ {
m_printoutView = view; m_printoutView = view;
} }