IndexedColour Class Reference

Definition of a colour, stored to high (128-bit) precision. DocColours in the Document may refer to IndexedColour objects from which they are defined. More...

#include <colourix.h>

Inheritance diagram for IndexedColour:

ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 IndexedColour ()
 Constructor for an IndexedColour object Initialises the colour to the RGBT value for Opaque Black.
 ~IndexedColour ()
 Destructor for an IndexedColour object.
 IndexedColour (const IndexedColour &Col)
 Copy constructor for an IndexedColour object.
 IndexedColour (const DocColour &Col)
 Copy constructor for an IndexedColour object.
 IndexedColour (ColourModel ColModel, ColourGeneric *Col)
 Constructor for an IndexedColour object Initialises the colour to the given value in the given colour model NOTE that if you have a ColourABCD structure, you can pass this in as a single parameter, and inline functions will convert the call into a call to this function on your behalf. i.e. you can use IndexedColour((ColourRGBT *)Bob); -- See colour.h.
 IndexedColour (ColourValue Red, ColourValue Green, ColourValue Blue, ColourValue Transparent=0, UINT32 TransType=TRANSTYPE_DEFAULT)
 Constructor for an IndexedColour object Initialises the colour to the given Extended RGBT value.
IndexedColouroperator= (const IndexedColour &)
 IndexedColour assignment operator Copies the definition of one IndexedColour into another Notes: The name field is copied verbatim - if you want it to say 'Copy of ...' then you'll have to prepend this text yourself.
void SetName (const StringBase &Name, BOOL ForceNamed=TRUE)
 To set the name of an IndexedColour. The name will be truncated to a maximum length of 63 characters.
void SetUnnamed (void)
 To UNset the name of an IndexedColour, forcing it back to being Unnamed.
String_64GetName (BOOL ReturnTrueID=FALSE)
 To find the name of an IndexedColour (or the ID of an unnamed indexed colour).
BOOL IsNamed (void)
 Determines if this colour has been given a name. This cannot be determined using the GetName function, which returns a default name if the colour is unnamed.
void GetSourceColour (ColourGeneric *Result)
 Gets the definition of the IndexedColour.
BOOL IsDifferent (const IndexedColour &Other)
 To determine if two indexed colours share a common definition.
BOOL IsDifferent (const IndexedColour &Other, FIXED24 ErrorLimit)
ColourModel GetColourModel (void) const
 To determine the colour model in which an IndexedColour is defined.
void IncrementUsage (void)
 Informs the IndexedColour that yet another thing is referencing it. An IndexedColour should not be deleted if its usage count != 0 A non-zero usage count on exit will generate ENSUREs which usually signal memory leaks or people forgetting to link/delink themselves properly.
BOOL DecrementUsage (void)
 Informs the IndexedColour that a client is no longer referencing it. An IndexedColour should not be deleted if its usage count != 0.
BOOL IsInUse (BOOL IgnoreColourGallery=FALSE)
 To determine if anything references this IndexedColour (An IndexedColour must not be deleted if it is in use).
BOOL IsDeleted (void)
 To determine if this colour has been marked 'deleted'. This is used for undo, to hide colours which have been 'deleted'.
void SetDeleted (BOOL DeletedFlag)
 This marks/unmarks a colour as 'deleted'. This flag is used for undo, to hide colours which have been 'deleted'. Remember that this constitutes a change to the colour, so you should call ColourManager::ColourListHasChanged, to ensure that the Colour dialogues update all displayed lists to show/not-show this colour. Scope: Only intended for internal ColourManager use Notes: Used by the undoable ColourManager OpColourChange. You should use colour manager calls to delete colours rather than touching them directly. Note that you can 'delete'/'undelete' colours even when they are deemed 'In Use'.
void InvalidateCache (void)
 Invalidates the IndexedColours output colour cache. This ensures that the colour is re-converted and cached the next time it is used. Scope: Generally private; All public access functions invalidate the cache automatically if it is necessary (if the colour changes).
IndexedColourType GetType (void) const
 Determines the type of this colour.
BOOL IsSpotOrTintOfSpot (void) const
 Determines if this colour is either a spot colour or a true tint of a spot colour. (Tints can unfortunately be made from non-spot colour parents, so you need to call this function to determine if a tint really is cleanly derived from a spot colour, or if it must be treated as a simple process colour).
IndexedColourFindLinkedParent (void)
 Finds the colour upon which a tint/based-on colour is based, if any. Can also be used to determine if a colour is a tint/basedon colour.
IndexedColourFindOldestAncestor (void)
 Finds the colour upon which a tint/based-on colour is based, if any. Can also be used to determine if a colour is a tint/basedon colour.
BOOL HasLinkedChildren (void)
 To determine if any other IndexedColour references this IndexedColour (An IndexedColour must not be deleted if it is in use).
BOOL IsADescendantOf (IndexedColour *Parent)
 Recursively backtracks through the chain of LinkedParent links to determine if this colour is in any way (directly or indirectly) linked to the given Parent colour, and might therefore be affected by any change to said colour.
void LinkedAncestorHasChanged (void)
 Informs an IndexedColour that an ancestor in the linking chain has changed, and that therefore, it may also have changed.
void SetLinkedParent (IndexedColour *Parent, IndexedColourType NewType=COLOURTYPE_LINKED)
 To make a colour linked to or a tint of another colour. This links the colour to the parent.
IndexedColourFindLastLinkedParent (void)
 Finds the last parent colour of this colour. Note that after changing a linked/tint colour back into a normal/spot colour, the parent is remembered. This call thus returns the parent even when the colour is no longer a linked/tint colour. Intended only for use by the colour editor to allow temporary type chnages to not lose the parent link info. The colour editor probably clears the parent colour on exit.
BOOL SetInheritsComponent (UINT32 ComponentID, BOOL Inherits)
 To set if a given component of a colour is inherited from its linked parent colour.
BOOL InheritsComponent (UINT32 ComponentID)
 To determine if a given component of a colour is inherited from its linked parent colour. Always returns FALSE if a colour is not linked.
void SetTintValue (FIXED24 NewTintValue)
 Sets a new tint value for a Tint colour. Will generate ENSURE failures in the debug build if the colour is not a tint.
FIXED24 GetTintValue (void) const
 Gets the current Tint value for the colour.
FIXED24 GetAccumulatedTintValue (void)
 To determine the accumulated tint value of any colour.
void SetShadeValues (FIXED24 NewShadeValueX, FIXED24 NewShadeValueY)
 Sets new shade values for a Shade colour. Will generate ENSURE failures in the debug build if the colour is not a Tint/Shade.
FIXED24 GetShadeValueX (void) const
 Gets the current Shade Saturation value for the colour.
FIXED24 GetShadeValueY (void) const
 Gets the current Shade Brightness value for the colour.
void SetTintOrShade (BOOL IsATint)
 Sets a COLOURTYPE_TINT colour to be either a Tint (fade-to-white) or a shade (fade-to-black) colour. The tint/shade fraction is unchnaged (the colour will just toggle between being darker and lighter!).
BOOL TintIsShade (void) const
 Determines if a COLOURTYPE_TINT colour is really a tint or a shade.
void SwapWith (IndexedColour *Other)
void GetDebugDetails (StringBase *Str)
 To get information on this colour for display in the Debug Tree.

Static Public Member Functions

static BOOL AreSpotsForcedToProcess (void)
static void ForceSpotsToBeProcess (BOOL ForceOn)
 To set the global colour flag. When the flag is TRUE, all spot colours in the entire program are forced to act as "normal" colours; when set FALSE, all spot colours behave normally.

Protected Member Functions

void InitialiseInfoFields (ColourModel ColModel)
 Private shared code for construction of IndexedColour objects Initialises the 'Info' structure to default values Scope: private.
void IncrementChildUsage (void)
 Informs the IndexedColour that yet another thing is referencing it. An IndexedColour must not be deleted if its usage count != 0 Scope: private.
BOOL DecrementChildUsage (void)
 Informs the IndexedColour that a client is no longer referencing it. An IndexedColour should not be deleted if its usage count != 0 Scope: private.
BOOL SetType (IndexedColourType NewType)
 Sets the type of this colour: MonoOn COLOURTYPE_NORMAL, COLOURTYPE_SPOT, COLOURTYPE_TINT, COLOURTYPE_LINKED MonoOff.
void SetSourceColourModel (ColourModel NewModel)
 Sets our colour model number, and invalidates the colour cache Scope: Private, for use by friend classes only.
ColourGenericSourceColourPtr (void)
 Returns a pointer to our source colour. Used to encapsulate our data for external friend users, rather than them poking directly at our data structures. Inlined, so just as efficient anyway. Scope: Private, for use by friend class ColourContext.

Protected Attributes

IndexedColourInfo Info
ColourGeneric SourceColour
ColourGeneric CachedColour
IndexedColourParentColour
DWORD ChildUsage
DWORD UsageCount
String_64Name

Static Private Attributes

static BOOL SpotsAreProcess = FALSE

Friends

class ColourContext
class DocColour
class ColourPicker

Detailed Description

