00001 // $Id: prdlgctl.cpp 1742 2006-09-05 17:25:58Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 // Custom Print Dialog 00099 00100 /* 00101 */ 00102 00103 #include "camtypes.h" 00104 00105 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 #include "prdlgctl.h" 00107 //#include "printdlg.h" 00108 #include "printprg.h" 00109 #include "princomp.h" 00110 #include "optsprin.h" 00111 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00112 #include "printmsg.h" 00113 #include "prnprefs.h" // PrintPrefsDlg;;InvokeDialog 00114 #include "helpuser.h" 00115 #include "camelot.h" 00116 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00117 #include "ccdc.h" 00118 #include "ctrlhelp.h" 00119 //#include "richard2.h" 00120 #include "progress.h" 00121 //#include "markn.h" 00122 #include "unicdman.h" 00123 //#include "fonts.h" 00124 #include "printctl.h" 00125 #include "prnmks.h" 00126 #include "psdc.h" 00127 //#include "jason.h" // Error messages 00128 //#include "resource.h" // _R(IDS_OK)/CANCEL 00129 //#include "simon.h" // _R(IDS_HELP) 00130 00131 #ifdef _DEBUG 00132 #include "optsprin.h" 00133 #include "keypress.h" 00134 #endif 00135 00136 #define Swap(a,b) { (a)^=(b), (b)^=(a), (a)^=(b); } 00137 00138 PORTNOTE("printing", "Disabled message map stuff") 00139 #ifndef EXCLUDE_FROM_XARALX 00140 //--------------------------------- 00141 00142 // WEBSTER-ranbirr-12/11/96 00143 #ifndef WEBSTER 00144 BEGIN_MESSAGE_MAP(CCPrintDialog, CPrintDialog) 00145 //{{AFX_MSG_MAP(CPrintDialog) 00146 ON_COMMAND_EX(_R(IDC_ALLOBJECTS), OnCommand) 00147 ON_COMMAND_EX(_R(IDC_SELECTEDOBJECTS), OnCommand) 00148 ON_COMMAND_EX(_R(IDC_DPSBOTH), OnCommand) 00149 ON_COMMAND_EX(_R(IDC_DPSLEFTPAGES), OnCommand) 00150 ON_COMMAND_EX(_R(IDC_DPSRIGHTPAGES), OnCommand) 00151 ON_COMMAND_EX(_R(IDC_PRINTOPTIONS), OnCommand) 00152 ON_COMMAND_EX(_R(IDC_PRINTHELP), OnCommand) 00153 ON_COMMAND(psh1, OnPrintSetup) // print setup button when print is displayed 00154 //}}AFX_MSG_MAP 00155 END_MESSAGE_MAP() 00156 00157 //--------------------------------- 00158 00159 #endif //webster 00160 #endif 00161 00162 IMPLEMENT_DYNAMIC_CLASS(CCPrintDialog, wxPrintDialog) 00163 CC_IMPLEMENT_DYNAMIC(PrintMsg,Msg) 00164 00165 00166 //--------------------------------- 00167 // This is the new Win95-compatible DOCINFO structure that has two extra fields, lpszDatatype & fwType. 00168 // We don't have the new header files yet, so we need to implement this struct ourselves. 00169 // This new struct is utilised by the func CCPrintInfo::SetUpDocInfo(DOCINFO* pDocInfo) 00170 00171 typedef struct _NEW_DOCINFOA { 00172 INT32 cbSize; 00173 LPCSTR lpszDocName; 00174 LPCSTR lpszOutput; 00175 LPCSTR lpszDatetype; 00176 DWORD fwType; 00177 } NEW_DOCINFOA; 00178 typedef struct _NEW_DOCINFOW { 00179 INT32 cbSize; 00180 LPCWSTR lpszDocName; 00181 LPCWSTR lpszOutput; 00182 LPCWSTR lpszDatetype; 00183 DWORD fwType; 00184 } NEW_DOCINFOW; 00185 #ifdef UNICODE 00186 typedef NEW_DOCINFOW NEW_DOCINFO; 00187 #else 00188 typedef NEW_DOCINFOA NEW_DOCINFO; 00189 #endif // UNICODE 00190 00191 #ifndef DI_APPBANDING 00192 #define DI_APPBANDING 0x0001 00193 #endif 00194 00195 //--------------------------------- 00196 00197 // CCPrintDialog static vars 00198 //CCPrintDialog* CCPrintDialog::pInfoPrintDlg = NULL; // Used to get settings for the default printer 00199 // WEBSTER-ranbirr-12/11/96 00200 #ifndef WEBSTER 00201 00202 BOOL CCPrintDialog::GotPrinterSettings = FALSE; 00203 wxSize CCPrintDialog::PrPaperSize; 00204 BOOL CCPrintDialog::PrPortrait = TRUE; 00205 INT32 CCPrintDialog::PrScale = 100; 00206 BOOL CCPrintDialog::PrMultiCopies = FALSE; 00207 00208 INT32 CCPrintDialog::PrResolution = 300; 00209 INT32 CCPrintDialog::PrResolutionX = 300; 00210 INT32 CCPrintDialog::PrResolutionY = 300; 00211 00212 INT32 CCPrintDialog::PrLeftMargin = 0; //0x32a0; 00213 INT32 CCPrintDialog::PrTopMargin = 0; //0x2ee0; 00214 INT32 CCPrintDialog::PrRightMargin = 0; //0x3750; 00215 INT32 CCPrintDialog::PrBottomMargin = 0; //0x2ee0; 00216 00217 BOOL CCPrintDialog::PrPostscript = FALSE; 00218 00219 BOOL CCPrintDialog::ReopenMainDlg = FALSE; 00220 BOOL CCPrintDialog::InformPrinterReset = FALSE; 00221 BOOL CCPrintDialog::IgnorePrntData = FALSE; 00222 00223 wxPrintDialogData CCPrintInfo::m_DefaultDialogData; 00224 BOOL CCPrintInfo::m_HaveSavedDefaultDialogData = FALSE; 00225 00226 00227 CCPrintInfo* CCPrintInfo::pCurrent = NULL; // Ptr to the last constructed CCPrintInfo 00228 #endif //webster 00229 00230 #ifndef EXCLUDE_FROM_XARALX 00231 TCHAR CCPrintToFileDialog::FileName[FILENAMEBUFSIZE] = {_T('\0')}; 00232 // WEBSTER-ranbirr-12/11/96 00233 #ifndef WEBSTER 00234 CCPrintDialog* CCPrintDialog::pCurrentCCPrintDialog = NULL; 00235 wxPrintDialog* CCPrintDialog::pDlgSetup = NULL; 00236 #endif //webster 00237 #endif 00238 00239 //--------------------------------- 00240 00241 // Paper selections 00242 // This data is taken from wingdi.h and defines the sizes of all the default paper size values 00243 // that appear in the dmPaperSize member of DEVMODE 00244 // 00245 // If dmPaperSize is zero, dmPaperLength and dmPaperWidth define the paper size (in tenths of a millimetre) 00246 // 00247 // NOTE: The code must be tested on a dot matrix printer because the dmPaperLength can be arbitrary. 00248 // 00249 // NOTE: I have not found an automatic way of finding out the dimensions of a particular paper size. 00250 // The closest I got was to use OpenPrinter() to get a handle of a printer, then use GetForm() to retrieve 00251 // the dimensions of a paper size given the name of the paper (e.g. "A4"). However MSDN says that neither of 00252 // these functions are supported under Win32s. 00253 00254 #define IN_TO_MP(n) (MILLIPOINT((double(IN_MP_VAL)*n)+0.5)) 00255 #define MM_TO_MP(n) (MILLIPOINT((double(MM_MP_VAL)*n)+0.5)) 00256 00257 //#define wxPAPER_LISTEND (wxPAPER_LAST+1) 00258 #define wxPAPER_LISTEND ((UINT32)(-1)) 00259 00260 struct PaperSizesType 00261 { 00262 UINT32 ID; 00263 MILLIPOINT Width; 00264 MILLIPOINT Height; 00265 } pPaperSizes[] = 00266 { 00267 { wxPAPER_LETTER, IN_TO_MP(8.5), IN_TO_MP(11) }, // Letter 8 1/2 x 11 in 00268 { wxPAPER_LETTERSMALL, IN_TO_MP(8.5), IN_TO_MP(11) }, // Letter Small 8 1/2 x 11 in 00269 { wxPAPER_TABLOID, IN_TO_MP(11), IN_TO_MP(17) }, // Tabloid 11 x 17 in 00270 { wxPAPER_LEDGER, IN_TO_MP(17), IN_TO_MP(11) }, // Ledger 17 x 11 in 00271 { wxPAPER_LEGAL, IN_TO_MP(8.5), IN_TO_MP(14) }, // Legal 8 1/2 x 14 in 00272 { wxPAPER_STATEMENT, IN_TO_MP(5.5), IN_TO_MP(8.5) }, // Statement 5 1/2 x 8 1/2 in 00273 { wxPAPER_EXECUTIVE, IN_TO_MP(7.25), IN_TO_MP(10.5) }, // Executive 7 1/4 x 10 1/2 in 00274 00275 { wxPAPER_A3, MM_TO_MP(297), MM_TO_MP(420) }, // A3 297 x 420 mm 00276 { wxPAPER_A4, MM_TO_MP(210), MM_TO_MP(297) }, // A4 210 x 297 mm 00277 { wxPAPER_A4SMALL, MM_TO_MP(210), MM_TO_MP(297) }, // A4 Small 210 x 297 mm 00278 { wxPAPER_A5, MM_TO_MP(148), MM_TO_MP(210) }, // A5 148 x 210 mm 00279 { wxPAPER_B4, MM_TO_MP(250), MM_TO_MP(354) }, // B4 250 x 354 00280 { wxPAPER_B5, MM_TO_MP(182), MM_TO_MP(257) }, // B5 182 x 257 mm 00281 00282 { wxPAPER_FOLIO, IN_TO_MP(8.5), IN_TO_MP(13) }, // Folio 8 1/2 x 13 in 00283 { wxPAPER_QUARTO, MM_TO_MP(215), MM_TO_MP(275) }, // Quarto 215 x 275 mm 00284 { wxPAPER_10X14, IN_TO_MP(10), IN_TO_MP(14) }, // 10x14 in 00285 { wxPAPER_11X17, IN_TO_MP(11), IN_TO_MP(17) }, // 11x17 in 00286 { wxPAPER_NOTE, IN_TO_MP(8.5), IN_TO_MP(11) }, // Note 8 1/2 x 11 in 00287 00288 { wxPAPER_ENV_9, IN_TO_MP(3.875), IN_TO_MP(8.875) }, // Envelope #9 3 7/8 x 8 7/8 in 00289 { wxPAPER_ENV_10, IN_TO_MP(4.125), IN_TO_MP(9.5) }, // Envelope #10 4 1/8 x 9 1/2 in 00290 { wxPAPER_ENV_11, IN_TO_MP(4.5), IN_TO_MP(10.375)}, // Envelope #11 4 1/2 x 10 3/8 in 00291 { wxPAPER_ENV_12, IN_TO_MP(4.75), IN_TO_MP(11) }, // Envelope #12 4 3/4 x 11 in 00292 { wxPAPER_ENV_14, IN_TO_MP(5), IN_TO_MP(11.5) }, // Envelope #14 5 x 11 1/2 in 00293 00294 { wxPAPER_CSHEET, IN_TO_MP(17), IN_TO_MP(22) }, // C size sheet 17 x 22 in 00295 { wxPAPER_DSHEET, IN_TO_MP(22), IN_TO_MP(34) }, // D size sheet 22 x 34 in 00296 { wxPAPER_ESHEET, IN_TO_MP(34), IN_TO_MP(44) }, // E size sheet 34 x 44 in 00297 00298 { wxPAPER_ENV_DL, MM_TO_MP(110), MM_TO_MP(220) }, // Envelope DL 110 x 220mm 00299 { wxPAPER_ENV_C5, MM_TO_MP(162), MM_TO_MP(229) }, // Envelope C5 162 x 229 mm 00300 { wxPAPER_ENV_C3, MM_TO_MP(324), MM_TO_MP(458) }, // Envelope C3 324 x 458 mm 00301 { wxPAPER_ENV_C4, MM_TO_MP(229), MM_TO_MP(324) }, // Envelope C4 229 x 324 mm 00302 { wxPAPER_ENV_C6, MM_TO_MP(114), MM_TO_MP(162) }, // Envelope C6 114 x 162 mm 00303 { wxPAPER_ENV_C65, MM_TO_MP(114), MM_TO_MP(229) }, // Envelope C65 114 x 229 mm 00304 00305 { wxPAPER_ENV_B4, MM_TO_MP(250), MM_TO_MP(353) }, // Envelope B4 250 x 353 mm 00306 { wxPAPER_ENV_B5, MM_TO_MP(176), MM_TO_MP(250) }, // Envelope B5 176 x 250 mm 00307 { wxPAPER_ENV_B6, MM_TO_MP(176), MM_TO_MP(125) }, // Envelope B6 176 x 125 mm 00308 { wxPAPER_ENV_ITALY, MM_TO_MP(110), MM_TO_MP(230) }, // Envelope 110 x 230 mm 00309 00310 { wxPAPER_ENV_MONARCH, IN_TO_MP(3.875), IN_TO_MP(7.5) }, // Envelope Monarch 3.875 x 7.5 in 00311 { wxPAPER_ENV_PERSONAL, IN_TO_MP(3.625), IN_TO_MP(6.5) }, // 6 3/4 Envelope 3 5/8 x 6 1/2 in 00312 00313 { wxPAPER_FANFOLD_US, IN_TO_MP(14.875), IN_TO_MP(11) }, // US Std Fanfold 14 7/8 x 11 in 00314 { wxPAPER_FANFOLD_STD_GERMAN, IN_TO_MP(8.5), IN_TO_MP(12) }, // German Std Fanfold 8 1/2 x 12 in 00315 { wxPAPER_FANFOLD_LGL_GERMAN, IN_TO_MP(8.5), IN_TO_MP(13) }, // German Legal Fanfold 8 1/2 x 13 in 00316 00317 #if(WINVER >= 0x0400) 00318 { wxPAPER_ISO_B4, MM_TO_MP(250), MM_TO_MP(353) }, // B4 (ISO) 250 x 353 mm 00319 { wxPAPER_JAPANESE_POSTCARD, MM_TO_MP(100), MM_TO_MP(148) }, // Japanese Postcard 100 x 148 mm 00320 { wxPAPER_9X11, IN_TO_MP(9), IN_TO_MP(11) }, // 9 x 11 in 00321 { wxPAPER_10X11, IN_TO_MP(10), IN_TO_MP(11) }, // 10 x 11 in 00322 { wxPAPER_15X11, IN_TO_MP(15), IN_TO_MP(11) }, // 15 x 11 in 00323 { wxPAPER_ENV_INVITE, MM_TO_MP(220), MM_TO_MP(220) }, // Envelope Invite 220 x 220 mm 00324 // { wxPAPER_RESERVED_48, MM_TO_MP(250), MM_TO_MP(353) }, // RESERVED--DO NOT USE 00325 // { wxPAPER_RESERVED_49, MM_TO_MP(250), MM_TO_MP(353) }, // RESERVED--DO NOT USE 00326 { wxPAPER_LETTER_EXTRA, IN_TO_MP(9.5), IN_TO_MP(12) }, // Letter Extra 9 \275 x 12 in 00327 { wxPAPER_LEGAL_EXTRA, IN_TO_MP(9.5), IN_TO_MP(15) }, // Legal Extra 9 \275 x 15 in 00328 { wxPAPER_TABLOID_EXTRA, IN_TO_MP(11.69), IN_TO_MP(18) }, // Tabloid Extra 11.69 x 18 in 00329 { wxPAPER_A4_EXTRA, IN_TO_MP(9.27), IN_TO_MP(12.69) }, // A4 Extra 9.27 x 12.69 in 00330 { wxPAPER_LETTER_TRANSVERSE, IN_TO_MP(8.5), IN_TO_MP(11) }, // Letter Transverse 8 \275 x 11 in 00331 { wxPAPER_A4_TRANSVERSE, MM_TO_MP(210), MM_TO_MP(297) }, // A4 Transverse 210 x 297 mm 00332 { wxPAPER_LETTER_EXTRA_TRANSVERSE,IN_TO_MP(9.5), IN_TO_MP(12) }, // Letter Extra Transverse 9\275 x 12 in 00333 { wxPAPER_A_PLUS, MM_TO_MP(227), MM_TO_MP(356) }, // SuperA/SuperA/A4 227 x 356 mm 00334 { wxPAPER_B_PLUS, MM_TO_MP(305), MM_TO_MP(487) }, // SuperB/SuperB/A3 305 x 487 mm 00335 { wxPAPER_LETTER_PLUS, IN_TO_MP(8.5), IN_TO_MP(12.69) }, // Letter Plus 8.5 x 12.69 in 00336 { wxPAPER_A4_PLUS, MM_TO_MP(210), MM_TO_MP(330) }, // A4 Plus 210 x 330 mm 00337 { wxPAPER_A5_TRANSVERSE, MM_TO_MP(148), MM_TO_MP(210) }, // A5 Transverse 148 x 210 mm 00338 { wxPAPER_B5_TRANSVERSE, MM_TO_MP(182), MM_TO_MP(257) }, // B5 (JIS) Transverse 182 x 257 mm 00339 { wxPAPER_A3_EXTRA, MM_TO_MP(322), MM_TO_MP(445) }, // A3 Extra 322 x 445 mm 00340 { wxPAPER_A5_EXTRA, MM_TO_MP(174), MM_TO_MP(235) }, // A5 Extra 174 x 235 mm 00341 { wxPAPER_B5_EXTRA, MM_TO_MP(201), MM_TO_MP(276) }, // B5 (ISO) Extra 201 x 276 mm 00342 { wxPAPER_A2, MM_TO_MP(420), MM_TO_MP(594) }, // A2 420 x 594 mm 00343 { wxPAPER_A3_TRANSVERSE, MM_TO_MP(297), MM_TO_MP(420) }, // A3 Transverse 297 x 420 mm 00344 { wxPAPER_A3_EXTRA_TRANSVERSE, MM_TO_MP(322), MM_TO_MP(445) }, // A3 Extra Transverse 322 x 445 mm 00345 #endif 00346 00347 { wxPAPER_LISTEND,0,0 } 00348 }; 00349 00350 //--------------------------------- 00351 void Beep(); 00352 //--------------------------------- 00353 00354 // WEBSTER-ranbirr-12/11/96 00355 #ifndef WEBSTER 00356 00357 00358 /******************************************************************************************** 00359 00360 > CCPrintDialog::CCPrintDialog(Document* pDoc,BOOL PrintSetUpOnly = FALSE) 00361 00362 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00363 Created: 29/3/95 00364 Inputs: pDoc = ptr to the document this print dialog is associated with 00365 PrintSetUpOnly = TRUE if you only want the print setup dialog only 00366 Purpose: Creates a camelot print dialog, based on CPrintDialog 00367 SeeAlso: CCPrintInfo 00368 00369 ********************************************************************************************/ 00370 00371 CCPrintDialog::CCPrintDialog(CCPrintInfo * pDialogData, Document* pDoc,BOOL PrintSetUpOnly) : wxPrintDialog(NULL, pDialogData) 00372 { 00373 pDocument = pDoc; 00374 PrintPrefsOpen = FALSE; 00375 PrintPrefsChanged = FALSE; 00376 } 00377 00378 00379 /******************************************************************************************** 00380 00381 > CCPrintDialog::~CCPrintDialog() 00382 00383 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00384 Created: 29/3/95 00385 Inputs: - 00386 Purpose: Default destructor 00387 This deletes the member DC using ::DeleteDC() as instructed by the help on 00388 CPrintDialog::GetPrinterDC() (only if the DC is not NULL of course) 00389 00390 Why CPrintDialog doesn't have a destructor to do this is a mystery. I think it relies 00391 on you using CPrintInfo who's destructor DOES delete the DC if need be. 00392 00393 SeeAlso: CCPrintInfo 00394 00395 ********************************************************************************************/ 00396 00397 CCPrintDialog::~CCPrintDialog() 00398 { 00399 } 00400 00401 /******************************************************************************************** 00402 00403 > PrintControl* CCPrintDialog::GetPrintControl() 00404 00405 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00406 Created: 5/4/95 00407 Inputs: - 00408 Returns: Ptr to the print control 00409 Purpose: Returns the ptr to the print control attached to the doc associated with this dialog 00410 SeeAlso: CCPrintInfo 00411 00412 ********************************************************************************************/ 00413 00414 PrintControl* CCPrintDialog::GetPrintControl() 00415 { 00416 PrintControl* pPrCtrl = NULL; 00417 00418 if (pDocument != NULL) 00419 { 00420 PrintComponent* pComp = (PrintComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent)); 00421 00422 if (pComp != NULL) 00423 pPrCtrl = pComp->GetPrintControl(); 00424 } 00425 00426 ERROR3IF(pPrCtrl == NULL,"Unable to find the print control object"); 00427 00428 return pPrCtrl; 00429 } 00430 00431 // Here's how we might one-day run help 00432 00433 // Yes, run the help system and don't process this message any more. As we don't 00434 // have any C++ object associated with the Print Problems page we must use the 00435 // bodgey raw help function here. 00436 // _HelpUser(TEXT("PrintProblems")); 00437 // _HelpUser(TEXT("CCPrintSetupDialog")); 00438 00439 #ifndef EXCLUDE_FROM_XARALX 00440 00441 /******************************************************************************************** 00442 00443 > INT32 CCPrintDialog::DoModal() 00444 00445 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00446 Created: 30/3/95 00447 Inputs: - 00448 Returns: See CPrintDialog::DoModal() for return values 00449 Purpose: This calls CPrintDialog::DoModal() and returns the value that it returns 00450 00451 This func allows us to detect when the print dialog has been displayed, and which 00452 button the user clicked on to close it (i.e. OK or Cancel) 00453 00454 SeeAlso: CPrintDialog::DoModal 00455 00456 ********************************************************************************************/ 00457 00458 INT32 CCPrintDialog::DoModal() 00459 { 00460 ERROR2IF(pDocument == NULL,IDCANCEL,"NULL doc ptr"); 00461 00462 ERROR3IF(pCurrentCCPrintDialog != NULL,"pCurrentCCPrintDialog is not NULL"); 00463 pCurrentCCPrintDialog = this; 00464 00465 // Get a copy of the print control in the associated document 00466 PrintControl* pPrCtrl = GetPrintControl(); 00467 ERROR2IF(pPrCtrl == NULL,IDCANCEL,"Unable to find the print control"); 00468 LocalPrintControl = *pPrCtrl; 00469 00470 // Inform the user if we have switched to using the default printer on the system 00471 InformResetToDefaultPrinter(FALSE); 00472 00473 // Initialise the custom dlg template 00474 ERROR2IF(!InitCustomDlg(),IDCANCEL,"Unable to init the print dlg with our custom template"); 00475 00476 // Update our details about this printer 00477 UpdatePrinterSettings(FALSE); 00478 00479 // Set the print control to print the selected spread 00480 // Do this after UpdatePrinterSettings() to make sure it uses the right values! 00481 LocalPrintControl.SetUp(Document::GetSelectedSpread()); 00482 00483 // Display the dlg to the user, and return the result 00484 BOOL ok = FALSE; 00485 BOOL Reopen = FALSE; 00486 do 00487 { 00488 // If we are reopening the main print dlg, update the printer settings first 00489 // (NB: This should only happen in Win3.1 after the print setup dlg has been used. 00490 // See CCPrintDialog::OnPrintSetup()) 00491 if (Reopen) 00492 UpdatePrinterSettings(); 00493 00494 // Keep Control Helper system informed 00495 ControlHelper::InformModalDialogOpened(); 00496 00497 // Open the main print dlg (uses ::PrintDlg() in the depths of MFC) 00498 ok = CPrintDialog::DoModal(); 00499 FixFPControlRegister(); 00500 00501 // Keep Control Helper system informed 00502 ControlHelper::InformModalDialogClosed(); 00503 00504 Reopen = ReopenMainDlg; // Do we need to reopen the main print dlg? 00505 ReopenMainDlg = FALSE; // Make sure this flag is cleared, or we'll be here all day 00506 00507 } while (Reopen); 00508 00509 // If we are to ignore the printer data (because the selected printer has been deleted, renamed, etc) 00510 // then we must reset the global memory handles that hold the data, as the settings they contain 00511 // no longer refer to a printer known by the host system 00512 if (IgnorePrintData()) 00513 { 00514 FreeGlobalHandle(&m_pd.hDevMode); 00515 FreeGlobalHandle(&m_pd.hDevNames); 00516 ResetIgnorePrintData(); 00517 } 00518 00519 ERROR3IF(pCurrentCCPrintDialog == NULL,"pCurrentCCPrintDialog is NULL"); 00520 pCurrentCCPrintDialog = NULL; 00521 00522 return ok; 00523 } 00524 #endif 00525 00526 //------------------- 00527 00528 /******************************************************************************************** 00529 00530 > static BOOL CCPrintDialog::GetPrinterSettings(BOOL RedrawPrintBorders = TRUE) 00531 00532 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00533 Created: 5/4/95 00534 Inputs: RedrawPrintBorders if a force redraw should be issued (Defaults to TRUE) 00535 Returns: TRUE if OK, FALSE otherwise 00536 Purpose: This function ensures that we have a valid set of printer settings. 00537 00538 If this is the first time this function has been called, it uses a CCPrintDialog 00539 to get the default settings from the printer driver. 00540 00541 If we already have a set of valid settings, this func does nothing 00542 00543 SeeAlso: - 00544 00545 ********************************************************************************************/ 00546 00547 BOOL CCPrintDialog::GetPrinterSettings(BOOL RedrawPrintBorders) 00548 { 00549 if (!GotPrinterSettings) 00550 { 00551 Progress Hourglass(_R(IDS_UPDATE_PRINTER_SETTINGS),-1,FALSE); 00552 Hourglass.Update(); 00553 00554 CCPrintInfo * pPrintInfo = CCPrintInfo::GetCurrent(); 00555 BOOL Local=FALSE; 00556 if (!pPrintInfo) 00557 { 00558 pPrintInfo = new CCPrintInfo(Document::GetSelected(), NULL); 00559 ERROR2IF(!pPrintInfo, FALSE, "Cannot get print info"); 00560 Local = TRUE; 00561 } 00562 00563 //CCPrintDialog PrintDlg(pPrintInfo); // Use CCPrintDialog to get hold of printer's DEVMODE settings 00564 00565 pPrintInfo->UpdatePrinterSettings(RedrawPrintBorders); 00566 00567 if (Local) 00568 delete pPrintInfo; 00569 00570 } 00571 00572 return (GotPrinterSettings); 00573 } 00574 00575 /******************************************************************************************** 00576 00577 > static void CCPrintDialog::ResetToDefaultPrinter() 00578 00579 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00580 Created: 8/2/96 00581 Inputs: - 00582 Returns: - 00583 Purpose: Use this function to tell the printing system that the printer data has been reset 00584 so that it will use the default printer next time you print. 00585 00586 If there are any print-related dialogs open, they will be closed. 00587 00588 If a dialog is closed, the function will display a warning to the user. 00589 00590 If a dialog is not closed, a flag is set so that the warning will be displayed when 00591 the user next tries to print something. 00592 00593 SeeAlso: CCamApp::ResetToDefaultPrinter() 00594 00595 ********************************************************************************************/ 00596 00597 void CCPrintDialog::ResetToDefaultPrinter() 00598 { 00599 if (GotPrinterSettings) 00600 { 00601 GotPrinterSettings = FALSE; // We need new printer settings 00602 InformPrinterReset = TRUE; // We need to inform the use about what's happening 00603 00604 // Close any print dlgs that may be open 00605 ClosePrintDialogs(); 00606 00607 // Get the default printer settings 00608 GetPrinterSettings(); 00609 } 00610 } 00611 00612 /******************************************************************************************** 00613 00614 > static void CCPrintDialog::ClosePrintDialogs() 00615 00616 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00617 Created: 8/2/96 00618 Inputs: - 00619 Returns: - 00620 Purpose: Closes any print-related dlgs that may be open. 00621 If any dlgs are closed, and it is due to resetting to the default printer, 00622 a warning will be issued to the user informing them of this fact. 00623 00624 SeeAlso: static BOOL ResetToDefaultPrinter() 00625 00626 ********************************************************************************************/ 00627 00628 void CCPrintDialog::ClosePrintDialogs() 00629 { 00630 // Close the print prefs tabbed dlg 00631 PrintPrefsDlg::CloseCurrentDlg(); 00632 00633 #ifndef EXCLUDE_FROM_XARALX 00634 // Close the print setup dlg that's opened from the main print dlg 00635 if (pDlgSetup != NULL) 00636 { 00637 IgnorePrntData = TRUE; // We are forcing the closure of the print dlgs 00638 // Inform the user if we have switched to using the default printer on the system 00639 // before closing dialog 00640 InformResetToDefaultPrinter(TRUE); 00641 delete pDlgSetup; 00642 pDlgSetup = NULL; 00643 } 00644 00645 // Close the main print dlg 00646 if (pCurrentCCPrintDialog != NULL) 00647 { 00648 IgnorePrntData = TRUE; // We are forcing the closure of the print dlgs 00649 // Inform the user if we have switched to using the default printer on the system 00650 // before closing dialog 00651 InformResetToDefaultPrinter(TRUE); 00652 delete pCurrentCCPrintDialog; 00653 pCurrentCCPrintDialog = NULL; 00654 } 00655 #endif 00656 00657 } 00658 00659 #endif 00660 00661 /******************************************************************************************** 00662 00663 > static void CCPrintDialog::InformResetToDefaultPrinter(BOOL ClosingDlgs) 00664 00665 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00666 Created: 8/2/96 00667 Inputs: ClosingDlgs - TRUE if the caller will also close any print dlgs too. 00668 Returns: - 00669 Purpose: Displays a warning to the user saying that we have switched to the default printer. 00670 00671 It only does this if the flag InformPrinterReset is TRUE. 00672 00673 After displaying the warning, InformPrinterReset is set to FALSE, so you can call this 00674 func as often as you like - it will only get displayed once until the next time we 00675 switch to the default printer. 00676 00677 If this is called just before closing any print dlgs, call with ClosingDlgs=TRUE. 00678 This will display a slightly different warning explaining the dlgs will be closed. 00679 00680 SeeAlso: static BOOL ResetToDefaultPrinter() 00681 00682 ********************************************************************************************/ 00683 00684 void CCPrintDialog::InformResetToDefaultPrinter(BOOL ClosingDlgs) 00685 { 00686 if (InformPrinterReset) 00687 { 00688 if (ClosingDlgs) 00689 InformWarning(_R(IDS_RESET_PRINTER_REOPEN)); 00690 else 00691 InformWarning(_R(IDS_RESET_PRINTER)); 00692 00693 InformPrinterReset = FALSE; 00694 } 00695 } 00696 00697 #ifndef EXCLUDE_FROM_XARALX 00698 00699 /******************************************************************************************** 00700 00701 > static void CCPrintDialog::GetSelectedPrinterName(LPTSTR pName,INT32 BufferSize) 00702 00703 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00704 Created: 15/2/96 00705 Inputs: pName = ptr to buffer to place name in 00706 BufferSize = size of buffer pointed to by BufferSize 00707 Returns: - 00708 Purpose: This will return what is considered to be the name of the app's selected printer 00709 00710 If the main print dlg or the print setup dlg (opened via the File menu) are open, 00711 the name is taken from them. 00712 00713 Otherwise, the app's cached printer data is used, and this is gained vai CCamApp::GetDevNames() 00714 00715 If no printer is found, pName == "" (i.e. pName[0] == 0). 00716 00717 SeeAlso: static BOOL ResetToDefaultPrinter() 00718 00719 ********************************************************************************************/ 00720 00721 void CCPrintDialog::GetSelectedPrinterName(LPTSTR pName,INT32 BufferSize) 00722 { 00723 // Enough of these silly values 00724 ERROR3IF(pName == NULL || BufferSize < 1,"How about some senisble input params eh?"); 00725 if (pName == NULL || BufferSize < 1) 00726 return; 00727 00728 CCamApp *pCamApp = (CCamApp *)AfxGetApp(); 00729 00730 // Default to the app's DEVMODE structure 00731 HGLOBAL hDevNames = NULL; 00732 if(pCamApp != NULL) 00733 hDevNames = pCamApp->GetDevNames(); 00734 00735 // If we have a main print dlg up, look at the selected printer within the dlg 00736 if (pCurrentCCPrintDialog != NULL) 00737 hDevNames = pCurrentCCPrintDialog->m_pd.hDevNames; 00738 00739 // If we have the print setup dlg open from the file menu, look at the selected printer within it 00740 if (pCamApp != NULL && pCamApp->GetFilePrintSetupDlg() != NULL) 00741 hDevNames = pCamApp->GetFilePrintSetupDlg()->m_pd.hDevNames; 00742 00743 // NULL terminate now, just in case things go wrong 00744 pName[0] = 0; 00745 00746 if (hDevNames != NULL) 00747 { 00748 // Get a ptr to the memory block defined by hDevNames 00749 DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames); 00750 if (pDevNames != NULL) 00751 { 00752 // Copy the name from the DEVNAMES field into the buffer provided 00753 camStrncpy(pName,LPTSTR(pDevNames) + pDevNames->wDeviceOffset,BufferSize); 00754 ::GlobalUnlock(hDevNames); 00755 } 00756 } 00757 } 00758 00759 #endif 00760 00761 /******************************************************************************************** 00762 00763 > BOOL CCPrintInfo::UpdatePrinterSettings(BOOL RedrawPrintBorders = TRUE) 00764 00765 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00766 Created: 14/4/95 00767 Inputs: RedrawPrintBorders = TRUE if you want any visible print borders redrawing 00768 Returns: TRUE if ok, FALSE otherwise 00769 Purpose: Updates the static members that represent the current printer settings Camelot 00770 is interested in, such a paper size, orientation, etc. 00771 It uses the DEVMODE structure returned by GetDevMode(), plus member funcs for 00772 driver, device and port names. 00773 00774 This sets the static member GotPrinterSettings to TRUE if successful 00775 00776 SeeAlso: static BOOL UpdatePrinterSettings() 00777 00778 ********************************************************************************************/ 00779 00780 BOOL CCPrintInfo::UpdatePrinterSettings(BOOL RedrawPrintBorders) 00781 { 00782 wxDC * dc = MakeDCFromPrintData(&GetPrintData()); 00783 BOOL ret=CCPrintDialog::UpdatePrinterSettings(m_pNativePrintData,dc,pDocument,RedrawPrintBorders); 00784 delete dc; 00785 return ret; 00786 } 00787 00788 /******************************************************************************************** 00789 00790 > static BOOL CCPrintDialog::UpdatePrinterSettings(wxPrintData * pPrintData, wxDC * pDC, Document* pDocument, BOOL RedrawPrintBorders) 00791 00792 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00793 Created: 5/4/95 00794 Inputs: pDevMode = ptr to a DEVMODE used to extract printer settings from 00795 hdc = printer device context (can be NULL) 00796 pDocument= ptr to associated doc (NULL means use current doc) 00797 RedrawPrintBorders = TRUE if you want any visible print borders redrawing 00798 Returns: TRUE if ok, FALSE otherwise 00799 Purpose: Updates the static members that represent the current printer settings Camelot 00800 is interested in, such a paper size, orientation, etc. 00801 00802 This sets the static member GotPrinterSettings to TRUE if successful 00803 00804 It will also redraw all views in the given doc that are showing print borders 00805 00806 SeeAlso: - 00807 00808 ********************************************************************************************/ 00809 00810 BOOL CCPrintDialog::UpdatePrinterSettings(wxPrintData * pPrintData, wxDC * pDC, Document* pDocument, BOOL RedrawPrintBorders) 00811 { 00812 if (pPrintData == NULL) 00813 { 00814 TRACE( _T("CCPrintDialog::UpdatePrinterSettings() - pPrintData is NULL")); 00815 GotPrinterSettings = FALSE; 00816 return FALSE; 00817 } 00818 00819 BOOL InitPaperSize = FALSE; 00820 00821 // First, look-up the paper size if we can, as this is more accurate than using the DC to get the 00822 // physical width & height plus X & Y dpi 00823 if (!InitPaperSize) 00824 { 00825 // The dmPaperSize field has been initialised, so look up the paper dimensions 00826 // if this value is not 0 00827 // Note: I discovered a page in MSDN on 7/2/96 that states that a paper size value 00828 // of wxPAPER_USER means "get size from dmPaperWidth & dmPaperLength" 00829 if (pPrintData->GetPaperId() != wxPAPER_NONE) 00830 InitPaperSize = LookUpPaperSize(pPrintData->GetPaperId(),&PrPaperSize); 00831 } 00832 00833 // Use the DC to find out the paper size 00834 if (!InitPaperSize && pDC) 00835 { 00836 double xdpi = pDC->GetPPI().GetWidth(); // Get X & Y dots (pixels) per inch 00837 double ydpi = pDC->GetPPI().GetHeight(); 00838 00839 ERROR3IF(xdpi == 0,"(papersize) xdpi == 0"); 00840 ERROR3IF(ydpi == 0,"(papersize) ydpi == 0"); 00841 00842 // Find the width and height in inches 00843 double width =double(pDC->GetSize().GetWidth()) / xdpi; // 2479.0 00844 double height =double(pDC->GetSize().GetHeight()) / ydpi; // 3504.0 00845 00846 PrPaperSize = wxSize(IN_TO_MP(width), IN_TO_MP(height)); 00847 InitPaperSize = TRUE; 00848 } 00849 00850 if (!InitPaperSize) 00851 { 00852 // If we still haven't managed to get the paper size, then error in debug builds 00853 // and set the paper size to a sensible default 00854 ERROR3("Unable to extract paper size"); 00855 LookUpPaperSize(wxPAPER_A4,&PrPaperSize); 00856 } 00857 00858 // --------------------------------- 00859 // Extract paper orientation 00860 // 00861 00862 // Has the orientation field been initialised? 00863 PrPortrait = (pPrintData->GetOrientation() == wxPORTRAIT); 00864 00865 // --------------------------------- 00866 // Extract print quality (i.e. resolution in dots per inch) 00867 // 00868 // It turns out that the printer quality setting isn't always set in the DEVMODE structure. If this is the 00869 // case, the hdc param is used to extract the device x & y resolution 00870 00871 // Set PrResolution to a value that means "yet to find printer resolution" 00872 PrResolution = -1; 00873 00874 // Use the DC to find the resolution, in preference to using the DEVMODE structure 00875 // (Overall DPI is the smallest between the X and Y resolution of the device) 00876 if (PrResolution <= 0 && pDC) 00877 { 00878 PrResolutionX = pDC->GetPPI().GetWidth(); 00879 PrResolutionY = pDC->GetPPI().GetHeight(); 00880 00881 PrResolution = min(PrResolutionX,PrResolutionY); 00882 } 00883 00884 // If we failed to get the printer resolution using the DC, try the DEVMODE structure 00885 if (PrResolution <= 0) 00886 { 00887 PrResolution = pPrintData->GetQuality(); 00888 PrResolutionX = PrResolutionY = PrResolution; // The X & Y res are the same 00889 } 00890 00891 // If all else fails, fall back on a default value 00892 if (PrResolution <= 0) 00893 { 00894 ERROR3IF(pDC == NULL,"hdc is NULL. Try supplying one in order to get printer resolution."); 00895 ERROR3("Unable to find the printer resolution"); 00896 PrResolution = 300; 00897 PrResolutionX = PrResolutionY = PrResolution; // The X & Y res are the same 00898 } 00899 00900 // --------------------------------- 00901 // Extract the margins of the printable area on the paper 00902 // (we can only do this via the DC) 00903 00904 #ifndef EXCLUDE_FROM_XARALX 00905 if (hdc != NULL) 00906 { 00907 // Find out the various printer bits and bobs, all measured in pixels 00908 double left,top,width,height; 00909 00910 if (IsWindows31()) //IsWin32s() && !IsWin32c()) 00911 { 00912 POINT offsets,size; 00913 ::Escape(hdc,GETPRINTINGOFFSET,NULL,NULL,&offsets); 00914 ::Escape(hdc,GETPHYSPAGESIZE,NULL,NULL,&size); 00915 00916 left = double(offsets.x); // 54.0 00917 top = double(offsets.y); // 50.0 00918 width = double(size.x); // 2479.0 00919 height = double(size.y); // 3504.0 00920 00921 //TRACE( _T("GETPRINTINGOFFSET.x = %ld\n"),offsets.x); 00922 //TRACE( _T("GETPRINTINGOFFSET.y = %ld\n"),offsets.y); 00923 //TRACE( _T("GETPHYSPAGESIZE.x = %ld\n"),size.x); 00924 //TRACE( _T("GETPHYSPAGESIZE.y = %ld\n"),size.y); 00925 //TRACE( _T("\n")); 00926 } 00927 else 00928 { 00929 left = double(::GetDeviceCaps(hdc,PHYSICALOFFSETX)); // left margin // 54.0 00930 top = double(::GetDeviceCaps(hdc,PHYSICALOFFSETY)); // top margin // 50.0 00931 width = double(::GetDeviceCaps(hdc,PHYSICALWIDTH)); // width of paper // 2479.0 00932 height = double(::GetDeviceCaps(hdc,PHYSICALHEIGHT)); // height of paper // 3504.0 00933 00934 //TRACE( _T("PHYSICALOFFSETX = %ld\n"),INT32(left)); 00935 //TRACE( _T("PHYSICALOFFSETY = %ld\n"),INT32(top)); 00936 //TRACE( _T("PHYSICALWIDTH = %ld\n"),INT32(width)); 00937 //TRACE( _T("PHYSICALHEIGHT = %ld\n"),INT32(height)); 00938 } 00939 00940 double hres = double(::GetDeviceCaps(hdc,HORZRES)); // width of printable area 2366.0 00941 double yres = double(::GetDeviceCaps(hdc,VERTRES)); // height of printable area 3404.0 00942 double xdpi = double(::GetDeviceCaps(hdc,LOGPIXELSX)); // Get X & Y dots (pixels) per inch 300.0 00943 double ydpi = double(::GetDeviceCaps(hdc,LOGPIXELSY)); // 300.0 00944 00945 ERROR3IF(xdpi == 0,"xdpi == 0"); 00946 ERROR3IF(ydpi == 0,"ydpi == 0"); 00947 00948 //TRACE( _T("HORZRES = %ld\n"),INT32(hres)); 00949 //TRACE( _T("VERTRES = %ld\n"),INT32(yres)); 00950 //TRACE( _T("LOGPIXELSX = %ld\n"),INT32(xdpi)); 00951 //TRACE( _T("LOGPIXELSY = %ld\n"),INT32(ydpi)); 00952 00953 PrLeftMargin = IN_TO_MP(left / xdpi); 00954 PrTopMargin = IN_TO_MP(top / ydpi); 00955 PrRightMargin = IN_TO_MP((width-hres-left) / xdpi); 00956 PrBottomMargin = IN_TO_MP((height-yres-top) / ydpi); 00957 } 00958 else 00959 #endif 00960 { 00961 PrLeftMargin = 0; 00962 PrTopMargin = 0; 00963 PrRightMargin = 0; 00964 PrBottomMargin = 0; 00965 } 00966 00967 // --------------------------------- 00968 // Is printer a Postscript printer? 00969 // 00970 PrPostscript = pDC->IsKindOf(CLASSINFO(wxPostScriptDC)); 00971 00972 #ifndef EXCLUDE_FROM_XARALX 00973 // --------------------------------- 00974 // Extract the scale factor 00975 // 00976 if (Fields & DM_SCALE) 00977 { 00978 PrScale = pDevMode->dmScale; 00979 00980 // is the value sensible? 00981 if (PrScale <= 0) 00982 { 00983 ERROR3_PF(("Bad printer scale factor (%d)",PrScale)); 00984 PrScale = 100; 00985 } 00986 } 00987 else 00988 #endif 00989 { 00990 // We haven't managed to get the print scale, so error in debug builds 00991 // and set the scale to a sensible default 00992 //ERROR3("Unable to extract print scale from given DEVMODE"); 00993 PrScale = 100; 00994 } 00995 00996 // --------------------------------- 00997 // Extract the printer's ability to do multiple copies. 00998 // 00999 PrMultiCopies = 1; // ((Fields & DM_COPIES) != 0); 01000 01001 // --------------------------------- 01002 // Final processing on extracted data 01003 // 01004 01005 if (!PrPortrait) 01006 { 01007 // If landscape printing, swap the width and height of the paper to which we will print to 01008 PrPaperSize=wxSize(PrPaperSize.GetHeight(),PrPaperSize.GetWidth()); 01009 } 01010 01011 if (PrScale != 100) 01012 { 01013 // If the printer driver is applying a scale factor, scale the real paper size to the apparent 01014 // size of the paper after scaling 01015 01016 double w = PrPaperSize.GetWidth(); // w = width of paper 01017 double h = PrPaperSize.GetHeight(); // h = height of paper 01018 double f = 100/double(PrScale); // f = scale factor applied by printer driver 01019 01020 PrPaperSize = wxSize(MILLIPOINT((w*f)+0.5), MILLIPOINT((h*f)+0.5)); 01021 } 01022 01023 GotPrinterSettings = TRUE; // Note that we have a set of valid printer settings now 01024 01025 // Tell everyone that the print settings have changed 01026 BROADCAST_TO_ALL(PrintMsg(PrintMsg::SETTINGSCHANGED)); 01027 01028 // Update the document's print control to make sure it recalculates scale factors etc, and 01029 // redraw any views that are showing their print borders 01030 if (pDocument == NULL) 01031 pDocument = Document::GetSelected(); 01032 01033 if (pDocument != NULL) 01034 { 01035 PrintControl* pPrCtrl = NULL; 01036 PrintComponent* pComp = (PrintComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent)); 01037 if (pComp != NULL) 01038 pPrCtrl = pComp->GetPrintControl(); 01039 01040 if (pPrCtrl != NULL) 01041 pPrCtrl->SetUp(pDocument->GetSelectedSpread()); 01042 01043 if (RedrawPrintBorders) 01044 { 01045 CBitmapCache* pBC = Camelot.GetBitmapCache(); 01046 pBC->DeInitialise(); // Brute force cache clear 01047 01048 // Redraw all views that are showing their print borders 01049 FRDocViewFunc pFunc = PrintControl::RedrawPrintableArea; 01050 pDocument->ForceRedraw(pFunc); 01051 } 01052 } 01053 01054 return (TRUE); 01055 } 01056 01057 01058 01059 /******************************************************************************************** 01060 01061 > static BOOL CCPrintDialog::IsPostscript() 01062 01063 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01064 Created: 15/6/95 01065 Inputs: - 01066 Returns: TRUE means the printer is a Postscript printer, FALSE otherwise 01067 Purpose: Use this to find out if the printer is a Postscript one or not. 01068 SeeAlso: - 01069 01070 ********************************************************************************************/ 01071 01072 BOOL CCPrintDialog::IsPostscript() 01073 { 01074 PORTNOTE("printing", "Make printer always appear to be postscript") 01075 #ifndef EXCLUDE_FROM_XARALX 01076 GetPrinterSettings(); 01077 return PrPostscript; 01078 #else 01079 return TRUE; 01080 #endif 01081 } 01082 01083 01084 /******************************************************************************************** 01085 01086 > static BOOL CCPrintDialog::LookUpPaperSize(UINT32 PaperSizeID,wxSize* pPaperSize) 01087 01088 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01089 Created: 6/4/95 01090 Inputs: PaperSizeID = ID of the paper, i.e. wxPAPER_? 01091 pPaperSize = ptr to place to put dimensions in (defined in MILLIPOINTS) 01092 Returns: TRUE means found, FALSE otherwise 01093 Purpose: This looks up the paper size in our table of standard paper sizes, and puts the dimensions 01094 in pPaperSize. 01095 01096 If PaperSizeID > 0, and it's not found, then we're in trouble! 01097 01098 SeeAlso: - 01099 01100 ********************************************************************************************/ 01101 01102 BOOL CCPrintDialog::LookUpPaperSize(UINT32 PaperSizeID,wxSize* pPaperSize) 01103 { 01104 ERROR2IF(pPaperSize == NULL,FALSE,"pPaperSize is NULL"); 01105 01106 for(INT32 i=0;pPaperSizes[i].ID != wxPAPER_LISTEND;i++) 01107 { 01108 if (pPaperSizes[i].ID == PaperSizeID) 01109 { 01110 *pPaperSize = wxSize(pPaperSizes[i].Width, pPaperSizes[i].Height); 01111 return TRUE; 01112 } 01113 } 01114 01115 ERROR3_PF(("Couldn't find paper size for paper ID %d",PaperSizeID)); 01116 01117 return FALSE; 01118 } 01119 01120 /******************************************************************************************** 01121 01122 > static BOOL CCPrintDialog::GetPaperSize(wxSize* pPaperSize, BOOL RedrawPrintBorders = TRUE) 01123 01124 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01125 Created: 5/4/95 01126 Inputs: pPaperSize = ptr to a wxSize struct to place the size of the paper into 01127 RedrawPrintBorders - True (Default) to force a redraw of docs 01128 Returns: TRUE means OK, FALSE otherwise 01129 Purpose: Retrieves the physical size of the printer's paper, in MILLIPOINTS 01130 01131 This size takes into account any processing that is done by t