NodeBitmap Class Reference

A class for including bitmap objects within the tree. More...

#include <nodebmp.h>

Inheritance diagram for NodeBitmap:

NodeRect NodeSimpleShape NodeRenderableInk NodeRenderableBounded NodeRenderable Node CCObject SimpleCCObject NodeAnimatingBitmap List of all members.

Public Member Functions

 NodeBitmap ()
 This constructor creates a NodeBitmap linked to no other with all status flags false and an uninitialized bounding rectangle.
 NodeBitmap (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE)
 This constructor initialises the nodes flags and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated.
virtual NodeSimpleCopy ()
 Makes a copy of all the data in the node.
void CopyNodeContents (NodeBitmap *NodeCopy)
 Copies the data in the node by first calling the base class to get it to copy its stuff, and then copying its own stuff Scope: protected.
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.
virtual String Describe (BOOL Plural, BOOL Verbose)
 To return a description of the NodeBitmap object in either the singular or the plural. This method is called by the DescribeRange method. The description will always begin with a lower case letter.
virtual KernelBitmapEnumerateBitmaps (UINT32 Count)
 Find out what bitmaps, if any, are used by this node.
virtual double GetEffectiveBitmapMinDPI (KernelBitmap *pBitmap)
virtual BOOL ReplaceBitmap (KernelBitmap *pOrigBitmap, KernelBitmap *pNewBitmap)
virtual BOOL SupportsClipboardFormat (InternalClipboardFormat *Format) const
 Determine if a node supports a given internal data type. This is used by the clipboard when exporting to other applications in order to determine if certain data types can be supplied.
UINT32 GetBitmapDPI ()
 Caculates the actual DPI of the bitmap on the page.
virtual void Render (RenderRegion *pRender)
 Will render the bitmap contained within the object to the given render region.
virtual void PreExportRender (RenderRegion *pRender)
 Prevent the base class NodeRect::PreExportRender() function from exporting anything to mark this as a rectangle object - because it's not; it's a bitmap object.
virtual BOOL ExportRender (RenderRegion *pRender)
 Export a bitmap object to a file.
virtual INT32 GetSizeOfExport (Filter *)
 Determine how many 'nodes' this bitmap is equivalent to. We use the rough approximation that each scanline taks the same amount of space as a typical node. This gives us enough granularity for a reasonably accurate and smooth progress display update.
virtual BOOL RequiresAttrib (NodeAttribute *pAttrib, BOOL Search=FALSE)
 Determine which attributes a bitmap object supports a particular type of attribute. A bitmap only supports transparent fill geometries, mappings, and effects - all other attributes are rejected.
virtual BOOL ApplyDefaultBitmapAttrs (UndoableOperation *pOp, AttrBitmapTranspFill *pTranspBitmap=NULL)
 Apply the default attributes that a NodeBitmap needs. This is specific to Bitmap Nodes, which need the Start and End colours to be NONE initially, and also need to ensure the line width is 0. There is now an optional pointer to a transparent bitmap fill to be applied over the current bitmap node. This is used by the transparent GIF import code.
virtual BOOL OnNodePopUp (Spread *pSpread, DocCoord PointerPos, ContextMenu *pMenu)
 Allows the Node to respond to pop up menu clicks on it (rather than its blobs).
virtual UINT32 GetNodeSize () const
 For finding the size of the node.
virtual BOOL IsABitmap () const
virtual BOOL NeedsTransparency () const
 Called.
virtual BOOL CanBecomeA (BecomeA *pBecomeA)
 This function is used by the convert to shapes operation. It determines if the node or any of its children can convert themselves into an InkClass object. In the case of a node bitmap we must stop it from it having the make shapes applied as otherwise we will loose the bitmap from view. NodeSimpleShape overrides the baseclass function to return True.
virtual BOOL DoBecomeA (BecomeA *pBecomeA)
 Transforms the object into another type of object. Note: changed 7/10/94 by MarkN to take the pBecomeA param, so that more data could be passed to these functions in the future without causing massive rebuilds due to the editing of node.h.
BOOL AllowOp (ObjChangeParam *, BOOL)
 This is the way to ask a node if you can do an op to it.
BOOL MakeContoneBitmap (UndoableOperation *)
 Make this NodeBitmap into a grey level version of itself.
virtual KernelBitmapRefGetBitmapRef ()
virtual KernelBitmapGetBitmap ()
 Get the bitmap referenced by this node.
virtual BOOL HidingNode ()
 This virtual function is called whenever the node is hidden. It allows the node do things like 'optimise' itself to use less memory or send a message to let others know it is being hidden etc.
virtual BOOL ShowingNode ()
 This virtual function is called whenever the node is re-shown after being Hidden. It allows the node to reconstruct itself if it was optimised or send a message to let others know it is back etc.
virtual void SetStartColour (DocColour *)
 Set the start colour of a bitmap palette.
virtual void SetEndColour (DocColour *)
 Set the end colour of a bitmap palette.
virtual DocColourGetStartColour ()
 Gets the start colour of the bitmap palette.
virtual DocColourGetEndColour ()
 Gets the end colour of the bitmap palette.
virtual BOOL GetApplyContoneColour ()
BOOL HasSimpleOrientation (RenderRegion *)
 Determine if a bitmap is classified as a 'simple' bitmap, for use during the complex rendering of a view - if the render region can support simple bitmaps and this function returns TRUE, then we render the bitmap directly, otherwise it goes into the masked GDraw bitmap and is rendered that way.