Definition of a colour, stored to high (128-bit) precision. DocColours in the Document may refer to IndexedColour objects from which they are defined.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
IndexedColours are used in two forms: Named and Unnamed. The former are held in a list for each document, and appear in the colour line/bar. The latter do not appear in the user interface (except when editing the colour of an object). They are stored in a separate list in the ColourList for the document

NOTE That if an UNNAMED IndexedColour's usage count is decremented to zero, it will automatically delete itself. Named colours must be explicitly deleted.

See also:
DocColour; ColourModel; ColourContext; ColourList Documentation: HowToUse.doc

Definition at line 207 of file colourix.h.


Constructor & Destructor Documentation

IndexedColour::IndexedColour  ) 
 

Constructor for an IndexedColour object Initialises the colour to the RGBT value for Opaque Black.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 185 of file colourix.cpp.

00186 {
00187     InitialiseInfoFields(COLOURMODEL_RGBT);
00188 
00189     SourceColour.Component1 = 0;    // Black & No-colour (in RGBT)
00190     SourceColour.Component2 = 0;
00191     SourceColour.Component3 = 0;
00192     SourceColour.Component4 = 1.0;  // 100% transparent
00193 }

IndexedColour::~IndexedColour  ) 
 

Destructor for an IndexedColour object.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 212 of file colourix.cpp.

00213 {
00214     ERROR3IF(UsageCount < 0, "IndexedColour UsageCount is negative");
00215 
00216 #ifdef _DEBUG
00217     if (UsageCount != 0)
00218     {
00219         if (IsNamed())
00220             TRACE( _T("\n>> Named IndexedColour %p ('%s') is still referenced %ld times\n"),
00221                     this, (TCHAR *)(*Name), (INT32)UsageCount);
00222         else
00223             TRACE( _T("\n>> Unnamed IndexedColour %p is still referenced %ld times\n"),
00224                     this, (INT32)UsageCount);
00225 
00226         // Now, ask SimpleCCObject to wugg through all current objects to see if we can find something
00227         // that could be the pointer back at us!
00228         extern void CheckForUsedPointer(void *ThePointer);
00229 
00230         TRACE( _T("  References to this object were found in:\n"));
00231         CheckForUsedPointer(this);
00232         TRACE( _T("\n"));
00233     }
00234 
00235     ERROR3IF(UsageCount > 0, "IndexedColour deleted while still in use");
00236 
00237     if (ChildUsage != 0)
00238     {
00239         if (IsNamed())
00240         {
00241             TRACEUSER( "Jason", _T("Jason: Named IndexedColour %p ('%s') is still LINKED %ld times\n"),
00242                     this, (TCHAR *)(*Name), (INT32)ChildUsage);
00243         }
00244         else
00245         {
00246             TRACEUSER( "Jason", _T("Jason: Unnamed IndexedColour %p is still LINKED %ld times\n"),
00247                     this, (INT32)ChildUsage);
00248         }
00249     }
00250 #endif
00251 
00252     // If we are linked to another colour, we need to de-reference it
00253     if (ParentColour != NULL)
00254         ParentColour->DecrementChildUsage();
00255 
00256     if (Name != NULL)
00257         delete Name;
00258 }

IndexedColour::IndexedColour const IndexedColour Col  ) 
 

Copy constructor for an IndexedColour object.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/05/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 277 of file colourix.cpp.

00278 {
00279     Info = Col.Info;
00280     memcpy(&SourceColour, &Col.SourceColour, sizeof(ColourGeneric));
00281     memcpy(&CachedColour, &Col.CachedColour, sizeof(ColourGeneric));
00282 
00283     // If we are copying a linked/tint colour, we make ourselves linked to their parent
00284     ParentColour = Col.ParentColour;
00285     if (ParentColour != NULL)
00286         ParentColour->IncrementChildUsage();
00287 
00288     UsageCount = 0;
00289     ChildUsage = 0;
00290     
00291     Info.IsNamed = FALSE;
00292     Name = NULL;
00293     
00294     // Nasty casting to get around this messy const problem.
00295     if (((IndexedColour *)&Col)->IsNamed())
00296         SetName(*(Col.Name));   // Copy the string, not the string-pointer
00297 }

IndexedColour::IndexedColour const DocColour Col  ) 
 

Copy constructor for an IndexedColour object.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/11/94
Parameters:
Col - A DocColour from which to take the definition of this new IndexedCol [INPUTS]
- [OUTPUTS]
Returns:
-
Notes: If the DocColour is immediate (does not reference an IndexedColour) then the indexedcolour uses its colour definition - NOTE that this creates an UNNAMED colour by default (SetName it afterwards).

If the DocColour references an IndexedColour, the referenced colour is copied

Tints and Linked colours are copied and remain tints/linked (Gosh!)

Named/Unnamed colours will be copied as Named/Unnamed colours (Gosh!)

The name is copied verbatim (i.e it is not changed to 'Copy of X')

Returns:
Errors: -
See also:
IndexedColour::SetName

Definition at line 329 of file colourix.cpp.

00330 {
00331     // Find the parent IndexedColour, if any. Nasty cast to remove compiler warning
00332     IndexedColour *Def = ((DocColour *) &Col)->FindParentIndexedColour();
00333 
00334     if (Def != NULL)
00335     {
00336         // The DocColour references an IndexedColour, so copy the parent IndexedColour
00337         Info = Def->Info;
00338         memcpy(&SourceColour, &Def->SourceColour, sizeof(ColourGeneric));
00339         memcpy(&CachedColour, &Def->CachedColour, sizeof(ColourGeneric));
00340 
00341         // If we are copying a linked/tint colour, we need to link ourselves to its parent
00342         ParentColour = Def->ParentColour;
00343         if (ParentColour != NULL)
00344             ParentColour->IncrementChildUsage();
00345 
00346         UsageCount = 0;
00347         ChildUsage = 0;
00348     
00349         Info.IsNamed = FALSE;
00350         Name = NULL;
00351         if (Def->IsNamed())
00352             SetName(*(Def->Name));  // Copy the string, not the string-pointer
00353     }
00354     else
00355     {
00356         // This is an immediate DocColour, so copy its definition into our SourceColour
00357         InitialiseInfoFields(Col.GetColourModel());
00358         ((DocColour *) &Col)->GetSourceColour(&SourceColour);
00359     }
00360 }

IndexedColour::IndexedColour ColourModel  ColModel,
ColourGeneric Col
 

Constructor for an IndexedColour object Initialises the colour to the given value in the given colour model NOTE that if you have a ColourABCD structure, you can pass this in as a single parameter, and inline functions will convert the call into a call to this function on your behalf. i.e. you can use IndexedColour((ColourRGBT *)Bob); -- See colour.h.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
ColModel - The colour model in which Col is defined [INPUTS] Col - The definition, in the given colour model, of the colour
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 423 of file colourix.cpp.

00424 {
00425     InitialiseInfoFields(ColModel);
00426     memcpy(&SourceColour, Col, sizeof(ColourGeneric));
00427 }

IndexedColour::IndexedColour ColourValue  Red,
ColourValue  Green,
ColourValue  Blue,
ColourValue  Transparent = 0,
UINT32  TransType = TRANSTYPE_DEFAULT
 

Constructor for an IndexedColour object Initialises the colour to the given Extended RGBT value.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
Red; Green; Blue - The RGB definition of the colour [INPUTS]
Transparent - The transparency of the colour - IGNORED! TransType - The transparency type of the colour - IGNORED!

Parameters:
- [OUTPUTS]
Returns:
-
Notes: Colours no longer support transparency. The transparency fields are ignored.

Returns:
Errors: -
See also:
-

Definition at line 390 of file colourix.cpp.

00392 {
00393     InitialiseInfoFields(COLOURMODEL_RGBT);
00394     SourceColour.Component1 = Red;
00395     SourceColour.Component2 = Green;
00396     SourceColour.Component3 = Blue;
00397     SourceColour.Component4 = Transparent;
00398 }


Member Function Documentation

static BOOL IndexedColour::AreSpotsForcedToProcess void   )  [inline, static]
 

Definition at line 290 of file colourix.h.

00290 { return(SpotsAreProcess); };

BOOL IndexedColour::DecrementChildUsage void   )  [inline, protected]
 

Informs the IndexedColour that a client is no longer referencing it. An IndexedColour should not be deleted if its usage count != 0 Scope: private.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if the IndexedColour is not in use (can be safely deleted) TRUE if the IndexedColour is in use

Errors: -

See also:
IndexedColour::IncrementChildUsage; IndexedColour::HasLinkedChildren

Definition at line 504 of file colourix.h.

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 }

BOOL IndexedColour::DecrementUsage void   )  [inline]
 

Informs the IndexedColour that a client is no longer referencing it. An IndexedColour should not be deleted if its usage count != 0.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if the IndexedColour is not in use (can be safely deleted) TRUE if the IndexedColour is in use

Errors: -

See also:
IndexedColour::IncrementUsage; IndexedColour::IsInUse

Definition at line 413 of file colourix.h.

00414 {
00415     ENSURE(UsageCount > 0, "IndexedColour::DecrementUsage - UsageCount has gone NEGATIVE!");
00416 
00417     return((--UsageCount) != 0);
00418 }

IndexedColour * IndexedColour::FindLastLinkedParent void   )  [inline]
 

