BitmapList Class Reference

A list of Kernel Bitmaps used by a document. More...

#include <bmpcomp.h>

Inheritance diagram for BitmapList:

List CCObject SimpleCCObject List of all members.

Public Member Functions

 BitmapList ()
 ~BitmapList ()
 BitmapList destructor.
void Init (BaseDocument *ParentDocument)
 BitmapList initialiser. MUST be called after constructing a BitmapList in order to correctly initialise it. Note that if ParentDocument is not set to a useful value, some operations on Bitmap lists will fail.
BOOL AddItem (KernelBitmap *Item)
 Adds an item to the tail of the Bitmaplist, and incremeants it's usage count. (Unless it's already in the list, in which case it's usage count is just bumped up).
BOOL RemoveItem (KernelBitmap *Item)
 Removes an item from the list.
BOOL MoveAfter (KernelBitmap *InsertPoint, KernelBitmap *ItemToMove)
 Re-arranges the bitmaps in the list.
BOOL MoveBefore (KernelBitmap *InsertPoint, KernelBitmap *ItemToMove)
 Re-arranges the bitmaps in the list.
BaseDocumentGetParentDocument (void)
 To find the parent document of this Bitmap list.
KernelBitmapFindDuplicateBitmap (OILBitmap *pBitmap)
 Looks to see if an identical bitmap is already in the bitmap list.
KernelBitmapFindDefaultBitmap ()
 Finds the default bitmap in this bitmap list.

Private Attributes

BaseDocumentParentDoc

Friends

class GlobalBitmapList

Detailed Description

A list of Kernel Bitmaps used by a document.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
See also:
-

Definition at line 157 of file bmpcomp.h.


Constructor & Destructor Documentation

BitmapList::BitmapList  ) 
 

BitmapList::~BitmapList  ) 
 

BitmapList destructor.

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

Definition at line 182 of file bmpcomp.cpp.

00183 {
00184     ListItem* pItem = GetHead();
00185     ListItem* pNextItem;
00186 
00187     while (pItem)
00188     {
00189         pNextItem = GetNext(pItem);
00190 
00191         KernelBitmap* pBmp = (KernelBitmap*)pItem;
00192 
00193         ERROR3IF(pBmp->GetParentBitmapList() != this, "Bad ParentList ptr found in bitmap (during BitmapList destructor)");
00194         
00195         // if this bitmap is used by a brush we don't want to delete it here.
00196         if (!pBmp->IsUsedByBrush())
00197             delete pBmp;    // This should remove it from the list first
00198         else
00199         {
00200             pBmp->Detach();
00201             RemoveItem(pBmp);
00202         }
00203 
00204         pItem = pNextItem;
00205     }
00206 
00207     // Tidy up the global bitmap list
00208     Camelot.GetGlobalBitmapList()->DeleteAllUnusedBitmaps();
00209 }


Member Function Documentation

BOOL BitmapList::AddItem KernelBitmap Item  ) 
 

Adds an item to the tail of the Bitmaplist, and incremeants it's usage count. (Unless it's already in the list, in which case it's usage count is just bumped up).

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Returns:
TRUE

Definition at line 248 of file bmpcomp.cpp.

00249 {
00250     ERROR3IF(Item == NULL, "Trying to add NULL item to Bitmap List");
00251     
00252     if (Item == NULL)
00253         return FALSE;
00254 
00255     // Is this Bitmap already in the list ?
00256     LISTPOS pos = FindPosition((ListItem*)Item);
00257 
00258     if (pos == NOT_IN_LIST || pos == EMPTY_LIST)
00259     {
00260         // It's not in the list yet, so add it on the end
00261         AddTail((ListItem*)Item);
00262 
00263         if (ParentDoc != NULL)
00264         {
00265             BROADCAST_TO_ALL(BitmapListChangedMsg(this)); 
00266         }
00267 
00268         return TRUE;
00269     }
00270     else
00271     {
00272         // It's already in the list, so just return
00273         // (It's usage count has already been incremeanted)
00274         return FALSE;
00275     }
00276 }

KernelBitmap * BitmapList::FindDefaultBitmap  ) 
 

Finds the default bitmap in this bitmap list.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/8/96

Definition at line 424 of file bmpcomp.cpp.

00425 {
00426     ListItem* pItem = GetHead();
00427     while (pItem != NULL)
00428     {
00429         KernelBitmap* pBmp = (KernelBitmap*)pItem;
00430 
00431         if (pBmp->ActualBitmap &&
00432             pBmp->ActualBitmap == OILBitmap::Default)
00433         {
00434             return pBmp;
00435         }
00436 
00437         pItem = GetNext(pItem);
00438     }
00439 
00440     return NULL;
00441 }

