impcol.h

Go to the documentation of this file.
00001 // $Id: impcol.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 // Encapsulates a set of colours imported from a file.
00100 
00101 #ifndef INC_IMPCOL
00102 #define INC_IMPCOL
00103 
00104 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "listitem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "colourix.h"
00107 //#include "colmodel.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 
00109 class ColourListComponent;
00110 
00111 /********************************************************************************************
00112 
00113 <   ImportedNewColour
00114 
00115     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00116     Created:    18 03 95
00117     Purpose:    A structure to hold a new colour, which can be represented in any colour
00118                 model. Uses a ColourGeneric which must be cast because C++ can't do unions
00119                 in any useful way.
00120     SeeAlso:    ImportedColours
00121 
00122 ********************************************************************************************/
00123 
00124 typedef struct
00125 {
00126     ColourModel     Model;
00127     ColourGeneric   Colour;
00128 } ImportedNewColour;
00129 
00130 /********************************************************************************************
00131 
00132 >   class NewColour : public ListItem
00133 
00134     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00135     Created:    30/11/94
00136     Purpose:    Represents a new colour object to be added to a document after a file
00137                 has beeen imported.  It holds information on whether the colour name
00138                 will need to be mangled
00139     SeeAlso:    NewColourList; ImportedColours
00140 
00141 ********************************************************************************************/
00142 
00143 class NewColour : public ListItem
00144 {
00145     CC_DECLARE_MEMDUMP(NewColour)
00146 
00147 public:
00148     NewColour(IndexedColour*, BOOL);
00149 
00150     // Adds a colour to the list which duplicates this name
00151     BOOL AddDuplicateColour(IndexedColour **pNewCol, BOOL AlreadyExists);
00152 
00153     // Pointer to the new colour - can point to a colour that already exists in the document.
00154     IndexedColour *pCol;
00155 
00156     // This is TRUE if this colour is one that already exists in the document.
00157     // (i.e. pCol points to a colour that is in the document)
00158     BOOL AlreadyExistsInDoc;
00159 
00160     // TRUE if colour *name* has been defined more than once in the file being imported.
00161     // In this case, there is a list of such dupes (see pNextDuplicate, below)
00162     BOOL Duplicate;
00163 
00164     // Cached CMYK definition for comparing colours on CMYK values.
00165     PColourCMYK ColDefn;
00166 
00167     // If Duplicate is TRUE, this points to another imported colour that uses the same
00168     // name as this one.  Hence we have a simple one-way linked list here - this is
00169     // enough for our purposes.
00170     NewColour *pNextDuplicate;
00171 
00172 // New bits for native/web file filter
00173     // If loaded    - this will be the record number that the colour definition has been loaded from
00174     // If unsaved   - this will be zero to indicate the fact that this colour has not been imported
00175     INT32 RecordNumber;
00176 
00177     // the desired entry number for this colour in the list
00178     UINT32 EntryNumber;
00179 };
00180 
00181 
00182 
00183 /********************************************************************************************
00184 
00185 >   class NewColourList : public List
00186 
00187     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00188     Created:    30/11/94
00189     Purpose:    Holds a list of colours that are imported while importing a file into
00190                 a Camelot document.
00191     SeeAlso:    NewColour; ImportedColours
00192 
00193 ********************************************************************************************/
00194 
00195 class NewColourList : public List
00196 {
00197     CC_DECLARE_MEMDUMP(NewColourList)
00198 
00199 public:
00200     NewColour *AddColour(IndexedColour *pCol, BOOL AlreadyExists);  
00201 
00202     // We need to over-ride this because some items hold more than one colour.
00203     DWORD GetCount() const;                         
00204 };
00205 
00206 
00207 class NewColourInfo
00208 {
00209 public:
00210     NewColourInfo();
00211 
00212 public:
00213     // Field that says what kind of colour this is.
00214     IndexedColourType Type;
00215 
00216     // Flag for each colour component - defaults to no inheritance at all - only used
00217     // if Type is NEWCOLOUR_LINKED.
00218     BOOL Inherits[4];
00219 
00220     // Tint value - only used if Type is COLOURTYPE_TINT. 
00221     // (defaults to 100%, i.e. original colour)
00222     FIXED24 TintValue;
00223     FIXED24 ShadeValue;
00224 
00225     // Tint modifier - if it is COLOURTYPE_TINT, this flag is TRUE if the tint is really a shade!
00226     // (Shades are treated as special cases of tints for historical reasons)
00227     BOOL TintIsShade;
00228 
00229 // New bits for native/web file filter
00230     // Flags whether this colour is being imported by the web/native filter and therefore
00231     // has a different way of defining the parent colour
00232     BOOL WebNativeColour;
00233 
00234     // Pointer to the colour that has been imported.
00235     IndexedColour *pParentCol;
00236 
00237     // If loaded    - this will be the record number that the colour definition has been loaded from
00238     // If unsaved   - this will be zero to indicate the fact that this colour has not been imported
00239     INT32 RecordNumber;
00240     
00241     // the desired entry number for this colour in the list
00242     UINT32 EntryNumber;
00243 };
00244 
00245 
00246 
00247 /********************************************************************************************
00248 
00249 >   class ColourImportContext : public List
00250 
00251     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00252     Created:    01/12/94
00253     Purpose:    Provides a colour context to use when importing colours, which allows us
00254                 to easily import arbitrarily nested linked colours.
00255     SeeAlso:    ContextItem; ImportedColours
00256 
00257 ********************************************************************************************/
00258 
00259 class ColourImportContext : public List
00260 {
00261     CC_DECLARE_MEMDUMP(ColourImportContext);
00262 
00263 public:
00264     ColourImportContext();
00265     ~ColourImportContext();
00266 
00267     BOOL Init();
00268 
00269     void SetContext(IndexedColour*);
00270     IndexedColour *GetContext();
00271 
00272     BOOL SaveContext();
00273     BOOL RestoreContext();
00274     BOOL RestoreContextTo(UINT32);
00275 };
00276 
00277 
00278 /********************************************************************************************
00279 
00280 >   class ImportedColours : public CCObject
00281 
00282     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00283     Created:    30/11/94
00284     Purpose:    Encapsulate the process of importing a number of colours into a document.
00285                 This object maintains a list of colours to be imported, and implicitly 
00286                 handles all the merging/duplication problems that may occur.
00287     SeeAlso:    NewColour; NewColourList
00288 
00289 ********************************************************************************************/
00290 
00291 class ImportedColours : public CCObject
00292 {
00293     CC_DECLARE_MEMDUMP(ImportedColours)
00294 
00295 public:
00296     ImportedColours(ColourListComponent*, BOOL);
00297     ~ImportedColours();
00298 
00299     BOOL Init();
00300 
00301     // Overloaded functions to add new colours to the table.
00302     BOOL AddColour(const String_64 *pColName, ColourCMYK  *pCMYK, 
00303                    NewColourInfo *pLinkInfo = NULL);
00304     BOOL AddColour(const String_64 *pColName, ColourRGBT  *pRGB,  
00305                    NewColourInfo *pLinkInfo = NULL);
00306     BOOL AddColour(const String_64 *pColName, ColourHSVT  *pHSV,  
00307                    NewColourInfo *pLinkInfo = NULL);
00308     BOOL AddColour(const String_64 *pColName, ColourGreyT *pGrey, 
00309                    NewColourInfo *pLinkInfo = NULL);
00310     BOOL AddColour(const String_64 *pColName, ImportedNewColour *pCol, 
00311                    NewColourInfo *pLinkInfo = NULL);
00312 
00313     // New function added for native/web import
00314     BOOL AddTintOrShade(const String_64 *pColName, NewColourInfo *pColourInfo);
00315 
00316     // Functions to add tints/shades and manipulate linked colours
00317     BOOL AddTint(const String_64 *pColName, UINT32 Tint);
00318     BOOL AddShade(const String_64 *pColName, INT32 ShadeX, INT32 ShadeY);
00319     void SetLinkedColourInherits(UINT32 ComponentID);
00320 
00321     // Functions to update the context stack for tinting and linking colours.
00322     void SaveContext();
00323     void RestoreContextTo(UINT32 Level);
00324 
00325     // Works out which new colour is referred to by this name
00326     IndexedColour *GetColour( PCTSTR ColName);
00327 
00328     // Works out which new colour is referred to by this name - intelligently
00329     // decides whether to use the CMYK definition to resolve ambiguities.
00330     IndexedColour *GetColour( PCTSTR ColName, const PColourCMYK *Defn);
00331 
00332     // Import has finished successfully- add the colours into the document
00333     // in an undoable way.
00334     BOOL AddColoursToDocument();
00335 
00336     BOOL SortColoursByEntryNumber();
00337 
00338     // Import failed - destroy colours and do not add them to the document.
00339     BOOL DestroyColours();
00340 
00341     // Function for native/web filters to find an indexed colour from the specified
00342     // record number or colour reference
00343     IndexedColour *GetColour(INT32 ReqRecordNumber);
00344 
00345 protected:
00346     // The sort comparator we use for SortColoursByEntryNumber()
00347     static INT32 __cdecl SortComparator(const void *Item1, const void *Item2);
00348 
00349     // The list of colours to add
00350     NewColourList Colours;
00351 
00352     // A hash table from colour names to NewColour items.
00353     typedef CMap< String_64, const String_64 &, NewColour *, NewColour * >  CMapStringToNewColour;
00354     CMapStringToNewColour   *pColourMap;
00355 
00356     // The colour list component of the destination document.
00357     ColourListComponent *pColourComponent;
00358 
00359     // Used to remember which colours to link to or tint.
00360     ColourImportContext Context;
00361 
00362     // Indicates whether to check the CMYK values when servicing calls to GetColour().
00363     BOOL StrictColourMatching;
00364 
00365 protected:
00366     BOOL AddColour(const String_64 *pColName, IndexedColour **pCol, 
00367                    NewColourInfo *pLinkInfo = NULL);
00368 };
00369 
00370 
00371 #endif  // INC_IMPCOL
00372 
00373 

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