Finds the last parent colour of this colour. Note that after changing a linked/tint colour back into a normal/spot colour, the parent is remembered. This call thus returns the parent even when the colour is no longer a linked/tint colour. Intended only for use by the colour editor to allow temporary type chnages to not lose the parent link info. The colour editor probably clears the parent colour on exit.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/11/94
Returns:
The parent 'linked' colour of this colour. This will be NULL if the colour is not linked to another.
YOU SHOULD NOT BE USING THIS FUNCTION unless absolutely necessary. Use FindLinkedParent instead.

See also:
IndexedColour::FindLinkedParent

Definition at line 760 of file colourix.h.

00761 {
00762     return(ParentColour);
00763 }

IndexedColour * IndexedColour::FindLinkedParent void   ) 
 

Finds the colour upon which a tint/based-on colour is based, if any. Can also be used to determine if a colour is a tint/basedon colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/94
Returns:
The colour upon which this Tint or Linked colour is based. (If this colour is not a Tint or Linked colour, or if it is a deleted (hidden for undo) colour, the return value is NULL)
Notes: If you need to know what colour this colour *was* linked to, as the colour editor does when the user is randomly plonking about with the colour type, then call FindLastLinkedParent instead.

See also:
IndexedColour::FindLastLinkedParent

Definition at line 1080 of file colourix.cpp.

01081 {
01082     if (IsDeleted())
01083         return(NULL);
01084 
01085     if (GetType() != COLOURTYPE_TINT && GetType() != COLOURTYPE_LINKED)
01086         return(NULL);
01087 
01088     return(FindLastLinkedParent());
01089 }

IndexedColour * IndexedColour::FindOldestAncestor void   ) 
 

Finds the colour upon which a tint/based-on colour is based, if any. Can also be used to determine if a colour is a tint/basedon colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/96
Returns:
The utimate colour upon which this Tint or Linked colour is based. Note that if this colour has no parent, it will return itself!
This is similar to FindLinkedParent, except it traverses all parent links until it finds the ultimate parent of the entire linked-colour tree in which this colour resides.

See also:
IndexedColour::FindLinkedParent

Definition at line 1113 of file colourix.cpp.

01114 {
01115     IndexedColour *Ptr  = FindLinkedParent();
01116     IndexedColour *Last = this;
01117 
01118     while (Ptr != NULL)
01119     {
01120         Last = Ptr;
01121         Ptr = Ptr->FindLinkedParent();
01122     }
01123 
01124     return(Last);
01125 }

void IndexedColour::ForceSpotsToBeProcess BOOL  ForceOn  )  [static]
 

To set the global colour flag. When the flag is TRUE, all spot colours in the entire program are forced to act as "normal" colours; when set FALSE, all spot colours behave normally.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/8/96
Parameters:
ForceOn - TRUE to force spots to process, FALSE to let them be spots [INPUTS]
Notes: In many ways this would be better as a localised option, at least limited to the selected document, but this is much more difficult to achieve, and anyway, it's better that spot colours are effectively disabled by this flag, so that it becomes obvious that spot colours are no longer special.

This calls ColourManager::SelViewContextHasChanged() to make all the appropriate colour interfaces update themselves correctly. (Yeah, it's not quite the right name for what the message does, but this is just as fundamental a change as context changing)

Definition at line 1934 of file colourix.cpp.

01935 {
01936     SpotsAreProcess = ForceOn;
01937     ColourManager::SelViewContextHasChanged();
01938 }

FIXED24 IndexedColour::GetAccumulatedTintValue void   ) 
 

To determine the accumulated tint value of any colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/96
Returns:
A FIXED24 value between 0.0 and 1.0 representing the accumulated Tint for this colour. See Purpose for details.
If this is not a true tint colour, returns 0.0 (a 0% tint, i.e. white)

If this is a spot colour, returns 1.0 (i.e. 100% ink)

If this is a true tint of a spot ink, it returns the overall ink density that should be used. With a simple tint-of-spot tint, this is the normal tint value, but if there are a chain of tints, the tint values are cumulative, i.e. a 50% tint of a 50% tint of Red gives a _25_ ink density.

Thus, if you apply the GetAccumulatedTintVlaue() to the GetOldestAncestor() colour, you will arrive at the right output colour. (This isn't actually how screen values for tints are produced, but the cumulative tint is used when mixing tints in blends, and most importantly when outputting separated Spot ink plates!

Notes: The cumulative value is simply the tint values of each colour in turn in the parent-colour chain multiplied together (where process colours are treated as a tint value of 0.0 and the ultimate spot colour is 1.0)

Definition at line 1566 of file colourix.cpp.

01567 {
01568     double Tint = 1.0;
01569     IndexedColour *Ptr = this;
01570 
01571     while (Ptr != NULL && Tint > 0.0)
01572     {
01573         Tint *= Ptr->GetTintValue().MakeDouble();
01574 
01575         Ptr = Ptr->FindLinkedParent();
01576     }
01577 
01578     return(FIXED24(Tint));
01579 }

ColourModel IndexedColour::GetColourModel void   )  const
 

To determine the colour model in which an IndexedColour is defined.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The colour model in which the IndexedColour was defined
Notes: If this colour is a TINT, the parent colour's colour model is returned, as tints cannot be defined in a different model to their parents

Returns:
Errors: -
See also:
IndexedColour::GetSourceColour

Definition at line 582 of file colourix.cpp.

00583 {
00584     // If we're a tint, return our parent's colour. NOTE that we do not call GetType()
00585     // as we want to ask our parent even if it is 'deleted' for UNDO reasons.
00586     if (Info.ColourType == COLOURTYPE_TINT && ParentColour != NULL)
00587         return(ParentColour->GetColourModel());
00588 
00589     return((ColourModel) Info.SourceColourModel);
00590 }

void IndexedColour::GetDebugDetails StringBase Str  ) 
 

To get information on this colour for display in the Debug Tree.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/5/94
Parameters:
Str - string to receive the debug details [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

Definition at line 1854 of file colourix.cpp.

01855 {
01856     String_256 TempStr;
01857     ColourContext *cc = ColourContext::GetGlobalDefault(GetColourModel());
01858     ColourGeneric col;
01859 
01860     String_8 UnnamedString(TEXT("N"));
01861     if (!IsNamed())
01862         UnnamedString = TEXT("U");
01863 
01864     GetSourceColour(&col);
01865     
01866     String_32 ModelName;
01867     cc->GetModelName(&ModelName);
01868 
01869     String_32 Type(TEXT(""));
01870     switch(GetType())
01871     {
01872         case COLOURTYPE_SPOT:
01873             Type._MakeMsg(TEXT(" Spot"));
01874             break;
01875 
01876         case COLOURTYPE_TINT:
01877             if (TintIsShade())
01878                 TempStr._MakeMsg( TEXT(" Shade, resulting in"));
01879             else
01880                 TempStr._MakeMsg( TEXT(" #1%ld% Tint, resulting in"),
01881                                     (INT32) (GetTintValue().MakeDouble()*100));
01882             break;
01883 
01884         case COLOURTYPE_LINKED:
01885             Type._MakeMsg(TEXT(" Linked, resulting in"));
01886             break;
01887 
01888         default:
01889             break;
01890     }
01891 
01892 
01893     TempStr._MakeMsg( TEXT(" #1%sIxCol (#2%s) =#3%s #4%s(#5%ld, #6%ld, #7%ld, #8%ld)\r\n"),
01894                         (TCHAR *) UnnamedString,
01895                         (TCHAR *) *(GetName(TRUE)),
01896                         (TCHAR *) Type,
01897                         (TCHAR *) ModelName,
01898                         (INT32) (col.Component1.MakeDouble()*100),
01899                         (INT32) (col.Component2.MakeDouble()*100),
01900                         (INT32) (col.Component3.MakeDouble()*100),
01901                         (INT32) (col.Component4.MakeDouble()*100));
01902 
01903     (*Str) += TempStr;
01904 }

String_64 * IndexedColour::GetName BOOL  ReturnTrueID = FALSE  ) 
 

To find the name of an IndexedColour (or the ID of an unnamed indexed colour).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/04/94
Parameters:
ReturnTrueID - FALSE (the default) to retrieve the 'normal' name. If this [INPUTS] colour is unnamed, the string "Unnamed" will be returned. TRUE (*use with care*) to return a unique id for this colour. If unnamed, this will return a unique name string like "_362180". This is only intended for use by the import/export system.
- [OUTPUTS]
Returns:
A pointer to a String_64 containing the name of this indexed colour If it is named, the return value is always the name If it is unnamed, then either "Unnamed" or a unique id "_1234567" will be returned.

Errors: -

Definition at line 893 of file colourix.cpp.

00894 {
00895     static String_64 Default(_R(IDS_LOCALCOLOUR));
00896 
00897     if (IsNamed())
00898     {
00899         if (Name != NULL)
00900             return(Name);
00901     }
00902     else
00903     {
00904         if (ReturnTrueID)
00905         {
00906             // If we're an unnamed colour, then we generate an "ID" (not a name, honest, guv!)
00907             // which is unique. This is used for export/import to recognise unnamed colours
00908 
00909             if (Name == NULL)
00910             {
00911                 Name = new String_64;
00912                 if (Name != NULL)
00913                     Name->_MakeMsg( TEXT("_#1%ld"), (UINT32)(UINT_PTR)(this) );
00914             }
00915 
00916             if (Name != NULL)
00917                 return(Name);
00918         }
00919     }
00920 
00921     return(&Default);
00922 }

