1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_PRNDLG_HXX 25 #define _SV_PRNDLG_HXX 26 27 #include <vcl/dllapi.h> 28 29 #include "print.h" 30 31 #include "vcl/print.hxx" 32 #include "vcl/dialog.hxx" 33 #include "vcl/fixed.hxx" 34 #include "vcl/button.hxx" 35 #include "vcl/gdimtf.hxx" 36 #include "vcl/lstbox.hxx" 37 #include "vcl/field.hxx" 38 #include "vcl/tabctrl.hxx" 39 #include "vcl/tabpage.hxx" 40 #include "vcl/arrange.hxx" 41 #include "vcl/virdev.hxx" 42 43 #include <boost/shared_ptr.hpp> 44 #include <map> 45 46 namespace vcl 47 { 48 class PrintDialog : public ModalDialog 49 { 50 class PrintPreviewWindow : public Window 51 { 52 GDIMetaFile maMtf; 53 Size maOrigSize; 54 Size maPreviewSize; 55 VirtualDevice maPageVDev; 56 rtl::OUString maReplacementString; 57 rtl::OUString maToolTipString; 58 bool mbGreyscale; 59 FixedLine maHorzDim; 60 FixedLine maVertDim; 61 62 bool useHCColorReplacement() const; 63 public: 64 PrintPreviewWindow( Window* pParent, const ResId& ); 65 virtual ~PrintPreviewWindow(); 66 67 virtual void Paint( const Rectangle& rRect ); 68 virtual void Command( const CommandEvent& ); 69 virtual void Resize(); 70 virtual void DataChanged( const DataChangedEvent& ); 71 72 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize, 73 const rtl::OUString& i_rPaperName, 74 const rtl::OUString& i_rNoPageString, 75 sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, 76 bool i_bGreyscale 77 ); 78 }; 79 80 class ShowNupOrderWindow : public Window 81 { 82 int mnOrderMode; 83 int mnRows; 84 int mnColumns; 85 void ImplInitSettings(); 86 public: 87 ShowNupOrderWindow( Window* pParent ); 88 virtual ~ShowNupOrderWindow(); 89 90 virtual void Paint( const Rectangle& ); 91 setValues(int i_nOrderMode,int i_nColumns,int i_nRows)92 void setValues( int i_nOrderMode, int i_nColumns, int i_nRows ) 93 { 94 mnOrderMode = i_nOrderMode; 95 mnRows = i_nRows; 96 mnColumns = i_nColumns; 97 Invalidate(); 98 } 99 }; 100 101 class NUpTabPage : public TabPage 102 { 103 public: 104 FixedLine maNupLine; 105 RadioButton maPagesBtn; 106 RadioButton maBrochureBtn; 107 FixedText maPagesBoxTitleTxt; 108 ListBox maNupPagesBox; 109 110 // controls for "Custom" page mode 111 FixedText maNupNumPagesTxt; 112 NumericField maNupColEdt; 113 FixedText maNupTimesTxt; 114 NumericField maNupRowsEdt; 115 FixedText maPageMarginTxt1; 116 MetricField maPageMarginEdt; 117 FixedText maPageMarginTxt2; 118 FixedText maSheetMarginTxt1; 119 MetricField maSheetMarginEdt; 120 FixedText maSheetMarginTxt2; 121 FixedText maNupOrientationTxt; 122 ListBox maNupOrientationBox; 123 124 // page order ("left to right, then down") 125 FixedText maNupOrderTxt; 126 ListBox maNupOrderBox; 127 ShowNupOrderWindow maNupOrderWin; 128 // border around each page 129 CheckBox maBorderCB; 130 131 boost::shared_ptr< vcl::RowOrColumn > mxBrochureDep; 132 boost::shared_ptr< vcl::LabeledElement >mxPagesBtnLabel; 133 134 void setupLayout(); 135 136 NUpTabPage( Window*, const ResId& ); 137 virtual ~NUpTabPage(); 138 139 void readFromSettings(); 140 void storeToSettings(); 141 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& ); 142 void enableNupControls( bool bEnable ); 143 144 void showAdvancedControls( bool ); 145 146 // virtual void Resize(); 147 }; 148 149 class JobTabPage : public TabPage 150 { 151 public: 152 FixedLine maPrinterFL; 153 ListBox maPrinters; 154 DisclosureButton maDetailsBtn; 155 FixedText maStatusLabel; 156 FixedText maStatusTxt; 157 FixedText maLocationLabel; 158 FixedText maLocationTxt; 159 FixedText maCommentLabel; 160 FixedText maCommentTxt; 161 162 PushButton maSetupButton; 163 164 FixedLine maCopies; 165 FixedLine maCopySpacer; 166 FixedText maCopyCount; 167 NumericField maCopyCountField; 168 CheckBox maCollateBox; 169 FixedImage maCollateImage; 170 CheckBox maReverseOrderBox; 171 172 Image maCollateImg; 173 Image maCollateHCImg; 174 Image maNoCollateImg; 175 Image maNoCollateHCImg; 176 177 long mnCollateUIMode; 178 179 boost::shared_ptr<vcl::RowOrColumn> mxPrintRange; 180 boost::shared_ptr<vcl::WindowArranger> mxDetails; 181 182 JobTabPage( Window*, const ResId& ); 183 virtual ~JobTabPage(); 184 185 void readFromSettings(); 186 void storeToSettings(); 187 188 // virtual void Resize(); 189 190 void setupLayout(); 191 }; 192 193 class OutputOptPage : public TabPage 194 { 195 public: 196 FixedLine maOptionsLine; 197 CheckBox maToFileBox; 198 CheckBox maCollateSingleJobsBox; 199 200 boost::shared_ptr<vcl::RowOrColumn> mxOptGroup; 201 202 OutputOptPage( Window*, const ResId& ); 203 virtual ~OutputOptPage(); 204 205 void readFromSettings(); 206 void storeToSettings(); 207 208 // virtual void Resize(); 209 210 void setupLayout(); 211 }; 212 213 OKButton maOKButton; 214 CancelButton maCancelButton; 215 HelpButton maHelpButton; 216 PrintPreviewWindow maPreviewWindow; 217 NumericField maPageEdit; 218 FixedText maNumPagesText; 219 PushButton maBackwardBtn; 220 PushButton maForwardBtn; 221 222 TabControl maTabCtrl; 223 NUpTabPage maNUpPage; 224 JobTabPage maJobPage; 225 OutputOptPage maOptionsPage; 226 227 FixedLine maButtonLine; 228 229 boost::shared_ptr< PrinterController > maPController; 230 231 rtl::OUString maPageStr; 232 rtl::OUString maNoPageStr; 233 sal_Int32 mnCurPage; 234 sal_Int32 mnCachedPages; 235 236 std::list< Window* > maControls; 237 std::map< Window*, rtl::OUString > maControlToPropertyMap; 238 std::map< rtl::OUString, std::vector< Window* > > 239 maPropertyToWindowMap; 240 std::map< Window*, sal_Int32 > maControlToNumValMap; 241 std::set< rtl::OUString > maReverseDependencySet; 242 243 Size maNupPortraitSize; 244 Size maNupLandscapeSize; 245 246 // internal, used for automatic Nup-Portrait/landscape 247 Size maFirstPageSize; 248 249 rtl::OUString maPrintToFileText; 250 rtl::OUString maPrintText; 251 rtl::OUString maDefPrtText; 252 253 boost::shared_ptr<vcl::RowOrColumn> mxPreviewCtrls; 254 255 Size maDetailsCollapsedSize; 256 Size maDetailsExpandedSize; 257 258 sal_Bool mbShowLayoutPage; 259 260 Size getJobPageSize(); 261 void updateNup(); 262 void updateNupFromPages(); 263 void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); 264 void setPreviewText( sal_Int32 ); 265 void updatePrinterText(); 266 void checkControlDependencies(); 267 void checkOptionalControlDependencies(); 268 void makeEnabled( Window* ); 269 void updateWindowFromProperty( const rtl::OUString& ); 270 void setupOptionalUI(); 271 void readFromSettings(); 272 void storeToSettings(); 273 com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; 274 275 virtual void Resize(); 276 virtual void Command( const CommandEvent& ); 277 virtual void DataChanged( const DataChangedEvent& ); 278 279 DECL_LINK( SelectHdl, ListBox* ); 280 DECL_LINK( ClickHdl, Button* ); 281 DECL_LINK( ModifyHdl, Edit* ); 282 DECL_LINK( UIOptionsChanged, void* ); 283 284 DECL_LINK( UIOption_CheckHdl, CheckBox* ); 285 DECL_LINK( UIOption_RadioHdl, RadioButton* ); 286 DECL_LINK( UIOption_SelectHdl, ListBox* ); 287 DECL_LINK( UIOption_ModifyHdl, Edit* ); 288 289 void setupLayout(); 290 public: 291 PrintDialog( Window*, const boost::shared_ptr< PrinterController >& ); 292 virtual ~PrintDialog(); 293 294 bool isPrintToFile(); 295 int getCopyCount(); 296 bool isCollate(); 297 bool isSingleJobs(); 298 299 void previewForward(); 300 void previewBackward(); 301 }; 302 303 class PrintProgressDialog : public ModelessDialog 304 { 305 String maStr; 306 FixedText maText; 307 CancelButton maButton; 308 309 bool mbCanceled; 310 sal_Int32 mnCur; 311 sal_Int32 mnMax; 312 long mnProgressHeight; 313 Rectangle maProgressRect; 314 bool mbNativeProgress; 315 316 DECL_LINK( ClickHdl, Button* ); 317 318 void implCalcProgressRect(); 319 public: 320 PrintProgressDialog( Window* i_pParent, int i_nMax ); 321 ~PrintProgressDialog(); 322 isCanceled() const323 bool isCanceled() const { return mbCanceled; } 324 void setProgress( int i_nCurrent, int i_nMax = -1 ); 325 void tick(); 326 void reset(); 327 328 virtual void Paint( const Rectangle& ); 329 }; 330 } 331 332 333 #endif // _SV_PRNDLG_HXX 334