virtual BOOL OnClick (DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread *pSpread)
 Allows the Node to respond to clicks by selecting its blobs or starting drags etc. This functions should be overridden in the all the NodeRenderableInk classes so that this version never gets called. Eg the NodePath class might claim the click if it happened over one of its unselected blobs.
virtual TCHARGetDefaultOpToken ()
virtual void SetAspectRatio (double dExWidth, double dExHeight, BOOL bPathAndFill)
 To reset the stored path and Parallelogram to retain their shape and scale but to take on a new aspect ratio.
virtual BOOL ReleaseCached (BOOL bAndParents=TRUE, BOOL bAndChildren=TRUE, BOOL bSelf=TRUE, BOOL bAndDerived=TRUE)
 Get rid of cached data held in the tree.
virtual DocRect GetOriginalBitmapRect ()
 Find the starting point for the instance transform.
virtual Matrix GetInstanceTransform ()
 Find the instance transform matrix Notes: Parallelogram format includes 4 coords and is stored in this format: 0-------1 | | 3-------2 (Why?).
virtual BOOL CanSupplyDirectBitmap ()
virtual BOOL GetDirectBitmap (RenderRegion *pRender, LPBITMAPINFO *plpInfo, LPBYTE *plpBits, DocRect *pRect, Matrix *pMat, double *pdRes)
 Return details of direct bitmap to caller (caller is usually a NodeBitmapEffect).
virtual BOOL WritePreChildrenWeb (BaseCamelotFilter *pFilter)
 saves a NodeBitmap to the filter
virtual BOOL WritePreChildrenNative (BaseCamelotFilter *pFilter)

Static Public Member Functions

static KernelBitmapCheckGreyscaleBitmap (KernelBitmap *pBitmap, UINT32 PromptID, UINT32 OkID)
 Checks a bitmap to see if can be applied as a texture, and gives the option to create a grey level version if not.

Public Attributes

KernelBitmapRef BitmapRef

Protected Member Functions

virtual BOOL HasBitmapAttrs ()
 Test whether we need to render this bitmap before we can return it from GetDirectBitmap.

Protected Attributes

DocColour Colour
DocColour EndColour
BOOL ApplyContoneColour

Private Member Functions

 CC_DECLARE_DYNCREATE (NodeBitmap)

Detailed Description

A class for including bitmap objects within the tree.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/03/94
See also:
NodeRect, KernelBitmap

Definition at line 124 of file nodebmp.h.


Constructor & Destructor Documentation

NodeBitmap::NodeBitmap  ) 
 

This constructor creates a NodeBitmap linked to no other with all status flags false and an uninitialized bounding rectangle.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/08/94
NB. SetUpPath() must be called before the NodeBitmap is in a state in which it can be used.

See also:
SetUpPath

Definition at line 266 of file nodebmp.cpp.

00266                       : NodeRect()
00267 {
00268     Colour = COLOUR_NONE;
00269     EndColour = COLOUR_NONE;
00270 
00271     ApplyContoneColour = FALSE;
00272 }

NodeBitmap::NodeBitmap Node ContextNode,
AttachNodeDirection  Direction,
BOOL  Locked = FALSE,
BOOL  Mangled = FALSE,
BOOL  Marked = FALSE,
BOOL  Selected = FALSE
 

This constructor initialises the nodes flags and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/08/94
Parameters:
ContextNode,: Pointer to a node which this node is to be attached to. [INPUTS]
Direction:

Specifies the direction in which the node is to be attached to the ContextNode. The values this variable can take are as follows:

PREV : Attach node as a previous sibling of the context node NEXT : Attach node as a next sibling of the context node FIRSTCHILD: Attach node as the first child of the context node LASTCHILD : Attach node as a last child of the context node

The remaining inputs specify the status of the node:

Locked: Is node locked ? Mangled: Is node mangled ? Marked: Is node marked ? Selected: Is node selected ?

Note: SetUpPath() must be called before the NodeBitmap is in a state in which it can be used.

See also:
SetUpPath
Returns:
Errors: An assertion error will occur if ContextNode is NULL

Definition at line 235 of file nodebmp.cpp.

00241                :NodeRect(ContextNode, Direction, Locked, Mangled, Marked, Selected )  
00242 {                         
00243     Colour = COLOUR_NONE;
00244     EndColour = COLOUR_NONE;
00245 
00246     ApplyContoneColour = FALSE;
00247 }                        


Member Function Documentation

BOOL NodeBitmap::AllowOp ObjChangeParam pParam,
BOOL  SetOpPermissionState
 

This is the way to ask a node if you can do an op to it.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/02/95
Parameters:
pParam = describes the way an op wants to change the node [INPUTS] SetOpPermissionState = if TRUE the Op permission state of this node will be set according to the outcome of the call
- [OUTPUTS]
Returns:
TRUE means the node and all its parents are happy with this op, FALSE means don't do it
The ObjChangeParam class contains flags that describe how it will change the node

For example, the op could change the node's appearence (e.g. attr application, editing a path), replace the node with another node (e.g. because it uses hidden nodes to hide the original and put another node in its place, or "make shapes"), delete the node (e.g. the delete and cut ops), etc.

This function gives the node a chance to say NO. It also gives the parents a chance to say no too. E.g. a blend node will allow itself to be deleted, but it will NOT allow a child of itself to be deleted).

This call should only be made on selected, or parents of selected, nodes. It makes a decision as a straight node if it is selected. It makes a decision as a parent if it has selected children.