FIXED24 IndexedColour::GetShadeValueX void   )  const
 

Gets the current Shade Saturation value for the colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/8/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A FIXED24 value between -1.0 and 1.0 representing the Shade for this colour This value is the half of the shading settings for affecting Saturation (If the colour is not a Tint/Shade, debug builds will ENSURE, and all builds will return 1.0 (a 100% shade))
Notes: Internally, tint/shade is currently stored in the SourceColour.Component1 field And now the Component2 field as well. Bodgy city dude. This should not be relied upon externally.

Definition at line 1661 of file colourix.cpp.

01662 {
01663     if (GetType() != COLOURTYPE_TINT || !Info.InheritComponent1)
01664     {
01665         ERROR3("Attempt to read tint value for a non-shade colour");
01666         return(FIXED24(1.0));
01667     }
01668 
01669     return(SourceColour.Component1);
01670 }

FIXED24 IndexedColour::GetShadeValueY void   )  const
 

Gets the current Shade Brightness value for the colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/8/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A FIXED24 value between -1.0 and 1.0 representing the Shade for this colour This value is the half of the shading settings for affecting Brightness (If the colour is not a Tint/Shade, debug builds will ENSURE, and all builds will return 1.0 (a 100% shade))
Notes: Internally, tint/shade is currently stored in the SourceColour.Component1 field And now the Component2 field as well. Bodgy city dude. This should not be relied upon externally.

Definition at line 1695 of file colourix.cpp.

01696 {
01697     if (GetType() != COLOURTYPE_TINT || !Info.InheritComponent1)
01698     {
01699         ERROR3("Attempt to read tint value for a non-shade colour");
01700         return(FIXED24(1.0));
01701     }
01702 
01703     return(SourceColour.Component2);
01704 }

void IndexedColour::GetSourceColour ColourGeneric Result  ) 
 

Gets the definition of the IndexedColour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The colour definition of this IndexedColour, in its native colour model
Notes: If the colour is Tint/Linked, this may involve a recursive set of calls which will convert and override each parent colour up the chain until the resulting colour definition for this colour is eventually produced at the end.

Returns:
Errors: -
See also:
IndexedColour::GetColourModel

Definition at line 615 of file colourix.cpp.

00616 {
00617     ERROR3IF(Result == &SourceColour,
00618              "Illegal attempt to GetSourceColour into a colour's own SourceColour field!");
00619 
00620     if (ParentColour == NULL || ParentColour == this ||
00621         (Info.ColourType != COLOURTYPE_LINKED && Info.ColourType != COLOURTYPE_TINT))
00622     {
00623         // We are not linked to a parent colour (or the link is scarily illegal to ourself!)
00624         // (ParentColour == NULL OR we are not tint/linked)
00625         // - simply copy our own colour definition, checking that this is not an internal
00626         // call to get a source colour definition into our own source colour!
00627         if (&SourceColour != Result)
00628             memcpy(Result, &SourceColour, sizeof(ColourGeneric));
00629     }
00630     else
00631     {
00632         ERROR3IF(ParentColour == NULL || ParentColour == this ||
00633                  ParentColour->IsADescendantOf(this),
00634                  "Consistency failure in IndexedColour parent linkage");
00635 
00636         // Ask our parent for its colour definition - recurse!
00637         ParentColour->GetSourceColour(Result);
00638 
00639         // Get our 'parent' colour context
00640         ColourContext *cc = ColourContext::GetGlobalDefault(GetColourModel());
00641         ERROR3IF(cc == NULL, "IndexedColour::GetSourceColour - illegal colour context in use?!");
00642 
00643         // Now, override the colour as necessary
00644         // NOTE that we do NOT call GetType(), as this might return COLOURTYPE_NORMAL for tints/linked
00645         // colours which have 'deleted' parents. This is due to nasty UNDO considerations - we retain
00646         // our linked parent internally when it is 'deleted'.
00647         if (Info.ColourType == COLOURTYPE_LINKED)
00648         {
00649             // If necessary, convert the Result colour into our own colour model
00650             if (ParentColour->GetColourModel() != GetColourModel())
00651             {
00652                 ColourContext *ccSource = ColourContext::GetGlobalDefault(ParentColour->GetColourModel());
00653 
00654                 if (ccSource != NULL)   // Shouldn't happen, but let's be safe
00655                 {
00656                     ColourGeneric Source;
00657                     memcpy(&Source, Result, sizeof(ColourGeneric));
00658 
00659                     cc->ConvertColour(ccSource, &Source, Result);
00660                 }
00661             }
00662 
00663 // **** ToDo !!!! Override by copying OR Inherit by scaling !!!!
00664 
00665             // This is a linked colour. Override the given components with our own values
00666             if (!Info.InheritComponent1)
00667                 Result->Component1 = SourceColour.Component1;
00668             if (!Info.InheritComponent2)
00669                 Result->Component2 = SourceColour.Component2;
00670             if (!Info.InheritComponent3)
00671                 Result->Component3 = SourceColour.Component3;
00672             if (!Info.InheritComponent4)
00673                 Result->Component4 = SourceColour.Component4;
00674         }
00675         else if (Info.ColourType == COLOURTYPE_TINT)
00676         {
00677             // This is a tint. Component 1 of our 'SourceColour' is the tinting value
00678             // We get our 'parent' colour context to work out how to apply the tint/shade
00679             if (TintIsShade())
00680                 cc->ApplyShade(SourceColour.Component1, SourceColour.Component2, Result);   // Shade it
00681             else
00682                 cc->ApplyTint(SourceColour.Component1, Result);                             // Tint it
00683         }
00684         else
00685         {
00686             ERROR3("Unknown/Illegal colour type in IndexedColour::GetSourceColour");
00687         }
00688     }
00689 }

FIXED24 IndexedColour::GetTintValue void   )  const
 

Gets the current Tint value for the colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A FIXED24 value between 0.0 and 1.0 representing the Tint for this colour
Note that a spot colour returns 1.0 (a 100% tint - 100% ink density), and any process (non-spot/tint) colour returns 0.0 (a 0% tint, i.e. no ink).

NOTE that the returned tint value simply indicates how much this colour tints its parent colour (if at all). If you want to know how much ink will actually be produced for this colour, then you want to use GetAccumulatedTintValue() instead.

Notes: Internally, tint is currently stored in the SourceColour.Component1 field This should not be relied upon externally.

See also:
IndexedColour::GetAccumulatedTintValue

Definition at line 1520 of file colourix.cpp.

01521 {
01522     if (GetType() == COLOURTYPE_SPOT)
01523         return(FIXED24(1.0));                   // Spot colour is a 100% tint
01524 
01525     if (GetType() != COLOURTYPE_TINT || TintIsShade())
01526         return(FIXED24(0.0));                   // Any process colour is a 0% tint
01527 
01528     return(SourceColour.Component1);            // Any tint is a (Tint)% tint
01529 }

IndexedColourType IndexedColour::GetType void   )  const
 

Determines the type of this colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/10/94
Returns:
The type of this colour: MonoOn COLOURTYPE_NORMAL, COLOURTYPE_SPOT, COLOURTYPE_TINT, COLOURTYPE_LINKED MonoOff
Notes: If this colour is linked to a deleted colour, then for sneaky undo reasons it (internally) remains linked. However, it pretends to the outside world that it is in fact a normal colour.

See also:
IndexedColour::SetType; IndexedColour::FindLinkedParent; IndexedColour::SetLinkedParent

Definition at line 497 of file colourix.cpp.

00498 {
00499     if ((Info.ColourType == (UINT32) COLOURTYPE_LINKED ||
00500          Info.ColourType == (UINT32) COLOURTYPE_TINT) &&
00501          ParentColour != NULL && ParentColour->IsDeleted())
00502     {
00503         return(COLOURTYPE_NORMAL);
00504     }
00505 
00506     // If the global "SpotsareProcess" flag is set, then spots pretend to be normal
00507     // Unnamed/Local colours also cannot be spots, so in case we accidentally get into the
00508     // wrong state, we make sure never to return a silly result.
00509     if (Info.ColourType == COLOURTYPE_SPOT && (SpotsAreProcess || !Info.IsNamed))
00510         return(COLOURTYPE_NORMAL);
00511 
00512     return((IndexedColourType) Info.ColourType);
00513 }

BOOL IndexedColour::HasLinkedChildren void   )  [inline]
 

To determine if any other IndexedColour references this IndexedColour (An IndexedColour must not be deleted if it is in use).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the IndexedColour is in use (as a ParentColour) by other IndexedCols
Notes: This is a simple usage count, and does not handle references from undo-system hidden nodes etc. This simply records how many other IndexedColours hold ParentColour pointers to this IndexedColour.
Returns:
Errors: -
See also:
IndexedColour::IncrementChildUsage; IndexedColour::DecrementChildUsage

Definition at line 535 of file colourix.h.

00536 {
00537     return(ChildUsage != 0);
00538 }

void IndexedColour::IncrementChildUsage void   )  [inline, protected]
 

