Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / printdlg.hxx
blob770d1777f26a55361a19b385e276770aed86058c
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 "print.h"
27 #include "vcl/print.hxx"
28 #include "vcl/dialog.hxx"
29 #include "vcl/fixed.hxx"
30 #include "vcl/button.hxx"
31 #include "vcl/gdimtf.hxx"
32 #include "vcl/lstbox.hxx"
33 #include "vcl/prgsbar.hxx"
34 #include "vcl/field.hxx"
35 #include "vcl/tabctrl.hxx"
36 #include "vcl/tabpage.hxx"
37 #include "vcl/virdev.hxx"
39 #include <memory>
40 #include <map>
42 namespace vcl
44 class PrintDialog : public ModalDialog
46 public:
47 class PrintPreviewWindow : public vcl::Window
49 static const sal_Int32 PREVIEW_BITMAP_WIDTH;
51 GDIMetaFile maMtf;
52 Size maOrigSize;
53 Size maPreviewSize;
54 VclPtr<VirtualDevice> maPageVDev;
55 Bitmap maPreviewBitmap;
56 OUString maReplacementString;
57 OUString maToolTipString;
58 bool mbGreyscale;
59 VclPtr<FixedLine> maHorzDim;
60 VclPtr<FixedLine> maVertDim;
62 void preparePreviewBitmap();
64 public:
65 PrintPreviewWindow( vcl::Window* pParent );
66 virtual ~PrintPreviewWindow();
67 virtual void dispose() SAL_OVERRIDE;
69 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
70 virtual void Command( const CommandEvent& ) SAL_OVERRIDE;
71 virtual void Resize() SAL_OVERRIDE;
72 virtual void DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
74 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
75 const OUString& i_rPaperName,
76 const OUString& i_rNoPageString,
77 sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
78 bool i_bGreyscale
82 class ShowNupOrderWindow : public vcl::Window
84 int mnOrderMode;
85 int mnRows;
86 int mnColumns;
87 void ImplInitSettings();
88 public:
89 ShowNupOrderWindow( vcl::Window* pParent );
91 virtual Size GetOptimalSize() const SAL_OVERRIDE;
93 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) SAL_OVERRIDE;
95 void setValues( int i_nOrderMode, int i_nColumns, int i_nRows )
97 mnOrderMode = i_nOrderMode;
98 mnRows = i_nRows;
99 mnColumns = i_nColumns;
100 Invalidate();
104 private:
106 class NUpTabPage
108 public:
109 VclPtr<RadioButton> mpPagesBtn;
110 VclPtr<RadioButton> mpBrochureBtn;
111 VclPtr<FixedText> mpPagesBoxTitleTxt;
112 VclPtr<ListBox> mpNupPagesBox;
114 // controls for "Custom" page mode
115 VclPtr<FixedText> mpNupNumPagesTxt;
116 VclPtr<NumericField> mpNupColEdt;
117 VclPtr<FixedText> mpNupTimesTxt;
118 VclPtr<NumericField> mpNupRowsEdt;
119 VclPtr<FixedText> mpPageMarginTxt1;
120 VclPtr<MetricField> mpPageMarginEdt;
121 VclPtr<FixedText> mpPageMarginTxt2;
122 VclPtr<FixedText> mpSheetMarginTxt1;
123 VclPtr<MetricField> mpSheetMarginEdt;
124 VclPtr<FixedText> mpSheetMarginTxt2;
125 VclPtr<FixedText> mpNupOrientationTxt;
126 VclPtr<ListBox> mpNupOrientationBox;
128 // page order ("left to right, then down")
129 VclPtr<FixedText> mpNupOrderTxt;
130 VclPtr<ListBox> mpNupOrderBox;
131 VclPtr<ShowNupOrderWindow> mpNupOrderWin;
132 /// border around each page
133 VclPtr<CheckBox> mpBorderCB;
135 void setupLayout();
137 NUpTabPage( VclBuilder* );
139 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& );
140 void enableNupControls( bool bEnable );
142 void showAdvancedControls( bool );
145 class JobTabPage
147 public:
148 VclPtr<ListBox> mpPrinters;
149 VclPtr<FixedText> mpStatusTxt;
150 VclPtr<FixedText> mpLocationTxt;
151 VclPtr<FixedText> mpCommentTxt;
153 VclPtr<PushButton> mpSetupButton;
155 VclPtr<FixedLine> mpCopySpacer;
156 VclPtr<NumericField> mpCopyCountField;
157 VclPtr<CheckBox> mpCollateBox;
158 VclPtr<FixedImage> mpCollateImage;
159 VclPtr<CheckBox> mpReverseOrderBox;
161 Image maCollateImg;
162 Image maNoCollateImg;
164 long mnCollateUIMode;
166 JobTabPage( VclBuilder* );
168 void readFromSettings();
169 void storeToSettings();
172 class OutputOptPage
174 public:
175 VclPtr<CheckBox> mpToFileBox;
176 VclPtr<CheckBox> mpCollateSingleJobsBox;
177 VclPtr<CheckBox> mpPapersizeFromSetup;
179 OutputOptPage( VclBuilder* );
181 void readFromSettings();
182 void storeToSettings();
185 VclBuilder* mpCustomOptionsUIBuilder;
187 std::shared_ptr<PrinterController> maPController;
188 VclPtr<TabControl> mpTabCtrl;
189 NUpTabPage maNUpPage;
190 JobTabPage maJobPage;
191 OutputOptPage maOptionsPage;
192 VclPtr<PrintPreviewWindow> mpPreviewWindow;
193 VclPtr<NumericField> mpPageEdit;
195 VclPtr<FixedText> mpNumPagesText;
196 VclPtr<PushButton> mpBackwardBtn;
197 VclPtr<PushButton> mpForwardBtn;
199 VclPtr<OKButton> mpOKButton;
200 VclPtr<CancelButton> mpCancelButton;
201 VclPtr<HelpButton> mpHelpButton;
203 OUString maPageStr;
204 OUString maNoPageStr;
205 sal_Int32 mnCurPage;
206 sal_Int32 mnCachedPages;
208 std::map< VclPtr<vcl::Window>, OUString > maControlToPropertyMap;
209 std::map< OUString, std::vector< VclPtr<vcl::Window> > >
210 maPropertyToWindowMap;
211 std::map< VclPtr<vcl::Window>, sal_Int32 > maControlToNumValMap;
212 std::set< OUString > maReverseDependencySet;
214 Size maNupPortraitSize;
215 Size maNupLandscapeSize;
217 /// internal, used for automatic Nup-Portrait/landscape
218 Size maFirstPageSize;
220 OUString maPrintToFileText;
221 OUString maPrintText;
222 OUString maDefPrtText;
224 Size maDetailsCollapsedSize;
225 Size maDetailsExpandedSize;
227 bool mbShowLayoutPage;
229 Size getJobPageSize();
230 void updateNup();
231 void updateNupFromPages();
232 void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false );
233 void setPreviewText( sal_Int32 );
234 void updatePrinterText();
235 void checkControlDependencies();
236 void checkOptionalControlDependencies();
237 void makeEnabled( vcl::Window* );
238 void updateWindowFromProperty( const OUString& );
239 void setupOptionalUI();
240 void readFromSettings();
241 void storeToSettings();
242 com::sun::star::beans::PropertyValue* getValueForWindow( vcl::Window* ) const;
244 virtual void Resize() SAL_OVERRIDE;
245 virtual void Command( const CommandEvent& ) SAL_OVERRIDE;
246 virtual void DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
248 DECL_LINK( SelectHdl, ListBox* );
249 DECL_LINK( ClickHdl, Button* );
250 DECL_LINK( ModifyHdl, Edit* );
251 DECL_LINK( UIOptionsChanged, void* );
253 DECL_LINK( UIOption_CheckHdl, CheckBox* );
254 DECL_LINK( UIOption_RadioHdl, RadioButton* );
255 DECL_LINK( UIOption_SelectHdl, ListBox* );
256 DECL_LINK( UIOption_ModifyHdl, Edit* );
258 public:
259 PrintDialog( vcl::Window*, const std::shared_ptr< PrinterController >& );
260 virtual ~PrintDialog();
261 virtual void dispose() SAL_OVERRIDE;
263 bool isPrintToFile();
264 bool isCollate();
265 bool isSingleJobs();
267 void previewForward();
268 void previewBackward();
271 class PrintProgressDialog : public ModelessDialog
273 OUString maStr;
274 VclPtr<FixedText> mpText;
275 VclPtr<ProgressBar> mpProgress;
276 VclPtr<CancelButton> mpButton;
278 bool mbCanceled;
279 sal_Int32 mnCur;
280 sal_Int32 mnMax;
282 DECL_LINK( ClickHdl, Button* );
284 public:
285 PrintProgressDialog(vcl::Window* i_pParent, int i_nMax);
286 virtual ~PrintProgressDialog();
287 virtual void dispose() SAL_OVERRIDE;
288 bool isCanceled() const { return mbCanceled; }
289 void setProgress( int i_nCurrent, int i_nMax = -1 );
290 void tick();
291 void reset();
295 #endif // INCLUDED_VCL_INC_PRINTDLG_HXX
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */