00001 // $Id: prnprefs.cpp 1362 2006-06-25 17:49:11Z 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 // 00099 // PrintPrefs.cpp 00100 // 00101 // This file implements the dialogue box that allows the user to set the 00102 // preferences for the printer. Brought up from the print dialog box. 00103 // Uses the same system as the application preferences 00104 00105 /* 00106 */ 00107 00108 #include "camtypes.h" 00109 // WEBSTER-ranbirr-13/11/96 00110 #ifndef WEBSTER 00111 //#include "app.h" // Camelot object - in camtypes.h [AUTOMATICALLY REMOVED] 00112 //#include "dialogop.h" // DialogOp header - in camtypes.h [AUTOMATICALLY REMOVED] 00113 #include "appprefs.h" 00114 #include "prnprefs.h" 00115 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00116 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00117 //#include "optsres.h" // error strings 00118 //#include "prefsdlg.h" // _R(IDD_DOCUMENTOPTIONS) 00119 #include "prnmks.h" 00120 #include "optsprin.h" 00121 #include "printmsg.h" 00122 //#include "printdlg.h" 00123 00124 // This is not compulsory, but you may as well put it in so that the correct version 00125 // of your file can be registered in the .exe 00126 DECLARE_SOURCE("$Revision: 1362 $"); 00127 00128 // An implement to match the Declare in the .h file. 00129 // If you have many classes, it is recommended to place them all together, 00130 // here at the start of the file 00131 CC_IMPLEMENT_DYNCREATE(PrintPrefsDlg, DialogTabOp) 00132 CC_IMPLEMENT_DYNCREATE(PrintTabPrintPrefsDlg, PrintPrefsDlg) 00133 00134 // This will get Camelot to display the filename and linenumber of any memory allocations 00135 // that are not released at program exit 00136 #define new CAM_DEBUG_NEW 00137 00138 // Set up explicit details about this dialog box such as the id and type 00139 const CDlgResID PrintPrefsDlg::IDD = _R(IDD_DOCUMENTOPTIONS); // Dialog box id 00140 const CDlgMode PrintPrefsDlg::Mode = MODAL; //make it modal for now 00141 //const CDlgMode PrintPrefsDlg::Mode = MODELESS; // This dialog is modeless 00142 00143 BOOL PrintPrefsDlg::OkUsed = FALSE; // remember whether ok or cancel used 00144 BOOL PrintPrefsDlg::Open = FALSE; // Are we open? 00145 PrintPrefsDlg* PrintPrefsDlg::pCurrentDlg = NULL; // ptr to current op desc 00146 00147 /****************************************************************************************** 00148 00149 > static BOOL PrintPrefsDlg::InvokeDialog() 00150 00151 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00152 Created: 12/4/94 00153 Inputs: - 00154 Outputs: - 00155 Returns: True if Ok used or False if Cancel used. 00156 Purpose: How to invoke or start a PrintPrefsDlg box. 00157 Errors: - 00158 SeeAlso: - 00159 00160 ******************************************************************************************/ 00161 00162 BOOL PrintPrefsDlg::InvokeDialog() 00163 { 00164 static BOOL FirstTime = TRUE; 00165 00166 if (!Open) 00167 { 00168 Open = TRUE; 00169 00170 // First time through we want to force open the second Print tab as opposed to the Output 00171 // tab as this is deemed to be the better option. 00172 OpDescriptor *pOpDesc = NULL; 00173 if (!FirstTime) 00174 { 00175 pOpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(PrintPrefsDlg)); 00176 } 00177 else 00178 { 00179 // Only do this the first time 00180 FirstTime = FALSE; 00181 pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_PRINTOPTIONSDLG); 00182 } 00183 ERROR3IF(pOpDesc == NULL,"PrintPrefsDlg::InvokeDialog is unable to find the PrintPrefsDlg OpDescriptor"); 00184 00185 if (pOpDesc != NULL) 00186 pOpDesc->Invoke(); 00187 00188 Open = FALSE; 00189 00190 return OkUsed; 00191 } 00192 else 00193 { 00194 ERROR3("PrintPrefsDlg::InvokeDialog() called again, before previous call returned"); 00195 return FALSE; 00196 } 00197 } 00198 00199 00200 /****************************************************************************************** 00201 00202 > PrintPrefsDlg::PrintPrefsDlg(): DialogTabOp(PrintPrefsDlg::IDD, PrintPrefsDlg::Mode) 00203 00204 00205 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00206 Created: 12/4/95 00207 Inputs: - 00208 Outputs: - 00209 Returns: - 00210 Purpose: PrintPrefsDlg constructor. Creates a non-undoable operation 00211 Errors: - 00212 SeeAlso: - 00213 00214 ******************************************************************************************/ 00215 00216 PrintPrefsDlg::PrintPrefsDlg(): DialogTabOp(PrintPrefsDlg::IDD, PrintPrefsDlg::Mode) 00217 { 00218 // At present, just:- 00219 OptionsTabs::SetApplyNowState(FALSE); // grey the apply now button 00220 OptionsTabs::SetInitMessageState(FALSE); // not sending an init message 00221 OptionsTabs::pScopeDocument = NULL; // Document in use when sending messages 00222 00223 // Set default units 00224 OptionsTabs::SetDefaultUnits(); // set up our default display units 00225 00226 // Document and spread we are supposed to be working on. Of course none at present. 00227 OptionsTabs::SetCurrentDocAndSpread(NULL); 00228 00229 PrintPrefsDlg::SetCurrentDlg(this); 00230 } 00231 00232 /****************************************************************************************** 00233 00234 > PrintPrefsDlg::PrintPrefsDlg(INT32 StartingPage): DialogTabOp(PrintPrefsDlg::IDD, PrintPrefsDlg::Mode) 00235 00236 00237 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00238 Created: 13/10/94 00239 Inputs: - 00240 Outputs: - 00241 Returns: - 00242 Purpose: PrintPrefsDlg constructor. Creates a non-undoable operation 00243 Errors: - 00244 SeeAlso: - 00245 00246 ******************************************************************************************/ 00247 00248 PrintPrefsDlg::PrintPrefsDlg(INT32 StartingPage): DialogTabOp(PrintPrefsDlg::IDD, PrintPrefsDlg::Mode, 00249 CC_RUNTIME_CLASS(DialogOp), StartingPage) 00250 { 00251 // At present, just:- 00252 OptionsTabs::SetApplyNowState(FALSE); // grey the apply now button 00253 OptionsTabs::SetInitMessageState(FALSE); // not sending an init message 00254 OptionsTabs::pScopeDocument = NULL; // Document in use when sending messages 00255 00256 // Set default units 00257 OptionsTabs::SetDefaultUnits(); // set up our default display units 00258 00259 // Document and spread we are supposed to be working on. Of course none at present. 00260 OptionsTabs::SetCurrentDocAndSpread(NULL); 00261 00262 PrintPrefsDlg::SetCurrentDlg(this); 00263 } 00264 00265 00266 /****************************************************************************************** 00267 00268 > PrintPrefsDlg::~PrintPrefsDlg() 00269 00270 00271 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00272 Created: 12/4/95 00273 Inputs: - 00274 Outputs: - 00275 Returns: - 00276 Purpose: PrintPrefsDlg destructor. 00277 Errors: - 00278 SeeAlso: - 00279 00280 ******************************************************************************************/ 00281 00282 PrintPrefsDlg::~PrintPrefsDlg() 00283 { 00284 // Make sure that we remove our options tabs link to the dialog box class 00285 // as the dialog will now be destroyed 00286 OptionsTabs::pPrefsDlg = NULL; 00287 00288 PrintPrefsDlg::SetCurrentDlg(NULL); 00289 } 00290 00291 00292 /****************************************************************************************** 00293 00294 > BOOL PrintPrefsDlg::CommitDialogValues() 00295 00296 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00297 Created: 12/4/95 00298 Inputs: - 00299 Outputs: - 00300 Returns: True if values in dialog box ok, False otherwise. 00301 Purpose: Takes the values in the dialog box and sets the return values accordingly 00302 Called when ok is pressed on the dialog box. 00303 Errors: - 00304 SeeAlso: - 00305 00306 ******************************************************************************************/ 00307 00308 BOOL PrintPrefsDlg::CommitDialogValues() 00309 { 00310 // Ok has been pressed so take the values from the dialog box 00311 BOOL ok = TRUE; 00312 BOOL ValuesOk = TRUE; 00313 00314 // Go through all the tabs declared to the system in turn 00315 // and tell them to commit the values for their tab 00316 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00317 00318 while (pOptionsTabs != NULL) 00319 { 00320 // Only get the tab to commit if it is a print based option 00321 if ( pOptionsTabs->IsPrintingOption() ) 00322 { 00323 // Get the found page to commit its values. 00324 // Should return False if reported error and we should just fail. 00325 // 2 if set an error which we should report and then fail. 00326 ok = pOptionsTabs->CommitSection(); 00327 if ( ok != TRUE ) 00328 { 00329 if (ok == 2) 00330 InformError(); // If error required show it. 00331 00332 // Carry on with other pages so that report all errors and have a chance 00333 // to correct mistakes in other pages but make note of error state. 00334 ValuesOk = FALSE; 00335 //return FALSE; 00336 } 00337 } 00338 // Get the next option's tab. 00339 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00340 } 00341 00342 // Return whether we found bad values or not. 00343 return ValuesOk; 00344 } 00345 00346 /****************************************************************************************** 00347 00348 > MsgResult PrintPrefsDlg::Message(CDlgMessage DlgMsg, CGadgetID Gadget) 00349 00350 00351 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00352 Created: 12/4/95 00353 Inputs: - 00354 Outputs: - 00355 Returns: OK Message handled ok (return this even if you don't need to 00356 respond to the message). 00357 00358 FAIL Something terrible happened whilst processing the message 00359 eg. we ran out of memory. You must set ERROR if you 00360 are returning this value. 00361 00362 EAT_MSG The Message was handled ok but don't send it to any 00363 more MessageHandlers. 00364 Purpose: Handles all the application preferences dialog's messages 00365 Errors: - 00366 SeeAlso: - 00367 00368 ******************************************************************************************/ 00369 00370 MsgResult PrintPrefsDlg::Message(Msg* Message) 00371 { 00372 TRACEUSER( "Neville", _T("PrintPrefsDlg::Message\n")); 00373 ERROR3IF(Message == NULL,"PrintPrefsDlg::Message null message received"); 00374 00375 // Jason - This is a message-loop lock which is used in the DIM_CREATE code to 00376 // allow the print marks manager cache print marks - this causes a lot of diocument 00377 // message broadcats and suchlike, which cause re-entrant messages to come in 00378 // here and trigger 3 billion ERROR3s. While caching the print marks, we lock this 00379 // message handler so that it just ignores all resultant broadcasts. 00380 static BOOL IgnoreAllMessages = FALSE; 00381 if (IgnoreAllMessages) 00382 return DialogTabOp::Message(Message); 00383 00384 00385 // Cope with messages for the dialog box 00386 if (MESSAGE_IS_A(Message,PrintMsg)) // Check for print messages 00387 { 00388 PrintMsg* pPrintMsg = (PrintMsg*)Message; 00389 00390 if (pPrintMsg->Reason == PrintMsg::SETTINGSCHANGED) 00391 { 00392 // Tell the print layout tab about the print settings change 00393 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00394 while (pOptionsTabs != NULL) 00395 { 00396 if (pOptionsTabs->GetPageID() == _R(IDD_OPTSTAB_PRINTLAYOUT) || 00397 pOptionsTabs->GetPageID() == _R(IDD_OPTSTAB_PRINTGENERAL)) 00398 { 00399 PrintBaseTab* pBaseTab = (PrintBaseTab *) pOptionsTabs; 00400 pBaseTab->PrintSettingsChanged(); 00401 } 00402 00403 // Get the next option's tab. 00404 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00405 } 00406 } 00407 00408 return DialogTabOp::Message(Message); 00409 } 00410 00411 if (IS_OUR_DIALOG_MSG(Message)) 00412 { 00413 DialogMsg* Msg = (DialogMsg*)Message; 00414 00415 MsgResult Result; 00416 00417 // Main handler for dialog type messages 00418 BOOL EndDialog = FALSE; // TRUE if we should quit the dialog 00419 BOOL CommitValues = FALSE; // TRUE if we should commit the dialog values 00420 BOOL OldApplyNow = OptionsTabs::GetApplyNowState(); // Old ApplyNow button state 00421 00422 // Make sure that we have set up our class variables so that the tabs know what 00423 // is the current document and spread to work on. 00424 Document *pDocument = Document::GetSelected(); 00425 OptionsTabs::SetCurrentDocAndSpread(pDocument); 00426 // Plus the current document units are correct 00427 OptionsTabs::SetUpDocUnits(); 00428 00429 // Check if sending init/create message and if so set flag True. 00430 // If True then do not ungrey the ApplyNow button on changing messages 00431 if (Msg->DlgMsg == DIM_CREATE) 00432 { 00433 TRACEUSER( "Neville", _T("PrintPrefsDlg::Message DIM_CREATE\n")); 00434 OptionsTabs::SetInitMessageState(TRUE); 00435 } 00436 00437 // If the message is not for the main options window then try the tab pages 00438 BOOL FoundPage = FALSE; 00439 TRACEUSER( "Neville", _T("PrintPrefsDlg::Message PageID = %d\n"),Msg->PageID); 00440 if (Msg->PageID != 0) 00441 { 00442 // Now go through all the tabs declared to the system 00443 // And see if the message is for that page or not. 00444 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00445 00446 while (pOptionsTabs != NULL && !FoundPage) 00447 { 00448 CDlgResID PageId = pOptionsTabs->GetPageID(); 00449 if (PageId == Msg->PageID) 00450 { 00451 // Found the correct page so stop the search and send the message 00452 // to that page 00453 pOptionsTabs->HandleMsg(Msg); 00454 FoundPage = TRUE; 00455 } 00456 // Get the next option's tab. 00457 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00458 } 00459 } 00460 else 00461 { 00462 // Main page window 00463 switch (Msg->DlgMsg) 00464 { 00465 case DIM_CREATE: // Creating the main dialog box 00466 { 00467 // grey out the apply now button as this should only become enabled when 00468 // we have made a change to the dialog box. 00469 OptionsTabs::SetInitMessageState(FALSE); 00470 00471 IgnoreAllMessages = TRUE; 00472 // BLOCK 00473 { 00474 // Make sure the print marks are cached by the PMManager. This must be done now 00475 // because we want to demand-load the marks, but if we leave it any later we get 00476 // an awful lot of rather nasty problems with document messages flying around. 00477 PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager(); 00478 if (pMarksMan) 00479 { 00480 pMarksMan->ConstructCache(); 00481 if (Document::GetSelected() != NULL) 00482 pMarksMan->AddDefaultMarksToDoc(Document::GetSelected()); 00483 } 00484 } 00485 IgnoreAllMessages = FALSE; 00486 00487 OptionsTabs::SetApplyNowState(FALSE); 00488 OptionsTabs::GreyApplyNow(); 00489 // remove the apply now button as not required. 00490 CDlgResID PageID = GetCurrentPageID(); // Get currently selected Tab id 00491 TalkToPage(0); // Select the main tab 00492 HideGadget(_R(ID_APPLY_NOW), TRUE); // hide button on main tab 00493 TalkToPage(PageID); // Select the originally selected tab 00494 00495 // Pass the message up to all the tabs in case it's of use to them 00496 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00497 while (pOptionsTabs != NULL) 00498 { 00499 if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message 00500 pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) 00501 pOptionsTabs->HandleMsg(Msg); 00502 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00503 } 00504 break; 00505 } 00506 00507 00508 case DIM_COMMIT: // Want to commit and quit 00509 { 00510 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00511 while (pOptionsTabs != NULL) 00512 { 00513 if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message 00514 pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) 00515 pOptionsTabs->HandleMsg(Msg); 00516 00517 // Get the next option's tab. 00518 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00519 } 00520 OkUsed = TRUE; // Flag ok used 00521 EndDialog = TRUE; 00522 CommitValues = TRUE; 00523 } 00524 break; 00525 00526 case DIM_SOFT_COMMIT: // Want to commit but leave the dialogue open 00527 { 00528 // Pass the message up to all the tabs in case it's of use to them 00529 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00530 while (pOptionsTabs != NULL) 00531 { 00532 if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message 00533 pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) 00534 pOptionsTabs->HandleMsg(Msg); 00535 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00536 } 00537 00538 OkUsed = TRUE; // Flag ok used 00539 CommitValues = TRUE; 00540 } 00541 break; 00542 00543 case DIM_CANCEL: // Want to quit 00544 { 00545 // Pass the message up to all the tabs in case it's of use to them 00546 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00547 while (pOptionsTabs != NULL) 00548 { 00549 if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message 00550 pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) 00551 pOptionsTabs->HandleMsg(Msg); 00552 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00553 } 00554 } 00555 OkUsed = FALSE; // Flag ok used 00556 EndDialog = TRUE; 00557 break; 00558 00559 default: 00560 break; 00561 } 00562 } 00563 00564 // Commit values here 00565 if (CommitValues) 00566 { 00567 BOOL ok = CommitDialogValues(); 00568 // Only unset EndDialog as in SOFT_COMMIT case we do not want to end the 00569 // Operation and hence close the dialog box 00570 if (!ok) 00571 { 00572 Msg->DlgMsg = DIM_NONE; // prevent baseclass from removing the dialog 00573 EndDialog = FALSE; // Values not correct so do not allow exit 00574 } 00575 } 00576 00577 if ( !OldApplyNow && OptionsTabs::GetApplyNowState() 00578 && !EndDialog && !OptionsTabs::GetInitMessageState() ) 00579 { 00580 // Check for a change from apply now being False to it becoming 00581 // True as an item has been changed. 00582 OptionsTabs::UngreyApplyNow(); 00583 } 00584 00585 if ( OptionsTabs::GetApplyNowState() && (Msg->DlgMsg == DIM_SOFT_COMMIT) 00586 && !EndDialog && !OptionsTabs::GetInitMessageState() ) 00587 { 00588 // Check for an apply now (DIM_SOFT_COMMIT) being used and the 00589 // apply being True, should always be the case, so that we can reset 00590 // the grey state to False as we are in an unchanged state. 00591 OptionsTabs::SetApplyNowState(FALSE); 00592 OptionsTabs::GreyApplyNow(); 00593 } 00594 00595 // End dialog here 00596 if (EndDialog) 00597 { 00598 // Grey all the tabs to remove the Indexed colour in use error 00599 OptionsTabs::SetCurrentDocAndSpread(NULL); 00600 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00601 while (pOptionsTabs != NULL) 00602 { 00603 if (pOptionsTabs->IsPrintingOption()) 00604 pOptionsTabs->GreySection(); 00605 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00606 } 00607 00608 // Note this destroys "this". Hence don't call the base class 00609 Close(); // Hide the dialog box 00610 End(); // Finish the operation 00611 00612 // Make sure that we remove our options tabs link to the dialog box class 00613 // as the dialog will now be destroyed 00614 OptionsTabs::pPrefsDlg = NULL; 00615 return OK; 00616 } 00617 00618 // Allow the base class access to the message, it will do the 00619 // DLG_EAT_IF_HUNGRY(Msg) for us 00620 // Must do this before the Close and End 00621 Result = DialogTabOp::Message(Message); 00622 00623 // Check if have been sending an init/create message and if so then set flag False. 00624 // Only do this in the init/create case as we might be sent one of these and then 00625 // be sent other messages whilst in the middle of the init/create message such as 00626 // text changing messages. 00627 if (Msg->DlgMsg == DIM_CREATE) 00628 OptionsTabs::SetInitMessageState(FALSE); 00629 00630 // The message was for our dialog box so return that we have handled it, if necessary 00631 //return (DLG_EAT_IF_HUNGRY(Msg)); 00632 return Result; 00633 } 00634 00635 // If nobody above has processed the message, then pass it around all the tabs in 00636 // case it's of use to them. 00637 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00638 00639 while (pOptionsTabs != NULL) 00640 { 00641 pOptionsTabs->Message(Message); 00642 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00643 } 00644 00645 return DialogTabOp::Message(Message); 00646 } 00647 00648 /****************************************************************************************** 00649 00650 > OpState PrintPrefsDlg::GetState(String_256*, OpDescriptor*) 00651 00652 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00653 Created: 12/4/95 00654 Inputs: - 00655 Outputs: - 00656 Returns: - 00657 Purpose: PrintPrefsDlg GetState method 00658 Errors: - 00659 SeeAlso: - 00660 00661 ******************************************************************************************/ 00662 00663 OpState PrintPrefsDlg::GetState(String_256*, OpDescriptor*) 00664 { 00665 OpState OpSt; 00666 00667 // If the pointer is non-null then it implies that another dialog box is up which 00668 // uses our tab set and so we must force greying of the menu option 00669 // This one is different in that we force the main options dialog box to be closed. 00670 if (OptionsTabs::pPrefsDlg != NULL) 00671 OpSt.Greyed=TRUE; 00672 00673 return(OpSt); 00674 } 00675 00676 00677 00678 00679 /****************************************************************************************** 00680 00681 > BOOL PrintPrefsDlg::Init() 00682 00683 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00684 Created: 12/4/95 00685 Inputs: - 00686 Outputs: - 00687 Returns: - 00688 Purpose: PrintPrefsDlg Init method. Called when the kernel initialises. 00689 Errors: - 00690 SeeAlso: - 00691 00692 ******************************************************************************************/ 00693 00694 BOOL PrintPrefsDlg::Init() 00695 { 00696 BOOL InitOK; 00697 00698 // Now register ourselves with the dialog system 00699 InitOK = RegisterOpDescriptor( 00700 0, // Tool ID 00701 _R(IDS_PRINTOPTIONS), // String resource ID 00702 CC_RUNTIME_CLASS(PrintPrefsDlg), // Runtime class 00703 OPTOKEN_PRINTOPTIONS, // Token string 00704 GetState, // GetState function 00705 0, // help ID 00706 0, // bubble help 00707 0, // resource ID 00708 0, // control ID 00709 SYSTEMBAR_ILLEGAL, // Bar ID 00710 FALSE, // Recieve system messages 00711 FALSE, // Smart duplicate operation 00712 TRUE, // Clean operation 00713 0, // No vertical counterpart 00714 _R(IDS_PRINTPREFSDLG_ONE), // String for one copy only error 00715 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags ); 00716 ); 00717 00718 // Now register ourselves with the dialog system for the units button on the windows 00719 // button bar as well 00720 InitOK = InitOK && RegisterOpDescriptor( 00721 0, // Tool ID 00722 _R(IDS_PRINTOPTIONS), // String resource ID 00723 CC_RUNTIME_CLASS(PrintTabPrintPrefsDlg), // Runtime class 00724 OPTOKEN_PRINTOPTIONSDLG, // Token string 00725 GetState, // GetState function 00726 0, // help ID 00727 0, // bubble help 00728 0, // resource ID 00729 0, // control ID 00730 SYSTEMBAR_ILLEGAL, // Bar ID 00731 FALSE, // Recieve system messages 00732 FALSE, // Smart duplicate operation 00733 TRUE, // Clean operation 00734 0, // No vertical counterpart 00735 _R(IDS_PRINTPREFSDLG_ONE), // String for one copy only error 00736 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags ); 00737 ); 00738 00739 // Options tabs and page sizes initialised by the applications options (AppPrefsDlg) 00740 // class. 00741 00742 return (InitOK); 00743 } 00744 00745 00746 /****************************************************************************************** 00747 00748 > void PrintPrefsDlg::Do(OpDescriptor*) 00749 00750 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00751 Created: 12/4/95 00752 Inputs: - 00753 Outputs: - 00754 Returns: - 00755 Purpose: Creates then opens the dialog in response to a request from the user. 00756 Errors: - 00757 SeeAlso: - 00758 00759 ******************************************************************************************/ 00760 void PrintPrefsDlg::Do(OpDescriptor*) 00761 { 00762 BOOL ok; 00763 00764 if (OptionsTabs::pPrefsDlg != NULL) 00765 { 00766 ERROR3("PrintPrefsDlg::Do an options tabbed dialog box is already present"); 00767 return; 00768 } 00769 00770 // Set up the name that the main dialog page is going to use 00771 String_256 Temp(_R(IDN_PRINTOPTS)); 00772 TitleString = Temp; 00773 SetName(&TitleString); 00774 00775 // Make sure that our options tabs have a link to the dialog box class 00776 OptionsTabs::pPrefsDlg = this; 00777 OptionsTabs::SetApplyNowState(FALSE); 00778 00779 // Make sure that we have set up our class variables so that the tabs know what 00780 // is the current document and spread to work on. 00781 Document *pDocument = Document::GetSelected(); 00782 OptionsTabs::SetCurrentDocAndSpread(pDocument); 00783 // Work out the document name so that it is ready for options tabs to display. 00784 OptionsTabs::SetDocumentName(pDocument); 00785 00786 00787 // Force the dialog box to be created, as it is non-modal it must be opened if the create 00788 // works ok. 00789 ok = Create(); // create the dialog box 00790 00791 if ( ok ) 00792 { 00793 // // Modal at present so remove the Open() 00794 // Open(); // created ok so open the dialog box up 00795 // 00796 // // grey out the apply now button as this should only become enabled when we have 00797 // // made a change to the dialog box. 00798 // OptionsTabs::SetInitMessageState(FALSE); 00799 // OptionsTabs::SetApplyNowState(FALSE); 00800 // OptionsTabs::GreyApplyNow(); 00801 } 00802 else 00803 { 00804 // Could not create the dialog box so call inform error 00805 InformError(); // Show user the error 00806 End(); // End the operation 00807 } 00808 } 00809 00810 /****************************************************************************************** 00811 00812 > BOOL PrintPrefsDlg::RegisterYourPagesInOrderPlease() 00813 00814 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00815 Created: 12/4/95 00816 Inputs: - 00817 Outputs: - 00818 Returns: return TRUE if all calls to AddAPage returned TRUE, else FALSE 00819 Purpose: This virtual function will get called to give you a chance to add pages to your 00820 DialogTabOp. This function will usually make multiple calls to AddAPage to 00821 register the initial set of pages to be contained in the tab dialog. The pages 00822 should all be the same size and be registered in the left to right order in which 00823 you wish them to appear. 00824 00825 This function get's called directly from the Create method, Don't call it 00826 explicitly yourself. If you return FALSE from this method then the Create 00827 method will fail. 00828 00829 Errors: - 00830 SeeAlso: DialogTabOp::AddAPage; DialogOp::Create 00831 00832 ******************************************************************************************/ 00833 00834 BOOL PrintPrefsDlg::RegisterYourPagesInOrderPlease() 00835 { 00836 BOOL ok = TRUE; 00837 00838 // Now go through all the tabs declared to the system 00839 OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); 00840 00841 while (pOptionsTabs != NULL) 00842 { 00843 // Only add the tab if it is a document based option 00844 if ( pOptionsTabs->IsPrintingOption() ) 00845 { 00846 CDlgResID PageId = pOptionsTabs->GetPageID(); 00847 ok = ok && AddAPage(PageId); 00848 } 00849 00850 // Get the next option's tab. 00851 pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); 00852 } 00853 00854 return (ok); 00855 } 00856 00857 /****************************************************************************************** 00858 00859 > static void PrintPrefsDlg::SetCurrentDlg(PrintPrefsDlg* pDlg) 00860 00861 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00862 Created: 7/2/96 00863 Inputs: pDlg = ptr to a PrintPrefsDlg 00864 Outputs: - 00865 Returns: - 00866 Purpose: This sets the ptr to the currently created PrintPrefsDlg. 00867 There should only be one at a time, so if you set this value 00868 to a non-NULL value, and there's already one set, an ERROR3 will go off 00869 00870 NOTE: This should only be called from the constructors & destructors of 00871 the PrintPrefsDlg class 00872 00873 Errors: - 00874 SeeAlso: PrintPrefsDlg::CloseCurrentDlg() 00875 00876 ******************************************************************************************/ 00877 00878 void PrintPrefsDlg::SetCurrentDlg(PrintPrefsDlg* pDlg) 00879 { 00880 ERROR3IF(pDlg != NULL && pCurrentDlg != NULL,"Setting current Dlg, but there's already one there"); 00881 ERROR3IF(pDlg == NULL && pCurrentDlg == NULL,"Setting current Dlg to NULL, but there's no current dlg"); 00882 00883 pCurrentDlg = pDlg; 00884 } 00885 00886 /****************************************************************************************** 00887 00888 > static void PrintPrefsDlg::CloseCurrentDlg() 00889 00890 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00891 Created: 7/2/96 00892 Inputs: - 00893 Outputs: - 00894 Returns: - 00895 Purpose: This will close the currently open print prefs dlg, if there is one. 00896 If there isn't one open, nothing happens 00897 Errors: - 00898 SeeAlso: PrintPrefsDlg::SetCurrentDlg() 00899 00900 ******************************************************************************************/ 00901 00902 void PrintPrefsDlg::CloseCurrentDlg() 00903 { 00904 if (pCurrentDlg != NULL) 00905 { 00906 DialogMsg Msg(pCurrentDlg->WindowID, DIM_CANCEL, 0); 00907 pCurrentDlg->Message(&Msg); 00908 } 00909 } 00910 00911 /****************************************************************************************** 00912 00913 > PrintTabPrintPrefsDlg::PrintTabPrintPrefsDlg(): PrintPrefsDlg(1) 00914 00915 00916 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00917 Created: 13/2/96 00918 Inputs: - 00919 Outputs: - 00920 Returns: - 00921 Purpose: PrintTabPrintPrefsDlg constructor. Creates a non-undoable operation. 00922 Just starts up the PrintPrefsDlg specifying the tab number that it is in the 00923 list. This has been calculated when the options tabs were declared just to 00924 be on the safe side. 00925 Must use a number rather than the ID as this is what MFC's property sheet 00926 constructors require. 00927 Errors: - 00928 SeeAlso: PrintPrefsDlg; GridTabAppPrefsDlg; 00929 00930 ******************************************************************************************/ 00931 00932 PrintTabPrintPrefsDlg::PrintTabPrintPrefsDlg(): PrintPrefsDlg( OptionsTabs::PrintTabNumber ) 00933 { 00934 // At present, just:- do nothing 00935 } 00936 00937 #endif //webster