Many changes to the printing classes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1981 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 1999-03-25 23:06:01 +00:00
parent 0ed9a934ca
commit 7bcb11d307
59 changed files with 5485 additions and 4090 deletions

View File

@ -57,6 +57,7 @@ in an application.
\twocolitem{\helpref{wxFontDialog}{wxfontdialog}}{Font chooser dialog}
\twocolitem{\helpref{wxPageSetupDialog}{wxpagesetupdialog}}{Standard page setup dialog}
\twocolitem{\helpref{wxPrintDialog}{wxprintdialog}}{Standard print dialog}
\twocolitem{\helpref{wxPageSetupDialog}{wxpagesetupdialog}}{Standard page setup dialog}
\twocolitem{\helpref{wxMessageDialog}{wxmessagedialog}}{Simple message box dialog}
\end{twocollist}
@ -308,12 +309,15 @@ facilities.
\twocolitem{\helpref{wxPreviewFrame}{wxpreviewframe}}{Frame for displaying a print preview}
\twocolitem{\helpref{wxPreviewCanvas}{wxpreviewcanvas}}{Canvas for displaying a print preview}
\twocolitem{\helpref{wxPreviewControlBar}{wxpreviewcontrolbar}}{Standard control bar for a print preview}
\twocolitem{\helpref{wxPrintData}{wxprintdata}}{Represents information about the document being printed}
\twocolitem{\helpref{wxPrintDialog}{wxprintdialog}}{Standard print dialog}
\twocolitem{\helpref{wxPageSetupDialog}{wxpagesetupdialog}}{Standard page setup dialog}
\twocolitem{\helpref{wxPrinter}{wxprinter}}{Class representing the printer}
\twocolitem{\helpref{wxPrinterDC}{wxprinterdc}}{Printer device context}
\twocolitem{\helpref{wxPrintout}{wxprintout}}{Class representing a particular printout}
\twocolitem{\helpref{wxPrintPreview}{wxprintpreview}}{Class representing a print preview}
\twocolitem{\helpref{wxPrintData}{wxprintdata}}{Represents information about the document being printed}
\twocolitem{\helpref{wxPrintDialogData}{wxprintdialogdata}}{Represents information about the print dialog}
\twocolitem{\helpref{wxPageSetupDialogData}{wxpagesetupdialogdata}}{Represents information about the page setup dialog}
\end{twocollist}
{\large {\bf Database classes}}

View File

