layer.cpp

Go to the documentation of this file.
00001 // $Id: layer.cpp 1361 2006-06-25 16:43:38Z 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 // Layer and LayerStatus classes  (removed from paper.cpp 15/4/94)
00100 
00101 
00102 #include "camtypes.h"
00103 #include "layer.h"
00104 //#include "simon.h"
00105 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "page.h"
00108 //#include "mario.h"
00109 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include "nodedoc.h"
00111 #include "blobs.h"
00112 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "aw_eps.h"
00114 #include "ccdc.h"
00115 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "nativeps.h"       // The old style EPS native filter, used in v1.1
00117 //#include "ben.h"
00118 #include "prdlgctl.h"
00119 #include "printctl.h"
00120 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 //#include "jason.h"
00122 #include "sglayer.h"
00123 #include "cameleps.h"
00124 #include "colourix.h"
00125 #include "colmsg.h"
00126 #include "cmxrendr.h"
00127 #include "ai_epsrr.h"
00128 //-#include "cmxexdc.h"
00129 //#include "tim.h"
00130 
00131 // WEBSTER - markn 15/1/97
00132 // Extra headers needed for Webster
00133 //#include "markn.h"
00134 #include "qualattr.h"
00135 
00136 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00137 #include "cxftags.h"
00138 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00139 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00140 
00141 #include "layermsg.h"   // layer messages
00142 //#include "prevwres.h" // _R(IDS_FRAMENAMEUNIQUEFORM) _R(IDS_TAG_LAYER_FRAMEPROPS) ...
00143 #include "slicehelper.h"
00144 #include "nbevcont.h"
00145 #include "ncntrcnt.h"
00146 #include "nodecont.h"
00147 #include "ndclpcnt.h"
00148 #include "lineattr.h"
00149 
00150 CC_IMPLEMENT_DYNAMIC(Layer, NodeRenderablePaper)          
00151 CC_IMPLEMENT_DYNAMIC(LayerMsgHandler,MessageHandler) 
00152 
00153 // Declare smart memory handling in Debug builds
00154 #define new CAM_DEBUG_NEW
00155 
00156 #define COL_MAX 255
00157 INT32 Layer::GuideLayerRed  = COL_MAX;
00158 INT32 Layer::GuideLayerGreen    = 0;
00159 INT32 Layer::GuideLayerBlue = 0;
00160 
00161 LayerMsgHandler* Layer::pLayerMsgHandler = NULL;
00162 
00163 /*********************************************************************************************
00164 
00165     Preference: ActiveLayerVisibleAndEditable
00166     Section:    Layers
00167     Range:      0 - 1
00168     Purpose:    Dictates whether the active layer is automatically made visible and editable
00169                 or whether it is left in its last state which might include it being invisible.
00170                 Defaults to the old system (FALSE).
00171                 
00172                 It is controlled by the "Current layer always visible & editable" switch in
00173                 the General options tab. 
00174 
00175     SeeAlso:    NodeRenderableBounded::Init();
00176 
00177 **********************************************************************************************/ 
00178 
00179 BOOL Layer::ActiveLayerVisibleAndEditable = FALSE;
00180 
00181 /*********************************************************************************************
00182 
00183     Preference: EnableLayerCacheing
00184     Section:    Layers
00185     Range:      0 - 2
00186     Purpose:    Control whether layers are cached or not. 
00187 
00188     SeeAlso:    NodeRenderableBounded::Init();
00189 
00190 **********************************************************************************************/ 
00191 
00192 INT32 Layer::EnableLayerCacheing = 1;
00193 
00194 /*********************************************************************************************
00195 
00196 >    static BOOL Layer::Init()
00197 
00198      Author:    Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00199      Created:   10/10/95
00200      Inputs:    -
00201      Outputs:   -
00202      Returns:   -
00203      Purpose:   Does any layer initialisation necessary.
00204                 Declares some layer INI settings
00205                 Creates a layer message handler
00206      Errors:    
00207 
00208 **********************************************************************************************/
00209  
00210 BOOL Layer::Init()
00211 {
00212     BOOL ok = TRUE;
00213 
00214 #if !defined(EXCLUDE_FROM_RALPH)
00215     // Declare the section that the preferences for layers will live in
00216     if (ok) ok= Camelot.DeclareSection(TEXT("Layers"), 3);
00217 
00218     // declare the guideline colour vars
00219     if (ok) ok= Camelot.DeclarePref(TEXT("Layers"), TEXT("GuideLayerRed"),  &Layer::GuideLayerRed,   0, COL_MAX);
00220     if (ok) ok= Camelot.DeclarePref(TEXT("Layers"), TEXT("GuideLayerGreen"),&Layer::GuideLayerGreen, 0, COL_MAX);
00221     if (ok) ok= Camelot.DeclarePref(TEXT("Layers"), TEXT("GuideLayerBlue"), &Layer::GuideLayerBlue,  0, COL_MAX);
00222 #endif
00223 
00224     if (ok)
00225     {
00226         pLayerMsgHandler = new LayerMsgHandler;
00227         ok = (pLayerMsgHandler != NULL);
00228     }
00229 
00230     return ok;
00231 }
00232 
00233 /*********************************************************************************************
00234 
00235 >    static void Layer::Deinit()
00236 
00237      Author:    Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00238      Created:   10/10/95
00239      Inputs:    -
00240      Outputs:   -
00241      Returns:   -
00242      Purpose:   Deinits the layer system.
00243                 This deletes the layer message handler
00244      Errors:    
00245 
00246 **********************************************************************************************/
00247 
00248 void Layer::Deinit()
00249 {
00250     if (pLayerMsgHandler != NULL)
00251     {
00252         delete pLayerMsgHandler;
00253         pLayerMsgHandler = NULL;
00254     }
00255 } 
00256 
00257 /*********************************************************************************************
00258 
00259 >    Layer::Layer() 
00260 
00261      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00262      Created:   13/5/93
00263      Inputs:    -
00264      Outputs:   -
00265      Returns:   -
00266               
00267      Purpose: This constructor creates a Layer linked to no other nodes, with all status
00268               flags false, and NULL bounding and pasteboard rectangles.            
00269             
00270      Errors:    
00271 
00272 **********************************************************************************************/
00273  
00274 
00275 Layer::Layer(): NodeRenderablePaper()
00276 { 
00277     // Set all layer flags to their defaults 
00278     Visible     = TRUE; 
00279     Locked      = FALSE; 
00280     Printable   = TRUE; 
00281     Background  = FALSE; 
00282     Outline     = FALSE;
00283     Guide       = FALSE;
00284     Active      = FALSE; 
00285 
00286     pGuideColour= NULL;
00287     pIndexedGuideColour = NULL;
00288 
00289     m_PageBackground = FALSE;
00290 
00291     // Frame related items
00292     m_Solid      = FALSE;
00293     m_Overlay    = FALSE;
00294     m_Edited     = FALSE;
00295     m_Frame      = FALSE;
00296     m_HiddenFrame   = FALSE;
00297     m_FrameDelay = 10;
00298 
00299     m_pReferencedBitmap = NULL; // DO NOT DELETE as it is a reference
00300 }                    
00301  
00302 /*********************************************************************************************
00303 
00304 >    Layer::~Layer() 
00305 
00306      Author:    Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00307      Created:   10/10/95
00308      Purpose:   Default destructor
00309      Errors:    
00310 
00311 **********************************************************************************************/
00312 
00313 Layer::~Layer()
00314 { 
00315     if (pGuideColour != NULL)
00316         delete pGuideColour;
00317 
00318     if (pIndexedGuideColour != NULL)
00319         delete pIndexedGuideColour;
00320 
00321     m_pReferencedBitmap = NULL; // DO NOT DELETE as it is a reference
00322 }                    
00323  
00324 /***********************************************************************************************
00325 
00326 >   Layer::Layer
00327     (
00328         Node* ContextNode,  
00329         AttachNodeDirection Direction,  
00330         String_256& LayerID, 
00331         BOOL Locked = FALSE, 
00332         BOOL Mangled = FALSE,  
00333         BOOL Marked = FALSE, 
00334         BOOL Selected = FALSE, 
00335         BOOL Renderable = FALSE
00336     )
00337 
00338     Author:  Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00339     Created: 26/4/93             
00340     
00341     Inputs: ContextNode: Pointer to a node which this node is to be attached to.     
00342     
00343             Direction: 
00344             
00345                 Specifies the direction in which this node is to be attached to the 
00346                 ContextNode. The values this variable can take are as follows: 
00347                                   
00348                 PREV      : Attach node as a previous sibling of the context node
00349                 NEXT      : Attach node as a next sibling of the context node
00350                 FIRSTCHILD: Attach node as the first child of the context node
00351                 LASTCHILD : Attach node as a last child of the context node                               
00352                           
00353             LayerID: String which uniquely identifies layer within the spread   
00354                                   
00355             The remaining inputs specify the status of the node: 
00356             
00357             Locked:     Is node locked ?
00358             Mangled:    Is node mangled ?
00359             Marked:     Is node marked ?
00360             Selected:   Is node selected ?
00361             
00362     Outputs:   -
00363     Returns:   - 
00364     Purpose: This method initialises the node and links it to ContextNode in the
00365              direction specified by Direction. All neccesary tree links are
00366              updated.     
00367              
00368     Errors:  An assertion error will occur if ContextNode is NULL
00369 
00370 
00371 ***********************************************************************************************/
00372 
00373 Layer::Layer(Node* ContextNode,  
00374                     AttachNodeDirection Direction,
00375                     const String_256 &LayerID,  
00376                     BOOL NodeLocked, 
00377                     BOOL Mangled,  
00378                     BOOL Marked, 
00379                     BOOL Selected 
00380                    ): NodeRenderablePaper(ContextNode, Direction, NodeLocked, Mangled, 
00381                                     Marked, Selected)
00382 { 
00383     // Set all layer flags to their defaults 
00384     Visible     = TRUE; 
00385     Locked      = FALSE; 
00386     Printable   = TRUE; 
00387     Background  = FALSE; 
00388     Outline     = FALSE;
00389     Guide       = FALSE;
00390     Active      = FALSE; 
00391 
00392     m_PageBackground = FALSE;
00393 
00394     // Frame related flags
00395     m_Overlay       = FALSE;
00396     m_Solid         = FALSE;
00397     m_Edited        = FALSE;
00398     m_Frame         = FALSE;
00399     m_HiddenFrame   = FALSE;
00400     m_FrameDelay    = 10;
00401 
00402     m_pReferencedBitmap = NULL; // DO NOT DELETE as it is a reference
00403 
00404     pGuideColour    = NULL;
00405     pIndexedGuideColour = NULL;
00406 
00407     LayerSt.StringLayerID = LayerID; 
00408 }     
00409 
00410 /********************************************************************************************
00411 
00412 >   BOOL Layer::NeedsToRender(RenderRegion *pRender)
00413 
00414     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00415     Created:    07/02/94
00416     Inputs:     pRender - A pointer to the current render region (NULL if none)
00417     Returns:    TRUE  => This node should be rendered,
00418                 FALSE => This node does not need to be rendered.
00419     Purpose:    Virtual function - this version decides whether or not a layer should be
00420                 rendered according to the ExcludeLockedLayers flags and the state of the
00421                 layer itself.
00422     SeeAlso:    Node::NeedsToRender
00423 
00424 ********************************************************************************************/
00425 
00426 SubtreeRenderState Layer::RenderSubtree(RenderRegion *pRender, Node** ppNextNode, BOOL bClip)
00427 {
00428     if (pRender==NULL)
00429         return SUBTREE_ROOTANDCHILDREN;
00430 
00431     // ignore hit detection render regions when the layer is locked.
00432     if (pRender->IsHitDetect() && IsLocked())
00433         return SUBTREE_NORENDER;
00434 
00435 
00436     // If we are printing then we do special things
00437     else if (pRender->IsPrinting())
00438     {
00439         // Ignore non-printable layers (i.e. don't ever print background layers)
00440         if (!IsPrintable())
00441             return SUBTREE_NORENDER;
00442 
00443         // Added this since we want to print what we see - might need looking at ?
00444         return IsVisible() ? SUBTREE_ROOTANDCHILDREN : SUBTREE_NORENDER;
00445 
00446         // Otherwise, get the print control
00447         
00448         CCPrintInfo *pInfo = CCPrintInfo::GetCurrent();
00449 //      ERROR2IF(pInfo == NULL, FALSE, "No print info for printing render region!");
00450         PrintControl *pPrCtrl = NULL;
00451         if (pInfo != NULL)
00452             pPrCtrl = pInfo->GetPrintControl();
00453 //      ERROR2IF(pPrCtrl == NULL, FALSE, "No print control for printing render region!");
00454 
00455         // Ok, work out what whether we should print this layer...
00456         if (pPrCtrl == NULL || pPrCtrl->GetPrintLayers() == PRINTLAYERS_VISIBLEFOREGROUND)
00457         {
00458             // Print only visible foreground layers.
00459             return IsVisible() ? SUBTREE_ROOTANDCHILDREN : SUBTREE_NORENDER;
00460         }
00461         else
00462         {
00463             // Print all foreground layers, regardless of visibility.
00464             return SUBTREE_ROOTANDCHILDREN;
00465         }
00466 
00467     }
00468     else if (IS_A(pRender,CamelotEPSRenderRegion))
00469         return (IsVisible() && IsPrintable()) ? SUBTREE_ROOTANDCHILDREN : SUBTREE_NORENDER;
00470     else
00471     {
00472         // Normal rendering
00473         //
00474         // Ask Helper function to set up cacheing for me...
00475         //
00476         // If we can find a cached bitmap for this node and render it
00477         // Then tell the renderer to move on without doing any more...
00478         // Else we might have set up a capture, in which case render as normal
00479         // and let RenderAfterSubtree catch the capture at the other end
00480         switch (Layer::EnableLayerCacheing)
00481         {
00482         // Value 1 means enable all layer cacheing
00483         case 1:
00484             if (IsVisible() && !IsGuide() && RenderCached(pRender))
00485             {
00486                 return SUBTREE_NORENDER;
00487             }
00488         break;
00489 
00490         // Value 2 means enable layer cacheing for all but the active layer
00491         case 2:
00492             if (IsVisible() && !IsGuide() && !IsActive() && RenderCached(pRender))
00493             {
00494                 return SUBTREE_NORENDER;
00495             }
00496         break;
00497 
00498         }
00499 
00500         // Simple visibility check...
00501         return IsVisible() ? SUBTREE_ROOTANDCHILDREN : SUBTREE_NORENDER;
00502     }
00503 
00504     return SUBTREE_NORENDER;
00505 }
00506 
00507 
00508 
00509 /********************************************************************************************
00510 
00511 >   void Layer::RenderAfterSubtree(RenderRegion* pRender)
00512 
00513     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00514     Created:    10/08/2004
00515     Inputs:     pRender - The region to render into
00516     Purpose:    Capture the group as a cached bitmap
00517 
00518 ********************************************************************************************/
00519 
00520 void Layer::RenderAfterSubtree(RenderRegion* pRegion)
00521 {
00522     // Call Helper function to run all my cacheing functionality for me...
00523     if (IsVisible())
00524         CaptureCached(pRegion);
00525 }
00526 
00527 
00528 
00529 /********************************************************************************************
00530 
00531 >   BOOL Layer::NeedsToExport(RenderRegion *pRender, BOOL VisibleLayersOnly = FALSE,
00532                               BOOL CheckSelected = FALSE)
00533 
00534     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00535     Created:    24/03/94
00536     Inputs:     pRender - A pointer to the current export region (NULL if none)
00537                 VisibleLayersOnly - TRUE => remove nodes which are on invisible layers
00538                                        - FALSE => export everything
00539                 CheckSelected - TRUE => we check if object selected and only export selected bjects
00540                               - FALSE => we don't bother checking for selection or not
00541     Returns:    TRUE => export this node.
00542     Purpose:    Indicate that we want to export layers.
00543                 Now takes a parameter to say whether we want to take notice of the layers
00544                 visible status when deciding about exporting it or not.
00545     SeeAlso:    Layer::NeedsToRender
00546 
00547 ********************************************************************************************/
00548 
00549 BOOL Layer::NeedsToExport(RenderRegion *pRender, BOOL VisibleLayersOnly, BOOL CheckSelected)
00550 {
00551 #ifdef DO_EXPORT
00552     // If this is export as a ART file, we want to save all the layers
00553     if (pRender->IS_KIND_OF(NativeRenderRegion))
00554         return TRUE;
00555 
00556     // If there's a filter running
00557     // and it's trying to export just one layer
00558     // then return FALSE if this layer is NOT the layer in question
00559     // else fall through to the normal logic...
00560     Filter* pFilter = pRender->GetFilter();
00561     if (pFilter)
00562     {
00563         Layer* pFilterLayer = pFilter->GetSoleLayer();
00564         if (pFilterLayer!=NULL && pFilterLayer!=this)
00565             return FALSE;
00566     }
00567 
00568     // if this is an export as a CMX file, we don't want invisible layers
00569     // as CMX doesn't support non-visible stuff so we can't save it and
00570     // get the file looking the same
00571 PORTNOTE("cmx", "Removed use of CMXRenderRegion")
00572 #ifndef EXCLUDE_FROM_XARALX
00573     if(!IsVisible() && pRender->IS_KIND_OF(CMXRenderRegion))
00574         return FALSE;
00575 #endif
00576 
00577     // Guide layers only export to Native render regions
00578     if (Guide)
00579         return FALSE;
00580 
00581     // Changed so that instead of always returning True there is a parameter which
00582     // defaults to the old state whereby it always returns True but can be set so
00583     // that we return the visible state of the layer and hence this dictates whether
00584     // only visible layers will be exported.
00585     if (VisibleLayersOnly)
00586         return (IsVisible());
00587     else
00588         return(TRUE);
00589 #else
00590     return FALSE;
00591 #endif
00592 }
00593 
00594 
00595 
00596 
00597 /********************************************************************************************
00598 
00599 >   BOOL Layer::IsLayer() const
00600 
00601     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00602     Created:    25/11/94
00603     Returns:    TRUE => This node is a layer
00604     Purpose:    Indicate that we are a layer (overrides function in Node).
00605     SeeAlso:    Node::IsLayer
00606 
00607 ********************************************************************************************/
00608 
00609 BOOL Layer::IsLayer() const
00610 {
00611     return TRUE;
00612 }
00613 
00614 
00615 
00616 
00617 /********************************************************************************************
00618 
00619 >   virtual String Layer::Describe(BOOL Plural, BOOL Verbose = TRUE)
00620 
00621     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00622     Created:    21/6/93
00623     Inputs:     Plural: Flag indicating if the string description should be plural or
00624                         singular. 
00625     Outputs:    -
00626     Retuns:     Description of the object 
00627     Purpose:    To return a description of the Node object in either the singular or the 
00628                 plural. This method is called by the DescribeRange method.
00629                 
00630                 The description will always begin with a lower case letter.   
00631                 
00632     Errors:     A resource exception will be thrown if a problem occurs when loading the 
00633                 string resource. 
00634     SeeAlso:    -
00635 
00636 ********************************************************************************************/
00637 /*
00638     Technical Notes:
00639     
00640     The String resource identifiers should be of the form: ID_<Class>_DescriptionS for the 
00641     singular description and ID_<Class>_DescriptionP for the plural. 
00642 */              
00643               
00644 String Layer::Describe(BOOL Plural, BOOL Verbose) 
00645 {     
00646     if (Plural)
00647         return(String(_R(IDS_LAYER_DESCRP)));  
00648     else
00649         return(String(_R(IDS_LAYER_DESCRS))); 
00650 }; 
00651  
00652 
00653 /*********************************************************************************************
00654 
00655 >    DocRect Layer::GetPasteboardRectangle(BOOL Pixelise = TRUE, View *pView = NULL) const
00656 
00657      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00658      Created:   13/5/93
00659      Inputs:    Pixelise - whether or not to pixelise the pasteboard rectangle before
00660                            returning it.
00661                 pView - the view to pixelise to (not used if Pixelise is FALSE).
00662      Outputs:   The objects pasteboard rectangle
00663      Returns:   -
00664               
00665      Purpose:   For obtaining the layer's pasteboard rectangle which is actually the 
00666                 pasteboard rectangle of its parent spread node.  
00667             
00668      Errors:    
00669 
00670 **********************************************************************************************/
00671 
00672 DocRect Layer::GetPasteboardRect(BOOL Pixelise, View *pView) const
00673 {
00674     // Ensure that the parent of the Layer object is a spread
00675     ERROR2IF(!Parent->IsKindOf(CC_RUNTIME_CLASS(Spread)),
00676             DocRect(0,0,0,0),
00677             "The parent of a layer node was not a spread node");
00678 
00679     return ( ((Spread*)Parent)->GetPasteboardRect(Pixelise, pView) );
00680 }       
00681                 
00682     
00683 /***********************************************************************************************
00684 > Node* Layer::SimpleCopy()  
00685 
00686     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00687     Created:    28/4/93
00688     
00689     Inputs:         - 
00690     Outputs:    
00691     Returns:    A copy of the node, or NULL if memory runs out
00692          
00693     Purpose:    This method returns a shallow copy of the node with all Node pointers NULL. 
00694                 The function is virtual, and must be defined for all derived classes.  
00695            
00696     Errors:     If memory runs out when trying to copy, then ERROR is called with an out of memory
00697                 error and the function returns NULL. 
00698       
00699     Scope:      protected       
00700 **********************************************************************************************/
00701 
00702 Node* Layer::SimpleCopy()
00703 {
00704     Layer* NodeCopy; 
00705     NodeCopy = new Layer();  
00706     //ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
00707     if (NodeCopy != NULL)
00708         CopyNodeContents(NodeCopy);   
00709     return (NodeCopy);
00710 }           
00711   
00712 #ifdef _DEBUG  
00713 
00714 void Layer::ShowDebugTreeDetails() const
00715 {                                 
00716     TRACE( _T("Layer ")); 
00717     Node::ShowDebugTreeDetails(); 
00718 }            
00719 
00720 #endif    
00721  
00722 
00723 /***********************************************************************************************
00724 >   void Layer::CopyNodeContents(Layer* NodeCopy)
00725 
00726     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00727     Created:    10/8/94
00728     Inputs:     NodeCopy = ptr to the layer node that needs to become a copy of this layer
00729     Outputs:    The layer at *NodeCopy is a identical copy of this layer
00730     Returns:    -
00731     Purpose:    This method copies the node's contents to the node pointed to by NodeCopy.
00732     Errors:     An assertion failure will occur if NodeCopy is NULL
00733     Scope:      protected
00734                                      
00735 ***********************************************************************************************/
00736 
00737 void Layer::CopyNodeContents(Layer* NodeCopy)
00738 {
00739     // Ensure the pointer's not null
00740     ENSURE(NodeCopy != NULL,"Trying to copy a node's contents into a NULL node");  
00741 
00742     // Get immediate base class to copy its bits
00743     NodeRenderablePaper::CopyNodeContents(NodeCopy); 
00744 
00745     // Copy layer-specific stuff now.
00746     NodeCopy->LayerSt = LayerSt;
00747 
00748     NodeCopy->Active = Active;
00749     NodeCopy->Visible = Visible;
00750     NodeCopy->Locked = Locked;
00751     NodeCopy->Printable = Printable;
00752     NodeCopy->Background = Background;
00753     NodeCopy->Outline = Outline;
00754     NodeCopy->Guide = Guide;
00755 
00756     NodeCopy->Active = Active;
00757     NodeCopy->Visible = Visible;
00758     NodeCopy->Locked = Locked;
00759     NodeCopy->Printable = Printable;
00760     NodeCopy->Background = Background;
00761     NodeCopy->Outline = Outline;
00762     NodeCopy->Guide = Guide;
00763 
00764     // Copy across the useful frame related information
00765     NodeCopy->m_FrameDelay      = m_FrameDelay;
00766     NodeCopy->m_Overlay         = m_Overlay;
00767     NodeCopy->m_Solid           = m_Solid;
00768     NodeCopy->m_Frame           = m_Frame;
00769     NodeCopy->m_HiddenFrame     = m_HiddenFrame;
00770     NodeCopy->m_Edited          = m_Edited;
00771     NodeCopy->m_PageBackground  = m_PageBackground;
00772 }       
00773    
00774                                              
00775 /***********************************************************************************************
00776 >   void Layer::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00777 
00778     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00779     Created:    18/12/2003
00780     Outputs:    -
00781     Purpose:    Polymorphically copies the contents of this node to another
00782     Errors:     An assertion failure will occur if NodeCopy is NULL
00783     Scope:      protected
00784                                      
00785 ***********************************************************************************************/
00786 
00787 void Layer::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00788 {
00789     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00790     ENSURE(IS_A(pNodeCopy, Layer), "PolyCopyNodeContents given wrong dest node type");
00791 
00792     if (IS_A(pNodeCopy, Layer))
00793         CopyNodeContents((Layer*)pNodeCopy);
00794 }
00795 
00796 
00797 
00798 /***********************************************************************************************
00799 
00800 >   Layer* Layer::FindNextLayer(BOOL ExcludeInvisible = FALSE, BOOL ExcludeLocked = FALSE)
00801 
00802     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00803     Created:    21/01/94
00804     Inputs:     ExcludeInvisible    Do not consider any invisible layer.
00805                 ExcludeLocked       Do not consider any locked layer.
00806     Outputs:    -
00807     Returns:    The next sibling layer of this node, or NULL if there are no more layers 
00808     Purpose:    To find the next sibling layer
00809 
00810     Notes:      Karim 08/08/2000
00811                 Extended this method so we can also exclude locked layers from the search.
00812 
00813     Errors:     -
00814     SeeAlso:    -
00815 
00816 ***********************************************************************************************/
00817 
00818 
00819 Layer* Layer::FindNextLayer(BOOL ExcludeInvisible, BOOL ExcludeLocked)
00820 {
00821     Node* CurrentNode = FindNext();
00822     while (CurrentNode != NULL)
00823     {
00824         if (CurrentNode->IsLayer())
00825         {
00826             Layer* l = (Layer*) CurrentNode;
00827             if (ExcludeInvisible && !l->IsVisible())
00828             {
00829                 // we're ignoring invisible layers and this layer is invisible.
00830             }
00831             else if (ExcludeLocked && l->IsLocked())
00832             {
00833                 // we're ignoring locked layers and this layer is locked.
00834             }
00835             else
00836             {
00837                 // this one's ok - return it.
00838                 return l;
00839             }
00840         }
00841 
00842         CurrentNode = CurrentNode->FindNext();
00843     }
00844 
00845     // no layer found.
00846     return NULL;
00847 }
00848 
00849 
00850 /***********************************************************************************************
00851 
00852 >   Layer* Layer::FindPrevLayer(BOOL ExcludeInvisible = FALSE, BOOL ExcludeLocked = FALSE)
00853 
00854     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00855     Created:    9/8/94
00856     Inputs:     ExcludeInvisible    Do not consider any invisible layer.
00857                 ExcludeLocked       Do not consider any locked layer.
00858     Outputs:    -
00859     Returns:    The prev sibling layer of this node, or NULL if there are no more layers 
00860     Purpose:    To find the prev sibling layer
00861 
00862     Notes:      Karim 08/08/2000
00863                 Extended this method so we can also exclude locked layers from the search.
00864 
00865     Errors:     -
00866     SeeAlso:    -
00867 
00868 ***********************************************************************************************/
00869 
00870 
00871 Layer* Layer::FindPrevLayer(BOOL ExcludeInvisible, BOOL ExcludeLocked)
00872 {
00873     Node* CurrentNode = FindPrevious();
00874     while (CurrentNode != NULL)
00875     {
00876         if (CurrentNode->IsLayer())
00877         {
00878             Layer* l = (Layer*) CurrentNode;
00879             if (ExcludeInvisible && !l->IsVisible())
00880             {
00881                 // we're ignoring invisible layers and this layer is invisible.
00882             }
00883             else if (ExcludeLocked && l->IsLocked())
00884             {
00885                 // we're ignoring locked layers and this layer is locked.
00886             }
00887             else
00888             {
00889                 // this one's ok - return it.
00890                 return l;
00891             }
00892         }
00893 
00894         CurrentNode = CurrentNode->FindPrevious(); 
00895     }
00896 
00897     // no layer found.
00898     return (NULL);
00899 }
00900 
00901 /***********************************************************************************************
00902 
00903 >   Layer* Layer::FindNextFrameLayer()
00904 
00905     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00906     Created:    23/04/97
00907     Returns:    The next sibling frame layer of this node, or NULL if there are no more layers 
00908     Purpose:    To find the next sibling frame layer
00909     Errors:     -
00910     SeeAlso:    FindPrevFrameLayer; FindPrevLayer;
00911 
00912 ***********************************************************************************************/
00913   
00914 Layer* Layer::FindNextFrameLayer()
00915 {
00916     Layer* pCurrentLayer = FindNextLayer(); 
00917     while (pCurrentLayer != NULL)
00918     {
00919         // Frame layers cannot be guide layers or background layers
00920         if (pCurrentLayer->IsFrame() && !pCurrentLayer->IsPageBackground() && !pCurrentLayer->IsGuide())
00921         { 
00922             return pCurrentLayer;     
00923         }
00924 
00925         pCurrentLayer = pCurrentLayer->FindNextLayer(); 
00926     }
00927     
00928     // No next frame layer found
00929     return NULL;
00930 }                                                               
00931   
00932 
00933 /***********************************************************************************************
00934 
00935 >   Layer* Layer::FindPrevFrameLayer()
00936 
00937     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00938     Created:    23/04/97
00939     Returns:    The previous sibling frame layer of this node, or NULL if there are no more layers 
00940     Purpose:    To find the prev sibling frame layer
00941     Errors:     -
00942     SeeAlso:    FindNextFrameLayer; FindNextLayer;
00943 
00944 ***********************************************************************************************/
00945   
00946 Layer* Layer::FindPrevFrameLayer()
00947 {
00948     Layer* pCurrentLayer = FindPrevLayer(); 
00949     while (pCurrentLayer != NULL)
00950     {
00951         // Frame layers cannot be guide layers or background layers
00952         if (pCurrentLayer->IsFrame() && !pCurrentLayer->IsPageBackground() && !pCurrentLayer->IsGuide())
00953         { 
00954             return pCurrentLayer;     
00955         }
00956 
00957         pCurrentLayer = pCurrentLayer->FindPrevLayer(); 
00958     }
00959 
00960     // No next frame layer found
00961     return NULL;
00962 }                                                               
00963 
00964 /***********************************************************************************************
00965 
00966 >    virtual BOOL Layer::HidingNode()
00967 
00968      Author:    Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00969      Created:   17/6/97
00970      Returns:   TRUE if all was ok. FALSE if an error occured.
00971      Purpose:   This virtual function is called whenever the node is hidden.
00972                 It allows the node do things like 'optimise' itself to use less memory or
00973                 send a message to let others know it is being hidden etc.
00974 
00975                 ALWAYS CALL THE BASE CLASS' FUNCTION FROM YOUR OVERRIDDEN FUNCTION.
00976 
00977 ***********************************************************************************************/
00978 
00979 BOOL Layer::HidingNode()
00980 {
00981     // Call the base class first
00982     if (!Node::HidingNode())
00983         return FALSE;
00984 
00985     // Check if we are the active layer, if we are then try and make
00986     // another layer active
00987     if (IsActive())
00988     {
00989         // Hiding an active layer
00990         TRACEUSER( "Neville", _T("++++++ Hiding the active layer\n"));
00991 
00992 // Included in Camelot2 for frame/layer integration - RanbirR - 06/11/97
00993 //#ifdef WEBSTER
00994         if (!IsFrame())
00995         {
00996             // Choose the next/prev layer to be the new active one
00997             Layer* pNewActiveLayer = FindPrevLayer();
00998             if (pNewActiveLayer == NULL)
00999                 pNewActiveLayer = FindNextLayer();
01000             if (pNewActiveLayer != NULL)
01001                 LayerSGallery::MakeActiveLayer(pNewActiveLayer);
01002         }
01003         else
01004         {
01005 PORTNOTE("other", "Disabled frame gallery")
01006 #ifndef EXCLUDE_FROM_XARALX
01007             // Choose the next/prev frame layer to be the new active one
01008             Layer* pNewActiveLayer = FindPrevFrameLayer();
01009             if (pNewActiveLayer == NULL)
01010                 pNewActiveLayer = FindNextFrameLayer();
01011             if (pNewActiveLayer != NULL)
01012                 FrameSGallery::MakeActiveLayer(pNewActiveLayer);
01013 #endif
01014         }
01015     }
01016 
01017     // If we are hiding the page background layer then we must mark all frame layers
01018     // as edited as they must be regenerated.
01019     // Use frame layers as only these will have been captured
01020     if (IsPageBackground())
01021     {
01022         Node * pParentNode = FindParent();
01023         Spread * pSpread = NULL;
01024         if (pParentNode->IsKindOf(CC_RUNTIME_CLASS(Spread)))
01025             pSpread = (Spread*)pParentNode;
01026         if (pSpread)
01027         {
01028             Layer* pLayer = pSpread->FindFirstFrameLayer();
01029             while (pLayer != NULL)
01030             {
01031                 // This is just as a double check
01032                 if (pLayer->IsPseudoFrame())
01033                 {
01034                     // Set the edited flag on the layer
01035                     pLayer->SetEdited(TRUE);
01036 #ifdef _DEBUG
01037                     // Tell the frame gallery to update its display of the frame
01038                     BROADCAST_TO_ALL(LayerMsg(pLayer, LayerMsg::REDRAW_LAYER));
01039 #endif
01040                 }
01041 
01042                 // Move to the next frame layer in the animation
01043                 pLayer = pLayer->FindNextFrameLayer();
01044             }
01045         }
01046     }
01047     return TRUE;
01048 }
01049 
01050 /********************************************************************************************
01051 
01052 >   LayerStatus::LayerStatus() 
01053 
01054     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01055     Created:    14/1/94
01056     Inputs:     -
01057     Outputs:    -
01058     Returns:    -
01059     Purpose:    LayerStatus constructor
01060     Errors:     -
01061     SeeAlso:    -
01062 
01063 ********************************************************************************************/
01064 
01065  
01066 LayerStatus::LayerStatus() 
01067 {
01068 }
01069 
01070 /********************************************************************************************
01071 
01072 >   LayerStatus::LayerStatus(LayerStatus& ls) 
01073 
01074     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01075     Created:    14/1/94
01076     Inputs:     -
01077     Outputs:    -
01078     Returns:    -
01079     Purpose:    LayerStatus copy constructor 
01080     Errors:     -
01081     SeeAlso:    -
01082 
01083 ********************************************************************************************/
01084 
01085 
01086 
01087 LayerStatus::LayerStatus(LayerStatus& ls) 
01088 {
01089 //  Flags.Visible = ls.Flags.Visible; 
01090 //  Flags.Locked = ls.Flags.Locked;
01091 //  Flags.Printable = ls.Flags.Printable;
01092 //  Flags.Background = ls.Flags.Background;
01093 //  Flags.Outline = ls.Flags.Outline;
01094 
01095     StringLayerID = ls.StringLayerID; 
01096 }
01097 
01098 /********************************************************************************************
01099 
01100 >   LayerStatus::operator==(LayerStatus Status)
01101 
01102     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01103     Created:    14/1/94
01104     Inputs:     -
01105     Outputs:    -
01106     Returns:    -
01107     Purpose:    LayerStatus == operator
01108     Errors:     -
01109     SeeAlso:    -
01110 
01111 ********************************************************************************************/
01112 
01113 
01114 INT32 LayerStatus::operator==(LayerStatus Status)
01115 {
01116     return ( 
01117 //           (Flags.Visible    == Status.Flags.Visible) && 
01118 //           (Flags.Locked     == Status.Flags.Locked) && 
01119 //           (Flags.Printable  == Status.Flags.Printable) && 
01120 //           (Flags.Background == Status.Flags.Background) && 
01121 //           (Flags.Outline    == Status.Flags.Outline) &&
01122              (StringLayerID    == Status.StringLayerID)
01123            ); 
01124 }
01125 
01126 
01127 // Query Layer status functions 
01128 // -----------------------------------------------------------------------------------------
01129 
01130 /********************************************************************************************
01131 
01132 >   Document* Layer::FindDocument()
01133 
01134     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01135     Created:    17/8/94
01136     Inputs:     -
01137     Outputs:    -
01138     Returns:    Finds the Document object that contains the tree that contains this layer, or NULL (God forbit)
01139     Purpose:    This should be able to return the document associated with this layer.
01140                 If not, then this program is a worthless piece of junk and way beyond repair
01141     Errors:     -
01142     SeeAlso:    -
01143 
01144 ********************************************************************************************/
01145 
01146 Document* Layer::FindDocument()
01147 {
01148     Node* pThisNodeDoc = FindParent(CC_RUNTIME_CLASS(NodeDocument));
01149 
01150     if (pThisNodeDoc != NULL)
01151     {
01152         List* pList = &GetApplication()->Documents;
01153 
01154         if (pList != NULL)
01155         {
01156             Document* pDoc = (Document*) pList->GetHead();
01157 
01158             while (pDoc != NULL)
01159             {
01160                 Node* pNodeDoc = pDoc->GetFirstNode();
01161                 if (pNodeDoc != NULL)
01162                     pNodeDoc = pNodeDoc->FindNext(CC_RUNTIME_CLASS(NodeDocument));
01163 
01164                 if (pNodeDoc == pThisNodeDoc)
01165                     return (pDoc);
01166 
01167                 pDoc = (Document*) pList->GetNext(pDoc);
01168             }
01169         }
01170     }
01171 
01172     return NULL;
01173 }
01174 
01175 /********************************************************************************************
01176 
01177 >   BOOL Layer::BelongsToDocument(Document* pDoc)
01178 
01179     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01180     Created:    12/8/94
01181     Inputs:     pDoc = ptr to the document
01182     Outputs:    -
01183     Returns:    TRUE if the layer belongs to the current document
01184     Purpose:    Checks to see if this layer belongs to the document, i.e. the node is part
01185                 of the tree that is attached to the given document. 
01186     Errors:     -
01187     SeeAlso:    -
01188 
01189 ********************************************************************************************/
01190 // A quickie for Alpha release on 15/8/94                                                             
01191 // THIS FUNC IS IN THE WRONG PLACE!!!
01192 // It should be a member of Document and have a prototype something like this -
01193 //
01194 //  BOOL Document::ContainsNode(Node* pNode)
01195 //
01196 // Didn't have time to wait for a rebuild after changing document.h
01197 
01198 BOOL Layer::BelongsToDocument(Document* pDoc)
01199 {
01200     ENSURE(pDoc != NULL,"Get a NULL pDoc");
01201     if (pDoc == NULL) return FALSE;
01202 
01203     Node* pTreeStart = pDoc->GetFirstNode();
01204 
01205     ENSURE(pTreeStart != NULL,"This doc doesn't have a tree start node");
01206 
01207     Node* pNodeDoc     = pTreeStart->FindNext(CC_RUNTIME_CLASS(NodeDocument));
01208     Node* pThisNodeDoc = FindParent(CC_RUNTIME_CLASS(NodeDocument));
01209 
01210     ENSURE(pNodeDoc     != NULL,"This doc has no NodeDocument node");
01211     ENSURE(pThisNodeDoc != NULL,"This layer has no NodeDocument parent node");
01212 
01213     BOOL ok = ((pNodeDoc != NULL) && (pThisNodeDoc != NULL) && (pNodeDoc == pThisNodeDoc));
01214 
01215     if( !ok )
01216     {
01217         TRACEUSER( "MarkN", _T("-------\n"));
01218         TRACEUSER( "MarkN", _T("pDoc            = %ld 0x%p\n"),pDoc,pDoc);
01219         TRACEUSER( "MarkN", _T("pLayer          = %ld 0x%p\n"),this,this);
01220         TRACEUSER( "MarkN", _T("Layer's NodeDoc = %ld 0x%p\n"),pThisNodeDoc,pThisNodeDoc);
01221         TRACEUSER( "MarkN", _T("pDoc's  NodeDoc = %ld 0x%p\n"),pNodeDoc,pNodeDoc);
01222     }
01223 
01224     return (ok);
01225 }
01226 
01227 /********************************************************************************************
01228 
01229 >   BOOL Layer::IsVisible(DocView* pView = NULL)
01230 
01231     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> (modified by Markn)
01232     Created:    6/1/94
01233     Inputs:     pDocView = ptr to a docview (only used if the layer is a guide layer)
01234     Outputs:    -
01235     Returns:    TRUE if the layer is visible, otherwise FALSE. 
01236     Purpose:    For finding the layers visible status 
01237     Errors:     -
01238     SeeAlso:    -
01239 
01240 ********************************************************************************************/
01241 /*  Implementation notes:
01242 
01243     A layer is visible if the following is true - 
01244         The layer's visible flag is TRUE 
01245     OR  The layer is active and ActiveLayerVisibleAndEditable is TRUE
01246     OR  The AllVisible flag in the parent document is TRUE
01247 
01248     Guide layers are a special case:
01249 
01250     If the layer is a guide layer, then the visibility is determined by the associated DocView's GuideShow flag.
01251     The flag in the given DocView is used.
01252     If no DocView is given, the current DocView is used.
01253 */
01254 
01255 BOOL Layer::IsVisible(DocView* pDocView)
01256 {
01257     if (Guide)
01258     {
01259         // WEBSTER - markn 29/1/97
01260         // Guide layers are always invisible
01261         #ifndef WEBSTER
01262             if (pDocView == NULL)
01263                 pDocView = DocView::GetCurrent();
01264             if (pDocView != NULL)
01265                  return (pDocView->GetShowGuidesState());
01266             else
01267                 return FALSE;
01268         #else
01269             return FALSE;
01270         #endif // WEBSTER
01271     }
01272 
01273     // If it is visible, fast track the return
01274     if (Visible)
01275         return (TRUE);
01276 
01277     // If the "Active layer is editable and visible" flag is TRUE,
01278     // then return TRUE (layer is visible) if this layer is Active
01279     if (Active && ActiveLayerVisibleAndEditable)
01280         return (TRUE);
01281 
01282     // This layer is NOT visible. However, if the document to which this layer belongs
01283     // has the AllVisible flag set, then return TRUE
01284     // I.e. return the doc's AllVisible state
01285     Document *pDoc = FindDocument();
01286     if (pDoc == NULL)
01287         return(TRUE);
01288 
01289     return(pDoc->IsAllVisible());
01290 }
01291   
01292 /********************************************************************************************
01293 
01294 >   BOOL Layer::GetVisibleFlagState()
01295 
01296     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01297     Created:    17/8/94
01298     Inputs:     -
01299     Outputs:    -
01300     Returns:    TRUE if the layer's Visible is TRUE, FALSE otherwise
01301     Purpose:    Returns the raw state of the layer's visible flag (specialist use only) 
01302     Errors:     -
01303     SeeAlso:    Layer::IsVisible()
01304 
01305 ********************************************************************************************/
01306 
01307 BOOL Layer::GetVisibleFlagState()
01308 {   
01309     if (Guide)
01310     {
01311         DocView* pDocView = DocView::GetCurrent();
01312         if (pDocView != NULL)
01313              return (pDocView->GetShowGuidesState());
01314     }
01315 
01316     return (Visible);
01317 }
01318   
01319 /********************************************************************************************
01320 
01321 >   BOOL Layer::IsLocked()
01322 
01323     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> (modified by Markn) (modified to not use CurrentDoc by Jason)
01324     Created:    6/1/94
01325     Inputs:     -
01326     Outputs:    -
01327     Returns:    TRUE if the layer is locked, otherwise FALSE. 
01328     Purpose:    For finding the layers locked status 
01329                 A layer is locked if the following is true - 
01330                     The layer's locked flag is TRUE 
01331                 AND The layer is NOT active (clause not used in Alpha release 15/8/94)
01332                 AND The Multilayer flag in the parent document is FALSE
01333     Errors:     -
01334     SeeAlso:    -
01335 
01336 ********************************************************************************************/
01337 
01338 BOOL Layer::IsLocked()
01339 {
01340 /*  // WEBSTER - markn 29/1/97
01341     // All layers are editable in Webster
01342     #ifndef WEBSTER */
01343         // Disabled as we now have frame layers and some layers MUST be locked
01344 
01345         // Fast track it if the layer is not locked (the majority of cases)
01346         if (!Locked)
01347             return (FALSE);
01348 
01349         // If we are the page background layer then ALWAYS return locked
01350         if (IsPageBackground())
01351             return TRUE;
01352 
01353         // If the "Active layer is editable and visible" flag is TRUE,
01354         // then return FALSE (layer is editable) if this layer is Active
01355         if (Active && ActiveLayerVisibleAndEditable)
01356             return (FALSE);
01357 
01358         // This layer is locked. However, if the document to which this layer belongs
01359         // has the Multilayer flag set (i.e. all layers editable), the return FALSE
01360         // I.e. return the inverse of the doc's Multilayer state
01361         Document *pDoc = FindDocument();
01362         if (pDoc == NULL)
01363             return (FALSE);
01364 
01365         return (!pDoc->IsMultilayer());
01366 /*  #else
01367         // Fast track it if the layer is not locked (the majority of cases)
01368         // Required in Webster so that when the BackgroundOp is inserting objects and
01369         // it has turned the locked status off, then we do not get the warning. In other
01370         // cases where the user is trying to change the background layer and the locked
01371         // flag is set to its default true state, we should fall through to the PageBackground
01372         // test and fail.
01373         if (!Locked)
01374             return (FALSE);
01375 
01376         // If we are the page background layer then ALWAYS return locked
01377         if (IsPageBackground())
01378             return TRUE;
01379         
01380         // always return FALSE i.e. editable
01381         return FALSE;
01382     #endif // WEBSTER */
01383 }
01384 
01385 /********************************************************************************************
01386 
01387 >   BOOL Layer::GetLockedFlagState()
01388 
01389     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01390     Created:    17/8/94
01391     Inputs:     -
01392     Outputs:    -
01393     Returns:    TRUE if the layer's Locked is TRUE, FALSE otherwise
01394     Purpose:    Returns the raw state of the layer's Locked flag (specialist use only)  
01395     Errors:     -
01396     SeeAlso:    Layer::IsLocked()
01397 
01398 ********************************************************************************************/
01399 
01400 BOOL Layer::GetLockedFlagState()
01401 {   
01402     return (Locked);
01403 }
01404   
01405 /********************************************************************************************
01406 
01407 >   BOOL Layer::IsActive()
01408 
01409     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01410     Created:    6/1/94
01411     Inputs:     -
01412     Outputs:    -
01413     Returns:    TRUE if the layer is active, otherwise FALSE. 
01414     Purpose:    For finding the layers active status 
01415     Errors:     -
01416     SeeAlso:    -
01417 
01418 ********************************************************************************************/
01419 
01420 
01421 BOOL Layer::IsActive()
01422 {
01423     return (Active); 
01424 } 
01425 
01426 /********************************************************************************************
01427 
01428 >   BOOL Layer::IsPrintable()
01429 
01430     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01431     Created:    6/1/94
01432     Inputs:     -
01433     Outputs:    -
01434     Returns:    TRUE if the layer is printable, otherwise FALSE. 
01435     Purpose:    For finding the layers printable status 
01436     Errors:     -
01437     SeeAlso:    -
01438 
01439 ********************************************************************************************/
01440 
01441 
01442 BOOL Layer::IsPrintable()
01443 {
01444     return (Printable && !IsGuide()); 
01445 } 
01446 
01447 /********************************************************************************************
01448 
01449 >   BOOL Layer::IsBackground()
01450 
01451     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01452     Created:    6/1/94
01453     Inputs:     -
01454     Outputs:    -
01455     Returns:    TRUE if the layer is a background layer, otherwise FALSE. 
01456     Purpose:    For finding the layers background status 
01457     Errors:     -
01458     SeeAlso:    -
01459 
01460 ********************************************************************************************/
01461 
01462 
01463 BOOL Layer::IsBackground()
01464 {
01465     return (Background); 
01466 } 
01467 
01468 /********************************************************************************************
01469 
01470 >   BOOL Layer::IsOutline()
01471 
01472     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01473     Created:    12/8/94
01474     Inputs:     -
01475     Outputs:    -
01476     Returns:    TRUE if the layer is to render its objects in outline mode
01477     Purpose:    For finding the layers outline status 
01478     Errors:     -
01479     SeeAlso:    -
01480 
01481 ********************************************************************************************/
01482 
01483 
01484 BOOL Layer::IsOutline()
01485 {
01486     return (Outline); 
01487 } 
01488 
01489 /********************************************************************************************
01490 
01491 >   BOOL Layer::IsGuide()
01492 
01493     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01494     Created:    6/9/95
01495     Inputs:     -
01496     Outputs:    -
01497     Returns:    TRUE if the layer is one that can contain guidelines
01498     Purpose:    For finding the layers guide status 
01499     Errors:     -
01500     SeeAlso:    -
01501 
01502 ********************************************************************************************/
01503 
01504 
01505 BOOL Layer::IsGuide()
01506 {
01507     return (Guide); 
01508 } 
01509 
01510 /********************************************************************************************
01511 
01512 >   BOOL Layer::IsPageBackground()
01513 
01514     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01515     Created:    4/4/97
01516     Inputs:     -
01517     Outputs:    -
01518     Returns:    TRUE if the layer is one that can contains the page background
01519     Purpose:    For finding the layer's page background status 
01520     Errors:     -
01521     SeeAlso:    -
01522 
01523 ********************************************************************************************/
01524 
01525 BOOL Layer::IsPageBackground()
01526 {
01527     return (m_PageBackground); 
01528 } 
01529 
01530 
01531 /********************************************************************************************
01532 
01533 >   BOOL Layer::IsOverlay()
01534 
01535     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01536     Created:    16/4/97
01537     Returns:    TRUE if the frame/layer is one that has its Overlay flag set
01538     Purpose:    For finding the frame's/layer's Overlay status 
01539 
01540 ********************************************************************************************/
01541 
01542 BOOL Layer::IsOverlay()
01543 {
01544     return m_Overlay;
01545 }
01546 
01547 /********************************************************************************************
01548 
01549 >   BOOL Layer::IsSolid()
01550 
01551     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01552     Created:    16/4/97
01553     Returns:    TRUE if the frame/layer is one that has its Solid flag set
01554     Purpose:    For finding the frame's/layer's Solid status 
01555 
01556 ********************************************************************************************/
01557 
01558 BOOL Layer::IsSolid()
01559 {
01560     return m_Solid;
01561 }
01562 
01563 /********************************************************************************************
01564 
01565 >   BOOL Layer::IsEdited()
01566 
01567     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01568     Created:    16/4/97
01569     Returns:    TRUE if the frame/layer is one that has its Edited flag set
01570     Purpose:    For finding the frame's/layer's Edited status 
01571 
01572 ********************************************************************************************/
01573 
01574 BOOL Layer::IsEdited()
01575 {
01576     return m_Edited;
01577 }
01578 
01579 /********************************************************************************************
01580 
01581 >   BOOL Layer::IsFrame()
01582 
01583     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01584     Created:    23/4/97
01585     Returns:    TRUE if the frame/layer is one that has its Frame flag set
01586     Purpose:    For finding the frame's/layer's Frame status 
01587 
01588 ********************************************************************************************/
01589 
01590 BOOL Layer::IsFrame()
01591 {
01592     return m_Frame;
01593 }
01594 
01595 /********************************************************************************************
01596 
01597 >   BOOL Layer::IsHiddenFrame()
01598 
01599     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01600     Created:    23/4/97
01601     Returns:    TRUE if the frame/layer is one that has its Hidden flag set
01602     Purpose:    For finding the frame's/layer's Hidden status
01603                 This marks this frame as a hidden frame layer which will not be saved into
01604                 the GIF animation but may take part in the rendering process of other frames.
01605 
01606 ********************************************************************************************/
01607 
01608 BOOL Layer::IsHiddenFrame()
01609 {
01610     return m_HiddenFrame;
01611 }
01612 
01613 /********************************************************************************************
01614 
01615 >   BOOL Layer::IsPseudoFrame()
01616 
01617     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01618     Created:    23/4/97
01619     Returns:    TRUE if the frame/layer is one that might be a frame layer
01620     Purpose:    For finding out whether this might be regarded as a frame layer without
01621                 especially having its frame flag set.
01622 
01623 ********************************************************************************************/
01624 
01625 BOOL Layer::IsPseudoFrame()
01626 {
01627     // Only true if the layer is not a background layer or a guide layer or a page background
01628     // layer
01629     return (!IsBackground() && !IsGuide() && !IsPageBackground());
01630 }
01631 
01632 /********************************************************************************************
01633 >   UINT32 Layer::GetFrameDelay()
01634 
01635     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01636     Created:    01/05/97
01637     Returns:    The delay value for each animation frame layer.
01638     
01639 ********************************************************************************************/
01640 
01641 DWORD Layer::GetFrameDelay()
01642 {
01643     return m_FrameDelay;
01644 }
01645 
01646 /********************************************************************************************
01647 >   UINT32 Layer::SetFrameDelay()
01648 
01649     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01650     Created:    01/05/97
01651     Returns:    -
01652     purpose:    To set the delay value for each animation frame layer.
01653     
01654 ********************************************************************************************/
01655 void Layer::SetFrameDelay(const DWORD& Delay)
01656 {
01657     m_FrameDelay = Delay;
01658 }
01659 
01660 /********************************************************************************************
01661 
01662 >   BOOL Layer::IncludeLayerInBoundingCalcs()
01663 
01664     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01665     Created:    8/4/97
01666     Inputs:     -
01667     Outputs:    -
01668     Returns:    TRUE if the layer is one that can contains the page background
01669     Purpose:    For finding out whether to include the layer in bounding box calcalutions.
01670                 This may not be a simple IsVisible test as usually you want to exclude the
01671                 two special layers:- guides and page background.
01672                 This function should be used when:-
01673                     Calculating drawing sizes for zooming
01674                     Calculating drawing sizes for export
01675     Errors:     -
01676     SeeAlso:    Spread::GetPageVisibleBounds(); BaseBitmapFilter::GetSizeOfDrawing();
01677 
01678 ********************************************************************************************/
01679 
01680 BOOL Layer::IncludeLayerInBoundingCalcs()
01681 {
01682     // Only add the bounding box of the layer in if it is visible and if it is not
01683     // either a guide layer or the page background layer.
01684     return (!IsPageBackground() && !IsGuide() && IsVisible());
01685 } 
01686 
01687 
01688 
01689 /********************************************************************************************
01690 
01691 >   String_256& Layer::GetLayerID()
01692 
01693     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01694     Created:    6/1/94
01695     Inputs:     -
01696     Outputs:    -
01697     Returns:    The layers ID
01698     Purpose:    For finding the layers identifier 
01699     Errors:     -
01700     SeeAlso:    -
01701 
01702 ********************************************************************************************/
01703 
01704 String_256& Layer::GetLayerID()
01705 {
01706     return (LayerSt.StringLayerID); 
01707 } 
01708 
01709 /********************************************************************************************
01710 
01711 >   LayerStatus& GetLayerStatus()
01712 
01713     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01714     Created:    10/1/94
01715     Inputs:     -
01716     Outputs:    -
01717     Returns:    -
01718     Purpose:    Returns the layers status 
01719     Errors:     -
01720     SeeAlso:    -
01721 
01722 ********************************************************************************************/
01723 
01724 LayerStatus& Layer::GetLayerStatus()
01725 {
01726     return (LayerSt); 
01727 } 
01728 
01729 // Set Layers status functions 
01730 // -----------------------------------------------------------------------------------------
01731 
01732 /********************************************************************************************
01733 
01734 >   void Layer::SetVisible(BOOL Status) 
01735 
01736     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01737     Created:    6/1/94
01738     Inputs:     Status: Status of the Layer's visible flag 
01739     Outputs:    -
01740     Returns:    -
01741     Purpose:    To set the Layer's visible flag status (TRUE/FALSE)
01742     Errors:     -
01743     SeeAlso:    -
01744 
01745 ********************************************************************************************/
01746 
01747 void Layer::SetVisible(BOOL Status) 
01748 {
01749     if (Guide)
01750     {
01751         DocView* pDocView = DocView::GetCurrent();
01752         if (pDocView != NULL)
01753              pDocView->SetShowGuidesState(Status);
01754     }
01755     else
01756         Visible = Status;
01757 }
01758 
01759 /********************************************************************************************
01760 
01761 >   void Layer::SetLocked(BOOL Status) 
01762 
01763     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01764     Created:    6/1/94
01765     Inputs:     Status: Status of the Layer's locked flag 
01766     Outputs:    -
01767     Returns:    -
01768     Purpose:    To set the Layer's locked flag status (TRUE/FALSE)
01769     Errors:     -
01770     SeeAlso:    -
01771 
01772 ********************************************************************************************/
01773 
01774 
01775 void Layer::SetLocked(BOOL Status) 
01776 {
01777     Locked = Status; 
01778 }
01779 
01780 /********************************************************************************************
01781 
01782 >   void Layer::SetActive(BOOL Status) 
01783 
01784     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01785     Created:    6/1/94
01786     Inputs:     Status: Status of the Layer's active flag 
01787     Outputs:    -
01788     Returns:    -
01789     Purpose:    To set the Layer's active flag status (TRUE/FALSE)
01790     Errors:     -
01791     SeeAlso:    -
01792 
01793 ********************************************************************************************/
01794 
01795 
01796 void Layer::SetActive(BOOL Status) 
01797 {
01798     Active = Status; 
01799 }
01800 
01801 /********************************************************************************************
01802 
01803 >   void Layer::SetPrintable(BOOL Status) 
01804 
01805     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01806     Created:    6/1/94
01807     Inputs:     Status: Status of the Layer's printable flag 
01808     Outputs:    -
01809     Returns:    -
01810     Purpose:    To set the Layer's printable flag status (TRUE/FALSE)
01811     Errors:     -
01812     SeeAlso:    -
01813 
01814 ********************************************************************************************/
01815 
01816 
01817 void Layer::SetPrintable(BOOL Status) 
01818 {
01819     Printable = Status; 
01820 }
01821 
01822 /********************************************************************************************
01823 
01824 >   void Layer::SetBackground(BOOL Status) 
01825 
01826     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01827     Created:    6/1/94
01828     Inputs:     Status: Status of the Layer's background flag 
01829     Outputs:    -
01830     Returns:    -
01831     Purpose:    To set the Layer's background flag status (TRUE/FALSE)
01832     Errors:     -
01833     SeeAlso:    -
01834 
01835 ********************************************************************************************/
01836 
01837 
01838 void Layer::SetBackground(BOOL Status) 
01839 {
01840     Background = Status; 
01841 }
01842 
01843 
01844 /********************************************************************************************
01845 
01846 >   void Layer::SetOutline(BOOL Status) 
01847 
01848     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01849     Created:    12/8/94
01850     Inputs:     Status: Status of the Layer's outline flag
01851     Outputs:    -
01852     Returns:    -
01853     Purpose:    To set the Layer's outline flag status (TRUE/FALSE)
01854     Errors:     -
01855     SeeAlso:    -
01856 
01857 ********************************************************************************************/
01858 
01859 
01860 void Layer::SetOutline(BOOL Status) 
01861 {
01862     Outline = Status; 
01863 }
01864 
01865 /********************************************************************************************
01866 
01867 >   void Layer::SetGuide(BOOL Status) 
01868 
01869     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01870     Created:    6/9/95
01871     Inputs:     Status: Status of the Layer's Guide flag
01872     Outputs:    -
01873     Returns:    -
01874     Purpose:    To set the Layer's Guide flag status (TRUE/FALSE)
01875     Errors:     -
01876     SeeAlso:    -
01877 
01878 ********************************************************************************************/
01879 
01880 
01881 void Layer::SetGuide(BOOL Status) 
01882 {
01883     Guide = Status; 
01884 }
01885 
01886 /********************************************************************************************
01887 
01888 >   void Layer::SetPageBackground(BOOL Status) 
01889 
01890     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01891     Created:    4/4/97
01892     Inputs:     Status: Status of the Layer's PageBackground flag
01893     Outputs:    -
01894     Returns:    -
01895     Purpose:    To set the Layer's PageBackground flag status (TRUE/FALSE)
01896     Errors:     -
01897     SeeAlso:    -
01898 
01899 ********************************************************************************************/
01900 
01901 void Layer::SetPageBackground(BOOL Status) 
01902 {
01903     m_PageBackground = Status; 
01904 }
01905 
01906 /********************************************************************************************
01907 
01908 >   void Layer::SetSolid(BOOL Status) 
01909 
01910     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01911     Created:    16/4/97
01912     Inputs:     Status: Status of the Frame/Layer's Solid flag
01913     Purpose:    To set the Frame/Layer's Solid flag status (TRUE/FALSE)
01914 
01915 ********************************************************************************************/
01916 
01917 void Layer::SetSolid(BOOL Status)
01918 {
01919     m_Solid = Status; 
01920 }
01921 
01922 /********************************************************************************************
01923 
01924 >   void Layer::SetOverlay(BOOL Status) 
01925 
01926     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01927     Created:    16/4/97
01928     Inputs:     Status: Status of the Frame/Layer's Overlay flag
01929     Purpose:    To set the Frame/Layer's Overlay flag status (TRUE/FALSE)
01930 
01931 ********************************************************************************************/
01932 
01933 void Layer::SetOverlay(BOOL Status)
01934 {
01935     m_Overlay = Status; 
01936 }
01937 
01938 /********************************************************************************************
01939 
01940 >   void Layer::SetEdited(BOOL Status) 
01941 
01942     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01943     Created:    16/4/97
01944     Inputs:     Status: Status of the Frame/Layer's Edited flag
01945     Purpose:    To set the Frame/Layer's Edited flag status (TRUE/FALSE)
01946 
01947 ********************************************************************************************/
01948 
01949 void Layer::SetEdited(BOOL Status)
01950 {
01951     m_Edited = Status; 
01952 }
01953 
01954 /********************************************************************************************
01955 
01956 >   void Layer::SetFrame(BOOL Status) 
01957 
01958     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01959     Created:    16/4/97
01960     Inputs:     Status: Status of the Frame/Layer's Frame flag
01961     Purpose:    To set the Frame/Layer's Frame flag status (TRUE/FALSE)
01962 
01963 ********************************************************************************************/
01964 
01965 void Layer::SetFrame(BOOL Status)
01966 {
01967     m_Frame = Status; 
01968 }
01969 
01970 /********************************************************************************************
01971 
01972 >   void Layer::SetHiddenFrame(BOOL Status) 
01973 
01974     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01975     Created:    21/7/97
01976     Inputs:     Status: Status of the Frame/Layer's Hidden flag
01977     Purpose:    To set the Frame/Layer's Hidden flag status (TRUE/FALSE)
01978 
01979 ********************************************************************************************/
01980 
01981 void Layer::SetHiddenFrame(BOOL Status)
01982 {
01983     m_HiddenFrame = Status; 
01984 }
01985 
01986 /********************************************************************************************
01987 // Generated Bitmap related functions
01988 ********************************************************************************************/
01989 
01990 /********************************************************************************************
01991 
01992 >   virtual ChangeCode Layer::OnChildChange(ObjChangeParam* pParam)
01993 
01994     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01995     Created:    08/05/97
01996     Inputs:     pParam  = pointer to a object change parameter class
01997     Returns:    CC_OK       if we have successfully processed the change.
01998                 CC_FAIL     if we cannot handle this particular change and must prevent the
01999                             child from continuing
02000     Purpose:    We override the function to mark layers as edited.
02001                 This should do the same as the baseclass i.e. return ok but should else set
02002                 the edited flag to true.
02003                 Composite objects can use this function to respond to one of their children
02004                 undergoing a change. They should return CC_FAIL whenever they are unable to
02005                 cope with the change.
02006     SeeAlso:    WarnParentOfChange();
02007 
02008 ********************************************************************************************/
02009 
02010 ChangeCode Layer::OnChildChange(ObjChangeParam* pParam)
02011 {
02012     // Note that this layer has been edited
02013     SetEdited(TRUE);
02014 
02015 #ifdef _DEBUG
02016     // Tell the frame gallery to update its display of the frame
02017     BROADCAST_TO_ALL(LayerMsg(this, LayerMsg::REDRAW_LAYER));
02018 #endif
02019 
02020     return CC_OK;
02021 }
02022 
02023 /********************************************************************************************
02024 // Generated Bitmap related functions
02025 ********************************************************************************************/
02026 
02027 /********************************************************************************************
02028 
02029 >   KernelBitmap * Layer::GetGeneratedBitmap()
02030 
02031     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
02032     Created:    7/5/97
02033     Returns:    NULL or the kernel bitmap that we generated to represent this layer
02034     Purpose:    To recover the bitmap that has been generated to represent this layer, if any.
02035 
02036 ********************************************************************************************/
02037 
02038 KernelBitmap * Layer::GetGeneratedBitmap()
02039 {
02040     // Just ask the embedded bitmap ref to return its current status
02041     return m_GeneratedBitmap.GetBitmap();
02042 }
02043         
02044 /********************************************************************************************
02045 
02046 >   BOOL Layer::SetGeneratedBitmap(KernelBitmap * pBitmap)
02047 
02048     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
02049     Created:    7/5/97
02050     Inputs:     The kernel bitmap that we wish to represent this layer
02051     Purpose:    To set the bitmap that has been generated to represent this layer.
02052 
02053 ********************************************************************************************/
02054 
02055 BOOL Layer::SetGeneratedBitmap(KernelBitmap * pBitmap)
02056 {
02057     //ERROR2IF(pBitmap == NULL,FALSE,"SetGeneratedBitmap Bad params");
02058 
02059     Document *pParentDoc = (Document *) FindOwnerDoc();
02060     ERROR2IF(pParentDoc == NULL,FALSE,"SetGeneratedBitmap bad parent doc!");
02061 
02062     // delete the old one from the system, if it is there and it is not used
02063     // elsewhere in the document
02064     KernelBitmap * pOldBitmap = m_GeneratedBitmap.GetBitmap();
02065     if (pOldBitmap)
02066     {
02067         // Disclude ourselves from the count
02068         m_GeneratedBitmap.Detach();
02069         
02070         // Should we use HasBeenDeleted???
02071         // If the bitmap is not used in this document then delete it
02072         if (!pOldBitmap->IsUsedInDocument(pParentDoc))
02073             delete pOldBitmap;
02074         //m_GeneratedBitmap.DeleteBmp();
02075     }
02076 
02077     // Only do this if we are passed in a non-null bitmap
02078     if (pBitmap != NULL)
02079     {
02080         // Make our bitmap ref use the new specified one
02081         // We could use the nice and simple:-
02082         //m_GeneratedBitmap.Attach(pBitmap, pParentDoc);
02083         // but this makes a new kernel bitmap, which is bad!
02084         // So do this instead:-
02085         // Try and add it to the list of bitmaps already present in this document
02086         BitmapList * pBmpList = pParentDoc->GetBitmapList();
02087         if (pBmpList == NULL)
02088         {
02089             ERROR3("SetGeneratedBitmap No document bitmap ref found!");
02090             return FALSE; 
02091         }
02092 
02093         // and then attach the bitmap
02094         pBitmap->Attach(pBmpList);
02095         // and tell everybody about the change
02096         BROADCAST_TO_ALL(BitmapListChangedMsg(pBmpList, pBitmap)); 
02097 
02098         m_GeneratedBitmap.SetBitmap(pBitmap);
02099 
02100         // If we have a generated bitmap then we cannot have a referenced bitmap
02101         // so reset the referenced bitmap
02102         SetReferencedBitmap(NULL);
02103     }
02104 
02105     return TRUE;
02106 }
02107 
02108 /********************************************************************************************
02109 
02110 >   KernelBitmap *Layer::EnumerateBitmaps(UINT32 Count)
02111 
02112     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> based on Will code
02113     Created:    7/5/97
02114     Inputs:     Count - the bitmap to get (see Purpose).
02115     Returns:    The KernelBitmap in use by the node, or NULL if no more are used.
02116     Purpose:    Find out what bitmaps, if any, are used by this node.
02117 
02118                 The base class returns NULL always, so you over-ride this in any node classes
02119                 that use bitmaps.
02120 
02121                 This function supports nodes that use more than one bitmap - you call this
02122                 function repeatedly and keep incrementing the Count parameter that you pass
02123                 in each time by 1.  You should stop calling it when it returns NULL, as this
02124                 indicates that no more bitmaps are used by this node.
02125                 Count should start off as 0 for the first call.  Note that this function
02126                 can (and often will) return NULL for the first call, as many nodes don't
02127                 use bitmaps, obviously.
02128 
02129     SeeAlso:    KernelBitmap
02130 
02131 ********************************************************************************************/
02132 
02133 KernelBitmap *Layer::EnumerateBitmaps(UINT32 Count)
02134 {
02135     if (Count == 0) 
02136         return GetGeneratedBitmap();
02137 
02138     return NULL;
02139 }
02140 
02141 /********************************************************************************************
02142 // End of Generated Bitmap related functions
02143 ********************************************************************************************/
02144 
02145 /********************************************************************************************
02146 // Referenced Bitmap related functions
02147 ********************************************************************************************/
02148 
02149 /********************************************************************************************
02150 
02151 >   KernelBitmap * Layer::GetReferencedBitmap()
02152 
02153     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
02154     Created:    7/5/97
02155     Returns:    NULL or the kernel bitmap that we reference to represent this layer
02156     Purpose:    To recover the bitmap that is present on the layer and is of the correct sort
02157                 so that it can be used to represent this layer.
02158 
02159 ********************************************************************************************/
02160 
02161 KernelBitmap * Layer::GetReferencedBitmap()
02162 {
02163     // We have a direct pointer rather than a ref as otherwise we will see the bitmap twice
02164     // in the bitmap gallery for this document.
02165     return m_pReferencedBitmap;
02166 }
02167         
02168 /********************************************************************************************
02169 
02170 >   BOOL Layer::SetReferencedBitmap(KernelBitmap * pBitmap)
02171 
02172     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
02173     Created:    1/7/97
02174     Inputs:     The kernel bitmap that we wish to represent this layer
02175     Purpose:    To set the bitmap that has been found which is a single bitmap on this layer
02176                 which is of the correct colour depth and scaling which can be used to directly
02177                 represent this layer. Usually, the bitmap will be part of an animation that
02178                 has been loaded in.
02179 
02180 ********************************************************************************************/
02181 
02182 BOOL Layer::SetReferencedBitmap(KernelBitmap * pBitmap)
02183 {
02184     // We have a direct pointer rather than a ref as otherwise we will see the bitmap twice
02185     // in the bitmap gallery for this document.
02186     m_pReferencedBitmap = pBitmap;
02187 
02188     return TRUE;
02189 }
02190 
02191 /********************************************************************************************
02192 // End of Referenced Bitmap related functions
02193 ********************************************************************************************/
02194 
02195 /***********************************************************************************************
02196 
02197 >   BOOL Layer::HasLayerGotRenderableChildren(Layer* pLayer)
02198 
02199   Author:       Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> from MarkN version in LayerSGallery::HasLayerGotChildren()
02200     Created:    21/7/97
02201     Returns:    TRUE  - The layer has children the user may be interested in - i.e. children
02202                         that actually render something.
02203                 FALSE - The layer has no rendering children
02204     Purpose:    Scans the layer for children that render something on the screen.
02205                 It ignores attributes, hidden nodes, etc - nodes that don't render anything themselves.
02206                 
02207 ***********************************************************************************************/
02208 
02209 BOOL Layer::HasLayerGotRenderableChildren()
02210 {
02211     Node* pNode = FindFirstChild();
02212     BOOL ChildFound = FALSE;
02213 
02214     while (pNode != NULL && !ChildFound)
02215     {
02216         ChildFound = pNode->IsBounded();
02217         pNode = pNode->FindNext();
02218     }
02219 
02220     return (ChildFound);
02221 }
02222 
02223 /********************************************************************************************
02224 
02225 >   void Layer::SetLayerID((String_256& LayerID)
02226 
02227     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02228     Created:    6/1/94
02229     Inputs:     LayerID: The new layer identifier
02230     Outputs:    -
02231     Returns:    - 
02232     Purpose:    For setting the layer's identifier 
02233     Errors:     -
02234     SeeAlso:    -
02235 
02236 ********************************************************************************************/
02237 
02238 void Layer::SetLayerID(String_256& LayerID)
02239 {
02240     LayerSt.StringLayerID = LayerID; 
02241 } 
02242 
02243 
02244 /********************************************************************************************
02245 
02246 >   void Layer::SetLayerStatus(LayerStatus& Status); 
02247 
02248     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02249     Created:    14/1/94
02250     Inputs:     Status: The new status for the layer 
02251     Outputs:    -
02252     Returns:    -
02253     Purpose:    To set the layers status
02254     Errors:     -
02255     SeeAlso:    Layer::SetVisible 
02256     SeeAlso:    Layer::SetLocked
02257     SeeAlso:    Layer::SetActive
02258     SeeAlso:    Layer::SetPrintable
02259     SeeAlso:    Layer::SetBackground
02260     SeeAlso:    LAyer::SetGlobalQualityFlg
02261 
02262 ********************************************************************************************/
02263  
02264 void Layer::SetLayerStatus(LayerStatus& Status) 
02265 {
02266     LayerSt = Status;   
02267 }
02268 
02269 void Layer::GetDebugDetails(StringBase* Str) 
02270 {          
02271 #ifdef _DEBUG
02272     NodeRenderablePaper::GetDebugDetails(Str); 
02273     (*Str)+= TEXT("\r\nLayer Status("); 
02274     (*Str)+=TEXT("\r\n   VISIBLE = "); 
02275     if (Visible)
02276         (*Str)+=TEXT("TRUE"); 
02277     else
02278         (*Str)+=TEXT("FALSE"); 
02279     
02280     (*Str)+=TEXT("\r\n   LOCKED = "); 
02281     if (Locked)
02282         (*Str)+=TEXT("TRUE"); 
02283     else
02284         (*Str)+=TEXT("FALSE"); 
02285 
02286     (*Str)+=TEXT("\r\n   ACTIVE = "); 
02287     if (Active)
02288         (*Str)+=TEXT("TRUE"); 
02289     else
02290         (*Str)+=TEXT("FALSE"); 
02291             
02292     (*Str)+=TEXT("\r\n   PRINTABLE = "); 
02293     if (Printable)
02294         (*Str)+=TEXT("TRUE"); 
02295     else
02296         (*Str)+=TEXT("FALSE"); 
02297 
02298     (*Str)+=TEXT("\r\n   BACKGROUND = "); 
02299     if (Background)
02300         (*Str)+=TEXT("TRUE"); 
02301     else
02302         (*Str)+=TEXT("FALSE"); 
02303 
02304     (*Str)+=TEXT("\r\n");
02305     
02306     String_256 Temp; 
02307 
02308     Temp._MakeMsg(TEXT("Outline = #1%ld\r\n"),Outline);   
02309     (*Str)+=Temp; 
02310     Temp._MakeMsg(TEXT("Guide   = #1%ld\r\n"),Guide);   
02311     (*Str)+=Temp; 
02312     Temp._MakeMsg(TEXT("PageBackground   = #1%ld\r\n"),m_PageBackground);   
02313     (*Str)+=Temp; 
02314     Temp._MakeMsg(TEXT("Frame   = #1%ld\r\n"),m_Frame);   
02315     (*Str)+=Temp; 
02316     Temp._MakeMsg(TEXT("Edited  = #1%ld\r\n"),m_Edited);   
02317     (*Str)+=Temp; 
02318     Temp._MakeMsg(TEXT("Hidden frame = #1%ld\r\n"),m_HiddenFrame);   
02319     (*Str)+=Temp; 
02320 
02321     (*Str)+=TEXT("Layer ID = "); 
02322     (*Str)+=LayerSt.StringLayerID; 
02323     (*Str)+=TEXT("\r\n");
02324 #endif
02325 }   
02326 
02327 /********************************************************************************************
02328 
02329 >   virtual UINT32 Layer::GetNodeSize() const
02330 
02331     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02332     Created:    6/10/93
02333     Inputs:     -
02334     Outputs:    -
02335     Returns:    The size of the node in bytes
02336     Purpose:    For finding the size of the node 
02337                 
02338     SeeAlso:    Node::GetSubtreeSize
02339 
02340 ********************************************************************************************/
02341 
02342 UINT32 Layer::GetNodeSize() const 
02343 {     
02344     return (sizeof(Layer)); 
02345 }  
02346  
02347 /********************************************************************************************
02348 
02349 >   virtual DocRect Layer::GetBlobBoundingRect()
02350 
02351     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02352     Created:    15/8/94
02353     Inputs:     -
02354     Outputs:    -
02355     Returns:    The layer's blob bounds
02356     Purpose:    Returns the layer's bounding rect inflated by the size of a blob
02357     SeeAlso:    NodeRenderable::GetBlobBoundingRect()
02358 
02359 ********************************************************************************************/
02360 
02361 DocRect Layer::GetBlobBoundingRect()
02362 {
02363 #if !defined(EXCLUDE_FROM_RALPH)
02364     BlobManager* BlobMgr = GetApplication()->GetBlobManager();
02365     ENSURE(BlobMgr != NULL,"No blob manager - HELP!");
02366 
02367     DocRect rect     = GetBoundingRect();
02368     INT32   BlobSize = BlobMgr->GetBlobSize();
02369 
02370     rect.Inflate(BlobSize);
02371 
02372     return (rect);
02373 #else
02374     return DocRect(0,0,0,0);
02375 #endif
02376 }
02377 
02378 /********************************************************************************************
02379 
02380 > void Layer::PreExportRender(RenderRegion* pRegion)
02381 
02382     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02383     Created:    17/8/94
02384     Inputs:     -
02385     Outputs:    -
02386     Returns:    -
02387     Purpose:    Outputs data to mark the beginning of a layer
02388     SeeAlso:    -
02389 
02390 ********************************************************************************************/
02391 
02392 void Layer::PreExportRender(RenderRegion* pRegion)
02393 {
02394 #ifdef DO_EXPORT
02395     if(pRegion->IsKindOf(CC_RUNTIME_CLASS(ArtWorksEPSRenderRegion)))
02396     {
02397         // export layers in ArtWorks-type EPS render regions
02398 
02399         // Can only export guide layers in Native format
02400         if (Guide && !pRegion->IS_KIND_OF(NativeRenderRegion))
02401             return;
02402 
02403         // Get ptr to the export DC
02404         EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC();
02405 
02406         // Guide layers are extended objects so mark them as such
02407         if (Guide)
02408         {
02409             pDC->OutputValue(INT32(EOTAG_GUIDELAYER));  // Output start extended object tag and token
02410             pDC->OutputToken(_T("cso"));
02411             pDC->OutputNewLine();
02412         }
02413 
02414         // Output the layer name
02415         pDC->OutputString(LayerSt.StringLayerID);
02416 
02417         // Layer type - foreground or background
02418         if (IsBackground())
02419             pDC->OutputToken(_T("0"));
02420         else
02421             pDC->OutputToken(_T("1"));
02422 
02423         // Visible flag
02424         if (Visible)
02425             pDC->OutputToken(_T("1"));
02426         else
02427             pDC->OutputToken(_T("0"));
02428 
02429         // Printable flag
02430         if (IsPrintable())
02431             pDC->OutputToken(_T("1"));
02432         else
02433             pDC->OutputToken(_T("0"));
02434 
02435         // Locked flag
02436         if (Locked)
02437             pDC->OutputToken(_T("1"));
02438         else
02439             pDC->OutputToken(_T("0"));
02440 
02441         // Layer token itself
02442 
02443         if (!Guide)
02444             pDC->OutputToken(_T("alyr"));
02445         else
02446         {
02447             // Output guide layer stuff
02448 
02449             if (pGuideColour == NULL)
02450                 SetGuideColour(NULL);
02451 
02452             ERROR3IF(pGuideColour == NULL,"Can't export guide layer without a colour");
02453 
02454             if (pGuideColour != NULL)
02455                 pDC->OutputNamedColour(pGuideColour);
02456 
02457             pDC->OutputToken(_T("glyr"));
02458         }
02459 
02460         pDC->OutputNewLine();
02461     }
02462 PORTNOTE("cmx", "Disabled CMXRenderRegion")
02463 #ifndef EXCLUDE_FROM_XARALX
02464     else if(pRegion->IsKindOf(CC_RUNTIME_CLASS(CMXRenderRegion)))
02465     {
02466         // mark start of a group...
02467         CMXExportDC *pDC = (CMXExportDC *) pRegion->GetRenderDC();
02468         pDC->StartLayer(GetLayerID());
02469     }
02470 #endif
02471 #endif
02472 }
02473 
02474 /***********************************************************************************************
02475 
02476 >   virtual BOOL Layer::ExportRender(RenderRegion* pRegion)
02477 
02478     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02479     Created:    11/10/95
02480     Inputs:     pRegion = the render region to export to
02481     Outputs:    -
02482     Returns:    -   
02483     Purpose:    Called after all child nodes are asked to export
02484         
02485 ***********************************************************************************************/
02486 
02487 BOOL Layer::ExportRender(RenderRegion* pRegion)
02488 {
02489 #ifdef DO_EXPORT
02490     // Can only export guide layers in Native format
02491     if (Guide && pRegion->IS_KIND_OF(NativeRenderRegion))
02492     {
02493         EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC();
02494 
02495         pDC->OutputToken(_T("ceo"));
02496         pDC->OutputNewLine();
02497     }
02498 PORTNOTE("cmx", "Disabled CMXRenderRegion")
02499 #ifndef EXCLUDE_FROM_XARALX
02500     else if(pRegion->IsKindOf(CC_RUNTIME_CLASS(CMXRenderRegion)))
02501     {
02502         // mark start of a group...
02503         CMXExportDC *pDC = (CMXExportDC *) pRegion->GetRenderDC();
02504         pDC->EndLayer();
02505 
02506         return TRUE;
02507     }
02508 #endif
02509     // Graeme (11-4-00) - Added call to AIEPSRenderRegion to export layers in that format.
02510     else if ( pRegion->IsKindOf ( CC_RUNTIME_CLASS ( AIEPSRenderRegion ) ) )
02511     {
02512         // Cast the render region to get a reference to an AIEPSRenderRegion.
02513         AIEPSRenderRegion   *pAIEPS = static_cast<AIEPSRenderRegion*> ( pRegion );
02514 
02515         // Call the export method.
02516         pAIEPS->ExportLayer ( this );
02517 
02518         // Return TRUE to avoid calling the standard exporter code.
02519         return TRUE;
02520     }
02521 #endif
02522 
02523     return FALSE;
02524 }
02525 
02526 
02527 /********************************************************************************************
02528 
02529 >   virtual BOOL Layer::AllowOp(ObjChangeParam* pParam, BOOL SetOpPermissionState = TRUE,
02530                                                         BOOL DoPreTriggerEdit = TRUE)
02531 
02532     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 20/01/2000
02533     Created:    6/02/95
02534     Inputs:     pParam               = describes the way an op wants to change the node
02535                 SetOpPermissionState = if TRUE the Op permission state of this node will be set according to
02536                                         the outcome of the call
02537                 DoPreTriggerEdit     = layers and the nodes above them are not part of the stretching
02538                                        mechanism, and hence do not use this flag at all.
02539     Outputs:    -
02540     Returns:    TRUE always!!
02541     Purpose:    Layers will allow any op to happen to them, or to their children.
02542 
02543                 The main purpose for layers overriding this func is to ensure that layers become the
02544                 top level node in the tree for the op permission mechanism, i.e. parents of layers (spreads, etc)
02545                 shouldn't play a part.
02546 
02547                 This func will always return TRUE, and if 'SetOpPermissionState' is TRUE, the layer's op permission
02548                 state will be set to PERMISSION_ALLOWED.
02549 
02550     SeeAlso:    Node::AllowOp(),Node::GetOpPermission(),Node::SetOpPermission(),Layer::SetOpPermission()
02551 
02552 ********************************************************************************************/
02553 
02554 BOOL Layer::AllowOp(ObjChangeParam* pParam, BOOL SetOpPermissionState, BOOL DoPreTriggerEdit)
02555 {
02556     if (SetOpPermissionState)
02557         SetOpPermission(PERMISSION_ALLOWED);
02558 
02559     return TRUE;
02560 }
02561 
02562 /********************************************************************************************
02563 
02564 >   virtual void Layer::SetOpPermission(OpPermissionState NewState,BOOL AndParents = FALSE)
02565 
02566     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02567     Created:    6/02/95
02568     Inputs:     NewState    = the state to set the permission to
02569                 AndParents  = Ignored (see later)
02570     Outputs:    -
02571     Returns:    -
02572     Purpose:    Calls Node::SetOpPermission(NewState,FALSE), i.e. you can set the layer's op permission
02573                 state, but the 'AndParent' param is ignored.
02574 
02575                 The purpose of this func is to make layers the top level node that has it's op permission
02576                 state changed.
02577 
02578     SeeAlso:    Node::SetOpPermission();
02579 
02580 ********************************************************************************************/
02581 
02582 void Layer::SetOpPermission(OpPermissionState NewState,BOOL AndParents)
02583 {
02584     Node::SetOpPermission(NewState,FALSE);
02585 }
02586 
02587 
02588 /********************************************************************************************
02589 
02590 >   virtual void Layer::EnsureUniqueLayerID(void)
02591 
02592     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
02593     Created:    18/04/95
02594     Inputs:     -
02595     Outputs:    -
02596     Returns:    -
02597     Purpose:    Ensures that the layers ID is unique amoung it's siblings. Call after the
02598                 node is linked into the document tree.
02599     SeeAlso:    Layer::SetLayerID
02600 
02601 ********************************************************************************************/
02602 
02603 void Layer::EnsureUniqueLayerID(void)
02604 {
02605     // first, find the first sibling of this node
02606     Layer *pFirstSibling = this;
02607     Layer *pPrevious = NULL;
02608 
02609     while ((pPrevious = pFirstSibling->FindPrevLayer()) != NULL)
02610         pFirstSibling = pPrevious;
02611 
02612     // then run though checking to see if the name is unqiue.
02613     String_256 ID   = GetLayerID();
02614     INT32 Count     = 1;            // the count of the extra number to give the layer
02615     Layer *pExamine = NULL;
02616     BOOL Unique     = FALSE;
02617     BOOL Changed    = FALSE;        // whether the ID got changed
02618 
02619     do
02620     {
02621         // run through the siblings to find out if their ID match this one
02622         pExamine = pFirstSibling;
02623         Unique = TRUE;
02624         
02625         while (pExamine != NULL)
02626         {
02627             // don't fiddle with this layer
02628             if (pExamine != this)
02629             {
02630                 // OK, does it match?
02631                 Layer *pLayer = pExamine;
02632                 if (pLayer->GetLayerID() == ID)
02633                 {
02634                     // nope
02635                     Unique = FALSE;
02636                     break;
02637                 }
02638             }
02639 
02640             // next thing to look at...
02641             pExamine = pExamine->FindNextLayer();
02642         }
02643 
02644         // right then, is it unique?
02645         if (Unique == FALSE)
02646         {
02647             // munge up a new layer name
02648             Count++;
02649 
02650 // there is a problem here..
02651 // a) ralph has no string resources
02652 // b) MakeMsg has been bodged so that it never fails
02653 // the result is that ralph sits in this loop forever
02654 // ralph doesn't give a fig about layer names so just get out of here 
02655 #ifdef RALPH
02656             return;
02657 #endif
02658             UINT32 format_id = _R(IDT_LAYERNAMEUNIQUEFORM); // "#1%s (#2%d)" 
02659             // If its a frame then use a different form of unique formatter without the brackets
02660             if (IsFrame())
02661                 format_id = _R(IDS_FRAMENAMEUNIQUEFORM);            // "#1%s #2%d"
02662             
02663             if (ID.MakeMsg(format_id, (TCHAR *)GetLayerID(), Count) == 0)
02664                 return;     // error getting a string -- give up! (doesn't really matter as the only problem will be the user seeing two layers with the same name)
02665 
02666             Changed = TRUE;
02667 
02668             // and then try again...
02669         }
02670     
02671     } while (Unique == FALSE);
02672     
02673     // and if it needs to be changed, change it
02674     if (Changed)
02675         SetLayerID(ID);
02676 }
02677 
02678 
02679 /********************************************************************************************
02680 
02681 >   UINT32 Layer::CountNumWritableWebLayers(BaseCamelotFilter* pFilter)
02682 
02683     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02684     Created:    2/8/96
02685     Inputs:     pFilter = ptr to the filter to write to
02686     Outputs:    -
02687     Returns:    The number of layers that will be written in the web file
02688     Purpose:    Counts how many layers are writable, as determined by Layer::CanWriteChildrenWeb()
02689 
02690                 The count looks at all layers, including this one, in the spread to which this layer belongs
02691 
02692     SeeAlso:    CanWriteChildrenWeb()
02693 
02694 ********************************************************************************************/
02695 
02696 UINT32 Layer::CountNumWritableWebLayers(BaseCamelotFilter* pFilter)
02697 {
02698 #ifdef DO_EXPORT
02699 /*****************************************************
02700 See note in BOOL Layer::WritePreChildrenWeb(BaseCamelotFilter* pFilter) for 
02701 a reason why this code is commented out
02702 (markn 12/8/96)
02703 
02704     UINT32 WritableLayerCount = 0;
02705     Spread* pSpread = (Spread*)FindParent(CC_RUNTIME_CLASS(Spread));
02706     if (pSpread != NULL)
02707     {
02708         Layer* pLayer = pSpread->FindFirstLayer();
02709         while (pLayer != NULL)
02710         {
02711             if (pLayer->CanWriteChildrenWeb(pFilter))
02712                 WritableLayerCount++;
02713             pLayer = pLayer->FindNextLayer();
02714         }
02715     }
02716 
02717     return WritableLayerCount;
02718 ******************************************************/
02719 
02720     return 0;
02721 #else
02722     return 0;
02723 #endif
02724 }
02725 
02726 /********************************************************************************************
02727 
02728 >   BOOL Layer::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02729 
02730     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02731     Created:    31/7/96
02732     Inputs:     pFilter = ptr to the filter to write to
02733     Outputs:    -
02734     Returns:    TRUE if the node has written out a record to the filter
02735                 FALSE otherwise
02736     Purpose:    Writes out the layer data suitable for the web format
02737 
02738                 Web files only need to write out the basic layer record - no other info is needed.
02739 
02740                 NOTE:   See Layer::CanWriteChildrenWeb() header for the rules that determine
02741                         whether a layer is actually written or not
02742 
02743     SeeAlso:    CanWriteChildrenWeb()
02744 
02745 ********************************************************************************************/
02746 
02747 BOOL Layer::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02748 {
02749 #ifdef DO_EXPORT
02750     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
02751 
02752     // If the layer doesn't want the children to be written out, then don't write out the layer record
02753     if (!CanWriteChildrenWeb(pFilter))
02754         return FALSE;
02755 
02756 /***************************************
02757 Originally, .web files would not write out a layer node if there was only one layer
02758 i.e. the layer could be implied, hence saving space.
02759 
02760 However, writing the layer node out has benefits when importing .web files.  It means we can easily
02761 make sure undo import works, plus we can cope with redraw problems easier.
02762 
02763 So single-layer docs saved out in the new format will contain a layer node.
02764 (markn 12/8/96)
02765 
02766 -   UINT32 WritableLayerCount = CountNumWritableWebLayers(pFilter);
02767 -   ERROR3IF(WritableLayerCount == 0,"WritableLayerCount should be at least 1");
02768 -
02769 -   // If there aren't 2 or more writable layers, then don't bother 
02770 -   if (WritableLayerCount < 2)
02771 -       return FALSE;
02772 *****************************************/
02773 
02774     CamelotFileRecord Rec(pFilter,TAG_LAYER,TAG_LAYER_SIZE);
02775     return (pFilter->Write(&Rec) != 0);
02776 
02777 #else
02778     return FALSE;
02779 #endif
02780 }
02781 
02782 /********************************************************************************************
02783 
02784 >   BOOL Layer::WritePreChildrenNative(BaseCamelotFilter* pFilter)
02785 
02786     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02787     Created:    31/7/96
02788     Inputs:     pFilter = ptr to the filter to write to
02789     Outputs:    -
02790     Returns:    TRUE if the node has written out a record to the filter
02791                 FALSE otherwise
02792     Purpose:    Writes out the layer data suitable for the native format
02793 
02794     SeeAlso:    WritePreChildrenNative()
02795 
02796 ********************************************************************************************/
02797 
02798 BOOL Layer::WritePreChildrenNative(BaseCamelotFilter* pFilter)
02799 {
02800 #ifdef DO_EXPORT
02801     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
02802 
02803     // If the layer doesn't want the children to be written out, then don't write out the layer record
02804     if (!CanWriteChildrenNative(pFilter))
02805         return FALSE;
02806 
02807     // Always write out the layer record in the native format
02808     CamelotFileRecord Rec(pFilter,TAG_LAYER,TAG_LAYER_SIZE);
02809     return (pFilter->Write(&Rec) != 0);
02810 
02811 #else
02812     return FALSE;
02813 #endif
02814 }
02815 
02816 /********************************************************************************************
02817 
02818 >   BOOL Layer::CanWriteChildrenWeb(BaseCamelotFilter* pFilter)
02819 
02820     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02821     Created:    31/7/96
02822     Inputs:     pFilter = ptr to the filter to write to
02823     Outputs:    -
02824     Returns:    TRUE if it's ok to write out the layer's children
02825                 FALSE otherwise
02826     Purpose:    Determines if the layer should write out its contents in the web format
02827 
02828                 Web files will not write out the following types of layer:
02829                     Invisible layers
02830                     Layers than contain no renderable objects
02831                     Guide layers
02832 
02833     SeeAlso:    WritePreChildrenNative()
02834 
02835 ********************************************************************************************/
02836 
02837 BOOL Layer::CanWriteChildrenWeb(BaseCamelotFilter* pFilter)
02838 {
02839 #ifdef DO_EXPORT
02840     // If not visible and not a animated GIF frame layer, don't bother
02841     if (!IsVisible() && !IsFrame())
02842         return FALSE;
02843 
02844     // If a guide layer, don't bother
02845     if (IsGuide())
02846         return FALSE;
02847 
02848     // If no renderable objects on the layer and not a animated GIF frame layer, don't bother
02849     if (!IsFrame())
02850     {
02851         DocRect Rect = GetBoundingRect();
02852         if (Rect.IsEmpty())
02853             return FALSE;
02854     }
02855 
02856     return TRUE;
02857 #else
02858     return FALSE;
02859 #endif
02860 }
02861 
02862 /********************************************************************************************
02863 
02864 >   BOOL Layer::CanWriteChildrenNative(BaseCamelotFilter* pFilter)
02865 
02866     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02867     Created:    31/7/96
02868     Inputs:     pFilter = ptr to the filter to write to
02869     Outputs:    -
02870     Returns:    TRUE if it's ok to write out the layer's children
02871                 FALSE otherwise
02872     Purpose:    Determines if the layer should write out its contents in the native format
02873 
02874                 Native files will not write out layers when:
02875                     It's actually the cack compact format AND
02876                     The user has selected "Remove invisible layers" AND
02877                     The layer is invisible
02878                     The layer is NOT a frame layer
02879 
02880     SeeAlso:    WritePreChildrenNative()
02881 
02882 ********************************************************************************************/
02883 
02884 BOOL Layer::CanWriteChildrenNative(BaseCamelotFilter* pFilter)
02885 {
02886 #ifdef DO_EXPORT
02887 
02888     // if we are saving in the compact format, and
02889     // the user has selected to remove invisible layers & the layer is invisible,
02890     // then don't let the children go out
02891     if (pFilter->IsCompactNativeFilter())
02892     {
02893         // If user doesn't want visible layers, and it's not visible and it's not a animated GIF frame layer, don't bother
02894         if (pFilter->GetRemoveInvisibleLayers() && !IsVisible() && !IsFrame())
02895             return FALSE;
02896     }
02897 
02898     return Node::CanWriteChildrenNative(pFilter);
02899 #else
02900     return FALSE;
02901 #endif
02902 }
02903 
02904 /********************************************************************************************
02905 
02906 >   BOOL Layer::WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter)
02907 
02908     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02909     Created:    1/8/96
02910     Inputs:     pFilter = ptr to the filter to write to
02911     Outputs:    -
02912     Returns:    TRUE if the node has written out a record to the filter
02913                 FALSE otherwise
02914     Purpose:    Begins the child record sequence for layers in the native format
02915 
02916                 The native format writes out all layers and includes the layer details record 
02917                 as the layer's first child record
02918 
02919     SeeAlso:    WritePreChildrenNative()
02920 
02921 ********************************************************************************************/
02922 
02923 BOOL Layer::WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter)
02924 {
02925 #ifdef DO_EXPORT
02926     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
02927 
02928     // First thing to do is write out the Down record
02929     BOOL ok = (pFilter->WriteZeroSizedRecord(TAG_DOWN));
02930 
02931     // The colour ref used in the guide layer info record
02932     INT32 ColRef = 0;
02933 
02934     // Firstly, if it's a guide layer write out the colour definition
02935     if (ok && IsGuide())
02936     {
02937         DocColour* pColour = GetGuideColour();
02938 
02939         if (pColour != NULL)
02940             ColRef = pFilter->WriteRecord(pColour);
02941 
02942         if (ColRef == 0)
02943         {
02944             pFilter->GotError(_R(IDE_FILE_WRITE_ERROR));
02945             ok = FALSE;
02946         }
02947     }
02948 
02949     if (ok)
02950     {
02951         // Assume it's a normal layer (i.e. not a guide layer)
02952         UINT32 Tag  = TAG_LAYERDETAILS;
02953         INT32  Size = TAG_LAYERDETAILS_SIZE;
02954 
02955         // If it's a guide layer, change the tag & size values
02956         if (IsGuide())
02957         {
02958             Tag  = TAG_GUIDELAYERDETAILS;
02959             Size = TAG_GUIDELAYERDETAILS_SIZE;
02960         }
02961 
02962         // Build the flags byte
02963         BYTE Flags = 0;
02964         if (GetVisibleFlagState())  Flags |= TAG_LAYER_FLAG_VISIBLE;
02965         if (GetLockedFlagState())   Flags |= TAG_LAYER_FLAG_LOCKED;
02966         if (IsPrintable())          Flags |= TAG_LAYER_FLAG_PRINTABLE;
02967         if (IsActive())             Flags |= TAG_LAYER_FLAG_ACTIVE;
02968         // new 4/4/97
02969         if (IsPageBackground())     Flags |= TAG_LAYER_FLAG_PAGEBACKGROUND;
02970         if (IsBackground())         Flags |= TAG_LAYER_FLAG_BACKGROUND;
02971 
02972         // Create a record and write to it
02973         CamelotFileRecord Rec(pFilter,Tag,Size);
02974         if (ok) ok = Rec.Init();
02975         if (ok) ok = Rec.WriteBYTE(Flags);
02976         if (ok) ok = Rec.WriteUnicode(GetLayerID());
02977 
02978         // Make sure the guide layer details include the colour ref
02979         if (ok && Tag == TAG_GUIDELAYERDETAILS)
02980             ok = Rec.WriteReference(ColRef);
02981 
02982         // Write the details record to the file.
02983         ok = (pFilter->Write(&Rec) != 0);
02984 
02985         // Only write out the frame properties if it is a frame layer
02986         if (ok && IsFrame()) ok = WriteFrameLayerProperties(pFilter);
02987 
02988         ok = WriteAtomicNodesColourRefs (this, pFilter);
02989     }
02990 
02991     return ok;
02992 #else
02993     return FALSE;
02994 #endif
02995 }
02996 
02997 /********************************************************************************************
02998 
02999 >   BOOL Layer::WriteEndChildRecordsNative(BaseCamelotFilter* pFilter)
03000 
03001     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03002     Created:    1/8/96
03003     Inputs:     pFilter = ptr to the filter to write to
03004     Outputs:    -
03005     Returns:    TRUE if the node has written out a record to the filter
03006                 FALSE otherwise
03007     Purpose:    Ends the child record sequence for layers in the native format
03008 
03009                 The native format writes out all layers.  This func just writes out the Up record
03010 
03011     SeeAlso:    WritePreChildrenNative()
03012 
03013 ********************************************************************************************/
03014 
03015 BOOL Layer::WriteEndChildRecordsNative(BaseCamelotFilter* pFilter)
03016 {
03017 #ifdef DO_EXPORT
03018     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
03019     return pFilter->WriteZeroSizedRecord(TAG_UP);
03020 #else
03021     return FALSE;
03022 #endif
03023 }
03024 
03025 
03026 //-------------------------------------------------------------------
03027 // These stubs have been put in so that layer.h doesn't have to get touched if they need
03028 // implementing.
03029 
03030 BOOL Layer::WritePostChildrenWeb(BaseCamelotFilter* pFilter)
03031 {
03032     return Node::WritePostChildrenWeb(pFilter);
03033 }
03034 
03035 BOOL Layer::WritePostChildrenNative(BaseCamelotFilter* pFilter)
03036 {
03037     return Node::WritePostChildrenNative(pFilter);
03038 }
03039 
03040 BOOL Layer::WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter)
03041 {
03042 /*****************************************************
03043 See note in BOOL Layer::WritePreChildrenWeb(BaseCamelotFilter* pFilter) for 
03044 a reason why this code is commented out
03045 (markn 12/8/96)
03046 
03047 -   UINT32 WritableLayerCount = CountNumWritableWebLayers(pFilter);
03048 -
03049 -   if (WritableLayerCount < 2)
03050 -       return TRUE;
03051 ******************************************************/
03052 
03053     return Node::WriteBeginChildRecordsWeb(pFilter);
03054 }
03055 
03056 BOOL Layer::WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter)
03057 {
03058 /*****************************************************
03059 See note in BOOL Layer::WritePreChildrenWeb(BaseCamelotFilter* pFilter) for 
03060 a reason why this code is commented out
03061 (markn 12/8/96)
03062 
03063 -   UINT32 WritableLayerCount = CountNumWritableWebLayers(pFilter);
03064 -
03065 -   if (WritableLayerCount < 2)
03066 -       return TRUE;
03067 ******************************************************/
03068 
03069     return Node::WriteEndChildRecordsWeb(pFilter);
03070 }
03071 
03072 BOOL Layer::ReadPostChildrenWeb(BaseCamelotFilter* pFilter)
03073 {
03074     if (pFilter != NULL)
03075         pFilter->InvalidateRegion(this);
03076 
03077     return Node::ReadPostChildrenWeb(pFilter);
03078 }
03079 
03080 BOOL Layer::ReadPostChildrenNative(BaseCamelotFilter* pFilter)
03081 {
03082     if (pFilter != NULL)
03083         pFilter->InvalidateRegion(this);
03084 
03085     return Node::ReadPostChildrenNative(pFilter);
03086 }
03087 
03088 
03089 /********************************************************************************************
03090 
03091 >   DocColour* Layer::GetGuideColour()
03092 
03093     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03094     Created:    10/10/95
03095     Inputs:     -
03096     Outputs:    -
03097     Returns:    ptr to the DocColour attached to this layer
03098     Purpose:    Returns the DocColour that specifies the colour to render the guide objects
03099                 in this layer with.
03100     SeeAlso:    SetGuideColour()
03101 
03102 ********************************************************************************************/
03103 
03104 DocColour* Layer::GetGuideColour()
03105 {
03106     if (pGuideColour == NULL)
03107         SetGuideColour(NULL);
03108 
03109     return (pGuideColour);
03110 }
03111 
03112 /********************************************************************************************
03113 
03114 >   void Layer::SetGuideColour(IndexedColour* pIndexedColour)
03115 
03116     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03117     Created:    10/10/95
03118     Inputs:     pIndexedColour = ptr to IndexedColour (NULL means set to default)
03119     Outputs:    -
03120     Returns:    -
03121     Purpose:    Assigns the given indexed colour as the colour to render guide objects in this layer in.
03122     SeeAlso:    GetGuideColour()
03123 
03124 ********************************************************************************************/
03125 
03126 void Layer::SetGuideColour(IndexedColour* pIndexedColour)
03127 {
03128     if (pGuideColour == NULL)
03129         pGuideColour = new DocColour();
03130 
03131     if (pGuideColour != NULL)
03132     {
03133         if (pIndexedColour == NULL)
03134         {
03135             ColourValue r = ColourValue(double(GuideLayerRed)   / double(COL_MAX));
03136             ColourValue g = ColourValue(double(GuideLayerGreen) / double(COL_MAX));
03137             ColourValue b = ColourValue(double(GuideLayerBlue)  / double(COL_MAX));
03138             pIndexedColour = new IndexedColour(r,g,b);
03139             pIndexedGuideColour = pIndexedColour;
03140         }
03141 
03142         if (pIndexedColour != NULL)
03143             pGuideColour->MakeRefToIndexedColour(pIndexedColour);
03144     }
03145 }
03146 
03147 /********************************************************************************************
03148 
03149 >   void Layer::MakeGuideColourDefault()
03150 
03151     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03152     Created:    10/10/95
03153     Inputs:     -
03154     Outputs:    -
03155     Returns:    -
03156     Purpose:    Makes the current colour the default for all guide layers
03157     SeeAlso:    GetGuideColour(),SetGuideColour()
03158 
03159 ********************************************************************************************/
03160 
03161 void Layer::MakeGuideColourDefault()
03162 {
03163 #if !defined(EXCLUDE_FROM_RALPH)
03164     if (pGuideColour != NULL)
03165     {
03166         INT32 Red,Green,Blue;
03167         pGuideColour->GetRGBValue(&Red,&Green,&Blue);
03168         GuideLayerRed   = INT32(Red);
03169         GuideLayerGreen = INT32(Green);
03170         GuideLayerBlue  = INT32(Blue);
03171     }
03172 #endif
03173 }
03174 
03175 /********************************************************************************************
03176 
03177 >   DocColour Layer::GetDefaultGuideColour()
03178 
03179     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03180     Created:    10/10/95
03181     Inputs:     -
03182     Outputs:    -
03183     Returns:    The DocColour that represents the default colour settings
03184     Purpose:    Makes the current colour the default for all guide layers
03185     SeeAlso:    GetGuideColour(),SetGuideColour()
03186 
03187 ********************************************************************************************/
03188 
03189 DocColour Layer::GetDefaultGuideColour()
03190 {
03191 #if !defined(EXCLUDE_FROM_RALPH)
03192     ColourValue r = ColourValue(double(GuideLayerRed)   / double(COL_MAX));
03193     ColourValue g = ColourValue(double(GuideLayerGreen) / double(COL_MAX));
03194     ColourValue b = ColourValue(double(GuideLayerBlue)  / double(COL_MAX));
03195 
03196     DocColour Col(r,g,b);
03197 
03198     return Col;
03199 #else
03200     return DocColour(0,0,0);
03201 #endif
03202 }
03203 
03204 /********************************************************************************************
03205 
03206 >   void Layer::ColourChanged(IndexedColour* pChangedColour)
03207 
03208     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03209     Created:    10/10/95
03210     Inputs:     pChangedColour = ptr to the colour that's just changed
03211     Outputs:    -
03212     Returns:    -
03213     Purpose:    Called when a colour has changed.
03214     SeeAlso:    ColourDeleted()
03215 
03216 ********************************************************************************************/
03217 
03218 void Layer::ColourChanged(IndexedColour* pChangedColour)
03219 {
03220 // WEBSTER - markn 15/1/97
03221 // Don't need this in Webster
03222 #ifndef WEBSTER
03223 #if !defined(EXCLUDE_FROM_RALPH)
03224     if (pChangedColour == NULL || pGuideColour == NULL)
03225         return;
03226 
03227     IndexedColour* pColour = pGuideColour->FindParentIndexedColour();
03228 
03229     if (pChangedColour == pColour)
03230     {
03231         Document* pDoc = Document::GetCurrent();
03232         if (pDoc != NULL)
03233             LayerSGallery::ForceRedrawLayer(pDoc,this);
03234     }
03235 #endif
03236 #endif // WEBSTER
03237 }
03238 
03239 /********************************************************************************************
03240 
03241 >   void Layer::ColourDeleted()
03242 
03243     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03244     Created:    10/10/95
03245     Inputs:     -
03246     Outputs:    -
03247     Returns:    -
03248     Purpose:    Called when a colour may have been deleted.
03249     SeeAlso:    ColourChanged()
03250 
03251 ********************************************************************************************/
03252 
03253 void Layer::ColourDeleted()
03254 {
03255 #if !defined(EXCLUDE_FROM_RALPH)
03256     if (pGuideColour != NULL)
03257     {
03258         IndexedColour* pIndexedColour = pGuideColour->FindParentIndexedColour();
03259 
03260         if (pIndexedColour != NULL && pIndexedColour->IsDeleted())
03261         {
03262             ColourGeneric ColGen;
03263             pIndexedColour->GetSourceColour(&ColGen);
03264             ColourModel Model = pIndexedColour->GetColourModel();
03265 
03266             IndexedColour* pNewColour = new IndexedColour(Model,&ColGen);
03267 
03268             SetGuideColour(pNewColour);
03269 //          Document* pDoc = Document::GetCurrent();
03270 //          if (pDoc != NULL)
03271 //              LayerSGallery::ForceRedrawLayer(pDoc,this);
03272         }
03273     }
03274 #endif
03275 }
03276 
03277 /***********************************************************************************************
03278 
03279 >   static Layer* Layer::CreateGuideLayer()
03280 
03281     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03282     Created:    4/10/95
03283     Inputs:     -
03284     Outputs:    -
03285     Returns:    Ptr to a guide layer that's ready to be inserted into the tree
03286     Purpose:    This does everything required in creating a layer fit to be called the guide layer
03287 
03288                 // WEBSTER - markn - 15/1/97
03289                 // Moved from OpGuideLine for WEBSTER purposes, but it should be in this class anyway
03290     SeeAlso:    -
03291         
03292 ***********************************************************************************************/
03293 
03294 Layer* Layer::CreateGuideLayer()
03295 {
03296     Layer* pNewLayer = new Layer;
03297     if (pNewLayer != NULL)
03298     {
03299         String_256 LayerName(_R(IDS_GUIDESLAYERNAME));
03300 
03301         pNewLayer->SetVisible(TRUE); 
03302         pNewLayer->SetLocked(FALSE); 
03303         pNewLayer->SetPrintable(FALSE); 
03304 //      pNewLayer->SetBackground(TRUE);
03305         pNewLayer->SetBackground(FALSE);    // make sure Guides are in the "normal" foreground section
03306         pNewLayer->SetOutline(FALSE);
03307         pNewLayer->SetGuide(TRUE);
03308         pNewLayer->SetLayerID(LayerName); 
03309 
03310         Quality Qual;
03311         Qual.SetQuality(-1);
03312         QualityAttribute QualAttr(Qual);
03313         NodeAttribute* pNodeAttr = QualAttr.MakeNode();
03314         pNodeAttr->AttachNode(pNewLayer,FIRSTCHILD);
03315     }
03316 
03317     return pNewLayer;
03318 }
03319 
03320 /********************************************************************************************
03321 
03322 >   BOOL Layer::WriteFrameLayerProperties(BaseCamelotFilter* pFilter)
03323 
03324     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
03325     Created:    8/5/97
03326     Input:      pFilter = ptr to the filter to export to.
03327     Outputs:    -
03328     Returns:    TRUE if ok, FALSE otherwise.
03329     Purpose:    Exports the delay details for this frame layer to the filter.
03330         
03331 ********************************************************************************************/
03332 
03333 BOOL Layer::WriteFrameLayerProperties(BaseCamelotFilter* pFilter)
03334 {
03335 #ifdef DO_EXPORT
03336     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
03337 
03338     BOOL RecordWritten = FALSE;
03339     BOOL ok = TRUE;
03340 
03341     // Add a description of the TAG_LAYER_FRAMEPROPS record, for older importers that don't understand this record
03342     pFilter->AddTagDescription(TAG_LAYER_FRAMEPROPS, _R(IDS_TAG_LAYER_FRAMEPROPS));
03343 
03344     // Start a record to save our data in
03345     CXaraFileRecord Rec(TAG_LAYER_FRAMEPROPS, TAG_LAYER_FRAMEPROPS_SIZE);
03346     // Get the Frame delay inforamtion.
03347     DWORD Delay = GetFrameDelay();
03348     BYTE Flags = 0;
03349 
03350     if (IsSolid())          Flags |= TAG_LAYER_FLAG_SOLID;
03351     if (IsOverlay())        Flags |= TAG_LAYER_FLAG_OVERLAY;
03352     if (IsHiddenFrame())    Flags |= TAG_LAYER_FLAG_HIDDEN;
03353         
03354     ok = Rec.Init();
03355 
03356     if (ok)
03357         ok = Rec.WriteUINT32(Delay);    
03358 
03359     if (ok)
03360         ok = Rec.WriteBYTE(Flags);  
03361 
03362     // Write out the record.
03363     if (ok) ok = (pFilter->Write(&Rec) != 0);
03364     if (ok)
03365         RecordWritten = TRUE;
03366     else
03367         pFilter->GotError(_R(IDE_FILE_WRITE_ERROR));
03368 
03369     return RecordWritten;
03370 #else
03371     return FALSE;   
03372 #endif 
03373 
03374 };
03375 
03376 /********************************************************************************************
03377 
03378 >   PathName Layer::MakeExportLayerName(const PathName& path)
03379 
03380     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
03381     Created:    24/03/2004
03382     Input:      PathName - original pathname
03383     Outputs:    -
03384     Returns:    PathName - modified pathname
03385     Purpose:    Make a pathname that's specific to this layer
03386         
03387 ********************************************************************************************/
03388 
03389 PathName Layer::MakeExportLayerName(const PathName& path)
03390 {
03391     PathName pathLayer = path;
03392 
03393     String_256 filename = path.GetFileName(FALSE);
03394     filename += String( _T(" ") );
03395 //  if (LayerSt.StringLayerID.SubWithoutCase("Layer")==-1)
03396 //      filename += String("Layer ");
03397     filename += LayerSt.StringLayerID;
03398     pathLayer.SetFileName(filename);
03399 
03400     return pathLayer;
03401 };
03402 
03403 //-----------------------------------------------------
03404 //-----------------------------------------------------
03405 //-----------------------------------------------------
03406 
03407 /********************************************************************************************
03408 
03409 >   LayerMsgHandler::LayerMsgHandler()
03410 
03411     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03412     Created:    10/10/95
03413     Purpose:    Constructs a LayerMsgHandler, an object which handles messages for layers
03414     Errors:     -
03415     SeeAlso:    MessageHandler
03416 
03417 ********************************************************************************************/
03418 
03419 LayerMsgHandler::LayerMsgHandler()
03420   : MessageHandler(CC_RUNTIME_CLASS(MessageHandler), TRUE)
03421 {
03422 }
03423 
03424 /********************************************************************************************
03425 
03426 >   virtual MsgResult LayerMsgHandler::Message(Msg* Message)
03427 
03428     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03429     Created:    10/10/95
03430     Inputs:     Message: The message
03431 
03432     Purpose:    Process messages on behalf of layers
03433 
03434 ********************************************************************************************/
03435 
03436 MsgResult LayerMsgHandler::Message(Msg* Message)
03437 {
03438 #if !defined(EXCLUDE_FROM_RALPH)
03439     if (MESSAGE_IS_A(Message, ColourChangingMsg))
03440     {
03441         ColourChangingMsg *Msg = (ColourChangingMsg *) Message;
03442         switch ( Msg->State )
03443         {
03444             case ColourChangingMsg::LISTDELETED:
03445             case ColourChangingMsg::LISTDESELECTED:
03446             case ColourChangingMsg::LISTPAGED:
03447             case ColourChangingMsg::LISTUPDATED:
03448                 if (Msg->ScopeDoc != NULL)
03449                 {
03450 PORTNOTE("spread", "Multi-spread warning!")
03451                     Spread* pSpread = Msg->ScopeDoc->FindFirstSpread();
03452                     if (pSpread != NULL)
03453                     {
03454                         Layer* pGuideLayer = pSpread->FindFirstGuideLayer();
03455                         if (pGuideLayer != NULL)
03456                             pGuideLayer->ColourDeleted();
03457                     }
03458                 }               
03459                 break;
03460 
03461             case ColourChangingMsg::COLOURUPDATED:
03462                 if (Msg->ScopeDoc != NULL)
03463                 {
03464 PORTNOTE("spread", "Multi-spread warning!")
03465                     Spread* pSpread = Msg->ScopeDoc->FindFirstSpread();
03466                     if (pSpread != NULL)
03467                     {
03468                         Layer* pGuideLayer = pSpread->FindFirstGuideLayer();
03469                         if (pGuideLayer != NULL)
03470                             pGuideLayer->ColourChanged(Msg->ChangedColour);
03471                     }
03472                 }               
03473                 break;
03474             default:
03475                 break;
03476         }
03477     }
03478 #endif
03479     return OK; 
03480 }
03481 
03482 
03483 
03484 /********************************************************************************************
03485 
03486   > virtual BOOL ShouldWriteColourDefinitions (Node* pNode)
03487 
03488     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
03489     Created:    14/9/2000
03490     Inputs:     pNode = ptr to node
03491     Returns:    TRUE if record should be written, FALSE if not
03492     Purpose:    Determins whether colour definitions should be written for this node
03493     SeeAlso:    BaseCamelotFilter::WriteRemainingAtomicTagDefinitions ()
03494                 Layer::WriteAtomicNodesColourRefs ()
03495 
03496 ********************************************************************************************/
03497 
03498 BOOL ShouldWriteColourDefinitions (Node* pNode)
03499 {
03500     CCRuntimeClass * pClass = CC_RUNTIME_CLASS(NodeBevelController);
03501     BOOL done = FALSE;
03502     INT32 i = 0;
03503 
03504     while (!done)
03505     {
03506         Node* pParent = pNode->FindParent (pClass);
03507 
03508         if (pParent)
03509         {
03510             return (TRUE);
03511         }
03512 
03513         switch (i)
03514         {
03515             case 0:
03516                 pClass = CC_RUNTIME_CLASS(NodeContourController);
03517             break;
03518             case 1:
03519                 pClass = CC_RUNTIME_CLASS(NodeShadowController);
03520             break;
03521             case 2:
03522                 pClass = CC_RUNTIME_CLASS(NodeClipViewController);
03523             break;
03524             default:
03525                 done = TRUE;
03526         }
03527 
03528         i++;
03529     }
03530     return (FALSE);
03531 }
03532 
03533 
03534 
03535 /********************************************************************************************
03536 
03537 >   BOOL Layer::WriteAtomicNodesColourRefs (Node* pLayer, BaseCamelotFilter* pFilter)
03538 
03539     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
03540     Created:    14/9/2000
03541     Inputs:     -
03542     Outputs:    -
03543     Returns:    TRUE if written, FALSE otherwise
03544     Purpose:    All compound nodes (e.g.  bevels, contours, shadows, clipview) are now defined
03545                 as being atomic.  This is so that they can be backwards compatible with CX2.
03546                 This means that colour definitions that occur within these nodes are omitted
03547                 when CX2 reads the files.  The cause access violations when another colour
03548                 definition references the omitted.  Thus, compund atomic nodes MUST write
03549                 colour definitions BEFORE the node is written.  The function scans the document
03550                 for relevent nodes, and cause them to write out their colour definitions
03551                 immediately after the layer node.  This is only done of compound atomic nodes,
03552                 since doing it for all would slow down other peoples distributed stuff.
03553     Errors:     -
03554     SeeAlso:    BaseCamelotFilter::WriteRemainingAtomicTagDefinitions ()
03555                 Layer::WriteAtomicNodesColourRefs ()
03556                 AttrFillGeometry::WriteColourDefinitions ()
03557 
03558 ********************************************************************************************/
03559 
03560 BOOL Layer::WriteAtomicNodesColourRefs (Node* pLayer, BaseCamelotFilter* pFilter)
03561 {
03562     BOOL ok = TRUE;
03563 
03564     CCRuntimeClass * pClass = CC_RUNTIME_CLASS(AttrFlatColourFill);
03565     BOOL done = FALSE;
03566     INT32 i = 0;
03567 
03568     while (!done)
03569     {
03570         AttrFillGeometry* pNode = (AttrFillGeometry*) SliceHelper::FindNextOfClass(pLayer, pLayer, pClass);
03571 
03572         while (pNode)
03573         {
03574             if (ShouldWriteColourDefinitions (pNode))
03575             {
03576                 ok = pNode->WriteColourDefinitions (pFilter);
03577             }
03578             pNode = (AttrFillGeometry*) SliceHelper::FindNextOfClass(pNode, pLayer, pClass);
03579         }
03580         if (!ok) done = TRUE;
03581         switch (i)
03582         {
03583             case 0:
03584                 pClass = CC_RUNTIME_CLASS(AttrLinearColourFill);
03585             break;
03586             case 1:
03587                 pClass = CC_RUNTIME_CLASS(AttrRadialColourFill);
03588             break;
03589             case 2:
03590                 pClass = CC_RUNTIME_CLASS(AttrConicalColourFill);
03591             break;
03592             case 3:
03593                 pClass = CC_RUNTIME_CLASS(AttrSquareColourFill);
03594             break;
03595             case 4:
03596                 pClass = CC_RUNTIME_CLASS(AttrThreeColColourFill);
03597             break;
03598             case 5:
03599                 pClass = CC_RUNTIME_CLASS(AttrFourColColourFill);
03600             break;
03601             case 6:
03602                 pClass = CC_RUNTIME_CLASS(AttrBitmapColourFill);
03603             break;
03604             case 7:
03605                 pClass = CC_RUNTIME_CLASS(AttrFractalColourFill);
03606             break;
03607             case 8:
03608                 pClass = CC_RUNTIME_CLASS(AttrNoiseColourFill);
03609             break;
03610             case 9:
03611                 pClass = CC_RUNTIME_CLASS(AttrStrokeColour);
03612             break;
03613             default:
03614                 done = TRUE;
03615         }
03616 
03617         i++;
03618     }
03619 
03620     return (ok);
03621 }

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