OpDeleteBitmap Class Reference

Removes all references to a bitmap, and deletes it from memory. More...

#include <bmplist.h>

Inheritance diagram for OpDeleteBitmap:

Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

void DoDelete (OILBitmap *)
 Frees the memory used by a bitmap.

Static Public Member Functions

static BOOL Init ()
 Get a pointer to the greyscale bitmap listOpDeleteBitmap initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the OpDeleteBitmap's state.

Protected Member Functions

void ForceRedrawOfNode (Document *, Node *, ObjChangeParam *)
 


Private Member Functions

 CC_DECLARE_DYNCREATE (OpDeleteBitmap)

Detailed Description

Removes all references to a bitmap, and deletes it from memory.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
See also:
-

Definition at line 286 of file bmplist.h.


Member Function Documentation

OpDeleteBitmap::CC_DECLARE_DYNCREATE OpDeleteBitmap   )  [private]
 

void OpDeleteBitmap::DoDelete OILBitmap pBmpToDelete  ) 
 

Frees the memory used by a bitmap.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
Parameters:
pOpParam,: Param1 contains a pointer to the OILBitmap to delete. [INPUTS]
Returns:
Errors: -
See also:
-

Definition at line 1274 of file bmplist.cpp.

01275 {
01276     // Declared up 'ere, 'cus of the goto thingy
01277     Document* Doc;
01278     OILBitmap* poBmp = NULL;
01279 
01280     // Set the busy cursor . . .
01281     String_64 StatusText =  String_64(_R(IDS_K_BMPLIST_DELBMPOPEN));
01282     StatusText +=   pBmpToDelete->GetName();
01283     StatusText +=   String_64(_R(IDS_K_BMPLIST_DELBMPCLOSE));
01284 
01285     BeginSlowJob(-1, FALSE, &StatusText);
01286 
01287     // Remember the current document
01288     Document* pCurrent  = Document::GetCurrent();
01289 
01290     ObjChangeFlags cFlags;
01291     cFlags.TransformNode = TRUE;    // The node is going to be changed to point at a
01292                                     // different bitmap, which is a Bit like transforming
01293                                     // it I suppose ?
01294 
01295     cFlags.Attribute = TRUE;        // Needed to make Blends re-calc themselves
01296 
01297     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,NULL);
01298 
01299     // Don't do anything if the bitmap is NULL, or if it's the default bitmap
01300     if (pBmpToDelete == NULL || pBmpToDelete == OILBitmap::Default)
01301         goto EndOperation;
01302 
01303     ERROR3IF(pBmpToDelete->HasBeenDeleted(), "This bitmap has been deleted already !");
01304 
01305     // -------------------------------------------------------------
01306     // If this bitmap is an XPE master bitmap then we must unlink
01307     poBmp = (OILBitmap*) GetApplication()->GetGlobalBitmapList()->GetHead();
01308     while (poBmp)
01309     {
01310         if (poBmp->m_pMasterBitmap == pBmpToDelete)
01311         {
01312             poBmp->RebuildXPEBitmap();      // Ensure that we have a generated bitmap
01313             poBmp->DestroyXPEInfo();        // Unlink this bitmap from the master being deleted
01314         }
01315 
01316         poBmp = (OILBitmap*) GetApplication()->GetGlobalBitmapList()->GetNext(poBmp);
01317     }
01318 
01319     // -------------------------------------------------------------
01320     // Go though all the documents
01321     Doc = (Document*)GetApplication()->Documents.GetHead();
01322     while (Doc != NULL)
01323     {
01324         // Set the document to be current, because the bitmap system needs this
01325         // so it knows which bitmap list to look at.
01326         Doc->SetCurrent();
01327 
01328         // First we look at the doc component bitmap list to see if the bitmap
01329         // we deleted is in there somewhere
01330         BOOL BitmapIsInList = FALSE;
01331 
01332         BitmapList* pBitmaps = Doc->GetBitmapList();
01333         if (pBitmaps != NULL)
01334         {
01335             KernelBitmap* pBitmap = (KernelBitmap*)pBitmaps->GetHead();
01336             while (pBitmap)
01337             {
01338                 if (pBitmap->GetActualBitmap() == pBmpToDelete)
01339                 {
01340                     // We've found the bitmap, so flag thaat we need to 
01341                     // scan the tree
01342                     BitmapIsInList = TRUE;
01343                     break;
01344                 }
01345 
01346                 pBitmap = (KernelBitmap*)pBitmaps->GetNext(pBitmap);
01347             }
01348         }
01349 
01350         if (BitmapIsInList)
01351         {
01352             // If the bitmap was found in the list somewhere, then we need to scan
01353             // though the document tree, and make sure we redraw any nodes that
01354             // use the bitmap
01355 
01356             BOOL DocModified = FALSE;
01357 
01358             // Scan the document's tree for bitmap references
01359             Node* pNode = Node::DocFindFirstDepthFirst(Doc);
01360             while (pNode != NULL)
01361             {
01362                 // Ignore hidden nodes
01363                 if (!pNode->IsNodeHidden())
01364                 {
01365                     INT32 Count = 0;
01366 
01367                     // Does this node have any bitmaps in it ?
01368                     KernelBitmap* pBitmap = pNode->EnumerateBitmaps(Count++);
01369 
01370                     while (pBitmap != NULL)
01371                     {
01372                         // Found a bitmap reference, but ... is it the one that we deleted ?
01373                         if (pBitmap->GetActualBitmap() == pBmpToDelete)
01374                         {
01375                             // pBmpToDelete is being deleted, so we MUST reset any bitmapref
01376                             // that references it to the default (otherwise we still reference the
01377                             // deleted bitmap) ....
01378                             if (IS_A (pNode, NodeBitmap))
01379                             {
01380                                 // i'm only willing to do this for NodeBitmaps!  Not sure about
01381                                 // any other type of node that overides the EnumerateBitmaps function
01382                                 // (they look scary).
01383                                 NodeBitmap* pBitmap = (NodeBitmap*) pNode;
01384                                 pBitmap->GetBitmapRef ()->SetBitmap (pBitmaps->FindDefaultBitmap());
01385                             }
01386                             
01387                             // Make sure the node is redrawn
01388                             ForceRedrawOfNode(Doc, pNode, &ObjChange);
01389                             DocModified = TRUE;
01390                         }
01391                         
01392                         pBitmap = pNode->EnumerateBitmaps(Count++);             
01393                     }
01394                 }
01395 
01396                 // Move onto the next node in the tree
01397                 pNode = pNode->DocFindNextDepthFirst(); 
01398             }
01399 
01400             if (DocModified)
01401             {
01402                 // Flag that the document has changed
01403                 Doc->SetModified(TRUE);
01404             }
01405         }
01406 
01407         // Move onto the next document
01408         Doc = (Document*)GetApplication()->Documents.GetNext(Doc);
01409     }
01410 
01411     // Now delete the bitmap data
01412     pBmpToDelete->DeleteData();
01413 
01414     // and make sure all the bitmap list are updated ...
01415     // (this needs to be done after the bitmap data is deleted)
01416     Doc = (Document*)GetApplication()->Documents.GetHead();
01417     while (Doc != NULL)
01418     {
01419         BROADCAST_TO_ALL(BitmapListChangedMsg(Doc->GetBitmapList())); 
01420         Doc = (Document*)GetApplication()->Documents.GetNext(Doc);
01421     }
01422 
01423     // Restore the current document
01424     if (pCurrent)
01425         pCurrent->SetCurrent();
01426 
01427 EndOperation:
01428     ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,NULL);
01429     UpdateAllChangedNodes(&ObjChange);
01430 
01431     EndSlowJob();
01432     End();
01433 }