E.g. NodeBlend::AllowOp(...op delete...) if the node is selected, then it will return TRUE (parents permitting), i.e. I can be deleted if the node is a parent of selected it will return FALSE (i.e. can't delete children of blends).

So when the node is selected, you are asking the node if you can do the op to it. When the node is a parent of a selected node, you are asking if you can do the op to one of its children.

If the 'SetOpPermissionState' param is TRUE, the following indented lines applies: The node's op permission state is set according to the result of this function.

If TRUE is returned, then the node's op permission state will be left unchanged. AND the parent's op permission state will be set to PERMISSION_ALLOWED

if FALSE is returned, then the node's op permission state will be PERMISSION_DENIED, AND all it's parents (up to the layer) will be set to PERMISSION_DENIED

Also, all parents of this node are called via their AllowOp() func with the same state as this node. This means that after this call, you can guarantee that all of its parents will have either a PERMISSION_DENIED or PERMISSION_ALLOWED state.

Note: Even if this node tries to set all it's parents to have a PERMISSION_DENIED state, if any of its parents have previously been set to PERMISSION_ALLOWED they will remain in that state (see SetOpPermission()). Why? Well, it is possible for a parent node to have one child with a PERMISSION_DENIED and another child with a PERMISSION_ALLOWED. It this state the parent MUST be in state PERMISSION_ALLOWED, because at least one of its children will allow the op to happen to it.

So, after this call: The op permission state for this node will be either left unchanged (and therefore remain PERMISSION_UNDEFINED), or PERMISSION_DENIED.

The parent's op permission state will be either PERMISSION_ALLOWED, or PERMISSION_DENIED.

This is so UndoableOperation::UpdateChangedNodes() will only call OnChildChange() on parent nodes, because it only calls that func for nodes that have an op permission state of PERMISSION_ALLOWED.

See also:
GetOpPermission(),SetOpPermission();

Definition at line 1479 of file nodebmp.cpp.

01479     {
01480         BOOL AnyAllowed=AllowOp_AccountForCompound(pParam, SetOpPermissionState);
01481         // if called by a parent, just pass this result back
01482         if (pParam->GetDirection()==OBJCHANGE_CALLEDBYPARENT)
01483             return AnyAllowed;
01484     }
01485     else
01486     {
01487         // clean out the calling-child ptr, so it doesn't get passed around unintentionally.
01488         pParam->SetCallingChild(NULL);
01489     }
01490 
01491     // at this point we must have been called directly by the op or via a child AllowOp()
01492 
01493     // decide if we allow it ... 
01494     BOOL allowed=TRUE;
01495     ObjChangeFlags Flags = pParam->GetChangeFlags();
01496 
01497     if (Flags.Attribute)
01498     {
01499         // Someone is applying an attribute .....
01500         // We really need to check the actual attribute, so for
01501         // now we'll rely on the fact that the 'RequiresAttrib()'
01502         // function will have been called before this one.
01503 
01504         // If we are applying a contone colour, then make sure we
01505         // are a Grey level bitmap, and give the user the option
01506         // of making one if not.
01507         if (ApplyContoneColour)
01508         {
01509             // 'ApplyContoneColour' is set in the 'RequiresAttrib()'
01510             // function if a contone colour change attr is applied.
01511             allowed = MakeContoneBitmap(pParam->GetOpPointer());        
01512         }       
01513     }
01514 
01515     // if we allowed it, see if our parents do ...
01516     if (allowed && Parent!=NULL)
01517     {
01518         ObjChangeDirection OldDirection=pParam->GetDirection();
01519         pParam->SetCallingChild(this);
01520         pParam->SetDirection(OBJCHANGE_CALLEDBYCHILD);
01521         allowed=Parent->AllowOp(pParam,SetOpPermissionState);
01522         pParam->SetDirection(OldDirection);
01523     }
01524 
01525     // if setting permisions ...
01526     if (SetOpPermissionState)
01527     {
01528         // if allowed, mark parent accordingly, else mark child as denied and update parents
01529         if (allowed)
01530             Parent->SetOpPermission(PERMISSION_ALLOWED);
01531         else
01532             SetOpPermission(PERMISSION_DENIED,TRUE);
01533     }
01534 
01535     // return result (directly, or indirectly via a child AllowOp()) to op
01536     return allowed;
01537 }
01538 
01539 /********************************************************************************************
01540 
01541 >   BOOL NodeBitmap::MakeContoneBitmap(UndoableOperation* pOperation)
01542 
01543     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>

BOOL NodeBitmap::ApplyDefaultBitmapAttrs UndoableOperation pOp,
AttrBitmapTranspFill pTranspBitmap = NULL
[virtual]
 

Apply the default attributes that a NodeBitmap needs. This is specific to Bitmap Nodes, which need the Start and End colours to be NONE initially, and also need to ensure the line width is 0. There is now an optional pointer to a transparent bitmap fill to be applied over the current bitmap node. This is used by the transparent GIF import code.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/95
Parameters:
pOp - the undoable operation in which this Node has been created. [INPUTS] pTranspBitmap - optional bitmap to apply as transparency. (Default = NULL)
Returns:
TRUE => Default attribute where applied ok. FALSE => Apply failed.

Definition at line 997 of file nodebmp.cpp.

00999 {
01000     if (pTranspBitmap != NULL)
01001     {
01002         pTranspBitmap->AttachNode(this, FIRSTCHILD);
01003 
01004         // Apply it as a single tiled fill. Otherwise in the GIF transparency case
01005         // the repeating can give ghost pixels along the edges.
01006         AttrTranspFillMappingLinear *pNoRepeatAttr = new AttrTranspFillMappingLinear;
01007         if (pNoRepeatAttr == NULL)
01008             return FALSE;
01009 
01010         pNoRepeatAttr->Value.Repeat = 1;
01011 
01012         pNoRepeatAttr->AttachNode(this, FIRSTCHILD);
01013     }
01014 
01015     Node* pLineColAttr = new AttrStrokeColour();
01016     if (pLineColAttr == NULL)
01017         return FALSE;
01018 
01019 /*
01020     Node* pLineTranspAttr = new AttrStrokeTransp();
01021     if (pLineTranspAttr == NULL)
01022     {
01023         delete pLineColAttr;
01024         return FALSE;
01025     }
01026  */
01027 
01028     Node* pFillColAttr = new AttrFlatColourFill();
01029     if (pFillColAttr == NULL)
01030     {
01031         delete pLineColAttr;
01032 //      delete pLineTranspAttr;
01033         return FALSE;
01034     }
01035 
01036     Node* pLineWidthAttr = new AttrLineWidth();
01037     if (pFillColAttr == NULL)
01038     {
01039         delete pLineColAttr;
01040 //      delete pLineTranspAttr;
01041         delete pFillColAttr;
01042         return FALSE;
01043     }
01044 
01045     DocColour           colorNull(COLOUR_NONE);
01046     ((AttrFillGeometry*)pLineColAttr)->SetStartColour( &colorNull );
01047     ((AttrFillGeometry*)pFillColAttr)->SetStartColour( &colorNull );
01048     ((AttrLineWidth*)pLineWidthAttr)->Value.LineWidth = 0;
01049 
01050 //  UINT32 LineTransp = 255;
01051 //  ((AttrFillGeometry*)pLineTranspAttr)->SetStartTransp(&LineTransp);
01052 //  ((AttrFillGeometry*)pLineTranspAttr)->SetTranspType(1);
01053 
01054     pLineColAttr->AttachNode(this, FIRSTCHILD);
01055 //  pLineTranspAttr->AttachNode(this, FIRSTCHILD);
01056     pFillColAttr->AttachNode(this, FIRSTCHILD);
01057     pLineWidthAttr->AttachNode(this, FIRSTCHILD);
01058 
01059     return TRUE;
01060 }

