styles.h

Go to the documentation of this file.
00001 // $Id: styles.h 1688 2006-08-10 12:05:20Z gerry $
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 // The document component for the document's unit list.
00100 
00101 #ifndef INC_STYLES
00102 #define INC_STYLES
00103 
00104 class BaseCamelotFilter;
00105 class CXaraFileRecord;
00106 
00107 
00108 /********************************************************************************************
00109 
00110 >   class Style : public CC_CLASS_MEMDUMP
00111 
00112     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00113     Created:    15/07/96
00114 
00115     Purpose:    
00116 
00117     SeeAlso:    Styles
00118 
00119 ********************************************************************************************/
00120 class Style : public CC_CLASS_MEMDUMP
00121 {
00122     CC_DECLARE_MEMDUMP(Style)
00123 
00124 public:
00125     virtual ~Style() = 0;
00126     virtual Style* CreateCopy(const StringBase& NewName) const = 0;
00127     virtual BOOL operator==(const Style& OtherStyle) const;
00128 
00129     const StringBase&   GetName() const;
00130 
00131 
00132 protected:
00133     Style(const StringBase& Name);
00134 
00135     BOOL SetName(const StringBase& Name);
00136 
00137 private:
00138     String_64       m_Name;
00139 };
00140 
00141 
00142 class StyleContainer;
00143 class StyleContainerItem;
00144 /**************************************************************************************
00145 
00146 >   class StyleIterator
00147 
00148     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00149     Created:    15/07/97
00150 
00151     Purpose:    Returns entries in a visible list
00152 
00153     See Also:   VisibleList::Begin(), End()
00154 
00155 **************************************************************************************/
00156 class StyleIterator
00157 {
00158 public:
00159     StyleIterator& operator ++();
00160     Style& operator*();
00161     BOOL operator!=(const StyleIterator& Other);
00162 
00163     StyleIterator(StyleContainer& Container, StyleContainerItem* const pPosition);
00164 
00165 private:
00166     StyleContainerItem* m_CurrentItem;
00167     StyleContainer&     m_Container;
00168 };
00169 
00170 class StylesExporter;
00171 typedef INT32 XFileRef;
00172 /********************************************************************************************
00173 
00174 >   class Styles : public DocComponent
00175 
00176     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00177     Created:    15/07/96
00178 
00179     Purpose:    This DocComponent is an abstract class for styles. I put it in 'cos 
00180                 someone's bound to come along and want the functionality of the derived class
00181                 WizOpStyleComponent
00182 
00183     SeeAlso:    StyleComponentClass
00184 
00185 ********************************************************************************************/
00186 class Styles : public DocComponent
00187 {
00188     CC_DECLARE_DYNAMIC(Styles)
00189 public:
00190     virtual BOOL Init();
00191 
00192     virtual Style* AddStyle(const Style& NewStyle);
00193     virtual BOOL MergeStyles(Styles& OtherStyles);
00194 
00195 // Examining the styles
00196     virtual StyleIterator Begin() const;
00197     virtual const StyleIterator& End() const;
00198     virtual Style* FindStyleFromName(const StringBase& StyleName) const;
00199 
00200 
00201 
00202 //  Overridden methods called before and after a tree copy
00203     virtual BOOL StartComponentCopy();
00204     virtual BOOL EndComponentCopy(); 
00205     virtual void AbortComponentCopy();  
00206 
00207     virtual Style* CopyComponentData(const Style& NewStyle);
00208 
00209     virtual ~Styles();
00210 protected:
00211     Styles();
00212     Styles(const Styles& OtherStyles);
00213     Styles& operator=(const Styles&);
00214 
00215     BOOL GenerateUniqueName(const StringBase& Prefix, StringBase* pResult);
00216     BOOL NameExists(const StringBase& Name) const;
00217     void SendStylesChangeMessage();
00218     
00219 // Data access
00220     StyleContainer& GetContainer() const;
00221     Styles& GetStylesToAdd() const;
00222 protected:
00223     StylesExporter* m_pCurrentExporter; // used when exporting
00224 private:
00225     StyleContainer* m_pStyleContainer;
00226 
00227 
00228     Styles*         m_pStylesToAdd;     // used when copying component
00229 };
00230 
00231 
00232 
00233 class WizOp;
00234 class WizOpStyleRecordHandler;
00235 /********************************************************************************************
00236 
00237 >   class WizOpStyleComponentClass : public DocComponentClass
00238 
00239     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00240     Created:    15/07/96
00241 
00242     Purpose:    Provide a class that will add document information components to new documents.
00243 
00244     SeeAlso:    DocComponentClass
00245 
00246 ********************************************************************************************/
00247 class WizOpStyleComponentClass : public DocComponentClass
00248 {
00249     CC_DECLARE_DYNAMIC(WizOpStyleComponentClass)
00250 
00251 public:
00252     static BOOL Init();
00253 
00254     virtual BOOL AddComponent(BaseDocument*);
00255 };
00256 
00257 
00258 /********************************************************************************************
00259 
00260 >   class WizOpStyle : public Style
00261 
00262     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00263     Created:    15/07/96
00264 
00265     Purpose:    A WizOpStyle is a style solely for the purpose of naming WizOps
00266 
00267 ********************************************************************************************/
00268 class WizOpStyle : public Style
00269 {
00270     CC_DECLARE_MEMDUMP(WizOpStyle)
00271 public:
00272     WizOpStyle( const StringBase& Name, const StringBase& Question, 
00273                 const WizOp& WizOpRef, const StringBase& Param);
00274 
00275     virtual Style* CreateCopy(const StringBase& NewName) const;
00276     virtual BOOL operator==(const Style& OtherStyle) const;
00277 
00278     const StringBase&   GetQuestion() const;
00279     BOOL                SetQuestion(const StringBase& NewQuestion);
00280 
00281     const WizOp&        GetWizOp() const;
00282     const StringBase&   GetParam() const;
00283 
00284 protected:
00285     BOOL                SetParam(const StringBase& NewParam);
00286 
00287 private:
00288     String_256          m_Question;
00289     const WizOp&        m_WizOp;
00290     String_256          m_Param;
00291 };
00292 
00293 
00294 
00295 /********************************************************************************************
00296 
00297 >   class WizOpStyles : public Styles
00298 
00299     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00300     Created:    15/07/96
00301 
00302     Purpose:    Provide a component that allows us to save out the information for this document
00303                 using the serialisation facilities of the DocComponent base class.
00304     SeeAlso:    DocComponent
00305 
00306 ********************************************************************************************/
00307 class WizOpStyles : public Styles
00308 {
00309     CC_DECLARE_DYNAMIC(WizOpStyles)
00310 
00311 public:
00312     WizOpStyles()   {}
00313     // Usual document component functions...
00314 
00315 // Import
00316     virtual BOOL StartImport(BaseCamelotFilter *pFilter);
00317     virtual BOOL EndImport(BaseCamelotFilter *pFilter, BOOL Success);
00318 
00319     WizOpStyle* FindStyleFromRecordReference(XFileRef RecordRef) const;
00320 
00321     BOOL                        SetRecordHandler(WizOpStyleRecordHandler& RecordHandler);
00322     WizOpStyleRecordHandler&    GetRecordHandler() const;
00323 
00324 // Export
00325     virtual BOOL StartExport(BaseCamelotFilter *pFilter);
00326     virtual BOOL EndExport(BaseCamelotFilter *pFilter, BOOL Success);
00327 
00328     virtual XFileRef GetRecordRefForStyle(const WizOpStyle& Style);
00329 
00330 private:
00331     WizOpStyleRecordHandler*    m_pImporter;
00332 };
00333 
00334 
00335 extern const INT32 XFILEREF_ERROR;
00336 
00337 class RecordReferenceItem;
00338 class List;
00339 
00340 /********************************************************************************************
00341 
00342 >   class RecordReferencingExporter : public CC_CLASS_MEMDUMP
00343 
00344     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00345     Created:    15/07/96
00346 
00347     Purpose:    
00348 
00349     SeeAlso:    Styles
00350 
00351 ********************************************************************************************/
00352 class RecordReferencingExporter : public CC_CLASS_MEMDUMP
00353 {
00354     CC_DECLARE_MEMDUMP(RecordReferencingExporter)
00355 
00356 protected:
00357     RecordReferencingExporter(BaseCamelotFilter& FilterToUse) : m_Filter(FilterToUse)   {}
00358     RecordReferencingExporter(const RecordReferencingExporter& Other);
00359     const RecordReferencingExporter& operator=(const RecordReferencingExporter& Other);
00360 
00361     virtual ~RecordReferencingExporter();
00362 
00363 // Implementation
00364     virtual XFileRef WriteItem(const RecordReferenceItem& TentativeExportItem);
00365 
00366     virtual XFileRef WriteRecord(const RecordReferenceItem& ItemToExport) = 0;
00367 
00368 // Support functions
00369     virtual BOOL AddExportedItem(RecordReferenceItem& NewItem);
00370     virtual const RecordReferenceItem* FindExportedItem(const RecordReferenceItem& ItemToFind);
00371 
00372 
00373 // Data Access
00374     BaseCamelotFilter&  GetFilter()                         {   return m_Filter;    }
00375 
00376 private:
00377     BaseCamelotFilter&  m_Filter;
00378     List                m_ExportedItems;
00379 };
00380 
00381 
00382 /********************************************************************************************
00383 
00384 >   class StylesExporter : public RecordReferencingExporter
00385 
00386     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00387     Created:    15/07/96
00388 
00389     Purpose:    
00390 
00391     SeeAlso:    Styles
00392 
00393 ********************************************************************************************/
00394 class StylesExporter : public RecordReferencingExporter
00395 {
00396     CC_DECLARE_MEMDUMP(StylesExporter)
00397 
00398 public:
00399     StylesExporter(Styles& StylesToExport, BaseCamelotFilter& FilterToUse);
00400 
00401 // The entry point...
00402     virtual XFileRef WriteStyle(const WizOpStyle& StyleToWrite);
00403 
00404 protected:
00405 // Implemented pure
00406     virtual XFileRef WriteRecord(const RecordReferenceItem& ItemToExport);
00407 
00408 private:
00409     Styles&             m_Styles;
00410 };
00411 
00412 /********************************************************************************************
00413 
00414 >   class WizOpStyleRecordHandler : public CamelotRecordHandler
00415 
00416     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00417     Created:    15/07/96
00418 
00419     Purpose:    Allows WizOpStyleComponent's to be read from the .xar/.web file formats.
00420 
00421 ********************************************************************************************/
00422 class WizOpStyleRecordHandler : public CamelotRecordHandler
00423 {
00424     // Give my name in memory dumps
00425     CC_DECLARE_DYNAMIC(WizOpStyleRecordHandler);
00426 
00427 public:
00428     WizOpStyleRecordHandler();
00429     virtual ~WizOpStyleRecordHandler();
00430 
00431     // overridden functions
00432     virtual UINT32* GetTagList();
00433     virtual BOOL    Init(BaseCamelotFilter* pFilter);
00434     virtual BOOL    HandleRecord(CXaraFileRecord* pCXaraFileRecord);
00435     virtual BOOL    EndImport();
00436 
00437     WizOpStyle* FindStyleFromRecordReference(XFileRef RecordRef) const;
00438 
00439 #ifdef XAR_TREE_DIALOG
00440     virtual void GetRecordDescriptionText(CXaraFileRecord* pCXaraFileRecord,StringBase* Str);
00441     virtual void GetTagText(UINT32 Tag,String_256& Str);
00442 #endif
00443 
00444 protected:
00445     WizOpStyleRecordHandler(const WizOpStyleRecordHandler& Other);
00446     WizOpStyleRecordHandler& operator=(const WizOpStyleRecordHandler& Other);
00447 
00448 // Implementation
00449     WizOpStyle* AddStyle(   const StringBase& Name, const StringBase& Question, 
00450                             const StringBase& WizOpName, const StringBase& Param);
00451 
00452     BOOL AddRecordReference(XFileRef RecordRef, const WizOpStyle& ImportedStyle);
00453 // Data access
00454     WizOpStyles& GetTentativeStyles();
00455 
00456 
00457 private:
00458 //  WizOpStyles*    m_pStyleComponent;  // a pointer to the importing document's styles
00459     WizOpStyles*    m_pTentativeStyles; // styles in & not in the importing document's styles
00460     List            m_ImportedItems;
00461 };
00462 
00463 
00464 /********************************************************************************************
00465 
00466 >   class StylesMessage : public Msg
00467 
00468     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00469     Created:    15/07/96
00470 
00471     Purpose:    Informs us that a Styles component has changed
00472 
00473     SeeAlso:    Styles
00474 
00475 ********************************************************************************************/
00476 class StylesMessage : public Msg
00477 {
00478     CC_DECLARE_DYNAMIC(StylesMessage);
00479 
00480 public:
00481     StylesMessage(Styles& StylesChanging) :
00482         m_StylesChanging(StylesChanging)                {}
00483 
00484     Styles& GetStylesChanging()                         {   return m_StylesChanging;    }
00485 
00486 private:
00487     Styles& m_StylesChanging;
00488 };
00489 
00490 #endif  // INC_STYLES

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