@ -1,7 +1,10 @@
\section{\class{wxPageSetupData}}\label{wxpagesetupdata}
\section{\class{wxPageSetupDialogData}}\label{wxpagesetupdialogdata}
This class holds a variety of information related to \helpref{wxPageSetupDialog}{wxpagesetupdialog}.
It contains a \helpref{wxPrintData}{wxprintdata} member which is used to hold basic printer configuration data (as opposed to the
user-interface configuration settings stored by wxPageSetupDialogData).
\wxheading{Derived from}
\helpref{wxObject}{wxobject}
@ -16,177 +19,212 @@ This class holds a variety of information related to \helpref{wxPageSetupDialog}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxPageSetupData::wxPageSetupData}
\membersection{wxPageSetupDialogData::wxPageSetupDialogData}
\func{}{wxPageSetupData}{\void}
\func{}{wxPageSetupDialogData}{\void}
Constructor.
Default constructor.
\membersection{wxPageSetupData::\destruct{wxPageSetupData}}
\func{}{wxPageSetupDialogData}{\param{wxPageSetupDialogData\&}{ data}}
\func{}{\destruct{wxPageSetupData}}{\void}
Copy constructor.
\func{}{wxPrintDialogData}{\param{wxPrintData\&}{ printData}}
Construct an object from a print dialog data object.
\membersection{wxPageSetupDialogData::\destruct{wxPageSetupDialogData}}
\func{}{\destruct{wxPageSetupDialogData}}{\void}
Destructor.
\membersection{wxPageSetupData::EnableHelp}\label{wxpagesetupdataenablehelp}
\membersection{wxPageSetupDialogData::EnableHelp}\label{wxpagesetupdialogdataenablehelp}
\func{void}{EnableHelp}{\param{bool }{flag}}
Enables or disables the `Help' button (Windows only).
\membersection{wxPageSetupData::EnableMargins}\label{wxpagesetupdataenablemargins}
\membersection{wxPageSetupDialogData::EnableMargins}\label{wxpagesetupdialogdataenablemargins}
\func{void}{EnableMargins}{\param{bool }{flag}}
Enables or disables the margin controls (Windows only).
\membersection{wxPageSetupData::EnableOrientation}\label{wxpagesetupdataenableorientation}
\membersection{wxPageSetupDialogData::EnableOrientation}\label{wxpagesetupdialogdataenableorientation}
\func{void}{EnableOrientation}{\param{bool }{flag}}
Enables or disables the orientation control (Windows only).
\membersection{wxPageSetupData::EnablePaper}\label{wxpagesetupdataenablepaper}
\membersection{wxPageSetupDialogData::EnablePaper}\label{wxpagesetupdialogdataenablepaper}
\func{void}{EnablePaper}{\param{bool }{flag}}
Enables or disables the paper size control (Windows only).
\membersection{wxPageSetupData::EnablePrinter}\label{wxpagesetupdataenableprinter}
\membersection{wxPageSetupDialogData::EnablePrinter}\label{wxpagesetupdialogdataenableprinter}
\func{void}{EnablePrinter}{\param{bool }{flag}}
Enables or disables the {\bf Printer} button, which invokes a printer setup dialog.
\membersection{wxPageSetupData::GetPaperSize}\label{wxpagesetupdatagetpapersize}
\membersection{wxPageSetupDialogData::GetDefaultMinMargins}\label{wxpagesetupdialogdatagetdefaultminmargins}
\func{wxPoint}{GetPaperSize}{\void}
Returns the paper size in millimetres.
\membersection{wxPageSetupData::GetMarginTopLeft}\label{wxpagesetupdatagetmargintopleft}
\func{wxPoint}{GetMarginTopLeft}{\void}
Returns the left (x) and top (y) margins.
\membersection{wxPageSetupData::GetMarginBottomRight}\label{wxpagesetupdatagetmarginbottomright}
\func{wxPoint}{GetMarginBottomRight}{\void}
Returns the right (x) and bottom (y) margins.
\membersection{wxPageSetupData::GetMinMarginTopLeft}\label{wxpagesetupdatagetminmargintopleft}
\func{wxPoint}{GetMinMarginTopLeft}{\void}
Returns the left (x) and top (y) minimum margins the user can enter (Windows only).
\membersection{wxPageSetupData::GetMinMarginBottomRight}\label{wxpagesetupdatagetminmarginbottomright}
\func{wxPoint}{GetMinMarginBottomRight}{\void}
Returns the right (x) and bottom (y) minimum margins the user can enter (Windows only).
\membersection{wxPageSetupData::GetOrientation}\label{wxpagesetupdatagetorientation}
\func{int}{GetOrientation}{\void}
Returns the orientation, which can be wxPORTRAIT or wxLANDSCAPE.
\membersection{wxPageSetupData::GetDefaultMinMargins}\label{wxpagesetupdatagetdefaultminmargins}
\func{bool}{GetDefaultMinMargins}{\void}
\constfunc{bool}{GetDefaultMinMargins}{\void}
Returns TRUE if the page setup dialog will take its minimum margin values from the currently
selected printer properties. Windows only.
\membersection{wxPageSetupData::GetEnableMargins}\label{wxpagesetupdatagetenablemargins}
\membersection{wxPageSetupDialogData::GetEnableMargins}\label{wxpagesetupdialogdatagetenablemargins}
\func{bool}{GetEnableMargins}{\void}
\constfunc{bool}{GetEnableMargins}{\void}
Returns TRUE if the margin controls are enabled (Windows only).
\membersection{wxPageSetupData::GetEnableOrientation}\label{wxpagesetupdatagetenableorientation}
\membersection{wxPageSetupDialogData::GetEnableOrientation}\label{wxpagesetupdialogdatagetenableorientation}
\func{bool}{GetEnableOrientation}{\void}
\constfunc{bool}{GetEnableOrientation}{\void}
Returns TRUE if the orientation control is enabled (Windows only).
\membersection{wxPageSetupData::GetEnablePaper}\label{wxpagesetupdatagetenablepaper}
\membersection{wxPageSetupDialogData::GetEnablePaper}\label{wxpagesetupdialogdatagetenablepaper}
\func{bool}{GetEnablePaper}{\void}
\constfunc{bool}{GetEnablePaper}{\void}
Returns TRUE if the paper size control is enabled (Windows only).
\membersection{wxPageSetupData::GetEnablePrinter}\label{wxpagesetupdatagetenableprinter}
\membersection{wxPageSetupDialogData::GetEnablePrinter}\label{wxpagesetupdialogdatagetenableprinter}
\func{bool}{GetEnablePrinter}{\void}
\constfunc{bool}{GetEnablePrinter}{\void}
Returns TRUE if the printer setup button is enabled.
\membersection{wxPageSetupData::GetEnableHelp}\label{wxpagesetupdatagetenablehelp}
\membersection{wxPageSetupDialogData::GetEnableHelp}\label{wxpagesetupdialogdatagetenablehelp}
\func{bool}{GetEnableHelp}{\void}
\constfunc{bool}{GetEnableHelp}{\void}
Returns TRUE if the printer setup button is enabled.
\membersection{wxPageSetupData::GetDefaultInfo}\label{wxpagesetupdatagetdefaultinfo}
\membersection{wxPageSetupDialogData::GetDefaultInfo}\label{wxpagesetupdialogdatagetdefaultinfo}
\func{bool}{GetDefaultInfo}{\void}
\constfunc{bool}{GetDefaultInfo}{\void}
Returns TRUE if the dialog will simply return default printer information (such as orientation)
instead of showing a dialog. Windows only.
\membersection{wxPageSetupData::SetPaperSize}\label{wxpagesetupdatasetpapersize}
\membersection{wxPageSetupDialogData::GetMarginTopLeft}\label{wxpagesetupdialogdatagetmargintopleft}
\func{void}{SetPaperSize}{\param{const wxPoint\& }{size}}
\constfunc{wxPoint}{GetMarginTopLeft}{\void}
Sets the paper size in millimetres.
Returns the left (x) and top (y) margins.
\membersection{wxPageSetupData::SetMarginTopLeft}\label{wxpagesetupdatasetmargintopleft}
\membersection{wxPageSetupDialogData::GetMarginBottomRight}\label{wxpagesetupdialogdatagetmarginbottomright}
\func{void}{GetMarginTopLeft}{\param{const wxPoint\& }{pt}}
\constfunc{wxPoint}{GetMarginBottomRight}{\void}
Sets the left (x) and top (y) margins.
Returns the right (x) and bottom (y) margins.
\membersection{wxPageSetupData::SetMarginBottomRight}\label{wxpagesetupdatasetmarginbottomright}
\membersection{wxPageSetupDialogData::GetMinMarginTopLeft}\label{wxpagesetupdialogdatagetminmargintopleft}
\func{void}{SetMarginBottomRight}{\param{const wxPoint\& }{pt}}
\constfunc{wxPoint}{GetMinMarginTopLeft}{\void}
Sets the right (x) and bottom (y) margins.
Returns the left (x) and top (y) minimum margins the user can enter (Windows only).
\membersection{wxPageSetupData::SetMinMarginTopLeft}\label{wxpagesetupdatasetminmargintopleft}
\membersection{wxPageSetupDialogData::GetMinMarginBottomRight}\label{wxpagesetupdialogdatagetminmarginbottomright}
\func{void}{SetMinMarginTopLeft}{\param{const wxPoint\& }{pt}}
\constfunc{wxPoint}{GetMinMarginBottomRight}{\void}
Sets the left (x) and top (y) minimum margins the user can enter (Windows only).
Returns the right (x) and bottom (y) minimum margins the user can enter (Windows only).
\membersection{wxPageSetupData::SetMinMarginBottomRight}\label{wxpagesetupdatasetminmarginbottomright}
\membersection{wxPageSetupDialogData::GetPaperId}\label{wxpagesetupdialogdatagetpaperid}
\func{void}{SetMinMarginBottomRight}{\param{const wxPoint\& }{pt}}
\constfunc{wxPaperSize}{GetPaperId}{\void}
Sets the right (x) and bottom (y) minimum margins the user can enter (Windows only).
Returns the paper id (stored in the internal wxPrintData object).
\membersection{wxPageSetupData::SetOrientation}\label{wxpagesetupdatasetorientation}
For further information, see \helpref{wxPrintData::SetPaperId}{wxprintdatasetpaperid}.
\func{void}{SetOrientation}{\param{int }{orientation}}
\membersection{wxPageSetupDialogData::GetPaperSize}\label{wxpagesetupdialogdatagetpapersize}
Sets the orientation, which can be wxPORTRAIT or wxLANDSCAPE.
\constfunc{wxSize}{GetPaperSize}{\void}
\membersection{wxPageSetupData::SetDefaultMinMargins}\label{wxpagesetupdatasetdefaultminmargins}
Returns the paper size in millimetres.
\membersection{wxPageSetupDialogData::GetPrintData}\label{wxpagesetupdialogdatagetprintdata}
\func{wxPrintData\&}{GetPrintData}{\void}
Returns a reference to the \helpref{print data}{wxprintdata} associated with this object.
\membersection{wxPageSetupDialogData::SetDefaultInfo}\label{wxpagesetupdialogdatasetdefaultinfo}
\func{void}{SetDefaultInfo}{\param{bool}{ flag}}
Pass TRUE if the dialog will simply return default printer information (such as orientation)
instead of showing a dialog. Windows only.
\membersection{wxPageSetupDialogData::SetDefaultMinMargins}\label{wxpagesetupdialogdatasetdefaultminmargins}
\func{void}{SetDefaultMinMargins}{\param{bool}{ flag}}
Pass TRUE if the page setup dialog will take its minimum margin values from the currently
selected printer properties. Windows only.
\membersection{wxPageSetupData::SetDefaultInfo}\label{wxpagesetupdatasetdefaultinfo}
\membersection{wxPageSetupDialogData::SetMarginTopLeft}\label{wxpagesetupdialogdatasetmargintopleft}
\func{void}{SetDefaultInfo}{\param{bool}{ flag}}
\func{void}{GetMarginTopLeft}{\param{const wxPoint\& }{pt}}
Pass TRUE if the dialog will simply return default printer information (such as orientation)
instead of showing a dialog. Windows only.
Sets the left (x) and top (y) margins.
\membersection{wxPageSetupDialogData::SetMarginBottomRight}\label{wxpagesetupdialogdatasetmarginbottomright}
\func{void}{SetMarginBottomRight}{\param{const wxPoint\& }{pt}}
Sets the right (x) and bottom (y) margins.
\membersection{wxPageSetupDialogData::SetMinMarginTopLeft}\label{wxpagesetupdialogdatasetminmargintopleft}
\func{void}{SetMinMarginTopLeft}{\param{const wxPoint\& }{pt}}
Sets the left (x) and top (y) minimum margins the user can enter (Windows only).
\membersection{wxPageSetupDialogData::SetMinMarginBottomRight}\label{wxpagesetupdialogdatasetminmarginbottomright}
\func{void}{SetMinMarginBottomRight}{\param{const wxPoint\& }{pt}}
Sets the right (x) and bottom (y) minimum margins the user can enter (Windows only).
\membersection{wxPageSetupDialogData::SetPaperId}\label{wxpagesetupdialogdatasetpaperid}
\func{void}{SetPaperId}{\param{wxPaperSize\& }{id}}
Sets the paper size id. For further information, see \helpref{wxPrintData::SetPaperId}{wxprintdatasetpaperid}.
Calling this function overrides the explicit paper dimensions passed in \helpref{wxPageSetupDialogData::SetPaperSize}{wxpagesetupdialogdatasetpapersize}.
\membersection{wxPageSetupDialogData::SetPaperSize}\label{wxpagesetupdialogdatasetpapersize}
\func{void}{SetPaperSize}{\param{const wxSize\& }{size}}
Sets the paper size in millimetres. If a corresponding paper id is found, it will be set in the
internal wxPrintData object, otherwise the paper size overrides the paper id.
\membersection{wxPageSetupDialogData::SetPrintData}\label{wxpagesetupdialogdatasetprintdata}
\func{void}{SetPrintData}{\param{const wxPrintData\&}{ printData}}
Sets the \helpref{print data}{wxprintdata} associated with this object.
\membersection{wxPageSetupDialogData::operator $=$}\label{wxpagesetupdialogdataassign}
\func{void}{operator $=$}{\param{const wxPrintData\&}{ data}}
Assigns print data to this object.
\func{void}{operator $=$}{\param{const wxPageSetupDialogData\&}{ data}}
Assigns page setup data to this object.
\section{\class{wxPageSetupDialog}}\label{wxpagesetupdialog}
@ -197,8 +235,8 @@ native to the windowing system, otherwise it is emulated.
The page setup dialog contains controls for paper size (A4, A5 etc.), orientation (landscape
or portrait), and controls for setting left, top, right and bottom margin sizes in millimetres.
The page setup dialog does not set any global information (the exception being orientation
for PostScript printing) so you need to query the \helpref{wxPageSetupData}{wxpagesetupdata} object
When the dialog has been closed, you need to query the \helpref{wxPageSetupDialogData}{wxpagesetupdialogdata} object
associated with the dialog.
Note that the OK and Cancel buttons do not destroy the dialog; this must be done by the
@ -217,13 +255,13 @@ application.
\wxheading{See also}
\helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPageSetupData}{wxpagesetupdata}
\helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPageSetupDialogData}{wxpagesetupdialogdata}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxPageSetupDialog::wxPageSetupDialog}
\func{}{wxPageSetupDialog}{\param{wxWindow* }{parent}, \param{wxPageSetupData* }{data = NULL}}
\func{}{wxPageSetupDialog}{\param{wxWindow* }{parent}, \param{wxPageSetupDialogData* }{data = NULL}}
Constructor. Pass a parent window, and optionally a pointer to a block of page setup
data, which will be copied to the print dialog's internal data.
@ -236,9 +274,9 @@ Destructor.
\membersection{wxPageSetupDialog::GetPageSetupData}\label{wxpagesetupdialoggetpagesetupdata}
\func{wxPageSetupData\&}{GetPageSetupData}{\void}
\func{wxPageSetupDialogData\&}{GetPageSetupData}{\void}
Returns the \helpref{page setup data}{wxpagesetupdata} associated with the dialog.
Returns the \helpref{page setup data}{wxpagesetupdialogdata} associated with the dialog.
\membersection{wxPageSetupDialog::ShowModal}\label{wxpagesetupdialogshowmodal}

View File

@ -15,6 +15,10 @@ descriptions of the member functions.
\membersection{wxPostScriptDC::wxPostScriptDC}
\func{}{wxPostScriptDC}{\param{const wxPrintData\&}{ printData}}
Constructs a PostScript printer device context from a \helpref{wxPrintData}{wxprintdata} object.
\func{}{wxPostScriptDC}{\param{const wxString\& }{output}, \param{bool }{interactive = TRUE},\\
\param{wxWindow *}{parent}}
@ -28,6 +32,9 @@ in creating a useable device context.
See \helpref{Printer settings}{printersettings} for functions to set and
get PostScript printing settings.
This constructor and the global printer settings are now deprecated;
use the wxPrintData constructor instead.
\membersection{wxPostScriptDC::GetStream}
\func{ostream *}{GetStream}{\void}

View File

@ -1,6 +1,10 @@
\section{\class{wxPrintData}}\label{wxprintdata}
This class holds a variety of information related to print dialogs.
This class holds a variety of information related to printers and
printer device contexts. This class is used to create a wxPrinterDC
and a wxPostScriptDC. It is also used as a data member of wxPrintDialogData
and wxPageSetupDialogData, as part of the mechanism for transferring data
between the print dialogs and the application.
\wxheading{Derived from}
@ -12,7 +16,45 @@ This class holds a variety of information related to print dialogs.
\wxheading{See also}
\helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPrintDialog Overview}{wxprintdialogoverview}
\helpref{wxPrintDialog}{wxprintdialog},
\helpref{wxPageSetupDialog}{wxpagesetupdialog},
\helpref{wxPrintDialogData}{wxprintdialogdata},
\helpref{wxPageSetupDialogData}{wxpagesetupdialogdata},
\helpref{wxPrintDialog Overview}{wxprintdialogoverview},
\helpref{wxPrinterDC}{wxprinterdc},
\helpref{wxPostScriptDC}{wxpostscriptdc}
\wxheading{Remarks}
The following functions are specific to PostScript printing
and have not yet been documented:
\begin{verbatim}
const wxString& GetPrinterCommand() const ;
const wxString& GetPrinterOptions() const ;
const wxString& GetPreviewCommand() const ;
const wxString& GetFilename() const ;
const wxString& GetFontMetricPath() const ;
double GetPrinterScaleX() const ;
double GetPrinterScaleY() const ;
long GetPrinterTranslateX() const ;
long GetPrinterTranslateY() const ;
// wxPRINT_MODE_PREVIEW, wxPRINT_MODE_FILE, wxPRINT_MODE_PRINTER
wxPrintMode GetPrintMode() const ;
void SetPrinterCommand(const wxString& command) ;
void SetPrinterOptions(const wxString& options) ;
void SetPreviewCommand(const wxString& command) ;
void SetFilename(const wxString& filename) ;
void SetFontMetricPath(const wxString& path) ;
void SetPrinterScaleX(double x) ;
void SetPrinterScaleY(double y) ;
void SetPrinterScaling(double x, double y) ;
void SetPrinterTranslateX(long x) ;
void SetPrinterTranslateY(long y) ;
void SetPrinterTranslation(long x, long y) ;
void SetPrintMode(wxPrintMode printMode) ;
\end{verbatim}
\latexignore{\rtfignore{\wxheading{Members}}}
@ -20,7 +62,11 @@ This class holds a variety of information related to print dialogs.
\func{}{wxPrintData}{\void}
Constructor.
Default constructor.
\func{}{wxPrintData}{\param{const wxPrintData\&}{ data}}
Copy constructor.
\membersection{wxPrintData::\destruct{wxPrintData}}
@ -28,107 +74,83 @@ Constructor.
Destructor.
\membersection{wxPrintData::EnableHelp}\label{wxprintdataenablehelp}
\func{void}{EnableHelp}{\param{bool }{flag}}
Enables or disables the `Help' button.
\membersection{wxPrintData::EnablePageNumbers}\label{wxprintdataenablepagenumbers}
\func{void}{EnablePageNumbers}{\param{bool }{flag}}
Enables or disables the `Page numbers' controls.
\membersection{wxPrintData::EnablePrintToFile}\label{wxprintdataenableprinttofile}
\func{void}{EnablePrintToFile}{\param{bool }{flag}}
Enables or disables the `Print to file' checkbox.
\membersection{wxPrintData::EnableSelection}\label{wxprintdataenableselection}
\func{void}{EnableSelection}{\param{bool }{flag}}
Enables or disables the `Selection' radio button.
\membersection{wxPrintData::GetAllPages}\label{wxprintdatagetallpages}
\func{bool}{GetAllPages}{\void}
Returns TRUE if the user requested that all pages be printed.
\membersection{wxPrintData::GetCollate}\label{wxprintdatagetcollate}
\func{bool}{GetCollate}{\void}
\constfunc{bool}{GetCollate}{\void}
Returns TRUE if the user requested that the document(s) be collated.
Returns TRUE if collation is on.
\membersection{wxPrintData::GetFromPage}\label{wxprintdatagetfrompage}
\membersection{wxPrintData::GetColour}\label{wxprintdatagetcolour}
\func{int}{GetFromPage}{\void}
\constfunc{bool}{GetColour}{\void}
Returns the {\it from} page number, as entered by the user.
Returns TRUE if colour printing is on.
\membersection{wxPrintData::GetMaxPage}\label{wxprintdatagetmaxpage}
\membersection{wxPrintData::GetDuplex}\label{wxprintdatagetduplex}
\func{int}{GetMaxPage}{\void}
\constfunc{wxDuplexMode}{GetDuplex}{\void}
Returns the {\it maximum} page number.
\membersection{wxPrintData::GetMinPage}\label{wxprintdatagetminpage}
\func{int}{GetMinPage}{\void}
Returns the {\it minimum} page number.
Returns the duplex mode. One of wxDUPLEX\_SIMPLEX, wxDUPLEX\_HORIZONTAL, wxDUPLEX\_VERTICAL.
\membersection{wxPrintData::GetNoCopies}\label{wxprintdatagetnocopies}
\func{int}{GetNoCopies}{\void}
\constfunc{int}{GetNoCopies}{\void}
Returns the number of copies requested by the user.
\membersection{wxPrintData::GetOrientation}\label{wxprintdatagetorientation}
\func{int}{GetOrientation}{\void}
\constfunc{int}{GetOrientation}{\void}
Gets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
\membersection{wxPrintData::GetToPage}\label{wxprintdatagettopage}
\membersection{wxPrintData::GetPaperId}\label{wxprintdatagetpaperid}
\func{int}{GetToPage}{\void}
\constfunc{wxPaperSize}{GetPaperId}{\void}
Returns the {\it to} page number, as entered by the user.
Returns the paper size id. For more information, see \helpref{wxPrintData::SetPaperId}{wxprintdatasetpaperid}.
\membersection{wxPrintData::GetPrinterName}\label{wxprintdatagetprintername}
\constfunc{const wxString\&}{GetPrinterName}{\void}
Returns the printer name. If the printer name is the empty string, it indicates that the default
printer should be used.
\membersection{wxPrintData::GetQuality}\label{wxprintdatagetquality}
\constfunc{wxPaperQuality}{GetQuality}{\void}
Returns the current print quality. This can be a positive integer, denoting the number of dots per inch, or
one of the following identifiers:
\begin{verbatim}
wxPRINT\_QUALITY\_HIGH
wxPRINT\_QUALITY\_MEDIUM
wxPRINT\_QUALITY\_LOW
wxPRINT\_QUALITY\_DRAFT
\end{verbatim}
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::SetCollate}\label{wxprintdatasetcollate}
\func{void}{SetCollate}{\param{bool }{flag}}
Sets the 'Collate' checkbox to TRUE or FALSE.
Sets collation to on or off.
\membersection{wxPrintData::SetFromPage}\label{wxprintdatasetfrompage}
\membersection{wxPrintData::SetColour}\label{wxprintdatasetcolour}
\func{void}{SetFromPage}{\param{int }{page}}
\func{void}{SetColour}{\param{bool }{flag}}
Sets the {\it from} page number.
Sets colour printing on or off.
\membersection{wxPrintData::SetMaxPage}\label{wxprintdatasetmaxpage}
\membersection{wxPrintData::SetDuplex}\label{wxprintdatasetduplex}
\func{void}{SetMaxPage}{\param{int }{page}}
\func{void}{SetDuplex}{\param{wxDuplexMode}{ mode}}
Sets the {\it maximum} page number.
\membersection{wxPrintData::SetMinPage}\label{wxprintdatasetminpage}
\func{void}{SetMinPage}{\param{int }{page}}
Sets the {\it minimum} page number.
\membersection{wxPrintData::SetOrientation}\label{wxprintdatasetorientation}
\func{void}{SetOrientation}{\param{int }{orientation}}
Sets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
Returns the duplex mode. One of wxDUPLEX\_SIMPLEX, wxDUPLEX\_HORIZONTAL, wxDUPLEX\_VERTICAL.
\membersection{wxPrintData::SetNoCopies}\label{wxprintdatasetnocopies}
@ -136,27 +158,129 @@ Sets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
Sets the default number of copies to be printed out.
\membersection{wxPrintData::SetPrintToFile}\label{wxprintdatasetprinttofile}
\membersection{wxPrintData::SetOrientation}\label{wxprintdatasetorientation}
\func{void}{SetPrintToFile}{\param{bool }{flag}}
\func{void}{SetOrientation}{\param{int }{orientation}}
Sets the 'Print to file' checkbox to TRUE or FALSE.
Sets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
\membersection{wxPrintData::SetSetupDialog}\label{wxprintdatasetsetupdialog}
\membersection{wxPrintData::SetPaperId}\label{wxprintdatasetpaperid}
\func{void}{SetSetupDialog}{\param{bool }{flag}}
\func{void}{SetPaperId}{\param{wxPaperSize}{ paperId}}
Determines whether the dialog to be shown will be the Print dialog
(pass FALSE) or Print Setup dialog (pass TRUE).
\index{wxPaperSize}Sets the paper id. This indicates the type of paper to be used. For a mapping between
paper id, paper size and string name, see wxPrintPaperDatabase in {\tt paper.h} (not yet documented).
Note that the setup dialog is obsolete from
Windows 95, though retained for backward compatibility.
{\it paperId} can be one of:
\membersection{wxPrintData::SetToPage}\label{wxprintdatasettopage}
{\small
\begin{verbatim}
wxPAPER_NONE, // Use specific dimensions
wxPAPER_LETTER, // Letter, 8 1/2 by 11 inches
wxPAPER_LEGAL, // Legal, 8 1/2 by 14 inches
wxPAPER_A4, // A4 Sheet, 210 by 297 millimeters
wxPAPER_CSHEET, // C Sheet, 17 by 22 inches
wxPAPER_DSHEET, // D Sheet, 22 by 34 inches
wxPAPER_ESHEET, // E Sheet, 34 by 44 inches
wxPAPER_LETTERSMALL, // Letter Small, 8 1/2 by 11 inches
wxPAPER_TABLOID, // Tabloid, 11 by 17 inches
wxPAPER_LEDGER, // Ledger, 17 by 11 inches
wxPAPER_STATEMENT, // Statement, 5 1/2 by 8 1/2 inches
wxPAPER_EXECUTIVE, // Executive, 7 1/4 by 10 1/2 inches
wxPAPER_A3, // A3 sheet, 297 by 420 millimeters
wxPAPER_A4SMALL, // A4 small sheet, 210 by 297 millimeters
wxPAPER_A5, // A5 sheet, 148 by 210 millimeters
wxPAPER_B4, // B4 sheet, 250 by 354 millimeters
wxPAPER_B5, // B5 sheet, 182-by-257-millimeter paper
wxPAPER_FOLIO, // Folio, 8-1/2-by-13-inch paper
wxPAPER_QUARTO, // Quarto, 215-by-275-millimeter paper
wxPAPER_10X14, // 10-by-14-inch sheet
wxPAPER_11X17, // 11-by-17-inch sheet
wxPAPER_NOTE, // Note, 8 1/2 by 11 inches
wxPAPER_ENV_9, // #9 Envelope, 3 7/8 by 8 7/8 inches
wxPAPER_ENV_10, // #10 Envelope, 4 1/8 by 9 1/2 inches
wxPAPER_ENV_11, // #11 Envelope, 4 1/2 by 10 3/8 inches
wxPAPER_ENV_12, // #12 Envelope, 4 3/4 by 11 inches
wxPAPER_ENV_14, // #14 Envelope, 5 by 11 1/2 inches
wxPAPER_ENV_DL, // DL Envelope, 110 by 220 millimeters
wxPAPER_ENV_C5, // C5 Envelope, 162 by 229 millimeters
wxPAPER_ENV_C3, // C3 Envelope, 324 by 458 millimeters
wxPAPER_ENV_C4, // C4 Envelope, 229 by 324 millimeters
wxPAPER_ENV_C6, // C6 Envelope, 114 by 162 millimeters
wxPAPER_ENV_C65, // C65 Envelope, 114 by 229 millimeters
wxPAPER_ENV_B4, // B4 Envelope, 250 by 353 millimeters
wxPAPER_ENV_B5, // B5 Envelope, 176 by 250 millimeters
wxPAPER_ENV_B6, // B6 Envelope, 176 by 125 millimeters
wxPAPER_ENV_ITALY, // Italy Envelope, 110 by 230 millimeters
wxPAPER_ENV_MONARCH, // Monarch Envelope, 3 7/8 by 7 1/2 inches
wxPAPER_ENV_PERSONAL, // 6 3/4 Envelope, 3 5/8 by 6 1/2 inches
wxPAPER_FANFOLD_US, // US Std Fanfold, 14 7/8 by 11 inches
wxPAPER_FANFOLD_STD_GERMAN, // German Std Fanfold, 8 1/2 by 12 inches
wxPAPER_FANFOLD_LGL_GERMAN, // German Legal Fanfold, 8 1/2 by 13 inches
\func{void}{SetToPage}{\param{int }{page}}
Windows 95 only:
wxPAPER_ISO_B4, // B4 (ISO) 250 x 353 mm
wxPAPER_JAPANESE_POSTCARD, // Japanese Postcard 100 x 148 mm
wxPAPER_9X11, // 9 x 11 in
wxPAPER_10X11, // 10 x 11 in
wxPAPER_15X11, // 15 x 11 in
wxPAPER_ENV_INVITE, // Envelope Invite 220 x 220 mm
wxPAPER_LETTER_EXTRA, // Letter Extra 9 \275 x 12 in
wxPAPER_LEGAL_EXTRA, // Legal Extra 9 \275 x 15 in
wxPAPER_TABLOID_EXTRA, // Tabloid Extra 11.69 x 18 in
wxPAPER_A4_EXTRA, // A4 Extra 9.27 x 12.69 in
wxPAPER_LETTER_TRANSVERSE, // Letter Transverse 8 \275 x 11 in
wxPAPER_A4_TRANSVERSE, // A4 Transverse 210 x 297 mm
wxPAPER_LETTER_EXTRA_TRANSVERSE, // Letter Extra Transverse 9\275 x 12 in
wxPAPER_A_PLUS, // SuperA/SuperA/A4 227 x 356 mm
wxPAPER_B_PLUS, // SuperB/SuperB/A3 305 x 487 mm
wxPAPER_LETTER_PLUS, // Letter Plus 8.5 x 12.69 in
wxPAPER_A4_PLUS, // A4 Plus 210 x 330 mm
wxPAPER_A5_TRANSVERSE, // A5 Transverse 148 x 210 mm
wxPAPER_B5_TRANSVERSE, // B5 (JIS) Transverse 182 x 257 mm
wxPAPER_A3_EXTRA, // A3 Extra 322 x 445 mm
wxPAPER_A5_EXTRA, // A5 Extra 174 x 235 mm
wxPAPER_B5_EXTRA, // B5 (ISO) Extra 201 x 276 mm
wxPAPER_A2, // A2 420 x 594 mm
wxPAPER_A3_TRANSVERSE, // A3 Transverse 297 x 420 mm
wxPAPER_A3_EXTRA_TRANSVERSE // A3 Extra Transverse 322 x 445 mm
\end{verbatim}
}
Sets the {\it to} page number.
\membersection{wxPrintData::SetPrinterName}\label{wxprintdatasetprintername}
\func{void}{SetPrinterName}{\param{const wxString\& }{printerName}}
Sets the printer name. This can be the empty string to indicate that the default
printer should be used.
\membersection{wxPrintData::SetQuality}\label{wxprintdatasetquality}
\func{void}{SetQuality}{\param{wxPaperQuality}{ quality}}
Sets the desired print quality. This can be a positive integer, denoting the number of dots per inch, or
one of the following identifiers:
\begin{verbatim}
wxPRINT\_QUALITY\_HIGH
wxPRINT\_QUALITY\_MEDIUM
wxPRINT\_QUALITY\_LOW
wxPRINT\_QUALITY\_DRAFT
\end{verbatim}
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::operator $=$}\label{wxprintdataassign}
\func{void}{operator $=$}{\param{const wxPrintData\&}{ data}}
Assigns print data to this object.
\func{void}{operator $=$}{\param{const wxPrintSetupData\&}{ data}}
Assigns print setup data to this object. wxPrintSetupData is deprecated,
but retained for backward compatibility.
\section{\class{wxPrintDialog}}\label{wxprintdialog}
@ -183,14 +307,14 @@ a successfully dismissed print dialog.
\membersection{wxPrintDialog::wxPrintDialog}
\func{}{wxPrintDialog}{\param{wxWindow* }{parent}, \param{wxPrintData* }{data = NULL}}
\func{}{wxPrintDialog}{\param{wxWindow* }{parent}, \param{wxPrintDialogData* }{data = NULL}}
Constructor. Pass a parent window, and optionally a pointer to a block of print
data, which will be copied to the print dialog's print data.
\wxheading{See also}
\helpref{wxPrintData}{wxprintdata}
\helpref{wxPrintDialogData}{wxprintdialogdata}
\membersection{wxPrintDialog::\destruct{wxPrintDialog}}
@ -199,11 +323,11 @@ data, which will be copied to the print dialog's print data.
Destructor. If wxPrintDialog::GetPrintDC has {\it not} been called,
the device context obtained by the dialog (if any) will be deleted.
\membersection{wxPrintDialog::GetPrintData}\label{wxprintdialoggetprintdata}
\membersection{wxPrintDialog::GetPrintDialogData}\label{wxprintdialoggetprintdialogdata}
\func{wxPrintData\&}{GetPrintData}{\void}
\func{wxPrintDialogData\&}{GetPrintDialogData}{\void}
Returns the \helpref{print data}{wxprintdata} associated with the print dialog.
Returns the \helpref{print dialog data}{wxprintdialogdata} associated with the print dialog.
\membersection{wxPrintDialog::GetPrintDC}\label{wxprintdialoggetprintdc}
@ -222,6 +346,191 @@ Shows the dialog, returning wxID\_OK if the user pressed OK, and wxID\_CANCEL
otherwise. After this function is called, a device context may
be retrievable using \helpref{wxPrintDialog::GetPrintDC}{wxprintdialoggetprintdc}.
\section{\class{wxPrintDialogData}}\label{wxprintdialogdata}
This class holds information related to the visual characteristics of wxPrintDialog.
It contains a wxPrintData object with underlying printing settings.
\wxheading{Derived from}
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/cmndata.h>
\wxheading{See also}
\helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPrintDialog Overview}{wxprintdialogoverview}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxPrintDialogData::wxPrintDialogData}
\func{}{wxPrintDialogData}{\void}
Default constructor.
\func{}{wxPrintDialogData}{\param{wxPrintDialogData\&}{ dialogData}}
Copy constructor.
\func{}{wxPrintDialogData}{\param{wxPrintData\&}{ printData}}
Construct an object from a print dialog data object.
\membersection{wxPrintDialogData::\destruct{wxprintdialogdata}}
\func{}{\destruct{wxPrintDialogData}}{\void}
Destructor.
\membersection{wxPrintDialogData::EnableHelp}\label{wxprintdialogdataenablehelp}
\func{void}{EnableHelp}{\param{bool }{flag}}
Enables or disables the `Help' button.
\membersection{wxPrintDialogData::EnablePageNumbers}\label{wxprintdialogdataenablepagenumbers}
\func{void}{EnablePageNumbers}{\param{bool }{flag}}
Enables or disables the `Page numbers' controls.
\membersection{wxPrintDialogData::EnablePrintToFile}\label{wxprintdialogdataenableprinttofile}
\func{void}{EnablePrintToFile}{\param{bool }{flag}}
Enables or disables the `Print to file' checkbox.
\membersection{wxPrintDialogData::EnableSelection}\label{wxprintdialogdataenableselection}
\func{void}{EnableSelection}{\param{bool }{flag}}
Enables or disables the `Selection' radio button.
\membersection{wxPrintDialogData::GetAllPages}\label{wxprintdialogdatagetallpages}
\constfunc{bool}{GetAllPages}{\void}
Returns TRUE if the user requested that all pages be printed.
\membersection{wxPrintDialogData::GetCollate}\label{wxprintdialogdatagetcollate}
\constfunc{bool}{GetCollate}{\void}
Returns TRUE if the user requested that the document(s) be collated.
\membersection{wxPrintDialogData::GetFromPage}\label{wxprintdialogdatagetfrompage}
\constfunc{int}{GetFromPage}{\void}
Returns the {\it from} page number, as entered by the user.
\membersection{wxPrintDialogData::GetMaxPage}\label{wxprintdialogdatagetmaxpage}
\constfunc{int}{GetMaxPage}{\void}
Returns the {\it maximum} page number.
\membersection{wxPrintDialogData::GetMinPage}\label{wxprintdialogdatagetminpage}
\constfunc{int}{GetMinPage}{\void}
Returns the {\it minimum} page number.
\membersection{wxPrintDialogData::GetNoCopies}\label{wxprintdialogdatagetnocopies}
\constfunc{int}{GetNoCopies}{\void}
Returns the number of copies requested by the user.
\membersection{wxPrintDialogData::GetPrintData}\label{wxprintdialogdatagetprintdata}
\func{wxPrintData\&}{GetPrintData}{\void}
Returns a reference to the internal wxPrintData object.
\membersection{wxPrintDialogData::GetPrintToFile}\label{wxprintdialogdatagetprinttofile}
\constfunc{bool}{GetPrintToFile}{\void}
Returns TRUE if the user has selected printing to a file.
\membersection{wxPrintDialogData::GetToPage}\label{wxprintdialogdatagettopage}
\constfunc{int}{GetToPage}{\void}
Returns the {\it to} page number, as entered by the user.
\membersection{wxPrintDialogData::SetCollate}\label{wxprintdialogdatasetcollate}
\func{void}{SetCollate}{\param{bool }{flag}}
Sets the 'Collate' checkbox to TRUE or FALSE.
\membersection{wxPrintDialogData::SetFromPage}\label{wxprintdialogdatasetfrompage}
\func{void}{SetFromPage}{\param{int }{page}}
Sets the {\it from} page number.
\membersection{wxPrintDialogData::SetMaxPage}\label{wxprintdialogdatasetmaxpage}
\func{void}{SetMaxPage}{\param{int }{page}}
Sets the {\it maximum} page number.
\membersection{wxPrintDialogData::SetMinPage}\label{wxprintdialogdatasetminpage}
\func{void}{SetMinPage}{\param{int }{page}}
Sets the {\it minimum} page number.
\membersection{wxPrintDialogData::SetNoCopies}\label{wxprintdialogdatasetnocopies}
\func{void}{SetNoCopies}{\param{int }{n}}
Sets the default number of copies the user has requested to be printed out.
\membersection{wxPrintDialogData::SetPrintData}\label{wxprintdialogdatasetprintdata}
\func{void}{SetPrintData}{\param{const wxPrintData\& }{printData}}
Sets the internal wxPrintData.
\membersection{wxPrintDialogData::SetPrintToFile}\label{wxprintdialogdatasetprinttofile}
\func{void}{SetPrintToFile}{\param{bool }{flag}}
Sets the 'Print to file' checkbox to TRUE or FALSE.
\membersection{wxPrintDialogData::SetSetupDialog}\label{wxprintdialogdatasetsetupdialog}
\func{void}{SetSetupDialog}{\param{bool }{flag}}
Determines whether the dialog to be shown will be the Print dialog
(pass FALSE) or Print Setup dialog (pass TRUE).
Note that the setup dialog is (according to Microsoft) obsolete from
Windows 95, though retained for backward compatibility.
\membersection{wxPrintDialogData::SetToPage}\label{wxprintdialogdatasettopage}
\func{void}{SetToPage}{\param{int }{page}}
Sets the {\it to} page number.
\membersection{wxPrintDialogData::operator $=$}\label{wxprintdialogdataassign}
\func{void}{operator $=$}{\param{const wxPrintData\&}{ data}}
Assigns print data to this object.
\func{void}{operator $=$}{\param{const wxPrintDialogData\&}{ data}}
Assigns another print dialog data object to this object.
\section{\class{wxPrinter}}\label{wxprinter}
This class represents the Windows or PostScript printer, and is the vehicle through
@ -247,13 +556,14 @@ method of printing.
\membersection{wxPrinter::wxPrinter}
\func{}{wxPrinter}{\param{wxPrintData* }{data = NULL}}
\func{}{wxPrinter}{\param{wxPrintDialogData* }{data = NULL}}
Constructor. Pass an optional pointer to a block of print
data, which will be copied to the printer object's print data.
dialog data, which will be copied to the printer object's local data.
\wxheading{See also}
\helpref{wxPrintDialogData}{wxprintdialogdata},
\helpref{wxPrintData}{wxprintdata}
\membersection{wxPrinter::\destruct{wxPrinter}}
@ -274,9 +584,9 @@ Returns TRUE if the user has aborted the print job.
Creates the default printing abort window, with a cancel button.
\membersection{wxPrinter::GetPrintData}\label{wxprintergetprintdata}
\membersection{wxPrinter::GetPrintDialogData}\label{wxprintergetprintdialogdata}
\func{wxPrintData\&}{GetPrintData}{\void}
\func{wxPrintDialogData\&}{GetPrintDialogData}{\void}
Returns the \helpref{print data}{wxprintdata} associated with the printer object.
@ -292,9 +602,13 @@ Print could return FALSE if there was a problem initializing the printer device
\membersection{wxPrinter::PrintDialog}\label{wxprinterprintdialog}
\func{bool}{PrintDialog}{\param{wxWindow *}{parent}}
\func{wxDC*}{PrintDialog}{\param{wxWindow *}{parent}}
Invokes the print dialog.
Invokes the print dialog. If successful (the user did not press Cancel
and no error occurred), a suitable device context will be returned
(otherwise NULL is returned).
The application must delete this device context to avoid a memory leak.
\membersection{wxPrinter::ReportError}\label{wxprinterreporterror}
@ -304,7 +618,7 @@ Default error-reporting function.
\membersection{wxPrinter::Setup}\label{wxprintersetup}
\func{void}{Setup}{\param{wxWindow *}{parent}}
\func{bool}{Setup}{\param{wxWindow *}{parent}}
Invokes the print setup dialog. Note that the setup dialog is obsolete from
Windows 95, though retained for backward compatibility.
@ -333,6 +647,12 @@ achieving the correct scaling for the page.
\membersection{wxPrinterDC::wxPrinterDC}
\func{}{wxPrinterDC}{\param{const wxPrintData\& }{printData}}
Pass a \helpref{wxPrintData}{wxprintdata} object with information
necessary for setting up a suitable printer device context. This
is the recommended way to construct a wxPrinterDC.
\func{}{wxPrinterDC}{\param{const wxString\& }{driver}, \param{const wxString\& }{device}, \param{const wxString\& }{output},
\param{const bool }{interactive = TRUE}, \param{int }{orientation = wxPORTRAIT}}
@ -342,6 +662,8 @@ is an optional file for printing to. The {\it driver} parameter is
currently unused. Use the {\it Ok} member to test whether the
constructor was successful in creating a useable device context.
This constructor is deprecated and retained only for backward compatibility.
\section{\class{wxPrintout}}\label{wxprintout}
This class encapsulates the functionality of printing out an
@ -671,4 +993,3 @@ Associates a printout object with the wxPrintPreview object.
Sets the percentage preview zoom, and refreshes the preview canvas
accordingly.

View File

@ -1,8 +1,14 @@
\section{Printing overview}\label{printingoverview}
Classes: \helpref{wxPrintout}{wxprintout}, \helpref{wxPrinter}{wxprinter},\rtfsp
\helpref{wxPrintPreview}{wxprintpreview}, \helpref{wxPrinterDC}{wxprinterdc},\rtfsp
\helpref{wxPrintDialog}{wxprintdialog}.
Classes: \helpref{wxPrintout}{wxprintout},
\helpref{wxPrinter}{wxprinter},
\helpref{wxPrintPreview}{wxprintpreview},
\helpref{wxPrinterDC}{wxprinterdc},
\helpref{wxPrintDialog}{wxprintdialog},
\helpref{wxPrintData}{wxprintdata},
\helpref{wxPrintDialogData}{wxprintdialogdata},
\helpref{wxPageSetupDialog}{wxpagesetupdialog},
\helpref{wxPageSetupDialogData}{wxpagesetupdialogdata}
The printing framework relies on the application to provide classes
whose member functions can respond to particular requests, such
@ -11,8 +17,6 @@ This method allows wxWindows to take over the housekeeping duties of
turning preview pages, calling the print dialog box, creating
the printer device context, and so on: the application can concentrate
on the rendering of the information onto a device context.
The printing framework is mainly a Windows feature; PostScript
support under non-Windows platforms is emerging but has not been rigorously tested.
The \helpref{document/view framework}{docviewoverview} creates a default wxPrintout
object for every view, calling wxView::OnDraw to achieve a

View File

@ -438,7 +438,7 @@ as possible to the C++ spec over time.
\item \helpref{wxMoveEvent}{wxmoveevent}
\item \helpref{wxNotebookEvent}{wxnotebookevent}
\item \helpref{wxNotebook}{wxnotebook}
\item \helpref{wxPageSetupData}{wxpagesetupdata}
\item \helpref{wxPageSetupDialogData}{wxpagesetupdialogdata}
\item \helpref{wxPageSetupDialog}{wxpagesetupdialog}
\item \helpref{wxPaintDC}{wxpaintdc}
\item \helpref{wxPaintEvent}{wxpaintevent}

View File

@ -19,208 +19,363 @@
#include "wx/font.h"
#include "wx/colour.h"
#if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT
class WXDLLEXPORT wxPrintSetupData;
#endif
class WXDLLEXPORT wxColourData: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxColourData)
public:
wxColour dataColour;
wxColour custColours[16];
bool chooseFull;
DECLARE_DYNAMIC_CLASS(wxColourData)
public:
wxColourData();
wxColourData(const wxColourData& data);
~wxColourData();
inline void SetChooseFull(bool flag) { chooseFull = flag; }
inline bool GetChooseFull() const { return chooseFull; }
inline void SetColour(wxColour& colour) { dataColour = colour; }
inline wxColour &GetColour() { return dataColour; }
wxColourData(void);
~wxColourData(void);
// Array of 16 custom colours
void SetCustomColour(int i, wxColour& colour);
wxColour GetCustomColour(int i);
void operator=(const wxColourData& data);
inline void SetChooseFull(bool flag) { chooseFull = flag; }
inline bool GetChooseFull(void) { return chooseFull; }
inline void SetColour(wxColour& colour) { dataColour = colour; }
inline wxColour &GetColour(void) { return dataColour; }
// Array of 16 custom colours
void SetCustomColour(int i, wxColour& colour);
wxColour GetCustomColour(int i);
void operator=(const wxColourData& data);
public:
wxColour dataColour;
wxColour custColours[16];
bool chooseFull;
};
class WXDLLEXPORT wxFontData: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxFontData)
public:
wxColour fontColour;
bool showHelp;
bool allowSymbols;
bool enableEffects;
wxFont initialFont;
wxFont chosenFont;
int minSize;
int maxSize;
DECLARE_DYNAMIC_CLASS(wxFontData)
public:
wxFontData();
wxFontData(const wxFontData& fontData);
~wxFontData();
wxFontData(void);
~wxFontData(void);
inline void SetAllowSymbols(bool flag) { allowSymbols = flag; }
inline bool GetAllowSymbols() const { return allowSymbols; }
inline void SetAllowSymbols(bool flag) { allowSymbols = flag; }
inline bool GetAllowSymbols(void) { return allowSymbols; }
inline void SetColour(const wxColour& colour) { fontColour = colour; }
inline wxColour &GetColour(void) { return fontColour; }
inline void SetShowHelp(bool flag) { showHelp = flag; }
inline bool GetShowHelp(void) { return showHelp; }
inline void EnableEffects(bool flag) { enableEffects = flag; }
inline bool GetEnableEffects(void) { return enableEffects; }
inline void SetInitialFont(const wxFont& font) { initialFont = font; }
inline wxFont GetInitialFont(void) { return initialFont; }
inline void SetChosenFont(const wxFont& font) { chosenFont = font; }
inline wxFont GetChosenFont(void) { return chosenFont; }
inline void SetRange(int minRange, int maxRange) { minSize = minRange; maxSize = maxRange; }
inline void SetColour(const wxColour& colour) { fontColour = colour; }
inline wxColour &GetColour() { return fontColour; }
void operator=(const wxFontData& data);
inline void SetShowHelp(bool flag) { showHelp = flag; }
inline bool GetShowHelp() const { return showHelp; }
inline void EnableEffects(bool flag) { enableEffects = flag; }
inline bool GetEnableEffects() const { return enableEffects; }
inline void SetInitialFont(const wxFont& font) { initialFont = font; }
inline wxFont GetInitialFont() const { return initialFont; }
inline void SetChosenFont(const wxFont& font) { chosenFont = font; }
inline wxFont GetChosenFont() const { return chosenFont; }
inline void SetRange(int minRange, int maxRange) { minSize = minRange; maxSize = maxRange; }
void operator=(const wxFontData& data);
public:
wxColour fontColour;
bool showHelp;
bool allowSymbols;
bool enableEffects;
wxFont initialFont;
wxFont chosenFont;
int minSize;
int maxSize;
};
/*
* wxPrintData
* Encapsulates information displayed and edited in the printer dialog box.
* Encapsulates printer information (not printer dialog information)
*/
class WXDLLEXPORT wxPrintData: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxPrintData)
DECLARE_DYNAMIC_CLASS(wxPrintData)
wxPrintData();
wxPrintData(const wxPrintData& printData);
~wxPrintData();
inline int GetNoCopies() const { return m_printNoCopies; };
inline bool GetCollate() const { return m_printCollate; };
inline int GetOrientation() const { return m_printOrientation; };
public:
#ifdef __WXMSW__
void *printData;
inline const wxString& GetPrinterName() const { return m_printerName; }
inline bool GetColour() const { return m_colour; }
inline wxDuplexMode GetDuplex() const { return m_duplexMode; }
inline wxPaperSize GetPaperId() const { return m_paperId; }
inline const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
// in wxPageSetupDialogData
inline wxPrintQuality GetQuality() const { return m_printQuality; }
inline void SetNoCopies(int v) { m_printNoCopies = v; };
inline void SetCollate(bool flag) { m_printCollate = flag; };
inline void SetOrientation(int orient) { m_printOrientation = orient; };
inline void SetPrinterName(const wxString& name) { m_printerName = name; }
inline void SetColour(bool colour) { m_colour = colour; }
inline void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
inline void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
inline void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
inline void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
// PostScript-specific data
inline const wxString& GetPrinterCommand() const { return m_printerCommand; }
inline const wxString& GetPrinterOptions() const { return m_printerOptions; }
inline const wxString& GetPreviewCommand() const { return m_previewCommand; }
inline const wxString& GetFilename() const { return m_filename; }
inline const wxString& GetFontMetricPath() const { return m_afmPath; }
inline double GetPrinterScaleX() const { return m_printerScaleX; }
inline double GetPrinterScaleY() const { return m_printerScaleY; }
inline long GetPrinterTranslateX() const { return m_printerTranslateX; }
inline long GetPrinterTranslateY() const { return m_printerTranslateY; }
inline wxPrintMode GetPrintMode() const { return m_printMode; }
inline void SetPrinterCommand(const wxString& command) { m_printerCommand = command; }
inline void SetPrinterOptions(const wxString& options) { m_printerOptions = options; }
inline void SetPreviewCommand(const wxString& command) { m_previewCommand = command; }
inline void SetFilename(const wxString& filename) { m_filename = filename; }
inline void SetFontMetricPath(const wxString& path) { m_afmPath = path; }
inline void SetPrinterScaleX(double x) { m_printerScaleX = x; }
inline void SetPrinterScaleY(double y) { m_printerScaleY = y; }
inline void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; }
inline void SetPrinterTranslateX(long x) { m_printerTranslateX = x; }
inline void SetPrinterTranslateY(long y) { m_printerTranslateY = y; }
inline void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; }
inline void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
void operator=(const wxPrintData& data);
// For compatibility
#if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT
void operator=(const wxPrintSetupData& setupData);
#endif
int printFromPage;
int printToPage;
int printMinPage;
int printMaxPage;
int printNoCopies;
int printOrientation;
bool printAllPages;
bool printCollate;
bool printToFile;
bool printEnableSelection;
bool printEnablePageNumbers;
bool printEnableHelp;
bool printEnablePrintToFile;
bool printSetupDialog;
wxPrintData(void);
~wxPrintData(void);
inline int GetFromPage(void) { return printFromPage; };
inline int GetToPage(void) { return printToPage; };
inline int GetMinPage(void) { return printMinPage; };
inline int GetMaxPage(void) { return printMaxPage; };
inline int GetNoCopies(void) { return printNoCopies; };
inline bool GetAllPages(void) { return printAllPages; };
inline bool GetCollate(void) { return printCollate; };
inline bool GetPrintToFile(void) { return printToFile; };
inline bool GetSetupDialog(void) { return printSetupDialog; };
inline int GetOrientation(void) { return printOrientation; };
inline void SetFromPage(int v) { printFromPage = v; };
inline void SetToPage(int v) { printToPage = v; };
inline void SetMinPage(int v) { printMinPage = v; };
inline void SetMaxPage(int v) { printMaxPage = v; };
inline void SetNoCopies(int v) { printNoCopies = v; };
inline void SetAllPages(bool flag) { printAllPages = flag; };
inline void SetCollate(bool flag) { printCollate = flag; };
inline void SetPrintToFile(bool flag) { printToFile = flag; };
inline void SetSetupDialog(bool flag) { printSetupDialog = flag; };
inline void SetOrientation(int orient) { printOrientation = orient; };
inline void EnablePrintToFile(bool flag) { printEnablePrintToFile = flag; };
inline void EnableSelection(bool flag) { printEnableSelection = flag; };
inline void EnablePageNumbers(bool flag) { printEnablePageNumbers = flag; };
inline void EnableHelp(bool flag) { printEnableHelp = flag; };
inline bool GetEnablePrintToFile(void) { return printEnablePrintToFile; };
inline bool GetEnableSelection(void) { return printEnableSelection; };
inline bool GetEnablePageNumbers(void) { return printEnablePageNumbers; };
inline bool GetEnableHelp(void) { return printEnableHelp; };
void operator=(const wxPrintData& data);
#ifdef __WXMSW__
// Convert to/from the PRINTDLG structure
void ConvertToNative(void);
void ConvertFromNative(void);
void SetOwnerWindow(wxWindow* win);
inline void* GetNativeData(void) { return printData; }
// Convert to/from the DEVMODE structure
void ConvertToNative();
void ConvertFromNative();
inline void* GetNativeData() const { return m_devMode; }
inline void SetNativeData(void* data) { m_devMode = data; }
#endif
public:
#ifdef __WXMSW__
void* m_devMode;
#endif
private:
int m_printNoCopies;
int m_printOrientation;
bool m_printCollate;
// New members, 24/3/99
wxString m_printerName;
bool m_colour;
wxDuplexMode m_duplexMode;
wxPrintQuality m_printQuality;
wxPaperSize m_paperId;
wxSize m_paperSize;
// PostScript-specific data
wxString m_printerCommand;
wxString m_previewCommand;
wxString m_printerOptions;
wxString m_filename;
wxString m_afmPath;
double m_printerScaleX;
double m_printerScaleY;
long m_printerTranslateX;
long m_printerTranslateY;
wxPrintMode m_printMode;
};
/*
* This is the data used (and returned) by the wxPageSetupDialog.
* wxPrintDialogData
* Encapsulates information displayed and edited in the printer dialog box.
* Contains a wxPrintData object which is filled in according to the values retrieved
* from the dialog.
*/
class WXDLLEXPORT wxPageSetupData: public wxObject
class WXDLLEXPORT wxPrintDialogData: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxPageSetupData)
DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
wxPrintDialogData();
wxPrintDialogData(const wxPrintDialogData& dialogData);
wxPrintDialogData(const wxPrintData& printData);
~wxPrintDialogData();
inline int GetFromPage() const { return m_printFromPage; };
inline int GetToPage() const { return m_printToPage; };
inline int GetMinPage() const { return m_printMinPage; };
inline int GetMaxPage() const { return m_printMaxPage; };
inline int GetNoCopies() const { return m_printNoCopies; };
inline bool GetAllPages() const { return m_printAllPages; };
inline bool GetCollate() const { return m_printCollate; };
inline bool GetPrintToFile() const { return m_printToFile; };
inline bool GetSetupDialog() const { return m_printSetupDialog; };
public:
#if defined(__WIN95__)
void* m_pageSetupData;
inline void SetFromPage(int v) { m_printFromPage = v; };
inline void SetToPage(int v) { m_printToPage = v; };
inline void SetMinPage(int v) { m_printMinPage = v; };
inline void SetMaxPage(int v) { m_printMaxPage = v; };
inline void SetNoCopies(int v) { m_printNoCopies = v; };
inline void SetAllPages(bool flag) { m_printAllPages = flag; };
inline void SetCollate(bool flag) { m_printCollate = flag; };
inline void SetPrintToFile(bool flag) { m_printToFile = flag; };
inline void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
inline void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; };
inline void EnableSelection(bool flag) { m_printEnableSelection = flag; };
inline void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; };
inline void EnableHelp(bool flag) { m_printEnableHelp = flag; };
inline bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; };
inline bool GetEnableSelection() const { return m_printEnableSelection; };
inline bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
inline bool GetEnableHelp() const { return m_printEnableHelp; };
inline wxPrintData& GetPrintData() { return m_printData; }
inline void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
void operator=(const wxPrintDialogData& data);
void operator=(const wxPrintData& data); // Sets internal m_printData member
#ifdef __WXMSW__
// Convert to/from the PRINTDLG structure
void ConvertToNative();
void ConvertFromNative();
void SetOwnerWindow(wxWindow* win);
inline void* GetNativeData() const { return m_printDlgData; }
#endif
wxPoint m_paperSize;
wxPoint m_minMarginTopLeft;
wxPoint m_minMarginBottomRight;
wxPoint m_marginTopLeft;
wxPoint m_marginBottomRight;
int m_orientation;
// Flags
bool m_defaultMinMargins;
bool m_enableMargins;
bool m_enableOrientation;
bool m_enablePaper;
bool m_enablePrinter;
bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
bool m_enableHelp;
wxPageSetupData(void);
~wxPageSetupData(void);
inline wxPoint GetPaperSize(void) { return m_paperSize; };
inline wxPoint GetMinMarginTopLeft(void) { return m_minMarginTopLeft; };
inline wxPoint GetMinMarginBottomRight(void) { return m_minMarginBottomRight; };
inline wxPoint GetMarginTopLeft(void) { return m_marginTopLeft; };
inline wxPoint GetMarginBottomRight(void) { return m_marginBottomRight; };
inline int GetOrientation(void) { return m_orientation; };
inline bool GetDefaultMinMargins(void) { return m_defaultMinMargins; };
inline bool GetEnableMargins(void) { return m_enableMargins; };
inline bool GetEnableOrientation(void) { return m_enableOrientation; };
inline bool GetEnablePaper(void) { return m_enablePaper; };
inline bool GetEnablePrinter(void) { return m_enablePrinter; };
inline bool GetDefaultInfo(void) { return m_getDefaultInfo; };
inline bool GetEnableHelp(void) { return m_enableHelp; };
inline void SetPaperSize(const wxPoint& pt) { m_paperSize = pt; };
inline void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; };
inline void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; };
inline void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; };
inline void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; };
inline void SetOrientation(int orient) { m_orientation = orient; };
inline void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; };
inline void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; };
inline void EnableMargins(bool flag) { m_enableMargins = flag; };
inline void EnableOrientation(bool flag) { m_enableOrientation = flag; };
inline void EnablePaper(bool flag) { m_enablePaper = flag; };
inline void EnablePrinter(bool flag) { m_enablePrinter = flag; };
inline void EnableHelp(bool flag) { m_enableHelp = flag; };
#if defined(__WIN95__)
// Convert to/from the PAGESETUPDLG structure
void ConvertToNative(void);
void ConvertFromNative(void);
void SetOwnerWindow(wxWindow* win);
inline void* GetNativeData(void) { return m_pageSetupData; }
#ifdef __WXMSW__
void* m_printDlgData;
#endif
void operator=(const wxPageSetupData& data);
private:
int m_printFromPage;
int m_printToPage;
int m_printMinPage;
int m_printMaxPage;
int m_printNoCopies;
bool m_printAllPages;
bool m_printCollate;
bool m_printToFile;
bool m_printEnableSelection;
bool m_printEnablePageNumbers;
bool m_printEnableHelp;
bool m_printEnablePrintToFile;
bool m_printSetupDialog;
wxPrintData m_printData;
};
/*
* This is the data used (and returned) by the wxPageSetupDialog.
*/
// Compatibility with old name
#define wxPageSetupData wxPageSetupDialogData
class WXDLLEXPORT wxPageSetupDialogData: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
public:
wxPageSetupDialogData();
wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
wxPageSetupDialogData(const wxPrintData& printData);
~wxPageSetupDialogData();
inline wxSize GetPaperSize() const { return m_paperSize; };
inline wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); };
inline wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; };
inline wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; };
inline wxPoint GetMarginTopLeft() const { return m_marginTopLeft; };
inline wxPoint GetMarginBottomRight() const { return m_marginBottomRight; };
inline bool GetDefaultMinMargins() const { return m_defaultMinMargins; };
inline bool GetEnableMargins() const { return m_enableMargins; };
inline bool GetEnableOrientation() const { return m_enableOrientation; };
inline bool GetEnablePaper() const { return m_enablePaper; };
inline bool GetEnablePrinter() const { return m_enablePrinter; };
inline bool GetDefaultInfo() const { return m_getDefaultInfo; };
inline bool GetEnableHelp() const { return m_enableHelp; };
// 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);
// Sets the wxPrintData id, plus the paper width/height if found in the paper database.
void SetPaperSize(wxPaperSize id);
inline void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; };
inline void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; };
inline void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; };
inline void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; };
inline void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; };
inline void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; };
inline void EnableMargins(bool flag) { m_enableMargins = flag; };
inline void EnableOrientation(bool flag) { m_enableOrientation = flag; };
inline void EnablePaper(bool flag) { m_enablePaper = flag; };
inline void EnablePrinter(bool flag) { m_enablePrinter = flag; };
inline void EnableHelp(bool flag) { m_enableHelp = flag; };
#if defined(__WIN95__)
// Convert to/from the PAGESETUPDLG structure
void ConvertToNative();
void ConvertFromNative();
void SetOwnerWindow(wxWindow* win);
inline void* GetNativeData() const { return m_pageSetupData; }
#endif
// Use paper size defined in this object to set the wxPrintData
// paper id
void CalculateIdFromPaperSize();
// Use paper id in wxPrintData to set this object's paper size
void CalculatePaperSizeFromId();
void operator=(const wxPageSetupData& data);
void operator=(const wxPrintData& data);
inline wxPrintData& GetPrintData() { return m_printData; }
inline void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
#if defined(__WIN95__)
void* m_pageSetupData;
#endif
private:
wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
wxPoint m_minMarginTopLeft;
wxPoint m_minMarginBottomRight;
wxPoint m_marginTopLeft;
wxPoint m_marginBottomRight;
// Flags
bool m_defaultMinMargins;
bool m_enableMargins;
bool m_enableOrientation;
bool m_enablePaper;
bool m_enablePrinter;
bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
bool m_enableHelp;
wxPrintData m_printData;
};
#endif
// _WX_CMNDATA_H_BASE_
// _WX_CMNDATA_H_BASE_

View File

@ -868,12 +868,6 @@ enum
wxWIN386 // Watcom 32-bit supervisor modus
};
/* Printing */
#ifndef wxPORTRAIT
#define wxPORTRAIT 1
#define wxLANDSCAPE 2
#endif
/* Standard menu identifiers */
#define wxID_LOWEST 4999
@ -939,6 +933,115 @@ enum
/* Shortcut for easier dialog-unit-to-pixel conversion */
#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
/* Paper types */
typedef enum {
wxPAPER_NONE, // Use specific dimensions
wxPAPER_LETTER, // Letter, 8 1/2 by 11 inches
wxPAPER_LEGAL, // Legal, 8 1/2 by 14 inches
wxPAPER_A4, // A4 Sheet, 210 by 297 millimeters
wxPAPER_CSHEET, // C Sheet, 17 by 22 inches
wxPAPER_DSHEET, // D Sheet, 22 by 34 inches
wxPAPER_ESHEET, // E Sheet, 34 by 44 inches
wxPAPER_LETTERSMALL, // Letter Small, 8 1/2 by 11 inches
wxPAPER_TABLOID, // Tabloid, 11 by 17 inches
wxPAPER_LEDGER, // Ledger, 17 by 11 inches
wxPAPER_STATEMENT, // Statement, 5 1/2 by 8 1/2 inches
wxPAPER_EXECUTIVE, // Executive, 7 1/4 by 10 1/2 inches
wxPAPER_A3, // A3 sheet, 297 by 420 millimeters
wxPAPER_A4SMALL, // A4 small sheet, 210 by 297 millimeters
wxPAPER_A5, // A5 sheet, 148 by 210 millimeters
wxPAPER_B4, // B4 sheet, 250 by 354 millimeters
wxPAPER_B5, // B5 sheet, 182-by-257-millimeter paper
wxPAPER_FOLIO, // Folio, 8-1/2-by-13-inch paper
wxPAPER_QUARTO, // Quarto, 215-by-275-millimeter paper
wxPAPER_10X14, // 10-by-14-inch sheet
wxPAPER_11X17, // 11-by-17-inch sheet
wxPAPER_NOTE, // Note, 8 1/2 by 11 inches
wxPAPER_ENV_9, // #9 Envelope, 3 7/8 by 8 7/8 inches
wxPAPER_ENV_10, // #10 Envelope, 4 1/8 by 9 1/2 inches
wxPAPER_ENV_11, // #11 Envelope, 4 1/2 by 10 3/8 inches
wxPAPER_ENV_12, // #12 Envelope, 4 3/4 by 11 inches
wxPAPER_ENV_14, // #14 Envelope, 5 by 11 1/2 inches
wxPAPER_ENV_DL, // DL Envelope, 110 by 220 millimeters
wxPAPER_ENV_C5, // C5 Envelope, 162 by 229 millimeters
wxPAPER_ENV_C3, // C3 Envelope, 324 by 458 millimeters
wxPAPER_ENV_C4, // C4 Envelope, 229 by 324 millimeters
wxPAPER_ENV_C6, // C6 Envelope, 114 by 162 millimeters
wxPAPER_ENV_C65, // C65 Envelope, 114 by 229 millimeters
wxPAPER_ENV_B4, // B4 Envelope, 250 by 353 millimeters
wxPAPER_ENV_B5, // B5 Envelope, 176 by 250 millimeters
wxPAPER_ENV_B6, // B6 Envelope, 176 by 125 millimeters
wxPAPER_ENV_ITALY, // Italy Envelope, 110 by 230 millimeters
wxPAPER_ENV_MONARCH, // Monarch Envelope, 3 7/8 by 7 1/2 inches
wxPAPER_ENV_PERSONAL, // 6 3/4 Envelope, 3 5/8 by 6 1/2 inches
wxPAPER_FANFOLD_US, // US Std Fanfold, 14 7/8 by 11 inches
wxPAPER_FANFOLD_STD_GERMAN, // German Std Fanfold, 8 1/2 by 12 inches
wxPAPER_FANFOLD_LGL_GERMAN, // German Legal Fanfold, 8 1/2 by 13 inches
wxPAPER_ISO_B4, // B4 (ISO) 250 x 353 mm
wxPAPER_JAPANESE_POSTCARD, // Japanese Postcard 100 x 148 mm
wxPAPER_9X11, // 9 x 11 in
wxPAPER_10X11, // 10 x 11 in
wxPAPER_15X11, // 15 x 11 in
wxPAPER_ENV_INVITE, // Envelope Invite 220 x 220 mm
wxPAPER_LETTER_EXTRA, // Letter Extra 9 \275 x 12 in
wxPAPER_LEGAL_EXTRA, // Legal Extra 9 \275 x 15 in
wxPAPER_TABLOID_EXTRA, // Tabloid Extra 11.69 x 18 in
wxPAPER_A4_EXTRA, // A4 Extra 9.27 x 12.69 in
wxPAPER_LETTER_TRANSVERSE, // Letter Transverse 8 \275 x 11 in
wxPAPER_A4_TRANSVERSE, // A4 Transverse 210 x 297 mm
wxPAPER_LETTER_EXTRA_TRANSVERSE, // Letter Extra Transverse 9\275 x 12 in
wxPAPER_A_PLUS, // SuperA/SuperA/A4 227 x 356 mm
wxPAPER_B_PLUS, // SuperB/SuperB/A3 305 x 487 mm
wxPAPER_LETTER_PLUS, // Letter Plus 8.5 x 12.69 in
wxPAPER_A4_PLUS, // A4 Plus 210 x 330 mm
wxPAPER_A5_TRANSVERSE, // A5 Transverse 148 x 210 mm
wxPAPER_B5_TRANSVERSE, // B5 (JIS) Transverse 182 x 257 mm
wxPAPER_A3_EXTRA, // A3 Extra 322 x 445 mm
wxPAPER_A5_EXTRA, // A5 Extra 174 x 235 mm
wxPAPER_B5_EXTRA, // B5 (ISO) Extra 201 x 276 mm
wxPAPER_A2, // A2 420 x 594 mm
wxPAPER_A3_TRANSVERSE, // A3 Transverse 297 x 420 mm
wxPAPER_A3_EXTRA_TRANSVERSE // A3 Extra Transverse 322 x 445 mm
} wxPaperSize ;
/* Printing orientation */
#ifndef wxPORTRAIT
#define wxPORTRAIT 1
#define wxLANDSCAPE 2
#endif
/* Duplex printing modes
*/
typedef enum {
wxDUPLEX_SIMPLEX, // Non-duplex
wxDUPLEX_HORIZONTAL,
wxDUPLEX_VERTICAL
} wxDuplexMode;
/* Print quality.
*/
#define wxPRINT_QUALITY_HIGH -1
#define wxPRINT_QUALITY_MEDIUM -2
#define wxPRINT_QUALITY_LOW -3
#define wxPRINT_QUALITY_DRAFT -4
typedef int wxPrintQuality;
/* Print mode (currently PostScript only)
*/
typedef enum {
wxPRINT_MODE_NONE = 0,
wxPRINT_MODE_PREVIEW = 1, // Preview in external application
wxPRINT_MODE_FILE = 2, // Print to file
wxPRINT_MODE_PRINTER = 3 // Send to printer
} wxPrintMode;
#ifdef __WXMSW__
/* Stand-ins for Windows types, to avoid
* #including all of windows.h */

View File

@ -69,6 +69,7 @@ public:
inline wxSize(long xx, long yy) { x = xx; y = yy; }
inline wxSize(const wxSize& sz) { x = sz.x; y = sz.y; }
inline void operator = (const wxSize& sz) { x = sz.x; y = sz.y; }
inline bool operator == (const wxSize& sz) const { return (x == sz.x && y == sz.y); }
inline wxSize operator + (const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
inline wxSize operator - (const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
inline void Set(long xx, long yy) { x = xx; y = yy; }
@ -88,6 +89,7 @@ class WXDLLEXPORT wxRealPoint
inline wxRealPoint operator - (const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); }
inline void operator = (const wxRealPoint& pt) { x = pt.x; y = pt.y; }
inline bool operator == (const wxRealPoint& pt) const { return (x == pt.x && y == pt.y); }
};
class WXDLLEXPORT wxPoint
@ -106,6 +108,7 @@ class WXDLLEXPORT wxPoint
wxPoint(const wxPoint& pt) { x = pt.x; y = pt.y; };
inline void operator = (const wxPoint& pt) { x = pt.x; y = pt.y; }
inline bool operator == (const wxPoint& pt) const { return (x == pt.x && y == pt.y); }
inline wxPoint operator + (const wxPoint& pt) { return wxPoint(x + pt.x, y + pt.y); }
inline wxPoint operator - (const wxPoint& pt) { return wxPoint(x - pt.x, y - pt.y); }
};

View File

@ -21,6 +21,7 @@
#include "wx/dialog.h"
#include "wx/module.h"
#include "wx/cmndata.h"
#include <fstream.h>
@ -41,14 +42,21 @@ class WXDLLEXPORT wxPostScriptDC: public wxDC
public:
wxPostScriptDC();
// Deprecated constructor
wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
// Recommended constructor
wxPostScriptDC(const wxPrintData& printData);
~wxPostScriptDC();
// Deprecated
bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
virtual bool Ok() const;
// Deprecated: use wxGenericPrintDialog instead
virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) NULL);
virtual void BeginDrawing() {}
@ -112,7 +120,10 @@ public:
wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE);
void GetSize(int* width, int* height) const;
void GetSizeMM(long *width, long *height) const;
void GetSizeMM(int *width, int *height) const;
// Resolution in pixels per logical inch
wxSize GetPPI(void) const;
void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
void SetDeviceOrigin( long x, long y );
@ -122,6 +133,9 @@ public:
inline ofstream *GetStream(void) const { return m_pstream; }
inline wxPrintData& GetPrintData() { return m_printData; }
inline void SetPrintData(const wxPrintData& data) { m_printData = data; }
protected:
ofstream * m_pstream; // PostScript output stream
@ -133,9 +147,10 @@ protected:
bool m_clipping;
double m_underlinePosition;
double m_underlineThickness;
wxPrintData m_printData;
};
// TODO Needed? Should perhaps use wxGenericPrintDialog instead.
// Deprecated: should use wxGenericPrintDialog instead.
#if 1
#define wxID_PRINTER_COMMAND 1
#define wxID_PRINTER_OPTIONS 2
@ -166,89 +181,94 @@ enum {
// Print Actions
enum {
PS_PRINTER,
PS_NONE,
PS_PREVIEW,
PS_FILE,
PS_PREVIEW
PS_PRINTER
};// ps_action = PS_PREVIEW;
// PostScript printer settings
WXDLLEXPORT void wxSetPrinterCommand(const char *cmd);
WXDLLEXPORT void wxSetPrintPreviewCommand(const char *cmd);
WXDLLEXPORT void wxSetPrinterOptions(const char *flags);
WXDLLEXPORT void wxSetPrinterCommand(const wxString& cmd);
WXDLLEXPORT void wxSetPrintPreviewCommand(const wxString& cmd);
WXDLLEXPORT void wxSetPrinterOptions(const wxString& flags);
WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
WXDLLEXPORT void wxSetPrinterMode(int mode);
WXDLLEXPORT void wxSetPrinterFile(const char *f);
WXDLLEXPORT void wxSetAFMPath(const char *f);
WXDLLEXPORT void wxSetPrinterFile(const wxString& f);
WXDLLEXPORT void wxSetAFMPath(const wxString& f);
// Get current values
WXDLLEXPORT char* wxGetPrinterCommand();
WXDLLEXPORT char* wxGetPrintPreviewCommand();
WXDLLEXPORT char* wxGetPrinterOptions();
WXDLLEXPORT wxString wxGetPrinterCommand();
WXDLLEXPORT wxString wxGetPrintPreviewCommand();
WXDLLEXPORT wxString wxGetPrinterOptions();
WXDLLEXPORT int wxGetPrinterOrientation();
WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
WXDLLEXPORT int wxGetPrinterMode();
WXDLLEXPORT char* wxGetPrinterFile();
WXDLLEXPORT char* wxGetAFMPath();
WXDLLEXPORT wxString wxGetPrinterFile();
WXDLLEXPORT wxString wxGetAFMPath();
/*
* PostScript print setup information
* PostScript print setup information.
* This is now obsolete, but retained for a while for compatibility
*/
class WXDLLEXPORT wxPrintSetupData: public wxObject
{
public:
char *printerCommand;
char *previewCommand;
char *printerFlags;
char *printerFile;
int printerOrient;
double printerScaleX;
double printerScaleY;
long printerTranslateX;
long printerTranslateY;
// 1 = Preview, 2 = print to file, 3 = send to printer
int printerMode;
char *afmPath;
// A name in the paper database (see wx_print.h: the printing framework)
char *paperName;
bool printColour;
public:
wxPrintSetupData();
~wxPrintSetupData();
void SetPrinterCommand(const char *cmd);
void SetPaperName(const char *paper);
void SetPrintPreviewCommand(const char *cmd);
void SetPrinterOptions(const char *flags);
void SetPrinterFile(const char *f);
void SetPrinterOrientation(int orient);
void SetPrinterScaling(double x, double y);
void SetPrinterTranslation(long x, long y);
void SetPrinterCommand(const wxString& cmd) { m_printerCommand = cmd; };
void SetPaperName(const wxString& paper) { m_paperName = paper; };
void SetPrintPreviewCommand(const wxString& cmd) { m_previewCommand = cmd; };
void SetPrinterOptions(const wxString& flags) { m_printerFlags = flags; };
void SetPrinterFile(const wxString& f) { m_printerFile = f; };
void SetPrinterOrientation(int orient) { m_printerOrient = orient; };
void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; };
void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; };
// 1 = Preview, 2 = print to file, 3 = send to printer
void SetPrinterMode(int mode);
void SetAFMPath(const char *f);
void SetColour(bool col);
void SetPrinterMode(int mode) { m_printerMode = mode; };
void SetAFMPath(const wxString& f) { m_afmPath = f; };
void SetColour(bool col) { m_printColour = col; };
// Get current values
char *GetPrinterCommand();
char *GetPrintPreviewCommand();
char *GetPrinterOptions();
char *GetPrinterFile();
char *GetPaperName();
int GetPrinterOrientation();
void GetPrinterScaling(double* x, double* y);
void GetPrinterTranslation(long *x, long *y);
int GetPrinterMode();
char *GetAFMPath();
bool GetColour();
wxString GetPrinterCommand() const { return m_printerCommand; } ;
wxString GetPrintPreviewCommand() const { return m_previewCommand; } ;
wxString GetPrinterOptions() const { return m_printerFlags; };
wxString GetPrinterFile() const { return m_printerFile; };
wxString GetPaperName() const { return m_paperName; }
int GetPrinterOrientation() const { return m_printerOrient; };
void GetPrinterScaling(double* x, double* y) const { *x = m_printerScaleX; *y = m_printerScaleY; };
void GetPrinterTranslation(long *x, long *y) const { *x = m_printerTranslateX; *y = m_printerTranslateY; };
int GetPrinterMode() const { return m_printerMode; };
wxString GetAFMPath() const { return m_afmPath; };
bool GetColour() const { return m_printColour; };
void operator=(wxPrintSetupData& data);
private:
// Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
// There is also an operator for initializing a wxPrintData from a wxPrintSetupData.
void operator=(const wxPrintData& data);
public:
wxString m_printerCommand;
wxString m_previewCommand;
wxString m_printerFlags;
wxString m_printerFile;
int m_printerOrient;
double m_printerScaleX;
double m_printerScaleY;
long m_printerTranslateX;
long m_printerTranslateY;
// 1 = Preview, 2 = print to file, 3 = send to printer
int m_printerMode;
wxString m_afmPath;
// A name in the paper database (see paper.h)
wxString m_paperName;
bool m_printColour;
DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
};

View File

@ -20,38 +20,38 @@
#include "wx/prntbase.h"
/*
* Represents the printer: manages printing a wxPrintout object
*/
* Represents the printer: manages printing a wxPrintout object
*/
class WXDLLEXPORT wxPostScriptPrinter: public wxPrinterBase
{
DECLARE_DYNAMIC_CLASS(wxPostScriptPrinter)
public:
wxPostScriptPrinter(wxPrintData *data = (wxPrintData *) NULL);
~wxPostScriptPrinter(void);
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
virtual bool PrintDialog(wxWindow *parent);
virtual bool Setup(wxWindow *parent);
DECLARE_DYNAMIC_CLASS(wxPostScriptPrinter)
public:
wxPostScriptPrinter(wxPrintDialogData *data = (wxPrintDialogData *) NULL);
~wxPostScriptPrinter(void);
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
virtual wxDC* PrintDialog(wxWindow *parent);
virtual bool Setup(wxWindow *parent);
};
/*
* wxPrintPreview
* Programmer creates an object of this class to preview a wxPrintout.
*/
* wxPrintPreview
* Programmer creates an object of this class to preview a wxPrintout.
*/
class WXDLLEXPORT wxPostScriptPrintPreview: public wxPrintPreviewBase
{
DECLARE_CLASS(wxPostScriptPrintPreview)
public:
wxPostScriptPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintData *data = (wxPrintData *) NULL);
~wxPostScriptPrintPreview(void);
virtual bool Print(bool interactive);
virtual void DetermineScaling(void);
DECLARE_CLASS(wxPostScriptPrintPreview)
public:
wxPostScriptPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintDialogData *data = (wxPrintDialogData *) NULL);
~wxPostScriptPrintPreview(void);
virtual bool Print(bool interactive);
virtual void DetermineScaling(void);
};
#endif
// __PRINTPSH__
// __PRINTPSH__

View File

@ -36,9 +36,9 @@ class WXDLLEXPORT wxRadioBox;
class WXDLLEXPORT wxPrintSetupData;
/*
* Simulated Print and Print Setup dialogs
* for non-Windows platforms (and Windows using PostScript print/preview)
*/
* Simulated Print and Print Setup dialogs
* for non-Windows platforms (and Windows using PostScript print/preview)
*/
#define wxPRINTID_STATIC 10
#define wxPRINTID_RANGE 11
@ -50,36 +50,39 @@ class WXDLLEXPORT wxPrintSetupData;
class WXDLLEXPORT wxGenericPrintDialog: public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxGenericPrintDialog)
DECLARE_DYNAMIC_CLASS(wxGenericPrintDialog)
public:
wxGenericPrintDialog(wxWindow *parent, wxPrintDialogData* data = (wxPrintDialogData*) NULL);
~wxGenericPrintDialog();
public:
wxStaticText *printerMessage;
wxButton *setupButton;
wxButton *helpButton;
wxRadioBox *rangeRadioBox;
wxTextCtrl *fromText;
wxTextCtrl *toText;
wxTextCtrl *noCopiesText;
wxCheckBox *printToFileCheckBox;
wxCheckBox *collateCopiesCheckBox;
void OnSetup(wxCommandEvent& event);
void OnRange(wxCommandEvent& event);
void OnOK(wxCommandEvent& event);
virtual bool TransferDataFromWindow();
virtual bool TransferDataToWindow();
wxPrintData printData;
wxGenericPrintDialog(wxWindow *parent, wxPrintData* data);
~wxGenericPrintDialog(void);
virtual int ShowModal();
void OnSetup(wxCommandEvent& event);
void OnRange(wxCommandEvent& event);
void OnOK(wxCommandEvent& event);
inline wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
wxDC *GetPrintDC();
virtual bool TransferDataFromWindow(void);
virtual bool TransferDataToWindow(void);
virtual int ShowModal(void);
inline wxPrintData& GetPrintData(void) { return printData; }
wxDC *GetPrintDC(void);
DECLARE_EVENT_TABLE()
public:
wxStaticText* m_printerMessage;
wxButton* m_setupButton;
wxButton* m_helpButton;
wxRadioBox* m_rangeRadioBox;
wxTextCtrl* m_fromText;
wxTextCtrl* m_toText;
wxTextCtrl* m_noCopiesText;
wxCheckBox* m_printToFileCheckBox;
wxCheckBox* m_collateCopiesCheckBox;
wxPrintDialogData m_printDialogData;
DECLARE_EVENT_TABLE()
};
#define wxPRINTID_PRINTCOLOUR 10
@ -90,27 +93,34 @@ DECLARE_EVENT_TABLE()
class WXDLLEXPORT wxGenericPrintSetupDialog: public wxDialog
{
DECLARE_CLASS(wxGenericPrintSetupDialog)
DECLARE_CLASS(wxGenericPrintSetupDialog)
public:
// There are no configuration options for the dialog, so we
// just pass the wxPrintData object (no wxPrintSetupDialogData class needed)
wxGenericPrintSetupDialog(wxWindow *parent, wxPrintData* data);
wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSetupData* data);
~wxGenericPrintSetupDialog();
public:
wxRadioBox *orientationRadioBox;
wxTextCtrl *printerCommandText;
wxTextCtrl *printerOptionsText;
wxCheckBox *colourCheckBox;
wxChoice *paperTypeChoice;
void Init(wxPrintData* data);
virtual bool TransferDataFromWindow();
virtual bool TransferDataToWindow();
wxChoice *CreatePaperTypeChoice(int* x, int* y);
public:
wxRadioBox* m_orientationRadioBox;
wxTextCtrl* m_printerCommandText;
wxTextCtrl* m_printerOptionsText;
wxCheckBox* m_colourCheckBox;
wxChoice* m_paperTypeChoice;
#if wxUSE_POSTSCRIPT
wxPrintSetupData printData;
inline wxPrintSetupData& GetPrintData(void) { return printData; }
wxPrintData m_printData;
inline wxPrintData& GetPrintData() { return m_printData; }
#endif
wxGenericPrintSetupDialog(wxWindow *parent, wxPrintSetupData* data);
~wxGenericPrintSetupDialog(void);
virtual bool TransferDataFromWindow(void);
virtual bool TransferDataToWindow(void);
wxChoice *CreatePaperTypeChoice(int* x, int* y);
};
#define wxPRINTID_LEFTMARGIN 30
@ -120,34 +130,35 @@ class WXDLLEXPORT wxGenericPrintSetupDialog: public wxDialog
class WXDLLEXPORT wxGenericPageSetupDialog: public wxDialog
{
DECLARE_CLASS(wxGenericPageSetupDialog)
DECLARE_CLASS(wxGenericPageSetupDialog)
public:
wxGenericPageSetupDialog(wxWindow *parent, wxPageSetupData* data = (wxPageSetupData*) NULL);
~wxGenericPageSetupDialog();
public:
wxButton *printerButton;
wxRadioBox *orientationRadioBox;
wxTextCtrl *marginLeftText;
wxTextCtrl *marginTopText;
wxTextCtrl *marginRightText;
wxTextCtrl *marginBottomText;
wxChoice *paperTypeChoice;
virtual bool TransferDataFromWindow();
virtual bool TransferDataToWindow();
static bool pageSetupDialogCancelled;
wxPageSetupData pageData;
void OnPrinter(wxCommandEvent& event);
wxChoice *CreatePaperTypeChoice(int* x, int* y);
inline wxPageSetupData& GetPageSetupData() { return m_pageData; }
wxGenericPageSetupDialog(wxWindow *parent, wxPageSetupData* data = (wxPageSetupData*) NULL);
~wxGenericPageSetupDialog(void);
virtual bool TransferDataFromWindow(void);
virtual bool TransferDataToWindow(void);
void OnPrinter(wxCommandEvent& event);
wxChoice *CreatePaperTypeChoice(int* x, int* y);
inline wxPageSetupData& GetPageSetupData(void) { return pageData; }
DECLARE_EVENT_TABLE()
public:
wxButton* m_printerButton;
wxRadioBox* m_orientationRadioBox;
wxTextCtrl* m_marginLeftText;
wxTextCtrl* m_marginTopText;
wxTextCtrl* m_marginRightText;
wxTextCtrl* m_marginBottomText;
wxChoice* m_paperTypeChoice;
static bool m_pageSetupDialogCancelled;
wxPageSetupData m_pageData;
DECLARE_EVENT_TABLE()
};
#endif
// __PRINTDLGH_G__
// __PRINTDLGH_G__

View File

@ -225,9 +225,16 @@ public:
virtual long MinY() const { return m_minY; }
virtual long MaxY() const { return m_maxY; }
// Size in device units
virtual void GetSize( int* width, int* height ) const;
inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
virtual void GetSizeMM( long* width, long* height ) const;
// Size in millimetres
virtual void GetSizeMM( int* width, int* height ) const;
inline wxSize GetSizeMM(void) const { int w, h; GetSizeMM(&w, &h); return wxSize(w, h); }
// Resolution in pixels per logical inch
virtual wxSize GetPPI(void) const;
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
virtual void EndDoc() {}
@ -339,7 +346,6 @@ public:
bool m_autoSetting; // wxMSW only ?
bool m_dontDelete; // wxMSW only ?
bool m_optimize; // wxMSW only ?
wxString m_filename; // Not sure where this belongs.
wxPen m_pen;
wxBrush m_brush;

View File

@ -92,6 +92,9 @@ public:
virtual void DrawSpline( wxList *points );
// Resolution in pixels per logical inch
wxSize GetPPI(void) const;
// implementation
GdkWindow *m_window;

View File

@ -225,9 +225,16 @@ public:
virtual long MinY() const { return m_minY; }
virtual long MaxY() const { return m_maxY; }
// Size in device units
virtual void GetSize( int* width, int* height ) const;
inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
virtual void GetSizeMM( long* width, long* height ) const;
// Size in millimetres
virtual void GetSizeMM( int* width, int* height ) const;
inline wxSize GetSizeMM(void) const { int w, h; GetSizeMM(&w, &h); return wxSize(w, h); }
// Resolution in pixels per logical inch
virtual wxSize GetPPI(void) const;
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
virtual void EndDoc() {}
@ -339,7 +346,6 @@ public:
bool m_autoSetting; // wxMSW only ?
bool m_dontDelete; // wxMSW only ?
bool m_optimize; // wxMSW only ?
wxString m_filename; // Not sure where this belongs.
wxPen m_pen;
wxBrush m_brush;

View File

@ -92,6 +92,9 @@ public:
virtual void DrawSpline( wxList *points );
// Resolution in pixels per logical inch
wxSize GetPPI(void) const;
// implementation
GdkWindow *m_window;

View File

@ -211,10 +211,17 @@ class WXDLLEXPORT wxDC: public wxObject
virtual inline long MinY(void) const { return m_minY; }
virtual inline long MaxY(void) const { return m_maxY; }
// Size in device units
virtual void GetSize( int* width, int* height ) const;
inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
virtual void GetSizeMM( long* width, long* height ) const;
// Size in millimetres
virtual void GetSizeMM( int* width, int* height ) const;
inline wxSize GetSizeMM(void) const { int w, h; GetSizeMM(&w, &h); return wxSize(w, h); }
// Resolution in pixels per logical inch
wxSize GetPPI(void) const ;
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; };
virtual void EndDoc(void) {};
virtual void StartPage(void) {};
@ -342,8 +349,7 @@ class WXDLLEXPORT wxDC: public wxObject
bool m_clipping; // Is clipping on right now ?
bool m_optimize; // wxMSW only ?
bool m_isInteractive; // For wxPostScriptDC
wxString m_filename; // Ditto
wxPen m_pen;
wxBrush m_brush;
wxBrush m_backgroundBrush;

View File

@ -172,6 +172,9 @@ class WXDLLEXPORT wxWindowDC: public wxDC
virtual void DrawSpline( int n, wxPoint points[] )
{ wxDC::DrawSpline(n, points); }
// Resolution in pixels per logical inch
wxSize GetPPI(void) const;
// Motif-specific
void SetDCClipping (); // Helper function for setting clipping

View File

@ -68,7 +68,7 @@
/*
* Use Threads
*/
#define wxUSE_THREADS 1
#define wxUSE_THREADS 0
/*
* Have glibc2
*/
@ -78,6 +78,8 @@
*/
#define wxHAVE_LIB_XPM 0
#define wxUSE_XPM 1
/* ------------------------------------------------------------------------ */
/* GUI control options (always enabled in wxGTK) */
/* ------------------------------------------------------------------------ */
@ -199,11 +201,11 @@
/*
* Use tooltips
*/
#define wxUSE_TOOLTIPS 1
#define wxUSE_TOOLTIPS 0
/*
* Use dnd
*/
#define wxUSE_DRAG_AND_DROP 1
#define wxUSE_DRAG_AND_DROP 0
/*
* Use wxLibrary class
*/
@ -387,7 +389,7 @@
/* #undef HAVE_DOPRNT */
/* Define if you have sched.h */
#define HAVE_SCHED_H 1
#define HAVE_SCHED_H 0
/* Define if you have strings.h */
#define HAVE_STRINGS_H 1
@ -405,10 +407,10 @@
#define HAVE_VSNPRINTF 1
/* Define if you have usleep() */
/* #undef HAVE_USLEEP */
#define HAVE_USLEEP 1
/* Define if you have nanosleep() */
#define HAVE_NANOSLEEP 1
#define HAVE_NANOSLEEP 0
/* Define if you have vfork() */
#define HAVE_VFORK 1

View File

@ -199,10 +199,14 @@ public:
// Size in device units
virtual void GetSize(int* width, int* height) const;
inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
inline wxSize GetSize() const { int w, h; GetSize(&w, &h); return wxSize(w, h); }
// Size in mm
virtual void GetSizeMM(long* width, long* height) const ;
virtual void GetSizeMM(int* width, int* height) const ;
inline wxSize GetSizeMM() const { int w, h; GetSizeMM(&w, &h); return wxSize(w, h); }
// Resolution in Pixels per inch
virtual wxSize GetPPI(void) const ;
// Compatibility
#if WXWIN_COMPATIBILITY
@ -351,7 +355,6 @@ protected:
wxWindow * m_canvas;
wxBitmap m_selectedBitmap;
wxString m_filename;
// TRUE => DeleteDC() in dtor, FALSE => only ReleaseDC() it
bool m_bOwnsDC;

View File

@ -17,21 +17,37 @@
#endif
#include "wx/dc.h"
#include "wx/cmndata.h"
class WXDLLEXPORT wxPrinterDC: public wxDC
{
public:
DECLARE_CLASS(wxPrinterDC)
public:
DECLARE_CLASS(wxPrinterDC)
// Create a printer DC
wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT);
wxPrinterDC(WXHDC theDC);
// Create a printer DC (obsolete function: use wxPrintData version now)
wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT);
~wxPrinterDC(void);
// Create from print data
wxPrinterDC(const wxPrintData& data);
wxPrinterDC(WXHDC theDC);
~wxPrinterDC(void);
bool StartDoc(const wxString& message);
void EndDoc(void);
void StartPage(void);
void EndPage(void);
protected:
wxPrintData m_printData;
};
// Gets an HDC for the default printer configuration
WXHDC WXDLLEXPORT wxGetPrinterDC(int orientation);
// WXHDC WXDLLEXPORT wxGetPrinterDC(int orientation);
// Gets an HDC for the specified printer configuration
WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& data);
#endif
// _WX_DCPRINT_H_

View File

@ -29,24 +29,23 @@ class WXDLLEXPORT wxPrintDialog: public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxPrintDialog)
private:
wxPrintData printData;
wxDC *printerDC;
bool destroyDC;
char *deviceName;
char *driverName;
char *portName;
wxWindow *dialogParent;
public:
public:
wxPrintDialog(void);
wxPrintDialog(wxWindow *parent, wxPrintData* data = NULL);
wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL);
~wxPrintDialog(void);
bool Create(wxWindow *parent, wxPrintData* data = NULL);
bool Create(wxWindow *parent, wxPrintDialogData* data = NULL);
virtual int ShowModal(void);
inline wxPrintData& GetPrintData(void) { return printData; }
inline wxPrintDialogData& GetPrintDialogData(void) { return m_printDialogData; }
inline wxPrintData& GetPrintData(void) { return m_printDialogData.GetPrintData(); }
virtual wxDC *GetPrintDC(void);
private:
wxPrintDialogData m_printDialogData;
wxDC* m_printerDC;
bool m_destroyDC;
wxWindow* m_dialogParent;
};
class WXDLLEXPORT wxPageSetupDialog: public wxDialog

View File

@ -27,11 +27,11 @@ class WXDLLEXPORT wxWindowsPrinter: public wxPrinterBase
DECLARE_DYNAMIC_CLASS(wxWindowsPrinter)
public:
wxWindowsPrinter(wxPrintData *data = NULL);
wxWindowsPrinter(wxPrintDialogData *data = NULL);
~wxWindowsPrinter(void);
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
virtual bool PrintDialog(wxWindow *parent);
virtual wxDC* PrintDialog(wxWindow *parent);
virtual bool Setup(wxWindow *parent);
private:
@ -48,7 +48,7 @@ class WXDLLEXPORT wxWindowsPrintPreview: public wxPrintPreviewBase
DECLARE_CLASS(wxWindowsPrintPreview)
public:
wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL);
wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintDialogData *data = NULL);
~wxWindowsPrintPreview(void);
virtual bool Print(bool interactive);

View File

@ -44,12 +44,12 @@ class WXDLLEXPORT wxPrinterBase: public wxObject
DECLARE_CLASS(wxPrinterBase)
public:
wxPrinterBase(wxPrintData *data = (wxPrintData *) NULL);
wxPrinterBase(wxPrintDialogData *data = (wxPrintDialogData *) NULL);
~wxPrinterBase();
virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
virtual void ReportError(wxWindow *parent, wxPrintout *printout, char *message);
inline wxPrintData& GetPrintData() const { return (wxPrintData&) m_printData; };
inline wxPrintDialogData& GetPrintDialogData() const { return (wxPrintDialogData&) m_printDialogData; };
inline bool GetAbort() const { return sm_abortIt; }
///////////////////////////////////////////////////////////////////////////
@ -57,10 +57,10 @@ public:
virtual bool Setup(wxWindow *parent) = 0;
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE) = 0;
virtual bool PrintDialog(wxWindow *parent) = 0;
virtual wxDC* PrintDialog(wxWindow *parent) = 0;
protected:
wxPrintData m_printData;
wxPrintDialogData m_printDialogData;
wxPrintout* m_currentPrintout;
public:
static wxWindow* sm_abortWindow;
@ -251,7 +251,7 @@ class WXDLLEXPORT wxPrintPreviewBase: public wxObject
DECLARE_CLASS(wxPrintPreviewBase)
public:
wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintData *data = (wxPrintData *) NULL);
wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintDialogData *data = (wxPrintDialogData *) NULL);
~wxPrintPreviewBase();
virtual bool SetCurrentPage(int pageNum);
@ -277,7 +277,7 @@ public:
// a wxMemoryDC.
virtual bool RenderPage(int pageNum);
inline wxPrintData& GetPrintData() { return m_printData; }
inline wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
virtual void SetZoom(int percent);
inline int GetZoom() const { return m_currentZoom; };
@ -302,7 +302,7 @@ public:
virtual void DetermineScaling() = 0;
protected:
wxPrintData m_printData;
wxPrintDialogData m_printDialogData;
wxWindow* m_previewCanvas;
wxFrame* m_previewFrame;
wxBitmap* m_previewBitmap;
@ -340,47 +340,5 @@ public:
DECLARE_EVENT_TABLE()
};
/*
* Again, this only really needed for non-Windows platforms
* or if you want to test the PostScript printing under Windows,
* or if you're using the generic page setup dialog under e.g. Win16.
*/
class WXDLLEXPORT wxPrintPaperType: public wxObject
{
public:
wxPrintPaperType(const char *name = (const char *) NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0);
~wxPrintPaperType();
public:
int widthMM;
int heightMM;
int widthPixels;
int heightPixels;
char *pageName;
private:
DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
};
class WXDLLEXPORT wxPrintPaperDatabase: public wxList
{
public:
wxPrintPaperDatabase();
~wxPrintPaperDatabase();
void CreateDatabase();
void ClearDatabase();
void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp);
wxPrintPaperType *FindPaperType(const char *name);
private:
DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
};
WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase;
#endif
// _WX_PRNTBASEH__

View File

@ -1,11 +1,11 @@
/*
* File: printing.cc
* Purpose: Printing demo for wxWindows class library
* Author: Julian Smart
* Created: 1995
* Updated:
* Copyright: (c) 1995, AIAI, University of Edinburgh
*/
* File: printing.cc
* Purpose: Printing demo for wxWindows class library
* Author: Julian Smart
* Created: 1995
* Updated:
* Copyright: (c) 1995, AIAI, University of Edinburgh
*/
/* static const char sccsid[] = "%W% %G%"; */
@ -52,7 +52,13 @@
// Declare a frame
MyFrame *frame = (MyFrame *) NULL;
int orientation = wxPORTRAIT;
// int orientation = wxPORTRAIT;
// Global print data, to remember settings during the session
wxPrintData *g_printData = (wxPrintData*) NULL ;
// Global page setup data
wxPageSetupData* g_pageSetupData = (wxPageSetupData*) NULL;
// Main proc
IMPLEMENT_APP(MyApp)
@ -68,25 +74,36 @@ MyApp::MyApp()
// main frame
bool MyApp::OnInit(void)
{
m_testFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
m_testFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
g_printData = new wxPrintData;
g_pageSetupData = new wxPageSetupDialogData;
// Create the main frame window
frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(400, 400));
// Give it a status line
frame->CreateStatusBar(2);
// Load icon and bitmap
frame->SetIcon( wxICON( mondrian) );
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(WXPRINT_PRINT, "&Print...", "Print");
file_menu->Append(WXPRINT_PRINT_SETUP, "Print &Setup...", "Setup printer properties");
file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup");
file_menu->Append(WXPRINT_PREVIEW, "Print Pre&view", "Preview");
// Compatibility with old system. In fact, we might keep wxThePrintSetupData
// just for useful default values which we can optionally assign to our
// own print data object.
#if defined(__WXGTK__) || defined(__WXMOTIF__)
(*g_printData) = * wxThePrintSetupData;
#endif
// Create the main frame window
frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(400, 400));
// Give it a status line
frame->CreateStatusBar(2);
// Load icon and bitmap
frame->SetIcon( wxICON( mondrian) );
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(WXPRINT_PRINT, "&Print...", "Print");
file_menu->Append(WXPRINT_PRINT_SETUP, "Print &Setup...", "Setup printer properties");
file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup");
file_menu->Append(WXPRINT_PREVIEW, "Print Pre&view", "Preview");
// Accelerators
wxAcceleratorEntry entries[1];
entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
@ -94,204 +111,206 @@ bool MyApp::OnInit(void)
frame->SetAcceleratorTable(accel);
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
file_menu->AppendSeparator();
file_menu->Append(WXPRINT_PRINT_PS, "Print PostScript...", "Print (PostScript)");
file_menu->Append(WXPRINT_PRINT_SETUP_PS, "Print Setup PostScript...", "Setup printer properties (PostScript)");
file_menu->Append(WXPRINT_PAGE_SETUP_PS, "Page Setup PostScript...", "Page setup (PostScript)");
file_menu->Append(WXPRINT_PREVIEW_PS, "Print Preview PostScript", "Preview (PostScript)");
file_menu->AppendSeparator();
file_menu->Append(WXPRINT_PRINT_PS, "Print PostScript...", "Print (PostScript)");
file_menu->Append(WXPRINT_PRINT_SETUP_PS, "Print Setup PostScript...", "Setup printer properties (PostScript)");
file_menu->Append(WXPRINT_PAGE_SETUP_PS, "Page Setup PostScript...", "Page setup (PostScript)");
file_menu->Append(WXPRINT_PREVIEW_PS, "Print Preview PostScript", "Preview (PostScript)");
#endif
file_menu->AppendSeparator();
file_menu->Append(WXPRINT_QUIT, "E&xit", "Exit program");
wxMenu *help_menu = new wxMenu;
help_menu->Append(WXPRINT_ABOUT, "&About", "About this demo");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
menu_bar->Append(help_menu, "&Help");
// Associate the menu bar with the frame
frame->SetMenuBar(menu_bar);
MyCanvas *canvas = new MyCanvas(frame, wxPoint(0, 0), wxSize(100, 100), wxRETAINED|wxHSCROLL|wxVSCROLL);
// Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
canvas->SetScrollbars(20, 20, 50, 50);
frame->canvas = canvas;
frame->Centre(wxBOTH);
frame->Show(TRUE);
frame->SetStatusText("Printing demo");
SetTopWindow(frame);
return TRUE;
file_menu->AppendSeparator();
file_menu->Append(WXPRINT_QUIT, "E&xit", "Exit program");
wxMenu *help_menu = new wxMenu;
help_menu->Append(WXPRINT_ABOUT, "&About", "About this demo");
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, "&File");
menu_bar->Append(help_menu, "&Help");
// Associate the menu bar with the frame
frame->SetMenuBar(menu_bar);
MyCanvas *canvas = new MyCanvas(frame, wxPoint(0, 0), wxSize(100, 100), wxRETAINED|wxHSCROLL|wxVSCROLL);
// Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
canvas->SetScrollbars(20, 20, 50, 50);
frame->canvas = canvas;
frame->Centre(wxBOTH);
frame->Show(TRUE);
frame->SetStatusText("Printing demo");
SetTopWindow(frame);
return TRUE;
}
int MyApp::OnExit()
{
delete wxGetApp().m_testFont;
return 1;
delete wxGetApp().m_testFont;
delete g_printData;
delete g_pageSetupData;
return 1;
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit)
EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint)
EVT_MENU(WXPRINT_PREVIEW, MyFrame::OnPrintPreview)
EVT_MENU(WXPRINT_PRINT_SETUP, MyFrame::OnPrintSetup)
EVT_MENU(WXPRINT_PAGE_SETUP, MyFrame::OnPageSetup)
EVT_MENU(WXPRINT_ABOUT, MyFrame::OnPrintAbout)
EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit)
EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint)
EVT_MENU(WXPRINT_PREVIEW, MyFrame::OnPrintPreview)
EVT_MENU(WXPRINT_PRINT_SETUP, MyFrame::OnPrintSetup)
EVT_MENU(WXPRINT_PAGE_SETUP, MyFrame::OnPageSetup)
EVT_MENU(WXPRINT_ABOUT, MyFrame::OnPrintAbout)
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
EVT_MENU(WXPRINT_PRINT_PS, MyFrame::OnPrintPS)
EVT_MENU(WXPRINT_PREVIEW_PS, MyFrame::OnPrintPreviewPS)
EVT_MENU(WXPRINT_PRINT_SETUP_PS, MyFrame::OnPrintSetupPS)
EVT_MENU(WXPRINT_PAGE_SETUP_PS, MyFrame::OnPageSetupPS)
EVT_MENU(WXPRINT_PRINT_PS, MyFrame::OnPrintPS)
EVT_MENU(WXPRINT_PREVIEW_PS, MyFrame::OnPrintPreviewPS)
EVT_MENU(WXPRINT_PRINT_SETUP_PS, MyFrame::OnPrintSetupPS)
EVT_MENU(WXPRINT_PAGE_SETUP_PS, MyFrame::OnPageSetupPS)
#endif
END_EVENT_TABLE()
// Define my frame constructor
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
wxFrame(frame, -1, title, pos, size)
wxFrame(frame, -1, title, pos, size)
{
canvas = (MyCanvas *) NULL;
canvas = (MyCanvas *) NULL;
}
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
Close(TRUE);
}
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
{
wxPrinter printer;
MyPrintout printout("My printout");
if (!printer.Print(this, &printout, TRUE))
wxPrintDialogData printDialogData(* g_printData);
wxPrinter printer(& printDialogData);
MyPrintout printout("My printout");
if (!printer.Print(this, &printout, TRUE))
wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK);
else
{
(*g_printData) = printer.GetPrintDialogData().GetPrintData();
}
}
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
{
wxPrintData printData;
printData.SetOrientation(orientation);
// Pass two printout objects: for preview, and possible printing.
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printData);
if (!preview->Ok())
{
// Pass two printout objects: for preview, and possible printing.
wxPrintDialogData printDialogData(* g_printData);
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printDialogData);
if (!preview->Ok())
{
delete preview;
wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
return;
}
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(TRUE);
}
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(TRUE);
}
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
{
wxPrintData data;
data.SetOrientation(orientation);
wxPrintDialogData printDialogData(* g_printData);
wxPrintDialog printerDialog(this, & printDialogData);
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
printerDialog.ShowModal();
wxPrintDialog printerDialog(this, & data);
printerDialog.GetPrintData().SetSetupDialog(TRUE);
printerDialog.ShowModal();
orientation = printerDialog.GetPrintData().GetOrientation();
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
}
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
wxPageSetupData data;
data.SetOrientation(orientation);
(*g_pageSetupData) = * g_printData;
wxPageSetupDialog pageSetupDialog(this, & data);
pageSetupDialog.ShowModal();
data = pageSetupDialog.GetPageSetupData();
orientation = data.GetOrientation();
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
pageSetupDialog.ShowModal();
(*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
(*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
}
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
{
wxPostScriptPrinter printer;
MyPrintout printout("My printout");
printer.Print(this, &printout, TRUE);
wxPostScriptPrinter printer(g_printData);
MyPrintout printout("My printout");
printer.Print(this, &printout, TRUE);
(*g_printData) = printer.GetPrintData();
}
void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
{
wxPrintData printData;
printData.SetOrientation(orientation);
// Pass two printout objects: for preview, and possible printing.
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printData);
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(TRUE);
// Pass two printout objects: for preview, and possible printing.
wxPrintDialogData printDialogData(* g_printData);
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printDialogData);
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(TRUE);
}
void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxPrintData data;
data.SetOrientation(orientation);
wxPrintDialogData printDialogData(* g_printData);
wxGenericPrintDialog printerDialog(this, & printDialogData);
wxGenericPrintDialog printerDialog(this, & data);
printerDialog.GetPrintData().SetSetupDialog(TRUE);
printerDialog.ShowModal();
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
printerDialog.ShowModal();
orientation = printerDialog.GetPrintData().GetOrientation();
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
}
void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxPageSetupData data;
data.SetOrientation(orientation);
(*g_pageSetupData) = * g_printData;
wxGenericPageSetupDialog pageSetupDialog(this, & data);
pageSetupDialog.ShowModal();
wxGenericPageSetupDialog pageSetupDialog(this, g_pageSetupData);
pageSetupDialog.ShowModal();
orientation = pageSetupDialog.GetPageSetupData().GetOrientation();
(*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
(*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
}
#endif
void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event))
{
(void)wxMessageBox("wxWindows printing demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk",
"About wxWindows printing demo", wxOK|wxCENTRE);
(void)wxMessageBox("wxWindows printing demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk",
"About wxWindows printing demo", wxOK|wxCENTRE);
}
void MyFrame::Draw(wxDC& dc)
{
dc.SetFont(* wxGetApp().m_testFont);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetBrush(* wxCYAN_BRUSH);
dc.SetPen(* wxRED_PEN);
dc.DrawRectangle(0, 30, 200, 100);
dc.DrawText("Rectangle 200 by 100", 40, 40);
dc.DrawEllipse(50, 140, 100, 50);
dc.DrawText("Test message: this is in 10 point text", 10, 180);
dc.SetPen(* wxBLACK_PEN);
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
wxIcon my_icon = wxICON(mondrian) ;
dc.DrawIcon( my_icon, 100, 100);
dc.SetFont(* wxGetApp().m_testFont);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetBrush(* wxCYAN_BRUSH);
dc.SetPen(* wxRED_PEN);
dc.DrawRectangle(0, 30, 200, 100);
dc.DrawText("Rectangle 200 by 100", 40, 40);
dc.DrawEllipse(50, 140, 100, 50);
dc.DrawText("Test message: this is in 10 point text", 10, 180);
dc.SetPen(* wxBLACK_PEN);
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
wxIcon my_icon = wxICON(mondrian) ;
dc.DrawIcon( my_icon, 100, 100);
}
void MyFrame::OnSize(wxSizeEvent& event )
@ -300,13 +319,14 @@ void MyFrame::OnSize(wxSizeEvent& event )
}
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_MOUSE_EVENTS(MyCanvas::OnEvent)
EVT_MOUSE_EVENTS(MyCanvas::OnEvent)
END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxFrame *frame, const wxPoint& pos, const wxSize& size, long style):
wxScrolledWindow(frame, -1, pos, size, style)
wxScrolledWindow(frame, -1, pos, size, style)
{
SetBackgroundColour(* wxWHITE);
}
MyCanvas::~MyCanvas(void)
@ -316,7 +336,7 @@ MyCanvas::~MyCanvas(void)
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
frame->Draw(dc);
frame->Draw(dc);
}
void MyCanvas::OnEvent(wxMouseEvent& WXUNUSED(event))
@ -325,196 +345,196 @@ void MyCanvas::OnEvent(wxMouseEvent& WXUNUSED(event))
bool MyPrintout::OnPrintPage(int page)
{
wxDC *dc = GetDC();
if (dc)
{
if (page == 1)
DrawPageOne(dc);
else if (page == 2)
DrawPageTwo(dc);
dc->SetDeviceOrigin(0, 0);
dc->SetUserScale(1.0, 1.0);
char buf[200];
sprintf(buf, "PAGE %d", page);
dc->DrawText(buf, 10, 10);
return TRUE;
}
else
return FALSE;
wxDC *dc = GetDC();
if (dc)
{
if (page == 1)
DrawPageOne(dc);
else if (page == 2)
DrawPageTwo(dc);
dc->SetDeviceOrigin(0, 0);
dc->SetUserScale(1.0, 1.0);
char buf[200];
sprintf(buf, "PAGE %d", page);
dc->DrawText(buf, 10, 10);
return TRUE;
}
else
return FALSE;
}
bool MyPrintout::OnBeginDocument(int startPage, int endPage)
{
if (!wxPrintout::OnBeginDocument(startPage, endPage))
return FALSE;
return TRUE;
if (!wxPrintout::OnBeginDocument(startPage, endPage))
return FALSE;
return TRUE;
}
void MyPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
{
*minPage = 1;
*maxPage = 2;
*selPageFrom = 1;
*selPageTo = 2;
*minPage = 1;
*maxPage = 2;
*selPageFrom = 1;
*selPageTo = 2;
}
bool MyPrintout::HasPage(int pageNum)
{
return (pageNum == 1 || pageNum == 2);
return (pageNum == 1 || pageNum == 2);
}
void MyPrintout::DrawPageOne(wxDC *dc)
{
/* You might use THIS code if you were scaling
* graphics of known size to fit on the page.
*/
int w, h;
// We know the graphic is 200x200. If we didn't know this,
// we'd need to calculate it.
float maxX = 200;
float maxY = 200;
// Let's have at least 50 device units margin
float marginX = 50;
float marginY = 50;
// Add the margin to the graphic size
maxX += (2*marginX);
maxY += (2*marginY);
// Get the size of the DC in pixels
dc->GetSize(&w, &h);
// Calculate a suitable scaling factor
float scaleX=(float)(w/maxX);
float scaleY=(float)(h/maxY);
// Use x or y scaling factor, whichever fits on the DC
float actualScale = wxMin(scaleX,scaleY);
// Calculate the position on the DC for centring the graphic
float posX = (float)((w - (200*actualScale))/2.0);
float posY = (float)((h - (200*actualScale))/2.0);
// Set the scale and origin
dc->SetUserScale(actualScale, actualScale);
dc->SetDeviceOrigin( (long)posX, (long)posY );
frame->Draw(*dc);
* graphics of known size to fit on the page.
*/
int w, h;
// We know the graphic is 200x200. If we didn't know this,
// we'd need to calculate it.
float maxX = 200;
float maxY = 200;
// Let's have at least 50 device units margin
float marginX = 50;
float marginY = 50;
// Add the margin to the graphic size
maxX += (2*marginX);
maxY += (2*marginY);
// Get the size of the DC in pixels
dc->GetSize(&w, &h);
// Calculate a suitable scaling factor
float scaleX=(float)(w/maxX);
float scaleY=(float)(h/maxY);
// Use x or y scaling factor, whichever fits on the DC
float actualScale = wxMin(scaleX,scaleY);
// Calculate the position on the DC for centring the graphic
float posX = (float)((w - (200*actualScale))/2.0);
float posY = (float)((h - (200*actualScale))/2.0);
// Set the scale and origin
dc->SetUserScale(actualScale, actualScale);
dc->SetDeviceOrigin( (long)posX, (long)posY );
frame->Draw(*dc);
}
void MyPrintout::DrawPageTwo(wxDC *dc)
{
/* You might use THIS code to set the printer DC to ROUGHLY reflect
* the screen text size. This page also draws lines of actual length 5cm
* on the page.
*/
// Get the logical pixels per inch of screen and printer
int ppiScreenX, ppiScreenY;
GetPPIScreen(&ppiScreenX, &ppiScreenY);
int ppiPrinterX, ppiPrinterY;
GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
// This scales the DC so that the printout roughly represents the
// the screen scaling. The text point size _should_ be the right size
// but in fact is too small for some reason. This is a detail that will
// need to be addressed at some point but can be fudged for the
// moment.
float scale = (float)((float)ppiPrinterX/(float)ppiScreenX);
// Now we have to check in case our real page size is reduced
// (e.g. because we're drawing to a print preview memory DC)
int pageWidth, pageHeight;
int w, h;
dc->GetSize(&w, &h);
GetPageSizePixels(&pageWidth, &pageHeight);
// If printer pageWidth == current DC width, then this doesn't
// change. But w might be the preview bitmap width, so scale down.
float overallScale = scale * (float)(w/(float)pageWidth);
dc->SetUserScale(overallScale, overallScale);
// Calculate conversion factor for converting millimetres into
// logical units.
// There are approx. 25.1 mm to the inch. There are ppi
// device units to the inch. Therefore 1 mm corresponds to
// ppi/25.1 device units. We also divide by the
// screen-to-printer scaling factor, because we need to
// unscale to pass logical units to DrawLine.
// Draw 50 mm by 50 mm L shape
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1));
float logUnits = (float)(50*logUnitsFactor);
dc->SetPen(* wxBLACK_PEN);
dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250);
dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits));
dc->SetFont(* wxGetApp().m_testFont);
dc->SetBackgroundMode(wxTRANSPARENT);
dc->DrawText("Some test text", 200, 200 );
// TESTING
int leftMargin = 20;
int rightMargin = 20;
int topMargin = 20;
int bottomMargin = 20;
int pageWidthMM, pageHeightMM;
GetPageSizeMM(&pageWidthMM, &pageHeightMM);
float leftMarginLogical = (float)(logUnitsFactor*leftMargin);
float topMarginLogical = (float)(logUnitsFactor*topMargin);
float bottomMarginLogical = (float)(logUnitsFactor*(pageHeightMM - bottomMargin));
float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin));
dc->SetPen(* wxRED_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical,
(long)rightMarginLogical, (long)topMarginLogical);
dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical,
(long)rightMarginLogical, (long)bottomMarginLogical);
WritePageHeader(this, dc, "A header", logUnitsFactor);
* the screen text size. This page also draws lines of actual length 5cm
* on the page.
*/
// Get the logical pixels per inch of screen and printer
int ppiScreenX, ppiScreenY;
GetPPIScreen(&ppiScreenX, &ppiScreenY);
int ppiPrinterX, ppiPrinterY;
GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
// This scales the DC so that the printout roughly represents the
// the screen scaling. The text point size _should_ be the right size
// but in fact is too small for some reason. This is a detail that will
// need to be addressed at some point but can be fudged for the
// moment.
float scale = (float)((float)ppiPrinterX/(float)ppiScreenX);
// Now we have to check in case our real page size is reduced
// (e.g. because we're drawing to a print preview memory DC)
int pageWidth, pageHeight;
int w, h;
dc->GetSize(&w, &h);
GetPageSizePixels(&pageWidth, &pageHeight);
// If printer pageWidth == current DC width, then this doesn't
// change. But w might be the preview bitmap width, so scale down.
float overallScale = scale * (float)(w/(float)pageWidth);
dc->SetUserScale(overallScale, overallScale);
// Calculate conversion factor for converting millimetres into
// logical units.
// There are approx. 25.1 mm to the inch. There are ppi
// device units to the inch. Therefore 1 mm corresponds to
// ppi/25.1 device units. We also divide by the
// screen-to-printer scaling factor, because we need to
// unscale to pass logical units to DrawLine.
// Draw 50 mm by 50 mm L shape
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1));
float logUnits = (float)(50*logUnitsFactor);
dc->SetPen(* wxBLACK_PEN);
dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250);
dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits));
dc->SetFont(* wxGetApp().m_testFont);
dc->SetBackgroundMode(wxTRANSPARENT);
dc->DrawText("Some test text", 200, 200 );
// TESTING
int leftMargin = 20;
int rightMargin = 20;
int topMargin = 20;
int bottomMargin = 20;
int pageWidthMM, pageHeightMM;
GetPageSizeMM(&pageWidthMM, &pageHeightMM);
float leftMarginLogical = (float)(logUnitsFactor*leftMargin);
float topMarginLogical = (float)(logUnitsFactor*topMargin);
float bottomMarginLogical = (float)(logUnitsFactor*(pageHeightMM - bottomMargin));
float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin));
dc->SetPen(* wxRED_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical,
(long)rightMarginLogical, (long)topMarginLogical);
dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical,
(long)rightMarginLogical, (long)bottomMarginLogical);
WritePageHeader(this, dc, "A header", logUnitsFactor);
}
// Writes a header on a page. Margin units are in millimetres.
bool WritePageHeader(wxPrintout *printout, wxDC *dc, char *text, float mmToLogical)
{
/*
static wxFont *headerFont = (wxFont *) NULL;
if (!headerFont)
{
headerFont = wxTheFontList->FindOrCreateFont(16, wxSWISS, wxNORMAL, wxBOLD);
}
dc->SetFont(headerFont);
*/
int pageWidthMM, pageHeightMM;
printout->GetPageSizeMM(&pageWidthMM, &pageHeightMM);
int leftMargin = 10;
int topMargin = 10;
int rightMargin = 10;
float leftMarginLogical = (float)(mmToLogical*leftMargin);
float topMarginLogical = (float)(mmToLogical*topMargin);
float rightMarginLogical = (float)(mmToLogical*(pageWidthMM - rightMargin));
long xExtent, yExtent;
dc->GetTextExtent(text, &xExtent, &yExtent);
float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0));
dc->DrawText(text, (long)xPos, (long)topMarginLogical);
dc->SetPen(* wxBLACK_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
(long)rightMarginLogical, (long)topMarginLogical+yExtent );
return TRUE;
static wxFont *headerFont = (wxFont *) NULL;
if (!headerFont)
{
headerFont = wxTheFontList->FindOrCreateFont(16, wxSWISS, wxNORMAL, wxBOLD);
}
dc->SetFont(headerFont);
*/
int pageWidthMM, pageHeightMM;
printout->GetPageSizeMM(&pageWidthMM, &pageHeightMM);
int leftMargin = 10;
int topMargin = 10;
int rightMargin = 10;
float leftMarginLogical = (float)(mmToLogical*leftMargin);
float topMarginLogical = (float)(mmToLogical*topMargin);
float rightMarginLogical = (float)(mmToLogical*(pageWidthMM - rightMargin));
long xExtent, yExtent;
dc->GetTextExtent(text, &xExtent, &yExtent);
float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0));
dc->DrawText(text, (long)xPos, (long)topMarginLogical);
dc->SetPen(* wxBLACK_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
(long)rightMarginLogical, (long)topMarginLogical+yExtent );
return TRUE;
}

File diff suppressed because it is too large Load Diff

View File

@ -762,10 +762,10 @@ void wxDocManager::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
if (view)
parentWin = view->GetFrame();
wxPrintData data;
wxPrintDialogData data;
wxPrintDialog printerDialog(parentWin, & data);
printerDialog.GetPrintData().SetSetupDialog(TRUE);
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
printerDialog.ShowModal();
}

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@
#include "wx/radiobox.h"
#include "wx/textctrl.h"
#include "wx/prntbase.h"
#include "wx/paper.h"
#include <math.h>
@ -245,6 +246,9 @@ wxPostScriptDC::wxPostScriptDC ()
m_signX = 1; // default x-axis left to right
m_signY = -1; // default y-axis bottom up -> top down
// Compatibility only
m_printData = * wxThePrintSetupData;
}
wxPostScriptDC::wxPostScriptDC (const wxString& file, bool interactive, wxWindow *parent)
@ -273,11 +277,11 @@ bool wxPostScriptDC::Create(const wxString& file, bool interactive, wxWindow *pa
m_isInteractive = interactive;
m_title = "";
m_filename = file;
m_printData.SetFilename(file);
#ifdef __WXMSW__
// Can only send to file in Windows
wxThePrintSetupData->SetPrinterMode(PS_FILE);
m_printData.SetPrintMode(wxPRINT_MODE_FILE);
#endif
if (m_isInteractive)
@ -292,6 +296,27 @@ bool wxPostScriptDC::Create(const wxString& file, bool interactive, wxWindow *pa
return m_ok;
}
wxPostScriptDC::wxPostScriptDC (const wxPrintData& printData)
{
m_pstream = (ofstream*) NULL;
m_currentRed = 0;
m_currentGreen = 0;
m_currentBlue = 0;
m_pageNumber = 0;
m_clipping = FALSE;
m_underlinePosition = 0.0;
m_underlineThickness = 0.0;
m_signX = 1; // default x-axis left to right
m_signY = -1; // default y-axis bottom up -> top down
m_printData = printData;
}
wxPostScriptDC::~wxPostScriptDC ()
{
if (m_pstream) delete m_pstream;
@ -302,6 +327,7 @@ bool wxPostScriptDC::Ok() const
return m_ok;
}
// This dialog is deprecated now: use wxGenericPrintDialog or the printing framework
bool wxPostScriptDC::PrinterDialog(wxWindow *parent)
{
wxPostScriptPrintDialog dialog( parent, _("Printer Settings"), wxPoint(150, 150), wxSize(400, 400),
@ -310,13 +336,13 @@ bool wxPostScriptDC::PrinterDialog(wxWindow *parent)
if (!m_ok) return FALSE;
if ((m_filename == "") &&
(wxThePrintSetupData->GetPrinterMode() == PS_PREVIEW ||
wxThePrintSetupData->GetPrinterMode() == PS_PRINTER))
if ((m_printData.GetFilename() == "") &&
(m_printData.GetPrintMode() == wxPRINT_MODE_PREVIEW ||
m_printData.GetPrintMode() == wxPRINT_MODE_PRINTER))
{
// steve, 05.09.94
#ifdef __VMS__
wxThePrintSetupData->SetPrinterFile("preview");
m_printData.SetFilename("preview");
#else
// For PS_PRINTER action this depends on a Unix-style print spooler
// since the wx_printer_file can be destroyed during a session
@ -326,15 +352,14 @@ bool wxPostScriptDC::PrinterDialog(wxWindow *parent)
char tmp[256];
strcpy (tmp, "/tmp/preview_");
strcat (tmp, userId);
wxThePrintSetupData->SetPrinterFile(tmp);
m_printData.SetFilename(tmp);
#endif
char tmp2[256];
strcpy(tmp2, wxThePrintSetupData->GetPrinterFile());
strcpy(tmp2, m_printData.GetFilename());
strcat (tmp2, ".ps");
wxThePrintSetupData->SetPrinterFile(tmp2);
m_filename = tmp2;
m_printData.SetFilename(tmp2);
}
else if ((m_filename == "") && (wxThePrintSetupData->GetPrinterMode() == PS_FILE))
else if ((m_printData.GetFilename() == "") && (m_printData.GetPrintMode() == wxPRINT_MODE_FILE))
{
wxString file = wxSaveFileSelector (_("PostScript"), "ps");
if ( file.IsEmpty() )
@ -343,8 +368,7 @@ bool wxPostScriptDC::PrinterDialog(wxWindow *parent)
return FALSE;
}
wxThePrintSetupData->SetPrinterFile(file);
m_filename = file;
m_printData.SetFilename(file);
m_ok = TRUE;
}
@ -1206,18 +1230,16 @@ void wxPostScriptDC::SetDeviceOrigin( long x, long y )
void wxPostScriptDC::GetSize(int* width, int* height) const
{
const char *paperType = wxThePrintSetupData->GetPaperName();
wxPaperSize id = m_printData.GetPaperId();
if (!paperType) paperType = _("A4 210 x 297 mm");
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(id);
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType);
if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm"));
if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
if (paper)
{
if (width) *width = paper->widthPixels;
if (height) *height = paper->heightPixels;
if (width) *width = paper->GetSizeDeviceUnits().x;
if (height) *height = paper->GetSizeDeviceUnits().y;
}
else
{
@ -1226,28 +1248,52 @@ void wxPostScriptDC::GetSize(int* width, int* height) const
}
}
void wxPostScriptDC::GetSizeMM(int *width, int *height) const
{
wxPaperSize id = m_printData.GetPaperId();
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(id);
if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
if (paper)
{
if (width) *width = paper->GetWidth() / 10;
if (height) *height = paper->GetHeight() / 10;
}
else
{
if (width) *width = 210;
if (height) *height = 297;
}
}
// Resolution in pixels per logical inch
wxSize wxPostScriptDC::GetPPI(void) const
{
return wxSize(72, 72);
}
bool wxPostScriptDC::StartDoc (const wxString& message)
{
wxCHECK_MSG( m_ok, FALSE, "invalid postscript dc" );
if (m_filename == "")
if (m_printData.GetFilename() == "")
{
m_filename = wxGetTempFileName("ps");
wxThePrintSetupData->SetPrinterFile((char *)(const char *)m_filename);
wxString filename = wxGetTempFileName("ps");
m_printData.SetFilename(filename);
m_ok = TRUE;
}
else
{
wxThePrintSetupData->SetPrinterFile((char *)(const char *)m_filename);
}
m_pstream = new ofstream (wxThePrintSetupData->GetPrinterFile());
m_pstream = new ofstream (m_printData.GetFilename());
if (!m_pstream || !m_pstream->good())
{
wxMessageBox (_("Cannot open file!"), _("Error"), wxOK);
m_ok = FALSE;
return FALSE;
wxMessageBox (_("Cannot open file!"), _("Error"), wxOK);
m_ok = FALSE;
return FALSE;
}
m_ok = TRUE;
@ -1309,12 +1355,16 @@ void wxPostScriptDC::EndDoc ()
long wx_printer_translate_x, wx_printer_translate_y;
double wx_printer_scale_x, wx_printer_scale_y;
wxThePrintSetupData->GetPrinterTranslation(&wx_printer_translate_x, &wx_printer_translate_y);
wxThePrintSetupData->GetPrinterScaling(&wx_printer_scale_x, &wx_printer_scale_y);
if (wxThePrintSetupData->GetPrinterOrientation() == PS_LANDSCAPE)
wx_printer_translate_x = m_printData.GetPrinterTranslateX();
wx_printer_translate_y = m_printData.GetPrinterTranslateY();
wx_printer_scale_x = m_printData.GetPrinterScaleX();
wx_printer_scale_y = m_printData.GetPrinterScaleY();
if (m_printData.GetOrientation() == wxLANDSCAPE)
{
*m_pstream << "%%Orientation: Landscape\n";
*m_pstream << "%%Orientation: Landscape\n";
}
else
{
@ -1329,7 +1379,7 @@ void wxPostScriptDC::EndDoc ()
long ury = (long) ((YLOG2DEV(m_maxY)+wx_printer_translate_y)*wx_printer_scale_y);
// If we're landscape, our sense of "x" and "y" is reversed.
if (wxThePrintSetupData->GetPrinterOrientation() == PS_LANDSCAPE)
if (m_printData.GetOrientation() == wxLANDSCAPE)
{
long tmp;
tmp = llx; llx = lly; lly = tmp;
@ -1378,46 +1428,53 @@ void wxPostScriptDC::EndDoc ()
char *tmp_file = wxGetTempFileName("ps");
// Paste header Before wx_printer_file
wxConcatFiles (header_file, wxThePrintSetupData->GetPrinterFile(), tmp_file);
wxConcatFiles (header_file, m_printData.GetFilename(), tmp_file);
wxRemoveFile (header_file);
wxRemoveFile (wxThePrintSetupData->GetPrinterFile());
wxRenameFile(tmp_file, wxThePrintSetupData->GetPrinterFile());
wxRemoveFile (m_printData.GetFilename());
wxRenameFile(tmp_file, m_printData.GetFilename());
#if defined(__X__) || defined(__WXGTK__)
if (m_ok)
{
switch (wxThePrintSetupData->GetPrinterMode()) {
case PS_PREVIEW:
wxString previewCommand(m_printData.GetPreviewCommand());
wxString printerCommand(m_printData.GetPrinterCommand());
wxString printerOptions(m_printData.GetPrinterOptions());
wxString filename(m_printData.GetFilename());
switch (m_printData.GetPrintMode()) {
case wxPRINT_MODE_PREVIEW:
{
char *argv[3];
argv[0] = wxThePrintSetupData->GetPrintPreviewCommand();
argv[1] = wxThePrintSetupData->GetPrinterFile();
argv[2] = (char *) NULL;
wxExecute (argv, TRUE);
wxRemoveFile(wxThePrintSetupData->GetPrinterFile());
argv[0] = (char*) (const char*) previewCommand;
argv[1] = (char*) (const char*) filename;
argv[2] = (char*) (char *) NULL;
wxExecute (argv, TRUE);
wxRemoveFile(m_printData.GetFilename());
}
break;
case PS_PRINTER:
case wxPRINT_MODE_PRINTER:
{
char *argv[4];
int argc = 0;
argv[argc++] = wxThePrintSetupData->GetPrinterCommand();
argv[argc++] = (char*) (const char*) printerCommand;
// !SM! If we simply assign to argv[1] here, if printer options
// are blank, we get an annoying and confusing message from lpr.
char * opts = wxThePrintSetupData->GetPrinterOptions();
char * opts = (char*) (const char*) printerOptions;
if (opts && *opts)
argv[argc++] = opts;
argv[argc++] = wxThePrintSetupData->GetPrinterFile();
argv[argc++] = (char*) (const char*) filename;
argv[argc++] = (char *) NULL;
wxExecute (argv, TRUE);
wxRemoveFile(wxThePrintSetupData->GetPrinterFile());
wxExecute (argv, TRUE);
wxRemoveFile(filename);
}
break;
case PS_FILE:
case wxPRINT_MODE_FILE:
case wxPRINT_MODE_NONE:
break;
}
}
@ -1446,10 +1503,14 @@ void wxPostScriptDC::StartPage ()
// Output scaling
long translate_x, translate_y;
double scale_x, scale_y;
wxThePrintSetupData->GetPrinterTranslation(&translate_x, &translate_y);
wxThePrintSetupData->GetPrinterScaling(&scale_x, &scale_y);
if (wxThePrintSetupData->GetPrinterOrientation() == PS_LANDSCAPE)
translate_x = m_printData.GetPrinterTranslateX();
translate_y = m_printData.GetPrinterTranslateY();
scale_x = m_printData.GetPrinterScaleX();
scale_y = m_printData.GetPrinterScaleY();
if (m_printData.GetOrientation() == wxLANDSCAPE)
{
translate_y -= m_maxY;
*m_pstream << "90 rotate\n";
@ -1621,7 +1682,8 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y,
/* get the directory of the AFM files */
char afmName[256];
afmName[0] = 0;
if (wxGetAFMPath()) strcpy( afmName, wxGetAFMPath() );
wxString fmPath(m_printData.GetFontMetricPath());
if (fmPath != "") strcpy( afmName, (const char*) fmPath );
/* 2. open and process the file
/ a short explanation of the AFM format:
@ -1794,28 +1856,6 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y,
#endif
}
void wxPostScriptDC::GetSizeMM(long *width, long *height) const
{
const char *paperType = wxThePrintSetupData->GetPaperName();
if (!paperType) paperType = _("A4 210 x 297 mm");
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType);
if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm"));
if (paper)
{
if (width) *width = paper->widthMM;
if (height) *height = paper->heightMM;
}
else
{
if (width) *width = 210;
if (height) *height = 297;
}
}
// Determine the Default Postscript Previewer
// available on the platform
#if defined(__SUN__) && defined(__XVIEW__)
@ -1898,7 +1938,7 @@ wxPostScriptPrintDialog::wxPostScriptPrintDialog (wxWindow *parent, const wxStri
if (wxThePrintSetupData->GetPrintPreviewCommand() == NULL)
wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG);
wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->previewCommand);
// wxGetResource ("wxWindows", "PSView", &wxThePrintSetupData->m_previewCommand);
features = (wxThePrintSetupData->GetPrintPreviewCommand() &&
*wxThePrintSetupData->GetPrintPreviewCommand()) ? 3 : 2;
@ -1959,17 +1999,17 @@ int wxPostScriptPrintDialog::ShowModal ()
wxRadioBox *radio0 = (wxRadioBox *)FindWindow(wxID_PRINTER_ORIENTATION);
wxRadioBox *radio1 = (wxRadioBox *)FindWindow(wxID_PRINTER_MODES);
StringToDouble (WXSTRINGCAST text1->GetValue (), &wxThePrintSetupData->printerScaleX);
StringToDouble (WXSTRINGCAST text2->GetValue (), &wxThePrintSetupData->printerScaleY);
StringToLong (WXSTRINGCAST text3->GetValue (), &wxThePrintSetupData->printerTranslateX);
StringToLong (WXSTRINGCAST text4->GetValue (), &wxThePrintSetupData->printerTranslateY);
StringToDouble (WXSTRINGCAST text1->GetValue (), &wxThePrintSetupData->m_printerScaleX);
StringToDouble (WXSTRINGCAST text2->GetValue (), &wxThePrintSetupData->m_printerScaleY);
StringToLong (WXSTRINGCAST text3->GetValue (), &wxThePrintSetupData->m_printerTranslateX);
StringToLong (WXSTRINGCAST text4->GetValue (), &wxThePrintSetupData->m_printerTranslateY);
#ifdef __X__
// wxThePrintSetupData->SetPrinterOptions(WXSTRINGCAST text0->GetValue ());
// wxThePrintSetupData->SetPrinterCommand(WXSTRINGCAST text_prt->GetValue ());
#endif
wxThePrintSetupData->SetPrinterOrientation((radio0->GetSelection() == 1 ? PS_LANDSCAPE : PS_PORTRAIT));
wxThePrintSetupData->SetPrinterOrientation((radio0->GetSelection() == 1 ? wxLANDSCAPE : wxPORTRAIT));
// C++ wants this
switch ( radio1->GetSelection() ) {
@ -1986,22 +2026,22 @@ int wxPostScriptPrintDialog::ShowModal ()
// PostScript printer settings
// RETAINED FOR BACKWARD COMPATIBILITY
void wxSetPrinterCommand(const char *cmd)
void wxSetPrinterCommand(const wxString& cmd)
{
wxThePrintSetupData->SetPrinterCommand(cmd);
}
void wxSetPrintPreviewCommand(const char *cmd)
void wxSetPrintPreviewCommand(const wxString& cmd)
{
wxThePrintSetupData->SetPrintPreviewCommand(cmd);
}
void wxSetPrinterOptions(const char *flags)
void wxSetPrinterOptions(const wxString& flags)
{
wxThePrintSetupData->SetPrinterOptions(flags);
}
void wxSetPrinterFile(const char *f)
void wxSetPrinterFile(const wxString& f)
{
wxThePrintSetupData->SetPrinterFile(f);
}
@ -2027,28 +2067,28 @@ void wxSetPrinterMode(int mode)
wxThePrintSetupData->SetPrinterMode(mode);
}
void wxSetAFMPath(const char *f)
void wxSetAFMPath(const wxString& f)
{
wxThePrintSetupData->SetAFMPath(f);
}
// Get current values
char *wxGetPrinterCommand()
wxString wxGetPrinterCommand()
{
return wxThePrintSetupData->GetPrinterCommand();
}
char *wxGetPrintPreviewCommand()
wxString wxGetPrintPreviewCommand()
{
return wxThePrintSetupData->GetPrintPreviewCommand();
}
char *wxGetPrinterOptions()
wxString wxGetPrinterOptions()
{
return wxThePrintSetupData->GetPrinterOptions();
}
char *wxGetPrinterFile()
wxString wxGetPrinterFile()
{
return wxThePrintSetupData->GetPrinterFile();
}
@ -2073,7 +2113,7 @@ int wxGetPrinterMode()
return wxThePrintSetupData->GetPrinterMode();
}
char *wxGetAFMPath()
wxString wxGetAFMPath()
{
return wxThePrintSetupData->GetAFMPath();
}
@ -2084,200 +2124,17 @@ char *wxGetAFMPath()
wxPrintSetupData::wxPrintSetupData()
{
printerCommand = (char *) NULL;
previewCommand = (char *) NULL;
printerFlags = (char *) NULL;
printerOrient = PS_PORTRAIT;
printerScaleX = (double)1.0;
printerScaleY = (double)1.0;
printerTranslateX = 0;
printerTranslateY = 0;
// 1 = Preview, 2 = print to file, 3 = send to printer
printerMode = 3;
afmPath = (char *) NULL;
paperName = (char *) NULL;
printColour = TRUE;
printerFile = (char *) NULL;
m_printerOrient = wxPORTRAIT;
m_printerScaleX = (double)1.0;
m_printerScaleY = (double)1.0;
m_printerTranslateX = 0;
m_printerTranslateY = 0;
m_printerMode = wxPRINT_MODE_FILE;
m_printColour = TRUE;
}
wxPrintSetupData::~wxPrintSetupData()
{
if (printerCommand)
delete[] printerCommand;
if (previewCommand)
delete[] previewCommand;
if (printerFlags)
delete[] printerFlags;
if (afmPath)
delete[] afmPath;
if (paperName)
delete[] paperName;
if (printerFile)
delete[] printerFile;
}
void wxPrintSetupData::SetPrinterCommand(const char *cmd)
{
if (cmd == printerCommand)
return;
if (printerCommand)
delete[] printerCommand;
if (cmd)
printerCommand = copystring(cmd);
else
printerCommand = (char *) NULL;
}
void wxPrintSetupData::SetPrintPreviewCommand(const char *cmd)
{
if (cmd == previewCommand)
return;
if (previewCommand)
delete[] previewCommand;
if (cmd)
previewCommand = copystring(cmd);
else
previewCommand = (char *) NULL;
}
void wxPrintSetupData::SetPaperName(const char *name)
{
if (name == paperName)
return;
if (paperName)
delete[] paperName;
if (name)
paperName = copystring(name);
else
paperName = (char *) NULL;
}
void wxPrintSetupData::SetPrinterOptions(const char *flags)
{
if (printerFlags == flags)
return;
if (printerFlags)
delete[] printerFlags;
if (flags)
printerFlags = copystring(flags);
else
printerFlags = (char *) NULL;
}
void wxPrintSetupData::SetPrinterFile(const char *f)
{
if (f == printerFile)
return;
if (printerFile)
delete[] printerFile;
if (f)
printerFile = copystring(f);
else
printerFile = (char *) NULL;
}
void wxPrintSetupData::SetPrinterOrientation(int orient)
{
printerOrient = orient;
}
void wxPrintSetupData::SetPrinterScaling(double x, double y)
{
printerScaleX = x;
printerScaleY = y;
}
void wxPrintSetupData::SetPrinterTranslation(long x, long y)
{
printerTranslateX = x;
printerTranslateY = y;
}
// 1 = Preview, 2 = print to file, 3 = send to printer
void wxPrintSetupData::SetPrinterMode(int mode)
{
printerMode = mode;
}
void wxPrintSetupData::SetAFMPath(const char *f)
{
if (f == afmPath)
return;
if (afmPath)
delete[] afmPath;
if (f)
afmPath = copystring(f);
else
afmPath = (char *) NULL;
}
void wxPrintSetupData::SetColour(bool col)
{
printColour = col;
}
// Get current values
char *wxPrintSetupData::GetPrinterCommand()
{
return printerCommand;
}
char *wxPrintSetupData::GetPrintPreviewCommand()
{
return previewCommand;
}
char *wxPrintSetupData::GetPrinterOptions()
{
return printerFlags;
}
char *wxPrintSetupData::GetPrinterFile()
{
return printerFile;
}
char *wxPrintSetupData::GetPaperName()
{
return paperName;
}
int wxPrintSetupData::GetPrinterOrientation()
{
return printerOrient;
}
void wxPrintSetupData::GetPrinterScaling(double *x, double *y)
{
*x = printerScaleX;
*y = printerScaleY;
}
void wxPrintSetupData::GetPrinterTranslation(long *x, long *y)
{
*x = printerTranslateX;
*y = printerTranslateY;
}
int wxPrintSetupData::GetPrinterMode()
{
return printerMode;
}
char *wxPrintSetupData::GetAFMPath()
{
return afmPath;
}
bool wxPrintSetupData::GetColour()
{
return printColour;
}
void wxPrintSetupData::operator=(wxPrintSetupData& data)
@ -2300,6 +2157,22 @@ void wxPrintSetupData::operator=(wxPrintSetupData& data)
SetColour(data.GetColour());
}
// Initialize from a wxPrintData object (wxPrintData should now be used instead of wxPrintSetupData).
void wxPrintSetupData::operator=(const wxPrintData& data)
{
SetPrinterCommand(data.GetPrinterCommand());
SetPrintPreviewCommand(data.GetPreviewCommand());
SetPrinterOptions(data.GetPrinterOptions());
SetPrinterTranslation(data.GetPrinterTranslateX(), data.GetPrinterTranslateY());
SetPrinterScaling(data.GetPrinterScaleX(), data.GetPrinterScaleY());
SetPrinterOrientation(data.GetOrientation());
SetPrinterMode((int) data.GetPrintMode());
SetAFMPath(data.GetFontMetricPath());
SetPaperName(wxThePrintPaperDatabase->ConvertIdToName(data.GetPaperId()));
SetColour(data.GetColour());
SetPrinterFile(data.GetFilename());
}
void wxInitializePrintSetupData(bool init)
{
if (init)
@ -2307,9 +2180,9 @@ void wxInitializePrintSetupData(bool init)
wxThePrintSetupData = new wxPrintSetupData;
wxThePrintSetupData->SetPrintPreviewCommand(PS_VIEWER_PROG);
wxThePrintSetupData->SetPrinterOrientation(PS_PORTRAIT);
wxThePrintSetupData->SetPrinterMode(PS_PREVIEW);
wxThePrintSetupData->SetPaperName(_("A4 210 x 297 mm"));
wxThePrintSetupData->SetPrinterOrientation(wxPORTRAIT);
wxThePrintSetupData->SetPrinterMode(wxPRINT_MODE_PREVIEW);
wxThePrintSetupData->SetPaperName(_("A4 sheet, 210 x 297 mm"));
// Could have a .ini file to read in some defaults
// - and/or use environment variables, e.g. WXWIN
@ -2321,12 +2194,12 @@ void wxInitializePrintSetupData(bool init)
#ifdef __WXMSW__
wxThePrintSetupData->SetPrinterCommand("print");
wxThePrintSetupData->SetAFMPath("c:\\windows\\system\\");
wxThePrintSetupData->SetPrinterOptions(NULL);
wxThePrintSetupData->SetPrinterOptions("");
#endif
#if !defined(__VMS__) && !defined(__WXMSW__)
wxThePrintSetupData->SetPrinterCommand("lpr");
wxThePrintSetupData->SetPrinterOptions((char *) NULL);
wxThePrintSetupData->SetAFMPath((char *) NULL);
wxThePrintSetupData->SetPrinterOptions("");
wxThePrintSetupData->SetAFMPath("");
#endif
}
else

View File

@ -1417,9 +1417,10 @@ void wxGenericGrid::OnSelectCellImplementation(wxDC *dc, int row, int col)
// Probably because of the SetValue?? JS.
// 2) Arrrrrgh. This isn't needed anywhere,
// of course. One hour of debugging... RR.
// Put back for Motif only on advice of Michael Bedward
#ifdef __WXMOTIF__
HighlightCell(dc);
#endif // motif
#endif
dc->DestroyClippingRegion();

View File

@ -34,6 +34,7 @@
#include "wx/dcprint.h"
#include "wx/printdlg.h"
#include "wx/generic/prntdlgg.h"
#include "wx/paper.h"
#include <stdlib.h>
@ -43,11 +44,11 @@ IMPLEMENT_CLASS(wxPostScriptPrintPreview, wxPrintPreviewBase)
#endif
/*
* Printer
*/
wxPostScriptPrinter::wxPostScriptPrinter(wxPrintData *data):
wxPrinterBase(data)
* Printer
*/
wxPostScriptPrinter::wxPostScriptPrinter(wxPrintDialogData *data):
wxPrinterBase(data)
{
}
@ -57,167 +58,182 @@ wxPostScriptPrinter::~wxPostScriptPrinter(void)
bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
{
sm_abortIt = FALSE;
sm_abortWindow = (wxWindow *) NULL;
if (!printout)
return FALSE;
sm_abortIt = FALSE;
sm_abortWindow = (wxWindow *) NULL;
printout->SetIsPreview(FALSE);
printout->OnPreparePrinting();
if (!printout)
return FALSE;
printout->SetIsPreview(FALSE);
printout->OnPreparePrinting();
// Get some parameters from the printout, if defined
int fromPage, toPage;
int minPage, maxPage;
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
if (maxPage == 0)
return FALSE;
m_printDialogData.SetMinPage(minPage);
m_printDialogData.SetMaxPage(maxPage);
if (fromPage != 0)
m_printDialogData.SetFromPage(fromPage);
if (toPage != 0)
m_printDialogData.SetToPage(toPage);
// Get some parameters from the printout, if defined
int fromPage, toPage;
int minPage, maxPage;
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
if (maxPage == 0)
return FALSE;
m_printData.SetMinPage(minPage);
m_printData.SetMaxPage(maxPage);
if (fromPage != 0)
m_printData.SetFromPage(fromPage);
if (toPage != 0)
m_printData.SetToPage(toPage);
if (minPage != 0)
{
m_printData.EnablePageNumbers(TRUE);
if (m_printData.GetFromPage() < m_printData.GetMinPage())
m_printData.SetFromPage(m_printData.GetMinPage());
else if (m_printData.GetFromPage() > m_printData.GetMaxPage())
m_printData.SetFromPage(m_printData.GetMaxPage());
if (m_printData.GetToPage() > m_printData.GetMaxPage())
m_printData.SetToPage(m_printData.GetMaxPage());
else if (m_printData.GetToPage() < m_printData.GetMinPage())
m_printData.SetToPage(m_printData.GetMinPage());
}
else
m_printData.EnablePageNumbers(FALSE);
// Create a suitable device context
wxDC *dc = (wxDC *) NULL;
if (prompt)
{
wxGenericPrintDialog dialog(parent, & m_printData);
if (dialog.ShowModal() == wxID_OK)
{
dc = dialog.GetPrintDC();
m_printData = dialog.GetPrintData();
}
}
else
{
dc = new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
}
// May have pressed cancel.
if (!dc || !dc->Ok())
{
if (dc) delete dc;
return FALSE;
}
int logPPIScreenX = 0;
int logPPIScreenY = 0;
int logPPIPrinterX = 0;
int logPPIPrinterY = 0;
logPPIScreenX = 100;
logPPIScreenY = 100;
/*
// Correct values for X/PostScript?
logPPIPrinterX = 100;
logPPIPrinterY = 100;
*/
logPPIPrinterX = 72;
logPPIPrinterY = 72;
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
// Set printout parameters
printout->SetDC(dc);
int w, h;
long ww, hh;
dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h);
dc->GetSizeMM(&ww, &hh);
printout->SetPageSizeMM((int)ww, (int)hh);
// Create an abort window
wxBeginBusyCursor();
printout->OnBeginPrinting();
bool keepGoing = TRUE;
int copyCount;
for (copyCount = 1; copyCount <= m_printData.GetNoCopies(); copyCount ++)
{
if (!printout->OnBeginDocument(m_printData.GetFromPage(), m_printData.GetToPage()))
if (minPage != 0)
{
wxEndBusyCursor();
wxMessageBox(_("Could not start printing."), _("Print Error"), wxOK, parent);
break;
m_printDialogData.EnablePageNumbers(TRUE);
if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage())
m_printDialogData.SetFromPage(m_printDialogData.GetMinPage());
else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage())
m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage());
if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage())
m_printDialogData.SetToPage(m_printDialogData.GetMaxPage());
else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage())
m_printDialogData.SetToPage(m_printDialogData.GetMinPage());
}
if (sm_abortIt)
break;
else
m_printDialogData.EnablePageNumbers(FALSE);
int pn;
for (pn = m_printData.GetFromPage(); keepGoing && (pn <= m_printData.GetToPage()) && printout->HasPage(pn);
pn++)
// Create a suitable device context
wxDC *dc = (wxDC *) NULL;
if (prompt)
{
if (sm_abortIt)
{
keepGoing = FALSE;
break;
}
else
{
dc->StartPage();
printout->OnPrintPage(pn);
dc->EndPage();
}
dc = PrintDialog(parent);
if (!dc)
return FALSE;
}
printout->OnEndDocument();
}
printout->OnEndPrinting();
wxEndBusyCursor();
delete dc;
return TRUE;
else
{
dc = new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
}
// May have pressed cancel.
if (!dc || !dc->Ok())
{
if (dc) delete dc;
return FALSE;
}
int logPPIScreenX = 0;
int logPPIScreenY = 0;
int logPPIPrinterX = 0;
int logPPIPrinterY = 0;
logPPIScreenX = 100;
logPPIScreenY = 100;
/*
// Correct values for X/PostScript?
logPPIPrinterX = 100;
logPPIPrinterY = 100;
*/
logPPIPrinterX = 72;
logPPIPrinterY = 72;
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
// Set printout parameters
printout->SetDC(dc);
int w, h;
dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h);
dc->GetSizeMM(&w, &h);
printout->SetPageSizeMM((int)w, (int)h);
// Create an abort window
wxBeginBusyCursor();
printout->OnBeginPrinting();
bool keepGoing = TRUE;
int copyCount;
for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
{
if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
{
wxEndBusyCursor();
wxMessageBox(_("Could not start printing."), _("Print Error"), wxOK, parent);
break;
}
if (sm_abortIt)
break;
int pn;
for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
pn++)
{
if (sm_abortIt)
{
keepGoing = FALSE;
break;
}
else
{
dc->StartPage();
printout->OnPrintPage(pn);
dc->EndPage();
}
}
printout->OnEndDocument();
}
printout->OnEndPrinting();
wxEndBusyCursor();
delete dc;
return TRUE;
}
bool wxPostScriptPrinter::PrintDialog(wxWindow *parent)
wxDC* wxPostScriptPrinter::PrintDialog(wxWindow *parent)
{
wxGenericPrintDialog dialog(parent, & m_printData);
return (dialog.ShowModal() == wxID_OK);
wxDC* dc = (wxDC*) NULL;
wxGenericPrintDialog* dialog = new wxGenericPrintDialog(parent, & m_printDialogData);
int ret = dialog->ShowModal() ;
if (ret == wxID_OK)
{
dc = dialog->GetPrintDC();
m_printDialogData = dialog->GetPrintDialogData();
}
dialog->Destroy();
return dc;
}
bool wxPostScriptPrinter::Setup(wxWindow *parent)
{
wxGenericPrintDialog dialog(parent, & m_printData);
dialog.GetPrintData().SetSetupDialog(TRUE);
return (dialog.ShowModal() == wxID_OK);
wxGenericPrintDialog* dialog = new wxGenericPrintDialog(parent, & m_printDialogData);
dialog->GetPrintDialogData().SetSetupDialog(TRUE);
int ret = dialog->ShowModal();
if (ret == wxID_OK)
{
m_printDialogData = dialog->GetPrintDialogData();
}
dialog->Destroy();
return (ret == wxID_OK);
}
/*
* Print preview
*/
* Print preview
*/
wxPostScriptPrintPreview::wxPostScriptPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data):
wxPrintPreviewBase(printout, printoutForPrinting, data)
wxPostScriptPrintPreview::wxPostScriptPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintDialogData *data):
wxPrintPreviewBase(printout, printoutForPrinting, data)
{
// Have to call it here since base constructor can't call it
DetermineScaling();
// Have to call it here since base constructor can't call it
DetermineScaling();
}
wxPostScriptPrintPreview::~wxPostScriptPrintPreview(void)
@ -226,47 +242,50 @@ wxPostScriptPrintPreview::~wxPostScriptPrintPreview(void)
bool wxPostScriptPrintPreview::Print(bool interactive)
{
if (!m_printPrintout)
return FALSE;
wxPostScriptPrinter printer(&m_printData);
return printer.Print(m_previewFrame, m_printPrintout, interactive);
if (!m_printPrintout)
return FALSE;
wxPostScriptPrinter printer(& m_printDialogData);
return printer.Print(m_previewFrame, m_printPrintout, interactive);
}
void wxPostScriptPrintPreview::DetermineScaling(void)
{
const char *paperType = wxThePrintSetupData->GetPaperName();
if (!paperType)
paperType = _("A4 210 x 297 mm");
wxPaperSize paperType = m_printDialogData.GetPrintData().GetPaperId();
if (paperType == wxPAPER_NONE)
paperType = wxPAPER_NONE;
wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType);
if (!paper)
paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm"));
paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4);
if (paper)
{
m_previewPrintout->SetPPIScreen(100, 100);
// m_previewPrintout->SetPPIPrinter(100, 100);
m_previewPrintout->SetPPIPrinter(72, 72);
m_previewPrintout->SetPPIScreen(100, 100);
// m_previewPrintout->SetPPIPrinter(100, 100);
m_previewPrintout->SetPPIPrinter(72, 72);
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());
wxSize sizeTenthsMM(paper->GetSize());
wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10);
// If in landscape mode, we need to swap the width and height.
if ( m_printData.GetOrientation() == wxLANDSCAPE )
{
m_pageWidth = paper->heightPixels;
m_pageHeight = paper->widthPixels;
m_previewPrintout->SetPageSizeMM(paper->heightMM, paper->widthMM);
m_previewPrintout->SetPageSizePixels(paper->heightPixels, paper->widthPixels);
}
else
{
m_pageWidth = paper->widthPixels;
m_pageHeight = paper->heightPixels;
m_previewPrintout->SetPageSizeMM(paper->widthMM, paper->heightMM);
m_previewPrintout->SetPageSizePixels(paper->widthPixels, paper->heightPixels);
}
// At 100%, the page should look about page-size on the screen.
m_previewScale = (float)0.8;
// m_previewScale = (float)((float)screenWidth/(float)printerWidth);
// m_previewScale = previewScale * (float)((float)screenXRes/(float)printerYRes);
// If in landscape mode, we need to swap the width and height.
if ( m_printDialogData.GetPrintData().GetOrientation() == wxLANDSCAPE )
{
m_pageWidth = sizeDevUnits.y;
m_pageHeight = sizeDevUnits.x;
m_previewPrintout->SetPageSizeMM(sizeMM.y, sizeMM.x);
m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
}
else
{
m_pageWidth = sizeDevUnits.x;
m_pageHeight = sizeDevUnits.y;
m_previewPrintout->SetPageSizeMM(sizeMM.x, sizeMM.y);
m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
}
// At 100%, the page should look about page-size on the screen.
m_previewScale = (float)0.8;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -39,6 +39,7 @@ LIB_CPP_SRC=\
common/dbtable.cpp \
common/prntbase.cpp \
common/serbase.cpp \
common/paper.cpp \
common/string.cpp \
common/textfile.cpp \
common/time.cpp \

View File

@ -194,13 +194,20 @@ void wxDC::GetSize( int* width, int* height ) const
if (height) *height = m_maxY-m_minY;
}
void wxDC::GetSizeMM( long* width, long* height ) const
void wxDC::GetSizeMM( int* width, int* height ) const
{
int w = 0;
int h = 0;
GetSize( &w, &h );
if (width) *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
if (height) *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
if (width) *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
if (height) *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
}
// Resolution in pixels per logical inch
wxSize wxDC::GetPPI(void) const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
void wxDC::SetTextForeground( const wxColour &col )

View File

@ -1370,6 +1370,11 @@ void wxWindowDC::DrawSpline( wxList *points )
wx_spline_draw_point_array( this );
}
// Resolution in pixels per logical inch
wxSize wxWindowDC::GetPPI(void) const
{
return wxSize(100, 100);
}
//-----------------------------------------------------------------------------
// wxPaintDC

View File

@ -194,13 +194,20 @@ void wxDC::GetSize( int* width, int* height ) const
if (height) *height = m_maxY-m_minY;
}
void wxDC::GetSizeMM( long* width, long* height ) const
void wxDC::GetSizeMM( int* width, int* height ) const
{
int w = 0;
int h = 0;
GetSize( &w, &h );
if (width) *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
if (height) *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
if (width) *width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
if (height) *height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
}
// Resolution in pixels per logical inch
wxSize wxDC::GetPPI(void) const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
void wxDC::SetTextForeground( const wxColour &col )

View File

@ -1370,6 +1370,11 @@ void wxWindowDC::DrawSpline( wxList *points )
wx_spline_draw_point_array( this );
}
// Resolution in pixels per logical inch
wxSize wxWindowDC::GetPPI(void) const
{
return wxSize(100, 100);
}
//-----------------------------------------------------------------------------
// wxPaintDC

View File

@ -35,6 +35,7 @@ LIB_CPP_SRC=\
common/mimetype.cpp \
common/module.cpp \
common/object.cpp \
common/paper.cpp \
common/prntbase.cpp \
common/resource.cpp \
common/serbase.cpp \

View File

@ -29,7 +29,9 @@
#include "wx/module.h"
#include "wx/memory.h"
#if wxUSE_THREADS
#include "wx/thread.h"
#endif
#if wxUSE_WX_RESOURCES
#include "wx/resource.h"
@ -297,11 +299,13 @@ int wxApp::MainLoop()
{
if (!ProcessIdle())
{
#if wxUSE_THREADS
// leave the main loop to give other threads a chance to
// perform their GUI work
wxMutexGuiLeave();
wxUsleep(20);
wxMutexGuiEnter();
#endif
}
}
@ -509,8 +513,9 @@ bool wxApp::OnInitGui()
argv);
if (!dpy) {
wxString className(wxTheApp->GetClassName());
wxLogError(_("wxWindows could not open display for '%s': exiting."),
wxTheApp->GetClassName());
(const char*) className);
exit(-1);
}
m_initialDisplay = (WXDisplay*) dpy;

View File

@ -197,7 +197,7 @@ bool wxBitmap::LoadFile(const wxString& filename, long type)
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
wxLogWarning("%s: no bitmap handler for type %d defined.", (const char*) filename, type);
return FALSE;
}
@ -214,7 +214,7 @@ bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
wxLogWarning("no data bitmap handler for type %d defined.", type);
return FALSE;
}
@ -790,7 +790,7 @@ void wxBitmap::InitStandardHandlers()
AddHandler(new wxXBMFileHandler);
AddHandler(new wxXBMDataHandler);
// XPM is considered standard for Moif, although it can be omitted if absolutely
// XPM is considered standard for Motif, although it can be omitted if absolutely
// necessary.
#if wxUSE_XPM
AddHandler(new wxXPMFileHandler);

View File

@ -213,15 +213,22 @@ void wxDC::GetSize( int* width, int* height ) const
*height = m_maxY-m_minY;
};
void wxDC::GetSizeMM( long* width, long* height ) const
void wxDC::GetSizeMM( int* width, int* height ) const
{
int w = 0;
int h = 0;
GetSize( &w, &h );
*width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
*height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
*width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
*height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
};
// Resolution in pixels per logical inch
wxSize wxDC::GetPPI(void) const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
void wxDC::SetTextForeground( const wxColour &col )
{
if (!Ok()) return;

View File

@ -2323,6 +2323,12 @@ void wxWindowDC::DrawSpline( wxList *points )
wx_spline_draw_point_array( this );
};
// Resolution in pixels per logical inch
wxSize wxWindowDC::GetPPI(void) const
{
return wxSize(100, 100);
}
/*
* wxPaintDC
*/

View File

@ -42,6 +42,7 @@ LIB_CPP_SRC=\
../common/prntbase.cpp \
../common/resource.cpp \
../common/serbase.cpp \
../common/paper.cpp \
../common/string.cpp \
../common/textfile.cpp \
../common/tbarbase.cpp \
@ -71,6 +72,9 @@ LIB_CPP_SRC=\
../common/http.cpp \
../common/url.cpp \
../common/tokenzr.cpp \
\
../unix/threadpsx.cpp \
../unix/utilsunx.cpp \
\
accel.cpp \
app.cpp \
@ -121,11 +125,9 @@ LIB_CPP_SRC=\
stattext.cpp \
taskbar.cpp \
textctrl.cpp \
thread.cpp \
timer.cpp \
toolbar.cpp \
utils.cpp \
utilsexc.cpp \
wave.cpp \
window.cpp \
\

File diff suppressed because it is too large Load Diff

View File

@ -52,88 +52,232 @@
IMPLEMENT_CLASS(wxPrinterDC, wxDC)
#endif
// This form is deprecated
wxPrinterDC::wxPrinterDC(const wxString& driver_name, const wxString& device_name, const wxString& file, bool interactive, int orientation)
{
m_isInteractive = interactive;
if (!file.IsNull() && file != "")
m_filename = file;
m_isInteractive = interactive;
if (!file.IsNull() && file != "")
m_printData.SetFilename(file);
#if wxUSE_COMMON_DIALOGS
if (interactive)
{
PRINTDLG pd;
pd.lStructSize = sizeof( PRINTDLG );
pd.hwndOwner=(HWND) NULL;
pd.hDevMode=(HANDLE)NULL;
pd.hDevNames=(HANDLE)NULL;
pd.Flags=PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS;
pd.nFromPage=0;
pd.nToPage=0;
pd.nMinPage=0;
pd.nMaxPage=0;
pd.nCopies=1;
pd.hInstance=(HINSTANCE)NULL;
if ( PrintDlg( &pd ) != 0 )
{
m_hDC = (WXHDC) pd.hDC;
m_ok = TRUE;
}
else
{
m_ok = FALSE;
return;
}
// m_dontDelete = TRUE;
}
else
if (interactive)
{
PRINTDLG pd;
pd.lStructSize = sizeof( PRINTDLG );
pd.hwndOwner=(HWND) NULL;
pd.hDevMode=(HANDLE)NULL;
pd.hDevNames=(HANDLE)NULL;
pd.Flags=PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS;
pd.nFromPage=0;
pd.nToPage=0;
pd.nMinPage=0;
pd.nMaxPage=0;
pd.nCopies=1;
pd.hInstance=(HINSTANCE)NULL;
if ( PrintDlg( &pd ) != 0 )
{
m_hDC = (WXHDC) pd.hDC;
m_ok = TRUE;
}
else
{
m_ok = FALSE;
return;
}
// m_dontDelete = TRUE;
}
else
#endif
if ((!driver_name.IsNull() && driver_name != "") &&
(!device_name.IsNull() && device_name != "") &&
(!file.IsNull() && file != ""))
{
m_hDC = (WXHDC) CreateDC((char *) (const char *) driver_name, (char *) (const char *) device_name, (char *) (const char *) file, NULL);
m_ok = m_hDC ? TRUE: FALSE;
}
else
{
m_hDC = wxGetPrinterDC(orientation);
m_ok = m_hDC ? TRUE: FALSE;
}
if (m_hDC)
{
// int width = GetDeviceCaps(m_hDC, VERTRES);
// int height = GetDeviceCaps(m_hDC, HORZRES);
SetMapMode(wxMM_TEXT);
}
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
if ((!driver_name.IsNull() && driver_name != "") &&
(!device_name.IsNull() && device_name != "") &&
(!file.IsNull() && file != ""))
{
m_hDC = (WXHDC) CreateDC((char *) (const char *) driver_name, (char *) (const char *) device_name, (char *) (const char *) file, NULL);
m_ok = m_hDC ? TRUE: FALSE;
}
else
{
wxPrintData printData;
printData.SetOrientation(orientation);
m_hDC = wxGetPrinterDC(printData);
m_ok = m_hDC ? TRUE: FALSE;
}
if (m_hDC)
{
// int width = GetDeviceCaps(m_hDC, VERTRES);
// int height = GetDeviceCaps(m_hDC, HORZRES);
SetMapMode(wxMM_TEXT);
}
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
}
wxPrinterDC::wxPrinterDC(const wxPrintData& printData)
{
m_printData = printData;
m_isInteractive = FALSE;
m_hDC = wxGetPrinterDC(printData);
m_ok = (m_hDC != 0);
if (m_hDC)
SetMapMode(wxMM_TEXT);
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
}
wxPrinterDC::wxPrinterDC(WXHDC theDC)
{
m_isInteractive = FALSE;
m_hDC = theDC;
m_ok = TRUE;
if (m_hDC)
{
// int width = GetDeviceCaps(m_hDC, VERTRES);
// int height = GetDeviceCaps(m_hDC, HORZRES);
SetMapMode(wxMM_TEXT);
}
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
m_isInteractive = FALSE;
m_hDC = theDC;
m_ok = TRUE;
if (m_hDC)
{
// int width = GetDeviceCaps(m_hDC, VERTRES);
// int height = GetDeviceCaps(m_hDC, HORZRES);
SetMapMode(wxMM_TEXT);
}
SetBrush(*wxBLACK_BRUSH);
SetPen(*wxBLACK_PEN);
}
wxPrinterDC::~wxPrinterDC(void)
{
}
bool wxPrinterDC::StartDoc(const wxString& message)
{
DOCINFO docinfo;
docinfo.cbSize = sizeof(DOCINFO);
docinfo.lpszDocName = (const char *)message;
wxString filename(m_printData.GetFilename());
if (filename.IsEmpty())
docinfo.lpszOutput = NULL;
else
docinfo.lpszOutput = (const char *) filename;
#if defined(__WIN95__)
docinfo.lpszDatatype = NULL;
docinfo.fwType = 0;
#endif
if (!m_hDC)
return FALSE;
int ret =
#ifndef __WIN32__
::StartDoc((HDC) m_hDC, &docinfo);
#else
#ifdef UNICODE
::StartDocW((HDC) m_hDC, &docinfo);
#else
#ifdef __TWIN32__
::StartDoc((HDC) m_hDC, &docinfo);
#else
::StartDocA((HDC) m_hDC, &docinfo);
#endif
#endif
#endif
#ifndef __WIN16__
if (ret <= 0)
{
DWORD lastError = GetLastError();
wxDebugMsg("wxDC::StartDoc failed with error: %d\n", lastError);
}
#endif
return (ret > 0);
}
void wxPrinterDC::EndDoc(void)
{
if (m_hDC) ::EndDoc((HDC) m_hDC);
}
void wxPrinterDC::StartPage(void)
{
if (m_hDC)
::StartPage((HDC) m_hDC);
}
void wxPrinterDC::EndPage(void)
{
if (m_hDC)
::EndPage((HDC) m_hDC);
}
// Returns default device and port names
static bool wxGetDefaultDeviceName(wxString& deviceName, wxString& portName)
{
deviceName = "";
LPDEVNAMES lpDevNames;
LPSTR lpszDriverName;
LPSTR lpszDeviceName;
LPSTR lpszPortName;
PRINTDLG pd;
// Cygwin has trouble believing PRINTDLG is 66 bytes - thinks it is 68
#ifdef __GNUWIN32__
pd.lStructSize = 66; // sizeof(PRINTDLG);
#else
pd.lStructSize = sizeof(PRINTDLG);
#endif
pd.hwndOwner = (HWND)NULL;
pd.hDevMode = NULL; // Will be created by PrintDlg
pd.hDevNames = NULL; // Ditto
pd.Flags = PD_RETURNDEFAULT;
pd.nCopies = 1;
if (!PrintDlg((LPPRINTDLG)&pd))
{
if ( pd.hDevMode )
GlobalFree(pd.hDevMode);
if (pd.hDevNames)
GlobalFree(pd.hDevNames);
return FALSE;
}
if (pd.hDevNames)
{
lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
GlobalUnlock(pd.hDevNames);
GlobalFree(pd.hDevNames);
pd.hDevNames=NULL;
deviceName = lpszDeviceName;
portName = lpszPortName;
}
if (pd.hDevMode)
{
GlobalFree(pd.hDevMode);
pd.hDevMode=NULL;
}
return ( deviceName != "" );
}
#if 0
// This uses defaults, except for orientation, so we should eliminate this function
// and use the 2nd form (passing wxPrintData) instead.
WXHDC wxGetPrinterDC(int orientation)
{
HDC hDC;
@ -142,58 +286,62 @@ WXHDC wxGetPrinterDC(int orientation)
LPSTR lpszDriverName;
LPSTR lpszDeviceName;
LPSTR lpszPortName;
PRINTDLG pd;
// __GNUWIN32__ has trouble believing PRINTDLG is 66 bytes - thinks it is 68
#ifdef __GNUWIN32__
pd.lStructSize = 66; // sizeof(PRINTDLG);
#else
pd.lStructSize = sizeof(PRINTDLG);
#endif
pd.hwndOwner = (HWND)NULL;
pd.hDevMode = NULL; // Will be created by PrintDlg
pd.hDevNames = NULL; // Ditto
pd.Flags = PD_RETURNDEFAULT;
pd.nCopies = 1;
if (!PrintDlg((LPPRINTDLG)&pd))
{
if ( pd.hDevMode )
GlobalFree(pd.hDevMode);
if (pd.hDevNames)
GlobalFree(pd.hDevNames);
return(0);
}
if (!pd.hDevNames)
{
if ( pd.hDevMode )
GlobalFree(pd.hDevMode);
}
lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
GlobalUnlock(pd.hDevNames);
if ( pd.hDevMode )
{
lpDevMode = (DEVMODE*) GlobalLock(pd.hDevMode);
lpDevMode->dmOrientation = orientation;
lpDevMode->dmFields |= DM_ORIENTATION;
}
#ifdef __WIN32__
hDC = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, (DEVMODE *)lpDevMode);
#else
hDC = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, (LPSTR)lpDevMode);
#endif
if (pd.hDevMode && lpDevMode)
GlobalUnlock(pd.hDevMode);
if (pd.hDevNames)
{
GlobalFree(pd.hDevNames);
pd.hDevNames=NULL;
GlobalFree(pd.hDevNames);
pd.hDevNames=NULL;
}
if (pd.hDevMode)
{
@ -202,5 +350,52 @@ WXHDC wxGetPrinterDC(int orientation)
}
return (WXHDC) hDC;
}
#endif
// Gets an HDC for the specified printer configuration
WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst)
{
wxPrintData printData = printDataConst;
printData.ConvertToNative();
char* driverName = (char*) NULL;
wxString devNameStr = printData.GetPrinterName();
char* deviceName;
char* portName = (char*) NULL; // Obsolete in WIN32
if (devNameStr == "")
deviceName = (char*) NULL;
else
deviceName = (char*) (const char*) devNameStr;
LPDEVMODE lpDevMode = (LPDEVMODE) NULL;
HGLOBAL hDevMode = (HGLOBAL) printData.GetNativeData();
if ( hDevMode )
lpDevMode = (DEVMODE*) GlobalLock(hDevMode);
if (devNameStr == "")
{
// Retrieve the default device name
wxString portName;
bool ret = wxGetDefaultDeviceName(devNameStr, portName);
wxASSERT_MSG( ret, "Could not get default device name." );
deviceName = (char*) (const char*) devNameStr;
}
#ifdef __WIN32__
HDC hDC = CreateDC(driverName, deviceName, portName, (DEVMODE *) lpDevMode);
#else
HDC hDC = CreateDC(driverName, deviceName, portName, (LPSTR) lpDevMode);
#endif
if (hDevMode && lpDevMode)
GlobalUnlock(hDevMode);
return (WXHDC) hDC;
}

View File

@ -132,6 +132,7 @@ COMMONOBJS = \
$(MSWDIR)\date.obj \
$(MSWDIR)\hash.obj \
$(MSWDIR)\list.obj \
$(MSWDIR)\paper.obj \
$(MSWDIR)\string.obj \
$(MSWDIR)\time.obj \
$(MSWDIR)\wxexpr.obj \
@ -551,6 +552,8 @@ $(MSWDIR)\hash.obj: $(COMMDIR)\hash.$(SRCSUFF)
$(MSWDIR)\list.obj: $(COMMDIR)\list.$(SRCSUFF)
$(MSWDIR)\paper.obj: $(COMMDIR)\paper.$(SRCSUFF)
$(MSWDIR)\string.obj: $(COMMDIR)\string.$(SRCSUFF)
$(MSWDIR)\variant.obj: $(COMMDIR)\variant.$(SRCSUFF)

View File

@ -130,6 +130,7 @@ COMMONOBJS = \
$(MSWDIR)\date.obj \
$(MSWDIR)\hash.obj \
$(MSWDIR)\list.obj \
$(MSWDIR)\paper.obj \
$(MSWDIR)\string.obj \
$(MSWDIR)\time.obj \
$(MSWDIR)\wxexpr.obj \
@ -539,6 +540,8 @@ $(MSWDIR)\hash.obj: $(COMMDIR)\hash.$(SRCSUFF)
$(MSWDIR)\list.obj: $(COMMDIR)\list.$(SRCSUFF)
$(MSWDIR)\paper.obj: $(COMMDIR)\paper.$(SRCSUFF)
$(MSWDIR)\string.obj: $(COMMDIR)\string.$(SRCSUFF)
$(MSWDIR)\variant.obj: $(COMMDIR)\variant.$(SRCSUFF)

View File

@ -116,6 +116,7 @@ COMMONOBJS = \
$(COMMDIR)\hash.obj \
$(COMMDIR)\list.obj \
$(COMMDIR)\variant.obj \
$(COMMDIR)\paper.obj \
$(COMMDIR)\string.obj \
$(COMMDIR)\time.obj \
$(COMMDIR)\y_tab.obj \
@ -873,6 +874,11 @@ $(COMMDIR)/variant.obj: $*.$(SRCSUFF)
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<<
$(COMMDIR)/paper.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<<
$(COMMDIR)/string.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)

View File

@ -114,6 +114,7 @@ COMMONOBJS = \
$(COMMDIR)/hash.$(OBJSUFF) \
$(COMMDIR)/list.$(OBJSUFF) \
$(COMMDIR)/variant.$(OBJSUFF) \
$(COMMDIR)/paper.$(OBJSUFF) \
$(COMMDIR)/string.$(OBJSUFF) \
$(COMMDIR)/time.$(OBJSUFF) \
$(COMMDIR)/tokenzr.$(OBJSUFF) \

View File

@ -88,6 +88,7 @@ COMMONOBJS = \
$(COMMDIR)\date.obj \
$(COMMDIR)\hash.obj \
$(COMMDIR)\list.obj \
$(COMMDIR)\paper.obj \
$(COMMDIR)\string.obj \
$(COMMDIR)\time.obj \
$(COMMDIR)\tokenzr.obj \

View File

@ -74,6 +74,7 @@ COMMONOBJS = cmndata.obj \
date.obj \
hash.obj \
list.obj \
paper.obj \
string.obj \
socket.obj \
sckaddr.obj \
@ -617,6 +618,9 @@ hash.obj: $(COMMDIR)\hash.cpp
list.obj: $(COMMDIR)\list.cpp
$(CCC) $(CPPFLAGS) $(IFLAGS) $(COMMDIR)\list.cpp /BINARY list.obj
paper.obj: $(COMMDIR)\paper.cpp
$(CCC) $(CPPFLAGS) $(IFLAGS) $(COMMDIR)\paper.cpp /BINARY paper.obj
string.obj: $(COMMDIR)\string.cpp
$(CCC) $(CPPFLAGS) $(IFLAGS) $(COMMDIR)\string.cpp /BINARY string.obj

View File

@ -116,6 +116,7 @@ COMMONOBJS = \
$(COMMDIR)/hash.$(OBJSUFF) \
$(COMMDIR)/list.$(OBJSUFF) \
$(COMMDIR)/variant.$(OBJSUFF) \
$(COMMDIR)/paper.$(OBJSUFF) \
$(COMMDIR)/string.$(OBJSUFF) \
$(COMMDIR)/time.$(OBJSUFF) \
$(COMMDIR)/tokenzr.$(OBJSUFF) \

View File

@ -135,6 +135,7 @@ COMMONOBJS = \
..\common\$D\date.obj \
..\common\$D\hash.obj \
..\common\$D\list.obj \
..\common\$D\paper.obj \
..\common\$D\string.obj \
..\common\$D\socket.obj \
..\common\$D\sckaddr.obj \

View File

@ -84,6 +84,7 @@ COMMONOBJS = cmndata.obj &
date.obj &
hash.obj &
list.obj &
paper.obj &
string.obj &
socket.obj &
sckaddr.obj &
@ -629,6 +630,9 @@ hash.obj: $(COMMDIR)\hash.cpp
list.obj: $(COMMDIR)\list.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
paper.obj: $(COMMDIR)\paper.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
string.obj: $(COMMDIR)\string.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<

View File

@ -50,112 +50,101 @@ IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
#endif
wxPrintDialog::wxPrintDialog(void):
wxDialog()
wxDialog()
{
dialogParent = NULL;
printerDC = NULL;
destroyDC = TRUE;
deviceName = NULL;
driverName = NULL;
portName = NULL;
m_dialogParent = NULL;
m_printerDC = NULL;
m_destroyDC = TRUE;
}
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
wxDialog()
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data):
wxDialog()
{
Create(p, data);
Create(p, data);
}
bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data)
bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
{
dialogParent = p;
printerDC = NULL;
destroyDC = TRUE;
deviceName = NULL;
driverName = NULL;
portName = NULL;
m_dialogParent = p;
m_printerDC = NULL;
m_destroyDC = TRUE;
if ( data )
printData = *data;
if ( data )
m_printDialogData = *data;
m_printDialogData.SetOwnerWindow(p);
#ifdef __WXMSW__
printData.SetOwnerWindow(p);
#endif
return TRUE;
return TRUE;
}
wxPrintDialog::~wxPrintDialog(void)
{
if (destroyDC && printerDC)
delete printerDC;
if (deviceName) delete[] deviceName;
if (driverName) delete[] driverName;
if (portName) delete[] portName;
if (m_destroyDC && m_printerDC)
delete m_printerDC;
}
int wxPrintDialog::ShowModal(void)
{
printData.ConvertToNative();
bool ret = (PrintDlg( (PRINTDLG *)printData.printData ) != 0);
if ( ret != FALSE && ((PRINTDLG *)printData.printData)->hDC)
{
wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)printData.printData)->hDC);
printerDC = pdc;
printData.ConvertFromNative();
return wxID_OK;
}
else
{
/*
char buf[256];
DWORD exError = CommDlgExtendedError();
sprintf(buf, "ret = %d, ex error = %d", (int) ret, (int) exError);
wxMessageBox(buf);
*/
return wxID_CANCEL;
}
m_printDialogData.ConvertToNative();
bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
{
wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
m_printerDC = pdc;
m_printDialogData.ConvertFromNative();
return wxID_OK;
}
else
{
/*
char buf[256];
DWORD exError = CommDlgExtendedError();
sprintf(buf, "ret = %d, ex error = %d", (int) ret, (int) exError);
wxMessageBox(buf);
*/
return wxID_CANCEL;
}
}
wxDC *wxPrintDialog::GetPrintDC(void)
{
if (printerDC)
{
destroyDC = FALSE;
return printerDC;
}
else
return NULL;
if (m_printerDC)
{
m_destroyDC = FALSE;
return m_printerDC;
}
else
return (wxDC*) NULL;
}
/*
* wxPageSetupDialog
*/
* wxPageSetupDialog
*/
wxPageSetupDialog::wxPageSetupDialog(void):
wxDialog()
wxDialog()
{
m_dialogParent = NULL;
m_dialogParent = NULL;
}
wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
wxDialog()
wxDialog()
{
Create(p, data);
Create(p, data);
}
bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
{
m_dialogParent = p;
if (data)
m_pageSetupData = (*data);
m_dialogParent = p;
if (data)
m_pageSetupData = (*data);
#if defined(__WIN95__)
m_pageSetupData.SetOwnerWindow(p);
m_pageSetupData.SetOwnerWindow(p);
#endif
return TRUE;
return TRUE;
}
wxPageSetupDialog::~wxPageSetupDialog(void)
@ -168,11 +157,11 @@ int wxPageSetupDialog::ShowModal(void)
m_pageSetupData.ConvertToNative();
if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
{
m_pageSetupData.ConvertFromNative();
return wxID_OK;
m_pageSetupData.ConvertFromNative();
return wxID_OK;
}
else
return wxID_CANCEL;
return wxID_CANCEL;
#else
wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
int ret = genericPageSetupDialog->ShowModal();

View File

@ -55,11 +55,11 @@ IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
#endif
/*
* Printer
*/
wxWindowsPrinter::wxWindowsPrinter(wxPrintData *data):
wxPrinterBase(data)
* Printer
*/
wxWindowsPrinter::wxWindowsPrinter(wxPrintDialogData *data):
wxPrinterBase(data)
{
m_lpAbortProc = (WXFARPROC) MakeProcInstance((FARPROC) wxAbortProc, wxGetInstance());
}
@ -71,204 +71,218 @@ wxWindowsPrinter::~wxWindowsPrinter(void)
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
{
sm_abortIt = FALSE;
sm_abortWindow = NULL;
if (!printout)
return FALSE;
printout->SetIsPreview(FALSE);
printout->OnPreparePrinting();
// Get some parameters from the printout, if defined
int fromPage, toPage;
int minPage, maxPage;
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
if (maxPage == 0)
return FALSE;
m_printData.SetMinPage(minPage);
m_printData.SetMaxPage(maxPage);
if (fromPage != 0)
m_printData.SetFromPage(fromPage);
if (toPage != 0)
m_printData.SetToPage(toPage);
if (minPage != 0)
{
m_printData.EnablePageNumbers(TRUE);
if (m_printData.GetFromPage() < m_printData.GetMinPage())
m_printData.SetFromPage(m_printData.GetMinPage());
else if (m_printData.GetFromPage() > m_printData.GetMaxPage())
m_printData.SetFromPage(m_printData.GetMaxPage());
if (m_printData.GetToPage() > m_printData.GetMaxPage())
m_printData.SetToPage(m_printData.GetMaxPage());
else if (m_printData.GetToPage() < m_printData.GetMinPage())
m_printData.SetToPage(m_printData.GetMinPage());
}
else
m_printData.EnablePageNumbers(FALSE);
// Create a suitable device context
wxDC *dc = NULL;
if (prompt)
{
wxPrintDialog dialog(parent, & m_printData);
if (dialog.ShowModal() == wxID_OK)
{
dc = dialog.GetPrintDC();
m_printData = dialog.GetPrintData();
}
}
else
{
dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
}
// May have pressed cancel.
if (!dc || !dc->Ok())
{
if (dc) delete dc;
return FALSE;
}
int logPPIScreenX = 0;
int logPPIScreenY = 0;
int logPPIPrinterX = 0;
int logPPIPrinterY = 0;
HDC hdc = ::GetDC(NULL);
logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
::ReleaseDC(NULL, hdc);
logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
{
delete dc;
return FALSE;
}
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
// Set printout parameters
printout->SetDC(dc);
int w, h;
long ww, hh;
dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h);
dc->GetSizeMM(&ww, &hh);
printout->SetPageSizeMM((int)ww, (int)hh);
// Create an abort window
wxBeginBusyCursor();
wxWindow *win = CreateAbortWindow(parent, printout);
wxYield();
#if defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc);
#else
::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
// cast it to right type only if required
// @@@ it's really cdecl and we're casting it to stdcall - either there is
// something I don't understand or it will crash at first usage
#ifdef STRICT
(HDC, int)
#else
()
#endif
)m_lpAbortProc);
#endif
if (!win)
{
wxEndBusyCursor();
wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent);
delete dc;
}
sm_abortWindow = win;
sm_abortWindow->Show(TRUE);
wxYield();
printout->OnBeginPrinting();
bool keepGoing = TRUE;
int copyCount;
for (copyCount = 1; copyCount <= m_printData.GetNoCopies(); copyCount ++)
{
if (!printout->OnBeginDocument(m_printData.GetFromPage(), m_printData.GetToPage()))
{
wxEndBusyCursor();
wxMessageBox("Could not start printing.", "Print Error", wxOK, parent);
break;
}
if (sm_abortIt)
break;
int pn;
for (pn = m_printData.GetFromPage(); keepGoing && (pn <= m_printData.GetToPage()) && printout->HasPage(pn);
pn++)
{
if (sm_abortIt)
{
keepGoing = FALSE;
break;
}
else
{
// int dcID = ::SaveDC(dc->GetHDC());
dc->StartPage();
printout->OnPrintPage(pn);
dc->EndPage();
// ::RestoreDC(dc->GetHDC(), dcID);
}
}
printout->OnEndDocument();
}
printout->OnEndPrinting();
if (sm_abortWindow)
{
sm_abortWindow->Show(FALSE);
delete sm_abortWindow;
sm_abortIt = FALSE;
sm_abortWindow = NULL;
}
if (!printout)
return FALSE;
printout->SetIsPreview(FALSE);
printout->OnPreparePrinting();
// Get some parameters from the printout, if defined
int fromPage, toPage;
int minPage, maxPage;
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
if (maxPage == 0)
return FALSE;
m_printDialogData.SetMinPage(minPage);
m_printDialogData.SetMaxPage(maxPage);
if (fromPage != 0)
m_printDialogData.SetFromPage(fromPage);
if (toPage != 0)
m_printDialogData.SetToPage(toPage);
if (minPage != 0)
{
m_printDialogData.EnablePageNumbers(TRUE);
if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage())
m_printDialogData.SetFromPage(m_printDialogData.GetMinPage());
else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage())
m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage());
if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage())
m_printDialogData.SetToPage(m_printDialogData.GetMaxPage());
else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage())
m_printDialogData.SetToPage(m_printDialogData.GetMinPage());
}
else
m_printDialogData.EnablePageNumbers(FALSE);
wxEndBusyCursor();
// Create a suitable device context
wxDC *dc = NULL;
if (prompt)
{
dc = PrintDialog(parent);
if (!dc)
return FALSE;
}
else
{
// dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
dc = new wxPrinterDC(m_printDialogData.GetPrintData());
}
// May have pressed cancel.
if (!dc || !dc->Ok())
{
if (dc) delete dc;
return FALSE;
}
int logPPIScreenX = 0;
int logPPIScreenY = 0;
int logPPIPrinterX = 0;
int logPPIPrinterY = 0;
HDC hdc = ::GetDC(NULL);
logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
::ReleaseDC(NULL, hdc);
logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
{
delete dc;
return FALSE;
}
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
// Set printout parameters
printout->SetDC(dc);
int w, h;
dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h);
delete dc;
return TRUE;
dc->GetSizeMM(&w, &h);
printout->SetPageSizeMM((int)w, (int)h);
// Create an abort window
wxBeginBusyCursor();
wxWindow *win = CreateAbortWindow(parent, printout);
wxYield();
#if defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc);
#else
::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
// cast it to right type only if required
// @@@ it's really cdecl and we're casting it to stdcall - either there is
// something I don't understand or it will crash at first usage
#ifdef STRICT
(HDC, int)
#else
()
#endif
)m_lpAbortProc);
#endif
if (!win)
{
wxEndBusyCursor();
wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent);
delete dc;
}
sm_abortWindow = win;
sm_abortWindow->Show(TRUE);
wxYield();
printout->OnBeginPrinting();
bool keepGoing = TRUE;
int copyCount;
for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
{
if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
{
wxEndBusyCursor();
wxMessageBox("Could not start printing.", "Print Error", wxOK, parent);
break;
}
if (sm_abortIt)
break;
int pn;
for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
pn++)
{
if (sm_abortIt)
{
keepGoing = FALSE;
break;
}
else
{
dc->StartPage();
printout->OnPrintPage(pn);
dc->EndPage();
}
}
printout->OnEndDocument();
}
printout->OnEndPrinting();
if (sm_abortWindow)
{
sm_abortWindow->Show(FALSE);
delete sm_abortWindow;
sm_abortWindow = NULL;
}
wxEndBusyCursor();
delete dc;
return TRUE;
}
bool wxWindowsPrinter::PrintDialog(wxWindow *parent)
wxDC* wxWindowsPrinter::PrintDialog(wxWindow *parent)
{
wxPrintDialog dialog(parent, & m_printData);
return (dialog.ShowModal() == wxID_OK);
wxDC* dc = (wxDC*) NULL;
wxPrintDialog dialog(parent, & m_printDialogData);
int ret = dialog.ShowModal();
if (ret == wxID_OK)
{
dc = dialog.GetPrintDC();
m_printDialogData = dialog.GetPrintDialogData();
}
return dc;
}
bool wxWindowsPrinter::Setup(wxWindow *parent)
{
wxPrintDialog dialog(parent, & m_printData);
dialog.GetPrintData().SetSetupDialog(TRUE);
return (dialog.ShowModal() == wxID_OK);
wxPrintDialog dialog(parent, & m_printDialogData);
dialog.GetPrintDialogData().SetSetupDialog(TRUE);
int ret = dialog.ShowModal();
if (ret == wxID_OK)
{
m_printDialogData = dialog.GetPrintDialogData();
}
return (ret == wxID_OK);
}
/*
* Print preview
*/
* Print preview
*/
wxWindowsPrintPreview::wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data):
wxPrintPreviewBase(printout, printoutForPrinting, data)
wxWindowsPrintPreview::wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintDialogData *data):
wxPrintPreviewBase(printout, printoutForPrinting, data)
{
DetermineScaling();
DetermineScaling();
}
wxWindowsPrintPreview::~wxWindowsPrintPreview(void)
@ -277,55 +291,55 @@ wxWindowsPrintPreview::~wxWindowsPrintPreview(void)
bool wxWindowsPrintPreview::Print(bool interactive)
{
if (!m_printPrintout)
return FALSE;
wxWindowsPrinter printer(&m_printData);
return printer.Print(m_previewFrame, m_printPrintout, interactive);
if (!m_printPrintout)
return FALSE;
wxWindowsPrinter printer(&m_printDialogData);
return printer.Print(m_previewFrame, m_printPrintout, interactive);
}
void wxWindowsPrintPreview::DetermineScaling(void)
{
HDC dc = ::GetDC(NULL);
int screenWidth = ::GetDeviceCaps(dc, HORZSIZE);
// int screenHeight = ::GetDeviceCaps(dc, VERTSIZE);
// int screenHeight = ::GetDeviceCaps(dc, VERTSIZE);
int screenXRes = ::GetDeviceCaps(dc, HORZRES);
// int screenYRes = ::GetDeviceCaps(dc, VERTRES);
// int screenYRes = ::GetDeviceCaps(dc, VERTRES);
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
m_previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
::ReleaseDC(NULL, dc);
// Get a device context for the currently selected printer
wxPrinterDC printerDC("", "", "", FALSE, m_printData.GetOrientation());
wxPrinterDC printerDC(m_printDialogData.GetPrintData());
int printerWidth = 150;
int printerHeight = 250;
int printerXRes = 1500;
int printerYRes = 2500;
if (printerDC.GetHDC())
{
printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE);
printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE);
printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES);
printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES);
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
m_isOk = FALSE;
printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE);
printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE);
printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES);
printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES);
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
m_isOk = FALSE;
}
else
m_isOk = FALSE;
m_isOk = FALSE;
m_pageWidth = printerXRes;
m_pageHeight = printerYRes;
// At 100%, the page should look about page-size on the screen.
m_previewScale = (float)((float)screenWidth/(float)printerWidth);
m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerYRes);
@ -333,29 +347,29 @@ void wxWindowsPrintPreview::DetermineScaling(void)
/****************************************************************************
FUNCTION: wxAbortProc()
FUNCTION: wxAbortProc()
PURPOSE: Processes messages for the Abort Dialog box
****************************************************************************/
LONG APIENTRY _EXPORT wxAbortProc(HDC WXUNUSED(hPr), int WXUNUSED(Code))
{
MSG msg;
if (!wxPrinterBase::sm_abortWindow) /* If the abort dialog isn't up yet */
return(TRUE);
/* Process messages intended for the abort dialog box */
while (!wxPrinterBase::sm_abortIt && PeekMessage(&msg, 0, 0, 0, TRUE))
if (!IsDialogMessage((HWND) wxPrinterBase::sm_abortWindow->GetHWND(), &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
/* bAbort is TRUE (return is FALSE) if the user has aborted */
return (!wxPrinterBase::sm_abortIt);
/* bAbort is TRUE (return is FALSE) if the user has aborted */
return (!wxPrinterBase::sm_abortIt);
}

View File

@ -34,6 +34,7 @@ LIB_CPP_SRC=\
common/module.cpp \
common/object.cpp \
common/odbc.cpp \
common/paper.cpp \
common/prntbase.cpp \
common/resource.cpp \
common/serbase.cpp \

View File

@ -24,12 +24,13 @@
#pragma implementation "thread.h"
#endif
// With simple makefiles, we must ignore the file body if not using
// threads.
#include "wx/setup.h"
#if wxUSE_THREADS
#include "wx/thread.h"
#if !wxUSE_THREADS
#error This file needs wxUSE_THREADS
#endif
#include "wx/module.h"
#include "wx/utils.h"
#include "wx/log.h"
@ -42,7 +43,7 @@
#include <errno.h>
#include <time.h>
#ifdef HAVE_SCHED_H
#if HAVE_SCHED_H
#include <sched.h>
#endif
@ -793,3 +794,5 @@ void wxMutexGuiLeave()
gs_mutexGui->Unlock();
}
#endif
// wxUSE_THREADS

View File

@ -41,7 +41,10 @@
#include <time.h> // nanosleep() and/or usleep()
#include <ctype.h> // isspace()
#ifdef HAVE_UNAME
// JACS: needed for FD_SETSIZE
#include <sys/time.h>
#if HAVE_UNAME
#include <sys/utsname.h> // for uname()
#endif // HAVE_UNAME
@ -81,14 +84,14 @@ void wxSleep(int nSecs)
void wxUsleep(unsigned long milliseconds)
{
#if defined(HAVE_NANOSLEEP)
#if HAVE_NANOSLEEP
timespec tmReq;
tmReq.tv_sec = milliseconds / 1000;
tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000;
// we're not interested in remaining time nor in return value
(void)nanosleep(&tmReq, (timespec *)NULL);
#elif defined(HAVE_USLEEP)
#elif HAVE_USLEEP
// uncomment this if you feel brave or if you are sure that your version
// of Solaris has a safe usleep() function but please notice that usleep()
// is known to lead to crashes in MT programs in Solaris 2.[67] and is not