#include <collist.h>
Inheritance diagram for ColourList:
Public Member Functions | |
ColourList () | |
ColourList constructor. | |
~ColourList () | |
ColourList destructor. | |
void | Init (BaseDocument *ParentDocument) |
ColourList initialiser. MUST be called after constructing a ColourList in order to correctly initialise it. Note that if ParentDocument is not set to a useful value, some operations on colour lists (eg. the colour editor) will fail. | |
void | AddHead (ListItem *) |
Overrides the List::AddHead method to ensure that any added item has a name which is unique within this colour list. | |
void | AddTail (ListItem *) |
Overrides the List::AddTail method to ensure that any added item has a name which is unique within this colour list. | |
BOOL | AddItem (IndexedColour *NewColour) |
Adds an IndexedColour item to the tail of the ColourList The name of the colour is checked, and may be changed to ensure that it is a unique identifier within the scope of this colour list. | |
LISTPOS | InsertBefore (LISTPOS here, ListItem *item) |
Inserts a NAMED IndexedColour at a particular list position (See List base class for a further description of the actual insertion process). | |
ListItem * | InsertBefore (ListItem *here, ListItem *item) |
Inserts the 'newItem' ListItem before 'here' ListItem in the list. | |
LISTPOS | InsertAfter (LISTPOS here, ListItem *item) |
Inserts a ListItem in the list position after the one that is passed in. Notes: To find 'here', the list must be scanned, so this is much slower on average than the other flavour of InsertAfter. | |
ListItem * | InsertAfter (ListItem *here, ListItem *item) |
Inserts the 'newItem' ListItem after 'here' ListItem in the list. | |
virtual void | DeleteAll () |
Deletes the list, calling the destructors of all ListItems. | |
UINT32 | GetUndeletedCount (void) |
Count the number of non-'deleted' items in a ColourList. | |
IndexedColour * | FindUndeletedItem (INT32 Index) |
The same as the conventional List FindItem() function, except that it treats 'deleted' colours as if they are not in the list. | |
IndexedColour * | GetUndeletedHead (void) |
The same as the conventional List GetHead() function, except that it treats 'deleted' colours as if they are not in the list. | |
IndexedColour * | GetUndeletedNext (IndexedColour *ThisItem) |
The same as the conventional List GetNext() function, except that it treats 'deleted' colours as if they are not in the list. | |
BaseDocument * | GetParentDocument (void) |
To find the parent document of this colour list. | |
IndexedColour ** | CompileInheritanceArray (IndexedColour *Parent) |
Compiles a NULL-terminated array of pointers to ALL colours which are linked to this, both directly and indirectly (i.e. an array listing the entire inheritance 'subtree' from 'Parent', *including* 'Parent', and including named, unnamed, and 'deleted' colours). | |
void | RemoveLinksToColour (IndexedColour *DeadColour) |
Scans the entire ColourList for any colours which reference the given IndexedColour. All these colours are converted into standalone representation of their former definition, so that all child-links of this colour are removed. It is then safe to delete the colour. | |
BOOL | IsColourInUseInDoc (IndexedColour *TheColour, BOOL IgnoreColourGallery=FALSE) |
Determine if a colour is used in the parent document. This is similar to IndexedColour::IsInUse(), but it also traverses the linking hierarchy to see if a colour is in use indirectly (e.g. A parent of a colour that is in use is needed for the document even if it is not used directly in document. | |
void | InvalidateInheritanceCache (void) |
Deallocates any memory used for the array of IndexedColours compiled by ColourList::CompileInheritanceArray. The next request for such an array will be regenerated from the ColourList, rather than from cache. | |
BOOL | NamedColourExists (PCTSTR pName) |
Determine if a colour name is already in use by any colours stored in this colour list. | |
BOOL | NamedColourExists (const StringBase *pName) |
Determine if a colour name is already in use by any colours stored in this colour list. | |
BOOL | GenerateUniqueColourName (const StringBase *pPrefix, String_64 *pResult) |
Scans the entire ColourList to determine if the suggested name is unique within this document. If it is not, the name is altered (currently by truncating to 50 characters and appending a decimal number) to provide a unique name, which is returned in the supplied string. | |
List * | GetUnnamedColours (void) |
To find the unnamed colours for this document. | |
Private Attributes | |
BaseDocument * | ParentDoc |
IndexedColour * | ArrayParent |
IndexedColour ** | InheritanceArray |
INT32 | LastUnnamedColour |
List | UnnamedColours |
The Colour list also includes another simple List of unnamed colours which are used for local colour attributes in a document. Unnamed colours are simply stored in this list, and are simpler than named colours...
Definition at line 141 of file collist.h.
|
ColourList constructor.
Definition at line 138 of file collist.cpp. 00139 { 00140 ParentDoc = NULL; // Document containing this list 00141 ArrayParent = NULL; // Current parent of the cached array 00142 InheritanceArray = NULL; // Cached array of all offspring of ArrayParent 00143 LastUnnamedColour = 2; // Memory to optimise unnamed-colour name generation 00144 }
|
|
ColourList destructor.
Definition at line 162 of file collist.cpp. 00163 { 00164 InvalidateInheritanceCache(); // Release our memory claims 00165 00166 UnnamedColours.DeleteAll(); // Delete any remaining unnamed colours 00167 // This will probably cause IxCol in use errors 00168 // as by now all colours should have been deleted 00169 // automatically when their usage reached zero. 00170 }
|
|
Overrides the List::AddHead method to ensure that any added item has a name which is unique within this colour list.
Reimplemented from List. Definition at line 236 of file collist.cpp. 00237 { 00238 ERROR3IF(!IS_A(ItemToAdd, IndexedColour), "You can only insert IndexedColours into ColourLists!"); 00239 00240 IndexedColour *NewColour = (IndexedColour *) ItemToAdd; 00241 00242 // Ensure the colour has a name which is unique within this colour list 00243 ERROR3IF(!NewColour->IsNamed(), "You can't Insert an unnamed colour before a named one!"); 00244 00245 // It's a named colour, so make sure its name is unique 00246 String_64 NewName; 00247 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00248 NewColour->SetName(NewName); 00249 00250 // And call the base class to add the item 00251 List::AddHead(ItemToAdd); 00252 }
|
|
Adds an IndexedColour item to the tail of the ColourList The name of the colour is checked, and may be changed to ensure that it is a unique identifier within the scope of this colour list.
Definition at line 311 of file collist.cpp. 00312 { 00313 // Ensure the colour has a name which is unique within this colour list 00314 if (!NewColour->IsNamed()) 00315 { 00316 UnnamedColours.AddTail(NewColour); 00317 return(TRUE); 00318 } 00319 00320 // It's a named colour, then... 00321 String_64 NewName; 00322 00323 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00324 NewColour->SetName(NewName); 00325 00326 // And add it to the tail of the list - using the base class function, not our overrides! 00327 List::AddTail(NewColour); 00328 return(TRUE); 00329 }
|
|
Overrides the List::AddTail method to ensure that any added item has a name which is unique within this colour list.
Reimplemented from List. Definition at line 272 of file collist.cpp. 00273 { 00274 ERROR3IF(!IS_A(ItemToAdd, IndexedColour), "You can only insert IndexedColours into ColourLists!"); 00275 00276 IndexedColour *NewColour = (IndexedColour *) ItemToAdd; 00277 00278 // Ensure the colour has a name which is unique within this colour list 00279 ERROR3IF(!NewColour->IsNamed(), "You can't Insert an unnamed colour before a named one!"); 00280 00281 // It's a named colour, so make sure its name is unique 00282 String_64 NewName; 00283 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00284 NewColour->SetName(NewName); 00285 00286 // And call the base class to add the item 00287 List::AddTail(ItemToAdd); 00288 }
|
|
Compiles a NULL-terminated array of pointers to ALL colours which are linked to this, both directly and indirectly (i.e. an array listing the entire inheritance 'subtree' from 'Parent', *including* 'Parent', and including named, unnamed, and 'deleted' colours).
Notes: The array is NULL terminated The array INCLUDES Parent as its first member (Array[0]) The array is owned (allocated and deallocated) by the ColourList. It MUST be treated as a read-only shared array. The array includes ALL affected indexed colours. Use IsDeleted() and IsNamed() to sort out named/unnamed colours, and deleted (hidden for undo) colours. This is expected to be called mainly as a result of COLOURUPDATED ColourChangingMsg broadcasts. The cache is flushed automatically by the colour manager just prior to these broadcasts. If you want to use this function outside these message broadcasts, then you must invalidate the cache at an appropriate time.
Definition at line 652 of file collist.cpp. 00653 { 00654 if (Parent != ArrayParent) 00655 { 00656 InvalidateInheritanceCache(); // Throw away any existing array 00657 00658 // Generate the array 00659 INT32 ColourArraySize = 32; 00660 InheritanceArray = (IndexedColour**) CCMalloc(ColourArraySize * sizeof(IndexedColour *)); 00661 00662 if (InheritanceArray == NULL) 00663 { 00664 InformError(); // Out of memory - inform the user 00665 return(NULL); 00666 } 00667 00668 INT32 ListEnd = 1; // Initialise array to just the Parent 00669 InheritanceArray[0] = Parent; 00670 InheritanceArray[1] = NULL; 00671 00672 // Do all the Named colours 00673 IndexedColour *Ptr = (IndexedColour *) GetHead(); 00674 while (Ptr != NULL) 00675 { 00676 if (Ptr != Parent && Ptr->IsADescendantOf(Parent)) 00677 { 00678 // Is a descendant: add this item to the end of the list 00679 if (ListEnd >= ColourArraySize - 1) 00680 { 00681 // We've filled the array - must increase the size 00682 ColourArraySize += 32; 00683 IndexedColour **TempArray = (IndexedColour **) CCRealloc(InheritanceArray, 00684 ColourArraySize * sizeof(IndexedColour *)); 00685 if (TempArray == NULL) 00686 { 00687 InvalidateInheritanceCache(); // Free our existing memory claim 00688 InformError(); 00689 return(NULL); 00690 } 00691 00692 InheritanceArray = TempArray; // It worked- set our ptr to the new block 00693 } 00694 00695 InheritanceArray[ListEnd++] = Ptr; // Add the item and a new NULL terminator 00696 InheritanceArray[ListEnd] = 0; // to the end of the list 00697 } 00698 00699 Ptr = (IndexedColour *) GetNext(Ptr); 00700 } 00701 00702 00703 // And likewise with all unnamed colours 00704 IndexedColour *Next; 00705 Ptr = (IndexedColour *) UnnamedColours.GetHead(); 00706 while (Ptr != NULL) 00707 { 00708 // Allow for deleting this colour from underneath ourselves 00709 Next = (IndexedColour *) UnnamedColours.GetNext(Ptr); 00710 00711 if (Ptr->IsInUse()) 00712 { 00713 if (Ptr->IsADescendantOf(Parent)) 00714 { 00715 // Is a descendant: add this item to the end of the list 00716 if (ListEnd >= ColourArraySize - 1) 00717 { 00718 // We've filled the array - must increase the size 00719 ColourArraySize += 32; 00720 IndexedColour **TempArray = (IndexedColour **) CCRealloc(InheritanceArray, 00721 ColourArraySize * sizeof(IndexedColour *)); 00722 if (TempArray == NULL) 00723 { 00724 InvalidateInheritanceCache(); // Free our existing memory claim 00725 InformError(); 00726 return(NULL); 00727 } 00728 00729 InheritanceArray = TempArray; // It worked- set our ptr to the new block 00730 } 00731 00732 InheritanceArray[ListEnd++] = Ptr; // Add the item and a new NULL terminator 00733 InheritanceArray[ListEnd] = 0; // to the end of the list 00734 } 00735 } 00736 else 00737 { 00738 // We've found an unnamed IndexedColour which is not in use, so we can vape it 00739 TRACEUSER( "Jason", _T("CIA: Deleting unnamed colour which is not in use [%p]\n"), Ptr ); 00740 // UnnamedColours.RemoveItem(Ptr); 00741 // delete Ptr; 00742 } 00743 00744 Ptr = Next; 00745 } 00746 00747 00748 ArrayParent = Parent; 00749 } 00750 00751 TRACEUSER( "Jason", _T("\n")); 00752 00753 return(InheritanceArray); 00754 }
|
|
Deletes the list, calling the destructors of all ListItems.
We thus vape all colour linking before deleting the colours. We don't need to be particularly gentle about this because we are deleting them all anyway.
Reimplemented from List. Definition at line 458 of file collist.cpp. 00459 { 00460 // Vape all colour linkages in the named colour list 00461 IndexedColour *Ptr = (IndexedColour *) GetHead(); 00462 while (Ptr != NULL) 00463 { 00464 Ptr->SetLinkedParent(NULL, COLOURTYPE_NORMAL); 00465 Ptr = (IndexedColour *) GetNext(Ptr); 00466 } 00467 00468 // And vape all colour linkages in the UNnamed colour list 00469 Ptr = (IndexedColour *) UnnamedColours.GetHead(); 00470 while (Ptr != NULL) 00471 { 00472 Ptr->SetLinkedParent(NULL, COLOURTYPE_NORMAL); 00473 Ptr = (IndexedColour *) UnnamedColours.GetNext(Ptr); 00474 } 00475 00476 // Delete all the unnamed colours now too, just to be tidy 00477 UnnamedColours.DeleteAll(); 00478 00479 // Finally, call the base class to do the actual deletions 00480 List::DeleteAll(); 00481 }
|
|
The same as the conventional List FindItem() function, except that it treats 'deleted' colours as if they are not in the list.
Definition at line 534 of file collist.cpp. 00535 { 00536 IndexedColour *Ptr = (IndexedColour *) GetHead(); 00537 00538 while (Ptr != NULL) 00539 { 00540 if (!Ptr->IsDeleted() && --Index < 0) 00541 return(Ptr); 00542 00543 Ptr = (IndexedColour *) GetNext(Ptr); 00544 } 00545 00546 return(NULL); 00547 }
|
|
Scans the entire ColourList to determine if the suggested name is unique within this document. If it is not, the name is altered (currently by truncating to 50 characters and appending a decimal number) to provide a unique name, which is returned in the supplied string.
Notes: Name matching is done using StringBase::IsIdentical, so see that method to determine the rules by which strings are matched If the colour is unnamed (pPrefix == NULL, *pPrefix is a NULL string, or the name is "Unnamed" (_R(IDS_UNNAMEDCOLOUR)), then the code is optimised to provide a new name for it extra fast.
Definition at line 1005 of file collist.cpp. 01006 { 01007 if (pResult == NULL) 01008 { 01009 ERROR3("ColourList::GenerateUniqueColourName: pResult is NULL!"); 01010 return(FALSE); 01011 } 01012 01013 if (pPrefix != NULL && !NamedColourExists(pPrefix)) 01014 { 01015 // Either the List is empty, or this name is unique, so return it (ensuring < 64 chars) 01016 pPrefix->Left(pResult, 63); 01017 return(FALSE); 01018 } 01019 01020 // Copy the prefix into this string. 01021 String_64 NewName; 01022 BOOL Unnamed = FALSE; // Remember if it is 'unnamed' 01023 01024 if (pPrefix != NULL) 01025 pPrefix->Left(&NewName, 50); // Copy into NewName, truncating 01026 01027 String_64 NoName(_R(IDS_UNNAMEDCOLOUR)); 01028 if ((pPrefix == NULL) || (NewName.Length() == 0)) // Has no name, so call it "Unnamed" 01029 { 01030 Unnamed = TRUE; 01031 NewName = NoName; 01032 } 01033 else if (NewName.IsIdentical(NoName)) // Is called 'Unnamed', so remember that 01034 { 01035 Unnamed = TRUE; 01036 } 01037 01038 INT32 PrefixLen = NewName.Length(); 01039 if (PrefixLen > 50) 01040 { 01041 // Limit prefix length to 50 chars - this means we can add numbers up to 01042 // 10-odd digits long in order to make it unique - should be enough! 01043 PrefixLen = 50; 01044 } 01045 01046 01047 TCHAR *pPrefixEnd = (TCHAR *) NewName; 01048 pPrefixEnd += PrefixLen; 01049 01050 // Is this name ok? 01051 if (!NamedColourExists(NewName)) 01052 { 01053 (*pResult) = NewName; // Yes - return it. 01054 return(TRUE); 01055 } 01056 01057 // Start adding numbers to make it unique 01058 INT32 i = (Unnamed) ? LastUnnamedColour : 2; 01059 01060 while (TRUE) 01061 { 01062 // If this doesn't terminate [Tim] will eat [his] Archimedes! 01063 camSnprintf( pPrefixEnd, 64, _T(" %ld"), i++ ); 01064 01065 // Is this name ok? 01066 if (!NamedColourExists(NewName)) 01067 { 01068 (*pResult) = NewName; // Yes - return it 01069 01070 if (Unnamed) // Update unnamed colour generation number 01071 LastUnnamedColour = i; 01072 01073 return(TRUE); 01074 } 01075 } 01076 01077 *pResult = NewName; // Ensure stable return, though this should never happen 01078 return(TRUE); 01079 }
|
|
To find the parent document of this colour list.
Definition at line 235 of file collist.h. 00236 { 00237 ERROR3IF(ParentDoc == NULL, "Uninitialised ColourList detected!"); 00238 return(ParentDoc); 00239 }
|
|
Count the number of non-'deleted' items in a ColourList.
Definition at line 500 of file collist.cpp. 00501 { 00502 ListItem *Ptr = GetHead(); 00503 UINT32 Count = 0; 00504 00505 while (Ptr != NULL) 00506 { 00507 if ( !((IndexedColour *)Ptr)->IsDeleted() ) 00508 Count++; 00509 00510 Ptr = GetNext(Ptr); 00511 } 00512 00513 return(Count); 00514 }
|
|
The same as the conventional List GetHead() function, except that it treats 'deleted' colours as if they are not in the list.
Definition at line 566 of file collist.cpp. 00567 { 00568 IndexedColour *Ptr = (IndexedColour *) GetHead(); 00569 00570 while (Ptr != NULL && Ptr->IsDeleted()) 00571 Ptr = (IndexedColour *) GetNext(Ptr); 00572 00573 return(Ptr); 00574 }
|
|
The same as the conventional List GetNext() function, except that it treats 'deleted' colours as if they are not in the list.
Definition at line 593 of file collist.cpp. 00594 { 00595 ERROR2IF(ThisItem == NULL, NULL, 00596 "ColourList::GetUndeletedNext - NULL parameter is illegal"); 00597 00598 IndexedColour *Ptr = (IndexedColour *) GetNext(ThisItem); 00599 00600 while (Ptr != NULL && Ptr->IsDeleted()) 00601 Ptr = (IndexedColour *) GetNext(Ptr); 00602 00603 return(Ptr); 00604 }
|
|
To find the unnamed colours for this document.
Definition at line 254 of file collist.h. 00255 { 00256 return(&UnnamedColours); 00257 }
|
|
ColourList initialiser. MUST be called after constructing a ColourList in order to correctly initialise it. Note that if ParentDocument is not set to a useful value, some operations on colour lists (eg. the colour editor) will fail.
Definition at line 187 of file collist.cpp. 00188 { 00189 ERROR3IF(ParentDocument == NULL, "NULL ParentDoc in ColourList::Init()"); 00190 ParentDoc = ParentDocument; 00191 }
|
|
Inserts the 'newItem' ListItem after 'here' ListItem in the list.
Reimplemented from List. Definition at line 416 of file collist.cpp. 00417 { 00418 ERROR3IF(!IS_A(item, IndexedColour), "You can only insert IndexedColours into ColourLists!"); 00419 00420 IndexedColour *NewColour = (IndexedColour *) item; 00421 00422 // Ensure the colour has a name which is unique within this colour list 00423 ERROR3IF(!NewColour->IsNamed(), "You can't Insert an unnamed colour before a named one!"); 00424 00425 // It's a named colour, so make sure its name is unique 00426 String_64 NewName; 00427 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00428 NewColour->SetName(NewName); 00429 00430 // And add it to the tail of the list - using the base class function, not our overrides! 00431 return(List::InsertAfter(here, item)); 00432 }
|
|
Inserts a ListItem in the list position after the one that is passed in. Notes: To find 'here', the list must be scanned, so this is much slower on average than the other flavour of InsertAfter.
Reimplemented from List. Definition at line 398 of file collist.cpp. 00399 { 00400 ERROR3IF(!IS_A(item, IndexedColour), "You can only insert IndexedColours into ColourLists!"); 00401 00402 IndexedColour *NewColour = (IndexedColour *) item; 00403 00404 // Ensure the colour has a name which is unique within this colour list 00405 ERROR3IF(!NewColour->IsNamed(), "You can't Insert an unnamed colour before a named one!"); 00406 00407 // It's a named colour, so make sure its name is unique 00408 String_64 NewName; 00409 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00410 NewColour->SetName(NewName); 00411 00412 // And add it to the tail of the list - using the base class function, not our overrides! 00413 return(List::InsertAfter(here, item)); 00414 }
|
|
Inserts the 'newItem' ListItem before 'here' ListItem in the list.
Reimplemented from List. Definition at line 380 of file collist.cpp. 00381 { 00382 ERROR3IF(!IS_A(item, IndexedColour), "You can only insert IndexedColours into ColourLists!"); 00383 00384 IndexedColour *NewColour = (IndexedColour *) item; 00385 00386 // Ensure the colour has a name which is unique within this colour list 00387 ERROR3IF(!NewColour->IsNamed(), "You can't Insert an unnamed colour before a named one!"); 00388 00389 // It's a named colour, so make sure its name is unique 00390 String_64 NewName; 00391 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00392 NewColour->SetName(NewName); 00393 00394 // And add it to the tail of the list - using the base class function, not our overrides! 00395 return(List::InsertBefore(here, item)); 00396 }
|
|
Inserts a NAMED IndexedColour at a particular list position (See List base class for a further description of the actual insertion process).
Note: IMPORTANT: NOTE that at present, these are NOT VIRTUAL, so you MUST call them using a ColourList pointer rather than a generic List pointer!
Reimplemented from List. Definition at line 362 of file collist.cpp. 00363 { 00364 ERROR3IF(!IS_A(item, IndexedColour), "You can only insert IndexedColours into ColourLists!"); 00365 00366 IndexedColour *NewColour = (IndexedColour *) item; 00367 00368 // Ensure the colour has a name which is unique within this colour list 00369 ERROR3IF(!NewColour->IsNamed(), "You can't Insert an unnamed colour before a named one!"); 00370 00371 // It's a named colour, so make sure its name is unique 00372 String_64 NewName; 00373 if (GenerateUniqueColourName(NewColour->GetName(), &NewName)) 00374 NewColour->SetName(NewName); 00375 00376 // And add it to the tail of the list - using the base class function, not our overrides! 00377 return(List::InsertBefore(here, item)); 00378 }
|
|
Deallocates any memory used for the array of IndexedColours compiled by ColourList::CompileInheritanceArray. The next request for such an array will be regenerated from the ColourList, rather than from cache.
Definition at line 211 of file collist.cpp. 00212 { 00213 if (InheritanceArray != NULL) 00214 CCFree(InheritanceArray); 00215 00216 InheritanceArray = NULL; 00217 ArrayParent = NULL; 00218 }
|
|
Determine if a colour is used in the parent document. This is similar to IndexedColour::IsInUse(), but it also traverses the linking hierarchy to see if a colour is in use indirectly (e.g. A parent of a colour that is in use is needed for the document even if it is not used directly in document.
Definition at line 859 of file collist.cpp. 00860 { 00861 ERROR3IF(TheColour == NULL, "Illegal NULL param"); 00862 00863 // First, is it directly in-use? 00864 if (TheColour->IsInUse(IgnoreColourGallery)) 00865 return(TRUE); 00866 00867 // Is it a parent of other colours? If not, then it is not in use 00868 if (!TheColour->IsNamed() || !TheColour->HasLinkedChildren()) 00869 return(FALSE); 00870 00871 // It has descendants, so scan the inheritance tree to determine if any of them are in use 00872 // Scan through the named colours (NOTE: We also scan 'deleted' colours, as a parent colour 00873 // may be indirectly in use in the undo record) 00874 IndexedColour *Ptr = (IndexedColour *) GetHead(); 00875 while (Ptr != NULL) // For all colours in the list... 00876 { 00877 if (Ptr != TheColour && Ptr->IsADescendantOf(TheColour)) // If this one is a descendant... 00878 { 00879 if (Ptr->IsInUse(IgnoreColourGallery)) // and it's in use, then we are 00880 return(TRUE); // in use, and can return now. 00881 } 00882 00883 Ptr = (IndexedColour *) GetNext(Ptr); 00884 } 00885 00886 // And scan through the unnamed colours as well 00887 Ptr = (IndexedColour *) UnnamedColours.GetHead(); 00888 while (Ptr != NULL) // For all colours in the list... 00889 { 00890 if (Ptr != TheColour && Ptr->IsADescendantOf(TheColour)) // If this one is a descendant... 00891 { 00892 if (Ptr->IsInUse()) // and it's in use, then we are 00893 return(TRUE); // in use, and can return now. 00894 } 00895 00896 Ptr = (IndexedColour *) UnnamedColours.GetNext(Ptr); 00897 } 00898 00899 // OK, we're obviously not in use then 00900 return(FALSE); 00901 }
|
|
Determine if a colour name is already in use by any colours stored in this colour list.
Definition at line 958 of file collist.cpp. 00959 { 00960 return(NamedColourExists((const TCHAR *)(*pName))); 00961 }
|
|
Determine if a colour name is already in use by any colours stored in this colour list.
Definition at line 920 of file collist.cpp. 00921 { 00922 IndexedColour *pItem = (IndexedColour *) GetHead(); 00923 00924 while (pItem != NULL) 00925 { 00926 if (!pItem->IsDeleted() && pItem->IsNamed() && 00927 (pItem->GetName()->IsIdentical(pName)) ) 00928 { 00929 // The name is the same - it's a match 00930 return(TRUE); 00931 } 00932 00933 // Try the next colour 00934 pItem = (IndexedColour *) GetNext(pItem); 00935 } 00936 00937 // No match for this name 00938 return(FALSE); 00939 }
|
|
Scans the entire ColourList for any colours which reference the given IndexedColour. All these colours are converted into standalone representation of their former definition, so that all child-links of this colour are removed. It is then safe to delete the colour.
NOTE that this does NOT remove the colour from the ColourList It also does NOT delete the colour.
Definition at line 784 of file collist.cpp. 00785 { 00786 // Search through the named colours 00787 IndexedColour *Ptr = (IndexedColour *) GetHead(); 00788 00789 while (Ptr != NULL) // For all colours in the list... 00790 { 00791 if (Ptr->FindLastLinkedParent() == DeadColour) // If they reference DeadColour... 00792 { 00793 IndexedColourType TheType = COLOURTYPE_NORMAL; 00794 00795 if (Ptr->GetType() == COLOURTYPE_SPOT) 00796 TheType = COLOURTYPE_SPOT; 00797 00798 Ptr->SetLinkedParent(NULL, TheType); // Convert to unlinked (normal/spot) colour 00799 } 00800 00801 Ptr = (IndexedColour *) GetNext(Ptr); 00802 } 00803 00804 00805 // And drag through the unnamed colours as well 00806 Ptr = (IndexedColour *) UnnamedColours.GetHead(); 00807 IndexedColour *Next; 00808 00809 while (Ptr != NULL) // For all colours in the list... 00810 { 00811 Next = (IndexedColour *) UnnamedColours.GetNext(Ptr); 00812 if (Ptr->FindLastLinkedParent() == DeadColour) // If they reference DeadColour... 00813 { 00814 IndexedColourType TheType = COLOURTYPE_NORMAL; 00815 00816 if (Ptr->GetType() == COLOURTYPE_SPOT) 00817 TheType = COLOURTYPE_SPOT; 00818 00819 Ptr->SetLinkedParent(NULL, TheType); // Convert to unlinked (normal/spot) colour 00820 } 00821 // This could be dangerous - what if the deleted colour is in the inheritance array? 00822 // if (!Ptr->IsInUse()) 00823 // { 00824 // // We've found an unnamed colour which is not in use - we can vape it 00825 //TRACEUSER( "Jason", _T("RLTC: Deleting unnamed colour which is not in use [%x]\n"), (INT32)Ptr); 00826 // UnnamedColours.RemoveItem(Ptr); 00827 // delete Ptr; 00828 // } 00829 00830 Ptr = Next; 00831 } 00832 }
|
|
|
|
|
|
|
|
|
|
|