BOOL NodeBitmap::CanBecomeA BecomeA pBecomeA  )  [virtual]
 

This function is used by the convert to shapes operation. It determines if the node or any of its children can convert themselves into an InkClass object. In the case of a node bitmap we must stop it from it having the make shapes applied as otherwise we will loose the bitmap from view. NodeSimpleShape overrides the baseclass function to return True.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/1/95
Parameters:
pClass,: The class of object [INPUTS] pNumObjects = ptr to place number of objects of type pClass that will be created (Note: can be NULL). pNumObects in undefined on entry
Returns:
TRUE if the node, or any of its children can transmogrify themselves to become an InkClass object
The number you put into pNumObjects (if it's not NULL) should exactly equal the total number of pClass objects you create. It should NOT contain any additional objects you may produce such as group objects for containing the pClass object, or attributes.

Also, the entry value of *pNumObjects cannot be assumed to be 0.

Reimplemented from NodeSimpleShape.

Definition at line 1087 of file nodebmp.cpp.

01088 {
01089     // The NodeBitmap can become a NodePath (with a bitmap fill)
01090     if (pBecomeA->BAPath())
01091     {
01092         pBecomeA->AddCount(1);
01093         return TRUE;
01094     }
01095 
01096     return FALSE;
01097 }

virtual BOOL NodeBitmap::CanSupplyDirectBitmap  )  [inline, virtual]
 

Reimplemented from NodeRenderableInk.

Definition at line 217 of file nodebmp.h.

00217 {return TRUE;}

NodeBitmap::CC_DECLARE_DYNCREATE NodeBitmap   )  [private]
 

KernelBitmap * NodeBitmap::CheckGreyscaleBitmap KernelBitmap pBitmap,
UINT32  PromptID,
UINT32  OkID
[static]
 

Checks a bitmap to see if can be applied as a texture, and gives the option to create a grey level version if not.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/95

Definition at line 1578 of file nodebmp.cpp.

01591           :     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>

void NodeBitmap::CopyNodeContents NodeBitmap NodeCopy  ) 
 

Copies the data in the node by first calling the base class to get it to copy its stuff, and then copying its own stuff Scope: protected.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/93
Parameters:
NodeCopy - The node to copy [INPUTS]
See also:
NodeRect::CopyNodeContents

Definition at line 312 of file nodebmp.cpp.

00313 {
00314     NodeRect::CopyNodeContents(NodeCopy);
00315 
00316     // Copy contents specific to derived class here
00317 
00318     // Copy KernelBitmap reference
00319     NodeCopy->BitmapRef = BitmapRef;
00320 
00321     // We need to copy the cached bitmaps into the new node
00322     // But since this cached (option 2) bitmap is only ever used as an intermediate stage
00323     // in producing another cached bitmap, we probably don't need to copy it
00324     //CopyCached(pCopyOfNode, GetPixelWidth(), 2);  // Copy cached bitmaps, options 0, 1 and 2 (original and processed)
00325 }

String NodeBitmap::Describe BOOL  Plural,
BOOL  Verbose
[virtual]
 

To return a description of the NodeBitmap object in either the singular or the plural. This method is called by the DescribeRange method. The description will always begin with a lower case letter.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/6/93
Parameters:
Plural,: Flag indicating if the string description should be plural or [INPUTS] singular.
Returns:
Description of the object

Errors: A resource exception will be thrown if a problem occurs when loading the string resource.

Reimplemented from NodeRect.

Reimplemented in NodeAnimatingBitmap.

Definition at line 370 of file nodebmp.cpp.

