strkcomp.h

Go to the documentation of this file.
00001 // $Id: strkcomp.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 // Stroke Doc-component classes.
00099 // These store brush-stroke definitions as clipart subtrees
00100 
00101 #ifndef INC_STRKCOMP
00102 #define INC_STRKCOMP
00103 
00104 //#include "doccomp.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "linecomp.h"
00106 #include "linedef.h"
00107 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 
00109 class BaseCamelotFilter;
00110 class CXaraFileRecord;
00111 class CamelotRecordHandler;
00112 class Node;
00113 
00114 
00115 /* NOTE: Diccon - 13/12/99.
00116 In the implementation of the new brush objects it was decided that they should be stored and
00117 retrieved in the same way as strokes.  Therefore a new superclass has been createed from which 
00118 these classes are now derived as well as the brushcomponent and brushdefintion classes.
00119 See other notes in linecomp.h for more info
00120 */
00121 
00122 /********************************************************************************************
00123 
00124 >   typedef UINT32 StrokeHandle;
00125 
00126     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00127     Created:    28/2/97
00128 
00129     Purpose:    A StrokeHandle is a unique reference to a vector stroke in the
00130                 StrokeComponent. All references to strokes are done via StrokeHandles,
00131                 which allows us to delete & relocate strokes without worrying about
00132                 leaving lots of pointers to them lying about and causing havoc.
00133 
00134                 The special handle StrokeHandle_NoStroke is used for illegal handles
00135                 and returning error states.
00136 
00137     SeeAlso:    StrokeComponent; StrokeDefinition
00138 
00139 ********************************************************************************************/
00140 
00141 typedef UINT32 StrokeHandle;
00142 
00143 const StrokeHandle StrokeHandle_NoStroke = 0xffffffff;
00144 
00145 
00146 
00147 /********************************************************************************************
00148 
00149 >   class StrokeDefinition : public LineDefinition
00150 
00151     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00152     Created:    28/2/97
00153 
00154     Purpose:    Stores a vector stroke definition
00155                 A static list of these items is held in the StrokeComponent.
00156 
00157     SeeAlso:    StrokeComponent
00158 
00159 ********************************************************************************************/
00160 
00161 class StrokeDefinition : public LineDefinition
00162 {
00163 CC_DECLARE_DYNAMIC(StrokeDefinition)
00164 
00165 public:
00166     StrokeDefinition()  { ERROR3("Don't use this constructor"); };
00167     StrokeDefinition(Node *pStrokeTree, BOOL repeating = FALSE, INT32 repeats = 0);
00168 //  StrokeDefinition(Node *pStrokeTree, MILLIPOINT StartCap, MILLIPOINT EndCap);
00169 
00170     ~StrokeDefinition();
00171 
00172     void SetStrokeName(StringBase *pName);
00173     void SetStrokeRepeating(BOOL Repeating);
00174     void SetNumStrokeRepeats(INT32 NumRepeats);
00175     void SetOverrideFill(BOOL Override)     { OverridesFill  = Override; };
00176     void SetOverrideTrans(BOOL Override)    { OverridesTrans = Override; };
00177 
00178 public:
00179     virtual BOOL IsDifferent(LineDefinition *pOther);
00180             // Returns TRUE if these stroke definitions are not the same
00181 
00182     inline Node *GetStrokeTree(void)        { return(pStroke); };
00183             // Get at the stroke clipart tree
00184 
00185     inline String_32 *GetStrokeName(void)   { return(&Name); };
00186 
00187     inline BOOL IsRepeating(void) const     { return(Repeating); };
00188             // Determine if this stroke should repeat or stretch onto the destination path
00189 
00190     inline INT32 NumRepeats(void) const     { return(Repeats); };
00191             // Determine if this stroke should repeat or stretch onto the destination path
00192 
00193     inline BOOL OverrideFill(void) const    { return(OverridesFill); };
00194     inline BOOL OverrideTrans(void) const   { return(OverridesTrans); };
00195             // Determine if this stroke overrides the fill/transparency geometry with its own ones
00196 
00197     BOOL NeedsTransparency(void) const;
00198             // Determine if this stroke needs transparency to render correctly
00199 
00200     inline void  SetIOStore(UINT32 NewValue)        { IOStore = NewValue; };
00201     inline UINT32 ReadIOStore(void) const       { return(IOStore); };
00202 
00203 private:
00204     Node *pStroke;              // A clipart subtree which defines the stroke
00205 
00206     String_32 Name;             // The name of this stroke (as shown in stroke gallery)
00207 
00208     INT32 Repeats;              // Number of times a brush should repeat along the stroke, or zero for optimal
00209     BOOL Repeating;             // TRUE if the stroke should repeat along the path, FALSE if it should stretch
00210     BOOL OverridesFill;         // TRUE if the stroke uses its own fills rather than the current fill colour
00211     BOOL OverridesTrans;        // TRUE if the stroke uses its own transparencies rather than the current one
00212 
00213     BOOL NeedsTrans;            // TRUE if the stroke needs transparency in order to render
00214 
00215     UINT32 IOStore;             // Used during export to indicate whether this definition has been saved
00216                                 // Used during import to store the handle associated with this stroke
00217                                 // in the file, so we can re-map handles into our array on import.
00218 };
00219 
00220 
00221 
00222 /********************************************************************************************
00223 
00224 >   class StrokeComponentClass : public DocComponentClass
00225 
00226     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00227     Created:    22/2/97
00228     Purpose:    The class that gets a Stroke doc component going on start up
00229                 We need to register our class as a document component and this is where
00230                 we do it all.
00231     SeeAlso:    DocComponentClass
00232 
00233 ********************************************************************************************/
00234 
00235 class StrokeComponentClass : public DocComponentClass
00236 {
00237 CC_DECLARE_DYNAMIC(StrokeComponentClass)
00238 
00239 public:
00240     static BOOL Init();
00241     static void DeInit();
00242 
00243 public:
00244     BOOL AddComponent(BaseDocument *pDoc);
00245 };
00246 
00247 
00248 
00249 /********************************************************************************************
00250 
00251 >   class StrokeComponent : public DocComponent
00252 
00253     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00254     Created:    22/2/97
00255 
00256     Purpose:    A document component for handling Stroke definitions.
00257 
00258                 StrokeComponents share a global cache of available stroke types.
00259                 Individual instances serve as managers for the list, mainly providing
00260                 import/export facilities for stroke definitions.
00261 
00262     SeeAlso:    DocComponent
00263 
00264 ********************************************************************************************/
00265 
00266 class StrokeComponent : public DocComponent
00267 {
00268 friend class StrokeComponentClass;
00269 friend class StrokeDefinition;
00270 
00271 CC_DECLARE_DYNAMIC(StrokeComponent)
00272 
00273 public:
00274     StrokeComponent();
00275     virtual ~StrokeComponent();
00276 
00277 
00278 protected:      // Internal functions for friend classes
00279     static void DeleteStrokeList(void);
00280                 // One-time deinitialisation, called on exit
00281 
00282 public:
00283     static StrokeHandle AddNewStroke(StrokeDefinition *pStroke);
00284                 // Add a new stroke definition to the global list
00285 
00286     static StrokeDefinition *FindStroke(StrokeHandle Handle);
00287                 // Finds the definition of a given stroke
00288 
00289 public:         // External V2 native file import/export handlers
00290     virtual BOOL StartImport(BaseCamelotFilter *pFilter);
00291     virtual BOOL EndImport(BaseCamelotFilter *pFilter, BOOL Success);
00292     virtual BOOL StartExport(BaseCamelotFilter *pFilter);
00293     virtual BOOL EndExport(BaseCamelotFilter *pFilter, BOOL Success);
00294 
00295 
00296 public:         // Internal file format handlers - called from our RecordHandler in strkattr.cpp
00297     static BOOL StartImportStroke(CamelotRecordHandler *pHandler, CXaraFileRecord *pRecord);
00298     static BOOL EndImportStroke(CamelotRecordHandler *pHandler);
00299                 // Starts and completes import of the Atomic stroke definition
00300 
00301     static StrokeHandle FindImportedStroke(UINT32 ImportedHandle);
00302                 // Finds the internal handle of the stroke definition with the given imported handle
00303 
00304     static BOOL ExportStroke(BaseCamelotFilter *pFilter, StrokeHandle Handle);
00305                 // Exports a stroke definition (if necessary)
00306 
00307 
00308 private:            // Global Stroke list & management functions
00309     static BOOL ExpandArray(void);
00310 
00311 private:
00312     static StrokeDefinition **pStrokeList;  // Global array of available stroke definitions
00313     static UINT32 CurrentSize;              // Number of entries allocated to the array
00314     static UINT32 Used;                     // Number of entries used in the array (index of 1st free slot)
00315 
00316 private:            // Import records
00317     static UINT32 ImportHandle;             // Record the data associated with the record currently 
00318     static UINT32 ImportFlags;              // being imported
00319     static UINT32 ImportData1;
00320     static UINT32 ImportData2;
00321     static InsertTreeContext *pImportPreviousContext;
00322     static Node  *pImportNewBrush;
00323     static String_32 ImportedName;
00324 };
00325 
00326 
00327 
00328 #endif

Generated on Sat Nov 10 03:47:05 2007 for Camelot by  doxygen 1.4.4