ColourImportContext Class Reference

Provides a colour context to use when importing colours, which allows us to easily import arbitrarily nested linked colours. More...

#include <impcol.h>

Inheritance diagram for ColourImportContext:

List CCObject SimpleCCObject List of all members.

Public Member Functions

 ColourImportContext ()
 ~ColourImportContext ()
BOOL Init ()
 Declares a preference that allows you to clear memory in delete().
void SetContext (IndexedColour *)
IndexedColourGetContext ()
BOOL SaveContext ()
BOOL RestoreContext ()
BOOL RestoreContextTo (UINT32)

Private Member Functions

 CC_DECLARE_MEMDUMP (ColourImportContext)

Detailed Description

Provides a colour context to use when importing colours, which allows us to easily import arbitrarily nested linked colours.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
01/12/94
See also:
ContextItem; ImportedColours

Definition at line 259 of file impcol.h.


Constructor & Destructor Documentation

ColourImportContext::ColourImportContext  ) 
 

Definition at line 184 of file impcol.cpp.

00185 {
00186 }

ColourImportContext::~ColourImportContext  ) 
 

Definition at line 188 of file impcol.cpp.

00189 {
00190     // Just lose all the items in our list.
00191     DeleteAll();
00192 }


Member Function Documentation

ColourImportContext::CC_DECLARE_MEMDUMP ColourImportContext   )  [private]
 

IndexedColour * ColourImportContext::GetContext  ) 
 

Definition at line 219 of file impcol.cpp.

00220 {
00221     // Get the current context item (always the last)
00222     ContextItem *pItem = (ContextItem *) GetTail();
00223 
00224     // Return its colour pointer
00225     return pItem->pCol;
00226 }

BOOL ColourImportContext::Init void   ) 
 

Declares a preference that allows you to clear memory in delete().

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/94
Returns:
TRUE if it worked OK, FALSE if not

Reimplemented from SimpleCCObject.

Definition at line 194 of file impcol.cpp.

00195 {
00196     // Add an initial context item
00197     ContextItem *pItem = new ContextItem(NULL);
00198     if (pItem == NULL)
00199         return FALSE;
00200 
00201     // Add to the list
00202     AddTail(pItem);
00203 
00204     // All ok
00205     return TRUE;
00206 }

BOOL ColourImportContext::RestoreContext  ) 
 

Definition at line 246 of file impcol.cpp.

00247 {
00248     // Make sure we can do this - must always have at least one node
00249     if (GetCount() <= 1)
00250     {
00251         ERROR3("Bad call to ColourImportContext::RestoreContext()");
00252         return FALSE;
00253     }
00254 
00255     // Remove and delete the last context item
00256     delete RemoveTail();
00257 
00258     // All ok
00259     return TRUE;
00260 }

BOOL ColourImportContext::RestoreContextTo UINT32   ) 
 

Definition at line 262 of file impcol.cpp.

00263 {
00264     // How many should we delete?
00265     INT32 NumToDelete = (INT32) (GetCount() - NewLevel) - 1;
00266 
00267     // Make sure this is a legal request.
00268     if (NumToDelete < 0)
00269         // No - return failure
00270         return FALSE;
00271 
00272     // Ok - delete this many items
00273     while (NumToDelete > 0)
00274     {
00275         if (!RestoreContext())
00276         {
00277             ERROR3("Bad call to ColourImportContext::RestoreContextTo()");
00278             return FALSE;
00279         }
00280 
00281         NumToDelete--;
00282     }
00283 
00284     // All ok
00285     return TRUE;
00286 }

BOOL ColourImportContext::SaveContext  ) 
 

Definition at line 228 of file impcol.cpp.

00229 {
00230     // Get a pointer to the current context node
00231     ContextItem *pCurrentItem = (ContextItem *) GetTail();
00232 
00233     // Add a new context node to the end of the list, and give it the same
00234     // context as the current context node.
00235     ContextItem *pItem = new ContextItem(pCurrentItem->pCol);
00236     if (pItem == NULL)
00237         return FALSE;
00238 
00239     // Add to the list
00240     AddTail(pItem);
00241 
00242     // All ok
00243     return TRUE;
00244 }

void ColourImportContext::SetContext IndexedColour  ) 
 

Definition at line 209 of file impcol.cpp.

00210 {
00211     // Get the current context item (always the last)
00212     ContextItem *pItem = (ContextItem *) GetTail();
00213 
00214     // Update its colour pointer
00215     pItem->pCol = pCol;
00216 }


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