00371 {     
00372 #if !defined(EXCLUDE_FROM_RALPH)
00373     if (Plural)
00374     {
00375         return(String(_R(IDS_BITMAP_DESCRP)));  
00376     }
00377     else
00378     {
00379         if (GetBitmap() == NULL || GetBitmap()->ActualBitmap == NULL)
00380             return(String(_R(IDS_BITMAP_DESCRS))); 
00381 
00382         // If we have a bitmap, then include it's name and actual dpi
00383         // in the desciption
00384 
00385         String_256 BmpName = GetBitmap()->ActualBitmap->GetName();
00386         String_64 TrunkName;
00387         if (BmpName.Length() > 12)
00388         {
00389             BmpName.Left(&TrunkName, 9);
00390             TrunkName += _T("...");
00391         }
00392         else
00393         {
00394             BmpName.Left(&TrunkName, 12);
00395         }
00396 
00397         String_256 DpiText;
00398         UINT32 dpi = GetBitmapDPI();
00399 
00400         if (dpi > 0)
00401         {
00402             String_256 jcf(_R(IDS_NODEBMP_DPI_FORMAT));
00403             camSnprintf(DpiText, 256, jcf, dpi);
00404         }
00405 
00406         String_64 TrunkDpi;
00407         DpiText.Left(&TrunkDpi, 11);
00408 
00409         String_256 Desc(_R(IDS_BITMAP_DESCRS));
00410         String_64 TrunkDesc;
00411         Desc.Left(&TrunkDesc, 6);
00412 
00413         if (Verbose)
00414         {
00415             String_32 ret = TrunkDesc;
00416             ret += TEXT(" '");
00417             ret += TrunkName;
00418             ret += TEXT("'");
00419             ret += TrunkDpi;
00420             return ret;
00421 //          return(String(TrunkDesc+TEXT(" '")+TrunkName+TEXT("'")+TrunkDpi));
00422         }
00423         else
00424         {
00425             String_32 ret = TrunkDesc;
00426             ret += TEXT(" ");
00427             ret += TrunkName;
00428             return ret;
00429 //          return(String(TrunkDesc+TEXT(" ")+TrunkName));
00430         }
00431     }
00432 #else
00433     return(String(_R(IDS_BITMAP_DESCRP)));  
00434 #endif
00435 }

BOOL NodeBitmap::DoBecomeA BecomeA pBecomeA  )  [virtual]
 

Transforms the object into another type of object. Note: changed 7/10/94 by MarkN to take the pBecomeA param, so that more data could be passed to these functions in the future without causing massive rebuilds due to the editing of node.h.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/95
Parameters:
pBecomeA = ptr to a class that contains all the info needed to become a new [INPUTS] type of node.
- [OUTPUTS]
Returns:
TRUE if the object has been transformed, FALSE if we run out of memory
See also:
NodeSimpleShape::CanBecomeA

Reimplemented from NodeSimpleShape.

Definition at line 1118 of file nodebmp.cpp.

