colourix.h

Go to the documentation of this file.
00001 // $Id: colourix.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 // colourix.h - definitions for the Camelot IndexedColour class (Named/Unnamed colours)
00099 
00100 
00101 #ifndef INC_COLOURIX
00102 #define INC_COLOURIX
00103 
00104 
00105 //#include "colmodel.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "colcontx.h"
00108 
00109 
00110 
00111 /********************************************************************************************
00112 
00113 <   IndexedColourInfo
00114 
00115     Comment:    Each IndexedColour has an information bitfield in its 'Info' data member.
00116                 This provides storage for many bits of useful information. Note that the
00117                 structure has been designed to align the bits nicely into 8/16 bit portions
00118                 to make life easier for compilers when extracting values.
00119 
00120                 Information is held on colour model of source and cached colour definitions,
00121                 the cache status and output context handle, inheritance in linked colours,
00122                 colour type (normal/spot/tint(shade)/linked), and whether a colour is 'deleted'
00123                 (hidden in an undo record).
00124 
00125                 There is a Reserved field, in which the spare bit(s) are retained.
00126                 There is currently only 1 spare bit.
00127 
00128                 A similar field is used in DocColours
00129 
00130     SeeAlso:    IndexedColour; DocColour
00131 
00132 ********************************************************************************************/
00133 
00134 typedef struct
00135 {
00136     UINT32 OCContextHandle  : 16;   // Handle of context of the cached colour
00137     UINT32 SourceColourModel    : 4;    // The ColourModel of the source colour data
00138     UINT32 CacheColourModel : 4;    // The ColourModel of the cached colour data
00139 
00140     UINT32 InheritComponent1    : 1;    // Inherited components (4 bits)
00141     UINT32 InheritComponent2    : 1;    // (NOTE: Tints use InheritComponent1 to indicate Shade)
00142     UINT32 InheritComponent3    : 1;
00143     UINT32 InheritComponent4    : 1;
00144 
00145     UINT32 Deleted          : 1;    // 'Deleted' flag for undo 'hiding' in ColMgrDlg
00146 
00147     UINT32 ColourType           : 2;    // Colour type (normal/spot/tint/linked)
00148 
00149     UINT32 IsNamed          : 1;    // TRUE if this is a named IndexedColour
00150 } IndexedColourInfo;
00151 
00152 
00153 
00154 /********************************************************************************************
00155 
00156 <   IndexedColourType
00157 
00158     Comment:    IndexedColours can be set to one of 4 types (held in their 2-bit
00159                 Info.ColourType field). The types are enumerated as:
00160                 MonoOn
00161                 COLOURTYPE_NORMAL   A Normal colour
00162                 COLOURTYPE_SPOT     A Spot colour
00163                 COLOURTYPE_TINT     A Tint of another colour
00164                 COLOURTYPE_LINKED   A colour Linked to another colour
00165                 MonoOff
00166 
00167     SeeAlso:    IndexedColour::SetType; IndexedColour::GetType;
00168                 IndexedColour::SetLinkedParent
00169             
00170 ********************************************************************************************/
00171 
00172 typedef enum
00173 {
00174     COLOURTYPE_NORMAL = 0,          // The colour is a perfectly normal colour
00175     COLOURTYPE_SPOT,                // The colour is a Spot Colour
00176     COLOURTYPE_TINT,                // The colour is a Tint (or a shade, a special type of tint)
00177     COLOURTYPE_LINKED               // The colour is a Linked colour
00178 } IndexedColourType;
00179 
00180 
00181 
00182 /********************************************************************************************
00183 
00184 >   class IndexedColour
00185 
00186     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00187     Created:    30/03/94
00188     Purpose:    Definition of a colour, stored to high (128-bit) precision.
00189                 DocColours in the Document may refer to IndexedColour objects
00190                 from which they are defined.
00191                 
00192                 IndexedColours are used in two forms: Named and Unnamed. The former
00193                 are held in a list for each document, and appear in the colour line/bar.
00194                 The latter do not appear in the user interface (except when editing
00195                 the colour of an object). They are stored in a separate list in the
00196                 ColourList for the document
00197 
00198                 NOTE That if an UNNAMED IndexedColour's usage count is decremented to zero,
00199                 it will automatically delete itself. Named colours must be explicitly
00200                 deleted.
00201     
00202     SeeAlso:    DocColour; ColourModel; ColourContext; ColourList
00203     Documentation:  HowToUse\colours.doc
00204             
00205 ********************************************************************************************/
00206 
00207 class CCAPI IndexedColour : public ListItem
00208 {
00209 friend class ColourContext;
00210 friend class DocColour;
00211 friend class ColourPicker;
00212 
00213 CC_DECLARE_DYNAMIC(IndexedColour)
00214 
00215 public:     // Construction/Destruction
00216     IndexedColour();
00217     ~IndexedColour();
00218 
00219     // Initialising/Copy Constructors
00220     IndexedColour(const IndexedColour& Col);
00221 
00222     IndexedColour(const DocColour& Col);
00223 
00224     IndexedColour(ColourModel ColModel, ColourGeneric *Col);
00225 
00226     IndexedColour(ColourValue Red, ColourValue Green, ColourValue Blue,
00227                     ColourValue Transparent = 0, UINT32 TransType = TRANSTYPE_DEFAULT);
00228 
00229     IndexedColour& operator=(const IndexedColour&);
00230 
00231 
00232 public:     // Interface
00233     void SetName(const StringBase &Name, BOOL ForceNamed = TRUE);
00234                                                 // Forces a colour to be named, and sets the name
00235     void SetUnnamed(void);                      // Forces a colour to be unnamed, clears the name
00236 
00237     String_64 *GetName(BOOL ReturnTrueID = FALSE);
00238     inline BOOL IsNamed(void);
00239 
00240     void GetSourceColour(ColourGeneric *Result);
00241 
00242     BOOL IsDifferent(const IndexedColour &Other);
00243     BOOL IsDifferent(const IndexedColour &Other, FIXED24 ErrorLimit);
00244 
00245     ColourModel GetColourModel(void) const;
00246 
00247     inline void IncrementUsage(void);
00248     inline BOOL DecrementUsage(void);
00249     inline BOOL IsInUse(BOOL IgnoreColourGallery = FALSE);
00250 
00251     inline BOOL IsDeleted(void);
00252     inline void SetDeleted(BOOL DeletedFlag);
00253 
00254     inline void InvalidateCache(void);
00255 
00256     IndexedColourType GetType(void) const;
00257 
00258     BOOL IsSpotOrTintOfSpot(void) const;
00259 
00260     IndexedColour *FindLinkedParent(void);
00261     IndexedColour *FindOldestAncestor(void);
00262     inline BOOL HasLinkedChildren(void);
00263     BOOL IsADescendantOf(IndexedColour *Parent);
00264     inline void LinkedAncestorHasChanged(void);
00265 
00266     void SetLinkedParent(IndexedColour *Parent, IndexedColourType NewType = COLOURTYPE_LINKED);
00267 
00268     inline IndexedColour *FindLastLinkedParent(void);
00269 
00270     BOOL SetInheritsComponent(UINT32 ComponentID, BOOL Inherits);
00271     BOOL InheritsComponent(UINT32 ComponentID);
00272 
00273     void SetTintValue(FIXED24 NewTintValue);
00274     FIXED24 GetTintValue(void) const;
00275     FIXED24 GetAccumulatedTintValue(void);
00276 
00277     void SetShadeValues(FIXED24 NewShadeValueX, FIXED24 NewShadeValueY);
00278     FIXED24 GetShadeValueX(void) const;
00279     FIXED24 GetShadeValueY(void) const;
00280 
00281     void SetTintOrShade(BOOL IsATint);      // Set this tint to be a Tint (TRUE) or Shade (FALSE)
00282     BOOL TintIsShade(void) const;           // Returns TRUE if it's a Shade, FALSE if it's a Tint
00283 
00284     void SwapWith(IndexedColour *Other);
00285 
00286     void GetDebugDetails(StringBase* Str);
00287 
00288 
00289 public:         // Special global overrides - use with great care
00290     static BOOL AreSpotsForcedToProcess(void)   { return(SpotsAreProcess); };
00291     static void ForceSpotsToBeProcess(BOOL ForceOn);
00292 
00293 
00294 protected:      // IndexedColour data members
00295     IndexedColourInfo   Info;               // Flags word
00296     ColourGeneric       SourceColour;       // Source colour definition
00297     ColourGeneric       CachedColour;       // Cached output colour
00298 
00299     IndexedColour       *ParentColour;      // NULL, or parent of a based-on colour
00300     DWORD               ChildUsage;         // Number of ParentColour refs from other colours
00301 
00302     DWORD               UsageCount;         // Number of refs to this colour
00303 
00304     String_64           *Name;              // NULL, or pointer to colours name
00305 
00306 
00307 protected:      // Internal and friend class access methods
00308     // Internal initialisation method (shared code)
00309     void InitialiseInfoFields(ColourModel ColModel);
00310 
00311     // Functions to be used only between IndexedColours
00312     inline void IncrementChildUsage(void);
00313     inline BOOL DecrementChildUsage(void);
00314 
00315     BOOL SetType(IndexedColourType NewType);
00316 
00317     // functions to access private data members - intended only for use by
00318     // our friend classes ColourContext and ColourPicker. Functions are used
00319     // to still provide some measure of data encapsulation.
00320     // NOTE: Remember when changing the colour definition, you must InvalidateCache
00321     inline void SetSourceColourModel(ColourModel NewModel);
00322     inline ColourGeneric *SourceColourPtr(void);
00323 
00324 private:
00325     static BOOL SpotsAreProcess;            // GLOBAL override - all spots are forced "normal"
00326 };
00327 
00328 
00329 typedef IndexedColour *IndexedColourPtr;
00330 
00331 
00332 
00333 /********************************************************************************************
00334 
00335 <   INDEXEDCOLOUR_RGBT(col)
00336 <   INDEXEDCOLOUR_HSVT(col)
00337 <   INDEXEDCOLOUR_CMYK(col)
00338 <   INDEXEDCOLOUR_CIET(col)
00339 <   INDEXEDCOLOUR_GREYT(col)
00340 
00341     Comment:    These macros simplify construction of IndexedColour objects in
00342                 given colour models. Use something like this:
00343 
00344                 MonoOn
00345                 {
00346                     ColourRGBT TheDefinition;
00347                     IndexedColour  TheColour = INDEXEDCOLOURRGBT(&TheDefinition);
00348                 }
00349                 MonoOff
00350 
00351     Notes:      Note that these macros explicitly cast 'col' to a
00352                 (ColourGeneric *), so if it is not a pointer to a 128-bit
00353                 colour structure (ColourGeneric, ColourRGBT, ColourCIET etc)
00354                 then nasty things may occur.
00355 
00356     SeeAlso:    IndexedColour::IndexedColour
00357 
00358 ********************************************************************************************/
00359 
00360 #define INDEXEDCOLOUR_RGBT(col)  IndexedColour(COLOURMODEL_RGBT,  (ColourGeneric *)(col))
00361 #define INDEXEDCOLOUR_CMYK(col)  IndexedColour(COLOURMODEL_CMYK,  (ColourGeneric *)(col))
00362 #define INDEXEDCOLOUR_HSVT(col)  IndexedColour(COLOURMODEL_HSVT,  (ColourGeneric *)(col))
00363 #define INDEXEDCOLOUR_CIET(col)  IndexedColour(COLOURMODEL_CIET,  (ColourGeneric *)(col))
00364 #define INDEXEDCOLOUR_GREYT(col) IndexedColour(COLOURMODEL_GREYT, (ColourGeneric *)(col))
00365 
00366 
00367 
00368 
00369 /********************************************************************************************
00370 
00371 >   inline void IndexedColour::IncrementUsage(void)
00372 
00373     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00374     Created:    30/03/94
00375     Inputs:     -
00376     Outputs:    -
00377     Returns:    -
00378     Purpose:    Informs the IndexedColour that yet another thing is referencing it.
00379                 An IndexedColour should not be deleted if its usage count != 0
00380                 A non-zero usage count on exit will generate ENSUREs which usually signal
00381                 memory leaks or people forgetting to link/delink themselves properly.
00382     Errors:     -
00383     SeeAlso:    IndexedColour::DecrementUsage; IndexedColour::IsInUse
00384 
00385 ********************************************************************************************/
00386 
00387 void IndexedColour::IncrementUsage(void)
00388 {
00389     UsageCount++;
00390 }
00391 
00392 
00393 
00394 /********************************************************************************************
00395 
00396 >   inline BOOL IndexedColour::DecrementUsage(void)
00397 
00398     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00399     Created:    30/03/94
00400     Inputs:     -
00401     Outputs:    -
00402     Returns:    FALSE if the IndexedColour is not in use (can be safely deleted)
00403                 TRUE if the IndexedColour is in use
00404 
00405     Purpose:    Informs the IndexedColour that a client is no longer referencing it.
00406                 An IndexedColour should not be deleted if its usage count != 0
00407 
00408     Errors:     -
00409     SeeAlso:    IndexedColour::IncrementUsage; IndexedColour::IsInUse
00410 
00411 ********************************************************************************************/
00412 
00413 BOOL IndexedColour::DecrementUsage(void)
00414 {
00415     ENSURE(UsageCount > 0, "IndexedColour::DecrementUsage - UsageCount has gone NEGATIVE!");
00416 
00417     return((--UsageCount) != 0);
00418 }
00419 
00420 
00421 
00422 /********************************************************************************************
00423 
00424 >   inline BOOL IndexedColour::IsInUse( [BOOL IgnoreColourGallery = FALSE] )
00425 
00426     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00427     Created:    30/03/94
00428 
00429     Inputs:     [IgnoreColourGallery - INTERNAL paramter for Colour SuperGallery ONLY]
00430                 [LEAVE THIS PARAMETER OUT!]
00431 
00432     Outputs:    -
00433     Returns:    FALSE if the IndexedColour can safely be deleted
00434                 TRUE if the IndexedColour is in use
00435     Purpose:    To determine if anything references this IndexedColour
00436                 (An IndexedColour must not be deleted if it is in use)
00437 
00438     Notes:      This is a simple usage count, and does not handle references
00439                 from undo-system hidden nodes etc. This simply records how many
00440                 things hold pointers to this IndexedColour object.
00441     Errors:     -
00442     SeeAlso:    IndexedColour::IncrementUsage; IndexedColour::DecrementUsage
00443 
00444 ********************************************************************************************/
00445 
00446 BOOL IndexedColour::IsInUse(BOOL IgnoreColourGallery)
00447 {
00448     // If this item is referenced in the colour gallery, the gallery needs to know if
00449     // nobody *else* is using the colour (i.e. if it has more than 1 user)
00450     if (IgnoreColourGallery)
00451         return(UsageCount > 1);
00452 
00453     // Under normal circumstances, the colour is in use if anybody is using it
00454     return(UsageCount != 0);
00455 }
00456 
00457 
00458 
00459 /********************************************************************************************
00460 
00461 >   inline void IndexedColour::IncrementChildUsage(void)
00462 
00463     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00464     Created:    17/11/94
00465     Inputs:     -
00466     Outputs:    -
00467     Returns:    -
00468     Purpose:    Informs the IndexedColour that yet another thing is referencing it.
00469                 An IndexedColour must not be deleted if its usage count != 0
00470     Scope:      private
00471     Errors:     -
00472     SeeAlso:    IndexedColour::DecrementChildUsage; IndexedColour::HasLinkedChildren
00473 
00474 ********************************************************************************************/
00475 
00476 void IndexedColour::IncrementChildUsage(void)
00477 {
00478     ENSURE(IsNamed(), "Attempt to increment child usage of an UNNAMED colour!");
00479     ChildUsage++;
00480 }
00481 
00482 
00483 
00484 /********************************************************************************************
00485 
00486 >   inline BOOL IndexedColour::DecrementChildUsage(void)
00487 
00488     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00489     Created:    17/11/94
00490     Inputs:     -
00491     Outputs:    -
00492     Returns:    FALSE if the IndexedColour is not in use (can be safely deleted)
00493                 TRUE if the IndexedColour is in use
00494 
00495     Purpose:    Informs the IndexedColour that a client is no longer referencing it.
00496                 An IndexedColour should not be deleted if its usage count != 0
00497     Scope:      private
00498 
00499     Errors:     -
00500     SeeAlso:    IndexedColour::IncrementChildUsage; IndexedColour::HasLinkedChildren
00501 
00502 ********************************************************************************************/
00503 
00504 BOOL IndexedColour::DecrementChildUsage(void)
00505 {
00506     ENSURE(IsNamed(), "Attempt to decrement child usage of an UNNAMED colour!");
00507 
00508     ENSURE(ChildUsage > 0, "IndexedColour::DecrementChildUsage - UsageCount has gone NEGATIVE!");
00509 
00510     return((--ChildUsage) != 0);
00511 }
00512 
00513 
00514 
00515 /********************************************************************************************
00516 
00517 >   inline BOOL IndexedColour::HasLinkedChildren(void)
00518 
00519     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00520     Created:    17/11/94
00521     Inputs:     -
00522     Outputs:    -
00523     Returns:    TRUE if the IndexedColour is in use (as a ParentColour) by other IndexedCols
00524     Purpose:    To determine if any other IndexedColour references this IndexedColour
00525                 (An IndexedColour must not be deleted if it is in use)
00526     
00527     Notes:      This is a simple usage count, and does not handle references
00528                 from undo-system hidden nodes etc. This simply records how many
00529                 other IndexedColours hold ParentColour pointers to this IndexedColour.
00530     Errors:     -
00531     SeeAlso:    IndexedColour::IncrementChildUsage; IndexedColour::DecrementChildUsage
00532 
00533 ********************************************************************************************/
00534 
00535 BOOL IndexedColour::HasLinkedChildren(void)
00536 {
00537     return(ChildUsage != 0);
00538 }
00539 
00540 
00541 
00542 /********************************************************************************************
00543 
00544 >   inline BOOL IndexedColour::IsDeleted(void)
00545 
00546     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00547     Created:    3/6/94
00548     Inputs:     -
00549     Outputs:    -
00550     Returns:    TRUE if this colour is marked 'deleted'
00551                 FALSE if it is not
00552     Purpose:    To determine if this colour has been marked 'deleted'. This is used
00553                 for undo, to hide colours which have been 'deleted'.
00554     Errors:     -
00555     SeeAlso:    IndexedColour::SetDeleted
00556 
00557 ********************************************************************************************/
00558 
00559 BOOL IndexedColour::IsDeleted(void)
00560 {
00561     return(Info.Deleted);
00562 }
00563 
00564 
00565 
00566 /********************************************************************************************
00567 
00568 >   inline void IndexedColour::SetDeleted(BOOL DeletedFlag)
00569 
00570     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00571     Created:    3/6/94
00572     Inputs:     -
00573     Outputs:    -
00574     Returns:    -
00575     Purpose:    This marks/unmarks a colour as 'deleted'. This flag is used
00576                 for undo, to hide colours which have been 'deleted'. Remember
00577                 that this constitutes a change to the colour, so you should call
00578                 ColourManager::ColourListHasChanged, to ensure that the Colour
00579                 dialogues update all displayed lists to show/not-show this colour.
00580     Scope:      Only intended for internal ColourManager use
00581     Notes:      Used by the undoable ColourManager OpColourChange. You should use
00582                 colour manager calls to delete colours rather than touching them
00583                 directly. Note that you can 'delete'/'undelete' colours even when
00584                 they are deemed 'In Use'.
00585     Errors:     -
00586     SeeAlso:    IndexedColour::IsInUse; IndexedColour::IsDeleted;
00587                 ColourManager::ColourHasChanged
00588 
00589 ********************************************************************************************/
00590 
00591 void IndexedColour::SetDeleted(BOOL DeletedFlag)
00592 {
00593     Info.Deleted = DeletedFlag;
00594 }
00595 
00596 
00597 
00598 /********************************************************************************************
00599 
00600 >   inline void IndexedColour::InvalidateCache(void)
00601 
00602     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00603     Created:    13/05/94
00604     Inputs:     -
00605     Outputs:    -
00606     Returns:    -
00607     Purpose:    Invalidates the IndexedColours output colour cache. This ensures that
00608                 the colour is re-converted and cached the next time it is used. 
00609     Scope:      Generally private; All public access functions invalidate the cache
00610                 automatically if it is necessary (if the colour changes)
00611     Errors:     -
00612     SeeAlso:    -
00613 
00614 ********************************************************************************************/
00615 
00616 void IndexedColour::InvalidateCache(void)
00617 {
00618     Info.CacheColourModel   = COLOURMODEL_NOTCACHED;
00619     Info.OCContextHandle    = 0;
00620 }
00621 
00622 
00623 
00624 /********************************************************************************************
00625 
00626 >   inline void IndexedColour::LinkedAncestorHasChanged(void)
00627 
00628     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00629     Created:    13/05/94
00630     Inputs:     -
00631     Outputs:    -
00632     Returns:    -
00633     Purpose:    Informs an IndexedColour that an ancestor in the linking chain has changed,
00634                 and that therefore, it may also have changed.
00635 
00636                 The ColourManager automatically calls this function for all affected
00637                 colours whenever it recieves a ColourChangingMsg COLOURUPDATED, so it should
00638                 never be necessary for anyone other than ColourManager to call this function.
00639                 
00640     Notes:      Currently this simply invalidates the cache to make the next access update
00641                 the colour from its Parent(s). A separate function has been used just in case
00642                 we change our minds about how this should be done in the future.
00643     Errors:     -
00644     SeeAlso:    -
00645 
00646 ********************************************************************************************/
00647 
00648 void IndexedColour::LinkedAncestorHasChanged(void)
00649 {
00650     InvalidateCache();
00651 }
00652 
00653 
00654 
00655 /********************************************************************************************
00656 
00657 >   void IndexedColour::SetSourceColourModel(ColourModel NewModel)
00658 
00659     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00660     Created:    13/05/94
00661     Inputs:     -
00662     Outputs:    -
00663     Returns:    -
00664     Purpose:    Sets our colour model number, and invalidates the colour cache
00665     Scope:      Private, for use by friend classes only
00666     Errors:     -
00667     SeeAlso:    -
00668 
00669 ********************************************************************************************/
00670 
00671 void IndexedColour::SetSourceColourModel(ColourModel NewModel)
00672 {
00673     // Set the new colour model
00674     Info.SourceColourModel  = NewModel;
00675 
00676     // And invalidate the cache...
00677     Info.CacheColourModel   = COLOURMODEL_NOTCACHED;
00678     Info.OCContextHandle    = 0;
00679 }
00680 
00681 
00682 
00683 /********************************************************************************************
00684 
00685 >   inline ColourDefn *IndexedColour::SourceColourPtr(void);
00686 
00687     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00688     Created:    12/04/94
00689     Inputs:     -
00690     Outputs:    -
00691     Returns:    A pointer to our source colour. Note that this is our source colour
00692                 so it would be appreciated if you'd not trample all over it with
00693                 hob nailed boots.
00694     Purpose:    Returns  a pointer to our source colour.
00695                 Used to encapsulate our data for external friend users, rather
00696                 than them poking directly at our data structures. Inlined, so
00697                 just as efficient anyway.
00698     Scope:      Private, for use by friend class ColourContext
00699     Errors:     -
00700     SeeAlso:    -
00701 
00702 ********************************************************************************************/
00703 
00704 ColourGeneric *IndexedColour::SourceColourPtr(void)
00705 {
00706     return(&SourceColour);
00707 }
00708 
00709 
00710 
00711 /********************************************************************************************
00712 
00713 >   inline BOOL IndexedColour::IsNamed(void)
00714 
00715     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00716     Created:    29/9/94
00717     Returns:    TRUE if this colour is named (GetName will return this name)
00718                 FALSE if this colour is not named (GetName will return a string like
00719                 "Unnamed colour" if this is the case)
00720 
00721     Purpose:    Determines if this colour has been given a name. This cannot be determined
00722                 using the GetName function, which returns a default name if the colour is
00723                 unnamed.
00724 
00725     SeeAlso:    IndexedColour::SetName; IndexedColour::GetName
00726 
00727 ********************************************************************************************/
00728 
00729 BOOL IndexedColour::IsNamed(void)
00730 {
00731     return((Info.IsNamed) ? TRUE : FALSE);      // **** !!!! TEMPORARY BODGE!
00732     //return(Name != NULL);
00733 }
00734 
00735 
00736 
00737 /********************************************************************************************
00738 
00739 >   inline IndexedColour *IndexedColour::FindLastLinkedParent(void)
00740 
00741     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00742     Created:    1/11/94
00743     Returns:    The parent 'linked' colour of this colour. This will be NULL if the
00744                 colour is not linked to another.
00745                 
00746     Purpose:    Finds the last parent colour of this colour. Note that after changing a
00747                 linked/tint colour back into a normal/spot colour, the parent is
00748                 remembered. This call thus returns the parent even when the colour
00749                 is no longer a linked/tint colour. Intended only for use by the colour
00750                 editor to allow temporary type chnages to not lose the parent link info.
00751                 The colour editor probably clears the parent colour on exit.
00752 
00753                 YOU SHOULD NOT BE USING THIS FUNCTION unless absolutely necessary. Use
00754                 FindLinkedParent instead.
00755 
00756     SeeAlso:    IndexedColour::FindLinkedParent
00757 
00758 ********************************************************************************************/
00759 
00760 IndexedColour *IndexedColour::FindLastLinkedParent(void)
00761 {
00762     return(ParentColour);
00763 }
00764 
00765 
00766 #endif      // INC_COLOURIX
00767 

Generated on Sat Nov 10 03:44:53 2007 for Camelot by  doxygen 1.4.4