Informs the IndexedColour that yet another thing is referencing it. An IndexedColour must not be deleted if its usage count != 0 Scope: private.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
IndexedColour::DecrementChildUsage; IndexedColour::HasLinkedChildren

Definition at line 476 of file colourix.h.

00477 {
00478     ENSURE(IsNamed(), "Attempt to increment child usage of an UNNAMED colour!");
00479     ChildUsage++;
00480 }

void IndexedColour::IncrementUsage void   )  [inline]
 

Informs the IndexedColour that yet another thing is referencing it. An IndexedColour should not be deleted if its usage count != 0 A non-zero usage count on exit will generate ENSUREs which usually signal memory leaks or people forgetting to link/delink themselves properly.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
IndexedColour::DecrementUsage; IndexedColour::IsInUse

Definition at line 387 of file colourix.h.

00388 {
00389     UsageCount++;
00390 }

BOOL IndexedColour::InheritsComponent UINT32  ComponentID  ) 
 

To determine if a given component of a colour is inherited from its linked parent colour. Always returns FALSE if a colour is not linked.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/94
Parameters:
ComponentID,: a number [1..4] indicating which component of the colour [INPUTS] you wish to find out about.
Returns:
TRUE if the component is inherited from the parent FALSE if the component overrides the parent, or if the colour isn't linked
Notes: Should be used in conjunction with the appropriate ColourContext for this colour's colour model to determine if *valid* components of a colour are inherited from their parent colour. If asked about an invalid component, the result will be indeterminate (generally FALSE, but somebody may have set it to TRUE without checking if it is a valid component)

See also:
IndexedColour::GetType(); ColourContext::GetComponentName; IndexedColour::SetInheritsComponent

Definition at line 1345 of file colourix.cpp.

01346 {
01347     ERROR3IF(ComponentID < 1 || ComponentID > 4,
01348                 "Bad colour component index passed to IndexedColour::InheritsComponent");
01349 
01350     if (GetType() == COLOURTYPE_LINKED)
01351     {
01352         switch(ComponentID)
01353         {
01354             case 1:
01355                 return(Info.InheritComponent1);
01356 
01357             case 2:
01358                 return(Info.InheritComponent2);
01359 
01360             case 3:
01361                 return(Info.InheritComponent3);
01362 
01363             case 4:
01364                 return(Info.InheritComponent4);
01365         }
01366     }
01367 
01368     return(FALSE);
01369 }

void IndexedColour::InitialiseInfoFields ColourModel  ColModel  )  [protected]
 

Private shared code for construction of IndexedColour objects Initialises the 'Info' structure to default values Scope: private.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 142 of file colourix.cpp.

00143 {
00144     UsageCount = 0;                     // We are not in-use yet
00145     ChildUsage = 0;
00146 
00147     Name         = NULL;                // This colour has no name
00148 
00149     ParentColour = NULL;                // We are not linked to another colour by default
00150 
00151     Info.OCContextHandle    = 0;        // Set colour model, and remember we're not cached
00152     Info.SourceColourModel  = ColModel;
00153     Info.CacheColourModel   = COLOURMODEL_NOTCACHED;
00154 
00155     Info.InheritComponent1  =           // By default, override all components in linked colour
00156         Info.InheritComponent2 =
00157         Info.InheritComponent3 =
00158         Info.InheritComponent4 = FALSE;
00159 
00160     Info.ColourType         = COLOURTYPE_NORMAL;    // Is normal (not spot/tint/linked) colour
00161 
00162     Info.Deleted            = FALSE;                // Not a deleted (hidden) colour
00163 
00164     Info.IsNamed = FALSE;
00165 }

void IndexedColour::InvalidateCache void   )  [inline]
 

Invalidates the IndexedColours output colour cache. This ensures that the colour is re-converted and cached the next time it is used. Scope: Generally private; All public access functions invalidate the cache automatically if it is necessary (if the colour changes).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/05/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 616 of file colourix.h.

00617 {
00618     Info.CacheColourModel   = COLOURMODEL_NOTCACHED;
00619     Info.OCContextHandle    = 0;
00620 }

BOOL IndexedColour::IsADescendantOf IndexedColour TestParent  ) 
 

Recursively backtracks through the chain of LinkedParent links to determine if this colour is in any way (directly or indirectly) linked to the given Parent colour, and might therefore be affected by any change to said colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
TestParent - the parent/ancestor colour we wish to test for [INPUTS]
Returns:
TRUE if this is indeed a descendant of the given colour
Notes: To determine if a colour is the *direct* parent of another, use if (TestParent == ThisColour->FindLinkedParent())

If the TestParent is THIS colour, the return value is TRUE (i.e Yes, a change to the 'Parent' colour will affect 'this' colour!). {This is also an end-of- recursion clause}

This method only calculates descendant information for LINKED/TINT colours. Non-linked/tint colours will always spell the end of the search.

Is quite happy if TestParent is NULL - will always return FALSE in this case

Definition at line 1040 of file colourix.cpp.

01041 {
01042     if (TestParent == NULL)         // Silly test! Of course it's not!
01043         return(FALSE);
01044 
01045     if (this == TestParent)         // We are the colour being tested - we are related
01046         return(TRUE);
01047                                     // We cannot be descended, as we're a normal colour
01048     if (GetType() == COLOURTYPE_NORMAL || GetType() == COLOURTYPE_SPOT)
01049         return(FALSE);
01050 
01051     if (ParentColour == NULL)       // We have no parent, so cannot be descended from anything
01052         return(FALSE);
01053                                     // Ask our parent to check back in the family tree
01054     return(ParentColour->IsADescendantOf(TestParent));
01055 }

BOOL IndexedColour::IsDeleted void   )  [inline]
 

To determine if this colour has been marked 'deleted'. This is used for undo, to hide colours which have been 'deleted'.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this colour is marked 'deleted' FALSE if it is not

Errors: -

See also:
IndexedColour::SetDeleted

Definition at line 559 of file colourix.h.

00560 {
00561     return(Info.Deleted);
00562 }

BOOL IndexedColour::IsDifferent const IndexedColour Other,
FIXED24  ErrorLimit
 

Definition at line 804 of file colourix.cpp.

00805 {
00806     if (GetType() != Other.GetType())
00807         return(TRUE);
00808 
00809     if (GetColourModel() != Other.GetColourModel())
00810         return(TRUE);
00811 
00812     // If this is a linked colour, check if their inheritance flags match
00813     if (GetType() == COLOURTYPE_LINKED)
00814     {
00815         if (ParentColour != Other.ParentColour)
00816             return(TRUE);
00817 
00818         if (Info.InheritComponent1 != Other.Info.InheritComponent1 ||
00819             Info.InheritComponent2 != Other.Info.InheritComponent2 ||
00820             Info.InheritComponent3 != Other.Info.InheritComponent3 ||
00821             Info.InheritComponent4 != Other.Info.InheritComponent4)
00822             return(TRUE);
00823     }
00824 
00825     // If this is a tint, it has no components in the regular sense.
00826     // Return immediately with the result of comparing the tint values
00827     if (GetType() == COLOURTYPE_TINT)
00828     {
00829         if (ParentColour != Other.ParentColour)
00830             return(TRUE);
00831 
00832         if (TintIsShade() != Other.TintIsShade())
00833             return(TRUE);
00834 
00835         if (TintIsShade())
00836         {
00837             return( OUTSIDE_LIMIT(GetShadeValueX(), Other.GetShadeValueX()) ||
00838                     OUTSIDE_LIMIT(GetShadeValueY(), Other.GetShadeValueY()) );
00839         }
00840 
00841         return( OUTSIDE_LIMIT(GetTintValue(), Other.GetTintValue()) );
00842     }
00843 
00844     // Special case for greyscales...
00845     if (GetColourModel() == COLOURMODEL_GREYT)
00846     {
00847         // We ignore the 2nd and 3rd components as they are not used.
00848         if (OUTSIDE_LIMIT(SourceColour.Component1, Other.SourceColour.Component1) ||
00849             OUTSIDE_LIMIT(SourceColour.Component4, Other.SourceColour.Component4))
00850             return(TRUE);
00851     }
00852     else
00853     {
00854         if (OUTSIDE_LIMIT(SourceColour.Component1, Other.SourceColour.Component1) ||
00855             OUTSIDE_LIMIT(SourceColour.Component2, Other.SourceColour.Component2) ||
00856             OUTSIDE_LIMIT(SourceColour.Component3, Other.SourceColour.Component3) ||
00857             OUTSIDE_LIMIT(SourceColour.Component4, Other.SourceColour.Component4))
00858             return(TRUE);
00859     }
00860     
00861     return(FALSE);
00862 }

BOOL IndexedColour::IsDifferent const IndexedColour Other  ) 
 

To determine if two indexed colours share a common definition.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/8/94
Parameters:
Other - the other indexed colour to which 'this' will be compared [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the two colours are considered different FALSE if they are considered the same
This is defined as: Same Colour model, and source colour definitions and both are linked to/tint of the same colour (or none), and the 'no colour' (and if linked: inheritance bits; if tint: tinting values) and colour type match exactly.

NOTE especially that this does NOT compare the names of the colours

Definition at line 714 of file colourix.cpp.

00715 {
00716     if (GetType() != Other.GetType())
00717         return(TRUE);
00718 
00719     if (GetColourModel() != Other.GetColourModel())
00720         return(TRUE);
00721 
00722     // If this is a linked colour, check if their inheritance flags match
00723     if (GetType() == COLOURTYPE_LINKED)
00724     {
00725         if (ParentColour != Other.ParentColour)
00726             return(TRUE);
00727 
00728         if (Info.InheritComponent1 != Other.Info.InheritComponent1 ||
00729             Info.InheritComponent2 != Other.Info.InheritComponent2 ||
00730             Info.InheritComponent3 != Other.Info.InheritComponent3 ||
00731             Info.InheritComponent4 != Other.Info.InheritComponent4)
00732             return(TRUE);
00733     }
00734 
00735     // If this is a tint, it has no components in the regular sense.
00736     // Return immediately with the result of comparing the tint values
00737     if (GetType() == COLOURTYPE_TINT)
00738     {
00739         if (ParentColour != Other.ParentColour)
00740             return(TRUE);
00741 
00742         if (TintIsShade() != Other.TintIsShade())
00743             return(TRUE);
00744 
00745         if (TintIsShade())
00746         {
00747             return(GetShadeValueX() != Other.GetShadeValueX() ||
00748                     GetShadeValueY() != Other.GetShadeValueY());
00749         }
00750 
00751         return(GetTintValue() != Other.GetTintValue());
00752     }
00753 
00754     if (GetColourModel() == COLOURMODEL_GREYT)
00755     {
00756         // We ignore the 2nd and 3rd components as they are not used.
00757         // (Should not be necessary, as these components should be zeroed anyway)
00758         if (SourceColour.Component1 != Other.SourceColour.Component1 ||
00759             SourceColour.Component4 != Other.SourceColour.Component4)
00760             return(TRUE);
00761     }
00762     else
00763     {   
00764         if (SourceColour.Component1 != Other.SourceColour.Component1 ||
00765             SourceColour.Component2 != Other.SourceColour.Component2 ||
00766             SourceColour.Component3 != Other.SourceColour.Component3 ||
00767             SourceColour.Component4 != Other.SourceColour.Component4)
00768             return(TRUE);
00769     }
00770 
00771     return(FALSE);
00772 }

BOOL IndexedColour::IsInUse BOOL  IgnoreColourGallery = FALSE  )  [inline]
 

To determine if anything references this IndexedColour (An IndexedColour must not be deleted if it is in use).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/03/94
Parameters:
[IgnoreColourGallery - INTERNAL paramter for Colour SuperGallery ONLY] [INPUTS] [LEAVE THIS PARAMETER OUT!]
- [OUTPUTS]
Returns:
FALSE if the IndexedColour can safely be deleted TRUE if the IndexedColour is in use
Notes: This is a simple usage count, and does not handle references from undo-system hidden nodes etc. This simply records how many things hold pointers to this IndexedColour object.
Returns:
Errors: -
See also:
IndexedColour::IncrementUsage; IndexedColour::DecrementUsage

Definition at line 446 of file colourix.h.

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 }

BOOL IndexedColour::IsNamed void   )  [inline]
 

Determines if this colour has been given a name. This cannot be determined using the GetName function, which returns a default name if the colour is unnamed.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
Returns:
TRUE if this colour is named (GetName will return this name) FALSE if this colour is not named (GetName will return a string like "Unnamed colour" if this is the case)
See also:
IndexedColour::SetName; IndexedColour::GetName

Definition at line 729 of file colourix.h.

00730 {
00731     return((Info.IsNamed) ? TRUE : FALSE);      // **** !!!! TEMPORARY BODGE!
00732     //return(Name != NULL);
00733 }

BOOL IndexedColour::IsSpotOrTintOfSpot void   )  const
 

Determines if this colour is either a spot colour or a true tint of a spot colour. (Tints can unfortunately be made from non-spot colour parents, so you need to call this function to determine if a tint really is cleanly derived from a spot colour, or if it must be treated as a simple process colour).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Returns:
TRUE if this colour is either a spot colour or a tint of a spot colour
Thus, this returns TRUE if the colour itself is a Spot, or if it is a Tint and its parent returns TRUE from IsSpotOrTintOfSpot().

Notes: If a colour in the tint chain is deleted, then all children must become process (non true-tint) colours, so this will return FALSE

Definition at line 540 of file colourix.cpp.

00541 {
00542     if (Info.Deleted)
00543         return(FALSE);
00544 
00545     IndexedColourType Type = GetType();
00546     if (Type == COLOURTYPE_SPOT)
00547         return(TRUE);                               // Is it a true spot colour?
00548 
00549     if (Type != COLOURTYPE_TINT || TintIsShade())
00550         return(FALSE);                              // It's not even a tint
00551 
00552     if (ParentColour == NULL)
00553         return(FALSE);                              // We have no parent colour
00554 
00555     // OK, we're a tint of something. Recurse to find out if that something
00556     // is a true tint or a spot colour.
00557     return(ParentColour->IsSpotOrTintOfSpot());
00558 }

void IndexedColour::LinkedAncestorHasChanged void   )  [inline]
 

Informs an IndexedColour that an ancestor in the linking chain has changed, and that therefore, it may also have changed.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/05/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
The ColourManager automatically calls this function for all affected colours whenever it recieves a ColourChangingMsg COLOURUPDATED, so it should never be necessary for anyone other than ColourManager to call this function.

Notes: Currently this simply invalidates the cache to make the next access update the colour from its Parent(s). A separate function has been used just in case we change our minds about how this should be done in the future.

Returns:
Errors: -
See also:
-

Definition at line 648 of file colourix.h.

00649 {
00650     InvalidateCache();
00651 }

IndexedColour & IndexedColour::operator= const IndexedColour Other  ) 
 

IndexedColour assignment operator Copies the definition of one IndexedColour into another Notes: The name field is copied verbatim - if you want it to say 'Copy of ...' then you'll have to prepend this text yourself.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/94
Parameters:
Other - colour to copy [INPUTS]
- [OUTPUTS]
Returns:

Errors: ERROR2 if you try to copy a colour over itself

Definition at line 448 of file colourix.cpp.

00449 {
00450     ERROR2IF(&Other == this, *this, "Attempt to copy an IndexedColour over itself!");
00451 
00452     Info = Other.Info;
00453     memcpy(&SourceColour, &Other.SourceColour, sizeof(ColourGeneric));
00454     memcpy(&CachedColour, &Other.CachedColour, sizeof(ColourGeneric));
00455 
00456     if (ParentColour != NULL)                   // Delink from old parent (if any)
00457         ParentColour->DecrementChildUsage();
00458 
00459     ParentColour = Other.ParentColour;
00460     if (ParentColour != NULL)                   // Link to new parent (if any)
00461         ParentColour->IncrementChildUsage();
00462 
00463 //  UsageCount = 0;     // These DO NOT CHANGE! We still have people referencing us
00464 //  ChildUsage = 0;     // and we must not forget about them!
00465 
00466     Info.IsNamed = FALSE;
00467     if (((IndexedColour *)&Other)->IsNamed())
00468         SetName(*(Other.Name));     // Copy the string, not the string-pointer
00469 
00470     return(*this);
00471 }

void IndexedColour::SetDeleted BOOL  DeletedFlag  )  [inline]
 

This marks/unmarks a colour as 'deleted'. This flag is used for undo, to hide colours which have been 'deleted'. Remember that this constitutes a change to the colour, so you should call ColourManager::ColourListHasChanged, to ensure that the Colour dialogues update all displayed lists to show/not-show this colour. Scope: Only intended for internal ColourManager use Notes: Used by the undoable ColourManager OpColourChange. You should use colour manager calls to delete colours rather than touching them directly. Note that you can 'delete'/'undelete' colours even when they are deemed 'In Use'.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
IndexedColour::IsInUse; IndexedColour::IsDeleted; ColourManager::ColourHasChanged

Definition at line 591 of file colourix.h.

00592 {
00593     Info.Deleted = DeletedFlag;
00594 }

BOOL IndexedColour::SetInheritsComponent UINT32  ComponentID,
BOOL  Inherits
 

To set if a given component of a colour is inherited from its linked parent colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/94
Parameters:
ComponentID,: a number [1..4] indicating which component of the colour [INPUTS] you wish to set inheritance information for. Inherits - TRUE if the component is to be inherited from the parent FALSE if the component is to override the parent
Returns:
TRUE if this results in the stored value actually changing

Errors: In a debug build, will give an ERROR3 if the colour is not linked or if the index given is out of range. In all builds, incorrect parameters will be ignored.

Notes: Should be used in conjunction with the appropriate ColourContext for this colour's colour model to determine if a component is *valid* before you try to set it.

See also:
IndexedColour::GetType(); ColourContext::GetComponentName; IndexedColour::InheritsComponent

Definition at line 1402 of file colourix.cpp.

