I have some printing code for wxTextCtrl under MSW, macOS, and GTK. It has the following features:
wxPrintData* object to use an application's printer settings (i.e., paper size, orientation).Would there be interest in a PR for this? If so, I was going to redesign my API for it. I was thinking of the following:
Print function that takes a single argument with all the options.PrintPreview function, but only under MSW. macOS's and GTK's print dialogs have built-in previews already, but MSW doesn't.wxPrintInfo with the following fields:
wxPrintInfo::PrintData(wxPrintData*) - this would be an in & out parameter for print preview, where the user may change the settings.wxPrintInfo::wxPrintInfo(wxPrintData*) - CTOR that can also accept a wxPrintData.wxPrintInfo::LeftHeader(const wxString&)wxPrintInfo::CenterHeader(const wxString&)wxPrintInfo::RightHeader(const wxString&)wxPrintInfo::LeftFooter(const wxString&)wxPrintInfo::CenterFooter(const wxString&)wxPrintInfo::RightFooter(const wxString&)wxPrintInfo::WaterMark(const wxString&) (if I can get this to work on macOS. This can always be added later.)Thoughts?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I'm not sure how common is it going to be to just print the wxTextCtrl contents. To me it would be more useful to allow rendering it to any wxDC (including wxPrinterDC, of course), but I guess this is going to be more difficult? FWIW, under MSW it could be done using WM_PRINTCLIENT, I think.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
For MSW and am rendering to a wxDC, but under macOS you have to use a NSPrintOperation to print. With NSPrintOperation, it handles all the rendering and pagination for you; it's a surprisingly simple process. But because of that, I'm limited to using a high-level API.
Anyway, IMHO it is a really nice feature to have; I can imagine other programs benefiting from built-in text control printing. And having to write this code for every platform is...a production to say the least.
Ultimately, I could see a similar print API added to wxListCtrl, but I am getting way ahead of myself there.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
AFAICS NSPrintOperation is supposed to work with any NSView, so it's similar to WM_PRINTCLIENT from this point of view and it could make sense to provide this at wxWindow or wxControl level.
I don't think GTK provides anything similar, unfortunately, please let me know if I'm missing something.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
For MSW, I use the EM_FORMATRANGE message, which formats and paginates RTF content from the text control. So, a DC is involved, but the process is still very specific to the text control (and its RTF content in particular).
For GTK, I use the gtk_print_operation* API. The _GtkPrintData object in there involves taking Pango markup from the text control. So GTK requires text control specific logic too, at least to have most rich output.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
OK, so this will indeed have to be wxTextCtrl-specific. I guess we should have some wxTextEasyPrinting similar to the existing wxHtmlEasyPrinting?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I was originally thinking that too, but then noticed that wxWebView has a Print() function and wasn't sure if I should go with a print API connected to the text control.
With the wxTextEasyPrinting approach, it could have similar options like wxHtmlEasyPrinting and have print functions that take a reference to a text control. I'll go with the wxTextEasyPrinting approach if you prefer that.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I don't have strong opinions about it, but mimicking wxHtmlEasyPrinting seems to make sense. And I'd definitely avoid having Print() as a member function, this just doesn't seem right.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()