KernelBitmap * BitmapList::FindDuplicateBitmap OILBitmap pOILBitmap  ) 
 

Looks to see if an identical bitmap is already in the bitmap list.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/8/96

Definition at line 394 of file bmpcomp.cpp.

00395 {
00396     ListItem* pItem = GetHead();
00397     while (pItem != NULL)
00398     {
00399         KernelBitmap* pBmp = (KernelBitmap*)pItem;
00400 
00401         if (pBmp->ActualBitmap &&
00402             pBmp->ActualBitmap != pOILBitmap &&
00403             *pBmp->ActualBitmap == *pOILBitmap)
00404         {
00405             return pBmp;
00406         }
00407 
00408         pItem = GetNext(pItem);
00409     }
00410 
00411     return NULL;
00412 }

BaseDocument * BitmapList::GetParentDocument void   ) 
 

To find the parent document of this Bitmap list.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Returns:
The document in which this Bitmap list resides

Definition at line 378 of file bmpcomp.cpp.

00379 {
00380     ERROR3IF(ParentDoc == NULL, "Uninitialised BitmapList detected!");
00381     return(ParentDoc);
00382 }

void BitmapList::Init BaseDocument ParentDocument  ) 
 

BitmapList initialiser. MUST be called after constructing a BitmapList in order to correctly initialise it. Note that if ParentDocument is not set to a useful value, some operations on Bitmap lists will fail.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
ParentDocument - the parent document of this Bitmap list [INPUTS]

Definition at line 224 of file bmpcomp.cpp.

00225 {
00226     ERROR3IF(ParentDocument == NULL, "NULL ParentDoc in BitmapList::Init!\n");
00227 
00228     // Ensure the default bitmap is always in the list.
00229     KernelBitmap* Default = new KernelBitmap();
00230     Default->Attach(this);
00231 
00232     ParentDoc = ParentDocument;
00233 }

BOOL BitmapList::MoveAfter KernelBitmap InsertPoint,
KernelBitmap ItemToMove
 

Re-arranges the bitmaps in the list.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Returns:
TRUE

Definition at line 354 of file bmpcomp.cpp.

00355 {
00356     List::RemoveItem((ListItem*)ItemToMove);
00357     List::InsertAfter((ListItem*)InsertPoint, (ListItem*)ItemToMove);
00358 
00359     if (ParentDoc != NULL)
00360     {
00361         BROADCAST_TO_ALL(BitmapListChangedMsg(this)); 
00362     }
00363 
00364     return TRUE;
00365 }

BOOL BitmapList::MoveBefore KernelBitmap InsertPoint,
KernelBitmap ItemToMove
 

Re-arranges the bitmaps in the list.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Returns:
TRUE

Definition at line 330 of file bmpcomp.cpp.

00331 {
00332     List::RemoveItem((ListItem*)ItemToMove);
00333     List::InsertBefore((ListItem*)InsertPoint, (ListItem*)ItemToMove);
00334 
00335     if (ParentDoc != NULL)
00336     {
00337         BROADCAST_TO_ALL(BitmapListChangedMsg(this)); 
00338     }
00339 
00340     return TRUE;
00341 }

BOOL BitmapList::RemoveItem KernelBitmap Item  ) 
 

Removes an item from the list.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Returns:
TRUE

Definition at line 289 of file bmpcomp.cpp.

00290 {
00291     ERROR3IF(Item == NULL, "Trying to remove NULL item from Bitmap List");
00292     
00293     if (Item == NULL)
00294         return FALSE;
00295 
00296     // Is this Bitmap in the list ?
00297     LISTPOS pos = FindPosition((ListItem*)Item);
00298 
00299     if (pos != NOT_IN_LIST || pos == EMPTY_LIST)
00300     {
00301         // It's not in the list yet, so add it on the end
00302         List::RemoveItem((ListItem*)Item);
00303         Item->m_pParentList = NULL;
00304 
00305         if (ParentDoc != NULL)
00306         {
00307             BROADCAST_TO_ALL(BitmapListChangedMsg(this)); 
00308         }
00309 
00310         return TRUE;
00311     }
00312     else
00313     {
00314         // It's not in the list, so just return
00315         return FALSE;
00316     }
00317 }


Friends And Related Function Documentation

friend class GlobalBitmapList [friend]
 

Definition at line 161 of file bmpcomp.h.


Member Data Documentation

BaseDocument* BitmapList::ParentDoc [private]
 

Definition at line 185 of file bmpcomp.h.


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