optsprin.cpp

Go to the documentation of this file.
00001 // $Id: optsprin.cpp 1357 2006-06-25 11:31:45Z 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 // Implementation of the print tabs of the options dialog box
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 //   WEBSTER-ranbirr-13/11/96
00107 #ifndef WEBSTER
00108 #include "appprefs.h"
00109 #include "optsprin.h"
00110 #include "optsmsgs.h"
00111 //#include "printdlg.h"
00112 #include "princomp.h"
00113 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "isetres.h"
00115 #include "colplate.h"
00116 #include "printmsg.h"
00117 //#include "markn.h"
00118 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "printdlg.h"
00120 #include "prdlgctl.h"
00121 //#include "barsdlgs.h"
00122 #include "camelot.h"
00123 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 #include "prnmks.h"
00125 #include "prnmkcom.h"
00126 #include "colmsg.h"
00127 #include "colormgr.h"
00128 #include "bubbleid.h"
00129 
00130 // for testing printing
00131 #ifdef _DEBUG
00132 #include "noderect.h"
00133 #include "layer.h"
00134 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00135 //#include "fillval.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00136 #include "sglayer.h"
00137 #include "keypress.h"
00138 //#include "printprg.h"
00139 #endif
00140 
00141 //#include "will2.h"
00142 //#include "customlist.h"
00143 
00144 CC_IMPLEMENT_DYNAMIC(PrintBaseTab,          OptionsTabs)
00145 CC_IMPLEMENT_DYNAMIC(PrintGeneralTab,       PrintBaseTab)
00146 CC_IMPLEMENT_DYNAMIC(PrintLayoutTab,        PrintBaseTab)
00147 CC_IMPLEMENT_DYNAMIC(PrintSepsTab,          PrintBaseTab)
00148 CC_IMPLEMENT_DYNAMIC(PrintImagesetterTab,   PrintBaseTab)
00149 CC_IMPLEMENT_DYNCREATE(OpShowPrintBorders,  Operation)
00150 CC_IMPLEMENT_DYNCREATE(SepsDlg,             DialogOp);
00151 
00152 
00153 // This is not compulsory, but you may as well put it in so that the correct version
00154 // of your file can be registered in the .exe
00155 DECLARE_SOURCE("$Revision: 1357 $");
00156 
00157 //------------------------------------------------
00158 
00159 static BOOL IgnoreTextChangedMsgs = FALSE;
00160 
00161 
00162 // This local PrintControl contains a copy of the associated document's print control object.
00163 // The local copy is copied from the document when InitSection() and UpdateSection() is called.
00164 // The local copy is copied into the document when CommitSection() is called.
00165 // NOTE that we have a static print control because it must be SHARED by all the different tabs!
00166 PrintControl PrintBaseTab::LocalPrintControl;
00167 Document *PrintBaseTab::pLastPrintControlDocument = NULL;
00168 
00169 static CGadgetID ScreenIDs[] =  // NULL terminated list of Screen control IDs
00170 {
00171     //Screen types
00172     _R(SCREEN_TYPE_BASE),
00173     _R(IDS_SCRTYPE_SPOT1),
00174     _R(IDS_SCRTYPE_SPOT2),
00175     _R(IDS_SCRTYPE_TRIPLESPOT1),
00176     _R(IDS_SCRTYPE_TRIPLESPOT2),
00177     _R(IDS_SCRTYPE_ELLIPTICAL),
00178     _R(IDS_SCRTYPE_LINE),
00179     _R(IDS_SCRTYPE_CROSSHATCH),
00180     _R(IDS_SCRTYPE_MEZZOTINT),
00181     _R(IDS_SCRTYPE_SQUARE),
00182     _R(IDS_SCRTYPE_DITHER),
00183     0
00184 };
00185 
00186 
00187 /********************************************************************************************
00188 
00189 >   PrintBaseTab::PrintBaseTab() 
00190 
00191 
00192     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00193     Created:    3/4/95
00194     Inputs:     -
00195     Outputs:    -
00196     Returns:    -
00197     Purpose:    PrintBaseTab constructor.
00198     Errors:     -
00199     SeeAlso:    -
00200 
00201 ********************************************************************************************/
00202 
00203 PrintBaseTab::PrintBaseTab()
00204 {   
00205 }        
00206 
00207 
00208 
00209 /********************************************************************************************
00210 
00211 >   PrintBaseTab::~PrintBaseTab()
00212 
00213 
00214     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00215     Created:    3/4/95
00216     Inputs:     -
00217     Outputs:    -
00218     Returns:    -
00219     Purpose:    PrintBaseTab destructor
00220     Errors:     -
00221     SeeAlso:    -
00222 
00223 ********************************************************************************************/
00224                                                                                 
00225 PrintBaseTab::~PrintBaseTab()
00226 {   
00227     // Vape the cached print control info
00228     pLastPrintControlDocument = NULL;
00229 
00230     // Clear out the entire print control to sensible defaults. This includes wiping the
00231     // plate list, which ensures there are no IndexedColours left "in use" when we exit
00232     PrintControl BlankPC;
00233     LocalPrintControl = BlankPC;
00234 }        
00235 
00236 
00237 
00238 /******************************************************************************************
00239 
00240 >   BOOL PrintBaseTab::IsDocumentOption()
00241 
00242     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00243     Created:    3/4/95
00244     Inputs:     -
00245     Outputs:    -
00246     Returns:    Returns True if this tab is a document option.    
00247     Purpose:    Allows the document options dialog code to determine if this tab belongs
00248                 to the group of document options.
00249     Errors:     -
00250     SeeAlso:    IsProgramOption();
00251 
00252 ******************************************************************************************/
00253 
00254 BOOL PrintBaseTab::IsDocumentOption()
00255 {
00256     return FALSE;   // This tab is not a document option. Changed from True 3/3/97.
00257 }
00258 
00259 
00260 
00261 /******************************************************************************************
00262 
00263 >   BOOL PrintBaseTab::IsProgramOption()
00264 
00265     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00266     Created:    3/4/95
00267     Inputs:     -
00268     Outputs:    -
00269     Returns:    Returns True if this tab is a program option.     
00270     Purpose:    Allows the program options dialog code to determine if this tab belongs
00271                 to the group of program options.
00272     Errors:     -
00273     SeeAlso:    IsProgramOption();
00274 
00275 ******************************************************************************************/
00276 
00277 BOOL PrintBaseTab::IsProgramOption()
00278 {
00279     return FALSE;   // This tab is not a program option. Changed from True 3/3/97.
00280 }
00281 
00282 
00283 
00284 /******************************************************************************************
00285 
00286 >   BOOL PrintBaseTab::IsPrintingOption()
00287 
00288     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00289     Created:    14/4/95
00290     Inputs:     -
00291     Outputs:    -
00292     Returns:    Returns True if this tab is a printing option.    
00293     Purpose:    Allows the printing options dialog code to determine if this tab belongs
00294                 to the group of printing options.
00295     Errors:     -
00296     SeeAlso:    IsProgramOption();
00297 
00298 ******************************************************************************************/
00299 
00300 BOOL PrintBaseTab::IsPrintingOption()
00301 {
00302     return TRUE;    // This tab is a printing option 
00303 }
00304 
00305 
00306 
00307 /********************************************************************************************
00308 
00309 >   BOOL PrintBaseTab::TalkToPage()
00310 
00311     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00312     Created:    4/4/95
00313     Inputs:     -
00314     Outputs:    -
00315     Returns:    TRUE if successful, FALSE otherwise
00316     Purpose:    This calls pPrefsDlg->TalkToPage() with the ID returned from GetPageID()
00317     Errors:     -
00318     SeeAlso:    -
00319 
00320 ********************************************************************************************/
00321 
00322 BOOL PrintBaseTab::TalkToPage()
00323 {
00324     if (pPrefsDlg != NULL)
00325         return (pPrefsDlg->TalkToPage(GetPageID()));
00326 
00327     return FALSE;
00328 }
00329 
00330 
00331 
00332 /********************************************************************************************
00333 
00334 >   void PrintBaseTab::UpdateDocName()
00335 
00336     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00337     Created:    4/4/95
00338     Inputs:     -
00339     Outputs:    -
00340     Returns:    -
00341     Purpose:    This displays the doc name returned from GetDocumentName() in the tab
00342                 If it can't do it for some reason (i.e. NULL dlg ptr) it just returns
00343     Errors:     -
00344     SeeAlso:    -
00345 
00346 ********************************************************************************************/
00347 
00348 void PrintBaseTab::UpdateDocName()
00349 {
00350     if (pPrefsDlg != NULL && TalkToPage())
00351         pPrefsDlg->SetStringGadgetValue(_R(IDC_PRINT_DOCNAME),*GetDocumentName());
00352 }
00353 
00354 
00355 
00356 /********************************************************************************************
00357 
00358 >   BOOL PrintBaseTab::GreySection()
00359 
00360     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00361     Created:    3/4/95
00362     Inputs:     -
00363     Outputs:    -
00364     Returns:    -
00365     Purpose:    Called when the user has closed all documents 
00366     Errors:     -
00367     SeeAlso:    PrintBaseTab::UngreySection;
00368 
00369 ********************************************************************************************/
00370 
00371 BOOL PrintBaseTab::GreySection()
00372 {
00373     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintBaseTab::GreySection called with no dialog pointer");
00374 
00375     // Vape the cached print control info
00376     pLastPrintControlDocument = NULL;
00377 
00378     // Clear out the entire print control to sensible defaults. This includes wiping the
00379     // plate list, which ensures there are no IndexedColours left "in use" when we exit
00380     PrintControl BlankPC;
00381     LocalPrintControl = BlankPC;
00382 
00383     if (TalkToPage())
00384     {
00385         // Make sure the information field displaying the name of the current document
00386         // is correct.
00387         UpdateDocName();
00388 
00389         AllGreyed = TRUE;
00390         EnableControls();   // Call our central greying/ungreying function
00391     }
00392 
00393     return TRUE;
00394 } 
00395 
00396 
00397 
00398 /********************************************************************************************
00399 
00400 >   BOOL PrintBaseTab::UngreySection()
00401 
00402     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00403     Created:    3/4/95
00404     Inputs:     -
00405     Outputs:    -
00406     Returns:    -
00407     Purpose:    Called when the user has selected a new document 
00408     Errors:     -
00409     SeeAlso:    PrintBaseTab::UngreySection;
00410 
00411 ********************************************************************************************/
00412 
00413 BOOL PrintBaseTab::UngreySection()
00414 {
00415     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintBaseTab::UngreySection called with no dialog pointer");
00416 
00417     // Vape the cached print control info
00418     pLastPrintControlDocument = NULL;
00419  
00420     // Clear out the entire print control to sensible defaults. This includes wiping the
00421     // plate list, which ensures there are no IndexedColours left "in use" when we exit
00422     PrintControl BlankPC;
00423     LocalPrintControl = BlankPC;
00424 
00425     if (TalkToPage())
00426     {
00427         // Make sure the information field displaying the name of the current document
00428         // is correct.
00429         UpdateDocName();
00430 
00431         AllGreyed = FALSE;
00432 
00433         ShowDetails();      // Make sure all details have been updated to show the new document
00434         EnableControls();   // Call our central greying/ungreying function
00435     }
00436 
00437     return TRUE;
00438 }
00439 
00440 
00441 
00442 /********************************************************************************************
00443 
00444 >   BOOL PrintBaseTab::UpdateSection(String_256 *DocumentName)
00445 
00446     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00447     Created:    3/4/95
00448     Inputs:     -
00449     Outputs:    -
00450     Returns:    -
00451     Purpose:    Called when we have switched to a new document and need to update all the 
00452                 controls on this tab. Should only init the tab if the page is present.  
00453     Errors:     -
00454     SeeAlso:    PrintBaseTab::GreySection; PrintBaseTab::UngreySection; PrintBaseTab::InitSection;
00455 
00456 ********************************************************************************************/
00457 
00458 BOOL PrintBaseTab::UpdateSection(String_256 *DocumentName)
00459 {
00460     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintBaseTab::UpdateSection called with no dialog pointer");
00461 
00462     if (!TalkToPage())
00463         return TRUE;    // Just return if TalkToPage() fails
00464 
00465     // Call the normal init section code
00466     return InitSection();
00467 }
00468 
00469 
00470 
00471 /******************************************************************************************
00472 
00473 >   PrintControl* PrintBaseTab::GetPrintControl()
00474 
00475     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00476     Created:    3/4/95
00477     Inputs:     -
00478     Outputs:    -
00479     Returns:    Ptr to the associated doc's print control object or NULL if it fails
00480     Purpose:    Access function to the doc's print control object
00481 
00482                 This has to find the doc's print component and ask it for the print
00483                 control object
00484     Errors:     -
00485     SeeAlso:    -
00486 
00487 ******************************************************************************************/
00488 
00489 PrintControl* PrintBaseTab::GetPrintControl()
00490 {
00491     // Return NULL if we don't have a document ptr
00492     if (pDocument == NULL)
00493         return NULL;
00494 
00495     // Find the doc's print component
00496     PrintComponent* pPrComp = (PrintComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
00497     ERROR2IF(pPrComp == NULL,NULL,"Can't find the associated doc's print component");
00498 
00499     // Find a ptr to the print component's print control object
00500     PrintControl* pPrCtrl = pPrComp->GetPrintControl();
00501     ERROR2IF(pPrCtrl == NULL,NULL,"The doc's print component gave me a NULL print control object");
00502 
00503     return pPrCtrl;
00504 }
00505 
00506 
00507 
00508 /******************************************************************************************
00509 
00510 >   void PrintBaseTab::CopyLocalPrintControlFromDoc(void)
00511 
00512     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00513     Created:    17/9/96
00514 
00515     Purpose:    Copies the current document print control into our locl print control copy
00516                 (i.e. copies the current document configuration into our local copy, either
00517                 initialising the values that the dialogue should be using, or effectively
00518                 "cancelling" any user changes made in the dialogue. Note that you'll have
00519                 to call updatesection to update the dialogue to use the new settings.
00520 
00521                 The print tabs all work *exclusively* on the copy, and then the base tab
00522                 will update the real document print control from the local one as 
00523                 appropriate when the dialogue values are committed.
00524 
00525     Notes:      This caches the print control information for the options dialogue document.
00526                 Subsequent calls don't bother doing anything, on the grounds that due to the
00527                 random times at which our tabs are initialised, they can try to copy the doc
00528                 information into the local control when doing so will overwrite changed
00529                 but non-committed values for this document. (e.g. without this caching
00530                 lock on it, clicking the "do separations" button doesn't auto-update
00531                 the "output printers marks" option in the other tab until you've "seen"
00532                 that tab!
00533 
00534 ******************************************************************************************/
00535 
00536 void PrintBaseTab::CopyLocalPrintControlFromDoc(void)
00537 {
00538     // If cached for this document, don't copy it again, because this could lose settings
00539     // which have been changed in the dialogue but not yet committed.
00540     if (pLastPrintControlDocument == pDocument)
00541         return;
00542 
00543     PrintControl *PrintCtrl = GetPrintControl();
00544     if (PrintCtrl != NULL)
00545     {
00546         LocalPrintControl = *PrintCtrl;
00547         LocalPrintControl.SetUp(pDocument->GetSelectedSpread());
00548 
00549         pLastPrintControlDocument = pDocument;
00550     }
00551 }
00552 
00553 
00554 /******************************************************************************************
00555 
00556 >   static void PrintBaseTab::DocumentSettingsUpdated(void)
00557 
00558     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00559     Created:    25/9/96
00560 
00561     Purpose:    Copies the current document print control into our locl print control copy
00562                 Called by the AppPrefs base dialogue when we soft-commit with the Apply button
00563 
00564 ******************************************************************************************/
00565 
00566 void PrintBaseTab::DocumentSettingsUpdated(void)
00567 {
00568     Document *pDoc = Document::GetSelected();
00569     if (pDoc != NULL)
00570     {
00571         PrintComponent* pPrComp = (PrintComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
00572         if (pPrComp != NULL)    
00573         {
00574             PrintControl* pPrCtrl = pPrComp->GetPrintControl();
00575             if (pPrCtrl != NULL)
00576             {
00577                 LocalPrintControl = *pPrCtrl;
00578                 LocalPrintControl.SetUp(pDoc->GetSelectedSpread());
00579 
00580                 pLastPrintControlDocument = pDoc;
00581             }
00582         }
00583     }
00584 }
00585 
00586 
00587 
00588 /******************************************************************************************
00589 
00590 >   void PrintBaseTab::CopyLocalPrintControlToDoc(void)
00591 
00592     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00593     Created:    17/9/96
00594 
00595     Purpose:    Copies our local print control copy into the current document
00596                 (i.e. commits the local dialogue values into the document)
00597 
00598                 The print tabs all work *exclusively* on the copy, and then the base tab
00599                 will update the real document print control from the local one as 
00600                 appropriate when the dialogue values are committed.
00601 
00602 ******************************************************************************************/
00603 
00604 void PrintBaseTab::CopyLocalPrintControlToDoc(void)
00605 {
00606     PrintControl *PrintCtrl = GetPrintControl();
00607     if (PrintCtrl != NULL)
00608     {
00609         *PrintCtrl = LocalPrintControl;
00610         if (pDocument)                      // If we have just changed document settings
00611             pDocument->SetModified(TRUE);   // Then mark the document modified!!!
00612     }
00613 }
00614 
00615 
00616 /******************************************************************************************
00617 
00618 >   BOOL PrintBaseTab::InitSection()
00619 
00620     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00621     Created:    3/4/95
00622     Inputs:     -
00623     Outputs:    -
00624     Returns:    TRUE if successful, else FALSE
00625     Purpose:    Sets initial values for the print general section of the options dialog box.
00626     Errors:     -
00627     SeeAlso:    AppPrefsDlg; OptionsTabs;
00628 
00629 ******************************************************************************************/
00630 
00631 BOOL PrintBaseTab::InitSection()
00632 {
00633     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintBaseTab::InitSection called with no dialog pointer");
00634 
00635     if (pDocument == NULL)
00636         return GreySection();
00637 
00638     AllGreyed = FALSE;  // we are ungreyed by default
00639 
00640     // Make sure the information field displaying the name of the current document
00641     // is correct.
00642     UpdateDocName();
00643 
00644     // Copy the doc's print control data into our local copy
00645     CopyLocalPrintControlFromDoc();
00646 
00647     if (!TalkToPage())
00648         return TRUE;    // Just return if TalkToPage() fails
00649 
00650     // Display the print data in our tab
00651     //return ShowDetails(); // I've commented this out as it should be done in the actual tab's init function - Adrian 
00652     return TRUE;
00653 }
00654 
00655 
00656 
00657 /********************************************************************************************
00658 
00659 >   virtual BOOL PrintBaseTab::PageSizeHasChanged()
00660 
00661     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00662     Created:    25/4/95
00663     Inputs:     -
00664     Outputs:    -
00665     Returns:    True if handled ok, False if not. 
00666     Purpose:    Allows a tab to update any page size items being displayed. 
00667     Errors:     -
00668     SeeAlso:    -
00669 
00670 ********************************************************************************************/
00671 
00672 BOOL PrintBaseTab::PageSizeHasChanged()
00673 {
00674     // Sent when the page size has been changed
00675     LocalPrintControl.SetUp(pDocument->GetSelectedSpread());
00676 
00677     if (!TalkToPage())
00678         return TRUE;    // Just return if TalkToPage() fails
00679 
00680     return ShowDetails();
00681 }
00682 
00683 /******************************************************************************************
00684 
00685 >   void PrintBaseTab::EnableControl(CGadgetID Gadget, BOOL Enabled)
00686 
00687     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00688     Created:    28/3/95
00689     Inputs:     Gadget  = gadget ID
00690                 Enabled = TRUE to enable, FALSE to disable gadget
00691     Outputs:    -
00692     Returns:    -
00693     Purpose:    This will enable the gadget given if Enabled is TRUE AND AllGreyed is FALSE,
00694                 i.e. it is a central control-greying func that takes the AllGreyed state of the tab
00695                 into account.
00696     Errors:     -
00697     SeeAlso:    -
00698 
00699 ******************************************************************************************/
00700 
00701 void PrintBaseTab::EnableControl(CGadgetID Gadget, BOOL Enabled)
00702 {
00703 
00704 // Code to comment out non-functional aspects of the print dlg (18/4/95)
00705 /*
00706 if (Gadget != _R(IDC_GROUP_PRINTMETHOD) &&
00707     Gadget != _R(IDC_PRINTMETHOD_NORMAL) &&
00708     Gadget != _R(IDC_PRINTMETHOD_BITMAP) &&
00709     Gadget != _R(IDC_PRINTMETHOD_AABITMAP) &&
00710 
00711     Gadget != _R(IDC_GROUP_DPI) &&
00712     Gadget != _R(IDC_DPIAUTO) &&
00713     Gadget != _R(IDC_DPIMANUAL) &&
00714     Gadget != _R(IDC_DPIEDIT) &&
00715     Gadget != _R(IDC_DPIEDITTEXT))
00716 {
00717     Enabled = FALSE;
00718 }
00719 */
00720     if (pPrefsDlg != NULL)
00721         pPrefsDlg->EnableGadget(Gadget,Enabled && !AllGreyed);
00722 }
00723 
00724 /******************************************************************************************
00725 
00726 >   void PrintBaseTab::PrintSettingsChanged()
00727 
00728     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00729     Created:    1/5/95
00730     Inputs:     -
00731     Outputs:    -
00732     Returns:    -
00733     Purpose:    Called by AppPrefsDlg::Message() when it received a PrintMsg::SETTINGSCHANGED message.
00734     Errors:     -
00735     SeeAlso:    -
00736 
00737 ******************************************************************************************/
00738 
00739 void PrintBaseTab::PrintSettingsChanged()
00740 {
00741     if (IsAllGreyed())
00742         return;
00743 
00744     // Set up the print again so that it takes the new settings on board
00745     LocalPrintControl.SetUp(pDocument->GetSelectedSpread());
00746 
00747     if (TalkToPage())
00748         ShowDetails();
00749 }
00750 
00751 
00752 /********************************************************************************************
00753 
00754 >   BOOL PrintBaseTab::HandleMsg(DialogMsg* Msg)
00755 
00756     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00757     Created:    18/9/96
00758     Inputs:     Msg - The dialogue message to be handled
00759     Returns:    TRUE
00760 
00761     Purpose:    Handles any print options tabs messages that the derived class is not
00762                 interested in handlign themselves. Should be called by the derived class
00763                 for any events they don't handle
00764 
00765                 Currently handles:
00766                 DIM_CREATE - Calls InitSection() and then ShowDetails()
00767                 
00768                 DIM_CANCEL - vapes the cached PrintControl info, so that cancel really
00769                              does cancel!
00770 
00771 ********************************************************************************************/
00772 
00773 BOOL PrintBaseTab::HandleMsg(DialogMsg* Msg)
00774 {
00775     ERROR2IF(Msg == NULL,FALSE,"PrintGeneralTab::Message null message received");
00776     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintGeneralTab::HandleMsg called with no dialog pointer");
00777 
00778     BOOL ok = TalkToPage(); // The print general tab identifier
00779     if (!ok)
00780         return TRUE;        // page not present
00781 
00782     switch(Msg->DlgMsg)
00783     {
00784         case DIM_CREATE:    // Initialise controls
00785             ok = InitSection();
00786             if (!ok)
00787                 InformError();
00788             else
00789                 ShowDetails();  // The base class InitSection() no longer does this by default
00790             break;
00791 
00792 
00793         case DIM_CANCEL:
00794         {
00795             // Vape the cached print control info
00796             pLastPrintControlDocument = NULL;
00797 
00798             // Clear out the entire print control to sensible defaults. This includes wiping the
00799             // plate list, which ensures there are no IndexedColours left "in use" when we exit
00800             PrintControl BlankPC;
00801             LocalPrintControl = BlankPC;
00802             break;
00803         }
00804 
00805         default:
00806             break;
00807     }
00808 
00809     return TRUE;
00810 }  
00811 
00812 
00813 
00814 /******************************************************************************************
00815 
00816 >   BOOL PrintBaseTab::CommitSection()
00817 
00818     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00819     Created:    25/9/96
00820     Inputs:     -
00821     Outputs:    -
00822     Returns:    True if values in dialog box ok, False otherwise.     
00823     Purpose:    Commits values from the print dialogue tabs to the document.
00824                 Should be called by all derived classes
00825     Errors:     -
00826     SeeAlso:    -
00827 
00828 ******************************************************************************************/
00829 
00830 BOOL PrintBaseTab::CommitSection()
00831 {
00832     if (!IsAllGreyed() && pDocument != NULL)
00833         CopyLocalPrintControlToDoc();
00834 
00835     pLastPrintControlDocument = NULL;
00836 
00837     return(TRUE);
00838 }
00839 
00840 
00841 
00842 //----------------------------------------------------------------
00843 //----------------------------------------------------------------
00844 //----------------------------------------------------------------
00845 
00846 
00847 //------------------------------------------------
00848 
00849 /********************************************************************************************
00850 
00851 >   PrintGeneralTab::PrintGeneralTab() 
00852 
00853 
00854     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00855     Created:    22/3/95
00856     Inputs:     -
00857     Outputs:    -
00858     Returns:    -
00859     Purpose:    PrintGeneralTab constructor.
00860     Errors:     -
00861     SeeAlso:    -
00862 
00863 ********************************************************************************************/
00864 
00865 PrintGeneralTab::PrintGeneralTab()
00866 {
00867 }        
00868 
00869 /********************************************************************************************
00870 
00871 >   PrintGeneralTab::~PrintGeneralTab()
00872 
00873 
00874     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00875     Created:    22/3/95
00876     Inputs:     -
00877     Outputs:    -
00878     Returns:    -
00879     Purpose:    PrintGeneralTab destructor
00880     Errors:     -
00881     SeeAlso:    -
00882 
00883 ********************************************************************************************/
00884                                                                                 
00885 PrintGeneralTab::~PrintGeneralTab()
00886 {   
00887 }        
00888 
00889 CDlgResID PrintGeneralTab::GetPageID()  { return _R(IDD_OPTSTAB_PRINTGENERAL); }
00890 
00891 /********************************************************************************************
00892 
00893 >   BOOL PrintGeneralTab::HandleMsg(DialogMsg* Msg)
00894 
00895     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00896     Created:    22/3/95
00897     Inputs:     -
00898     Outputs:    -
00899     Returns:    -
00900     Purpose:    Handles all the print general options tabs messages 
00901     Errors:     -
00902     SeeAlso:    -
00903 
00904 ********************************************************************************************/
00905 
00906 BOOL PrintGeneralTab::HandleMsg(DialogMsg* Msg)
00907 {
00908     ERROR2IF(Msg == NULL,FALSE,"PrintGeneralTab::Message null message received");
00909     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintGeneralTab::HandleMsg called with no dialog pointer");
00910 
00911     BOOL ok = TalkToPage(); // The print general tab identifier
00912     if (!ok)
00913         return TRUE;        // page not present
00914 
00915     switch(Msg->DlgMsg)
00916     {
00917         case DIM_LFT_BN_CLICKED:
00918             OptionsTabs::SetApplyNowState(TRUE);
00919             if (FALSE) {}
00920             // Print layers
00921             else if (Msg->GadgetID == _R(IDC_ALLFOREGROUND))
00922             {
00923                 LocalPrintControl.SetPrintLayers(PRINTLAYERS_ALLFOREGROUND);
00924             }
00925             else if (Msg->GadgetID == _R(IDC_VISIBLEFOREGROUND))
00926             {
00927                 LocalPrintControl.SetPrintLayers(PRINTLAYERS_VISIBLEFOREGROUND);
00928             }
00929 #if 0
00930             // Job 10463: remove PS Level bits - default to Level 2
00931             // Postscript language level
00932             else if (Msg->GadgetID == _R(IDC_PSLEVELAUTO))
00933             {
00934                 LocalPrintControl.SetPSLevel(PSLEVEL_AUTO);
00935             }
00936             else if (Msg->GadgetID == _R(IDC_PSLEVEL1))
00937             {
00938                 LocalPrintControl.SetPSLevel(PSLEVEL_1);
00939             }
00940             else if (Msg->GadgetID == _R(IDC_PSLEVEL2))
00941             {
00942                 LocalPrintControl.SetPSLevel(PSLEVEL_2);
00943             }
00944 #endif
00945             // Print method
00946             else if (Msg->GadgetID == _R(IDC_PRINTMETHOD_NORMAL))
00947             {
00948                 LocalPrintControl.SetPrintMethod(PRINTMETHOD_NORMAL);
00949                 ShowDetails();
00950             }
00951             else if (Msg->GadgetID == _R(IDC_PRINTMETHOD_BITMAP))
00952             {
00953                 LocalPrintControl.SetPrintMethod(PRINTMETHOD_BITMAP);
00954                 ShowDetails();
00955             }
00956             else if (Msg->GadgetID == _R(IDC_PRINTMETHOD_AABITMAP))
00957             {
00958                 LocalPrintControl.SetPrintMethod(PRINTMETHOD_AABITMAP);
00959                 ShowDetails();
00960             }
00961 
00962             // Bitmap DPI
00963             else if (Msg->GadgetID == _R(IDC_DPIAUTO))
00964             {
00965                 LocalPrintControl.SetBitmapResMethod(BITMAPRES_AUTO);
00966                 ShowDetails();
00967             }
00968             else if (Msg->GadgetID == _R(IDC_DPIMANUAL))
00969             {
00970                 LocalPrintControl.SetBitmapResMethod(BITMAPRES_MANUAL);
00971                 ShowDetails();
00972             }
00973             // Text options
00974             else if (Msg->GadgetID == _R(IDC_ALLTEXTASSHAPES))
00975             {
00976                 PrintTextOptions pto = LocalPrintControl.GetTextOptions();
00977                 pto = (pto == PRINTTEXTOPTIONS_NORMAL) ? PRINTTEXTOPTIONS_ALLTEXTASSHAPES
00978                                                         : PRINTTEXTOPTIONS_NORMAL;
00979                 LocalPrintControl.SetTextOptions(pto);
00980                 ShowDetails();
00981             }
00982 
00983             break; 
00984 
00985         case DIM_SELECTION_CHANGED:
00986             OptionsTabs::SetApplyNowState(TRUE);
00987             if (Msg->GadgetID == _R(IDC_FILLQUALLIST))
00988             {
00989                 WORD Index;
00990                 pPrefsDlg->GetValueIndex(_R(IDC_FILLQUALLIST),&Index); 
00991                 LocalPrintControl.SetFillQuality(PrintFillQuality(Index));
00992                 ShowDetails();
00993             }
00994             break;
00995 
00996         case DIM_TEXT_CHANGED:
00997             OptionsTabs::SetApplyNowState(TRUE);
00998             if (Msg->GadgetID == _R(IDC_DPIEDIT))
00999             {
01000                 INT32 DPI = pPrefsDlg->GetLongGadgetValue(_R(IDC_DPIEDIT),0,0);
01001                 LocalPrintControl.SetDotsPerInch(DPI);
01002             }
01003             break;
01004 
01005         default:
01006             return(PrintBaseTab::HandleMsg(Msg));
01007     }
01008 
01009     return TRUE;
01010 }  
01011 
01012 /******************************************************************************************
01013 
01014 >   BOOL PrintGeneralTab::CommitSection()
01015 
01016     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01017     Created:    25/4/95
01018     Inputs:     -
01019     Outputs:    -
01020     Returns:    True if values in dialog box ok, False otherwise.     
01021     Purpose:    Takes the values in the Print General section tab of the options dialog box and
01022                 sets the associated preference values accordingly
01023                 Called when ok is pressed on the dialog box.
01024     Errors:     -
01025     SeeAlso:    -
01026 
01027 ******************************************************************************************/
01028 
01029 BOOL PrintGeneralTab::CommitSection()
01030 {
01031     if (IsAllGreyed() || pDocument == NULL)
01032         return(PrintBaseTab::CommitSection());
01033 
01034     ERROR3IF(pPrefsDlg == NULL, "PrintGeneralTab::CommitSection called with no dialog pointer");
01035 
01036     if (!TalkToPage())
01037         return TRUE;    // Just return if TalkToPage() fails
01038 
01039 /*
01040     //---
01041     // RANGE CHECK ALL VALUES TO MAKE SURE THEY ARE SENSIBLE
01042     //---
01043     
01044     PrintControl* pPrCtrl = GetPrintControl();
01045     ERROR2IF(pPrCtrl == NULL,TRUE,"The doc's print component gave me a NULL print control object");
01046 
01047     // We only want to change the values of the doc print control as if we are importing the values
01048     // from a file, i.e. we don't want other values changing as a result of these calls
01049     pPrCtrl->StartImport();
01050 
01051     // Only set the members this tab has changed.
01052 |*  pPrCtrl->SetPrintLayers(    LocalPrintControl.GetPrintLayers());
01053     pPrCtrl->SetPSLevel(        LocalPrintControl.GetPSLevel());
01054     pPrCtrl->SetPrintMethod(    LocalPrintControl.GetPrintMethod());
01055     pPrCtrl->SetBitmapResMethod(LocalPrintControl.GetBitmapResMethod());
01056     pPrCtrl->SetDotsPerInch(    LocalPrintControl.GetDotsPerInch());
01057     pPrCtrl->SetFillQuality(    LocalPrintControl.GetFillQuality());
01058     pPrCtrl->SetTextOptions(    LocalPrintControl.GetTextOptions());
01059 *|
01060 
01061     CGadgetID LayerGadgets[] = { _R(IDC_ALLFOREGROUND), _R(IDC_VISIBLEFOREGROUND), NULL };
01062     BOOL Result = (pPrefsDlg->GetRadioGroupSelected(LayerGadgets) == _R(IDC_ALLFOREGROUND));
01063     pPrCtrl->SetPrintLayers((Result) ? PRINTLAYERS_ALLFOREGROUND : PRINTLAYERS_VISIBLEFOREGROUND);
01064 
01065     CGadgetID PSGadgets[] = { _R(IDC_PSLEVELAUTO), _R(IDC_PSLEVEL1), _R(IDC_PSLEVEL2), NULL };
01066     ResourceID PSRadio = pPrefsDlg->GetRadioGroupSelected(PSGadgets);
01067     if (PSRadio == _R(IDC_PSLEVELAUTO))
01068         pPrCtrl->SetPSLevel(PSLEVEL_AUTO);
01069     else if (PSRadio == _R(IDC_PSLEVEL1))
01070         pPrCtrl->SetPSLevel(PSLEVEL_1);
01071     else if (PSRadio == _R(IDC_PSLEVEL2))
01072         pPrCtrl->SetPSLevel(PSLEVEL_2);
01073 
01074     CGadgetID MethodGadgets[] = { _R(IDC_PRINTMETHOD_NORMAL), _R(IDC_PRINTMETHOD_BITMAP), _R(IDC_PRINTMETHOD_AABITMAP), NULL };
01075     ResourceID MethodRadio = GetRadioGroupSelected(MethodGadgets));
01076     if (MethodRadio == _R(IDC_PRINTMETHOD_NORMAL))
01077         pPrCtrl->SetPrintMethod(PRINTMETHOD_NORMAL);
01078     else if (MethodRadio == _R(IDC_PRINTMETHOD_BITMAP))
01079         pPrCtrl->SetPrintMethod(PRINTMETHOD_BITMAP);
01080     else if (MethodRadio == _R(IDC_PRINTMETHOD_AABITMAP))
01081         pPrCtrl->SetPrintMethod(PRINTMETHOD_AABITMAP);
01082 
01083     CGadgetID DPIGadgets[] = { _R(IDC_DPIAUTO), _R(IDC_DPIMANUAL), NULL };
01084     Result = (pPrefsDlg->GetRadioGroupSelected(DPIGadgets) == _R(IDC_DPIAUTO));
01085     pPrCtrl->SetBitmapResMethod((Result) ? BITMAPRES_AUTO : BITMAPRES_MANUAL);
01086 
01087     Result = pPrefsDlg->GetBoolGadgetSelected(_R(IDC_ALLTEXTASSHAPES));
01088     pPrCtrl->SetTextOptions((Result) ? PRINTTEXTOPTIONS_ALLTEXTASSHAPES : PRINTTEXTOPTIONS_NORMAL);
01089 
01090     WORD Index;
01091     pPrefsDlg->GetValueIndex(_R(IDC_FILLQUALLIST), &Index); 
01092     pPrCtrl->SetFillQuality(PrintFillQuality(Index));
01093 
01094     INT32 DPI = pPrefsDlg->GetLongGadgetValue(_R(IDC_DPIEDIT),0,0);
01095     pPrCtrl->SetDotsPerInch(DPI);
01096  
01097     // Finished making the changes.
01098     pPrCtrl->EndImport();
01099 */
01100     return(PrintBaseTab::CommitSection());
01101 }
01102 
01103 
01104 /******************************************************************************************
01105 
01106 >   BOOL PrintGeneralTab::ShowDetails()
01107 
01108     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01109     Created:    24/3/95
01110     Inputs:     -
01111     Outputs:    -
01112     Returns:    TRUE if successful, else FALSE
01113     Purpose:    Sets values for the print general section of the options dialog box.
01114     Errors:     -
01115     SeeAlso:    AppPrefsDlg; OptionsTabs;
01116 
01117 ******************************************************************************************/
01118 
01119 BOOL PrintGeneralTab::ShowDetails()
01120 {
01121     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintGeneralTab::ShowDetailscalled with no dialog pointer");
01122 
01123     String_256 Str;
01124 
01125     // The print layers group
01126     PrintLayers pl = LocalPrintControl.GetPrintLayers();
01127     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_ALLFOREGROUND), pl == PRINTLAYERS_ALLFOREGROUND);
01128     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_VISIBLEFOREGROUND),pl == PRINTLAYERS_VISIBLEFOREGROUND);
01129 
01130     /*
01131     // Job 10463: remove PS Level bits - default to Level 2
01132     // Postscript language level
01133     PSLevel PSLvl = LocalPrintControl.GetPSLevel();
01134     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PSLEVELAUTO),PSLvl == PSLEVEL_AUTO);
01135     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PSLEVEL1),   PSLvl == PSLEVEL_1);
01136     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PSLEVEL2),   PSLvl == PSLEVEL_2);
01137     */
01138 
01139     // Print method
01140     PrintMethodType pm = LocalPrintControl.GetPrintMethod();
01141     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PRINTMETHOD_NORMAL),    pm == PRINTMETHOD_NORMAL);
01142     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PRINTMETHOD_BITMAP),    pm == PRINTMETHOD_BITMAP);
01143     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PRINTMETHOD_AABITMAP),  pm == PRINTMETHOD_AABITMAP);
01144 
01145     if (CCPrintDialog::IsPostscript())
01146         Str.Load(_R(IDS_K_OPTSPRIN_POSTSCIPT));
01147     else
01148         Str.Load(_R(IDS_K_OPTSPRIN_NORMAL));
01149 
01150     pPrefsDlg->SetStringGadgetValue(_R(IDC_PRINTMETHOD_NORMAL),Str);
01151 
01152     // Bitmap resolution
01153     BitmapResMethod brm = LocalPrintControl.GetBitmapResMethod();
01154     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_DPIAUTO),  brm == BITMAPRES_AUTO);
01155     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_DPIMANUAL),brm == BITMAPRES_MANUAL);
01156     pPrefsDlg->SetLongGadgetValue(_R(IDC_DPIEDIT), LocalPrintControl.GetDotsPerInch());
01157 
01158     // The bitmap resolution group text
01159     if (pm == PRINTMETHOD_NORMAL)   Str.Load(_R(IDS_K_OPTSPRIN_TRANSRES));
01160     if (pm == PRINTMETHOD_BITMAP)   Str.Load(_R(IDS_K_OPTSPRIN_BITMAPRES));
01161     if (pm == PRINTMETHOD_AABITMAP) Str.Load(_R(IDS_K_OPTSPRIN_AABITMAPRES));
01162     pPrefsDlg->SetStringGadgetValue(_R(IDC_GROUP_DPI),Str);
01163 
01164     //  Fill quality group
01165     pPrefsDlg->SetSelectedValueIndex(_R(IDC_FILLQUALLIST),INT32(LocalPrintControl.GetFillQuality()));
01166 
01167     // Text options
01168     PrintTextOptions pto = LocalPrintControl.GetTextOptions();
01169     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_ALLTEXTASSHAPES), pto != PRINTTEXTOPTIONS_NORMAL);
01170 
01171     // All done!
01172     return EnableControls();
01173 }
01174 
01175 /******************************************************************************************
01176 
01177 >   BOOL PrintGeneralTab::EnableControls()
01178 
01179     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01180     Created:    28/3/95
01181     Inputs:     -
01182     Outputs:    -
01183     Returns:    TRUE if all went well
01184     Purpose:    The enables and disables the various controls depending on the values held
01185                 in the given print control object
01186     Errors:     -
01187     SeeAlso:    -
01188 
01189 ******************************************************************************************/
01190 
01191 BOOL PrintGeneralTab::EnableControls()
01192 {
01193     if (pPrefsDlg == NULL) return TRUE;
01194 
01195     if (!TalkToPage())
01196         return(TRUE);
01197 
01198     // General controls
01199     EnableControl(_R(IDC_PRINT_DOCNAME),     TRUE);
01200     EnableControl(_R(IDC_OUTPUT_DOCNAMETEXT),TRUE);
01201 
01202     // The layers group
01203     EnableControl(_R(IDC_GROUP_PRINTLAYERS),TRUE);
01204     EnableControl(_R(IDC_ALLFOREGROUND),    TRUE);
01205     EnableControl(_R(IDC_VISIBLEFOREGROUND),TRUE);
01206 
01207     // postscript level group
01208     BOOL IsPostcript = CCPrintDialog::IsPostscript();
01209     /*
01210     // Job 10463: remove PS Level bits - default to Level 2
01211     EnableControl(_R(IDC_GROUP_PSLEVEL),IsPostcript);
01212     EnableControl(_R(IDC_PSLEVELAUTO),  IsPostcript);
01213     EnableControl(_R(IDC_PSLEVEL1),     IsPostcript);
01214     EnableControl(_R(IDC_PSLEVEL2),     IsPostcript);
01215     */
01216 
01217     // print method group (print as...)
01218     EnableControl(_R(IDC_GROUP_PRINTMETHOD),    TRUE);
01219     EnableControl(_R(IDC_PRINTMETHOD_NORMAL),   TRUE);
01220     EnableControl(_R(IDC_PRINTMETHOD_BITMAP),   TRUE);
01221     EnableControl(_R(IDC_PRINTMETHOD_AABITMAP), TRUE);
01222 
01223     // Bmp DPI group
01224     EnableControl(_R(IDC_GROUP_DPI),    TRUE);
01225     EnableControl(_R(IDC_DPIAUTO),      TRUE);
01226     EnableControl(_R(IDC_DPIMANUAL),    TRUE);
01227     EnableControl(_R(IDC_DPIEDIT),      (LocalPrintControl.GetBitmapResMethod() == BITMAPRES_MANUAL));
01228     EnableControl(_R(IDC_DPIEDITTEXT),  (LocalPrintControl.GetBitmapResMethod() == BITMAPRES_MANUAL));
01229 
01230     // Fill quality group
01231     BOOL Normal = (LocalPrintControl.GetPrintMethod() == PRINTMETHOD_NORMAL);
01232     EnableControl(_R(IDC_GROUP_FILLQUAL),   Normal && (!IsPostcript));
01233     EnableControl(_R(IDC_FILLQUALTEXT),     Normal && (!IsPostcript));
01234     EnableControl(_R(IDC_FILLQUALLIST),     Normal && (!IsPostcript));
01235 
01236     // Text options
01237     EnableControl(_R(IDC_GROUP_TEXTOPTIONS), TRUE);
01238     EnableControl(_R(IDC_ALLTEXTASSHAPES),   TRUE);
01239 
01240     return TRUE;
01241 }
01242 
01243 //----------------------------------------------------------------
01244 //----------------------------------------------------------------
01245 //----------------------------------------------------------------
01246 
01247 /********************************************************************************************
01248 
01249 >   PrintLayoutTab::PrintLayoutTab() 
01250 
01251 
01252     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01253     Created:    23/3/95
01254     Inputs:     -
01255     Outputs:    -
01256     Returns:    -
01257     Purpose:    PrintLayoutTab constructor.
01258     Errors:     -
01259     SeeAlso:    -
01260 
01261 ********************************************************************************************/
01262 
01263 PrintLayoutTab::PrintLayoutTab()
01264 {   
01265 }        
01266 
01267 /********************************************************************************************
01268 
01269 >   PrintLayoutTab::~PrintLayoutTab()
01270 
01271 
01272     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01273     Created:    23/3/95
01274     Inputs:     -
01275     Outputs:    -
01276     Returns:    -
01277     Purpose:    PrintLayoutTab destructor
01278     Errors:     -
01279     SeeAlso:    -
01280 
01281 ********************************************************************************************/
01282                                                                                 
01283 PrintLayoutTab::~PrintLayoutTab()
01284 {   
01285 }        
01286 
01287 CDlgResID PrintLayoutTab::GetPageID()   { return _R(IDD_OPTSTAB_PRINTLAYOUT); }
01288 
01289 /********************************************************************************************
01290 
01291 >   BOOL PrintLayoutTab::HandleMsg(DialogMsg* Msg)
01292 
01293     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01294     Created:    23/3/95
01295     Inputs:     -
01296     Outputs:    -
01297     Returns:    -
01298     Purpose:    Handles all the print layout options tabs messages 
01299     Errors:     -
01300     SeeAlso:    -
01301 
01302 ********************************************************************************************/
01303 
01304 BOOL PrintLayoutTab::HandleMsg(DialogMsg* Msg)
01305 {
01306     ERROR2IF(Msg == NULL,FALSE,"PrintLayoutTab::Message null message received");
01307     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintLayoutTab::HandleMsg called with no dialog pointer");
01308 
01309     BOOL ok = TalkToPage(); // The print layout tab identifier
01310     if (!ok)
01311         return TRUE;        // page not present
01312 
01313     switch(Msg->DlgMsg)
01314     {
01315         case DIM_CREATE:    // Initialise controls
01316             ok = InitSection();
01317             if (!ok)
01318                 InformError();
01319             break;
01320 
01321         case DIM_LFT_BN_CLICKED:
01322             OptionsTabs::SetApplyNowState(TRUE);
01323 
01324             if (FALSE) {}
01325             // Orientation
01326             else if (Msg->GadgetID == _R(IDC_BTN_UPRIGHT))
01327             {
01328                 LocalPrintControl.SetPrintOrient(PRINTORIENTATION_UPRIGHT);
01329                 ShowDetails();
01330             }
01331             else if (Msg->GadgetID == _R(IDC_BTN_SIDEWAYS))
01332             {
01333                 LocalPrintControl.SetPrintOrient(PRINTORIENTATION_SIDEWAYS);
01334                 ShowDetails();
01335             }
01336             // DPS buttons
01337             else if (Msg->GadgetID == _R(IDC_DPS_INDIVIDUALPAGES))
01338             {
01339                 LocalPrintControl.SetWholeSpread(FALSE);
01340                 ShowDetails();
01341             }
01342             else if (Msg->GadgetID == _R(IDC_DPS_WHOLESPREAD))
01343             {
01344                 LocalPrintControl.SetWholeSpread(TRUE);
01345                 ShowDetails();
01346             }
01347             // Fit type
01348             else if (Msg->GadgetID == _R(IDC_BESTFIT))
01349             {
01350                 LocalPrintControl.SetFitType(PRINTFIT_BEST);
01351                 ShowDetails();
01352             }
01353             else if (Msg->GadgetID == _R(IDC_CUSTOMFIT))
01354             {
01355                 LocalPrintControl.SetFitType(PRINTFIT_CUSTOM);
01356                 ShowDetails();
01357             }
01358             else if (Msg->GadgetID == _R(IDC_MULTIPLEFIT))
01359             {
01360                 LocalPrintControl.SetFitType(PRINTFIT_MULTIPLE);
01361                 ShowDetails();
01362             }
01363             else if (Msg->GadgetID == _R(IDC_BESTFITPAPER))
01364             {
01365                 LocalPrintControl.SetFitType(PRINTFIT_BESTPAPER);
01366                 ShowDetails();
01367             }
01368             break;
01369 
01370         case DIM_SELECTION_CHANGED:
01371             OptionsTabs::SetApplyNowState(TRUE);
01372             break;
01373 
01374         case DIM_TEXT_CHANGED:
01375             OptionsTabs::SetApplyNowState(TRUE);
01376 
01377             if (!IgnoreTextChangedMsgs)
01378             {
01379                 if (FALSE) {}
01380                 // Scale ed field
01381                 else if (Msg->GadgetID == _R(IDC_SCALEEDIT))
01382                 {
01383                     double Scale = pPrefsDlg->GetDoubleGadgetValue(_R(IDC_SCALEEDIT),0,0);
01384                     // We need to range check the value before converting it to a Fixed 16
01385                     if (Scale > 32000.0) Scale = 32000.0;
01386                     if (Scale < 0)       Scale = 0.0;
01387                     LocalPrintControl.SetScale(FIXED16(Scale));
01388                     ShowDetails(NULL,_R(IDC_SCALEEDIT));
01389                 }
01390                 // Custom fit ed fields
01391                 else if (Msg->GadgetID == _R(IDC_TOPEDIT))
01392                 {
01393                     LocalPrintControl.SetTopMargin(pPrefsDlg->GetUnitGadgetValue(_R(IDC_TOPEDIT),CurrentPageUnits,0,0));
01394                     ShowDetails(NULL,_R(IDC_TOPEDIT));
01395                 }
01396                 else if (Msg->GadgetID == _R(IDC_LEFTEDIT))
01397                 {
01398                     LocalPrintControl.SetLeftMargin(pPrefsDlg->GetUnitGadgetValue(_R(IDC_LEFTEDIT),CurrentPageUnits,0,0));
01399                     ShowDetails(NULL,_R(IDC_LEFTEDIT));
01400                 }
01401                 else if (Msg->GadgetID == _R(IDC_WIDTHEDIT))
01402                 {
01403                     LocalPrintControl.SetWidth(pPrefsDlg->GetUnitGadgetValue(_R(IDC_WIDTHEDIT),CurrentPageUnits,0,0));
01404                     ShowDetails(NULL,_R(IDC_WIDTHEDIT));
01405                 }
01406                 else if (Msg->GadgetID == _R(IDC_HEIGHTEDIT))
01407                 {
01408                     LocalPrintControl.SetHeight(pPrefsDlg->GetUnitGadgetValue(_R(IDC_HEIGHTEDIT),CurrentPageUnits,0,0));
01409                     ShowDetails(NULL,_R(IDC_HEIGHTEDIT));
01410                 }
01411                 // Multiple fit ed fields
01412                 else if (Msg->GadgetID == _R(IDC_ROWSEDIT))
01413                 {
01414                     LocalPrintControl.SetRows(pPrefsDlg->GetLongGadgetValue(_R(IDC_ROWSEDIT),0,0));
01415                     ShowDetails(NULL,_R(IDC_ROWSEDIT));
01416                 }
01417                 else if (Msg->GadgetID == _R(IDC_COLUMNSEDIT))
01418                 {
01419                     LocalPrintControl.SetColumns(pPrefsDlg->GetLongGadgetValue(_R(IDC_COLUMNSEDIT),0,0));
01420                     ShowDetails(NULL,_R(IDC_COLUMNSEDIT));
01421                 }
01422                 else if (Msg->GadgetID == _R(IDC_GUTTEREDIT))
01423                 {
01424                     LocalPrintControl.SetGutter(pPrefsDlg->GetUnitGadgetValue(_R(IDC_GUTTEREDIT),CurrentPageUnits,0,0));
01425                     ShowDetails(NULL,_R(IDC_GUTTEREDIT));
01426                 }
01427             }
01428             break;
01429 
01430         case DIM_KILL_FOCUS:
01431             {
01432                 CGadgetID List[] = { 0, 0 };
01433                 // Edit fields
01434                 if ((Msg->GadgetID == _R(IDC_SCALEEDIT)) ||
01435                     (Msg->GadgetID == _R(IDC_ROWSEDIT)) ||
01436                     (Msg->GadgetID == _R(IDC_COLUMNSEDIT)) ||
01437                     (Msg->GadgetID == _R(IDC_GUTTEREDIT)) ||
01438                     (Msg->GadgetID == _R(IDC_TOPEDIT)) ||
01439                     (Msg->GadgetID == _R(IDC_LEFTEDIT)) ||
01440                     (Msg->GadgetID == _R(IDC_WIDTHEDIT)) ||
01441                     (Msg->GadgetID == _R(IDC_HEIGHTEDIT)) )
01442                 {
01443                     List[0] = Msg->GadgetID;
01444                     ShowDetails(List, 0);
01445                 }
01446             }
01447             break;
01448 
01449         default:
01450             return(PrintBaseTab::HandleMsg(Msg));
01451     }       
01452 
01453 #ifdef _DEBUG
01454     if (Msg->DlgMsg == DIM_LFT_BN_CLICKED &&
01455         ((Msg->GadgetID == _R(IDC_BESTFIT)) || (Msg->GadgetID == _R(IDC_CUSTOMFIT)) || (Msg->GadgetID == _R(IDC_MULTIPLEFIT))) &&
01456         KeyPress::IsConstrainPressed())
01457     {
01458         PrintLayoutTab::TestPrinting(&LocalPrintControl);
01459     }
01460 #endif
01461 
01462     return TRUE;
01463 }
01464 
01465 
01466 
01467 /******************************************************************************************
01468 
01469 >   BOOL PrintLayoutTab::CommitSection()
01470 
01471     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01472     Created:    25/4/95
01473     Inputs:     -
01474     Outputs:    -
01475     Returns:    True if values in dialog box ok, False otherwise.     
01476     Purpose:    Takes the values in the Print Layout section tab of the options dialog box and
01477                 sets the associated preference values accordingly
01478                 Called when ok is pressed on the dialog box.
01479     Errors:     -
01480     SeeAlso:    -
01481 
01482 ******************************************************************************************/
01483 
01484 BOOL PrintLayoutTab::CommitSection()
01485 {
01486     if (IsAllGreyed() || pDocument == NULL)
01487         return(PrintBaseTab::CommitSection());
01488 
01489     ERROR3IF(pPrefsDlg == NULL, "PrintLayoutTab::CommitSection called with no dialog pointer");
01490 
01491     if (!TalkToPage())
01492         return TRUE;    // Just return if TalkToPage() fails
01493 
01494 /*
01495 
01496     //---
01497     // RANGE CHECK ALL VALUES TO MAKE SURE THEY ARE SENSIBLE
01498     //---
01499     
01500     PrintControl* pPrCtrl = GetPrintControl();
01501     ERROR2IF(pPrCtrl == NULL,TRUE,"The doc's print component gave me a NULL print control object");
01502 
01503     // We only want to change the values of the doc print control as if we are importing the values
01504     // from a file, i.e. we don't want other values changing as a result of these calls
01505     pPrCtrl->StartImport();
01506 |*
01507     // Only set the members this tab has changed.
01508     pPrCtrl->SetPrintOrient(LocalPrintControl.GetPrintOrient());
01509     pPrCtrl->SetWholeSpread(LocalPrintControl.IsWholeSpread());
01510     pPrCtrl->SetFitType(    LocalPrintControl.GetFitType());
01511     pPrCtrl->SetScale(      LocalPrintControl.GetScale());
01512     pPrCtrl->SetTopMargin(  LocalPrintControl.GetTopMargin());
01513     pPrCtrl->SetLeftMargin( LocalPrintControl.GetLeftMargin());
01514     pPrCtrl->SetWidth(      LocalPrintControl.GetWidth());
01515     pPrCtrl->SetHeight(     LocalPrintControl.GetHeight());
01516     pPrCtrl->SetRows(       LocalPrintControl.GetRows());
01517     pPrCtrl->SetColumns(    LocalPrintControl.GetColumns());
01518     pPrCtrl->SetGutter(     LocalPrintControl.GetGutter());
01519 *|
01520 
01521     // Read the docuemnt vaules directly out of the dialogue
01522     CGadgetID OrientGadgets[] = { _R(IDC_BTN_UPRIGHT), _R(IDC_BTN_SIDEWAYS), NULL };
01523     BOOL Result = (pPrefsDlg->GetRadioGroupSelected(OrientGadgets) == _R(IDC_BTN_UPRIGHT));
01524     pPrCtrl->SetPrintOrient((Result) ? PRINTORIENTATION_UPRIGHT : PRINTORIENTATION_SIDEWAYS);
01525 
01526     CGadgetID DPSGadgets[] = { _R(IDC_DPS_INDIVIDUALPAGES), _R(IDC_DPS_WHOLESPREAD), NULL };
01527     Result = (pPrefsDlg->GetRadioGroupSelected(DPSGadgets) == _R(IDC_DPS_WHOLESPREAD));
01528     pPrCtrl->SetWholeSpread(Result);
01529 
01530     CGadgetID FitGadgets[] = { _R(IDC_BESTFIT), _R(IDC_CUSTOMFIT), _R(IDC_MULTIPLEFIT), NULL };
01531     ResourceID FitRadio = GetRadioGroupSelected(FitGadgets))
01532     if (FitRadio == _R(IDC_BESTFIT))
01533         pPrCtrl->SetFitType(PRINTFIT_BEST);
01534     else if (FitRadio == _R(IDC_CUSTOMFIT))
01535         pPrCtrl->SetFitType(PRINTFIT_CUSTOM);
01536     else if (FitRadio == _R(IDC_MULTIPLEFIT))
01537         pPrCtrl->SetFitType(PRINTFIT_MULTIPLE);
01538     
01539     double Scale = pPrefsDlg->GetDoubleGadgetValue(_R(IDC_SCALEEDIT),0,0);
01540     // We need to range check the value before converting it to a Fixed 16
01541     if (Scale > 32000.0) Scale = 32000.0;
01542     if (Scale < 0)       Scale = 0.0;
01543     pPrCtrl->SetScale(FIXED16(Scale));
01544 
01545     pPrCtrl->SetTopMargin(pPrefsDlg->GetUnitGadgetValue(_R(IDC_TOPEDIT),CurrentPageUnits,0,0));
01546     pPrCtrl->SetLeftMargin(pPrefsDlg->GetUnitGadgetValue(_R(IDC_LEFTEDIT),CurrentPageUnits,0,0));
01547     pPrCtrl->SetWidth(pPrefsDlg->GetUnitGadgetValue(_R(IDC_WIDTHEDIT),CurrentPageUnits,0,0));
01548     pPrCtrl->SetHeight(pPrefsDlg->GetUnitGadgetValue(_R(IDC_HEIGHTEDIT),CurrentPageUnits,0,0));
01549     pPrCtrl->SetRows(pPrefsDlg->GetLongGadgetValue(_R(IDC_ROWSEDIT),0,0));
01550     pPrCtrl->SetColumns(pPrefsDlg->GetLongGadgetValue(_R(IDC_COLUMNSEDIT),0,0));
01551     pPrCtrl->SetGutter(pPrefsDlg->GetUnitGadgetValue(_R(IDC_GUTTEREDIT),CurrentPageUnits,0,0));
01552 
01553     // Finished making the changes.
01554     pPrCtrl->EndImport();
01555 
01556     // Set up the print again so that it takes the new settings on board
01557     pPrCtrl->SetUp(pDocument->GetSelectedSpread());
01558 */
01559 
01560     // Redraw all views that are showing their print borders
01561     FRDocViewFunc pFunc = PrintControl::RedrawPrintableArea;
01562     pDocument->ForceRedraw(pFunc);
01563 
01564     return(PrintBaseTab::CommitSection());
01565 }
01566 
01567 
01568 /******************************************************************************************
01569 
01570 >   BOOL PrintLayoutTab::InitSection()
01571 
01572     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01573     Created:    23/3/95
01574     Inputs:     -
01575     Outputs:    -
01576     Returns:    TRUE if successful, else FALSE
01577     Purpose:    Sets initial values for the print layout section of the options dialog box.
01578                 This section includes the:-
01579     Errors:     -
01580     SeeAlso:    AppPrefsDlg; OptionsTabs;
01581 
01582 ******************************************************************************************/
01583 
01584 BOOL PrintLayoutTab::InitSection()
01585 {
01586     if (PrintBaseTab::InitSection())
01587     {
01588         ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintLayoutTab::InitSection called with no dialog pointer");
01589 
01590         pPrefsDlg->SetGadgetBitmaps(_R(IDC_BTN_SIDEWAYS),0,0);
01591         pPrefsDlg->SetGadgetBitmaps(_R(IDC_BTN_UPRIGHT),0,0);
01592 
01593         // Set up the units that are used in the currently selected document
01594         // All units work off the selected document and so we must do nothing if there is no
01595         // selected document.
01596         if (!SetUpDocUnits())
01597         {
01598             // If returns False then we are in an invalid situation and so should make sure that
01599             // the dialog box is greyed.
01600             GreySection();
01601             return (TRUE);
01602         }
01603 
01604         return ShowDetails();
01605     }
01606     else
01607         return FALSE;
01608 }
01609 
01610 /******************************************************************************************
01611 
01612 >   BOOL PrintLayoutTab::ShowDetails()
01613 
01614     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01615     Created:    24/3/95
01616     Inputs:     pGadgetIDList = ptr to gadgets to show details in (NULL means all gadgets)
01617     Outputs:    -
01618     Returns:    TRUE if successful, else FALSE
01619     Purpose:    Sets values for the print layout section of the options dialog box.
01620     Errors:     -
01621     SeeAlso:    AppPrefsDlg; OptionsTabs; ShowDetails(CGadgetID* pGadgetIDList,CGadgetID Exclude)
01622 
01623 ******************************************************************************************/
01624 
01625 BOOL PrintLayoutTab::ShowDetails()
01626 {
01627     return ShowDetails(NULL, 0);
01628 }
01629 
01630 /******************************************************************************************
01631 
01632 >   BOOL PrintLayoutTab::ShowDetails(CGadgetID* pGadgetIDList,CGadgetID Exclude)
01633 
01634     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01635     Created:    10/4/95
01636     Inputs:     pGadgetIDList   = ptr to gadgets to show details in (NULL means all gadgets)
01637                 Exclude         = gadget to exclude in list
01638     Outputs:    -
01639     Returns:    TRUE if successful, else FALSE
01640     Purpose:    Sets values for the print layout section of the options dialog box.
01641     Errors:     -
01642     SeeAlso:    AppPrefsDlg; OptionsTabs;
01643 
01644 ******************************************************************************************/
01645 
01646 BOOL PrintLayoutTab::ShowDetails(CGadgetID* pGadgetIDList, CGadgetID Exclude)
01647 {
01648     if (Document::GetSelected() == NULL)    // No document around! Eek!
01649         return(FALSE);
01650 
01651     IgnoreTextChangedMsgs = TRUE;
01652 
01653     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintLayoutTab::ShowDetailscalled with no dialog pointer");
01654 
01655     // A list of all the gadgets in which we display details in
01656     static CGadgetID pAllGadgets[] ={   _R(IDC_LAYOUTINFO),_R(IDC_PAPERSIZEINFO),_R(IDC_DPS_WHOLESPREAD),
01657                                         _R(IDC_BTN_UPRIGHT),_R(IDC_SCALEEDIT),_R(IDC_BESTFIT),
01658                                         _R(IDC_TOPEDIT),_R(IDC_LEFTEDIT),_R(IDC_WIDTHEDIT),_R(IDC_HEIGHTEDIT),
01659                                         _R(IDC_ROWSEDIT),_R(IDC_COLUMNSEDIT),_R(IDC_GUTTEREDIT),
01660                                         0 };
01661 
01662     // If no gadget list is given, fall back to the list of all gadgets
01663     if (pGadgetIDList == NULL)
01664         pGadgetIDList = pAllGadgets;
01665 
01666     BOOL ShowMargins =  (   (LocalPrintControl.GetFitType() != PRINTFIT_MULTIPLE) || 
01667                             ((LocalPrintControl.GetRows() == 1) && (LocalPrintControl.GetColumns() == 1))
01668                         );
01669 
01670     String_256 Str;
01671     String_256 Dash = "-";
01672     
01673     for (INT32 i=0; pGadgetIDList[i]; i++)
01674     {
01675         // Ignore the the exclude gadget
01676         if (pGadgetIDList[i] == Exclude)
01677             continue;
01678 
01679         if (FALSE) {}
01680         else if (pGadgetIDList[i] == _R(IDC_LAYOUTINFO))
01681         {
01682             // Display that print info
01683             Str = LocalPrintControl.BuildPrintInfoStr();
01684             pPrefsDlg->SetStringGadgetValue(_R(IDC_LAYOUTINFO),Str);
01685         }
01686         else if (pGadgetIDList[i] == _R(IDC_PAPERSIZEINFO))
01687         {
01688             // Display the paper size
01689             Str = LocalPrintControl.BuildPaperSizeStr();
01690             pPrefsDlg->SetStringGadgetValue(_R(IDC_PAPERSIZEINFO),Str);
01691         }
01692         else if (pGadgetIDList[i] == _R(IDC_DPS_WHOLESPREAD))
01693         {
01694             // Reflect the Whole Spread flag
01695             BOOL WholeSpread = LocalPrintControl.IsWholeSpread();
01696             pPrefsDlg->SetBoolGadgetSelected(_R(IDC_DPS_WHOLESPREAD),WholeSpread);
01697             pPrefsDlg->SetBoolGadgetSelected(_R(IDC_DPS_INDIVIDUALPAGES),!WholeSpread);
01698         }
01699         else if (pGadgetIDList[i] == _R(IDC_BTN_UPRIGHT))
01700         {
01701             // Set the orientation bitmap buttons
01702             BOOL Upright = (LocalPrintControl.GetPrintOrient() == PRINTORIENTATION_UPRIGHT);
01703             pPrefsDlg->SetBoolGadgetSelected(_R(IDC_BTN_UPRIGHT),Upright);
01704             pPrefsDlg->SetBoolGadgetSelected(_R(IDC_BTN_SIDEWAYS),!Upright);
01705         }
01706         else if (pGadgetIDList[i] == _R(IDC_SCALEEDIT)) 
01707         {
01708             // Set the scale factor field
01709             FIXED16 Scale = LocalPrintControl.GetScale();
01710             pPrefsDlg->SetDoubleGadgetValue(_R(IDC_SCALEEDIT),Scale.MakeDouble());
01711         }
01712         else if (pGadgetIDList[i] == _R(IDC_BESTFIT))
01713         {
01714             // The fit radio buttons
01715             CGadgetID FitList[] = { _R(IDC_BESTFIT),_R(IDC_CUSTOMFIT),_R(IDC_MULTIPLEFIT),_R(IDC_BESTFITPAPER), 0 };
01716 
01717             switch (LocalPrintControl.GetFitType())
01718             {
01719                 case PRINTFIT_BEST:     pPrefsDlg->SetRadioGroupSelected(FitList,_R(IDC_BESTFIT));      break;
01720                 case PRINTFIT_CUSTOM:   pPrefsDlg->SetRadioGroupSelected(FitList,_R(IDC_CUSTOMFIT));    break;
01721                 case PRINTFIT_MULTIPLE: pPrefsDlg->SetRadioGroupSelected(FitList,_R(IDC_MULTIPLEFIT));  break;
01722                 case PRINTFIT_BESTPAPER:pPrefsDlg->SetRadioGroupSelected(FitList,_R(IDC_BESTFITPAPER)); break;
01723                 default: ERROR2(FALSE,"Unknown print fit type");
01724             }
01725         }
01726         else if (pGadgetIDList[i] == _R(IDC_TOPEDIT))
01727         {
01728             // Custom fit editable values
01729             if (ShowMargins)
01730                 pPrefsDlg->SetUnitGadgetValue(_R(IDC_TOPEDIT),  CurrentPageUnits, LocalPrintControl.GetTopMargin());
01731             else
01732                 pPrefsDlg->SetStringGadgetValue(_R(IDC_TOPEDIT), Dash);
01733         }
01734         else if (pGadgetIDList[i] == _R(IDC_LEFTEDIT))
01735         {   
01736             // Custom fit editable values
01737             if (ShowMargins)
01738                 pPrefsDlg->SetUnitGadgetValue(_R(IDC_LEFTEDIT), CurrentPageUnits, LocalPrintControl.GetLeftMargin());
01739             else
01740                 pPrefsDlg->SetStringGadgetValue(_R(IDC_LEFTEDIT), Dash);
01741         }
01742         else if (pGadgetIDList[i] == _R(IDC_WIDTHEDIT))
01743         {
01744             pPrefsDlg->SetUnitGadgetValue(_R(IDC_WIDTHEDIT),CurrentPageUnits, LocalPrintControl.GetWidth());
01745         }
01746         else if (pGadgetIDList[i] == _R(IDC_HEIGHTEDIT))
01747         {
01748             pPrefsDlg->SetUnitGadgetValue(_R(IDC_HEIGHTEDIT),CurrentPageUnits, LocalPrintControl.GetHeight());
01749         }
01750         else if (pGadgetIDList[i] == _R(IDC_ROWSEDIT))
01751         {
01752             pPrefsDlg->SetLongGadgetValue(_R(IDC_ROWSEDIT), LocalPrintControl.GetRows());
01753         }
01754         else if (pGadgetIDList[i] == _R(IDC_COLUMNSEDIT))
01755         {
01756             pPrefsDlg->SetLongGadgetValue(_R(IDC_COLUMNSEDIT),LocalPrintControl.GetColumns());
01757         }
01758         else if (pGadgetIDList[i] == _R(IDC_GUTTEREDIT))
01759         {
01760             pPrefsDlg->SetUnitGadgetValue(_R(IDC_GUTTEREDIT),CurrentPageUnits, LocalPrintControl.GetGutter());
01761         }
01762         else
01763         {
01764             ERROR3_PF(("Unknown gadget ID (%D)",pGadgetIDList));
01765         }
01766     }
01767 
01768     BOOL ok = EnableControls();
01769 
01770     IgnoreTextChangedMsgs = FALSE;
01771 
01772     return ok;
01773 }
01774 
01775 /******************************************************************************************
01776 
01777 >   BOOL PrintLayoutTab::EnableControls()
01778 
01779     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01780     Created:    28/3/95
01781     Inputs:     -
01782     Outputs:    -
01783     Returns:    TRUE if all went well
01784     Purpose:    The enables and disables the various controls depending on the values held
01785                 in the given print control object
01786     Errors:     -
01787     SeeAlso:    -
01788 
01789 ******************************************************************************************/
01790 
01791 BOOL PrintLayoutTab::EnableControls()
01792 {
01793     if (pPrefsDlg == NULL) return TRUE;
01794 
01795     if (!TalkToPage())
01796         return(TRUE);
01797 
01798 //  BOOL BestFit     = (LocalPrintControl.GetFitType() == PRINTFIT_BEST);
01799     BOOL CustomFit   = (LocalPrintControl.GetFitType() == PRINTFIT_CUSTOM);
01800     BOOL MultipleFit = (LocalPrintControl.GetFitType() == PRINTFIT_MULTIPLE);
01801 //  BOOL BestFitPaper= (LocalPrintControl.GetFitType() == PRINTFIT_BESTPAPER);
01802 
01803     // Controls available all the time
01804     EnableControl(_R(IDC_BESTFIT),          TRUE);
01805     EnableControl(_R(IDC_CUSTOMFIT),        TRUE);
01806     EnableControl(_R(IDC_MULTIPLEFIT),      TRUE);
01807     EnableControl(_R(IDC_BESTFITPAPER),     TRUE);
01808     EnableControl(_R(IDC_PRINT_DOCNAME),    TRUE);
01809     EnableControl(_R(IDC_PRINT_DOCNAMETEXT),TRUE);
01810     EnableControl(_R(IDC_LAYOUTINFO),       TRUE);
01811     EnableControl(_R(IDC_PAPERSIZETEXT),    TRUE);
01812     EnableControl(_R(IDC_PAPERSIZEINFO),    TRUE);
01813 
01814     // Controls available when in custom fit mode
01815     EnableControl(_R(IDC_TOPEDIT),      CustomFit);
01816     EnableControl(_R(IDC_LEFTEDIT),     CustomFit);
01817     EnableControl(_R(IDC_WIDTHEDIT),    CustomFit);
01818     EnableControl(_R(IDC_HEIGHTEDIT),   CustomFit);
01819     EnableControl(_R(IDC_TOPTEXT),      CustomFit);
01820     EnableControl(_R(IDC_LEFTTEXT),     CustomFit);
01821     EnableControl(_R(IDC_WIDTHTEXT),    CustomFit);
01822     EnableControl(_R(IDC_HEIGHTTEXT),   CustomFit);
01823     EnableControl(_R(IDC_SCALEEDIT),    CustomFit);
01824     EnableControl(_R(IDC_SCALETEXT),    CustomFit);
01825     EnableControl(_R(IDC_SCALEPERCENT), CustomFit);
01826 
01827     // Controls available when in multiple fit mode
01828     EnableControl(_R(IDC_ROWSEDIT),     MultipleFit);
01829     EnableControl(_R(IDC_COLUMNSEDIT),  MultipleFit);
01830     EnableControl(_R(IDC_GUTTEREDIT),   MultipleFit);
01831     EnableControl(_R(IDC_ROWSTEXT),     MultipleFit);
01832     EnableControl(_R(IDC_COLUMNSTEXT),  MultipleFit);
01833     EnableControl(_R(IDC_GUTTERTEXT),   MultipleFit);
01834 
01835     // Controls available when in multiple or custom fit mode
01836     EnableControl(_R(IDC_BTN_UPRIGHT),          CustomFit || MultipleFit);
01837     EnableControl(_R(IDC_BTN_SIDEWAYS),         CustomFit || MultipleFit);
01838     EnableControl(_R(IDC_PRINTORIENTATIONTEXT), CustomFit || MultipleFit);
01839 
01840     // Controls available when the page is a double page spread
01841     EnableControl(_R(IDC_DPS_WHOLESPREAD),      LocalPrintControl.IsDoublePageSpread());
01842     EnableControl(_R(IDC_DPS_INDIVIDUALPAGES),  LocalPrintControl.IsDoublePageSpread());
01843 
01844     // If in windows 95, hide the picture boxes as they don't slab in, and go against Win95 look & feel
01845 PORTNOTE("other", "Assume new windows UI")
01846 #ifndef EXCLUDE_FROM_XARALX
01847     if (CCamApp::IsNewWindowsUI()) //IsWindows95())
01848 #endif
01849     {
01850         if (pPrefsDlg != NULL)
01851         {
01852             pPrefsDlg->HideGadget(_R(IDC_LAYOUTINFO_BOX),TRUE);
01853             pPrefsDlg->HideGadget(_R(IDC_PAPERSIZEINFO_BOX),TRUE);
01854         }
01855     }
01856 
01857     return TRUE;
01858 }
01859 
01860 #ifdef _DEBUG
01861 /******************************************************************************************
01862 
01863 >   static void PrintLayoutTab::TestPrinting(PrintControl* pPrCtrl)
01864 
01865     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01866     Created:    26/4/95
01867     Inputs:     pPrCtrl = ptr to print control to test
01868     Outputs:    -
01869     Returns:    -
01870     Purpose:    This tests the printing loop functions in the print control object
01871     Errors:     -
01872     SeeAlso:    -
01873 
01874 ******************************************************************************************/
01875 
01876 void PrintLayoutTab::TestPrinting(PrintControl* pPrCtrl)
01877 {
01878 PORTNOTE("printing", "Disable PrintLayoutTab::TestPrinting")
01879 #ifndef EXCLUDE_FROM_XARALX
01880     if (pPrCtrl != NULL && pPrCtrl->StartPrinting())
01881     {
01882         BOOL Aborted = FALSE;
01883         PrintProgressDlg* pPrgDlg = new PrintProgressDlg(NULL);
01884 
01885         if (pPrgDlg != NULL)
01886         {
01887             pPrgDlg->SetDocName(Document::GetCurrent()->GetTitle());
01888             pPrgDlg->Show();
01889         }
01890 
01891         time_t CurrentTime = time(NULL);
01892 
01893         while (!Aborted && pPrCtrl->GetNextPaper())
01894         {
01895             Layer* pLayer = new Layer;
01896 
01897             PrintPatchInfo PatchInfo;
01898 
01899             SIZEL PaperSize;
01900             if (!CCPrintDialog::GetPaperSize(&PaperSize))
01901                 return;
01902             MakeRectangle(pLayer,DocRect(0,0,PaperSize.cx,PaperSize.cy),COLOUR_MIDGREY);
01903 
01904             BOOL DisplayClipRect = TRUE;
01905 
01906             while (!Aborted && pPrCtrl->GetNextPatch(&PatchInfo))
01907             {
01908                 if (pPrgDlg != NULL)
01909                 {
01910                     pPrgDlg->SetPageNumber( PatchInfo.PaperNumber,
01911                                             PatchInfo.MaxPaperNumber,
01912                                             1, 1, NULL,
01913                                             PatchInfo.PatchNumber,
01914                                             PatchInfo.MaxPatchNumber);
01915 
01916                     pPrgDlg->SetSliderSubRangeMax(2000);
01917                 }
01918 
01919                 INT32 pos=0;
01920                 while ((time(NULL) - CurrentTime) < 2)
01921                 {
01922                     if (!PrintProgressDlg::AbortProc(0,0))
01923                     {
01924                         Aborted = TRUE;
01925                         break;
01926                     }
01927                     if (pPrgDlg != NULL)
01928                         pPrgDlg->SetSliderSubRangePos(pos++);
01929                 }
01930                 CurrentTime = time(NULL);
01931 
01932                 if (DisplayClipRect)
01933                 {
01934                     MakeRectangle(pLayer,PatchInfo.GetClipRect(FALSE,FALSE),COLOUR_GREEN);
01935                     DisplayClipRect = FALSE;
01936                 }
01937 
01938                 DocRect Rect = PatchInfo.GetClipRect(FALSE,FALSE);
01939                 double ScaleFactor = PatchInfo.Scale.MakeDouble() / 100;
01940 
01941                 INT32 w = Rect.Width();
01942                 INT32 h = Rect.Height();
01943 
01944                 if (PatchInfo.Rotate)
01945                 {   INT32 t = w;    w = h;  h = t;  }
01946 
01947                 Rect.lox = PatchInfo.XTrans;
01948                 Rect.loy = PatchInfo.YTrans;
01949 
01950                 Rect.hix = Rect.lox + (INT32((double(w) * ScaleFactor)+0.5));
01951                 Rect.hiy = Rect.loy + (INT32((double(h) * ScaleFactor)+0.5));
01952 
01953                 MakeRectangle(pLayer,Rect,COLOUR_RED);
01954             }
01955 
01956             if (!Aborted && pLayer != NULL && PatchInfo.pSpread != NULL)
01957             {
01958                 TCHAR name[256];
01959                 camSprintf(name,_T("Page %d"),PatchInfo.PaperNumber);
01960                 pLayer->SetLayerID(String_256(name));
01961                 pLayer->AttachNode(PatchInfo.pSpread,LASTCHILD);
01962                 pLayer->SetVisible(FALSE);
01963                 LayerSGallery::MakeActiveLayer(pLayer);
01964             }
01965         }
01966 
01967         if (pPrgDlg != NULL)
01968         {
01969             pPrgDlg->DestroyWindow();
01970             delete pPrgDlg;
01971             pPrgDlg = NULL;
01972         }
01973 
01974         pPrCtrl->EndPrinting();
01975         Document::GetCurrent()->ForceRedraw();
01976     }
01977 #endif
01978 }
01979 
01980 void PrintLayoutTab::MakeRectangle(Layer* pLayer,DocRect Rect, StockColour Col)
01981 {
01982     NodeRect* pNodeRect = new NodeRect;
01983     if (pNodeRect != NULL && pLayer != NULL)
01984     {
01985         if (pNodeRect->InkPath.Initialise())
01986         {
01987             pNodeRect->CreateShape(Rect);
01988             pNodeRect->AttachNode(pLayer,LASTCHILD);
01989             pNodeRect->InkPath.IsFilled = TRUE;
01990             pNodeRect->InkPath.IsStroked = TRUE;
01991 
01992             DocColour DocCol(Col);
01993             
01994             FlatFillAttribute Attr(DocCol);
01995             NodeAttribute* pAttr = Attr.MakeNode();
01996             if (pAttr != NULL)
01997                 pAttr->AttachNode(pNodeRect,LASTCHILD);
01998         }
01999     }
02000 }
02001 
02002 #endif  // _DEBUG
02003 
02004 
02005 /************************************************************************************************
02006 CLASS PrintSepsTab
02007  Adrian, 17/06/96
02008 ************************************************************************************************/
02009 
02010 /************************************************************************************************
02011   > PrintSepsTab::PrintSepsTab() 
02012 
02013 
02014     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
02015     Created:    12/6/96
02016     Inputs:     -
02017     Outputs:    -
02018     Returns:    -
02019     Purpose:    PrintSepsTab constructor.
02020     Errors:     -
02021     SeeAlso:    -
02022 
02023 ********************************************************************************************/
02024 
02025 PrintSepsTab::PrintSepsTab()
02026 {
02027     OldPrintSpotsAsProcess = IndexedColour::AreSpotsForcedToProcess();
02028 }
02029 
02030 
02031 /********************************************************************************************
02032 
02033 >   PrintSepsTab::~PrintSepsTab()
02034 
02035 
02036     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
02037     Created:    12/6/96
02038     Inputs:     -
02039     Outputs:    -
02040     Returns:    -
02041     Purpose:    PrintSepsTab destructor
02042     Errors:     -
02043     SeeAlso:    -
02044 
02045 ********************************************************************************************/
02046                                                                                 
02047 PrintSepsTab::~PrintSepsTab()
02048 { 
02049 }        
02050 
02051 CDlgResID PrintSepsTab::GetPageID() { return _R(IDD_OPTSTAB_PRINTPRINT); }
02052 
02053 /********************************************************************************************
02054 
02055 >   BOOL PrintSepsTab::HandleMsg(DialogMsg* Msg)
02056 
02057     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>/Jason
02058     Created:    12/6/96
02059     Inputs:     -
02060     Outputs:    -
02061     Returns:    -
02062     Purpose:    Handles messages sent by various controls on this tab  
02063     Errors:     -
02064     SeeAlso:    -
02065 
02066 ********************************************************************************************/
02067 
02068 BOOL PrintSepsTab::HandleMsg(DialogMsg* Msg)
02069 {
02070     if ((IsAllGreyed() || pDocument == NULL) && Msg->DlgMsg != DIM_CREATE)
02071         return(TRUE);
02072 
02073     ERROR2IF(Msg == NULL,FALSE,"PrintSepsTab::Message null message received");
02074     if ((IsAllGreyed() || pDocument == NULL) && Msg->DlgMsg != DIM_CREATE)
02075         return(TRUE);
02076 
02077 
02078     BOOL ok = TalkToPage();
02079     if (!ok)
02080         return TRUE;        // page not present
02081 
02082     TypesetInfo *pTypesetInfo = LocalPrintControl.GetTypesetInfo();
02083     ERROR2IF(pTypesetInfo == NULL, TRUE, "Can't find typesetting info structure");
02084 
02085     switch(Msg->DlgMsg)
02086     {
02087         case DIM_CANCEL:
02088             // If cancelled, we have to restore the previous setting of the "print spot colours as process"
02089             // flag, which (rather than being local has to be set on a global scale).
02090             IndexedColour::ForceSpotsToBeProcess(OldPrintSpotsAsProcess);
02091 
02092             // And call the base class to keep it happy.
02093             return(PrintBaseTab::HandleMsg(Msg));
02094 
02095 
02096         case DIM_LFT_BN_CLICKED:
02097             if (FALSE) {}
02098             // Separations checkbox
02099             else if (Msg->GadgetID == _R(IDC_CHECKSEPARATIONS))
02100             {
02101                 BOOL DoSeparations = pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKSEPARATIONS));
02102                 pTypesetInfo->SetSeparations(DoSeparations);
02103 
02104                 // Toggle the OutputPrintersMarks state automatically
02105                 if (pTypesetInfo->OutputPrintersMarks() != DoSeparations)
02106                 {
02107                     pTypesetInfo->SetOutputPrintersMarks(DoSeparations);
02108 
02109                     // Make sure the print layout tab updates scale factors etc suitably
02110                     BROADCAST_TO_ALL(PrintMsg(PrintMsg::SETTINGSCHANGED));
02111                 }
02112 
02113                 // And let the imagesetting tab know that the seps state has changed
02114                 BROADCAST_TO_ALL(OptionsChangingMsg(OptionsChangingMsg::SEPARATIONSENABLED));
02115 
02116                 // Adjust the shading of controls as appropriate, and make sure things like
02117                 // the page size are updated to take printers marks into account
02118                 PageSizeHasChanged();
02119                 OptionsTabs::SetApplyNowState(TRUE);
02120             }
02121             else if (Msg->GadgetID == _R(IDC_CHECKPROCESS))
02122             {
02123                 // If the "print spot colours as process colours" option is changed,
02124                 // interactively update the plate list
02125                 IndexedColour::ForceSpotsToBeProcess(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKPROCESS)));
02126                 ShowDetails();
02127                 OptionsTabs::SetApplyNowState(TRUE);
02128             }
02129             else if (Msg->GadgetID == _R(IDC_PRINTERDEFAULTS))
02130             {
02131                 EnableControl(_R(IDC_COMBORESOLUTION),  FALSE);
02132                 EnableControl(_R(IDC_COMBOFREQUENCY),   FALSE);
02133                 EnableControl(_R(IDC_COMBOTYPE),        FALSE);
02134 
02135                 pTypesetInfo->SetScreening(FALSE);      // Disable screening
02136                 pTypesetInfo->ResetAllPlatesToDefaultScreens();
02137                 ShowDetails();                          // Make sure colour plate list resets to defaults
02138 
02139                 OptionsTabs::SetApplyNowState(TRUE);
02140             }
02141             else if (Msg->GadgetID == _R(IDC_CUSTOMSETTINGS))
02142             {
02143                 EnableControl(_R(IDC_COMBORESOLUTION),  TRUE);
02144                 EnableControl(_R(IDC_COMBOFREQUENCY),   TRUE);
02145                 EnableControl(_R(IDC_COMBOTYPE),        TRUE);
02146 
02147                 pTypesetInfo->SetScreening(TRUE);
02148                 OptionsTabs::SetApplyNowState(TRUE);
02149             }
02150             else if (Msg->GadgetID == _R(IDC_PLATEPROPS))
02151             {
02152                 if (pTypesetInfo->AreSeparating())
02153                 {
02154                     String_256 GreyReason;
02155                     OpState DlgState = SepsDlg::GetState(&GreyReason, NULL);
02156 
02157                     if (!DlgState.Greyed)
02158                     {
02159                         // Store away the current plate settings in our local print control
02160                         ReadCurrentPlateSettings(pTypesetInfo);
02161 
02162                         ColourPlate *pPlate = GetSelectedPlate();
02163                         if (pPlate != NULL)
02164                         {
02165                             if (SepsDlg::InvokeDialog(pPlate, this))
02166                             {
02167                                 // The angle or frequency has been changed by the user, so make sure that
02168                                 // screening is auto-enabled...
02169                                 if (!pTypesetInfo->AreScreening())
02170                                     pTypesetInfo->SetScreening(TRUE);
02171                             }
02172 
02173                             ShowDetails(); //update tab data - maybe it should check whether the dialog returned with OK or Cancel 
02174                             OptionsTabs::SetApplyNowState(TRUE);
02175                         }
02176                     }
02177                 }
02178             }
02179 
02180         case DIM_TEXT_CHANGED:
02181             // Enable the Apply button 
02182             OptionsTabs::SetApplyNowState(TRUE);
02183             break;
02184 
02185         case DIM_FOCUS_LOST:
02186             if (FALSE) {}
02187             else if (Msg->GadgetID == _R(IDC_COMBORESOLUTION))
02188             {
02189                 pTypesetInfo->SetPrintResolution(pPrefsDlg->GetLongGadgetValue(_R(IDC_COMBORESOLUTION), 100, 10000));
02190             }
02191             else if (Msg->GadgetID == _R(IDC_COMBOFREQUENCY))
02192             {
02193                 BOOL valid = TRUE;
02194                 // Check that the value is within range, if not warn the user and fall back to a default value
02195                 
02196                 double NewVal = pPrefsDlg->GetDoubleGadgetValue(_R(IDC_COMBOFREQUENCY), 2, 1000, _R(IDS_INVALID_FREQUENCY), &valid);
02197                 if (valid) // update the default frequency
02198                 {
02199                     pTypesetInfo->SetScreening(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CUSTOMSETTINGS)));
02200                     if (pTypesetInfo->AreScreening())
02201                         pTypesetInfo->SetDefaultScreenFrequency(NewVal, TRUE);
02202                 }
02203 
02204                 ShowDetails();
02205             }
02206             break;
02207 
02208         
02209         case DIM_SELECTION_CHANGED:
02210             if (FALSE) {}
02211             else if (Msg->GadgetID == _R(IDC_COMBOFREQUENCY)) // make sure a change in the default frequency is reflected in the plate list
02212             {
02213                 pTypesetInfo->SetScreening(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CUSTOMSETTINGS)));
02214                 if (pTypesetInfo->AreScreening())
02215                     pTypesetInfo->SetDefaultScreenFrequency(pPrefsDlg->GetDoubleGadgetValue(_R(IDC_COMBOFREQUENCY), 2, 1000), TRUE);
02216 
02217                 ShowDetails();
02218             }
02219             else if (Msg->GadgetID == _R(IDC_COMBORESOLUTION))
02220             {
02221                 pTypesetInfo->SetPrintResolution(pPrefsDlg->GetLongGadgetValue(_R(IDC_COMBORESOLUTION), 100, 10000));
02222             }
02223             else if (Msg->GadgetID == _R(IDC_COMBOTYPE))
02224             {
02225                 pTypesetInfo->SetScreenFunction((ScreenType) (pPrefsDlg->GetSelectedValueIndex(_R(IDC_COMBOTYPE)) + 1));
02226             }
02227             else if (Msg->GadgetID == _R(IDC_LISTCOLOURS))
02228             {
02229                 // Store away the current plate settings in our local print control
02230                 if (pTypesetInfo->AreSeparating())
02231                     ReadCurrentPlateSettings(pTypesetInfo);
02232             }           
02233             OptionsTabs::SetApplyNowState(TRUE); // enable the Apply button
02234             break;
02235 
02236 
02237         case DIM_SELECTION_CHANGED_COMMIT:
02238             OptionsTabs::SetApplyNowState(TRUE);
02239             if (FALSE) {}
02240             else if (Msg->GadgetID == _R(IDC_LISTCOLOURS))
02241             {
02242                 if (pTypesetInfo->AreSeparating())
02243                 {
02244                     String_256 GreyReason;
02245                     OpState DlgState = SepsDlg::GetState(&GreyReason, NULL);
02246 
02247                     if (!DlgState.Greyed)
02248                     {
02249                         // Store away the current plate settings in our local print control
02250                         ReadCurrentPlateSettings(pTypesetInfo);
02251 
02252                         // And give the user a properties dialogue to edit in
02253                         ColourPlate *pPlate = GetSelectedPlate();
02254                         if (pPlate != NULL)
02255                         {
02256                             if (SepsDlg::InvokeDialog(pPlate, this))
02257                             {
02258                                 // The angle or frequency has been changed by the user, so make sure that
02259                                 // screening is auto-enabled...
02260                                 if (!pTypesetInfo->AreScreening())
02261                                     pTypesetInfo->SetScreening(TRUE);
02262                             }
02263                         }
02264 
02265                         ShowDetails(); //update tab data - maybe it should check whether the dialog returned with OK or Cancel
02266                     }
02267                 }
02268             }
02269             break;
02270 
02271         default:
02272             return(PrintBaseTab::HandleMsg(Msg));
02273     }       
02274     return TRUE;
02275 }  
02276 
02277 
02278 
02279 /********************************************************************************************
02280 
02281 >   virtual MsgResult PrintSepsDlg::Message(Msg *pMessage)
02282 
02283     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02284     Created:    20/8/96
02285     Inputs:     pMessage - the message
02286 
02287     Returns:    OK
02288 
02289     Purpose:    Handles miscellaneous system messages
02290                 Note that many messages (e.g. docuement/view changing) are handled by
02291                 the base dialogue, and call our UpdateSection() function. Only "left over"
02292                 messages like ColourChangingMsg are passed on to the tabs
02293 
02294 ********************************************************************************************/
02295 
02296 MsgResult PrintSepsTab::Message(Msg *pMessage)
02297 {
02298     if (MESSAGE_IS_A(pMessage, ColourChangingMsg))
02299     {
02300         ColourChangingMsg *TheMsg = (ColourChangingMsg *) pMessage;
02301 
02302         switch ( TheMsg->State )
02303         {
02304             case ColourChangingMsg::COLOURUPDATED:
02305             case ColourChangingMsg::COLOURUPDATEDINVISIBLE:
02306             case ColourChangingMsg::LISTUPDATED:
02307                 // Only handle these messages - others will be handled implicitly
02308                 // by the Document/View changing handlers.
02309                 ShowDetails();
02310                 break;
02311             default:
02312                 break;
02313         }
02314     }
02315 
02316     return(OK);
02317 }
02318 
02319 
02320 
02321 /******************************************************************************************
02322 
02323 >   BOOL PrintSepsTab::CommitSection()
02324 
02325     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>/Jason
02326     Created:    12/6/96
02327     Inputs:     -
02328     Outputs:    -
02329     Returns:    True if values in dialog box ok, False otherwise.     
02330     Purpose:    Takes the values in the Print Separations section tab of the options dialog box and
02331                 sets the associated preference values accordingly
02332                 Called when ok is pressed on the dialog box.
02333     Errors:     -
02334     SeeAlso:    -
02335 
02336 ******************************************************************************************/
02337 
02338 BOOL PrintSepsTab::CommitSection()
02339 {
02340     if (IsAllGreyed() || pDocument == NULL)
02341         return(PrintBaseTab::CommitSection());
02342 
02343     ERROR3IF(pPrefsDlg == NULL, "PrintLayoutTab::CommitSection called with no dialog pointer");
02344 
02345     if (!TalkToPage())
02346         return TRUE;    // Just return if TalkToPage() fails
02347 
02348     // Always update the real document print control
02349     PrintControl* pPrCtrl = &LocalPrintControl; //GetPrintControl();
02350     ERROR2IF(pPrCtrl == NULL,TRUE,"NULL print control object");
02351 
02352     TypesetInfo *pTypesetInfo = pPrCtrl->GetTypesetInfo();
02353     ERROR2IF(pTypesetInfo == NULL, TRUE, "Can't find typesetting info structure");
02354 
02355     // Read the screening settings
02356     BOOL AreScreening = pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CUSTOMSETTINGS));
02357     if (AreScreening)
02358     {
02359         // Custom screening settings - read the other controls
02360         pTypesetInfo->SetPrintResolution(pPrefsDlg->GetLongGadgetValue(_R(IDC_COMBORESOLUTION), 100, 100000));
02361         pTypesetInfo->SetDefaultScreenFrequency(pPrefsDlg->GetDoubleGadgetValue(_R(IDC_COMBOFREQUENCY), 2, 1000));
02362         pTypesetInfo->SetScreenFunction((ScreenType) (pPrefsDlg->GetSelectedValueIndex(_R(IDC_COMBOTYPE)) + 1));
02363     }
02364 
02365     // Read the current plate settings into the document's TypesetInfo
02366     ReadCurrentPlateSettings(pTypesetInfo);
02367 
02368     // And turn on screening, making sure that the "global" screen settings are properly copied
02369     // through all the ColourPlates
02370     pTypesetInfo->SetScreening(AreScreening);
02371     pTypesetInfo->EnsureAllPlatesHaveGlobalSettings();
02372 
02373     // Read the "print spot colours as process colours" state, and now that we've committed to the value,
02374     // remember it as the "old" state so that cancel doesn't "undo" it! (Needed if the user uses "Apply"
02375     // followed by "Cancel")
02376     OldPrintSpotsAsProcess = pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKPROCESS));
02377     IndexedColour::ForceSpotsToBeProcess(OldPrintSpotsAsProcess);
02378 
02379     return(PrintBaseTab::CommitSection());
02380 }
02381 
02382 
02383 
02384 /******************************************************************************************
02385 
02386 >   INT32 PrintSepsTab::ConvertDoubleToMinString(double Value, String_256 *Result)
02387 
02388     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02389     Created:    18/9/96
02390 
02391     Inputs:     Value - The number to output
02392     Outputs:    Result - Returned with a string representation of the number
02393     Returns:    The number of decimal places that were output
02394 
02395     Purpose:    Converts a double to a "minimal" string.
02396                 That is, it outputs up to 4 decimal places, but strips any trailing
02397                 zeroes off (excepting the first after the decimal point)
02398 
02399                 e.g 1.23456 -> 1.2345    1.230000 -> 1.23    1.00001 -> 1.0
02400 
02401 ******************************************************************************************/
02402 
02403 INT32 PrintSepsTab::ConvertDoubleToMinString(double Value, String_256 *Result)
02404 {
02405     ERROR3IF(Result == NULL, "Illegal null param");
02406 
02407     INT32 DecimalPlaces = 4;
02408     const String_8 Zero(TEXT("0"));
02409     String_8 Temp;
02410 
02411     // Let's do this with applied brute force!
02412     while (DecimalPlaces >= 1)
02413     {
02414         Convert::DoubleToString(Value, (StringBase *)Result, DecimalPlaces);
02415 
02416         Result->Right(&Temp, 1);    // If the rightmost character isn't a 0, then return the string immediately
02417         if (Temp != Zero)
02418             return(DecimalPlaces);
02419 
02420         // Otherwise, see if we can stripanother char off the end
02421         DecimalPlaces--;
02422     }
02423 
02424     // Stripped loads of trailing zeroes, so return 1 d.p.
02425     return(1);
02426 }
02427 
02428 
02429 
02430 /******************************************************************************************
02431 
02432 >   void PrintSepsTab::ReadCurrentPlateSettings(TypesetInfo *pTypesetInfo)
02433 
02434     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02435     Created:    17/9/96
02436 
02437     Outputs:    pTypesetInfo is updated to reflect the current dialogue state
02438 
02439     Purpose:    Retrieves all the colour plate settings in the dialogue and writes them into
02440                 the given TypesetInfo.
02441                 Used to update both the LocalPrintControl.GetTypesetInfo() (when settings
02442                 are changed) and the document's TypesetInfo (in CommitSection)
02443 
02444 ******************************************************************************************/
02445 
02446 void PrintSepsTab::ReadCurrentPlateSettings(TypesetInfo *pTypesetInfo)
02447 {
02448     if (!TalkToPage())
02449         return;
02450 
02451     // Read the "Print Colour separations" check box state and set the print control
02452     // setting as appropriate
02453     BOOL DoSeparations = pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKSEPARATIONS));
02454     pTypesetInfo->SetSeparations(DoSeparations);
02455 
02456 PORTNOTE("other", "Disabled CCustomList")
02457 #ifndef EXCLUDE_FROM_XARALX
02458     // Read back the settings from the list view
02459     CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_LISTCOLOURS));
02460     if (pListGadget)
02461     {
02462         // Read the values of the list switches and set the print/overprint options accordingly
02463         BOOL ok = pTypesetInfo->CreatePlateList();
02464         ERROR3IF(!ok, "Unable to create plate list");
02465 
02466         ColourPlate* pPlate;
02467         pPlate = pTypesetInfo->GetFirstPlate();
02468         ERROR3IF(pPlate == NULL,"Error building colour plate list");
02469         for (INT32 j = 0; j < (INT32) pTypesetInfo->GetNumPlates(); j++)
02470         {
02471             if (pPlate)
02472             {
02473                 pPlate->SetDisabled(!pListGadget->GetSwitchState(j, 0));
02474                 pPlate->SetOverprint(pListGadget->GetSwitchState(j, 1));
02475 
02476                 // Reading in the angle and frequency values is a bit more complicated
02477                 String_256 Angle;
02478                 String_256 Frequency;
02479                 pListGadget->GetItemString(Angle, j, 4);
02480                 pListGadget->GetItemString(Frequency, j, 5);
02481                 pPlate->SetScreenInfo(camAtof((TCHAR*) Angle) , camAtof((TCHAR*) Frequency));
02482 
02483                 pPlate = pTypesetInfo->GetNextPlate(pPlate);
02484             }
02485         }
02486     }
02487     else
02488     {
02489         ERROR3("Failed to find list gadget");
02490     }
02491 #endif
02492 }
02493 
02494 
02495 
02496 /******************************************************************************************
02497 
02498 >   BOOL PrintSepsTab::InitSection()
02499 
02500     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com> - adapted from Markn's stuff
02501     Created:    12/6/96
02502     Inputs:     -
02503     Outputs:    -
02504     Returns:    TRUE if successful, else FALSE
02505     Purpose:    Sets initial values for the print separations section of the options dialog box.
02506                 This section includes the:-
02507     Errors:     -
02508     SeeAlso:    AppPrefsDlg; OptionsTabs;
02509 
02510 ******************************************************************************************/
02511 
02512 BOOL PrintSepsTab::InitSection()
02513 {
02514     if (PrintBaseTab::InitSection())
02515     {
02516         TalkToPage();
02517         // First retrieve the custom list control object and set the column widths
02518 PORTNOTE("other", "Disabled CCustomList")
02519 #ifndef EXCLUDE_FROM_XARALX
02520         CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_LISTCOLOURS));
02521         ERROR2IF(!pListGadget, FALSE, "No list gadget");
02522         pListGadget->SetColumnWidth(0, GetSystemMetrics(SM_CXMENUCHECK) + 4); // Check 1
02523         pListGadget->SetColumnWidth(1, GetSystemMetrics(SM_CXMENUCHECK) + 5); // Check 2
02524         pListGadget->SetColumnWidth(2, 17); // Colour bitmaps
02525         pListGadget->SetColumnWidth(3, 90); // text 1
02526         pListGadget->SetColumnWidth(4, 50); // text 2
02527 
02528         BOOL ok = pListGadget->CreateCustomHeader(_R(IDB_HEADER));
02529         ERROR3IF(!ok, "Cannot create listview header");
02530 
02531         // Remember the current "print spots as process" setting so we can undo it on a cancel
02532         OldPrintSpotsAsProcess = IndexedColour::AreSpotsForcedToProcess();
02533 
02534         BOOL Result = UpdateSection(OptionsTabs::GetDocumentName());        // Update section just fills everything in from scratch
02535 
02536         if (!IsAllGreyed() && pDocument != NULL)
02537             pListGadget->SetSelectedItemIndex(0);
02538 
02539         return(Result);
02540 #endif
02541     }
02542 
02543     return FALSE;
02544 }
02545 
02546 
02547 /******************************************************************************************
02548 
02549 >   BOOL PrintSepsTab::GreySection()
02550 
02551     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>/Adrian
02552     Created:    20/8/96
02553     Inputs:     -
02554     Outputs:    -
02555     Returns:    TRUE if successful, else FALSE
02556     Purpose:    Called when the user has closed all documents. Gives any tabbed dialog a
02557                 chance to grey any fields which are document specific.
02558     Errors:     -
02559     SeeAlso:    PrintSepsTab::UngreySection(); PrintSepsTab::UpdateSection();
02560 
02561 ******************************************************************************************/
02562 
02563 BOOL PrintSepsTab::GreySection()
02564 {
02565     if (TalkToPage())
02566     {
02567 PORTNOTE("other", "Disabled CCustomList")
02568 #ifndef EXCLUDE_FROM_XARALX
02569         // Delete the contents of the list
02570         CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_LISTCOLOURS));
02571         if (pListGadget != NULL)
02572                 pListGadget->DeleteAllItems();      
02573 #endif
02574         // Destroy the plate list to avoid all kinds of problems that might arise if it contained spot plates 
02575         TypesetInfo *pTypesetInfo = LocalPrintControl.GetTypesetInfo();
02576         ERROR2IF(pTypesetInfo == NULL, TRUE, "Can't find typesetting info structure");
02577 
02578         pTypesetInfo->DestroyPlateList();
02579 
02580         // Grey out all controls
02581         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PRINTERDEFAULTS), FALSE);
02582         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CUSTOMSETTINGS), FALSE);
02583         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKSEPARATIONS), FALSE);
02584         pPrefsDlg->DeleteAllValues(_R(IDC_COMBORESOLUTION));
02585         pPrefsDlg->DeleteAllValues(_R(IDC_COMBOFREQUENCY));
02586         pPrefsDlg->DeleteAllValues(_R(IDC_COMBOTYPE));
02587         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKPROCESS), FALSE);
02588         EnableControl((CGadgetID) _R(IDC_PRINT_DOCNAMETEXT), FALSE);
02589         EnableControl((CGadgetID) _R(IDC_PRINT_DOCNAME), FALSE);
02590         EnableControl((CGadgetID) _R(IDC_SSTATIC1), FALSE);
02591         EnableControl((CGadgetID) _R(IDC_SSTATIC2), FALSE);
02592         EnableControl((CGadgetID) _R(IDC_SSTATIC3), FALSE);
02593         EnableControl((CGadgetID) _R(IDC_SSTATIC4), FALSE);
02594         EnableControl((CGadgetID) _R(IDC_SSTATIC5), FALSE);
02595         EnableControl((CGadgetID) _R(IDC_SSTATIC6), FALSE);
02596     }
02597     return(PrintBaseTab::GreySection());
02598 }
02599 
02600 
02601 
02602 /******************************************************************************************
02603 
02604 >   BOOL PrintSepsTab::UngreySection()
02605 
02606     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>/Adrian
02607     Created:    20/8/96
02608     Inputs:     -
02609     Outputs:    -
02610     Returns:    TRUE if successful, else FALSE
02611     Purpose:    Called when the user has opened a document. Gives any tabbed dialog a
02612                 chance to update any fields which may have been greyed when the last
02613                 document was closed.
02614     Errors:     -
02615     SeeAlso:     PrintSepsTab::GreySection(); PrintSepsTab::UpdateSection();
02616 
02617 ******************************************************************************************/
02618 
02619 BOOL PrintSepsTab::UngreySection()
02620 {
02621     if (TalkToPage())
02622     {
02623         // Switch to the new document print control  and update the tab
02624         if (pDocument)
02625             UpdateSection(OptionsTabs::GetDocumentName());  
02626 
02627         EnableControl((CGadgetID) _R(IDC_PRINT_DOCNAMETEXT), TRUE);
02628         EnableControl((CGadgetID) _R(IDC_PRINT_DOCNAME), TRUE);
02629         EnableControl((CGadgetID) _R(IDC_SSTATIC1), TRUE);
02630         EnableControl((CGadgetID) _R(IDC_SSTATIC2), TRUE);
02631         EnableControl((CGadgetID) _R(IDC_SSTATIC3), TRUE);
02632         EnableControl((CGadgetID) _R(IDC_SSTATIC4), TRUE);
02633         EnableControl((CGadgetID) _R(IDC_SSTATIC5), TRUE);
02634         EnableControl((CGadgetID) _R(IDC_SSTATIC6), TRUE);
02635     }
02636     return PrintBaseTab::UngreySection();
02637 }
02638 
02639 
02640 
02641 /******************************************************************************************
02642 
02643 >   BOOL PrintSepsTab::UpdateSection(String_256 *DocumentName)
02644 
02645     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
02646     Created:    20/8/96
02647     Inputs:     Name of document 
02648     Outputs:    -
02649     Returns:    TRUE if successful, else FALSE
02650     Purpose:    Called when the user has clicked on a new document or opened a new document.
02651                 Gives any tabbed dialog a chance to update any fields which are used to
02652                 reflect the current document's status.
02653                 The document name allows the info field on the tab to be filled in correctly.
02654     Errors:     -
02655     SeeAlso:    PrintSepsTab::UngreySection(); PrintSepsTab::GreySection();
02656 
02657 ******************************************************************************************/
02658 
02659 BOOL PrintSepsTab::UpdateSection(String_256 *DocumentName)
02660 {
02661     // Copy all the new document's details into our local print control
02662     CopyLocalPrintControlFromDoc();
02663 
02664     BOOL ok = TalkToPage();
02665     if (!ok)
02666         return(FALSE);
02667 
02668     // Set the new document name
02669     pPrefsDlg->SetStringGadgetValue(_R(IDC_PRINT_DOCNAME), *DocumentName);
02670 
02671     // And show the new details
02672     ShowDetails(NULL, 0);
02673     
02674     return TRUE;
02675 }
02676 
02677 
02678 
02679 /******************************************************************************************
02680 
02681 >   BOOL PrintSepsTab::ShowDetails()
02682 
02683     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
02684     Created:    12/6/96
02685     Inputs:     pGadgetIDList = ptr to gadgets to show details in (NULL means all gadgets)
02686     Outputs:    -
02687     Returns:    TRUE if successful, else FALSE
02688     Purpose:    Sets values for the print layout section of the options dialog box.
02689     Errors:     -
02690     SeeAlso:    AppPrefsDlg; OptionsTabs; ShowDetails(CGadgetID* pGadgetIDList,CGadgetID Exclude)
02691 
02692 ******************************************************************************************/
02693 
02694 BOOL PrintSepsTab::ShowDetails()
02695 {
02696     return ShowDetails(NULL,0);
02697 }
02698 
02699 
02700 
02701 /******************************************************************************************
02702 
02703 >   BOOL PrintSepsTab::ShowDetails(CGadgetID* pGadgetIDList,CGadgetID Exclude)
02704 
02705     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com> - adapted from Markn's stuff
02706     Created:    12/6/96
02707     Inputs:     pGadgetIDList   = ptr to gadgets to show details in (NULL means all gadgets)
02708                 Exclude         = gadget to exclude in list
02709     Outputs:    -
02710     Returns:    TRUE if successful, else FALSE
02711     Purpose:    Sets values for the print seps section of the options dialog box.
02712     Errors:     -
02713     SeeAlso:    AppPrefsDlg; OptionsTabs;
02714 
02715 ******************************************************************************************/
02716 
02717 BOOL PrintSepsTab::ShowDetails(CGadgetID* pGadgetIDList, CGadgetID Exclude)
02718 {
02719     // For now, just rebuild the entire tab
02720     BOOL ok = TalkToPage();
02721     if (!ok)
02722         return(FALSE);
02723 
02724     if (IsAllGreyed() || pDocument == NULL) // Don't try to fill in anything when the window is shaded
02725     {
02726 PORTNOTE("other", "Disabled CCustomList")
02727 #ifndef EXCLUDE_FROM_XARALX
02728         CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_LISTCOLOURS));
02729         if (pListGadget != NULL)
02730             pListGadget->DeleteAllItems();
02731 #endif
02732         EnableControls();
02733         return(TRUE);
02734     }
02735 
02736     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintSepsTab::InitSection called with no dialog pointer");
02737 
02738     TypesetInfo* tpInfo = LocalPrintControl.GetTypesetInfo();
02739     ERROR2IF(tpInfo == NULL,FALSE,"Error in PrintSepsTab::InitSection() : unexpected null pointer");
02740 
02741     // Now set up the controls
02742     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_PRINTERDEFAULTS), !tpInfo->AreScreening());
02743     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CUSTOMSETTINGS), tpInfo->AreScreening());
02744 
02745 
02746     // Set up the printer resolution list (just a default value at this stage)
02747     static INT32 Resolution[] = 
02748     {
02749         300,
02750         600,
02751         635,
02752         1200,
02753         1270,
02754         1693,
02755         2400,
02756         2540,
02757         0       // NULL terminator
02758     };
02759 
02760     pPrefsDlg->DeleteAllValues(_R(IDC_COMBORESOLUTION));
02761     String_256 Temp;
02762     INT32 i = 0;
02763     INT32 Selected = -1;
02764     while (Resolution[i] != 0)
02765     {
02766         if (Resolution[i] == tpInfo->GetPrintResolution())
02767             Selected = i;
02768 
02769         Temp._MakeMsg(TEXT("#1%ld"), Resolution[i]);
02770         pPrefsDlg->SetStringGadgetValue(_R(IDC_COMBORESOLUTION), Temp, FALSE, i);
02771         i++;
02772     }
02773 // As usual, this call causes dreadful gadget flicker
02774 //  pPrefsDlg->SetComboListLength(_R(IDC_COMBORESOLUTION));
02775 
02776     if (Selected >= 0)
02777         pPrefsDlg->SetSelectedValueIndex(_R(IDC_COMBORESOLUTION), Selected);
02778     else
02779     {
02780         Temp._MakeMsg(TEXT("#1%ld"), tpInfo->GetPrintResolution());
02781         pPrefsDlg->SetStringGadgetValue(_R(IDC_COMBORESOLUTION),Temp, FALSE, -1);
02782     }
02783 
02784     //Set up the screen frequency list (just a default value at this stage)  
02785     static INT32 Frequency[] =
02786     {
02787         60,
02788         70,
02789         80,
02790         90,
02791         100,
02792         110,
02793         120,
02794         130,
02795         140,
02796         150,
02797         0
02798     };
02799 
02800     pPrefsDlg->DeleteAllValues(_R(IDC_COMBOFREQUENCY));
02801     i = 0;
02802     Selected = -1;
02803     while (Frequency[i] != 0)
02804     {
02805         if ((double)Frequency[i] == tpInfo->GetDefaultScreenFrequency())
02806             Selected = i;
02807 
02808         Temp._MakeMsg(TEXT("#1%ld"), Frequency[i]);
02809         pPrefsDlg->SetStringGadgetValue(_R(IDC_COMBOFREQUENCY), Temp, FALSE, i);
02810         i++;
02811     }
02812 // As usual, this call causes dreadful gadget flicker
02813 //  pPrefsDlg->SetComboListLength(_R(IDC_COMBOFREQUENCY));
02814 
02815     if (Selected >= 0)
02816         pPrefsDlg->SetSelectedValueIndex(_R(IDC_COMBOFREQUENCY), Selected);
02817     else
02818     {
02819         // Put in the user custom value, with as few decimal places as we can get away with
02820 //      ConvertDoubleToMinString(tpInfo->GetDefaultScreenFrequency(), &Temp);
02821         INT32 IntFreq = (INT32) floor(tpInfo->GetDefaultScreenFrequency());
02822         Temp._MakeMsg(TEXT("#1%d"), IntFreq);
02823         pPrefsDlg->SetStringGadgetValue(_R(IDC_COMBOFREQUENCY), Temp, FALSE, -1);
02824     }
02825 
02826     //Set up the screen types list
02827     pPrefsDlg->DeleteAllValues(_R(IDC_COMBOTYPE));
02828 
02829     for (i = 0; ScreenIDs[i]; i++)
02830     {
02831         String_256 screenType(ScreenIDs[i]);
02832         pPrefsDlg->SetStringGadgetValue(_R(IDC_COMBOTYPE), screenType, FALSE, i);
02833     }
02834 
02835     pPrefsDlg->SetSelectedValueIndex(_R(IDC_COMBOTYPE), ((INT32)tpInfo->GetScreenFunction()) - 1);
02836 
02837     // Set the "Print colour separations" checkbox
02838     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKSEPARATIONS), tpInfo->AreSeparating());
02839 
02840     // Set up the separations list box
02841 PORTNOTE("other", "Disabled CCustomList")
02842 #ifndef EXCLUDE_FROM_XARALX
02843     CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_LISTCOLOURS));
02844     ERROR2IF(pListGadget == NULL, FALSE, "No list gadget?!");
02845 
02846     // Remember the selected item so we can restore it after rebuilding the list
02847     INT32 SelectedItem = pListGadget->GetSelectedItemIndex();
02848     if (SelectedItem < 0)
02849         SelectedItem = 0;
02850 
02851     // Clear the gadget out and rebuild it for the (new) plate list
02852     pListGadget->DeleteAllItems();
02853 #endif
02854 
02855     // Set the "print spot colours as process colours" flag appropriately
02856     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKPROCESS), IndexedColour::AreSpotsForcedToProcess());
02857 
02858     // Call CreatePlateList to ensure that the list of printing plates is set up
02859     // This will just update the list (if necessary) if it has been previously created
02860     ok = tpInfo->CreatePlateList();
02861     ERROR2IF(!ok, FALSE, "Unable to create plate list");
02862 
02863     ColourPlate* pPlate;
02864     pPlate = tpInfo->GetFirstPlate();
02865     ERROR2IF(pPlate == NULL, FALSE, "PrintSepsTab::Init() : unable to get first plate");
02866 
02867     // First we loop through the plates just to have a look at their angle values so that we know how
02868     // to format them in the second loop
02869     INT32 AnglePrecision = 1;
02870     INT32 FreqPrecision = 1;
02871     for (i = 0 ; i < (INT32) tpInfo->GetNumPlates(); i++)
02872     {
02873         if (pPlate)
02874         {
02875             // For each plate, see how many decimal places it needs to display
02876             INT32 MinPrecision = ConvertDoubleToMinString(pPlate->GetScreenAngle(), &Temp);
02877             if (MinPrecision > AnglePrecision)
02878                 AnglePrecision = MinPrecision;
02879 
02880             MinPrecision = ConvertDoubleToMinString(pPlate->GetScreenFrequency(), &Temp);
02881             if (MinPrecision > FreqPrecision)
02882                 FreqPrecision = MinPrecision;
02883 
02884             pPlate = tpInfo->GetNextPlate(pPlate);
02885         }
02886     }
02887 
02888     // Second loop, this time round we fill in the plate list
02889     pPlate = tpInfo->GetFirstPlate();
02890     for (i = 0 ; i < (INT32) tpInfo->GetNumPlates(); i++)
02891     {
02892         if (pPlate)
02893         {
02894             String_256 plateDescription;
02895             pPlate->GetDescription(&plateDescription);
02896 
02897             double Angle = pPlate->GetScreenAngle();
02898             double Frequency = pPlate->GetScreenFrequency();
02899             ERROR3IF(Angle < 0.0 || Angle >= 360.0, "Colour plate returns an illegal screen angle");
02900             ERROR3IF(Frequency < 1.0 || Frequency > 1000.0, "Colour plate returns an illegal screen frequency");
02901 
02902 
02903             String_256 plateAngle;
02904             String_256 plateFrequency;
02905 
02906 //          plateAngle.MakeMsg(_R(IDS_DEGREES), Angle);
02907 //          String_256 DegreeFormat(_R(IDS_DEGREES));           
02908             //_stprintf((TCHAR *)plateAngle, (TCHAR *)DegreeFormat, Angle);
02909 //          _stprintf((TCHAR *)plateAngle,"%.*f", precision,  Angle);
02910             Convert::DoubleToString(Angle, (StringBase *) &plateAngle, AnglePrecision);
02911             plateAngle += TEXT("");     // Let's give the internationalisation boys a heart attack
02912 
02913 //          plateFrequency.MakeMsg(_R(IDS_LPI_FLOAT), Frequency);           
02914 //          String_256 FreqFormat(_R(IDS_LPI_FLOAT));
02915 //          _stprintf((TCHAR *)plateFrequency, (TCHAR *)FreqFormat, Frequency);
02916             Convert::DoubleToString(Frequency, (StringBase *) &plateFrequency, FreqPrecision);
02917 
02918             // Draw the colour patch, converting to screen RGB with the selected view's
02919             // colour context, so that we use the same colour correction options as that view
02920             ColourContext *cc = ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
02921 
02922             DocColour PlateCol;
02923             pPlate->GetDisplayColour(&PlateCol);
02924 
02925             PColourRGBT RGB;
02926             cc->ConvertColour(&PlateCol, (ColourPacked *) &RGB);
02927 
02928 PORTNOTE("other", "Disabled CCustomList")
02929 #ifndef EXCLUDE_FROM_XARALX
02930             ok = pListGadget->AddColourListItem(plateDescription, RGB.Red, RGB.Green, RGB.Blue,
02931                                                 pPlate->GetType() == COLOURPLATE_SPOT);
02932             ERROR3IF(!ok, "Failed to add item to list");
02933 
02934             // Add the text columns
02935             ok = pListGadget->SetItemString(plateAngle, i, 4);
02936             ERROR3IF(!ok, "Failed to set listview string");
02937 
02938             ok = pListGadget->SetItemString(plateFrequency, i, 5);
02939             ERROR3IF(!ok, "Failed to set listview string");
02940 
02941             pListGadget->SetSwitchState(!pPlate->IsDisabled(), i, 0);
02942             pListGadget->SetSwitchState(pPlate->Overprints(), i, 1);
02943 #endif
02944             pPlate = tpInfo->GetNextPlate(pPlate);
02945         }
02946         else
02947             ERROR3("Fewer printing plates were found than expected");
02948 
02949     }
02950 
02951     // Shade/unshade the controls as appropriate
02952     EnableControls();
02953 
02954 PORTNOTE("other", "Disabled CCustomList")
02955 #ifndef EXCLUDE_FROM_XARALX
02956     // And re-select the previously selected (or first) item in the plate list
02957     pListGadget->SetSelectedItemIndex(SelectedItem);
02958 #endif
02959 
02960     return TRUE;
02961 }
02962 
02963 
02964 
02965 /******************************************************************************************
02966 
02967 >   BOOL PrintSepsTab::EnableControls()
02968 
02969     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>/Jason
02970     Created:    12/6/96
02971     Inputs:     -
02972     Outputs:    -
02973     Returns:    TRUE if all went well
02974     Purpose:    Enables and disables the controls on the tab as appropriate for the 
02975                 current settings
02976     Errors:     -
02977     SeeAlso:    -
02978 
02979 ******************************************************************************************/
02980 
02981 BOOL PrintSepsTab::EnableControls()
02982 {
02983     if (pPrefsDlg == NULL)
02984         return TRUE;
02985 
02986     if (!TalkToPage())
02987         return(FALSE);
02988 
02989     // If there is no XaraCMS colour manager, we simply can't do colour separations
02990     if (GetApplication()->GetCMSManager() == NULL)
02991         EnableControl(_R(IDC_CHECKSEPARATIONS), FALSE);
02992 
02993     TypesetInfo* tpInfo = NULL;
02994     if (!IsAllGreyed() && pDocument != NULL)
02995         tpInfo = LocalPrintControl.GetTypesetInfo();
02996 
02997     // Enable/Disable the postscript/screening options as appropriate
02998     BOOL Enabled = (tpInfo == NULL) ? FALSE : tpInfo->AreScreening();
02999     EnableControl(_R(IDC_COMBORESOLUTION),  Enabled);
03000     EnableControl(_R(IDC_COMBOFREQUENCY),   Enabled);
03001     EnableControl(_R(IDC_COMBOTYPE),        Enabled);
03002 
03003 
03004     // Enable/Disable the separation plate options depending on whether we're doing separations
03005     Enabled = (tpInfo != NULL && tpInfo->AreSeparating() && !IsAllGreyed() && pDocument != NULL);
03006     EnableControl(_R(IDC_LISTCOLOURS),      Enabled);
03007     EnableControl(_R(IDC_PLATEPROPS),       Enabled);
03008 
03009     Enabled = (!IsAllGreyed() && pDocument != NULL);
03010     EnableControl(_R(IDC_PRINTERDEFAULTS),  Enabled);
03011 
03012     EnableControl(_R(IDC_CHECKPROCESS),     Enabled);
03013 
03014     EnableControl(_R(IDC_CUSTOMSETTINGS),   Enabled);
03015     EnableControl(_R(IDC_CHECKSEPARATIONS), Enabled);
03016 
03017     return TRUE;
03018 }
03019 
03020 
03021 
03022 /*********************************************************************************************
03023 
03024   > PrintSepsTab::GetSelectedPlate() 
03025 
03026     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>/Jason
03027     Created:    12/6/96
03028     Inputs:     -
03029     Outputs:    -
03030     Returns:    - a pointer to the colour plate currently selected in the list box (NULL if none)
03031     Purpose:    used to invoke the Properties popup with the curently selected plate
03032     Errors:     -
03033     SeeAlso:    - class SepsDlg
03034 
03035 ********************************************************************************************/
03036 
03037 ColourPlate* PrintSepsTab::GetSelectedPlate()
03038 {
03039     if (IsAllGreyed() || pDocument == NULL)
03040         return(NULL);
03041 
03042     ERROR2IF(pPrefsDlg == NULL,FALSE,"Error in PrintSepsTab::GetSelectedPlate() : unexpected null pointer");
03043 
03044 PORTNOTE("other", "Disabled CCustomList")
03045 #ifndef EXCLUDE_FROM_XARALX
03046     ColourPlate* pPlate = NULL;
03047 
03048     CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_LISTCOLOURS));
03049     if (pListGadget)
03050     {
03051         INT32 index = pListGadget->GetSelectedItemIndex(); 
03052         if (index != -1)
03053         {
03054             TypesetInfo* tpInfo = LocalPrintControl.GetTypesetInfo();
03055             if (tpInfo)
03056             {
03057                 tpInfo->CreatePlateList();
03058 
03059                 pPlate = tpInfo->GetFirstPlate();
03060                 for (INT32 i = 0; i < index && pPlate != NULL; i++)
03061                     pPlate = tpInfo->GetNextPlate(pPlate);
03062             }
03063             return pPlate;
03064         }
03065     }
03066     else
03067         ERROR3("Cannot find list gadget");
03068 #endif
03069 
03070     return(NULL); // return NULL if no plate is selected
03071 }
03072 
03073 /************************************************************************************************
03074 *************************************************************************************************
03075 ********************                END CLASS PrintSepsTab     **********************************
03076 *************************************************************************************************
03077 ************************************************************************************************/
03078 
03079 
03080 
03081 
03082 
03083 
03084 /************************************************************************************************
03085 *************************************************************************************************
03086 ***************************               CLASS SepsDlg                ********************************
03087 ***************************               Adrian  17/06/96                 ********************************
03088 *************************************************************************************************
03089 ************************************************************************************************/
03090 
03091 
03092 
03093 const INT32 SepsDlg::IDD = _R(IDD_PLATEPROPS);
03094 const CDlgMode SepsDlg::Mode = MODAL;
03095 
03096 
03097 /*********************************************************************************************
03098   > SepsDlg::SepsDlg() 
03099 
03100 
03101     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03102     Created:    15/6/96
03103     Inputs:     -
03104     Outputs:    -
03105     Returns:    - 
03106     Purpose:    default constructor
03107     Errors:     -
03108     SeeAlso:    - class SepsDlg
03109 ********************************************************************************************/
03110 
03111 SepsDlg::SepsDlg() : DialogOp(IDD, Mode)
03112 {
03113     pColourPlate = NULL;
03114     pLocalColourPlate = NULL;
03115     pParam = NULL;
03116 }
03117 
03118 /*********************************************************************************************
03119   > SepsDlg::Create() 
03120 
03121 
03122     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03123     Created:    15/6/96
03124     Inputs:     -
03125     Outputs:    -
03126     Returns:    - DialogOp::Create() for now
03127     Purpose:    local version of DialogOp::Create()
03128     Errors:     -
03129     SeeAlso:    - class SepsDlg
03130 ********************************************************************************************/
03131 
03132 
03133 BOOL SepsDlg::Create()
03134 {
03135     return DialogOp::Create();
03136 }
03137 
03138 
03139 
03140 /*********************************************************************************************
03141 
03142 >   void SepsDlg::InitControls(void)
03143 
03144     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03145     Created:    19/8/96
03146 
03147     Purpose:    (Re-)Initialises all controls in the seps dialogue tab
03148 
03149 ********************************************************************************************/
03150 
03151 void SepsDlg::InitControls(void)
03152 {
03153     String_256 Temp;
03154     pColourPlate->GetDescription(&Temp);
03155 
03156     String_256 plateDescr;
03157     plateDescr.MakeMsg(_R(IDS_SEPPROPERTIES), (TCHAR *) Temp);
03158 
03159     SetStringGadgetValue(_R(IDC_PLATECAPTION), plateDescr);
03160 
03161     //Screen frequency  
03162     String_256 frequency;
03163     camSprintf((TCHAR*) frequency, _T("%1.4f"), double(pColourPlate->GetScreenFrequency()));
03164     SetStringGadgetValue(_R(IDC_EDITFREQUENCY), frequency, TRUE);
03165 
03166     //Screen angle  
03167     String_256 angle;
03168     camSprintf((TCHAR*) angle, _T("%1.4f"), double(pColourPlate->GetScreenAngle()));
03169     SetStringGadgetValue(_R(IDC_EDITANGLE), angle, TRUE);
03170 
03171     //'Print this ink' checkbox
03172     SetBoolGadgetSelected(_R(IDC_CHECKPRINT), !pColourPlate->IsDisabled());
03173 
03174     //'Overprint' checkbox
03175     SetBoolGadgetSelected(_R(IDC_CHECKOVERPRINT), pColourPlate->Overprints());
03176 }
03177 
03178 
03179 
03180 /*********************************************************************************************
03181   > SepsDlg::Message(Msg* Message) 
03182 
03183 
03184     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03185     Created:    15/6/96
03186     Inputs:     - pointer to a Msg object
03187     Outputs:    -
03188     Returns:    - 
03189     Purpose:    main message handler, will call HandleMessage if message is for the dialog box,
03190                 otherwise forward to base class
03191     Errors:     -
03192     SeeAlso:    - class SepsDlg
03193 ********************************************************************************************/
03194 
03195 
03196 MsgResult SepsDlg::Message(Msg* Message)
03197 {
03198     if (IS_OUR_DIALOG_MSG(Message))
03199         return HandleMessage((DialogMsg*) Message);
03200 
03201     return DialogOp::Message(Message);
03202 }
03203 
03204 
03205 
03206 /*********************************************************************************************
03207   > SepsDlg::HandleMessage(DialogMessage* Msg) 
03208 
03209 
03210     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03211     Created:    15/6/96
03212     Inputs:     - pointer to a DialogMessage object
03213     Outputs:    -
03214     Returns:    - MsgResult::OK for now 
03215     Purpose:    local message handler
03216     Errors:     -
03217     SeeAlso:    - class SepsDlg
03218 ********************************************************************************************/
03219 
03220 MsgResult SepsDlg::HandleMessage(DialogMsg* Msg)
03221 {
03222     ERROR2IF(pColourPlate == NULL,FAIL,"Error in SepsDlg::HandleMessage() : unexpected null pointer");  
03223     ERROR2IF(pLocalColourPlate == NULL,FAIL,"Error in SepsDlg::HandleMessage() : unexpected null pointer");
03224     switch (Msg->DlgMsg)
03225     {
03226         case DIM_CREATE:
03227             //Display the current settings data for our colour plate 
03228             InitControls();
03229             break;
03230 
03231         case DIM_COMMIT:        // OK button clicked
03232             {
03233                 BOOL angleIsValid = FALSE;
03234                 BOOL frequencyIsValid = FALSE;
03235                 double angle = GetDoubleGadgetValue(_R(IDC_EDITANGLE), 0, 360, _R(IDS_INVALID_ANGLE), &angleIsValid); 
03236                 double frequency = GetDoubleGadgetValue(_R(IDC_EDITFREQUENCY), 1, 1000, _R(IDS_INVALID_FREQUENCY), &frequencyIsValid); 
03237                 if (angleIsValid && frequencyIsValid)
03238                 {
03239                     pColourPlate->SetOverprint(pLocalColourPlate->Overprints());
03240                     pColourPlate->SetScreenInfo(angle, frequency);
03241                     pColourPlate->SetDisabled(pLocalColourPlate->IsDisabled());
03242 
03243                     if (fabs(pLocalColourPlate->GetScreenAngle() - pColourPlate->GetScreenAngle()) > 0.0001)
03244                         pParam->Result = TRUE;
03245                     else if (fabs(pLocalColourPlate->GetScreenFrequency() - pColourPlate->GetScreenFrequency()) > 0.0001)
03246                         pParam->Result = TRUE;
03247 
03248                     Close();
03249                     End();
03250                     return OK;
03251                 }
03252             }
03253             break;
03254 
03255         case DIM_CANCEL:        // Cancel button clicked
03256             {
03257                 Close();
03258                 End();
03259                 return OK;      // After End, we mustn't call base class, as this object may have been deleted
03260             }
03261             break;
03262 
03263         case DIM_LFT_BN_CLICKED: // Left button pressed
03264             {
03265                 if (Msg->GadgetID == _R(IDC_CHECKPRINT))
03266                     pLocalColourPlate->SetDisabled(!GetBoolGadgetSelected(_R(IDC_CHECKPRINT)));
03267                 else if (Msg->GadgetID == _R(IDC_CHECKOVERPRINT))
03268                     pLocalColourPlate->SetOverprint(GetBoolGadgetSelected(_R(IDC_CHECKOVERPRINT)));
03269             }
03270         default:
03271             break;
03272 
03273     }
03274     // Always call the base class, or things like help buttons won't work
03275     return DialogOp::Message(Msg);
03276 }
03277 
03278 
03279 
03280 /*********************************************************************************************
03281   > SepsDlg::~SepsDlg() 
03282 
03283 
03284     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03285     Created:    15/6/96
03286     Inputs:     -
03287     Outputs:    -
03288     Returns:    - 
03289     Purpose:    destructor
03290     Errors:     -
03291     SeeAlso:    - class SepsDlg
03292 ********************************************************************************************/
03293 
03294 SepsDlg::~SepsDlg()
03295 {
03296     delete pLocalColourPlate;
03297 }
03298 
03299 
03300 void SepsDlg::Do(OpDescriptor*)
03301 {
03302     ERROR3("Don't call SepsDlg::Do - use DoWithParam");
03303     End();
03304 }
03305 
03306 
03307 void SepsDlg::DoWithParam(OpDescriptor*, OpParam *Param)
03308 {
03309     ERROR3IF(Param == NULL, "Illegal NULL param");
03310     if (!Param)
03311         return;
03312 
03313     pParam = (SepsDlgParam *) Param;
03314     ERROR3IF(pParam->pColourPlate == NULL, "Illegal NULL param");
03315     if (!pParam->pColourPlate)
03316         return;
03317 
03318     pColourPlate = pParam->pColourPlate;
03319     pLocalColourPlate = new ColourPlate(*pColourPlate);
03320     ERROR3IF(pLocalColourPlate == NULL,"Error in SepsDlg::DoWithParam() : allocation failure"); 
03321     if (!pLocalColourPlate)
03322         return;
03323 
03324     pParent = pParam->pParent;
03325 
03326     pParam->Result = FALSE;     // Set up a reasonable default return value
03327 
03328     if (!Create())
03329     {
03330         InformError();
03331         End();
03332     }
03333 }
03334 
03335 
03336 BOOL SepsDlg::Init(void)
03337 {
03338     return RegisterOpDescriptor(    0,
03339                                     _R(IDS_SEPSDIALOG),
03340                                     CC_RUNTIME_CLASS(SepsDlg),
03341                                     OPTOKEN_SEPSDIALOG,
03342                                     SepsDlg::GetState,
03343                                     0,                          // help ID 
03344                                     0           // bubble help
03345                                 );
03346 
03347 }
03348 
03349 
03350 
03351 OpState SepsDlg::GetState(String_256*, OpDescriptor*)
03352 {
03353     OpState State;
03354 
03355     return(State);
03356 }
03357 
03358 /*********************************************************************************************
03359 
03360   > BOOL SepsDlg::InvokeDialog(ColourPlate *pTheColourPlate, PrintBaseTab* pParentDialog) 
03361 
03362     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03363     Created:    15/6/96
03364     Inputs:     - pointer to the colour plate we're setting, pointer to the Separations dialog tab
03365     Outputs:    -
03366     Returns:    TRUE if the colour plate angle or frequency values were changed
03367     Purpose:    display the dialog
03368     Errors:     -
03369     SeeAlso:    - class SepsDlg
03370 ********************************************************************************************/
03371 
03372 BOOL SepsDlg::InvokeDialog(ColourPlate *pTheColourPlate, PrintBaseTab* pParentDialog)
03373 {
03374     ERROR3IF(pTheColourPlate == NULL, "Come on, play by the rules");
03375     ERROR3IF(pParentDialog == NULL, "Come on, play by the rules!!!");
03376 
03377     OpDescriptor *TheDlg = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(SepsDlg));
03378 
03379     ERROR3IF(TheDlg == NULL, "SepsDlg::InvokeDialog is unable to find the Dlg OpDescriptor");
03380 
03381     if (TheDlg != NULL)
03382     {
03383         SepsDlgParam Param;
03384         Param.pColourPlate = pTheColourPlate;
03385         Param.pParent = pParentDialog;
03386         Param.Result = FALSE;
03387 
03388         TheDlg->Invoke(&Param);
03389         return(Param.Result);
03390     }
03391 
03392     return(FALSE);
03393 }
03394 
03395 
03396 /************************************************************************************************
03397 *************************************************************************************************
03398 ********************                END CLASS SepsDlg     **********************************
03399 *************************************************************************************************
03400 ************************************************************************************************/
03401 
03402 
03403 
03404 
03405 
03406 
03407 
03408 
03409 
03410 
03411 /************************************************************************************************
03412 *************************************************************************************************
03413 ****************************** CLASS PrintImagesetterTab   ********************************
03414 **************                              Adrian  10/08/96                    ********************************
03415 *************************************************************************************************
03416 ************************************************************************************************/
03417 
03418 
03419 /********************************************************************************************
03420 *********************************************************************************************
03421 *********************************************************************************************
03422 
03423   > PrintImagesetterTab::PrintImagesetterTab() 
03424 
03425     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03426     Created:    10/08/96
03427     Inputs:     -
03428     Outputs:    -
03429     Returns:    -
03430     Purpose:    PrintImagesetterTab default constructor.
03431     Errors:     -
03432     SeeAlso:    -
03433 
03434 ********************************************************************************************/
03435 
03436 PrintImagesetterTab::PrintImagesetterTab()
03437 {
03438 }
03439 
03440 /********************************************************************************************
03441 
03442 >   PrintImagesetterTab::~PrintImagesetterTab()
03443 
03444 
03445     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03446     Created:    12/6/96
03447     Inputs:     -
03448     Outputs:    -
03449     Returns:    -
03450     Purpose:    PrintImagesetterTab destructor
03451     Errors:     -
03452     SeeAlso:    -
03453 
03454 ********************************************************************************************/
03455                                                                                 
03456 PrintImagesetterTab::~PrintImagesetterTab()
03457 { 
03458 }        
03459 
03460 CDlgResID PrintImagesetterTab::GetPageID()  { return _R(IDD_OPTSTAB_IMAGESETTING); }
03461 
03462 /********************************************************************************************
03463 
03464 >   BOOL PrintImagesetterTab::HandleMsg(DialogMsg* Msg)
03465 
03466     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03467     Created:    12/6/96
03468     Inputs:     -
03469     Outputs:    -
03470     Returns:    -
03471     Purpose:    Handles messages sent by various controls on this tab  
03472     Errors:     -
03473     SeeAlso:    -
03474 
03475 ********************************************************************************************/
03476 
03477 BOOL PrintImagesetterTab::HandleMsg(DialogMsg* Msg)
03478 {
03479     if (Msg->DlgMsg != DIM_CREATE && (IsAllGreyed() || pDocument == NULL))
03480         return(TRUE);
03481 
03482     ERROR2IF(Msg == NULL,FALSE,"PrintImagesetterTab::Message null message received");
03483     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintImagesetterTab::HandleMsg called with no dialog pointer");
03484 
03485     BOOL ok = TalkToPage(); 
03486     if (!ok)
03487         return TRUE;        // page not present
03488 
03489     switch(Msg->DlgMsg)
03490     {
03491         case DIM_LFT_BN_CLICKED:
03492             {
03493                 TypesetInfo *tpInfo = LocalPrintControl.GetTypesetInfo();
03494                 ERROR2IF(tpInfo == NULL, TRUE, "No typesetInfo?!");
03495 
03496                 if (FALSE) {}
03497                 else if (Msg->GadgetID == _R(IDC_CHECKPMARKS))
03498                 {
03499                     tpInfo->SetOutputPrintersMarks(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKPMARKS)));
03500 
03501                     // Make sure the print layout tab updates scale factors etc suitably
03502                     BROADCAST_TO_ALL(PrintMsg(PrintMsg::SETTINGSCHANGED));
03503 
03504                     // And shade/unshade the controls as appropriate
03505                     EnableControls();
03506                 }
03507                 else if (Msg->GadgetID == _R(IDC_CHECKOPBLACK))
03508                 {
03509                     tpInfo->SetOverprintBlack(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKOPBLACK)));
03510                 }
03511                 else if (Msg->GadgetID == _R(IDC_CHECKNEGATIVE))
03512                 {
03513                     tpInfo->SetPhotoNegative(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKNEGATIVE)));
03514                 }
03515                 else if (Msg->GadgetID == _R(IDC_CHECKREFLECT))
03516                 {
03517                     tpInfo->SetEmulsionDown(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKREFLECT)));
03518                 }
03519                 OptionsTabs::SetApplyNowState(TRUE);
03520             }
03521             break;
03522 
03523         case DIM_SELECTION_CHANGED:
03524         case DIM_SELECTION_CHANGED_COMMIT:
03525             // If the user has ticked a print mark, check if it's a target or star, and if it is, 
03526             // un-tick all other marks which are also of the same type.
03527             EnsureSensiblePrintMarks();
03528             break;
03529 
03530         default:
03531             return(PrintBaseTab::HandleMsg(Msg));
03532     }
03533 
03534     return TRUE;
03535 }  
03536 
03537 
03538 
03539 /******************************************************************************************
03540 
03541 >   BOOL PrintImagesetterTab::GreySection()
03542 
03543     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03544     Created:    20/8/96
03545     Inputs:     -
03546     Outputs:    -
03547     Returns:    TRUE if successful, else FALSE
03548     Purpose:    Called when the user has closed all documents. Gives any tabbed dialog a
03549                 chance to grey any fields which are document specific.
03550     Errors:     -
03551     SeeAlso:    PrintImagesetterTab::UngreySection(); PrintImagesetterTab::UpdateSection();
03552 
03553 ******************************************************************************************/
03554 
03555 BOOL PrintImagesetterTab::GreySection()
03556 {
03557     if (TalkToPage())
03558     {
03559         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKPMARKS), FALSE);
03560         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKREFLECT), FALSE);
03561         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKNEGATIVE), FALSE);
03562         pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKOPBLACK), FALSE);
03563 
03564 PORTNOTE("other", "Disabled CCustomList")
03565 #ifndef EXCLUDE_FROM_XARALX
03566         CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_PRINTERMARKSLIST));
03567         if (pListGadget != NULL)
03568             pListGadget->DeleteAllItems();
03569 #endif
03570 
03571         EnableControl((CGadgetID) _R(IDC_PRINT_DOCNAME), FALSE);
03572         EnableControl((CGadgetID) _R(IDC_ISTATIC1), FALSE);
03573         EnableControl((CGadgetID) _R(IDC_ISTATIC2), FALSE);
03574         EnableControl((CGadgetID) _R(IDC_ISTATIC3), FALSE);
03575         EnableControl((CGadgetID) _R(IDC_ISTATIC4), FALSE);
03576     }
03577     return(PrintBaseTab::GreySection());
03578 }
03579 
03580 
03581 
03582 
03583 
03584 
03585 /******************************************************************************************
03586 
03587 >   BOOL PrintImagesetterTab::UngreySection()
03588 
03589     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03590     Created:    20/8/96
03591     Inputs:     -
03592     Outputs:    -
03593     Returns:    TRUE if successful, else FALSE
03594     Purpose:    Called when a new document is open
03595     Errors:     -
03596     SeeAlso:    PrintImagesetterTab::GreySection(); PrintImagesetterTab::UpdateSection();
03597 
03598 ******************************************************************************************/
03599 
03600 BOOL PrintImagesetterTab::UngreySection()
03601 {
03602     if (TalkToPage())
03603     {
03604         EnableControl((CGadgetID) _R(IDC_PRINT_DOCNAME), TRUE);
03605         EnableControl((CGadgetID) _R(IDC_ISTATIC1), TRUE);
03606         EnableControl((CGadgetID) _R(IDC_ISTATIC2), TRUE);
03607         EnableControl((CGadgetID) _R(IDC_ISTATIC3), TRUE);
03608         EnableControl((CGadgetID) _R(IDC_ISTATIC4), TRUE);
03609     }
03610     return PrintBaseTab::UngreySection();
03611 }
03612 
03613 
03614 
03615 
03616 /********************************************************************************************
03617 
03618 >   void PrintImagesetterTab::EnsureSensiblePrintMarks(void)
03619 
03620     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03621     Created:    28/8/96
03622 
03623     Purpose:    Ensures that only one printer mark of either "target" or "star" types
03624                 is ticked in the print marks list. It assumes that the currently selected
03625                 list item is the one that you want enabled, and disables all others
03626                 of the same type - if a non-star/target type mark is selected, nothing
03627                 is done.
03628                 
03629                 This just stops the user selecting two mutually exclusive print marks
03630 
03631 ********************************************************************************************/
03632 
03633 void PrintImagesetterTab::EnsureSensiblePrintMarks(void)
03634 {
03635     if (!pDocument)
03636         return;
03637 
03638     OptionsTabs::SetApplyNowState(TRUE);
03639 
03640     INT32 SelIndex = 0;
03641 
03642 PORTNOTE("other", "Disabled CCustomList")
03643 #ifndef EXCLUDE_FROM_XARALX
03644     CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_PRINTERMARKSLIST));
03645     if (!pListGadget)
03646         return;
03647 
03648     SelIndex = pListGadget->GetSelectedItemIndex();
03649     if (SelIndex < 0)       // No selected item?!
03650         return;
03651 
03652     if (!pListGadget->GetSwitchState(SelIndex, 0))
03653         return;             // Selected Item is disabled, so no problem
03654 #endif
03655 
03656     PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
03657     if (pMarksMan == NULL)
03658         return;
03659 
03660     if (!TalkToPage())
03661         return;
03662 
03663     // Get that print marks doc component
03664     PrintMarksComponent* pMarksComp = (PrintMarksComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintMarksComponent));
03665     if (!pMarksComp)
03666         return;
03667 
03668     // Scan the print marks to see if it's a star or target mark that is currently selected
03669     PrintMarkItem* pMarkItem = pMarksMan->PMMCache.GetFirstMark();
03670     INT32 Index = 0;
03671     while (pMarkItem && Index < SelIndex)       // Scan to find the SelIndex'th item
03672     {
03673         Index++;
03674         pMarkItem = pMarksMan->PMMCache.GetNextMark(pMarkItem);
03675     }
03676 
03677     // Find the print mark for the selection if we can
03678     if (pMarkItem == NULL)
03679         return;
03680 
03681     PrintMark *ThisMark = pMarkItem->GetPrintMark();
03682     if (ThisMark == NULL)
03683         return;
03684 
03685     // See if the selected item is a star/target
03686     MarkType TypeToKill = ThisMark->GetType();
03687 
03688     if (TypeToKill != MarkType_Star && TypeToKill != MarkType_Registration)
03689         return;     // Selected item not star/target mark, so no need 
03690 
03691     // OK, the user just selected a star/target, so turn off all others of the same type...
03692     pMarkItem = pMarksMan->PMMCache.GetFirstMark();
03693     Index = 0;
03694     while (pMarkItem)
03695     {
03696         if (Index != SelIndex)
03697         {
03698             ThisMark = pMarkItem->GetPrintMark();
03699 PORTNOTE("other", "Disabled CCustomList")
03700 #ifndef EXCLUDE_FROM_XARALX
03701             if (ThisMark != NULL && ThisMark->GetType() == TypeToKill)      // Kill all other marks of this type
03702                 pListGadget->SetSwitchState(FALSE, Index, 0);
03703 #endif
03704         }
03705 
03706         pMarkItem = pMarksMan->PMMCache.GetNextMark(pMarkItem);
03707         Index++;
03708     }
03709 }
03710 
03711 
03712 
03713 /********************************************************************************************
03714 
03715 >   virtual MsgResult PrintImagesetterTab::Message(Msg *pMessage)
03716 
03717     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03718     Created:    20/8/96
03719     Inputs:     pMessage - the message
03720 
03721     Returns:    OK
03722 
03723     Purpose:    Handles miscellaneous system messages
03724                 Note that many messages (e.g. docuement/view changing) are handled by
03725                 the base dialogue, and call our UpdateSection() function. Only "left over"
03726                 messages like ColourChangingMsg are passed on to the tabs
03727 
03728 ********************************************************************************************/
03729 
03730 MsgResult PrintImagesetterTab::Message(Msg *pMessage)
03731 {
03732     if (MESSAGE_IS_A(pMessage, OptionsChangingMsg))
03733     {
03734         OptionsChangingMsg *TheMsg = (OptionsChangingMsg *) pMessage;
03735 
03736         switch ( TheMsg->State )
03737         {
03738             case OptionsChangingMsg::SEPARATIONSENABLED:
03739                 // If the colour separation enablement state has changed, then
03740                 // update our controls approrpately. This basically means shading
03741                 // or unshading the printers marks list - the output of printers
03742                 // marks (while otherwise independent is slaved off the "do separations"
03743                 // state whenever it is changed
03744                 ShowDetails();
03745                 break;
03746             default:
03747                 break;
03748         }
03749     }
03750 
03751     return(OK);
03752 }
03753 
03754 
03755 
03756 /******************************************************************************************
03757 
03758 >   BOOL PrintImagesetterTab::CommitSection()
03759 
03760     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03761     Created:    12/6/96
03762     Inputs:     -
03763     Outputs:    -
03764     Returns:    True if values in dialog box ok, False otherwise.     
03765     Purpose:    Takes the values in the Print Separations section tab of the options dialog box and
03766                 sets the associated preference values accordingly
03767                 Called when ok is pressed on the dialog box.
03768     Errors:     -
03769     SeeAlso:    -
03770 
03771 ******************************************************************************************/
03772 
03773 BOOL PrintImagesetterTab::CommitSection()
03774 {
03775     if (IsAllGreyed() || pDocument == NULL || !TalkToPage())
03776         return(PrintBaseTab::CommitSection());
03777 
03778     ERROR3IF(pPrefsDlg == NULL, "PrintImagesetterTab::CommitSection called with no dialog pointer");
03779     ERROR2IF(GetPrintControl() == NULL, FALSE, "Can't find PrintControl info");
03780 
03781     TypesetInfo* tpInfo = /*GetPrintControl()->*/LocalPrintControl.GetTypesetInfo();
03782     ERROR2IF(tpInfo == NULL,FALSE,"Error in PrintImagesetterTab::CommitSection() : unexpected null pointer");
03783 
03784 PORTNOTE("other", "Disabled CCustomList")
03785 #ifndef EXCLUDE_FROM_XARALX
03786     // Get a pointer to the print marks list
03787     CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_PRINTERMARKSLIST));
03788     if (pListGadget)
03789     { 
03790         //Read the values of the list switches and set the printer marks accordingly
03791         PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
03792         ERROR2IF(!pMarksMan, FALSE, "Print marks manager is NULL");
03793 
03794         // Set the overall printing of Printers Marks
03795         BOOL UseMarks = pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKPMARKS));
03796         tpInfo->SetOutputPrintersMarks(UseMarks);
03797         TalkToPage();   // SetOutputPrintMarks could load a new document, so do this just to be safe
03798 
03799         if (pDocument)
03800         {
03801             // Get that print marks doc component
03802             PrintMarksComponent* pMarksComp = (PrintMarksComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintMarksComponent));
03803             if (pMarksComp)
03804             {
03805                 // Trash the current mark list
03806                 pMarksComp->RemoveAllMarks();
03807 
03808                 // now go through each print mark and add it if necessary
03809                 PrintMarkItem* pMarkItem = pMarksMan->PMMCache.GetFirstMark();
03810                 INT32 index = 0;
03811                 while (pMarkItem)
03812                 {
03813                     // Get the handle of this print mark item
03814                     UINT32 handle = pMarkItem->GetHandle();
03815 
03816                     // Get the corresponding list state
03817                     if (pListGadget->GetSwitchState(index, 0))
03818                         pMarksComp->AddMark(handle);
03819 
03820                     // find the next print mark item
03821                     pMarkItem = pMarksMan->PMMCache.GetNextMark(pMarkItem);
03822                     index++;
03823                 }
03824             }
03825         }
03826     }
03827     else
03828     {
03829         ERROR3("Failed to find list gadget");
03830     }
03831 #endif
03832 
03833     // Set the general imagesetting flags
03834     tpInfo->SetOverprintBlack(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKOPBLACK)));
03835     tpInfo->SetPhotoNegative(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKNEGATIVE)));
03836     tpInfo->SetEmulsionDown(pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKREFLECT)));
03837 
03838     // Make sure the print layout tab updates scale factors etc suitably
03839 //  BROADCAST_TO_ALL(PrintMsg(PrintMsg::SETTINGSCHANGED));
03840 
03841     return(PrintBaseTab::CommitSection());
03842 }
03843 
03844 
03845 
03846 /******************************************************************************************
03847 
03848 >   BOOL PrintImagesetterTab::InitSection()
03849 
03850     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
03851     Created:    12/6/96
03852     Inputs:     -
03853     Outputs:    -
03854     Returns:    TRUE if successful, else FALSE
03855     Purpose:    Sets initial values for the print separations section of the options dialog box.
03856                 This section includes the:-
03857     Errors:     -
03858     SeeAlso:    AppPrefsDlg; OptionsTabs;
03859 
03860 ******************************************************************************************/
03861 
03862 BOOL PrintImagesetterTab::InitSection()
03863 {
03864     if (!TalkToPage())
03865         return(FALSE);
03866 
03867     if (PrintBaseTab::InitSection())
03868     {
03869         ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintImagesetterTab::InitSection called with no dialog pointer");
03870 
03871         // Set the check boxes for the general options
03872         if (!TalkToPage())
03873             return TRUE;
03874 
03875 PORTNOTE("other", "Disabled CCustomList")
03876 #ifndef EXCLUDE_FROM_XARALX
03877         // Set up the printer marks list
03878         CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_PRINTERMARKSLIST));
03879         ERROR2IF(!pListGadget, FALSE, "No list gadget");
03880         pListGadget->SetColumnWidth(0, GetSystemMetrics(SM_CXMENUCHECK) + 2); // Check box
03881         pListGadget->SetColumnWidth(1, 20); // bitmap
03882 #endif
03883 
03884         // Fill in all the controls, and enable/disable as appropriate
03885         UpdateSection(OptionsTabs::GetDocumentName());
03886         return TRUE;
03887     }
03888 
03889     return FALSE;
03890 }
03891 
03892 
03893 
03894 /********************************************************************************************
03895 
03896 >   BOOL PrintImagesetterTab::UpdateSection(String_256 *DocumentName)
03897 
03898     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>/Adrian
03899     Created:    28/8/96
03900     Inputs:     DocumentName - Name of the new document
03901     Returns:    TRUE for success
03902     Purpose:    Called when we have switched to a new document and need to update all the 
03903                 controls on this tab. Should only init the tab if the page is present.  
03904     Errors:     -
03905     SeeAlso:    PrintBaseTab::GreySection; PrintBaseTab::UngreySection; PrintBaseTab::InitSection;
03906 
03907 ********************************************************************************************/
03908 
03909 BOOL PrintImagesetterTab::UpdateSection(String_256 *DocumentName)
03910 {
03911     if (!TalkToPage())
03912         return(FALSE);
03913 
03914     // Set the docuemnt name
03915     pPrefsDlg->SetStringGadgetValue(_R(IDC_PRINT_DOCNAME), *DocumentName);
03916 
03917     // And set up all the other controls
03918     ShowDetails();
03919 
03920     return(TRUE);
03921 }
03922 
03923 
03924 
03925 /******************************************************************************************
03926 
03927 >   virtual BOOL PrintImagesetterTab::ShowDetails()
03928 
03929     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
03930     Created:    17/9/96
03931     Inputs:     -
03932     Outputs:    -
03933     Returns:    TRUE if successful, else FALSE
03934     Purpose:    Sets values for the Imagesetting section of the options dialog box.
03935     Errors:     -
03936     SeeAlso:    AppPrefsDlg; OptionsTabs;
03937 
03938 ******************************************************************************************/
03939 
03940 BOOL PrintImagesetterTab::ShowDetails()
03941 {
03942     if (IsAllGreyed() || pDocument == NULL)     // Don't try to fill in anything when the window is shaded
03943     {
03944 PORTNOTE("other", "Disabled CCustomList")
03945 #ifndef EXCLUDE_FROM_XARALX
03946         CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_PRINTERMARKSLIST));
03947         if (pListGadget != NULL)
03948             pListGadget->DeleteAllItems();
03949 #endif
03950         EnableControls();
03951         return(TRUE);
03952     }
03953 
03954     ERROR2IF(pPrefsDlg == NULL,FALSE,"PrintBaseTab::UpdateSection called with no dialog pointer");
03955 
03956     if (!TalkToPage())
03957         return(FALSE);
03958 
03959     TypesetInfo* tpInfo = LocalPrintControl.GetTypesetInfo();
03960     ERROR2IF(tpInfo == NULL,FALSE,"Error in PrintSepsTab::InitSection() : unexpected null pointer");
03961     
03962     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKREFLECT),  tpInfo->PrintEmulsionDown());
03963     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKNEGATIVE), tpInfo->PrintPhotoNegative());
03964     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKOPBLACK),  tpInfo->AlwaysOverprintBlack()); 
03965 
03966     // Set the global "output printers marks" checkbox state
03967     pPrefsDlg->SetBoolGadgetSelected(_R(IDC_CHECKPMARKS), tpInfo->OutputPrintersMarks());
03968 
03969 PORTNOTE("other", "Disabled CCustomList")
03970 #ifndef EXCLUDE_FROM_XARALX
03971     // And set up the marks list
03972     CCustomList* pListGadget = CCustomList::GetGadget(pPrefsDlg->GetReadWriteWindowID(), _R(IDC_PRINTERMARKSLIST));
03973     if (!pListGadget)
03974         return(FALSE);
03975 #endif
03976 
03977     PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
03978     ERROR3IF(pMarksMan == NULL, "No print mark manager?");
03979 
03980     // Make sure this document includes the default marks.. assume it's the selected doc!
03981     if (Document::GetSelected() != NULL)
03982         pMarksMan->AddDefaultMarksToDoc(Document::GetSelected());
03983 
03984     PrintMarkItem* pMarkItem = pMarksMan->PMMCache.GetFirstMark();
03985 
03986 PORTNOTE("other", "Disabled CCustomList")
03987 #ifndef EXCLUDE_FROM_XARALX
03988     // Vape and re-build the marks list
03989     pListGadget->DeleteAllItems();
03990 #endif
03991 
03992     while (pDocument && pMarkItem)
03993     {
03994         PrintMarksComponent* pMarksComp = (PrintMarksComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintMarksComponent));
03995         // Get the handle of this print mark item
03996         UINT32 handle = pMarkItem->GetHandle();
03997         // Get the bitmap ID for this type of mark
03998 
03999 PORTNOTE("other", "While CCustomList, mark 2 variables as used to avoid warnings")
04000         // Mark the above as used
04001         CAM_USE(pMarksComp);
04002         CAM_USE(handle);
04003 
04004         ERROR2IF(!pMarkItem->GetPrintMark(), FALSE, "Illegal NULL pointer");
04005 
04006         UINT32 ImageID = _R(IDB_PRINTMARK_UNKNOWNMK);
04007         UINT32 GreyedID = _R(IDB_PRINTMARK_UNKNOWNMK);
04008         MarkType markType = pMarkItem->GetPrintMark()->GetType();
04009         switch (markType)
04010         {
04011             case MarkType_Star:         ImageID = _R(IDB_PRINTMARK_STARMK);         GreyedID = _R(IDB_PRINTMARK_GREYED_STARMK);         break;
04012             case MarkType_Registration: ImageID = _R(IDB_PRINTMARK_REGISTRATIONMK); GreyedID = _R(IDB_PRINTMARK_GREYED_REGISTRATIONMK); break;
04013             case MarkType_Information:  ImageID = _R(IDB_PRINTMARK_INFORMATIONMK);  GreyedID = _R(IDB_PRINTMARK_GREYED_INFORMATIONMK);      break;
04014             case MarkType_Crop:         ImageID = _R(IDB_PRINTMARK_CROPMK);         GreyedID = _R(IDB_PRINTMARK_GREYED_CROPMK);         break;
04015             case MarkType_GreyBar:      ImageID = _R(IDB_PRINTMARK_GRAYBARMK);      GreyedID = _R(IDB_PRINTMARK_GRAYBARMK);         break;
04016             case MarkType_ColourBar:    ImageID = _R(IDB_PRINTMARK_COLOURBARMK);    GreyedID = _R(IDB_PRINTMARK_GREYED_COLOURBARMK);        break;
04017             default:
04018                 break;
04019         }
04020 
04021         String_256 markDescription(pMarkItem->GetPrintMark()->GetMarkMenuText());
04022 PORTNOTE("other", "Disabled CCustomList")
04023 #ifndef EXCLUDE_FROM_XARALX
04024         pListGadget->AddItem(markDescription, ImageID, GreyedID);
04025 
04026         if (pMarksComp)
04027             pListGadget->SetSwitchState(NULL != pMarksComp->FindMark(handle), (pListGadget->GetItemCount() - 1), 0);
04028 #endif
04029 
04030         // find the next print mark item
04031         pMarkItem = pMarksMan->PMMCache.GetNextMark(pMarkItem);
04032     }
04033 
04034 PORTNOTE("other", "Disabled CCustomList")
04035 #ifndef EXCLUDE_FROM_XARALX
04036     // And make the first item in the list selected
04037     pListGadget->SetSelectedItemIndex(0);
04038 #endif
04039 
04040     EnableControls();
04041 
04042     return(TRUE);
04043 }
04044 
04045 
04046 
04047 /******************************************************************************************
04048 
04049 >   BOOL PrintImagesetterTab::EnableControls()
04050 
04051     Author:     Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com>
04052     Created:    12/6/96
04053     Inputs:     -
04054     Outputs:    -
04055     Returns:    TRUE if all went well
04056     Purpose:    Enables and disables the controls on the tab as appropriate for the 
04057                 current settings
04058     Errors:     -
04059     SeeAlso:    -
04060 
04061 ******************************************************************************************/
04062 
04063 BOOL PrintImagesetterTab::EnableControls()
04064 {
04065     if (pPrefsDlg == NULL)
04066         return TRUE;
04067 
04068     if (!TalkToPage())
04069         return(TRUE);
04070 
04071     if (!IsAllGreyed() && pDocument != NULL)
04072     {
04073         // If we have a marks manager, fill out the printer marks list
04074         PrintMarksMan *pPMM = GetApplication()->GetMarksManager();
04075 
04076         // If there is no print marks manager, the list will be disabled 
04077         EnableControl(_R(IDC_PRINTERMARKSLIST),
04078                     (pPMM != NULL && pDocument != NULL && pPrefsDlg->GetBoolGadgetSelected(_R(IDC_CHECKPMARKS))));
04079     }
04080     else
04081         EnableControl(_R(IDC_PRINTERMARKSLIST), FALSE);
04082 
04083     // Enable/Disable the postscript/screening options as appropriate
04084     EnableControl(_R(IDC_CHECKREFLECT),     !IsAllGreyed() && pDocument != NULL);
04085     EnableControl(_R(IDC_CHECKNEGATIVE),    !IsAllGreyed() && pDocument != NULL);
04086     EnableControl(_R(IDC_CHECKOPBLACK),     !IsAllGreyed() && pDocument != NULL);
04087     EnableControl(_R(IDC_CHECKPMARKS),      !IsAllGreyed() && pDocument != NULL);
04088 
04089     return TRUE;
04090 }
04091 
04092 
04093 
04094 /*************************************************************************************************************/
04095 /*********************** END CLASS PrintImagesetterTab ************************************************/
04096 /*************************************************************************************************************/ 
04097 
04098 
04099 /********************************************************************************************
04100 
04101 >   static BOOL OpShowPrintBorders::Init()
04102 
04103     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04104     Created:    10/5/95
04105     Inputs:     None
04106     Outputs:    None
04107     Returns:    TRUE if worked, FALSE if failed (out of memory)
04108     Purpose:    Declares op descriptors for show grid toggle op
04109     Errors:     Returns FALSE on failure.
04110     Scope:      Static
04111 
04112 ********************************************************************************************/
04113 
04114 
04115 BOOL OpShowPrintBorders::Init()
04116 {
04117     return RegisterOpDescriptor(    0,
04118                                     _R(IDS_SHOWPRINTBORDERS),
04119                                     CC_RUNTIME_CLASS(OpShowPrintBorders),
04120                                     OPTOKEN_SHOWPRINTBORDERS,
04121                                     GetState,
04122                                     0,                          // help ID 
04123                                     _R(IDBBL_PRINTBORDERS),         // bubble help
04124                                     _R(IDD_BARCONTROLSTORE),        // resource ID
04125                                     _R(IDC_PRINTBORDERS),           // control ID
04126                                     SYSTEMBAR_FILE,             // Bar ID
04127                                     TRUE,                       // Recieve system messages
04128                                     FALSE,                      // Smart duplicate operation
04129                                     TRUE,                       // Clean operation
04130                                     0,                          // No vertical counterpart
04131                                     0,                          // String for one copy only error
04132                                     (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC) // Auto state flags
04133                                 );
04134 }
04135 
04136 /********************************************************************************************
04137 
04138 >   OpShowPrintBorders::OpShowPrintBorders()
04139 
04140     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04141     Created:    10/5/95
04142     Inputs:
04143     Outputs:
04144     Returns:
04145     Purpose:    Constructor for OpShowPrintBorders operation. It is not undoable.
04146     Errors:     None
04147 
04148 ********************************************************************************************/
04149 
04150 OpShowPrintBorders::OpShowPrintBorders()
04151 {
04152 }
04153 
04154 /********************************************************************************************
04155 
04156 >   void OpShowPrintBorders::Do(OpDescriptor*)
04157 
04158     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04159     Created:    10/5/95
04160     Inputs:     None
04161     Outputs:    None
04162     Returns:    None
04163     Purpose:    Forces a redraw of the selected DocView and toggles the NodeGrid::RenderFlag flag
04164     Errors:     None
04165 
04166 ********************************************************************************************/
04167 
04168 void OpShowPrintBorders::Do(OpDescriptor*)
04169 {
04170     DocView *pDocView = DocView::GetSelected();
04171 
04172     if (pDocView != NULL)
04173     {
04174         pDocView->SetShowPrintBorders(!pDocView->GetShowPrintBorders());
04175         pDocView->ForceRedraw(TRUE);
04176     }
04177 
04178     End();
04179 }
04180 
04181 /********************************************************************************************
04182 
04183 >   OpState OpShowPrintBorders::GetState(String_256*, OpDescriptor*)
04184 
04185     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
04186     Created:    10/5/95
04187     Inputs:
04188     Outputs:
04189     Returns:
04190     Purpose:    This item is always available, so long as a document is visible.
04191     Errors:     None
04192 
04193 ********************************************************************************************/
04194 
04195 OpState OpShowPrintBorders::GetState(String_256*, OpDescriptor*)
04196 {
04197     OpState OpSt;
04198 
04199     DocView *pDocView = DocView::GetSelected();
04200     if (pDocView != NULL)
04201         OpSt.Ticked = pDocView->GetShowPrintBorders();
04202 
04203     return OpSt;
04204 }
04205 
04206 
04207 //--------------------------------------------------------------------------------------------
04208 #endif //webster

Generated on Sat Nov 10 03:46:20 2007 for Camelot by  doxygen 1.4.4