Added Ok() member for print data, print dialog, page dialog, page dialog data
so we can test in advance whether the print/page setup dialogs will fail. Removed assertions that would fire if the default printer was not found, for example. Added call to Ok() from HTML print code with suitable error message. Commented out my erroneous fix to wxStaticText. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,6 +50,14 @@ Destructor.
|
|||||||
|
|
||||||
Returns the \helpref{page setup data}{wxpagesetupdialogdata} associated with the dialog.
|
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}
|
\membersection{wxPageSetupDialog::ShowModal}\label{wxpagesetupdialogshowmodal}
|
||||||
|
|
||||||
\func{int}{ShowModal}{\void}
|
\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.
|
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}
|
\membersection{wxPageSetupDialogData::SetDefaultInfo}\label{wxpagesetupdialogdatasetdefaultinfo}
|
||||||
|
|
||||||
\func{void}{SetDefaultInfo}{\param{bool}{ flag}}
|
\func{void}{SetDefaultInfo}{\param{bool}{ flag}}
|
||||||
|
@@ -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
|
On input you should pass one of these identifiers, but on return you may get back a positive integer
|
||||||
indicating the current resolution setting.
|
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}
|
\membersection{wxPrintData::SetCollate}\label{wxprintdatasetcollate}
|
||||||
|
|
||||||
\func{void}{SetCollate}{\param{bool }{flag}}
|
\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
|
is transferred to the application, so it must then be deleted
|
||||||
explicitly.
|
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}
|
\membersection{wxPrintDialog::ShowModal}\label{wxprintdialogshowmodal}
|
||||||
|
|
||||||
\func{int}{ShowModal}{\void}
|
\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.
|
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}
|
\membersection{wxPrintDialogData::SetCollate}\label{wxprintdialogdatasetcollate}
|
||||||
|
|
||||||
\func{void}{SetCollate}{\param{bool }{flag}}
|
\func{void}{SetCollate}{\param{bool }{flag}}
|
||||||
|
@@ -140,6 +140,9 @@ class WXDLLEXPORT wxPrintData: public wxObject
|
|||||||
bool GetCollate() const { return m_printCollate; };
|
bool GetCollate() const { return m_printCollate; };
|
||||||
int GetOrientation() const { return m_printOrientation; };
|
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; }
|
const wxString& GetPrinterName() const { return m_printerName; }
|
||||||
bool GetColour() const { return m_colour; }
|
bool GetColour() const { return m_colour; }
|
||||||
wxDuplexMode GetDuplex() const { return m_duplexMode; }
|
wxDuplexMode GetDuplex() const { return m_duplexMode; }
|
||||||
@@ -288,6 +291,9 @@ class WXDLLEXPORT wxPrintDialogData: public wxObject
|
|||||||
bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
|
bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
|
||||||
bool GetEnableHelp() const { return m_printEnableHelp; };
|
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; }
|
wxPrintData& GetPrintData() { return m_printData; }
|
||||||
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
|
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
|
||||||
|
|
||||||
@@ -361,6 +367,9 @@ public:
|
|||||||
bool GetDefaultInfo() const { return m_getDefaultInfo; };
|
bool GetDefaultInfo() const { return m_getDefaultInfo; };
|
||||||
bool GetEnableHelp() const { return m_enableHelp; };
|
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
|
// If a corresponding paper type is found in the paper database, will set the m_printData
|
||||||
// paper size id member as well.
|
// paper size id member as well.
|
||||||
void SetPaperSize(const wxSize& sz);
|
void SetPaperSize(const wxSize& sz);
|
||||||
|
@@ -853,6 +853,16 @@ void wxPrintData::operator=(const wxPrintSetupData& setupData)
|
|||||||
}
|
}
|
||||||
#endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
|
#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
|
// Print dialog data
|
||||||
@@ -967,7 +977,8 @@ void wxPrintDialogData::ConvertToNative()
|
|||||||
|
|
||||||
m_printData.SetNativeData((void*) NULL);
|
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();
|
pd->hDevNames = (HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames();
|
||||||
|
|
||||||
@@ -1279,7 +1290,8 @@ void wxPageSetupDialogData::ConvertToNative()
|
|||||||
|
|
||||||
m_printData.SetNativeData((void*) NULL);
|
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)
|
// Pass the devnames data (created in m_printData.ConvertToNative)
|
||||||
// to the PRINTDLG structure, since it'll
|
// to the PRINTDLG structure, since it'll
|
||||||
|
@@ -543,6 +543,13 @@ void wxHtmlEasyPrinting::PrinterSetup()
|
|||||||
|
|
||||||
void wxHtmlEasyPrinting::PageSetup()
|
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);
|
m_PageSetupData->SetPrintData(*m_PrintData);
|
||||||
wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData);
|
wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData);
|
||||||
|
|
||||||
|
@@ -172,11 +172,14 @@ bool wxStaticText::SetFont(const wxFont& font)
|
|||||||
|
|
||||||
long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||||
{
|
{
|
||||||
// Ensure that static items get messages. Some controls don't like this
|
// Ensure that static items get messages. Some controls don't like this
|
||||||
// message to be intercepted (e.g. RichEdit), hence the tests.
|
// message to be intercepted (e.g. RichEdit), hence the tests.
|
||||||
if (nMsg == WM_NCHITTEST)
|
// Messes up display with Windows XP, apparently, so have to
|
||||||
return (long)HTCLIENT;
|
// do explicit hit-testing in wxWindowMSW.
|
||||||
|
#if 0
|
||||||
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
if (nMsg == WM_NCHITTEST)
|
||||||
|
return (long)HTCLIENT;
|
||||||
|
#endif
|
||||||
|
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STATTEXT
|
#endif // wxUSE_STATTEXT
|
||||||
|
Reference in New Issue
Block a user