1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 VCL_INC_NEWPRINTDLG_HXX
21 #define VCL_INC_NEWPRINTDLG_HXX
23 #include <vcl/print.hxx>
24 #include <vcl/dialog.hxx>
25 #include <vcl/fixed.hxx>
26 #include <vcl/button.hxx>
27 #include <vcl/field.hxx>
28 #include <vcl/layout.hxx>
29 #include <vcl/tabctrl.hxx>
30 #include <vcl/gdimtf.hxx>
31 #include <vcl/weld.hxx>
39 class MoreOptionsDialog
: public weld::GenericDialogController
41 VclPtr
<PrintDialog
> mpParent
;
42 std::unique_ptr
<weld::Button
> mxOKButton
;
43 std::unique_ptr
<weld::Button
> mxCancelButton
;
44 std::unique_ptr
<weld::CheckButton
> mxSingleJobsBox
;
46 DECL_LINK( ClickHdl
, weld::Button
&, void );
50 MoreOptionsDialog( VclPtr
<PrintDialog
> i_pParent
);
51 virtual ~MoreOptionsDialog() override
;
54 class PrintDialog
: public ModalDialog
56 friend class MoreOptionsDialog
;
59 class PrintPreviewWindow
: public vcl::Window
66 BitmapEx maPreviewBitmap
;
67 OUString maReplacementString
;
68 OUString
const maToolTipString
;
70 VclPtr
<FixedLine
> maHorzDim
;
71 VclPtr
<FixedLine
> maVertDim
;
73 void preparePreviewBitmap();
76 PrintPreviewWindow( vcl::Window
* pParent
);
77 virtual ~PrintPreviewWindow() override
;
78 virtual void dispose() override
;
80 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
81 virtual void Command( const CommandEvent
& ) override
;
82 virtual void Resize() override
;
84 void setPreview( const GDIMetaFile
&, const Size
& i_rPaperSize
,
85 const OUString
& i_rPaperName
,
86 const OUString
& i_rNoPageString
,
87 sal_Int32 i_nDPIX
, sal_Int32 i_nDPIY
,
92 class ShowNupOrderWindow
: public vcl::Window
94 NupOrderType mnOrderMode
;
98 ShowNupOrderWindow( vcl::Window
* pParent
);
100 virtual Size
GetOptimalSize() const override
;
102 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
104 void setValues( NupOrderType i_nOrderMode
, int i_nColumns
, int i_nRows
)
106 mnOrderMode
= i_nOrderMode
;
108 mnColumns
= i_nColumns
;
113 PrintDialog( vcl::Window
*, const std::shared_ptr
< PrinterController
>& );
114 virtual ~PrintDialog() override
;
115 virtual void dispose() override
;
117 bool isPrintToFile() const;
118 bool isCollate() const;
119 bool isSingleJobs() const { return mbSingleJobs
; };
120 bool hasPreview() const;
122 void setPaperSizes();
123 void previewForward();
124 void previewBackward();
128 std::unique_ptr
<VclBuilder
> mpCustomOptionsUIBuilder
;
130 std::shared_ptr
<PrinterController
> maPController
;
132 std::unique_ptr
<MoreOptionsDialog
> mxMoreOptionsDlg
;
134 VclPtr
<TabControl
> mpTabCtrl
;
135 VclPtr
<VclFrame
> mpPageLayoutFrame
;
136 VclPtr
<ListBox
> mpPrinters
;
137 VclPtr
<FixedText
> mpStatusTxt
;
138 VclPtr
<PushButton
> mpSetupButton
;
139 OUString
const maPrintToFileText
;
140 OUString maPrintText
;
141 OUString
const maDefPrtText
;
143 VclPtr
<NumericField
> mpCopyCountField
;
144 VclPtr
<CheckBox
> mpCollateBox
;
145 VclPtr
<FixedImage
> mpCollateImage
;
146 VclPtr
<ListBox
> mpPaperSidesBox
;
147 VclPtr
<CheckBox
> mpReverseOrderBox
;
149 VclPtr
<OKButton
> mpOKButton
;
150 VclPtr
<CancelButton
> mpCancelButton
;
151 VclPtr
<HelpButton
> mpHelpButton
;
152 VclPtr
<PushButton
> mpMoreOptionsBtn
;
154 VclPtr
<PushButton
> mpBackwardBtn
;
155 VclPtr
<PushButton
> mpForwardBtn
;
156 VclPtr
<CheckBox
> mpPreviewBox
;
157 VclPtr
<FixedText
> mpNumPagesText
;
158 VclPtr
<PrintPreviewWindow
> mpPreviewWindow
;
159 VclPtr
<NumericField
> mpPageEdit
;
162 OUString
const maNoPageStr
;
163 OUString
const maNoPreviewStr
;
165 sal_Int32 mnCachedPages
;
167 bool mbCollateAlwaysOff
;
169 VclPtr
<RadioButton
> mpPagesBtn
;
170 VclPtr
<RadioButton
> mpBrochureBtn
;
171 VclPtr
<FixedText
> mpPagesBoxTitleTxt
;
172 VclPtr
<ListBox
> mpNupPagesBox
;
174 // controls for "Custom" page mode
175 VclPtr
<FixedText
> mpNupNumPagesTxt
;
176 VclPtr
<NumericField
> mpNupColEdt
;
177 VclPtr
<FixedText
> mpNupTimesTxt
;
178 VclPtr
<NumericField
> mpNupRowsEdt
;
179 VclPtr
<FixedText
> mpPageMarginTxt1
;
180 VclPtr
<MetricField
> mpPageMarginEdt
;
181 VclPtr
<FixedText
> mpPageMarginTxt2
;
182 VclPtr
<FixedText
> mpSheetMarginTxt1
;
183 VclPtr
<MetricField
> mpSheetMarginEdt
;
184 VclPtr
<FixedText
> mpSheetMarginTxt2
;
185 VclPtr
<ListBox
> mpPaperSizeBox
;
186 VclPtr
<ListBox
> mpOrientationBox
;
188 // page order ("left to right, then down")
189 VclPtr
<FixedText
> mpNupOrderTxt
;
190 VclPtr
<ListBox
> mpNupOrderBox
;
191 VclPtr
<ShowNupOrderWindow
> mpNupOrderWin
;
192 /// border around each page
193 VclPtr
<CheckBox
> mpBorderCB
;
195 std::map
< VclPtr
<vcl::Window
>, OUString
>
196 maControlToPropertyMap
;
197 std::map
< OUString
, std::vector
< VclPtr
<vcl::Window
> > >
198 maPropertyToWindowMap
;
199 std::map
< VclPtr
<vcl::Window
>, sal_Int32
>
200 maControlToNumValMap
;
202 Size maNupPortraitSize
;
203 Size maNupLandscapeSize
;
204 /// internal, used for automatic Nup-Portrait/landscape
205 Size maFirstPageSize
;
207 bool mbShowLayoutFrame
;
212 DECL_LINK( ClickHdl
, Button
*, void );
213 DECL_LINK( SelectHdl
, ListBox
&, void );
214 DECL_LINK( ModifyHdl
, Edit
&, void );
215 DECL_LINK( ToggleHdl
, CheckBox
&, void );
216 DECL_LINK( ToggleRadioHdl
, RadioButton
&, void );
218 DECL_LINK( UIOption_CheckHdl
, CheckBox
&, void );
219 DECL_LINK( UIOption_RadioHdl
, RadioButton
&, void );
220 DECL_LINK( UIOption_SelectHdl
, ListBox
&, void );
221 DECL_LINK( UIOption_ModifyHdl
, Edit
&, void );
223 css::beans::PropertyValue
* getValueForWindow( vcl::Window
* ) const;
225 void preparePreview( bool i_bMayUseCache
);
226 void setupPaperSidesBox();
227 void storeToSettings();
228 void readFromSettings();
229 void setPaperOrientation( Orientation eOrientation
);
230 void updateOrientationBox( bool bAutomatic
= true );
231 bool hasOrientationChanged() const;
232 void checkPaperSize( Size
& rPaperSize
);
233 void setPreviewText();
234 void updatePrinterText();
235 void checkControlDependencies();
236 void checkOptionalControlDependencies();
237 void makeEnabled( vcl::Window
* );
238 void updateWindowFromProperty( const OUString
& );
239 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup
& );
240 void showAdvancedControls( bool );
241 void updateNup( bool i_bMayUseCache
= true );
242 void updateNupFromPages( bool i_bMayUseCache
= true );
243 void enableNupControls( bool bEnable
);
244 void setupOptionalUI();
245 Size
const & getJobPageSize();
249 class PrintProgressDialog
: public weld::GenericDialogController
256 std::unique_ptr
<weld::Label
> mxText
;
257 std::unique_ptr
<weld::ProgressBar
> mxProgress
;
258 std::unique_ptr
<weld::Button
> mxButton
;
260 DECL_LINK( ClickHdl
, weld::Button
&, void );
263 PrintProgressDialog(weld::Window
* i_pParent
, int i_nMax
);
264 virtual ~PrintProgressDialog() override
;
265 bool isCanceled() const { return mbCanceled
; }
266 void setProgress( int i_nCurrent
);
271 #endif // VCL_INC_NEWPRINTDLG_HXX
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */