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