wxPrintPreview(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

wxPrintPreview β€” okay so basically objects of this class manage the print preview process. that's the whole vibe, bestie. ✨


🌸 DESCRIPTION 🌸

okay so picture this: you hand the object a wxPrintout object, and then you hand the wxPrintPreview object itself to a wxPreviewFrame object. that's the chain, that's the lore. πŸ¦‹

previewing kicks off when you initialize and show the preview frame. and here's the slay part β€” unlike wxPrinter:print/4, the flow of control comes right back to the application immediately after the frame is shown. no waiting around, main character energy fr fr. πŸ’…

⚠️ Note (read this one, i'm serious): the preview shown is only exact on Windows. on other platforms, the wxDC used for preview is different from what's used for printing, and the results may be significantly different, depending on how the output is created. in particular, printing code that leans heavily on wxDC:getTextExtent/3 (for example, wxHtmlEasyPrinting and other wxHTML classes do exactly that) is affected. it is recommended to use native preview functionality on platforms that offer it (macOS, GTK+). 😭

See (the little reading list, go off):

  • Overview printing
  • wxPrintDialog
  • wxPrintout
  • wxPrinter
  • wxPreviewCanvas
  • wxPreviewControlBar
  • wxPreviewFrame

also, wxWidgets docs: wxPrintPreview


πŸŽ€ DATA TYPES πŸŽ€

wxPrintPreview() :: wx:wx_object().

that's it, that's the type. she's a wx object and she knows it. πŸ‘‘


✨ FUNCTIONS ✨

πŸ’œ destroy(This :: wxPrintPreview()) -> ok.

Destroys the object. bye bestie, no notes. πŸ’€

πŸ’œ getCanvas(This) -> wxPreviewCanvas:wxPreviewCanvas() when This :: wxPrintPreview().

Gets the preview window used for displaying the print preview image. that's the canvas you're staring at. πŸ–ΌοΈ

πŸ’œ getCurrentPage(This) -> integer() when This :: wxPrintPreview().

Gets the page currently being previewed. where are we rn, bestie.

πŸ’œ getFrame(This) -> wxFrame:wxFrame() when This :: wxPrintPreview().

Gets the frame used for displaying the print preview canvas and control bar. the whole lil stage for the show. 🎭

πŸ’œ getMaxPage(This) -> integer() when This :: wxPrintPreview().

Returns the maximum page number. the ceiling, periodt.

πŸ’œ getMinPage(This) -> integer() when This :: wxPrintPreview().

Returns the minimum page number. the floor, also periodt.

πŸ’œ getPrintout(This) -> wxPrintout:wxPrintout() when This :: wxPrintPreview().

Gets the preview printout object associated with the wxPrintPreview object. 🫢

πŸ’œ getPrintoutForPrinting(This) -> wxPrintout:wxPrintout() when This :: wxPrintPreview().

Gets the printout object to be used for printing from within the preview interface, or NULL if none exists. ngl if it's NULL she simply did not show up. πŸ™ˆ

πŸ’œ isOk(This) -> boolean() when This :: wxPrintPreview().

Returns true if the wxPrintPreview is valid, false otherwise.

It could return false if there was a problem initializing the printer device context (current printer not set, for example). so like, always vibe check this one. πŸ”

πŸ’œ new(Printout, [Option]) -> wxPrintPreview()

when
    Printout :: wxPrintout:wxPrintout(),
    Option ::
        {printoutForPrinting, wxPrintout:wxPrintout()} |
        {data, wxPrintDialogData:wxPrintDialogData()}.

Constructor. ✨

Pass a printout object, an optional printout object to be used for actual printing, and the address of an optional block of printer data, which will be copied to the print preview object's print data.

If printoutForPrinting is non-NULL, a "Print..." button will be placed on the preview frame so that the user can print directly from the preview interface. a whole extra button, we love to see it. πŸ”₯

Remark: Do not explicitly delete the printout objects once this constructor has been called, since they will be deleted in the wxPrintPreview destructor. The same does not apply to the data argument. okay so the destructor handles cleanup for the printouts, but bestie, the data argument is on you β€” do not mix those up, or it's giving memory issues. 😭

Use isOk/1 to check whether the wxPrintPreview object was created correctly.

πŸ’œ new(Printout, PrintoutForPrinting, Data) -> wxPrintPreview()

when
    Printout :: wxPrintout:wxPrintout(),
    PrintoutForPrinting :: wxPrintout:wxPrintout(),
    Data :: wxPrintData:wxPrintData().

πŸ’œ paintPage(This, Canvas, Dc) -> boolean()

when
    This :: wxPrintPreview(),
    Canvas :: wxPreviewCanvas:wxPreviewCanvas(),
    Dc :: wxDC:wxDC().

This refreshes the preview window with the preview image. 🌈

It must be called from the preview window's OnPaint member. like, mandatory, no skipping. πŸ“Œ

The implementation simply blits the preview bitmap onto the canvas, creating a new preview bitmap if none exists. lowkey efficient, highkey iconic.

when This :: wxPrintPreview(), Prompt :: boolean().

Invokes the print process using the second wxPrintout object supplied in the wxPrintPreview constructor. πŸ–¨οΈ

Will normally be called by the Print... panel item on the preview frame's control bar.

Returns false in case of error β€” call wxPrinter:getLastError/0 to get detailed information about the kind of the error. so if it flops, go ask getLastError/0 what happened. πŸ’…

πŸ’œ renderPage(This, PageNum) -> boolean()

when This :: wxPrintPreview(), PageNum :: integer().

Renders a page into a wxMemoryDC.

Used internally by wxPrintPreview. iykyk, you probably don't need to touch this one yourself. πŸ™ˆ

πŸ’œ setCanvas(This, Window) -> ok

when
    This :: wxPrintPreview(),
    Window :: wxPreviewCanvas:wxPreviewCanvas().

Sets the window to be used for displaying the print preview image. πŸ–ΌοΈ

πŸ’œ setCurrentPage(This, PageNum) -> boolean()

when
    This :: wxPrintPreview(),
    PageNum :: integer().

Sets the current page to be previewed. flipping to the page you actually want, slay. πŸ“–

πŸ’œ setFrame(This, Frame) -> ok

when
    This :: wxPrintPreview(),
    Frame :: wxFrame:wxFrame().

Sets the frame to be used for displaying the print preview canvas and control bar. 🎭

πŸ’œ setPrintout(This, Printout) -> ok

when
    This :: wxPrintPreview(),
    Printout :: wxPrintout:wxPrintout().

Associates a printout object with the wxPrintPreview object. besties, officially linked. 🫢

πŸ’œ setZoom(This, Percent) -> ok

when This :: wxPrintPreview(), Percent :: integer().

Sets the percentage preview zoom, and refreshes the preview canvas accordingly. zoom in, zoom out, she ate that. πŸ”βœ¨


aww okay that's the whole page bestie, you got this πŸ’–

β€” with love from Ericsson AB, running the wx 2.6 era of the wxPrintPreview(3) page. mwah, go write some preview code. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from