NDEVR
API Documentation
PrintPreview.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: PrintPreview
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Vector.h>
35#include <NDEVR/Buffer.h>
36#include <NDEVR/Pointer.h>
37#include <QWidget>
38#include <QImage>
39namespace Ui
40{
41 class PrintPreviewUI;
42}
43class QPrintDialog;
44class QPageSetupDialog;
45class QPrintPreviewWidget;
46class QPrinter;
47namespace NDEVR
48{
49 class WidgetIterator;
50 class Button;
55 class NDEVR_PRINT_API PrintPreview : public QWidget
56 {
57 Q_OBJECT
58 public:
61 PrintPreview(QWidget* parent = nullptr);
69 void setImages(const Buffer<QImage>& images, const Buffer<QWidget*>& custom_print_options = Buffer<QWidget*>());
74 void setImage(uint04 index, const QImage& image, const Buffer<QWidget*>& custom_print_options = Buffer<QWidget*>());
77 void setPreferredSize(QSize preferred_size);
83 void printWidget(QWidget* widget, const Buffer<QWidget*>& custom_print_options = Buffer<QWidget*>());
87 void printWidgets(const Buffer<QWidget*>& widgets, const Buffer<QWidget*>& custom_print_options = Buffer<QWidget*>());
91 void printWidgets(const DynamicPointer<WidgetIterator>& reports, const Buffer<QWidget*>& custom_print_options = Buffer<QWidget*>());
106 bool isZoomMode() const;
109 bool zoomInToFit() const;
112 bool isCustomPercent() const;
113
116 virtual QSize sizeHint() const override;
119 QPalette printPalette() const;
122 void setPrintFont(const QFont& font);
126 bool event(QEvent* event) override;
129 static bool SystemHasPrinters();
132 QPrintDialog* printSetupDialog();
135 QPageSetupDialog* pageSetupDialog();
136 public:
144 signals:
154 protected slots:
155 void fitComboChanged();
156 void settingsChanged();
157 void pageChanged();
158 void fontChanged();
159 void Print(QPrinter *printer);
160 void choosePrinterAccepted(QPrinter* printer);
161 protected:
162 void setToDefaultPrinter();
163 void printImages(QPrinter* printer);
164 void printWidgets(QPrinter* printer);
165 void printWidget(QWidget* widget, QPainter& painter, QPoint offset);
166 protected:
170 QPrinter* m_printer;
171 QPrintDialog* m_print_setup_dialog;
172 QPrintPreviewWidget* m_print_preview;
173 QPageSetupDialog* m_page_setup_dialog;
180 Ui::PrintPreviewUI* ui;
181 bool m_is_virtual_printer = false;
182 };
183
184
185}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
QPageSetupDialog * pageSetupDialog()
Returns the page setup dialog.
Button * m_print_button
The print action button.
QPrintPreviewWidget * m_print_preview
The preview rendering widget.
bool isZoomMode() const
Returns whether zoom mode is active.
bool zoomInToFit() const
Returns whether zoom-to-fit is enabled.
void setPrintFont(const QFont &font)
Sets the font used for print rendering.
void setImages(const Buffer< QImage > &images, const Buffer< QWidget * > &custom_print_options=Buffer< QWidget * >())
Sets the images to print.
void resetPreferredSize()
Resets the preferred page size to the printer default.
~PrintPreview()
Destroys the PrintPreview and releases printer resources.
PrintPreview(QWidget *parent=nullptr)
Constructs a PrintPreview widget.
void printWidgets(const DynamicPointer< WidgetIterator > &reports, const Buffer< QWidget * > &custom_print_options=Buffer< QWidget * >())
Prints widgets provided by a WidgetIterator.
Ui::PrintPreviewUI * ui
The auto-generated UI form.
void setImage(uint04 index, const QImage &image, const Buffer< QWidget * > &custom_print_options=Buffer< QWidget * >())
Sets a specific image at the given index.
void printWidget(QWidget *widget, const Buffer< QWidget * > &custom_print_options=Buffer< QWidget * >())
Prints a single widget.
void zoomModeChangedSignal()
Emitted when the zoom mode setting changes.
virtual QSize sizeHint() const override
Returns the preferred size hint for this widget.
void clearImages()
Clears all stored images from the print queue.
bool m_is_virtual_printer
Whether the selected printer is a virtual printer.
Buffer< QWidget * > m_custom_print_settings_widgets
Custom widgets for print settings.
bool m_is_setting_font
Whether a font change is in progress.
QPrinter * m_printer
The active printer device.
Button * m_page_settings_button
The page settings button.
void setCustomPrintSettingsWidgets(const Buffer< QWidget * > &widgets)
Sets custom widgets to display in the print settings area.
DynamicPointer< WidgetIterator > m_widgets
The widget iterator for multi-page widget printing.
static PrintPreview * PrintPreviewWidget()
Creates or returns the singleton PrintPreview widget.
Vector< 2, fltp08 > customPercent() const
Returns the custom scaling percentage for width and height.
bool isCustomPercent() const
Returns whether a custom scaling percentage is being used.
Vector< 2, uint04 > scaledPageResolution() const
Returns the page resolution after applying the current scale.
Vector< 2, uint04 > pageResolution() const
Returns the current page resolution in pixels.
QPrintDialog * printSetupDialog()
Returns the print setup dialog.
void pageResolutionChangedSignal(Vector< 2, uint04 > pixel_size)
Emitted when the page resolution changes.
void finishedSignal()
Emitted when the print preview dialog is finished.
QPrintDialog * m_print_setup_dialog
The printer selection dialog.
void setPreferredSize(QSize preferred_size)
Sets the preferred page size for printing.
void printedSignal()
Emitted after a print operation completes.
QPageSetupDialog * m_page_setup_dialog
The page layout setup dialog.
QPalette printPalette() const
Returns the palette used for print rendering.
QFont m_print_font
The font used for printing.
Button * m_print_settings_button
The printer settings button.
Vector< 2, uint04 > m_last_resolution
The last known page resolution.
static PrintPreview * PrintPreviewWidget(const Buffer< QImage > &images)
Creates or returns the singleton PrintPreview widget with the given images.
void printWidgets(const Buffer< QWidget * > &widgets, const Buffer< QWidget * > &custom_print_options=Buffer< QWidget * >())
Prints multiple widgets.
Buffer< QImage > m_images
The images queued for printing.
static bool SystemHasPrinters()
Checks whether the system has any configured printers.
bool event(QEvent *event) override
Handles widget events.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
Provides a way to iterate over a series of widgets, useful for printing dialogs or turning Widgets in...
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...