Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / printdlg.hxx
blob2371eaa5469b00af72f7f907bcb4e7be147c0df3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_INC_PRINTDLG_HXX
21 #define INCLUDED_VCL_INC_PRINTDLG_HXX
23 #include <vcl/dllapi.h>
25 #include <vcl/print.hxx>
26 #include <vcl/dialog.hxx>
27 #include <vcl/fixed.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/prgsbar.hxx>
30 #include <vcl/field.hxx>
31 #include <vcl/tabctrl.hxx>
32 #include <vcl/tabpage.hxx>
33 #include <vcl/virdev.hxx>
35 namespace vcl
37 class PrintDialog : public ModalDialog
39 public:
40 class PrintPreviewWindow : public vcl::Window
42 static const sal_Int32 PREVIEW_BITMAP_WIDTH;
44 GDIMetaFile maMtf;
45 Size maOrigSize;
46 Size maPreviewSize;
47 VclPtr<VirtualDevice> maPageVDev;
48 Bitmap maPreviewBitmap;
49 OUString maReplacementString;
50 OUString maToolTipString;
51 bool mbGreyscale;
52 VclPtr<FixedLine> maHorzDim;
53 VclPtr<FixedLine> maVertDim;
55 void preparePreviewBitmap();
57 public:
58 PrintPreviewWindow( vcl::Window* pParent );
59 virtual ~PrintPreviewWindow() override;
60 virtual void dispose() override;
62 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
63 virtual void Command( const CommandEvent& ) override;
64 virtual void Resize() override;
65 virtual void DataChanged( const DataChangedEvent& ) override;
67 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
68 const OUString& i_rPaperName,
69 const OUString& i_rNoPageString,
70 sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
71 bool i_bGreyscale
75 class ShowNupOrderWindow : public vcl::Window
77 NupOrderType mnOrderMode;
78 int mnRows;
79 int mnColumns;
80 public:
81 ShowNupOrderWindow( vcl::Window* pParent );
83 virtual Size GetOptimalSize() const override;
85 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
87 void setValues( NupOrderType i_nOrderMode, int i_nColumns, int i_nRows )
89 mnOrderMode = i_nOrderMode;
90 mnRows = i_nRows;
91 mnColumns = i_nColumns;
92 Invalidate();
96 private:
98 class NUpTabPage
100 public:
101 VclPtr<RadioButton> mpPagesBtn;
102 VclPtr<RadioButton> mpBrochureBtn;
103 VclPtr<FixedText> mpPagesBoxTitleTxt;
104 VclPtr<ListBox> mpNupPagesBox;
106 // controls for "Custom" page mode
107 VclPtr<FixedText> mpNupNumPagesTxt;
108 VclPtr<NumericField> mpNupColEdt;
109 VclPtr<FixedText> mpNupTimesTxt;
110 VclPtr<NumericField> mpNupRowsEdt;
111 VclPtr<FixedText> mpPageMarginTxt1;
112 VclPtr<MetricField> mpPageMarginEdt;
113 VclPtr<FixedText> mpPageMarginTxt2;
114 VclPtr<FixedText> mpSheetMarginTxt1;
115 VclPtr<MetricField> mpSheetMarginEdt;
116 VclPtr<FixedText> mpSheetMarginTxt2;
117 VclPtr<FixedText> mpNupOrientationTxt;
118 VclPtr<ListBox> mpNupOrientationBox;
120 // page order ("left to right, then down")
121 VclPtr<FixedText> mpNupOrderTxt;
122 VclPtr<ListBox> mpNupOrderBox;
123 VclPtr<ShowNupOrderWindow> mpNupOrderWin;
124 /// border around each page
125 VclPtr<CheckBox> mpBorderCB;
127 NUpTabPage( VclBuilder* );
129 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& );
130 void enableNupControls( bool bEnable );
132 void showAdvancedControls( bool );
135 class JobTabPage
137 public:
138 VclPtr<ListBox> mpPrinters;
139 VclPtr<FixedText> mpStatusTxt;
140 VclPtr<FixedText> mpLocationTxt;
141 VclPtr<FixedText> mpCommentTxt;
143 VclPtr<PushButton> mpSetupButton;
145 VclPtr<NumericField> mpCopyCountField;
146 VclPtr<CheckBox> mpCollateBox;
147 VclPtr<FixedImage> mpCollateImage;
148 VclPtr<CheckBox> mpReverseOrderBox;
150 BitmapEx maCollateBmp;
151 BitmapEx maNoCollateBmp;
153 long mnCollateUIMode;
155 JobTabPage( VclBuilder* );
157 void readFromSettings();
158 void storeToSettings();
161 class OutputOptPage
163 public:
164 VclPtr<CheckBox> mpCollateSingleJobsBox;
165 VclPtr<CheckBox> mpPapersizeFromSetup;
167 OutputOptPage( VclBuilder* );
169 void readFromSettings();
170 void storeToSettings();
173 VclBuilder* mpCustomOptionsUIBuilder;
175 std::shared_ptr<PrinterController> maPController;
176 VclPtr<TabControl> mpTabCtrl;
177 NUpTabPage maNUpPage;
178 JobTabPage maJobPage;
179 OutputOptPage maOptionsPage;
180 VclPtr<PrintPreviewWindow> mpPreviewWindow;
181 VclPtr<NumericField> mpPageEdit;
183 VclPtr<FixedText> mpNumPagesText;
184 VclPtr<PushButton> mpBackwardBtn;
185 VclPtr<PushButton> mpForwardBtn;
187 VclPtr<OKButton> mpOKButton;
188 VclPtr<CancelButton> mpCancelButton;
189 VclPtr<HelpButton> mpHelpButton;
191 OUString maPageStr;
192 OUString maNoPageStr;
193 sal_Int32 mnCurPage;
194 sal_Int32 mnCachedPages;
196 std::map< VclPtr<vcl::Window>, OUString > maControlToPropertyMap;
197 std::map< OUString, std::vector< VclPtr<vcl::Window> > >
198 maPropertyToWindowMap;
199 std::map< VclPtr<vcl::Window>, sal_Int32 > maControlToNumValMap;
200 std::set< OUString > maReverseDependencySet;
202 Size maNupPortraitSize;
203 Size maNupLandscapeSize;
205 /// internal, used for automatic Nup-Portrait/landscape
206 Size maFirstPageSize;
208 OUString maPrintToFileText;
209 OUString maPrintText;
210 OUString maDefPrtText;
212 bool mbShowLayoutPage;
214 Size const & getJobPageSize();
215 void updateNup();
216 void updateNupFromPages();
217 void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false );
218 void setPreviewText();
219 void updatePrinterText();
220 void checkControlDependencies();
221 void checkOptionalControlDependencies();
222 void makeEnabled( vcl::Window* );
223 void updateWindowFromProperty( const OUString& );
224 void setupOptionalUI();
225 void readFromSettings();
226 void storeToSettings();
227 css::beans::PropertyValue* getValueForWindow( vcl::Window* ) const;
229 virtual void Resize() override;
230 virtual void Command( const CommandEvent& ) override;
231 virtual void DataChanged( const DataChangedEvent& ) override;
233 DECL_LINK( SelectHdl, ListBox&, void );
234 DECL_LINK( ClickHdl, Button*, void );
235 DECL_LINK( ToggleHdl, CheckBox&, void );
236 DECL_LINK( ToggleRadioHdl, RadioButton&, void );
237 DECL_LINK( ModifyHdl, Edit&, void );
239 DECL_LINK( UIOption_CheckHdl, CheckBox&, void );
240 DECL_LINK( UIOption_RadioHdl, RadioButton&, void );
241 DECL_LINK( UIOption_SelectHdl, ListBox&, void );
242 DECL_LINK( UIOption_ModifyHdl, Edit&, void );
244 public:
245 PrintDialog( vcl::Window*, const std::shared_ptr< PrinterController >& );
246 virtual ~PrintDialog() override;
247 virtual void dispose() override;
249 bool isPrintToFile();
250 bool isCollate();
251 bool isSingleJobs();
253 void previewForward();
254 void previewBackward();
257 class PrintProgressDialog : public ModelessDialog
259 OUString maStr;
260 VclPtr<FixedText> mpText;
261 VclPtr<ProgressBar> mpProgress;
262 VclPtr<CancelButton> mpButton;
264 bool mbCanceled;
265 sal_Int32 mnCur;
266 sal_Int32 mnMax;
268 DECL_LINK( ClickHdl, Button*, void );
270 public:
271 PrintProgressDialog(vcl::Window* i_pParent, int i_nMax);
272 virtual ~PrintProgressDialog() override;
273 virtual void dispose() override;
274 bool isCanceled() const { return mbCanceled; }
275 void setProgress( int i_nCurrent );
276 void tick();
277 void reset();
281 #endif // INCLUDED_VCL_INC_PRINTDLG_HXX
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */