debugdlg.cpp

Go to the documentation of this file.
00001 // $Id: debugdlg.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 // debugdlg.cpp - The debug dialogue
00099 
00101 // This dialogue appears on the debug menu in debug builds only                             //
00102 // It offers a dropdown list of 'command groups'. Selecting one of these then shows a list  //
00103 // of available debugging commands which the user can invoke. Output from these commands    //
00104 // will generally appear in the TRACE output. This offers a simple way of adding debug      //
00105 // test code to the camelot menu tree so it can be easily triggered when you're ready for   //
00106 // it. Add your code to the last 4 functions in this file                                   //
00107 //      SetGroupList    - Sets the list of available groups                                 //
00108 //      SetCommandList  - Sets the list of commands for the given group                     //
00109 //      SetCommandValue - Sets the value field and help string for a given command          //
00110 //      InvokeCommand   - Applies the given command from the given group, using whatever    //
00111 //                        value the user typed into the 'value' field.                      //
00113 
00114 
00115 #include "camtypes.h"
00116 
00117 #if _DEBUG
00118 
00119 // Includes for the dialogue itself
00120 #include "debugdlg.h"   // kernel header
00121 //#include "dbgdlg.h"       // winoil resource header
00122 //#include "jason.h"        // For _R(IDS_DEBUGDLG)
00123 #include "progress.h"   // For the progress hourglass
00124 //#include "resource.h" // For _R(IDS_CANCEL)
00125 
00126 // Includes for specific debug commands
00127 #include "colcontx.h"   // Colour separation commands
00128 #include "colormgr.h"
00129 #include "colplate.h"
00130 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00131 
00132 //#include "app.h"      // Bitmap colour matching commands - in camtypes.h [AUTOMATICALLY REMOVED]
00133 //#include "bmplist.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00134 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00135 #include "bitmpinf.h"
00136 
00137 #include "prnmks.h"     // Printer marks
00138 
00139 #include "princomp.h"   // Print component (for always overprint black)
00140 #include "printctl.h"
00141 
00142 //#include "bmplist.h"  // For bitmap list dumps - in camtypes.h [AUTOMATICALLY REMOVED]
00143 
00144 #include "nodecont.h"   // ShadowType
00145 
00146 //#include "attrmgr.h"  // For Stroke Provider commands - in camtypes.h [AUTOMATICALLY REMOVED]
00147 #include "groupops.h"
00148 #include "lineattr.h"
00149 #include "mkshapes.h"
00150 #include "pathstrk.h"
00151 #include "ppairbsh.h"
00152 #include "ppstroke.h"
00153 #include "ppvecstr.h"
00154 #include "strkattr.h"
00155 #include "valfunc.h"
00156 
00157 #include "objcache.h"   // Object cache
00158 #include "cachrand.h"
00159 #include "cachweak.h"
00160 #include "cachfifo.h"
00161 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00162 #include "opimgset.h"
00163 
00164 #include "opliveeffects.h"
00165 //#include "xpehost.h"
00166 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00167 
00168 #include <time.h>
00169 #include <stdlib.h>
00170 
00171 #if FALSE
00172 #include <activscp.h>
00173 #include "ccc.h"    // <---- not here
00174 #endif
00175 
00176 //#include "mainfrm.h"
00177 
00178 CC_IMPLEMENT_DYNCREATE(DebugDlg, DialogOp)
00179 
00180 #define new CAM_DEBUG_NEW
00181 
00182 
00183 const INT32 DebugDlg::IDD = _R(IDD_DEBUGDLG);
00184 const CDlgMode DebugDlg::Mode = MODELESS;
00185 
00186 
00187 // Remember which command was selected last time we were open
00188 static INT32 LastSelectedIndex = 0;
00189 static INT32 LastSelectedGroup = 8;     // StrokeProviders. Geez I'm lazy!
00190 static BOOL CloseAndExecute = FALSE;
00191 
00192 #if FALSE
00193 static TCHAR g_szScriptToExecute[] = TEXT("ScriptToExecute");
00194 static String_256 g_ScriptToExecute;
00195 
00196 // Default to VBScript
00197 static TCHAR g_szScriptEngineCLSID[] = TEXT("B54F3741-5B07-11CF-A4B0-00AA004A55E8");
00198 static String_256 g_ScriptEngineCLSID;
00199 
00200 static IActiveScript* m_pScriptEngine = NULL;
00201 static IActiveScriptParse* m_pScriptParser = NULL;
00202 
00203 // {BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}
00204 static const IID IID_IActiveScript =
00205 { 0xbb1a2ae1, 0xa4f9, 0x11cf, {0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64}};
00206 
00207 // {BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}
00208 static const IID IID_IActiveScriptParse =
00209 { 0xbb1a2ae2, 0xa4f9, 0x11cf, {0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64}};
00210 
00211 HRESULT InitializeScriptEngine(const GUID& ScriptCLSID)
00212 {
00213     HRESULT Result = S_OK;
00214 
00215     Result = CoCreateInstance(ScriptCLSID, NULL, CLSCTX_INPROC_SERVER, IID_IActiveScript, (void**)&m_pScriptEngine);
00216 
00217     if (SUCCEEDED(Result))
00218     {
00219         Result = m_pScriptEngine->QueryInterface(IID_IActiveScriptParse, (void**)&m_pScriptParser);
00220     }
00221 
00222     if (SUCCEEDED(Result))
00223     {
00224         Result = m_pScriptEngine->SetScriptState(SCRIPTSTATE_INITIALIZED);
00225     }
00226 
00227     if (SUCCEEDED(Result))
00228     {
00229         Result = m_pScriptParser->InitNew();
00230     }
00231 
00232     if (SUCCEEDED(Result))
00233     {
00234         Result = m_pScriptEngine->AddNamedItem(OLESTR("Application"), SCRIPTITEM_ISVISIBLE);
00235     }
00236 
00237 
00238     return Result;
00239 }
00240 
00241 HRESULT ParseScript(const StringBase& ScriptName)
00242 {
00243     HRESULT Result = S_OK;
00244 
00245     ScriptName; // dosomething withthis
00246     BSTR bstrScript;
00247     EXCEPINFO ExceptionInfo;
00248     Result = m_pScriptParser->ParseScriptText(bstrScript, NULL,NULL,NULL,0,0,SCRIPTTEXT_ISVISIBLE,NULL,&ExceptionInfo);
00249 
00250     if (SUCCEEDED(Result))
00251     {
00252         Result = m_pScriptEngine->SetScriptState(SCRIPTSTATE_STARTED);
00253     }
00254 
00255     return Result;
00256 }
00257 
00258 
00259 void ExecuteScript(const StringBase& ScriptName)
00260 {
00261     HRESULT Result = S_OK;
00262 
00263     CLSID ScriptCLSID;
00264     LPOLESTR OSScriptCLSID = (LPOLESTR)((LPTSTR)g_ScriptEngineCLSID);
00265     Result = ::CLSIDFromString(OSScriptCLSID, &ScriptCLSID);
00266 //    LPOLESTR lpsz,    //Pointer to the string representation of the CLSID
00267     if (SUCCEEDED(Result))
00268     {
00269         Result = InitializeScriptEngine(ScriptCLSID);
00270     }
00271 
00272     if (SUCCEEDED(Result))
00273     {
00274         Result = ParseScript(ScriptName);
00275     }
00276 
00277 
00278     
00279 }
00280 
00281 CC_IMPLEMENT_MEMDUMP(ConcurrencyController, CC_CLASS_MEMDUMP)
00282 ConcurrencyController::ConcurrencyController()
00283 {
00284 }
00285 ConcurrencyController::~ConcurrencyController()
00286 {
00287 }
00288 
00289 void ExecuteScript(const StringBase& ScriptName)
00290 {
00291     AfxMessageBox(TEXT("Not this week"));
00292 }
00293 #endif  // Automation
00294 
00295 /********************************************************************************************
00296 
00297 >   DebugDlg::DebugDlg(): DialogOp(DebugDlg::IDD, DebugDlg::Mode) 
00298 
00299 
00300     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00301     Created:    8/5/96
00302 
00303     Purpose:    DebugDlg constructor.
00304 
00305 ********************************************************************************************/
00306 
00307 DebugDlg::DebugDlg() : DialogOp(DebugDlg::IDD, DebugDlg::Mode) 
00308 {
00309 }
00310 
00311 
00312 
00313 /********************************************************************************************
00314 
00315 >   DebugDlg::~DebugDlg()
00316 
00317     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00318     Created:    8/5/96
00319 
00320     Purpose:    You'll never guess...
00321 
00322 ********************************************************************************************/
00323  
00324 DebugDlg::~DebugDlg()
00325 {
00326 }
00327 
00328 
00329 
00330 /********************************************************************************************
00331 
00332 >   MsgResult DebugDlg::Message( CDlgMessage DlgMsg, CGadgetID Gadget)
00333 
00334     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00335     Created:    8/5/96
00336     Inputs:     Message - the message
00337     Outputs:    -
00338     Returns:    OK if it is happy
00339     Purpose:    Handles all the debug dialog's messages 
00340     Errors:     -
00341     SeeAlso:    -
00342 
00343 ********************************************************************************************/
00344 
00345 MsgResult DebugDlg::Message(Msg* Message)
00346 {
00347     if (IS_OUR_DIALOG_MSG(Message))
00348     {
00349         DialogMsg* Msg = (DialogMsg*)Message;
00350         BOOL EndDlg = FALSE;
00351 
00352         switch (Msg->DlgMsg)
00353         {
00354             case DIM_CREATE:
00355                 {
00356                     // Fill in the combobox of available command groups
00357                     SetGroupList();
00358 
00359                     // Fill in the list of available commands
00360                     SetCommandList(LastSelectedGroup);
00361 
00362                     // And then fill in the value/description fields as appropriate to whatever
00363                     // option is now selected in the list.
00364                     INT32 Index = GetSelectedValueIndex(_R(IDC_DEBUGDLG_LIST));
00365                     SetCommandValue(LastSelectedGroup, Index);
00366                     SetKeyboardFocus (_R(IDC_DEBUGDLG_VALUE1)) ;
00367                     HighlightText     (_R(IDC_DEBUGDLG_VALUE1)) ;
00368                     CloseAndExecute = FALSE;
00369                 }
00370                 break;
00371 
00372                 
00373             case DIM_COMMIT:
00374             case DIM_SOFT_COMMIT:
00375                 {
00376                     LastSelectedGroup = GetSelectedValueIndex(_R(IDC_DEBUGDLG_GROUP));
00377                     LastSelectedIndex = GetSelectedValueIndex(_R(IDC_DEBUGDLG_LIST));
00378                     String_256 Value = GetStringGadgetValue(_R(IDC_DEBUGDLG_VALUE1));
00379                     InvokeCommand(LastSelectedGroup, LastSelectedIndex, &Value);
00380 
00381                     // And update the window state to reflect any change
00382                     SetCommandValue(LastSelectedGroup, LastSelectedIndex);
00383                 }
00384                 break;
00385 
00386             case DIM_CANCEL:
00387                 EndDlg = TRUE;
00388                 break;
00389 
00390             case DIM_SELECTION_CHANGED:
00391                 if (Msg->GadgetID == _R(IDC_DEBUGDLG_LIST))
00392                 {
00393                     LastSelectedIndex = GetSelectedValueIndex(_R(IDC_DEBUGDLG_LIST));
00394                     SetCommandValue(LastSelectedGroup, LastSelectedIndex);
00395                 }
00396                 else if (Msg->GadgetID == _R(IDC_DEBUGDLG_GROUP))
00397                 {
00398                     LastSelectedGroup = GetSelectedValueIndex(_R(IDC_DEBUGDLG_GROUP));
00399                     SetCommandList(LastSelectedGroup);
00400                     LastSelectedIndex = 0;
00401                     SetCommandValue(LastSelectedGroup, LastSelectedIndex);
00402                 }
00403                 break;
00404 
00405             case DIM_SELECTION_CHANGED_COMMIT:
00406                 if (Msg->GadgetID == _R(IDC_DEBUGDLG_LIST))
00407                 {
00408                     LastSelectedGroup = GetSelectedValueIndex(_R(IDC_DEBUGDLG_GROUP));
00409                     LastSelectedIndex = GetSelectedValueIndex(_R(IDC_DEBUGDLG_LIST));
00410                     SetCommandValue(LastSelectedGroup, LastSelectedIndex);
00411 
00412                     String_256 Value = GetStringGadgetValue(_R(IDC_DEBUGDLG_VALUE1));
00413                     InvokeCommand(LastSelectedGroup, LastSelectedIndex, &Value);
00414 
00415                     // And update the window state to reflect any change
00416                     SetCommandValue(LastSelectedGroup, LastSelectedIndex);
00417                 }
00418                 break;
00419             default:
00420                 // Do nothing
00421                 break;
00422         }
00423 
00424         if (EndDlg)
00425         {
00426             Close();
00427             End();
00428             return(OK);
00429         }
00430 
00431         if (CloseAndExecute)
00432         {
00433             CloseAndExecute=FALSE;
00434             Close();
00435             End();
00436             InvokeLateCommand(LastSelectedGroup, LastSelectedIndex);
00437             return(OK);
00438         }
00439 
00440         return (DLG_EAT_IF_HUNGRY(Msg)); 
00441     }
00442 
00443     return OK; 
00444 }
00445 
00446 
00447 
00448 /********************************************************************************************
00449 
00450 >   OpState DebugDlg::GetState(String_256*, OpDescriptor*)
00451 
00452     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00453     Created:    8/5/96
00454     Purpose:    DebugDlg GetState method
00455 
00456 ********************************************************************************************/
00457 
00458 OpState DebugDlg::GetState(String_256*, OpDescriptor*)
00459 {    
00460     OpState OpSt;
00461     return(OpSt);
00462 }
00463 
00464 
00465          
00466 /********************************************************************************************
00467 
00468 >   BOOL DebugDlg::Init(void)
00469 
00470     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00471     Created:    8/5/96
00472 
00473     Purpose:    DebugDlg Init method. Called by sginit.cpp
00474 
00475 ********************************************************************************************/
00476 
00477 BOOL DebugDlg::Init(void)
00478 {
00479 #if FALSE
00480     Camelot.DeclarePref( "DebugFlags", g_szScriptToExecute, &g_ScriptToExecute);
00481     Camelot.DeclarePref( "DebugFlags", g_szScriptEngineCLSID, &g_ScriptEngineCLSID);
00482 #endif
00483     return (RegisterOpDescriptor(
00484                                 0,
00485                                 _R(IDS_DEBUGDLG),
00486                                 CC_RUNTIME_CLASS(DebugDlg),
00487                                 OPTOKEN_DEBUGDLG,
00488                                 DebugDlg::GetState,
00489                                 0,  // help ID
00490                                 0   // bubble ID
00491                                 )
00492             );
00493 }
00494  
00495 
00496 
00497 /********************************************************************************************
00498 
00499 >   BOOL DebugDlg::Create()
00500 
00501     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00502     Created:    8/5/96
00503     Returns:    TRUE if successful, else FALSE
00504     Purpose:    DebugDlg create method 
00505 
00506 ********************************************************************************************/
00507 
00508 BOOL DebugDlg::Create()
00509 {
00510     return(DialogOp::Create());
00511 }
00512 
00513 
00514 
00515 /********************************************************************************************
00516 
00517 >   void DebugDlg::Do(OpDescriptor *Bob)
00518 
00519     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00520     Created:    8/5/96
00521     Inputs:     OpDescriptor of this op
00522 
00523     Purpose:    Creates then opens the dialog 
00524 
00525 ********************************************************************************************/
00526 
00527 void DebugDlg::Do(OpDescriptor *Bob)
00528 {
00529     if (!Create())
00530     {
00531         InformError();
00532         End();
00533         return;
00534     }
00535 
00536     Open();
00537 }
00538 
00539 
00540 
00541 /********************************************************************************************
00542 
00543 >   void DebugDlg::SetGroupList(void)
00544 
00545     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00546     Created:    20/5/96
00547 
00548     Purpose:    Sets the list of debug dialogue command groups
00549 
00550                 ADD YOUR OWN GROUP NAMES TO THE END OF THE LIST
00551 
00552                 Note the index of the group in the list - this is the GroupIndex used
00553                 in the related functions (below).
00554 
00555     Notes:      This only appears in DEBUG builds, so it's fine to inline strings
00556 
00557 ********************************************************************************************/
00558 
00559 void DebugDlg::SetGroupList(void)
00560 {
00561     String_256 Temp;
00562 
00563     DeleteAllValues(_R(IDC_DEBUGDLG_GROUP));
00564 
00565 #define ADDGROUP(name) { Temp = TEXT(name); SetStringGadgetValue(_R(IDC_DEBUGDLG_GROUP), Temp); }
00566 
00567     ADDGROUP("Imagesetting (Jason)");       // Group 0
00568     ADDGROUP("Jason personal debug");       // Group 1
00569     ADDGROUP("Mikes personal debug");       // Group 2
00570     ADDGROUP("Wills bitmap debug");         // Group 3
00571     ADDGROUP("Low memory debug");           // Group 4
00572     ADDGROUP("Operation history dump");     // Group 5
00573 // Neville 2/10/97 removal of vector stroking bits
00574 #ifdef VECTOR_STROKING
00575     ADDGROUP("Shadow rendering tests");     // Group 6
00576     ADDGROUP("Stroke providers")            // Group 7
00577     ADDGROUP("Vector strokes")              // Group 8
00578     ADDGROUP("ObjectCache tests");          // Group 9
00579 #endif // VECTOR_STROKING
00580 #if FALSE
00581     ADDGROUP("Script Execution");           // Group 10
00582 #endif
00583     ADDGROUP("Phil Debug");                 // Group 10
00584     ADDGROUP("Gerry Debug");                // Group 11
00585     // Add more groups here...
00586 
00587 
00588 #undef ADDGROUP
00589 
00590     // Select the last item the user selected, in the hope that this is useful
00591     SetSelectedValueIndex(_R(IDC_DEBUGDLG_GROUP), LastSelectedGroup);
00592 }
00593 
00594 
00595 
00596 /********************************************************************************************
00597 
00598 >   void DebugDlg::SetCommandList(INT32 GroupIndex)
00599 
00600     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00601     Created:    8/5/96
00602 
00603     Inputs:     GroupIndex - indicates which command group is to be used
00604 
00605     Purpose:    Sets the list of debug dialogue commands
00606 
00607                 ADD YOUR OWN COMMAND NAMES TO THE END OF THE LIST
00608 
00609                 Note the index of the command in the list - this is the CommandIndex used
00610                 in the related functions (below).
00611 
00612     Notes:      This only appears in DEBUG builds, so it's fine to inline strings
00613 
00614 ********************************************************************************************/
00615 
00616 void DebugDlg::SetCommandList(INT32 GroupIndex)
00617 {
00618     String_256 Temp;
00619 
00620     DeleteAllValues(_R(IDC_DEBUGDLG_LIST));
00621 
00622 #define ADDCOMMAND(name) { Temp = TEXT(name); SetStringGadgetValue(_R(IDC_DEBUGDLG_LIST), Temp); }
00623 
00624     switch (GroupIndex)
00625     {
00626         case 0:     // Jason's colour separation controls ------------------------------------
00627             ADDCOMMAND("Normal document view");                     // Command 0
00628 
00629             ADDCOMMAND("  Composite preview");                      // Command 1
00630             ADDCOMMAND("  Cyan preview");                           // Command 2
00631             ADDCOMMAND("  Magenta preview");                        // Command 3
00632             ADDCOMMAND("  Yellow preview");                         // Command 4
00633             ADDCOMMAND("  Key preview");                            // Command 5
00634 
00635             ADDCOMMAND("  Spot plate");                             // Command 6
00636 
00637             ADDCOMMAND("Monochrome toggle");                        // Command 7
00638             ADDCOMMAND("Photographic negative toggle");             // Command 8
00639 
00640             ADDCOMMAND("Overprint toggle");                         // Command 9
00641             ADDCOMMAND("Always overprint black");                   // Command 10
00642             break;
00643 
00644 
00645         case 1:     // Jason's misc controls -------------------------------------------------
00646             ADDCOMMAND("Write line to debug stream");               // Command 0
00647             break;
00648 
00649         case 2:     // Mike's misc controls --------------------------------------------------
00650             ADDCOMMAND("Initialise print marks");                   // Command 0
00651             ADDCOMMAND("Add doc print mark");                       // Command 1
00652             ADDCOMMAND("Add a colour ramp entry");                  // Command 2
00653             ADDCOMMAND("Add a transparency ramp entry");            // Command 3
00654             break;
00655 
00656         case 3:     // Will's debug controls -------------------------------------------------
00657             ADDCOMMAND("Dump global bitmap list");                  // Command 0
00658             ADDCOMMAND("Dump greyscale bitmap list");               // Command 1
00659             break;
00660 
00661         case 4:     // Low memory testing (by Peter) -----------------------------------------
00662             ADDCOMMAND("Enable Low Memory Testing");                // Command 0
00663             ADDCOMMAND("  Fail all claims");                        // Command 1
00664             ADDCOMMAND("  Fail all claims after n bytes");          // Command 2
00665             ADDCOMMAND("Memory dump");                              // Command 3
00666             ADDCOMMAND("Camelot memory check");                     // Command 4
00667             ADDCOMMAND("MFC memory check (not for SmartHeap users)");   // Command 5
00668             break;
00669 
00670         case 5:     // Operation history dump (by Peter) -------------------------------------
00671             ADDCOMMAND("Dump last operation");                      // Command 0
00672             ADDCOMMAND("Dump all operations");                      // Command 1
00673             break;
00674 
00675 // Neville 2/10/97 removal of vector stroking bits
00676 #ifdef VECTOR_STROKING
00677         case 6:
00678             ADDCOMMAND("Random positioning");                       // Command 0
00679             ADDCOMMAND("Linewidth");                                // Command 1
00680             ADDCOMMAND("StrokePathToPath");                         // Command 2
00681             ADDCOMMAND("FlattenExpand");                            // Command 3
00682             ADDCOMMAND("Bitmap Shadow");                            // Command 4
00683             break;
00684 
00685         case 7:     // Stroke provider tests (Jason) -----------------------------------------
00686             ADDCOMMAND("Old-style line");                           // Command 0
00687             ADDCOMMAND("Constant width stroke");                    // Command 1
00688             ADDCOMMAND("Linear Ramp");                              // Command 2
00689             ADDCOMMAND("S Ramp");                                   // Command 3
00690             ADDCOMMAND("Blip");                                     // Command 4
00691             ADDCOMMAND("Ellipse");                                  // Command 5
00692             ADDCOMMAND("Teardrop");                                 // Command 6
00693             ADDCOMMAND("Thumbtack");                                // Command 7
00694             ADDCOMMAND("Airbrush - S");                             // Command 8
00695             ADDCOMMAND("Airbrush - linear");                        // Command 9
00696             ADDCOMMAND("Airbrush - random");                        // Command 10
00697             ADDCOMMAND("Airbrush - L");                             // Command 11
00698             break;
00699 
00700         case 8:     // Stroke provider tests (Jason) -----------------------------------------
00701             ADDCOMMAND("Create new vector stroke");                 // Command 0
00702             ADDCOMMAND("Create new repeating vector stroke");       // Command 1
00703             ADDCOMMAND("Apply last created vector stroke");         // Command 2
00704             break;
00705 
00706         case 9:     // Object cache tests (Olivier) ------------------------------------------
00707             ADDCOMMAND("Fill up the cache");                        // Command 1
00708             ADDCOMMAND("Add fixed size objects");                   // Command 2
00709             ADDCOMMAND("Add randomed size objects")                 // Command 3
00710             ADDCOMMAND("Add a big object");                         // Command 4
00711             break;
00712 #endif // VECTOR_STROKING
00713 
00714 #if FALSE
00715         case 10:    // Script Execution (Colin) ------------------------------------------
00716             ADDCOMMAND("Run the Script");                           // Command 0
00717             break;
00718         // Add further command groups here...
00719 #endif
00720         case 10:
00721             ADDCOMMAND("Apply default Live Effect (blur)");             // Command 0
00722             ADDCOMMAND("Invoke IXaraPhotoEditor3");                     // Command 1
00723             ADDCOMMAND("End IXaraPhotoEditor3 Session");                // Command 2
00724             ADDCOMMAND("Dump Bitmap Cache");                            // Command 3
00725             ADDCOMMAND("Create new spread");                            // Command 4
00726             break;
00727 
00728         case 11:    // Gerry Debug ------------------------------------------
00729             ADDCOMMAND("Command 0");                                // Command 0
00730             break;
00731     }
00732 
00733 #undef ADDCOMMMAND
00734 
00735     // Select the last item the user selected, in the hope that this is useful
00736     SetSelectedValueIndex(_R(IDC_DEBUGDLG_LIST), LastSelectedIndex);
00737 }
00738 
00739 
00740 
00741 /********************************************************************************************
00742 
00743 >   void DebugDlg::SetCommandValue(INT32 GroupIndex, INT32 CommandIndex)
00744 
00745     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00746     Created:    8/5/96
00747 
00748     Inputs:     GroupIndex - indicates which command group is to be used
00749                 CommandIndex - the index of the command in the list - see DebugDlg::SetCommandList
00750 
00751     Purpose:    Whenever a new command is chosen from the list, this function is called
00752                 to fill in the "value" field with whatever number you like.
00753 
00754                 ADD AN ENTRY TO THE SWITCH STATEMENT TO HANDLE YOUR COMMAND
00755                     Set "Description" to a helpful description string
00756                     Set "Value" to the current value (if any) associated with your command
00757                     Set "IsEditable" if you want the value to be editable
00758 
00759     Notes:      This only appears in DEBUG builds, so it's fine to inline strings
00760 
00761 ********************************************************************************************/
00762 
00763 void DebugDlg::SetCommandValue(INT32 GroupIndex, INT32 CommandIndex)
00764 {
00765     String_256 Description(TEXT("Does an unknown debug option"));
00766 
00767     String_256 Value(TEXT("0"));
00768     BOOL IsEditable = FALSE;
00769 
00770     switch(GroupIndex)
00771     {
00772         case 0:     // Jason's colour separation controls ------------------------------------
00773             switch (CommandIndex)
00774             {
00775                 case 0: Description = TEXT("Disables global colour separations");           break;
00776                 case 1: Description = TEXT("Changes to a composite WYSIWYG print preview"); break;
00777                 case 2: Description = TEXT("Changes to CYAN colour separation");            break;
00778                 case 3: Description = TEXT("Changes to MAGENTA colour separation");         break;
00779                 case 4: Description = TEXT("Changes to YELLOW colour separation");          break;
00780                 case 5: Description = TEXT("Changes to KEY colour separation");             break;
00781                 case 6:
00782                     {
00783                         Description = TEXT("Changes to specified SPOT separation");
00784                         Value = TEXT("1");
00785 
00786                         ColourContext *cc = ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
00787                         ColourPlate *SepDescriptor = cc->GetColourPlate();
00788                         if (SepDescriptor && SepDescriptor->GetType() == COLOURPLATE_SPOT)
00789                         {
00790                             IndexedColour *pSpotCol = SepDescriptor->GetSpotColour();
00791                             if (pSpotCol)
00792                             {
00793                                 // Count the spot colours until we find the required one
00794                                 ColourList* pColList = Document::GetSelected()->GetIndexedColours();
00795                                 IndexedColour* pCol = (IndexedColour*) pColList->GetHead();
00796                                 INT32 Count = 0;
00797 
00798                                 while (pCol != NULL)
00799                                 {
00800                                     if (pCol->GetType() == COLOURTYPE_SPOT && !pCol->IsDeleted())
00801                                     {
00802                                         Count++;
00803                                     }
00804 
00805                                     if (pCol == pSpotCol)
00806                                         break;
00807 
00808                                     pCol = (IndexedColour*) pColList->GetNext(pCol);
00809                                 }
00810 
00811                                 if (pCol && Count > 0)
00812                                     Value._MakeMsg(_T("#1%d"), Count);
00813                             }
00814                         }                       
00815 
00816                         // And allow the user to edit the string as they see fit
00817                         IsEditable = TRUE;
00818                     }
00819                     break;
00820 
00821                 case 7:
00822                     {
00823                         Description = TEXT("Toggles colour output to/from monochrome");
00824 
00825                         ColourContext *cc = ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
00826                         ColourPlate *SepDescriptor = cc->GetColourPlate();
00827                         BOOL Mono   = (SepDescriptor != NULL) ? SepDescriptor->IsMonochrome() : FALSE;
00828 
00829                         Value = (Mono) ? TEXT("Enabled") : TEXT("Disabled");
00830                     }
00831                     break;
00832 
00833                 case 8:
00834                     {
00835                         Description = TEXT("Toggles colour output to/from photographic negative");
00836 
00837                         ColourContext *cc = ColourManager::GetColourContext(COLOURMODEL_RGBT, DocView::GetSelected());
00838                         ColourPlate *SepDescriptor = cc->GetColourPlate();
00839                         BOOL Negate = (SepDescriptor != NULL) ? SepDescriptor->IsNegative() : FALSE;
00840 
00841                         Value = (Negate) ? TEXT("Enabled") : TEXT("Disabled");
00842                     }
00843                     break;
00844 
00845                 case 9:  Description = TEXT("Toggles plate overprint for the current plate");   break;
00846                 case 10:
00847                     Description = TEXT("Toggles 'Always overprint black' state");
00848                     {
00849                         Document *Bob = Document::GetSelected();
00850 
00851                         if (Bob != NULL)
00852                         {
00853                             PrintComponent *Sally = (PrintComponent *) 
00854                                                     Bob->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
00855                             if (Sally != NULL)
00856                             {
00857                                 PrintControl *Ernest = Sally->GetPrintControl();
00858                                 if (Ernest != NULL)
00859                                 {
00860                                     TypesetInfo *Mavis = Ernest->GetTypesetInfo();
00861                                     if (Mavis != NULL)
00862                                     {
00863                                         Value = (Mavis->AlwaysOverprintBlack()) ? TEXT("Enabled") : TEXT("Disabled");
00864                                     }
00865                                 }
00866                             }
00867                         }
00868                     }
00869                     break;
00870             }
00871             break;
00872 
00873 
00874         case 1:     // Jason's misc controls -------------------------------------------------
00875             switch (CommandIndex)
00876             {
00877                 case 0:
00878                     Description = TEXT("Writes the 'value' string to the debug stream");
00879 
00880                     // Set up a default string in the value field
00881                     Value = TEXT("--- trace marker inserted by user ---");
00882 
00883                     // And allow the user to edit the string as they see fit
00884                     IsEditable = TRUE;
00885                     break;
00886             }
00887             break;
00888 
00889 #ifndef WEBSTER // Neville 6/8/97
00890         case 2:     // Mikes's misc controls -------------------------------------------------
00891             switch (CommandIndex)
00892             {
00893                 case 0: Description = TEXT("Initialises the print mark managers cache"); break;
00894                 case 1: Description = TEXT("Adds the first print mark to the selected doc"); break;
00895                 
00896                 case 2: Description = TEXT("Adds a new colour to a grad fills colour ramp"); 
00897                         // set up a default string in the value field
00898                         Value = TEXT("128");
00899                         IsEditable = TRUE;
00900                         break;
00901                 case 3: Description = TEXT("Adds a new transp to a grad transp ramp");
00902                         // set up a default string in the value field
00903                         Value = TEXT("128");
00904                         IsEditable = TRUE;
00905                         break;
00906             }
00907             break;
00908 #endif // WEBSTER
00909 
00910         case 3:     // Will's bitmap controls -------------------------------------------------
00911             switch (CommandIndex)
00912             {
00913                 case 0: Description = TEXT("Dumps the current global bitmap list"); break;
00914                 case 1: Description = TEXT("Dumps the current greyscale bitmap list"); break;
00915             }
00916             break;
00917 
00918         case 4:     // Low memory Testing (Peter) ---------------------------------------------
00919             switch (CommandIndex)
00920             {
00921                 case 0: Description = TEXT("Enable or disbale low memory testing");
00922                     Value = (SimpleCCObject::GetLowMemoryState()) ? TEXT("Enabled") : TEXT("Disabled");
00923                     break;
00924                 case 1: Description = TEXT("Fails all memory claims.");
00925                     if (SimpleCCObject::GetLowMemoryState() && SimpleCCObject::GetLowMemoryLimit()==0)
00926                         Value = TEXT("Enabled");
00927                     else
00928                         Value = TEXT("Disabled");
00929                     break;
00930                 case 2: Description = TEXT("Fails memory claims after the specified number of bytes have been claimed.");
00931                 {
00932                     String_32 Number;
00933                     Number._MakeMsg(_T("#1%lu"), SimpleCCObject::GetLowMemoryLimit());
00934                     Value = Number;
00935                     IsEditable = TRUE;
00936                     break;
00937                 }
00938                 case 3: Description = TEXT("Lists all allocated objects to the TRACE display.");
00939                     break;
00940                 case 4: Description = TEXT("Checks guardwords on Camelot memory allocations.");
00941                     break;
00942                 case 5: Description = TEXT("MFC memory allocation check.");
00943                     break;
00944             }
00945             break;
00946 
00947         case 5:     // Operation history listing -------------------------------------------------
00948             switch (CommandIndex)
00949             {
00950                 case 0: Description = TEXT("Dump actions in the last operation (in the selected document) to TRACE display"); break;
00951                 case 1: Description = TEXT("Dump actions in all operations (in the selected document) to TRACE display"); break;
00952             }
00953             break;
00954 
00955 #ifdef VECTOR_STROKING // Neville 6/8/97
00956         case 6:
00957             switch (CommandIndex)
00958             {
00959                 case 0: Description = TEXT("Render n copies around a centrepoint (Fails on large penumbras)"); break;
00960                 case 1: Description = TEXT("Render decreasing linewidths with decreasing transparency (Fails on transparent shadows)"); break;
00961                 case 2: Description = TEXT("Render StrokePathToPath linewidths (Far too slow (on complex shapes))"); break;
00962                 case 3: Description = TEXT("Flatten and expand paths (Fails on inverted paths)"); break;
00963                 case 4: Description = TEXT("Bitmap shadower Using new Shadower COM Object"); break;
00964             }
00965             break;
00966 
00967         case 7:     // Stroke provider tests (Jason) -----------------------------------------
00968             switch (CommandIndex)
00969             {
00970                 case 0: Description = TEXT("Reset the stroke to 'old style line' (the default)");       break;
00971                 case 1: Description = TEXT("Apply a constant width variable-width stroke attribute");   break;
00972                 case 2: Description = TEXT("Apply a linear ramp variable-width stroke attribute");      break;
00973                 case 3: Description = TEXT("Apply an 'S' ramp variable-width stroke attribute");        break;
00974                 case 4: Description = TEXT("Apply a 'blip' variable-width stroke attribute");           break;
00975                 case 5: Description = TEXT("Apply an 'ellipse' variable-width stroke attribute");       break;
00976                 case 6: Description = TEXT("Apply a 'teardrop' variable-width stroke attribute");       break;
00977                 case 7: Description = TEXT("Apply a 'thumbtack' variable-width stroke attribute");      break;
00978                 case 8: Description = TEXT("Apply an airbrush stroke attribute");                       break;
00979                 case 9: Description = TEXT("Apply an airbrush stroke attribute");                       break;
00980                 case 10:Description = TEXT("Apply an airbrush stroke attribute");                       break;
00981                 case 11:Description = TEXT("Apply an airbrush stroke attribute");                       break;
00982             }
00983             break;
00984 
00985         case 8:
00986             switch (CommandIndex)
00987             {
00988                 case 0: Description = TEXT("Set the vector stroke brush from the selection");           break;
00989                 case 1: Description = TEXT("Set the vector stroke brush, and make it repeating");       break;
00990                 case 2: Description = TEXT("Apply the last vector stroke you created");                 break;
00991             }
00992             break;
00993 
00994         case 9:
00995             switch (CommandIndex)
00996             {
00997                 case 0: Description = TEXT("Add as many objects as needed to fill up the cache");break;
00998                 case 1: Description = TEXT("Add several objects which size increase");break;
00999                 case 2: Description = TEXT("Add several objects with a random size");break;
01000                 case 3: Description = TEXT("Add an object bigger than the cachesize");break;
01001             }
01002             break;
01003 #endif // VECTOR_STROKING
01004 
01005 #if FALSE
01006         case 10:        // Colin's script executioner -------------------------------------------------
01007             switch (CommandIndex)
01008             {
01009                 case 0:
01010                     Description = TEXT("Run a Script");
01011                     break;
01012             }
01013             break;
01014 #endif
01015         case 10:        // Phil's LiveEffects test -------------------------------------------------
01016             switch (CommandIndex)
01017             {
01018                 case 0:
01019                     Description = TEXT("Apply the default debug effect to the selection");
01020                     break;
01021                 case 1:
01022                     Description = TEXT("Call the new XPE interface for modeless editing");
01023                     break;
01024                 case 2:
01025                     Description = TEXT("End the XPE editing session successfully");
01026                     break;
01027                 case 3:
01028                     Description = TEXT("Dump a description of the bitmap cache to the debug output");
01029                     break;
01030                 case 4:
01031                     Description = TEXT("Create a second spread! OOER!");
01032                     break;
01033             }
01034             break;
01035 
01036         case 11:        // Gerry Debug-------------------------------------------------
01037             switch (CommandIndex)
01038             {
01039                 case 0:
01040                     Description = TEXT("Command 0");
01041                     break;
01042             }
01043             break;
01044         // case n:
01045         // Add your own command group(s) here       
01046     }
01047 
01048     SetStringGadgetValue(_R(IDC_DEBUGDLG_COMMENT), Description);
01049 
01050     SetStringGadgetValue(_R(IDC_DEBUGDLG_VALUE1), Value);
01051     EnableGadget(_R(IDC_DEBUGDLG_VALUE1), IsEditable);
01052 }
01053 
01054 
01055 class NodeShadowController;
01056 
01057 /********************************************************************************************
01058 
01059 >   void DebugDlg::InvokeCommand(INT32 GroupIndex, INT32 CommandIndex, StringBase *NewValue)
01060 
01061     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01062     Created:    8/5/96
01063 
01064     Inputs:     GroupIndex - indicates which command group is to be used
01065                 CommandIndex - the index of the command in the list - see DebugDlg::SetCommandList
01066                 NewValue - A string entered by the usert in the "Value" field of the dialogue.
01067                             (e.g. this is used by Jason's CommandIndex 0 to output a string into
01068                             the debug stream)
01069 
01070     Purpose:    Invokes one of the debug commands.
01071 
01072                 ADD AN ENTRY TO THE SWITCH STATEMENT TO HANDLE YOUR COMMAND
01073 
01074     Notes:      This only appears in DEBUG builds
01075 
01076 ********************************************************************************************/
01077 
01078 void DebugDlg::InvokeCommand(INT32 GroupIndex, INT32 CommandIndex, StringBase *NewValue)
01079 {
01080     String_256 Desc(TEXT("Doing debug command..."));
01081     Progress Hourglass((StringBase *) &Desc, -1, FALSE);    // Hourglass while we're busy
01082 
01083     switch (GroupIndex)
01084     {
01085         case 0:     // Jason's colour separation controls ------------------------------------
01086             switch (CommandIndex)
01087             {
01088                 case 0:     // Normal document view
01089                     if (DocView::GetSelected() != NULL)
01090                     {
01091                         // Remove any attached ColourPlate, and redraw all affected thingies
01092                         DocView::GetSelected()->SetColourPlate(NULL);
01093                         ColourManager::SelViewContextHasChanged();
01094                     }
01095                     break;
01096 
01097                 case 1:  SetNewColourPlate(COLOURPLATE_COMPOSITE,0,0); break;
01098                 case 2:  SetNewColourPlate(COLOURPLATE_CYAN,     0,0); break;
01099                 case 3:  SetNewColourPlate(COLOURPLATE_MAGENTA,  0,0); break;
01100                 case 4:  SetNewColourPlate(COLOURPLATE_YELLOW,   0,0); break;
01101                 case 5:  SetNewColourPlate(COLOURPLATE_KEY,      0,0); break;
01102                 case 6:
01103                     {
01104                         INT32 Pos = 0;
01105                         INT32 SpotPlate = NewValue->ConvertToInteger(Pos);
01106                         SetNewColourPlate(COLOURPLATE_SPOT,  0,SpotPlate);
01107                     }
01108                     break;
01109                 case 7:  SetNewColourPlate(COLOURPLATE_NONE,     1,0); break;
01110                 case 8:  SetNewColourPlate(COLOURPLATE_NONE,     2,0); break;
01111                 case 9:  SetNewColourPlate(COLOURPLATE_NONE,     3,0); break;
01112 
01113                 case 10:
01114                     {
01115                         Document *Bob = Document::GetSelected();
01116 
01117                         if (Bob != NULL)
01118                         {
01119                             PrintComponent *Sally = (PrintComponent *)
01120                                                     Bob->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent));
01121                             if (Sally != NULL)
01122                             {
01123                                 PrintControl *Ernest = Sally->GetPrintControl();
01124                                 if (Ernest != NULL)
01125                                 {
01126                                     TypesetInfo *Mavis = Ernest->GetTypesetInfo();
01127                                     if (Mavis != NULL)
01128                                     {
01129                                         Mavis->SetOverprintBlack(!Mavis->AlwaysOverprintBlack());
01130                                     }
01131                                 }
01132                             }
01133                         }
01134                     }
01135                     break;
01136 
01137                 default:
01138                     ERROR3("Unknown debug command");
01139                     break;
01140             }
01141             break;
01142 
01143 
01144         case 1:     // Jason's misc controls -------------------------------------------------
01145             switch (CommandIndex)
01146             {
01147                 case 0:
01148                     // Output the "value" string (entered by the user) into the trace output.
01149                     // I find this invaluable when dumping screeds of debug stuff, in order to
01150                     // mark positions in the output so I can find the important info amongst
01151                     // all the chaff.
01152                     TRACE( _T("%s\n"), (TCHAR *) (*NewValue));
01153                     break;
01154 
01155                 default:
01156                     ERROR3("Unknown debug command");
01157                     break;
01158             }
01159             break;
01160 
01161 #ifndef WEBSTER // Neville 6/8/97
01162         case 2:     // Mike's misc controls -------------------------------------------------
01163             switch (CommandIndex)
01164             {
01165                 case 0:
01166                 {
01167                     // We need to execute this one after the dialogue has closed.
01168                     // CloseAndExecute=TRUE;
01169                     PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
01170                     if (pMarksMan!=NULL)
01171                         pMarksMan->ConstructCache();
01172                 }
01173                 break;
01174 
01175                 case 1:
01176                 {
01177                     PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
01178                     if (pMarksMan!=NULL)
01179                     {
01180                         // get the first mark from the cache
01181                         PrintMarkItem *pMarkItem = pMarksMan->PMMCache.GetFirstMark();
01182                         if (pMarkItem!=NULL)
01183                         {
01184                             UINT32 Handle=pMarkItem->GetHandle();
01185                             Document* pDoc = Document::GetSelected();
01186                             if (pDoc)
01187                                 pMarksMan->AddMarkToDoc(Handle,pDoc);
01188                         }
01189                     }               
01190                     
01191                 }
01192                 break;
01193 
01194                 case 2:
01195                 {
01196                     // ok we need to find the selected object and alter its attribute to get a
01197                     // colour fill applied. How do we do this?
01198                     // hmm I'll work it out in a moment.
01199 
01200                     // Well like this really...
01201                     AttrColFillRampChange* pAttrib = new AttrColFillRampChange;
01202                     if (pAttrib!=NULL)
01203                     {
01204                         INT32 Pos = 0;
01205                         INT32 NewVal = NewValue->ConvertToInteger(Pos);
01206                         float pos = ((float)NewVal) / 255.0f;
01207                         if (pos<0.0f) pos=0.0f;
01208                         if (pos>1.0f) pos=1.0f;
01209                         // ok full yellow in the middle please
01210                         
01211                         srand((unsigned)time(NULL));
01212                         INT32 r,g,b;
01213                         r = rand();
01214                         g = rand();
01215                         b = rand();
01216                         r &= 0xFF;
01217                         g &= 0xFF;
01218                         g &= 0xFF;
01219                         DocColour TestColour(r,g,b);
01220                         pAttrib->InitForColourAdd(&TestColour, pos);
01221                         
01222                         // AttributeSelected knows what to do with a selected attribute
01223                         AttributeManager::AttributeSelected(NULL, pAttrib); 
01224                     }
01225                 }
01226                 break;
01227 
01228                 case 3:
01229                 {
01230                     // Well like this really...
01231                     AttrTranspFillRampChange* pAttrib = new AttrTranspFillRampChange;
01232                     if (pAttrib!=NULL)
01233                     {
01234                         INT32 Pos = 0;
01235                         INT32 NewVal = NewValue->ConvertToInteger(Pos);
01236                         
01237                         float pos = ((float)NewVal) / 255.0f;
01238                         if (pos<0.0f) pos=0.0f;
01239                         if (pos>1.0f) pos=1.0f;
01240 
01241                         // ok full yellow in the middle please
01242                         srand((unsigned)time(NULL));
01243                         UINT32 t = (UINT32)rand();
01244                         t = t & 0xFF;
01245                         pAttrib->InitForTranspAdd(t, pos);
01246                         
01247                         // AttributeSelected knows what to do with a selected attribute
01248                         AttributeManager::AttributeSelected(NULL, pAttrib); 
01249                     }
01250                 }
01251                 break;
01252 
01253                 default:
01254                     ERROR3("Unknown debug command");
01255                     break;
01256             }
01257             break;
01258 #endif // WEBSTER
01259 
01260         case 3:     // Will's bitmap controls -------------------------------------------------
01261             switch (CommandIndex)
01262             {
01263                 case 0:
01264                 {
01265                     GlobalBitmapList* pBmpList = GetApplication()->GetGlobalBitmapList();
01266                     if (pBmpList)
01267                         pBmpList->DumpGlobalBitmapListToTrace();
01268                 }
01269                 break;
01270 
01271 //              case 1:
01272 //              {
01273 //                  GreyscaleBitmapList* pGreyList = 
01274 //                          GetApplication()->GetGlobalBitmapList()->GetGreyscaleBitmapList();
01275 //                  if (pGreyList)
01276 //                      pGreyList->DumpGreyscaleBitmapListToTrace();
01277 //              }
01278 //              break;
01279 
01280                 default:
01281                     ERROR3("Unknown debug command");
01282                     break;
01283             }
01284             break;
01285 
01286         case 4 :
01287             switch (CommandIndex)
01288             {
01289                 case 0:
01290                 {
01291                     SimpleCCObject::EnableLowMemoryTesting();
01292                 }
01293                 break;
01294 
01295                 case 1:
01296                 {
01297                     SimpleCCObject::EnableLowMemoryTesting();
01298                     SimpleCCObject::SetClaimLimit(0);
01299                 }
01300                 break;
01301 
01302                 case 2:
01303                 {
01304                     INT32 Pos = 0;
01305                     INT32 NewVal = NewValue->ConvertToInteger(Pos);
01306                     SimpleCCObject::SetClaimLimit(NewVal);
01307                 }
01308                 break;
01309 
01310                 case 3:
01311                 {
01312                     SimpleCCObject::MemoryDump();
01313                 }
01314                 break;
01315 
01316                 case 4:
01317                 {
01318                     SimpleCCObject::CheckMemory(TRUE);
01319                 }
01320                 break;
01321                 
01322                 case 5:
01323                 {
01324 //                  BOOL MemOK = AfxCheckMemory();
01325 //                  ERROR3IF(!MemOK, "MFC Memory check failure (look at TRACE output)");
01326                 }
01327                 break;
01328 
01329                 default:
01330                     ERROR3("Unknown/Unimplemented debug command");
01331                     break;
01332             }
01333             break;
01334 
01335         case 5:
01336             switch (CommandIndex)
01337             {
01338                 case 0:     GetApplication()->DumpLastOp(); break;
01339                 case 1:     GetApplication()->DumpAllOps(); break;
01340                 default:    ERROR3("Unknown/Unimplemented debug command");  break;
01341             }
01342             break;
01343 
01344 #ifdef VECTOR_STROKING // Neville 6/8/97
01345         case 6:
01346             // NodeShadowController::RenderMethod = (ShadowType)CommandIndex;
01347             break;
01348 
01349         case 7:     // Stroke provider tests (Jason) -----------------------------------------
01350             {
01351                 AttrStrokeType *pStrokeAttr = new AttrStrokeType;
01352                 PathProcessorStroke *pProcessor = NULL;
01353 
01354                 AttrVariableWidth *pWidthAttr = new AttrVariableWidth;
01355                 VariableWidthID Function = VarWidth_NotPredefined;
01356                 ValueFunction *pFunction = NULL;
01357 
01358                 // Check to see if there is a path processor already applied - if it is, the
01359                 // options which only need to change the width function will not overwrite
01360                 // the stroker (allowing you to change the shape on an Airbrushed stroke, etc)
01361                 BOOL NeedToApplyType = FALSE;
01362                 
01363                 // BLOCK
01364                 {
01365                     SelRange *Selection = Camelot.FindSelection();
01366                     ERROR3IF(Selection == NULL, "No Selection SelRange!?!");
01367 
01368                     NodeAttribute *pNode = NULL;
01369                     switch(Selection->FindCommonAttribute(CC_RUNTIME_CLASS(AttrStrokeType), &pNode))
01370                     {
01371                         case SelRange::ATTR_COMMON:
01372                             if (pNode != NULL)      // Let's just be really safe
01373                             {
01374                                 // There is a common attribute - but we must check if it supplies
01375                                 // a proper path processor (or if it is just an old-style line)
01376                                 StrokeTypeAttrValue *pSAV = (StrokeTypeAttrValue *) ((AttrStrokeType *)pNode)->GetAttributeValue();
01377                                 if (pSAV == NULL || pSAV->GetPathProcessor() == NULL)
01378                                     NeedToApplyType = TRUE;
01379                             }
01380                             else
01381                                 NeedToApplyType = TRUE;
01382                             break;
01383 
01384                         default:
01385                             NeedToApplyType = TRUE;
01386                             break;
01387                     }
01388                 }
01389 
01390                 switch (CommandIndex)
01391                 {
01392                     case 0:
01393                         // leave processor and function undefined
01394                         break;
01395 
01396                                 // Different width functions
01397                     case 1: Function    = VarWidth_Constant;            break;
01398                     case 2: Function    = VarWidth_LinRamp;             break;
01399                     case 3: Function    = VarWidth_SRamp;               break;
01400                     case 4: pFunction   = new ValueFunctionBlip;        break;
01401                     case 5: pFunction   = new ValueFunctionEllipse;     break;
01402                     case 6: pFunction   = new ValueFunctionTeardrop;    break;
01403                     case 7: pFunction   = new ValueFunctionThumbtack;   break;
01404 
01405                     case 8: // Airbrush stroke type
01406                     case 9:
01407                     case 10:
01408                     case 11:
01409                         pProcessor = new PathProcessorStrokeAirbrush;
01410 
01411                         switch(CommandIndex)
01412                         {
01413                             case 8: // Airbrush stroke type
01414                                 break;
01415 
01416                             case 9:
01417                                 {
01418                                     ValueFunction *pFunc = new ValueFunctionRampLinear(1.0, 0.0);
01419                                     ((PathProcessorStrokeAirbrush *)pProcessor)->SetIntensityFunction(pFunc);
01420                                 }
01421                                 break;
01422 
01423                             case 10:
01424                                 {
01425                                     ValueFunction *pFunc = new ValueFunctionRandom(0, 0.0, 0.8);
01426                                     ((PathProcessorStrokeAirbrush *)pProcessor)->SetIntensityFunction(pFunc);
01427                                 }
01428                                 break;
01429 
01430                             case 11:
01431                                 {
01432                                     ValueFunction *pFunc = new ValueFunctionRampL;
01433                                     ((PathProcessorStrokeAirbrush *)pProcessor)->SetIntensityFunction(pFunc);
01434                                 }
01435                                 break;
01436                         }
01437 
01438                         // BLOCK
01439                         {
01440                             // Airbrush defaults to using round caps & joins
01441                             AttrJoinType *pJoinAttr = new AttrJoinType();
01442                             if (pJoinAttr != NULL)
01443                             {
01444                                 pJoinAttr->Value.JoinType = RoundJoin;
01445                                 AttributeManager::AttributeSelected(pJoinAttr);
01446                             }
01447 
01448                             AttrStartCap *pCapAttr = new AttrStartCap;
01449                             if (pCapAttr != NULL)
01450                             {
01451                                 pCapAttr->Value.StartCap = LineCapRound;
01452                                 AttributeManager::AttributeSelected(pCapAttr);
01453                             }
01454                         }
01455                         break;
01456                 }
01457 
01458                 if (CommandIndex != 0 && pProcessor == NULL)
01459                 {
01460                     // We only apply a variable-width PathProcessor if there was not already one
01461                     // applied to to the selection. This allows us to change the width function
01462                     // on airbrushed strokes, etc, without losing the stroke type
01463                     if (NeedToApplyType)
01464                         pProcessor  = new PathProcessorStroke;
01465                     else
01466                     {
01467                         delete pStrokeAttr;
01468                         pStrokeAttr = NULL;
01469                     }
01470                 }
01471 
01472                 if (pStrokeAttr != NULL && pProcessor != NULL)
01473                     ((StrokeTypeAttrValue *)pStrokeAttr->GetAttributeValue())->SetPathProcessor(pProcessor);
01474 
01475                 if (pWidthAttr != NULL)
01476                 {
01477                     if (Function != VarWidth_NotPredefined)
01478                         ((VariableWidthAttrValue *)pWidthAttr->GetAttributeValue())->SetWidthFunction(Function);
01479                     else if (pFunction != NULL)
01480                         ((VariableWidthAttrValue *)pWidthAttr->GetAttributeValue())->SetWidthFunction(pFunction);
01481                     else
01482                     {
01483                         // We're not trying to override the width, so vape our width attr
01484                         delete pWidthAttr;
01485                         pWidthAttr = NULL;
01486                     }
01487                 }
01488 
01489                 // Now apply the attributes
01490                 if (pStrokeAttr != NULL)
01491                     AttributeManager::AttributeSelected(pStrokeAttr);
01492 
01493                 if (pWidthAttr != NULL)
01494                     AttributeManager::AttributeSelected(pWidthAttr);
01495             }
01496             break;
01497 
01498         case 8:
01499             {
01500                 switch (CommandIndex)
01501                 {
01502                     case 0:
01503                     case 1:
01504                         // Rip up the selection and use that as the brush in future, please
01505                         {
01506                             // First, Make Shapes on everything so they're all simple paths
01507                             String_256 Desc("Building new stroke brush...");
01508                             Progress::Start(FALSE, &Desc);
01509                             OpDescriptor *pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_MAKE_SHAPES);
01510                             if (pOp != NULL)
01511                                 pOp->Invoke();
01512 
01513                             // Second, Group everything
01514                             pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_GROUP);
01515                             if (pOp != NULL)
01516                                 pOp->Invoke();
01517 
01518                             // Finally, create a new brush
01519                             PathStrokerVector::BodgeRipSelection((CommandIndex == 0) ? FALSE : TRUE);
01520                             Progress::Stop();
01521                         }
01522                         break;
01523 
01524 
01525                     case 2:
01526                         {
01527                             AttrStrokeType *pStrokeAttr = new AttrStrokeType;
01528                             PathProcessorStrokeVector *pProcessor = new PathProcessorStrokeVector;
01529 
01530                             if (pStrokeAttr != NULL && pProcessor != NULL)
01531                             {
01532                                 pProcessor->SetStrokeDefinition(PathStrokerVector::GetCurrentBrush());
01533                                 ((StrokeTypeAttrValue *)pStrokeAttr->GetAttributeValue())->SetPathProcessor(pProcessor);
01534                                 AttributeManager::AttributeSelected(pStrokeAttr);
01535                             }
01536                         }
01537                         break;
01538                 }
01539             }
01540             break;
01541 
01542 
01543         case 9:
01544             {
01545                 // Get the ObjectCache
01546                 ObjectCache* pObjCache = GetApplication()->GetObjectCache();
01547 
01548                 if (pObjCache == NULL)
01549                     return;
01550 
01551                 WORD hObj = 0;
01552                                         
01553                 switch(CommandIndex)
01554                 {
01555                     case 0: // Add 50 objects which size is sizeof(DummyCachedObject)
01556                         {
01557                             for (INT32 i=0;i<=50;i++)
01558                             {
01559                                 DummyCachedObject* a = new DummyCachedObject;
01560                                 pObjCache->Add(a);
01561                             }
01562                         }
01563                         break;
01564                     case 1: // Add 50 objects which size is 'i'
01565                         {
01566                             for (INT32 i=0;i<=50;i++)
01567                             {
01568                                 DummyCachedObject* b = new DummyCachedObject(i);
01569                                 pObjCache->Add(b);
01570                             }
01571                         }
01572                         break;
01573                     case 2: // Add 50 objects which size is rand()%50+1
01574                         {
01575                             srand((unsigned)time(NULL));
01576                             for (INT32 i=1;i<=50;i++)
01577                             {
01578                                 DummyCachedObject* c = new DummyCachedObject(rand()%50+1);
01579                                 pObjCache->Add(c);
01580                             }
01581                         }
01582                         break;
01583 
01584                     case 3: // Add an object which size is bigger than the cache size
01585                         {
01586                             DummyCachedObject* u = new DummyCachedObject(55);
01587                             hObj = pObjCache->Add(u);
01588                         }
01589                         break;
01590                     default:
01591                         ERROR3("Unknown/Unimplemented debug command");
01592                         break;
01593                 }
01594             }
01595             break;
01596 #endif // VECTOR_STROKING
01597 
01598 #if FALSE
01599         case 10:
01600             {
01601                 ExecuteScript(g_ScriptToExecute);
01602             }
01603             break;
01604 #endif
01605         case 10:
01606             {
01607                 switch(CommandIndex)
01608                 {
01609 PORTNOTE("LiveEffects", "Removed use of LiveEffects")
01610 #ifndef EXCLUDE_FROM_XARALX
01611                 case 0:
01612                     {
01613                         OpDescriptor* pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_APPLY_LIVEEFFECT);
01614                         if (pOp != NULL)
01615                         {
01616                             OpLiveEffectParam Param;
01617                             Param.bIsDestructive = FALSE;
01618                             Param.strOpUnique = String(_T("Enhance"));
01619                             pOp->Invoke(&Param);
01620                         }
01621                     }
01622                     break;
01623                 case 1:
01624                     {
01625                         OpDescriptor* pOp = OpDescriptor::FindOpDescriptor(OPTOKEN_EDIT_LIVEEFFECT);
01626                         if (pOp != NULL)
01627                         {
01628                             OpLiveEffectParam Param;
01629                             Param.bIsDestructive = FALSE;
01630                             Param.strOpUnique = String(_T("Enhance"));
01631                             pOp->Invoke(&Param);
01632                         }
01633                     }
01634                     break;
01635 #endif
01636                 case 2:
01637                     {
01638 //                      XPEHost::EndEditSession(TRUE);
01639                     }
01640                     break;
01641                 case 3:
01642                     {
01643                         CBitmapCache* pCache = GetApplication()->GetBitmapCache();
01644                         pCache->DebugDump();
01645                     }
01646                     break;
01647                 case 4:
01648                     {
01649 //#if NEW_PASTEBOARD
01650                         Spread* pSpread = Document::GetSelectedSpread();
01651                         Spread* pNewSpread = NULL;
01652                         pSpread->NodeCopy((Node**)&pNewSpread);
01653                         if (pNewSpread)
01654                         {
01655                             pNewSpread->AttachNode(pSpread, NEXT);
01656                             pSpread->AdjustPasteboards();
01657                         }
01658 //#else
01659 //                      InformWarning(_R(IDS_SPREADTESTWARNING));
01660 //#endif
01661                     }
01662                     break;
01663                 }
01664             }
01665             break;
01666 
01667         case 11:        // Gerry Debug
01668             {
01669                 switch(CommandIndex)
01670                 {
01671                 case 0:
01672                     {
01673                         // Set the size of a slot to something weird
01674 //                      OILFixedDockingBar* pDockBar = (OILFixedDockingBar*)(GetMainFrame()->GetDockBar(DOCKBAR_RIGHT));
01675 //                      pDockBar->SetSlotSize(0, 150);
01676 //                      GetMainFrame()->RecalcLayout();     
01677                     }
01678                     break;
01679                 }
01680             }
01681             break;
01682 
01683     //  case n:
01684     //      Add other command group(s) here...
01685     }
01686 }
01687 
01688 
01689 
01690 
01691 /********************************************************************************************
01692 
01693 >   void DebugDlg::InvokeLateCommand(INT32 GroupIndex, INT32 CommandIndex)
01694 
01695     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
01696     Created:    03/08/96
01697 
01698     Inputs:     GroupIndex - indicates which command group is to be used
01699                 CommandIndex - the index of the command in the list - see DebugDlg::SetCommandList
01700 
01701     Purpose:    Invokes one of the debug commands after the dialogue has been closed and
01702                 the dialogue op has been ended. If you need to trigger an operation from this
01703                 debug dialogue, just write your standard command handler to set the global
01704                 CloseAndExecute variable, and add you command to this 'Late' command execution
01705                 table. You will notice when you Apply/Execute your command the dialogue will
01706                 disappear which is not that much of a disaster.
01707 
01708     Notes:      This only appears in DEBUG builds
01709 
01710 ********************************************************************************************/
01711 
01712 void DebugDlg::InvokeLateCommand(INT32 GroupIndex, INT32 CommandIndex)
01713 {
01714     String_256 Desc(TEXT("Doing debug command..."));
01715     Progress Hourglass((StringBase *) &Desc, -1, FALSE);    // Hourglass while we're busy
01716 
01717     switch (GroupIndex)
01718     {
01719         case 0:     // Jason's colour separation controls ------------------------------------
01720         break;
01721 
01722         case 1:     // Jason's misc controls -------------------------------------------------
01723         break;
01724 
01725         case 2:     // Mike's misc controls -------------------------------------------------
01726             switch (CommandIndex)
01727             {
01728                 case 0:
01729                 {
01730                 //  PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager();
01731                 //  if (pMarksMan!=NULL)
01732                 //      pMarksMan->ConstructCache();
01733                 }
01734                 break;
01735             }
01736             break;
01737 
01738     //  case 3:
01739     //      Add other late command group(s) here...
01740     }
01741 }
01742 
01743 
01744 #endif      // if _DEBUG

Generated on Sat Nov 10 03:45:00 2007 for Camelot by  doxygen 1.4.4