void OpDeleteBitmap::ForceRedrawOfNode Document Doc,
Node pNodeToRedraw,
ObjChangeParam pObjChange
[protected]
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/95
Parameters:
- [INPUTS]
Returns:
Errors: -
See also:
-

Definition at line 1449 of file bmplist.cpp.

01451 {
01452 
01453     /*BOOL Allowed =*/ pNodeToRedraw->AllowOp(pObjChange);
01454     // Ignore the Allowed state, do it regardless ...
01455 
01456     // Force a redraw on the object and it's parent.
01457     Node* pParent = pNodeToRedraw;
01458     Spread* pSpread = pNodeToRedraw->FindParentSpread();
01459 
01460     while (pSpread != NULL && pParent != NULL)
01461     {
01462         Node* pPrevParent = pParent->FindParent();
01463 
01464         if (pPrevParent && pPrevParent->IsLayer())
01465         {
01466             DocRect Bounds = 
01467                 ((NodeRenderableBounded*)pParent)->GetBoundingRect();
01468             Doc->ForceRedraw(pSpread, Bounds, FALSE, pParent);
01469         }
01470 
01471         pParent = pPrevParent;
01472     }
01473 }

OpState OpDeleteBitmap::GetState String_256 UIDescription,
OpDescriptor
[static]
 

For finding the OpDeleteBitmap's state.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
Returns:
The state of the OpDeleteBitmap operation

Errors: -

See also:
-

Definition at line 1255 of file bmplist.cpp.

01256 {
01257     OpState OpSt;
01258     return(OpSt);
01259 }

BOOL OpDeleteBitmap::Init void   )  [static]
 

Get a pointer to the greyscale bitmap listOpDeleteBitmap initialiser method.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 1229 of file bmplist.cpp.

01230 {
01231     return (RegisterOpDescriptor(
01232                                 0,
01233                                 0,
01234                                 CC_RUNTIME_CLASS(OpDeleteBitmap),
01235                                 OPTOKEN_DELETEBITMAP,
01236                                 OpDeleteBitmap::GetState,
01237                                 0,  /* help ID */
01238                                 0,
01239                                 0   /* bitmap ID */));
01240 }               


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