01403 {
01404     BOOL Result = FALSE;
01405     
01406     ERROR3IF(ComponentID < 1 || ComponentID > 4,
01407                 "Bad colour component index passed to IndexedColour::InheritsComponent");
01408 
01409     ERROR3IF(GetType() != COLOURTYPE_LINKED,
01410                 "Attempt to set Component Inheritance for non-Linked colour");
01411 
01412     UINT32 ItInherits = (Inherits) ? 1 : 0;
01413 
01414     if (GetType() == COLOURTYPE_LINKED)
01415     {
01416         switch(ComponentID)
01417         {
01418             case 1:
01419                 Result = (Info.InheritComponent1 != ItInherits);
01420                 Info.InheritComponent1 = ItInherits;
01421                 break;
01422 
01423             case 2:
01424                 Result = (Info.InheritComponent2 != ItInherits);
01425                 Info.InheritComponent2 = ItInherits;
01426                 break;
01427 
01428             case 3:
01429                 Result = (Info.InheritComponent3 != ItInherits);
01430                 Info.InheritComponent3 = ItInherits;
01431                 break;
01432 
01433             case 4:
01434                 Result = (Info.InheritComponent4 != ItInherits);
01435                 Info.InheritComponent4 = ItInherits;
01436                 break;
01437         }
01438     }
01439 
01440     if (Result)                 // If the colour has changed, invalidate the output cache
01441         InvalidateCache();
01442 
01443     return(Result);
01444 }

void IndexedColour::SetLinkedParent IndexedColour Parent,
IndexedColourType  NewType = COLOURTYPE_LINKED
 

To make a colour linked to or a tint of another colour. This links the colour to the parent.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/94
Parameters:
Parent - the new Linked/Tint parent IndexedColour, or [INPUTS] NULL to remove any existing link
NewType - The ColourType to set this to. Note that for NORMAL/SPOT, the parent field must be NULL; For LINKED/TINT, it must point at a valid Named IndexedColour. If this is not the case, an ERROR3 will occur.

Notes: Generally, the colour's colour model and definition will be unaffected. However, if the colour was previously linked/tint, and it is being made into a standalone colour, the existing linked colour definition will be read, and then placed into SourceColour as a standalone version of the previous linked definition. (i.e. the colour's appearance will not change but the link will be broken)

If the colour was not already a COLOURTYPE_LINKED when it is being made LINKED, all components will be set to override the parent.

If the colour was not already a COLOURTYPE_TINT when it is being made a TINT, it will be set to be a 100% tint (no tinting at all)

When making a COLOURTYPE_TINT colour, it will be a TINT, not a SHADE. To make a shade, make it COLOURTYPE_TINT then call SetTintOrShade(TRUE); If it was already a COLOURTYPE_TINT, the tint/shade state is unaffected.

The colour's output cache is flushed by this call

It is your responsibility to confirm overwriting the colour. It is also your responsibility to inform the system that this colour has changed, by calling ColourManager::ColourHasChanged

IMPORTANT NOTE: This method allows you to do things like making a colour 'normal' (supposedly not linked), but still set a parent colour. This is a potentially dangerous practice so be very careful. (It is allowed so that the colour editor can cunningly remember what a colour was last linked to, in order to be far more helpful to the user).

Scope: private? Generally speaking, you should not be calling this method, unless you are the colour editor, or a load/import filter.

See also:
IndexedColour::GetLinkedParent; IndexedColour::GetLastLinkedParent; IndexedColour::SetInheritsComponent; IndexedColour::SetType; IndexedColourType; ColourManager::ColourHasChanged
Returns:
Errors: ERROR3 if you try to do anythign totally stupid (circular linking, linking to deleted colours, linking to unnamed colours, etc)

Definition at line 1188 of file colourix.cpp.

01189 {
01190     if (this == Parent)
01191     {
01192         ERROR3("Illegal attempt to make an IndexedColour Linked to itself");
01193         return;
01194     }
01195 
01196     if (Parent != NULL && Parent->IsADescendantOf(this))
01197     {
01198         // Our new parent-to-be is already a linked child of us!
01199         ERROR3("Illegal attempt to generate circular reference in Colour linking"); 
01200         return;
01201     }
01202 
01203     if (Parent != NULL && !Parent->IsNamed())
01204     {
01205         ERROR3("Illegal attempt to use UNNAMED IndexedColour as a linked parent");
01206         return;
01207     }
01208 
01209     if (Parent!= NULL && Parent->IsDeleted())
01210     {
01211         ERROR3("Illegal attempt to use 'DELETED' IndexedColour as a linked parent");
01212         return;
01213     }
01214 
01215 
01216     switch(NewType)
01217     {
01218         case COLOURTYPE_LINKED:
01219             if (GetType() != COLOURTYPE_LINKED)
01220             {
01221                 Info.InheritComponent1  =       // Override all components for now
01222                     Info.InheritComponent2 =
01223                     Info.InheritComponent3 =
01224                     Info.InheritComponent4 = FALSE;
01225             }
01226             break;
01227 
01228 
01229         case COLOURTYPE_TINT:
01230             if (GetType() != COLOURTYPE_TINT)
01231             {
01232                 SetType(NewType);               // Set type now to stop the next call ENSURE'ing
01233                 SetTintOrShade(FALSE);          // Make it a real tint (not a shade "tint")
01234                 SetTintValue(FIXED24(1.0));     // 100% tint (the colour) for now
01235             }
01236 
01237             // Swapping from Tint to Shade (which are both COLOURTYPE_TINT will need to do this,
01238             // so we do it even if it is supposely chnaging to the same "type"
01239             if (Parent != NULL)
01240                 Info.SourceColourModel = (UINT32) Parent->GetColourModel();
01241             break;
01242 
01243 
01244         default:        // COLOURTYPE_NORMAL, COLOURTYPE_SPOT
01245             if (FindLastLinkedParent() != NULL)
01246             {
01247                 // If this was previously a tint/linked colour, then copy the resulting
01248                 // colour definition into this colour to make it standalone again.
01249 
01250                 ColourGeneric NewSourceColour;
01251                 GetSourceColour(&NewSourceColour);
01252                 memcpy(&SourceColour, &NewSourceColour, sizeof(ColourGeneric));
01253             }
01254             break;
01255     }
01256 
01257     if (ParentColour != NULL)
01258         ParentColour->DecrementChildUsage();
01259 
01260     ParentColour = Parent;          // Set the new linked/tint parent colour
01261 
01262     if (ParentColour != NULL)
01263         ParentColour->IncrementChildUsage();
01264 
01265     InvalidateCache();              // Invalidate the output colour cache
01266     SetType(NewType);               // And set the new type of the colour
01267 }

void IndexedColour::SetName const StringBase NewName,
BOOL  ForceNamed = TRUE
 

To set the name of an IndexedColour. The name will be truncated to a maximum length of 63 characters.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/04/94
Parameters:
NewName - A StringBase which will be *copied* as this colours new name. [INPUTS] NOTE that this name will be truncated to a maximum length of 63 characters, and any underscore characters within it will be converted to spaces
ForceNamed - if TRUE (the default), this forces the colour to become 'named' and will strip out underline characters from it. If FALSE (*use with care*) this will leave the colour in its current state, (i.e. won't make an unnamed colour named) and will retain underlines. This is only intended for use by importers for handling export/import of unnamed colours.

Notes: Any underscore characters in the name will be converted to spaces, on the grounds that the export system uses underscores as a special name identifier to recognise unnamed colours. Suffice to say we just don't allow underscores

If NewName is NULL, or if we fail to allocate space for the name to be stored, the colour will revert to having no name.

Setting the name of an IndexedColour makes it a Named IndexedColour (Trust me, that is less silly than it sounds! ;-)

See also:
IndexedColour::SetUnnamed; IndexedColour::IsNamed

Definition at line 960 of file colourix.cpp.

00961 {
00962     if (ForceNamed)
00963         Info.IsNamed = TRUE;
00964 
00965     if (Name == NULL)
00966         Name = new String_64;       // If this fails, Name will just be NULL, which is safe
00967 
00968     if (Name != NULL)
00969     {
00970         if (ForceNamed)
00971         {
00972             const TCHAR *Src  = (const TCHAR *)NewName;
00973             TCHAR *Dest = (TCHAR *)(*Name);
00974 
00975             // Copy up to 63 chars across
00976             camStrncpy(Dest, Src, 63);
00977             
00978             // convert underscores into spaces
00979             Name->SwapChar(TCHAR('_'), TCHAR(' '));
00980         }
00981         else
00982         {
00983             NewName.Left(Name, 63);         // Truncate to 63 chars max, and copy
00984         }
00985     }
00986 }

void IndexedColour::SetShadeValues FIXED24  NewShadeValueX,
FIXED24  NewShadeValueY
 

Sets new shade values for a Shade colour. Will generate ENSURE failures in the debug build if the colour is not a Tint/Shade.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/8/95
Parameters:
NewShadeValueX - the new Shade Saturation value, in the range -1.0 to 1.0 [INPUTS] NewShadeValueY - the new Shade Brightness value, in the range -1.0 to 1.0
- [OUTPUTS]
Returns:
-
This also forces a Tint to be a shade (not a true tint)

Notes: Internally, tint/shade is currently stored in the SourceColour.Component1 field. And now the Component2 field as well. Bodgy city dude. This should not be relied upon externally.

See also:
IndexedColour::SetTintValue

Definition at line 1606 of file colourix.cpp.

01607 {
01608     if (GetType() != COLOURTYPE_TINT)
01609     {
01610         ERROR3("Your puny attempt to set the shade values for a non-shade colour has been ignored");
01611         return;
01612     }
01613 
01614     Info.InheritComponent1 = TRUE;      // Force it to be a shade
01615 
01616 
01617     if (NewShadeValueX <= FIXED24(-1.0))
01618         NewShadeValueX = FIXED24(-1.0);
01619 
01620     if (NewShadeValueX >= FIXED24(1.0))
01621         NewShadeValueX = FIXED24(1.0);
01622 
01623     SourceColour.Component1 = NewShadeValueX;
01624 
01625 
01626     if (NewShadeValueY <= FIXED24(-1.0))
01627         NewShadeValueY = FIXED24(-1.0);
01628 
01629     if (NewShadeValueY >= FIXED24(1.0))
01630         NewShadeValueY = FIXED24(1.0);
01631 
01632     SourceColour.Component2 = NewShadeValueY;
01633 
01634 
01635     InvalidateCache();      // The colour has changed, so invalidate the output cache
01636 }

void IndexedColour::SetSourceColourModel ColourModel  NewModel  )  [inline, protected]
 