01119 {
01120     // Check for a NULL entry param
01121     ERROR2IF_PF(pBecomeA == NULL,FALSE,("pBecomeA is NULL"));
01122 
01123     // This lump checks that the Reason is one that we understand
01124     // It also makes sure that we don't have a NULL UndoOp ptr
01125     BOOL ValidReason = (pBecomeA->GetReason() == BECOMEA_REPLACE || pBecomeA->GetReason() == BECOMEA_PASSBACK);
01126     ERROR2IF_PF(!ValidReason,FALSE,("Unkown BecomeA reason %d",pBecomeA->GetReason()));
01127 
01128     // pBecomeA->Reason is one that we understand.
01129 
01130     UndoableOperation* pUndoOp = pBecomeA->GetUndoOp();
01131     BOOL        Success = TRUE;         // Our success flag (Important that this defaults to TRUE)
01132     NodePath*   pNewNodePath = NULL;    // Ptr to a new NodePath, if we get to make one.
01133 
01134     if (pBecomeA->BAPath())
01135     {
01136         // We need to create a new NodePath, no matter what the reason.
01137         
01138         // Allocate a new NodePath node
01139         ALLOC_WITH_FAIL(pNewNodePath, (new NodePath), pBecomeA->GetUndoOp()); 
01140         Success = (pNewNodePath != NULL);
01141 
01142         // Initialise the path
01143         if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.Initialise(InkPath.GetNumCoords(),12), pBecomeA->GetUndoOp(), Success);
01144         if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.CopyPathDataFrom(&InkPath), pBecomeA->GetUndoOp(), Success);
01145         
01146         if (Success) pNewNodePath->InkPath.IsFilled = TRUE;
01147 
01148         // If Success is TRUE, then we now have a new NodePath object that contains this shape's path
01149 
01150         if (Success)
01151         {
01152             // Remember the contone colours before we go and hide the applied attributes
01153             DocColour* ContoneStart = GetStartColour();
01154             DocColour* ContoneEnd   = GetEndColour();
01155         
01156             switch (pBecomeA->GetReason())
01157             {
01158                 case BECOMEA_REPLACE :
01159                 {
01160                     // It's a BECOMEA_REPLACE, so replace this node with the new NodePath in an undoable way
01161 
01162                     // Can't do it in an undoable way without an Undo Op
01163 //                  ERROR2IF_PF(pBecomeA->GetUndoOp() == NULL,FALSE,("GetUndoOp() returned NULL"));
01164 
01165                     // The NodeBitmap uses the Fill and line colours to set it's
01166                     // contone colours.
01167                     // But the bitmap fill doesn't need them, so we will Hide
01168                     // any of these attributes that we find applied
01169                     Node* pChild = FindFirstChild();
01170                     while (pChild != NULL)
01171                     {
01172                         Node* pThisChild = pChild;
01173                         pChild = pChild->FindNext();    // Find next before we hide this child
01174                                                 
01175                         if (pThisChild->IsAnAttribute())
01176                         {
01177                             NodeAttribute* pAttr = (NodeAttribute*)pThisChild;
01178 
01179                             if (pAttr->IsAColourFill() ||
01180                                 pAttr->IsAStrokeColour() )
01181                             {
01182                                 if (pUndoOp)
01183                                 {
01184                                     // Hide and Fill or Line colour attributes
01185                                     NodeHidden* pNodeHidden; 
01186                                     Success = pBecomeA->GetUndoOp()->DoHideNode(pAttr, TRUE, &pNodeHidden);
01187                                 }
01188                                 else
01189                                 {
01190                                     pAttr->CascadeDelete();
01191                                     delete pAttr;
01192                                 }
01193                             }
01194                         }
01195                     }
01196 
01197                     // Now make a Bitmap Fill that is equivalent to this NodeBitmap
01198                     AttrFillGeometry* pBitmapFill;
01199                     ALLOC_WITH_FAIL(pBitmapFill , new AttrBitmapColourFill(), pBecomeA->GetUndoOp());
01200                     
01201                     if (pBitmapFill)
01202                     {
01203                         pBitmapFill->AttachBitmap(GetBitmap());
01204 
01205                         // Set any contone colours that we have
01206                         pBitmapFill->SetStartColour(ContoneStart);
01207                         pBitmapFill->SetEndColour(ContoneEnd);
01208 
01209                         // Set the control points from the NodeBitmap Parallelogram
01210                         pBitmapFill->SetStartPoint(&Parallel[3]);
01211                         pBitmapFill->SetEndPoint(&Parallel[2]);
01212                         pBitmapFill->SetEndPoint2(&Parallel[0]);
01213                         
01214                         pBitmapFill->AttachNode(this, FIRSTCHILD);
01215 
01216                         if (pUndoOp)
01217                         {
01218                             // Create a hide node action to hide the node when we undo 
01219                             HideNodeAction* UndoHideNodeAction;     
01220                             Success = (HideNodeAction::Init(pBecomeA->GetUndoOp(),
01221                                                      pBecomeA->GetUndoOp()->GetUndoActionList(),
01222                                                      pBitmapFill, 
01223                                                      TRUE,       // Include subtree size 
01224                                                      ( Action**)(&UndoHideNodeAction))
01225                                                      != AC_FAIL);
01226                         }
01227                     }
01228 
01229                     // We also need to make sure it has no line colour
01230                     AttrFillGeometry* pStrokeColour;
01231                     ALLOC_WITH_FAIL(pStrokeColour , new AttrStrokeColour(), pBecomeA->GetUndoOp());
01232                     
01233                     if (pStrokeColour)
01234                     {
01235                         // Ensure the line colour is set to NONE
01236                         DocColour NoCol = COLOUR_NONE;
01237                         pStrokeColour->SetStartColour(&NoCol);
01238                         
01239                         pStrokeColour->AttachNode(this, FIRSTCHILD);
01240 
01241                         if (pUndoOp)
01242                         {
01243                             // Create a hide node action to hide the node when we undo 
01244                             HideNodeAction* UndoHideNodeAction;     
01245                             Success = (HideNodeAction::Init(pBecomeA->GetUndoOp(),
01246                                                      pBecomeA->GetUndoOp()->GetUndoActionList(),
01247                                                      pStrokeColour, 
01248                                                      TRUE,       // Include subtree size 
01249                                                      ( Action**)(&UndoHideNodeAction))
01250                                                      != AC_FAIL);
01251                         }
01252                     }
01253 
01254                     // Copy the node's attributes
01255                     CALL_WITH_FAIL(CopyChildrenTo(pNewNodePath), pBecomeA->GetUndoOp(), Success); 
01256 
01257                     // Insert the new NodePath into the tree, next to this node
01258                     pNewNodePath->AttachNode(this,NEXT);
01259 
01260                     if (Success)
01261                     {
01262                         // Set the bounds  
01263                         pNewNodePath->InvalidateBoundingRect();
01264                         pNewNodePath->SetSelected(IsSelected());
01265 
01266                         if (pUndoOp)
01267                         {
01268                             // Create a hide node action to hide the node when we undo 
01269                             HideNodeAction* UndoHideNodeAction;     
01270                             Success = (HideNodeAction::Init(pBecomeA->GetUndoOp(),
01271                                                      pBecomeA->GetUndoOp()->GetUndoActionList(),
01272                                                      pNewNodePath, 
01273                                                      TRUE,       // Include subtree size 
01274                                                      ( Action**)(&UndoHideNodeAction))
01275                                                      != AC_FAIL);
01276                         }
01277                     }
01278 
01279                     if (Success)
01280                     {
01281                         CCAttrMap AttrMap;
01282                         CCAttrMap* pAttrMap = NULL;
01283                         BOOL bFoundAttrs = pNewNodePath->FindAppliedAttributes(&AttrMap);
01284                         if (bFoundAttrs)
01285                             pAttrMap = AttrMap.Copy();
01286                         pBecomeA->PassBack(pNewNodePath, this, pAttrMap);
01287                     }
01288 
01289                     // Now hide this NodeBitmap
01290                     if (pUndoOp)
01291                     {
01292                         NodeHidden* pNodeHidden; 
01293                         Success = pBecomeA->GetUndoOp()->DoHideNode(this, TRUE, &pNodeHidden);
01294                     }
01295                     else
01296                     {
01297                         CascadeDelete();
01298                         delete this;        // Scary!
01299                     }
01300                 }
01301                 break;
01302 
01303                 case BECOMEA_PASSBACK :
01304                 {
01305                     // First find all attributes applied to this node...
01306                     // 30 is a default value - this will grow if it needs more space
01307                     CCAttrMap* pAttribMap = new CCAttrMap(30);
01308                     CCAttrMap* pCopyOfAttrMap = NULL;
01309 
01310                     // Now find any attributes that are applied to this node.
01311                     /*BOOL FoundAttrs =*/ FindAppliedAttributes(pAttribMap);
01312 
01313 //                  size_t AttrCount = FoundAttrs ? pAttribMap->GetCount() : 30;
01314 
01315                     // Now make a copy of the applied attributes map
01316                     pCopyOfAttrMap = pAttribMap->Copy ();//new CCAttrMap(AttrCount);
01317                     if (pCopyOfAttrMap != NULL)
01318                     {           
01319                         // We've made a copy of the Attr map now, so we don't need
01320                         // the old one anymore
01321                         delete pAttribMap;
01322                      
01323                         // Replace the Fill and Line Colour attributes
01324                         // in the Attr Map copy
01325 
01326                         AttrFillGeometry* pBitmapFill = new AttrBitmapColourFill();
01327                         if (pBitmapFill)
01328                         {
01329                             // Make a Bitmap Fill that is equivalent to this
01330                             // node bitmap
01331                             pBitmapFill->AttachBitmap(GetBitmap());
01332 
01333                             // Set any contone colours that we have
01334                             pBitmapFill->SetStartColour(ContoneStart);
01335                             pBitmapFill->SetEndColour(ContoneEnd);
01336 
01337                             // Set the control points from the NodeBitmap Parallelogram
01338                             pBitmapFill->SetStartPoint(&Parallel[3]);
01339                             pBitmapFill->SetEndPoint(&Parallel[2]);
01340                             pBitmapFill->SetEndPoint2(&Parallel[0]);
01341 
01342                             void* pOldFill;
01343                             if( pCopyOfAttrMap->Lookup( CC_RUNTIME_CLASS(AttrFillGeometry), pOldFill ) )
01344                             {
01345                                 // We need to Remove and Delete the existing Fill Attr
01346                                 pCopyOfAttrMap->RemoveKey( CC_RUNTIME_CLASS(AttrFillGeometry) );
01347                                 delete (AttrFillGeometry*)pOldFill;
01348                             }
01349 
01350                             // Add the Bitmap fill into the Attr Map
01351                             pCopyOfAttrMap->SetAt( CC_RUNTIME_CLASS(AttrFillGeometry), (void*)pBitmapFill );
01352                         }
01353 
01354                         AttrFillGeometry* pStrokeColour = new AttrStrokeColour();
01355                         if (pStrokeColour)
01356                         {
01357                             // Ensure the line colour is set to NONE
01358                             DocColour NoCol = COLOUR_NONE;
01359                             pStrokeColour->SetStartColour(&NoCol);
01360 
01361                             void* pOldStroke;
01362                             if( pCopyOfAttrMap->Lookup( CC_RUNTIME_CLASS(AttrStrokeColour), pOldStroke ) )
01363                             {
01364                                 // We need to Remove and Delete the existing Stroke Colour Attr
01365                                 pCopyOfAttrMap->RemoveKey( CC_RUNTIME_CLASS(AttrStrokeColour) );
01366                                 delete (AttrFillGeometry*)pOldStroke;
01367                             }
01368 
01369                             // Add the new Stroke Colour into the Attr Map
01370                             pCopyOfAttrMap->SetAt( CC_RUNTIME_CLASS(AttrStrokeColour), (void*)pStrokeColour );
01371                         }
01372                     }
01373 
01374                     Success = pBecomeA->PassBack(pNewNodePath, this, pCopyOfAttrMap);
01375                 }
01376                 break;
01377 
01378                 case BECOMEA_TEST:
01379                     // Do nothing
01380                 break;
01381 
01382                 default:
01383                 {
01384                     ERROR3("Unhandled BecomeA type in NodeBitmap::DoBecomeA");
01385                 }
01386             }
01387         }
01388     }
01389 
01390     if (!Success)
01391     {
01392         if (pNewNodePath != NULL)
01393         {
01394             // Delete all the NodePath's children (if it has any) and unlink it from the tree (if it's linked)
01395             // This is all done by CascadeDelete()
01396             pNewNodePath->CascadeDelete(); 
01397             delete pNewNodePath;
01398             pNewNodePath = NULL;
01399         }
01400     }
01401 
01402     return Success;
01403 }
01404 
01405 /********************************************************************************************
01406 
01407 >   virtual BOOL NodeBitmap::AllowOp(ObjChangeParam* pParam,BOOL SetOpPermissionState = TRUE)
01408 
01409     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>

KernelBitmap * NodeBitmap::EnumerateBitmaps UINT32  Count  )  [virtual]
 

Find out what bitmaps, if any, are used by this node.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/17/95
Parameters:
Count - the bitmap to get (see Purpose). [INPUTS]
Returns:
The KernelBitmap in use by the node, or NULL if no more are used.
The base class returns NULL always, so you over-ride this in any node classes that use bitmaps.

This function supports nodes that use more than one bitmap - you call this function repeatedly and keep incrementing the Count parameter that you pass in each time by 1. You should stop calling it when it returns NULL, as this indicates that no more bitmaps are used by this node. Count should start off as 0 for the first call. Note that this function can (and often will) return NULL for the first call, as many nodes don't use bitmaps, obviously.

See also:
KernelBitmap

Reimplemented from Node.

Reimplemented in NodeAnimatingBitmap.

Definition at line 2444 of file nodebmp.cpp.

02450           :     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>

BOOL NodeBitmap::ExportRender RenderRegion pRegion  )  [virtual]
 

Export a bitmap object to a file.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
01/09/94
Parameters:
pRegion - the export render region to export to. [INPUTS]
Returns:
TRUE if the bitmap was exported ok; FALSE if not.

Errors: Usual disk/file errors.

See also:
Filter::ExportBitmap

Reimplemented from NodeRenderableInk.

Definition at line 625 of file nodebmp.cpp.

00626 {
00627 #ifdef DO_EXPORT
00628     if (pRegion->IsKindOf(CC_RUNTIME_CLASS(CamelotEPSRenderRegion)))
00629     {
00630         // Get valid transparency fill for this object
00631         CamelotEPSRenderRegion *pCamelotRegion = (CamelotEPSRenderRegion *) pRegion;
00632         pCamelotRegion->GetValidPathAttributes();
00633 
00634         // Output bitmap object position and keyword...
00635         EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC();
00636 
00637         DocCoord *Coords = InkPath.GetCoordArray();
00638 
00639 // Bodge Code
00640 
00641 // So this is some Bodge code to make Bitmaps in moulds, save themselves
00642 // correctly if a Line colour is applied to the Mould.
00643 
00644 // This line colour makes the Bitmap think it has been contoned, so we save out
00645 // a contoned version, which is looks incorrect when re-loaded.
00646 
00647 // To get around this problem, this code checks specifically for the situation,
00648 // and forces the bitmap to be saved as  a non-contoned version.
00649 
00650         BOOL CanSaveAsContoned = TRUE;
00651         BOOL LineColourIsAppliedToMould = FALSE;
00652 
00653         if (GetBitmap() && GetBitmap()->GetBPP() <= 8)
00654         {
00655             // We only need to worry about this for < 8BPP
00656             NodeAttribute* pLineAttr;
00657     
00658             // So we find the applied Stroke Colour ...
00659             if (FindAppliedAttribute(CC_RUNTIME_CLASS(AttrStrokeColour), &pLineAttr))
00660             {
00661                 Node* pParent = pLineAttr->FindParent();
00662                 
00663                 // And if it has been applied to a Mould ...
00664                 if (pParent && IS_A(pParent, NodeMould))
00665                 {
00666                     LineColourIsAppliedToMould = TRUE;
00667 
00668                     // and there is no Flat Colour Applied to the Bitmap,
00669                     // then this flag will be FALSE, stopping the bitmap
00670                     // from being saved as contone.
00671                     CanSaveAsContoned = (GetEndColour() != NULL);
00672                 }
00673             }
00674         }
00675 
00676         if (CanSaveAsContoned && (GetStartColour() || GetEndColour()))
00677         {
00678             // Must be a contone bitmap
00679 
00680             // If either the start or end colour is NULL, we need
00681             // to output a dummy colour, because 'No_Colour' doesn't
00682             // get saved
00683             if (LineColourIsAppliedToMould || GetStartColour() == NULL)
00684             {
00685                 DocColour StartCol;
00686                 AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
00687                                                     _R(IDS_BLACKNAME), &StartCol);
00688 
00689                 if (*GetEndColour() == StartCol)
00690                 {
00691                     AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
00692                                                         _R(IDS_WHITENAME), &StartCol);
00693                 }
00694 
00695                 // Output dummy start colour here
00696                 if (StartCol.FindParentIndexedColour() == NULL)
00697                 {
00698                     // Unnamed colour
00699                     PColourCMYK CMYK;
00700                     StartCol.GetCMYKValue(&CMYK);
00701                     pDC->OutputColour(&CMYK);
00702                     pDC->OutputToken(_T("K"));
00703                 }
00704                 else
00705                 {
00706                     // Named colour
00707                     pDC->OutputNamedColour(&StartCol);
00708                     pDC->OutputToken(_T("X"));
00709                 }
00710 
00711                 pDC->OutputNewLine();
00712             }
00713             else if (GetEndColour() == NULL)
00714             {
00715                 DocColour EndCol;
00716                 AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
00717                                                     _R(IDS_WHITENAME), &EndCol);
00718 
00719                 if (*GetStartColour() == EndCol)
00720                 {
00721                     AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
00722                                                         _R(IDS_BLACKNAME), &EndCol);
00723                 }
00724 
00725                 // Output dummy end colour here
00726                 if (EndCol.FindParentIndexedColour() == NULL)
00727                 {
00728                     // Unnamed colour
00729                     PColourCMYK CMYK;
00730                     EndCol.GetCMYKValue(&CMYK);
00731                     pDC->OutputColour(&CMYK);
00732                     pDC->OutputToken(_T("k"));
00733                 }
00734                 else
00735                 {
00736                     // Named colour
00737                     pDC->OutputNamedColour(&EndCol);
00738                     pDC->OutputToken(_T("x"));
00739                 }
00740 
00741                 pDC->OutputNewLine();
00742             }
00743         
00744             // Co-ords first,
00745             for (INT32 i = 0; i <= 3; i++)
00746                 pDC->OutputCoord(Coords[i]);
00747 
00748             // ...then the bitmap object token.
00749             pDC->OutputToken(_T("cbm"));
00750             pDC->OutputNewLine();
00751 
00752             // ...and then the bitmap data itself.
00753             pDC->GetParentFilter()->ExportBitmap(*GetBitmap());
00754         }
00755         else
00756         {
00757             // It's not a contone bitmap.
00758