00001 // $Id: layer.h 1282 2006-06-09 09:46:49Z 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 // declares LayerStatus and Layer classes 00100 00101 #ifndef INC_LAYER 00102 #define INC_LAYER 00103 00104 //#include "npaper.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 //#include "convert.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 //#include "quality.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 00109 class Document; 00110 class DocView; 00111 class DocColour; 00112 class IndexedColour; 00113 class LayerMsgHandler; 00114 //class KernelBitmapRef; 00115 00116 /******************************************************************************************** 00117 00118 > class LayerStatus: public CCObject 00119 00120 Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> 00121 Created: 4/1/94 00122 Purpose: This class (structure) holds layer information which can be changed by the 00123 user. 00124 The reason that this information is held in a seperate class is that it needs 00125 to be stored in both the Layer and Layer Manager classes. 00126 SeeAlso: Layer 00127 LayerManager 00128 00129 ********************************************************************************************/ 00130 00131 00132 class LayerStatus 00133 { 00134 public: 00135 String_256 StringLayerID; // Layer identifier. This should be unique within a spread 00136 00137 LayerStatus(); 00138 LayerStatus(LayerStatus& ls); 00139 INT32 operator==(LayerStatus); 00140 }; 00141 00142 /*********************************************************************************************** 00143 00144 > class Layer : public NodeRenderablePaper 00145 00146 Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> 00147 Created: 25/4/93 00148 Purpose: Layers optionally exist on a page, they group together objects which are drawn 00149 at a particular level in a document. 00150 00151 SeeAlso: NodeRenderablePaper 00152 SeeAlso: Chapter 00153 SeeAlso: Spread 00154 SeeAlso: Page 00155 00156 ***********************************************************************************************/ 00157 00158 class Layer: public NodeRenderablePaper 00159 { 00160 CC_DECLARE_DYNAMIC( Layer ) 00161 public: 00162 00163 Layer(); 00164 ~Layer(); 00165 00166 Layer(Node* ContextNode, 00167 AttachNodeDirection Direction, 00168 const String_256 &LayerID, 00169 BOOL Locked=FALSE, 00170 BOOL Mangled=FALSE, 00171 BOOL Marked=FALSE, 00172 BOOL Selected=FALSE 00173 ); 00174 00175 static BOOL Init(); 00176 static void Deinit(); 00177 00178 String Describe(BOOL Plural, BOOL Verbose); 00179 00180 virtual SubtreeRenderState RenderSubtree(RenderRegion *pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE); 00181 virtual void RenderAfterSubtree(RenderRegion *pRender); 00182 00183 virtual BOOL NeedsToExport(RenderRegion *pRender,BOOL VisibleLayersOnly = FALSE, 00184 BOOL CheckSelected = FALSE); 00185 void PreExportRender(RenderRegion* pRegion); 00186 BOOL ExportRender(RenderRegion* pRegion); 00187 BOOL IsLayer() const; 00188 00189 // obtains its page's pasteboard rectangle 00190 // obtains its page's pasteboard rectangle 00191 DocRect GetPasteboardRect(BOOL Pixelise = TRUE, View *pView = NULL) const; 00192 00193 #ifdef _DEBUG 00194 void ShowDebugTreeDetails() const; 00195 #endif 00196 00197 Layer* FindNextLayer(BOOL ExcludeInvisible = FALSE, BOOL ExcludeLocked = FALSE); 00198 Layer* FindPrevLayer(BOOL ExcludeInvisible = FALSE, BOOL ExcludeLocked = FALSE); 00199 00200 // Special frame related find layer functions 00201 Layer* FindNextFrameLayer(); 00202 Layer* FindPrevFrameLayer(); 00203 00204 // Called when a node is being hidden 00205 virtual BOOL HidingNode(); 00206 00207 // Query Layer status functions 00208 BOOL IsVisible(DocView* pDocView = NULL); 00209 BOOL IsLocked(); 00210 BOOL IsActive(); 00211 BOOL IsPrintable(); 00212 BOOL IsBackground(); 00213 BOOL IsOutline(); 00214 BOOL IsGuide(); 00215 BOOL IsPageBackground(); 00216 String_256& GetLayerID(); 00217 00218 // Query Frame status functions 00219 BOOL IsOverlay(); 00220 BOOL IsSolid(); 00221 BOOL IsEdited(); 00222 BOOL IsFrame(); 00223 BOOL IsHiddenFrame(); 00224 00225 BOOL IsPseudoFrame(); 00226 00227 // These functions are used to return the real settings of some of the flags 00228 // This is because some IsX() functions take other things into account 00229 BOOL GetVisibleFlagState(); 00230 BOOL GetLockedFlagState(); 00231 00232 // Has the layer got any renderable children 00233 BOOL HasLayerGotRenderableChildren(); 00234 00235 // When going through the layers to work out bounding boxes for the drawing 00236 // use this to determine if a layer should be included in the calculation 00237 BOOL IncludeLayerInBoundingCalcs(); 00238 00239 LayerStatus& GetLayerStatus(); 00240 00241 public: 00242 // Set Layers status functions 00243 void SetVisible(BOOL Status); 00244 void SetLocked(BOOL Status); 00245 void SetActive(BOOL Status); 00246 void SetPrintable(BOOL Status); 00247 void SetBackground(BOOL Status); 00248 void SetOutline(BOOL Status); 00249 void SetGuide(BOOL Status); 00250 void SetPageBackground(BOOL Status); 00251 void SetLayerID(String_256& LayerID); 00252 void SetLayerStatus(LayerStatus& Status); 00253 00254 // Set frame status functions 00255 void SetSolid(BOOL Status); 00256 void SetOverlay(BOOL Status); 00257 void SetEdited(BOOL Status); 00258 void SetFrame(BOOL Status); 00259 void SetHiddenFrame(BOOL Status); 00260 00261 void EnsureUniqueLayerID(void); 00262 00263 public: 00264 void GetDebugDetails(StringBase* Str); 00265 virtual UINT32 GetNodeSize() const; // Returns size of node in bytes 00266 00267 // Returns the bounding rect of the layer inflated by the size of a blob 00268 virtual DocRect GetBlobBoundingRect(); 00269 00270 BOOL BelongsToDocument(Document* pDoc); 00271 Document* FindDocument(); 00272 00273 // Op permission functions 00274 virtual BOOL AllowOp(ObjChangeParam* pParam,BOOL SetOpPermissionState = TRUE, 00275 BOOL DoPreTriggerEdit = TRUE); 00276 virtual void SetOpPermission(OpPermissionState NewState,BOOL AndParents = FALSE); 00277 00278 static BOOL ActiveLayerVisibleAndEditable; 00279 static INT32 EnableLayerCacheing; 00280 00281 // Guide layer colour stuff 00282 DocColour* GetGuideColour(); 00283 void SetGuideColour(IndexedColour* pIndexedColour); 00284 void MakeGuideColourDefault(); 00285 DocColour GetDefaultGuideColour(); 00286 void ColourChanged(IndexedColour* pChangedColour); 00287 void ColourDeleted(); 00288 00289 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy); 00290 00291 public: 00292 // Version 2 file format functions 00293 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter); 00294 virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter); 00295 virtual BOOL WritePostChildrenWeb(BaseCamelotFilter* pFilter); 00296 virtual BOOL WritePostChildrenNative(BaseCamelotFilter* pFilter); 00297 virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter); 00298 virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter); 00299 00300 virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter); 00301 virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter); 00302 virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter); 00303 virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter); 00304 00305 virtual BOOL ReadPostChildrenWeb(BaseCamelotFilter* pFilter); 00306 virtual BOOL ReadPostChildrenNative(BaseCamelotFilter* pFilter); 00307 00308 virtual UINT32 CountNumWritableWebLayers(BaseCamelotFilter* pFilter); 00309 00310 virtual BOOL WriteAtomicNodesColourRefs (Node* pLayer, BaseCamelotFilter* pFilter); 00311 virtual PathName MakeExportLayerName(const PathName& path); 00312 00313 // WEBSTER - markn 15/1/97 00314 // Moved CreateGuideLayer() from OpGuideline class 00315 static Layer* CreateGuideLayer(); 00316 00317 public: 00318 // Frame related functions 00319 virtual BOOL WriteFrameLayerProperties(BaseCamelotFilter* pFilter); 00320 00321 DWORD GetFrameDelay(); 00322 void SetFrameDelay(const DWORD& Delay); 00323 00324 // The quality level that the animation was captured at 00325 Quality GetCaptureQuality() { return m_CaptureQuality; } 00326 void SetCaptureQuality(const Quality& NewQuality) { m_CaptureQuality = NewQuality; } 00327 00328 // Generated Bitmap related functions 00329 KernelBitmap * GetGeneratedBitmap(); 00330 BOOL SetGeneratedBitmap(KernelBitmap * pBitmap); 00331 // Overide this so that our bitmaps get included in the counting process 00332 virtual KernelBitmap * EnumerateBitmaps(UINT32 Count); 00333 // Referenced Bitmap related functions 00334 KernelBitmap * GetReferencedBitmap(); 00335 BOOL SetReferencedBitmap(KernelBitmap * pBitmap); 00336 00337 // Functions for handling child nodes changing inside compound node, 00338 // We override this so we can mark the layer as edited 00339 virtual ChangeCode OnChildChange(ObjChangeParam* pParam); 00340 00341 private: 00342 LayerStatus LayerSt; // All layer info which can be changed by the user in an undoable way 00343 00344 BOOL Active; // The active layer is the layer to which new objects get added. A single layer 00345 // within a spread must always be active. 00346 BOOL Visible; // This flag indicates if the layer should be rendered or not 00347 BOOL Locked; // If a layer is locked then it should not be modifiable. i.e the user should 00348 // not be able to change or add new objects to the layer. 00349 BOOL Printable; // Indicates if the layer should be rendered to the printer 00350 BOOL Background; // ??? Prints at half tone (or something like this, need to find out !!) 00351 BOOL Outline; // Everything in this layer should be rendered in outlines (i.e. minimum quality) 00352 BOOL Guide; // This layer is a Guide layer, and can contain guidelines 00353 00354 BOOL m_PageBackground; // This layer is the special page background layer and hence contains a 00355 // rectangle covering the page(s) of the spread with either a bitmap fill 00356 // or a colour applied. 00357 // Frame related system flags 00358 BOOL m_Overlay; // Set if the previous layer is said to overlay the previous one rathar than 00359 // obscure it. 00360 BOOL m_Solid; // A solid frame/layer is like a background layer in that it forms the background 00361 // for frames above it. 00362 BOOL m_Edited; // Like the document flag, this says that the layer has been edited and so the 00363 // new bitmap frame needs generating. 00364 BOOL m_Frame; // This marks this frame as a special GIF animation frame layer. 00365 BOOL m_HiddenFrame; // This marks this frame as a hidden frame layer which will not be saved into 00366 // the GIF animation but may take part in the rendering process of other frames. 00367 00368 DWORD m_FrameDelay; // The delay value for a GIF animation will be stored in each frame layer. 00369 00370 Quality m_CaptureQuality; // The quality that the frame was captured at 00371 00372 KernelBitmapRef m_GeneratedBitmap; // The bitmap that has been generated to represent this frame/layer 00373 00374 KernelBitmap * m_pReferencedBitmap; // If there is a single bitmap on the frame of the correct type 00375 // then this will be used to represent this frame/layer 00376 00377 DocColour* pGuideColour; 00378 IndexedColour* pIndexedGuideColour; 00379 00380 // RGB value of default colour for guide layers 00381 static INT32 GuideLayerRed; 00382 static INT32 GuideLayerGreen; 00383 static INT32 GuideLayerBlue; 00384 00385 // Message handler that keeps layers up-to-date 00386 static LayerMsgHandler* pLayerMsgHandler; 00387 00388 protected: 00389 virtual Node* SimpleCopy(); 00390 void CopyNodeContents(Layer* NodeCopy); 00391 }; 00392 00393 00394 /******************************************************************************************** 00395 00396 > class LayerMsgHandler : public MessageHandler 00397 00398 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00399 Created: 10/10/95 00400 Purpose: Intercepts messages to ensure that layers are up to date 00401 00402 ********************************************************************************************/ 00403 00404 class LayerMsgHandler : public MessageHandler 00405 { 00406 public: 00407 CC_DECLARE_DYNAMIC( LayerMsgHandler ) 00408 LayerMsgHandler(); 00409 00410 protected: 00411 MsgResult Message(Msg* Msg); 00412 }; 00413 00414 00415 #endif // INC_LAYER