Sets our colour model number, and invalidates the colour cache Scope: Private, for use by friend classes only.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/05/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 671 of file colourix.h.

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 }

void IndexedColour::SetTintOrShade BOOL  IsATint  ) 
 

Sets a COLOURTYPE_TINT colour to be either a Tint (fade-to-white) or a shade (fade-to-black) colour. The tint/shade fraction is unchnaged (the colour will just toggle between being darker and lighter!).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/8/95
Parameters:
IsATint - TRUE to make this Tint a true Tint, FALSE to make it a Shade [INPUTS]
Notes: Internally, tint/shade is currently stored in the SourceColour.Component1 field This should not be relied upon externally.

Definition at line 1726 of file colourix.cpp.

01727 {
01728     if (GetType() != COLOURTYPE_TINT)
01729     {
01730         ERROR3("Attempt to set tint/shade value for a non-tint colour");
01731         return;
01732     }
01733 
01734     Info.InheritComponent1 = IsATint ? 1 : 0;
01735 }

void IndexedColour::SetTintValue FIXED24  NewTintValue  ) 
 

Sets a new tint value for a Tint colour. Will generate ENSURE failures in the debug build if the colour is not a tint.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
NewTintValue - the new tint value, in the range 0.0 to 1.0 [INPUTS] Any value outside this range will be clipped to 0.0 or 1.0
- [OUTPUTS]
Returns:
-
This also forces a Tint to be a true tint (not a shade)

Notes: Internally, tint is currently stored in the SourceColour.Component1 field. This should not be relied upon externally.

See also:
IndexedColour::SetShadeValues

Definition at line 1470 of file colourix.cpp.

01471 {
01472     if (GetType() != COLOURTYPE_TINT)
01473     {
01474         ERROR3("Your puny attempt to set the tint value for a non-tint colour has been ignored");
01475         return;
01476     }
01477 
01478     Info.InheritComponent1 = FALSE;     // Force it to be a tint (not a shade)
01479 
01480     if (NewTintValue <= FIXED24(0.0))
01481         NewTintValue = 0;
01482 
01483     if (NewTintValue >= FIXED24(1.0))
01484         NewTintValue = FIXED24(1.0);
01485 
01486     SourceColour.Component1 = NewTintValue;
01487 
01488     InvalidateCache();      // The colour has changed, so invalidate the output cache
01489 }

BOOL IndexedColour::SetType IndexedColourType  NewType  )  [protected]
 

Sets the type of this colour: MonoOn COLOURTYPE_NORMAL, COLOURTYPE_SPOT, COLOURTYPE_TINT, COLOURTYPE_LINKED MonoOff.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/11/94
Returns:
TRUE if this caused the type of this colour to be changed FALSE if the new type is the same as the old type
Notes: If you wish to make a colour Linked or a Tint, then you should set its type at the same time as its parent-link in SetLinkedParent(). If you wish to make a linked/tint colour normal again, then you should also use SetLinkedParent.

On second thoughts, you shouldn't be calling this method!

Scope: private

See also:
IndexedColour::SetType; IndexedColour::FindLinkedParent; IndexedColour::SetLinkedParent

Definition at line 1299 of file colourix.cpp.

01300 {
01301     BOOL Result = (NewType != (IndexedColourType) Info.ColourType);
01302 
01303     if ((INT32)NewType < 0 || (INT32)NewType > 3)
01304     {
01305         ERROR3("Attempt to set invalid colour type");
01306         return(FALSE);
01307     }
01308 
01309     Info.ColourType = (UINT32) NewType;
01310 
01311     if (Result)                 // If the colour has changed, invalidate the output cache
01312         InvalidateCache();
01313 
01314     return(Result);
01315 }

void IndexedColour::SetUnnamed void   ) 
 

To UNset the name of an IndexedColour, forcing it back to being Unnamed.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/04/94

Definition at line 1001 of file colourix.cpp.

01002 {
01003     Info.IsNamed = FALSE;
01004 
01005     if (Name != NULL)
01006         delete Name;
01007 
01008     Name = NULL;
01009 }

ColourGeneric * IndexedColour::SourceColourPtr void   )  [inline, protected]
 

Returns a pointer to our source colour. Used to encapsulate our data for external friend users, rather than them poking directly at our data structures. Inlined, so just as efficient anyway. Scope: Private, for use by friend class ColourContext.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/04/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to our source colour. Note that this is our source colour so it would be appreciated if you'd not trample all over it with hob nailed boots.

Errors: -

See also:
-

Definition at line 704 of file colourix.h.

00705 {
00706     return(&SourceColour);
00707 }

void IndexedColour::SwapWith IndexedColour Other  ) 
 

Definition at line 1806 of file colourix.cpp.

01807 {
01808     // Components to copy are:
01809     //      Info
01810     //      SourceColour
01811     //      ParentColour pointer
01812     //      Name POINTER
01813     //          CachedColour    -- We are discarding the cache anyway so ignore
01814     //          UsageCount      -- We wish to keep the usage counts intact, as it is
01815     //          ChildUsage          the number of refs to THIS object.
01816     // Thus, only the first 4 in this list are copied.
01817 
01818     JASONSWAP(Info, Other->Info, IndexedColourInfo);
01819     JASONSWAP(SourceColour, Other->SourceColour, ColourGeneric);
01820 
01821     // Swap the Name POINTER
01822     String_64 *NameTemp = Name;
01823     Name = Other->Name;
01824     Other->Name = NameTemp;
01825 
01826     // Swap the linked/tint Parent Colour pointer
01827     IndexedColour *ParentTemp = ParentColour;
01828     ParentColour = Other->ParentColour;
01829     Other->ParentColour = ParentTemp;
01830 
01831     // And invalidate the caches just to be on the safe side
01832     Info.CacheColourModel = Other->Info.CacheColourModel = COLOURMODEL_NOTCACHED;
01833     Info.OCContextHandle  = Other->Info.OCContextHandle  = 0;
01834 }

BOOL IndexedColour::TintIsShade void   )  const
 

Determines if a COLOURTYPE_TINT colour is really a tint or a shade.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/8/95
Returns:
TRUE if this COLOURTYPE_TINT colour is a true Tint, FALSE if it's a Shade
Notes: COLOURTYPE_TINT has two "subtypes" (tint-to white (tint) and tint-to-black (shade)). These are differentiated by a single flag, and are otherwise implemented identically. Thus, if it's type is "Tint" then it could be a shade! (Nasty, but gets around a shortage of flag bits, and also allows us to continue using screeds of old code which doesn't know the difference between tints and shades and doesn't need to know)

Internally, tint/shade is currently stored in the SourceColour.Component1 field This should not be relied upon externally.

Definition at line 1762 of file colourix.cpp.

01763 {
01764     if (Info.ColourType != COLOURTYPE_TINT)
01765     {
01766         ERROR3("TintIsShade() called for non-tint/shade colour");
01767         return(FALSE);
01768     }
01769 
01770     return(Info.InheritComponent1);
01771 }


Friends And Related Function Documentation

friend class ColourContext [friend]
 

Definition at line 209 of file colourix.h.

friend class ColourPicker [friend]
 

Definition at line 211 of file colourix.h.

friend class DocColour [friend]
 

Definition at line 210 of file colourix.h.


Member Data Documentation

ColourGeneric IndexedColour::CachedColour [protected]
 

Definition at line 297 of file colourix.h.

DWORD IndexedColour::ChildUsage [protected]
 

Definition at line 300 of file colourix.h.

IndexedColourInfo IndexedColour::Info [protected]
 

Definition at line 295 of file colourix.h.

String_64* IndexedColour::Name [protected]
 

Definition at line 304 of file colourix.h.

IndexedColour* IndexedColour::ParentColour [protected]
 

Definition at line 299 of file colourix.h.

ColourGeneric IndexedColour::SourceColour [protected]
 

Definition at line 296 of file colourix.h.

BOOL IndexedColour::SpotsAreProcess = FALSE [static, private]
 

Definition at line 325 of file colourix.h.

DWORD IndexedColour::UsageCount [protected]
 

Definition at line 302 of file colourix.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:27 2007 for Camelot by  doxygen 1.4.4