diff --git a/docs/latex/wx/pagedlg.tex b/docs/latex/wx/pagedlg.tex index ab02ba67b2..b68a9ffeb6 100644 --- a/docs/latex/wx/pagedlg.tex +++ b/docs/latex/wx/pagedlg.tex @@ -50,6 +50,14 @@ Destructor. Returns the \helpref{page setup data}{wxpagesetupdialogdata} associated with the dialog. +\membersection{wxPageSetupDialog::Ok}\label{wxpagesetupdialogok} + +\constfunc{bool}{Ok}{\void} + +Returns TRUE if the print data associated with the dialog data is valid. +This can return FALSE on Windows if the current printer is not set, for example. +On all other platforms, it returns TRUE. + \membersection{wxPageSetupDialog::ShowModal}\label{wxpagesetupdialogshowmodal} \func{int}{ShowModal}{\void} @@ -218,6 +226,14 @@ Returns the paper size in millimetres. Returns a reference to the \helpref{print data}{wxprintdata} associated with this object. +\membersection{wxPageSetupDialogData::Ok}\label{wxpagesetupdialogdataok} + +\constfunc{bool}{Ok}{\void} + +Returns TRUE if the print data associated with the dialog data is valid. +This can return FALSE on Windows if the current printer is not set, for example. +On all other platforms, it returns TRUE. + \membersection{wxPageSetupDialogData::SetDefaultInfo}\label{wxpagesetupdialogdatasetdefaultinfo} \func{void}{SetDefaultInfo}{\param{bool}{ flag}} diff --git a/docs/latex/wx/print.tex b/docs/latex/wx/print.tex index 8fa5bdd5a5..cc4df2a635 100644 --- a/docs/latex/wx/print.tex +++ b/docs/latex/wx/print.tex @@ -134,6 +134,14 @@ wxPRINT_QUALITY_DRAFT On input you should pass one of these identifiers, but on return you may get back a positive integer indicating the current resolution setting. +\membersection{wxPrintData::Ok}\label{wxprintdataok} + +\constfunc{bool}{Ok}{\void} + +Returns TRUE if the print data is valid for using in print dialogs. +This can return FALSE on Windows if the current printer is not set, for example. +On all other platforms, it returns TRUE. + \membersection{wxPrintData::SetCollate}\label{wxprintdatasetcollate} \func{void}{SetCollate}{\param{bool }{flag}} @@ -338,6 +346,14 @@ When this function has been called, the ownership of the device context is transferred to the application, so it must then be deleted explicitly. +\membersection{wxPrintDialog::Ok}\label{wxprintdialogok} + +\constfunc{bool}{Ok}{\void} + +Returns TRUE if the print data associated with the dialog is valid. +This can return FALSE on Windows if the current printer is not set, for example. +On all other platforms, it returns TRUE. + \membersection{wxPrintDialog::ShowModal}\label{wxprintdialogshowmodal} \func{int}{ShowModal}{\void} @@ -470,6 +486,14 @@ a concept specific to the application). Returns the {\it to} page number, as entered by the user. +\membersection{wxPrintDialogData::Ok}\label{wxprintdialogdataok} + +\constfunc{bool}{Ok}{\void} + +Returns TRUE if the print data is valid for using in print dialogs. +This can return FALSE on Windows if the current printer is not set, for example. +On all other platforms, it returns TRUE. + \membersection{wxPrintDialogData::SetCollate}\label{wxprintdialogdatasetcollate} \func{void}{SetCollate}{\param{bool }{flag}} diff --git a/include/wx/cmndata.h b/include/wx/cmndata.h index 8f58b83962..d2d1a2a4b2 100644 --- a/include/wx/cmndata.h +++ b/include/wx/cmndata.h @@ -140,6 +140,9 @@ class WXDLLEXPORT wxPrintData: public wxObject bool GetCollate() const { return m_printCollate; }; int GetOrientation() const { return m_printOrientation; }; + // Is this data OK for showing the print dialog? + bool Ok() const ; + const wxString& GetPrinterName() const { return m_printerName; } bool GetColour() const { return m_colour; } wxDuplexMode GetDuplex() const { return m_duplexMode; } @@ -288,6 +291,9 @@ class WXDLLEXPORT wxPrintDialogData: public wxObject bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }; bool GetEnableHelp() const { return m_printEnableHelp; }; + // Is this data OK for showing the print dialog? + bool Ok() const { return m_printData.Ok() ; } + wxPrintData& GetPrintData() { return m_printData; } void SetPrintData(const wxPrintData& printData) { m_printData = printData; } @@ -361,6 +367,9 @@ public: bool GetDefaultInfo() const { return m_getDefaultInfo; }; bool GetEnableHelp() const { return m_enableHelp; }; + // Is this data OK for showing the page setup dialog? + bool Ok() const { return m_printData.Ok() ; } + // If a corresponding paper type is found in the paper database, will set the m_printData // paper size id member as well. void SetPaperSize(const wxSize& sz); diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 78471439df..e09196f2fe 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -853,6 +853,16 @@ void wxPrintData::operator=(const wxPrintSetupData& setupData) } #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA +// Is this data OK for showing the print dialog? +bool wxPrintData::Ok() const +{ +#ifdef __WXMSW__ + ((wxPrintData*)this)->ConvertToNative(); + return (m_devMode != NULL) ; +#else + return TRUE; +#endif +} // ---------------------------------------------------------------------------- // Print dialog data @@ -967,7 +977,8 @@ void wxPrintDialogData::ConvertToNative() m_printData.SetNativeData((void*) NULL); - wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); + // Shouldn't assert; we should be able to test Ok-ness at a higher level + //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); pd->hDevNames = (HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames(); @@ -1279,7 +1290,8 @@ void wxPageSetupDialogData::ConvertToNative() m_printData.SetNativeData((void*) NULL); - wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); + // Shouldn't assert; we should be able to test Ok-ness at a higher level + //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); // Pass the devnames data (created in m_printData.ConvertToNative) // to the PRINTDLG structure, since it'll diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 801403e017..5c3f71cbd9 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -543,6 +543,13 @@ void wxHtmlEasyPrinting::PrinterSetup() void wxHtmlEasyPrinting::PageSetup() { + if (!m_PrintData->Ok()) + { + wxMessageBox(_("Sorry, there was a problem: you may need to set a default printer."), + _("Page Setup Problem"), wxICON_INFORMATION|wxOK, m_Frame); + return; + } + m_PageSetupData->SetPrintData(*m_PrintData); wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData); diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index a7f9c58876..4b33ade2c9 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -172,11 +172,14 @@ bool wxStaticText::SetFont(const wxFont& font) long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { - // Ensure that static items get messages. Some controls don't like this - // message to be intercepted (e.g. RichEdit), hence the tests. - if (nMsg == WM_NCHITTEST) - return (long)HTCLIENT; - - return wxWindow::MSWWindowProc(nMsg, wParam, lParam); + // Ensure that static items get messages. Some controls don't like this + // message to be intercepted (e.g. RichEdit), hence the tests. + // Messes up display with Windows XP, apparently, so have to + // do explicit hit-testing in wxWindowMSW. +#if 0 + if (nMsg == WM_NCHITTEST) + return (long)HTCLIENT; +#endif + return wxWindow::MSWWindowProc(nMsg, wParam, lParam); } #endif // wxUSE_STATTEXT