📄 print.tex
字号:
\func{void}{FitThisSizeToPageMargins}{\param{const wxSize\& }{imageSize}, \param{const wxPageSetupDialogData\& }{pageSetupData}}Set the user scale and device origin of the wxDC associated with this wxPrintoutso that the given image size fits entirely within the page margins set in thegiven wxPageSetupDialogData object. This function provides the greatestconsistency across all platforms because it does not depend on having access tothe printable area of the paper. Note that on Mac, the native wxPageSetupDialogdoes not let you set the page margins; you'll have to provide your own mechanism,or you can use the Mac-only class wxMacPageMarginsDialog.\membersection{wxPrintout::MapScreenSizeToPaper}\label{wxprintoutmapscreensizetopaper}\func{void}{MapScreenSizeToPaper}{}Set the user scale and device origin of the wxDC associated with this wxPrintoutso that the printed page matches the screen size as closely as possibleand the logical origin is in the top left corner of the paper rectangle.That is,a 100-pixel object on screen should appear at the same size on the printed page. (Itwill, of course, be larger or smaller in the preview image, depending on the zoomfactor.) Use this if you want WYSIWYG behavior, e.g., in a text editor.\membersection{wxPrintout::MapScreenSizeToPage}\label{wxprintoutmapscreensizetopage}\func{void}{MapScreenSizeToPage}{}This sets the user scale of the wxDC assocated with this wxPrintout to the samescale as \helpref{MapScreenSizeToPaper}{wxprintoutmapscreensizetopaper} but setsthe logical origin to the top left corner of the page rectangle.\membersection{wxPrintout::MapScreenSizeToPageMargins}\label{wxprintoutmapscreensizetopagemargins}\func{void}{MapScreenSizeToPageMargins}{\param{const wxPageSetupDialogData\& }{pageSetupData}}This sets the user scale of the wxDC assocated with this wxPrintout to the samescale as\helpref{MapScreenSizeToPageMargins}{wxprintoutmapscreensizetopagemargins} butsets the logical origin to the top left corner of the page margins specified bythe given wxPageSetupDialogData object.\membersection{wxPrintout::MapScreenSizeToDevice}\label{wxprintoutmapscreensizetodevice}\func{void}{MapScreenSizeToDevice}{}Set the user scale and device origin of the wxDC associated with this wxPrintoutso that one screen pixel maps to one device pixel on the DC. That is, the userscale is set to (1,1) and the device origin is set to (0,0). Use this if youwant to do your own scaling prior to calling wxDC drawing calls, for example, ifyour underlying model is floating-point and you want to achieve maximum drawingprecision on high-resolution printers. (Note that while the underlying drawingmodel of Mac OS X is floating-point, wxWidgets's drawing model scales from integercoordinates.) You can use the GetLogicalXXXRect() routines below to obtain thepaper rectangle, page rectangle, or page margins rectangle to perform your own scaling.\membersection{wxPrintout::GetLogicalPaperRect}\label{wxprintoutgetlogicalpaperrect}\func{wxRect}{GetLogicalPaperRect}{}Return the rectangle corresponding to the paper in the associated wxDC'slogical coordinates for the current user scale and device origin.\membersection{wxPrintout::GetLogicalPageRect}\label{wxprintoutgetlogicalpagerect}\func{wxRect}{GetLogicalPageRect}{}Return the rectangle corresponding to the page in the associated wxDC'slogical coordinates for the current user scale and device origin. On MSW and Mac, this will be the printable area of the paper. On other platformsand PostScript printing, this will be the full paper rectangle.\membersection{wxPrintout::GetLogicalPageMarginsRect}\label{wxprintoutgetlogicalpagemarginsrect}\func{wxRect}{GetLogicalPageMarginsRect}{\param{const wxPageSetupDialogData\& }{pageSetupData}}Return the rectangle corresponding to the page margins specified by the givenwxPageSetupDialogData object in the associated wxDC's logical coordinates for thecurrent user scale and device origin. The page margins are specifiedwith respect to the edges of the paper on all platforms.\membersection{wxPrintout::SetLogicalOrigin}\label{wxprintoutsetlogicalorigin}\func{void}{SetLogicalOrigin}{\param{wxCoord }{x}, \param{wxCoord }{y}}Set the device origin of the associated wxDC so that the current logical pointbecomes the new logical origin.\membersection{wxPrintout::OffsetLogicalOrigin}\label{wxprintoutoffsetlogicalorigin}\func{void}{OffsetLogicalOrigin}{\param{wxCoord }{xoff}, \param{wxCoord }{yoff}}Shift the device origin by an amount specified in logical coordinates.\membersection{wxPrintout::OnBeginDocument}\label{wxprintoutonbegindocument}\func{bool}{OnBeginDocument}{\param{int}{ startPage}, \param{int}{ endPage}}Called by the framework at the start of document printing. Return false fromthis function cancels the print job. OnBeginDocument is called once for everycopy printed.The base wxPrintout::OnBeginDocument {\it must} be called (and the return valuechecked) from within the overridden function, since it calls wxDC::StartDoc.\pythonnote{If this method is overridden in a Python class then thebase class version can be called by using the method{\tt base\_OnBeginDocument(startPage, endPage)}. }\membersection{wxPrintout::OnEndDocument}\label{wxprintoutonenddocument}\func{void}{OnEndDocument}{\void}Called by the framework at the end of document printing. OnEndDocumentis called once for every copy printed.The base wxPrintout::OnEndDocument {\it must} be calledfrom within the overridden function, since it calls wxDC::EndDoc.\membersection{wxPrintout::OnBeginPrinting}\label{wxprintoutonbeginprinting}\func{void}{OnBeginPrinting}{\void}Called by the framework at the start of printing. OnBeginPrinting is called once for everyprint job (regardless of how many copies are being printed).\membersection{wxPrintout::OnEndPrinting}\label{wxprintoutonendprinting}\func{void}{OnEndPrinting}{\void}Called by the framework at the end of printing. OnEndPrintingis called once for every print job (regardless of how many copies are being printed).\membersection{wxPrintout::OnPreparePrinting}\label{wxprintoutonprepareprinting}\func{void}{OnPreparePrinting}{\void}Called once by the framework before any other demands are made of thewxPrintout object. This gives the object an opportunity to calculate thenumber of pages in the document, for example.\membersection{wxPrintout::OnPrintPage}\label{wxprintoutonprintpage}\func{bool}{OnPrintPage}{\param{int}{ pageNum}}Called by the framework when a page should be printed. Returning false cancelsthe print job. The application can use wxPrintout::GetDC to obtain a devicecontext to draw on.\section{\class{wxPrintPreview}}\label{wxprintpreview}Objects of this class manage the print preview process. The object is passeda wxPrintout object, and the wxPrintPreview object itself is passed toa wxPreviewFrame object. Previewing is started by initializing and showingthe preview frame. Unlike wxPrinter::Print, flow of control returns to the applicationimmediately after the frame is shown.\wxheading{Derived from}\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/print.h>\wxheading{See also}\overview{Printing framework overview}{printingoverview}, \helpref{wxPrinterDC}{wxprinterdc}, \helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPrintout}{wxprintout}, \helpref{wxPrinter}{wxprinter}, \helpref{wxPreviewCanvas}{wxpreviewcanvas}, \helpref{wxPreviewControlBar}{wxpreviewcontrolbar}, \helpref{wxPreviewFrame}{wxpreviewframe}.\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxPrintPreview::wxPrintPreview}\label{wxprintpreviewctor}\func{}{wxPrintPreview}{\param{wxPrintout* }{printout}, \param{wxPrintout* }{printoutForPrinting},\param{wxPrintData* }{data=NULL}}Constructor. Pass a printout object, an optional printout object to beused for actual printing, and the address of an optionalblock of printer data, which will be copied to the print preview object'sprint data.If {\it printoutForPrinting} is non-NULL, a {\bf Print...} button will be placed on thepreview frame so that the user can print directly from the preview interface.Do not explicitly delete the printout objects once this destructor has beencalled, since they will be deleted in the wxPrintPreview constructor.The same does not apply to the {\it data} argument.Test the Ok member to check whether the wxPrintPreview object was created correctly.Ok could return false if there was a problem initializing the printer device context(current printer not set, for example).\membersection{wxPrintPreview::\destruct{wxPrintPreview}}\label{wxprintpreviewdtor}\func{}{\destruct{wxPrinter}}{\void}Destructor. Deletes both print preview objects, so do not destroy these objectsin your application.\membersection{wxPrintPreview::GetCanvas}\label{wxprintpreviewgetcanvas}\func{wxPreviewCanvas* }{GetCanvas}{\void}Gets the preview window used for displaying the print preview image.\membersection{wxPrintPreview::GetCurrentPage}\label{wxprintpreviewgetcurrentpage}\func{int}{GetCurrentPage}{\void}Gets the page currently being previewed.\membersection{wxPrintPreview::GetFrame}\label{wxprintpreviewgetframe}\func{wxFrame *}{GetFrame}{\void}Gets the frame used for displaying the print preview canvasand control bar.\membersection{wxPrintPreview::GetMaxPage}\label{wxprintpreviewgetmaxpage}\func{int}{GetMaxPage}{\void}Returns the maximum page number.\membersection{wxPrintPreview::GetMinPage}\label{wxprintpreviewgetminpage}\func{int}{GetMinPage}{\void}Returns the minimum page number.\membersection{wxPrintPreview::GetPrintout}\label{wxprintpreviewgetprintout}\func{wxPrintout *}{GetPrintout}{\void}Gets the preview printout object associated with the wxPrintPreview object.\membersection{wxPrintPreview::GetPrintoutForPrinting}\label{wxprintpreviewgetprintoutforprinting}\func{wxPrintout *}{GetPrintoutForPrinting}{\void}Gets the printout object to be used for printing from within the preview interface,or NULL if none exists.\membersection{wxPrintPreview::IsOk}\label{wxprintpreviewisok}\func{bool}{Ok}{\void}Returns true if the wxPrintPreview is valid, false otherwise. It could return false if there was aproblem initializing the printer device context (current printer not set, for example).\membersection{wxPrintPreview::PaintPage}\label{wxprintpreviewpaintpage}\func{bool}{PaintPage}{\param{wxPreviewCanvas *}{canvas}, \param{wxDC& }{dc}}This refreshes the preview window with the preview image.It must be called from the preview window's OnPaint member.The implementation simply blits the preview bitmap ontothe canvas, creating a new preview bitmap if none exists.\membersection{wxPrintPreview::Print}\label{wxprintpreviewprint}\func{bool}{Print}{\param{bool }{prompt}}Invokes the print process using the second wxPrintout objectsupplied in the wxPrintPreview constructor.Will normally be called by the {\bf Print...} panel item on thepreview frame's control bar.Returns false in case of error -- call\helpref{wxPrinter::GetLastError}{wxprintergetlasterror} to get detailedinformation about the kind of the error.\membersection{wxPrintPreview::RenderPage}\label{wxprintpreviewrenderpage}\func{bool}{RenderPage}{\param{int }{pageNum}}Renders a page into a wxMemoryDC. Used internally by wxPrintPreview.\membersection{wxPrintPreview::SetCanvas}\label{wxprintpreviewsetcanvas}\func{void}{SetCanvas}{\param{wxPreviewCanvas* }{window}}Sets the window to be used for displaying the print preview image.\membersection{wxPrintPreview::SetCurrentPage}\label{wxprintpreviewsetcurrentpage}\func{void}{SetCurrentPage}{\param{int}{ pageNum}}Sets the current page to be previewed.\membersection{wxPrintPreview::SetFrame}\label{wxprintpreviewsetframe}\func{void}{SetFrame}{\param{wxFrame *}{frame}}Sets the frame to be used for displaying the print preview canvasand control bar.\membersection{wxPrintPreview::SetPrintout}\label{wxprintpreviewsetprintout}\func{void}{SetPrintout}{\param{wxPrintout *}{printout}}Associates a printout object with the wxPrintPreview object.\membersection{wxPrintPreview::SetZoom}\label{wxprintpreviewsetzoom}\func{void}{SetZoom}{\param{int}{ percent}}Sets the percentage preview zoom, and refreshes the preview canvasaccordingly.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -