BfxOp Class Reference

Handles insertion of bitmap effect nodes into the tree. More...

#include <bfxdlg.h>

Inheritance diagram for BfxOp:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BfxOp ()
 BfxOp constructor.
void DoWithParam (OpDescriptor *pOp, OpParam *pParam)
 Performs the BfxOp for the first time.

Static Public Member Functions

static BOOL Init ()
 BlobyOp initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the BfxOp's state.

Protected Member Functions

BOOL FindCentreInsertionPosition (Spread **Spread, DocCoord *Position)
 Finds the centre insertion position for clipboard objects.

Detailed Description

Handles insertion of bitmap effect nodes into the tree.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/02/94

Definition at line 146 of file bfxdlg.h.


Constructor & Destructor Documentation

BfxOp::BfxOp  ) 
 

BfxOp constructor.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1718 of file bfxdlg.cpp.

01718             : UndoableOperation()  
01719 {                                
01720 }


Member Function Documentation

void BfxOp::DoWithParam OpDescriptor pOp,
OpParam pParam
[virtual]
 

Performs the BfxOp for the first time.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Parameters:
OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-
Blatantly copied from BitFilt::DoImportBitmap

Reimplemented from Operation.

Definition at line 1791 of file bfxdlg.cpp.

01792 {               
01793     DocCoord DropPos;
01794     Spread * pSpread;
01795     BOOL ok=FALSE;
01796     
01797     if (!GetWorkingDoc()) return;
01798     
01799     if (!FindCentreInsertionPosition(&pSpread, &DropPos))
01800     {
01801         InformError();
01802         FailAndExecute();
01803         End();
01804         return;
01805     }
01806 
01807     // Get a new NodeBitmap object to import into.
01808     NodeBitmap *pNodeBitmap = new NodeBitmap;
01809     if ((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12)))
01810     {
01811         InformError();      
01812         FailAndExecute();
01813         End();
01814         return;
01815     }
01816 
01817     KernelBitmap* pKB = *(((BfxOpParam *)(pParam))->ppBitmap);
01818     if (pKB == NULL)
01819     {
01820         // Bitmap is NULL, so the op must have failed
01821         delete pNodeBitmap;
01822         FailAndExecute();
01823         End();
01824         return;
01825     }
01826     
01827     // Put up a progress display/hourglass (FALSE => no delay, show it NOW!)
01828     BeginSlowJob(100, FALSE);
01829     *(((BfxOpParam *)(pParam))->ppBitmap) = NULL; // The bitmap is now the responsibility of this routine
01830 
01831     // The bitmap above is a temp bitmap, so we'll extract the OILBitmap (which will delete the KBmp),
01832     // and create a 'proper' kbmp to attach to the node
01833     OILBitmap* pOILBmp = pKB->ExtractOILBitmap();
01834     pKB = KernelBitmap::MakeKernelBitmap(pOILBmp, GetWorkingDoc());
01835 
01836     pNodeBitmap->GetBitmapRef()->Attach(pKB);
01837 
01838     if (pNodeBitmap->GetBitmap() != pKB)
01839     {
01840         // It didn't use the bitmap we gave it, so we can delete it
01841         delete pKB;
01842     }
01843 
01844     // First, set the rectangle to the right size for the bitmap...
01845     BitmapInfo Info;
01846     pNodeBitmap->GetBitmap()->ActualBitmap->GetInfo(&Info);
01847 
01848     DocRect BoundsRect;
01849     BoundsRect.lo.x = DropPos.x - (Info.RecommendedWidth/2);
01850     BoundsRect.lo.y = DropPos.y - (Info.RecommendedHeight/2);
01851     BoundsRect.hi.x = BoundsRect.lo.x + Info.RecommendedWidth;
01852     BoundsRect.hi.y = BoundsRect.lo.y + Info.RecommendedHeight;
01853 
01854     // And set this in our bitmap node
01855     pNodeBitmap->CreateShape(BoundsRect);
01856 
01857     // Apply some default attrs for the bitmap
01858     // This Must be done before the NodeBitmap is inserted into the tree
01859     if (!pNodeBitmap->ApplyDefaultBitmapAttrs(this))
01860     {
01861         goto EndOp;
01862     }
01863         
01864     // Insert the node
01865     if (!DoInsertNewNode(pNodeBitmap, pSpread, TRUE))
01866     {
01867         // It didn't work - delete the sub-tree we just created.
01868         delete pNodeBitmap;
01869         goto EndOp;
01870     }
01871 
01872     ok = TRUE;
01873 
01874 EndOp:
01875     if (!ok)
01876     {
01877         FailAndExecute();
01878         InformError();
01879     }
01880 
01881     EndSlowJob();
01882     End();
01883 }

BOOL BfxOp::FindCentreInsertionPosition Spread **  Spread,
DocCoord Position
[protected]
 

Finds the centre insertion position for clipboard objects.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/3/95
Parameters:
- [INPUTS]
Spread,: The spread to place the clipboard objects on [OUTPUTS] Position:The centre of the view (Spread coords)
Returns:
TRUE if succeeded else FALSE

Errors: ERROR2 in various situations Scope: private

See also:
-

Definition at line 1902 of file bfxdlg.cpp.

01903 {
01904     // Let's chuck in a smattering of defensive programming
01905     ERROR3IF(Spread == NULL || Position == NULL, "Illegal NULL params");
01906     *Spread = NULL;
01907     *Position = DocCoord(0,0);  // A default value if we fail
01908 
01909     // ---------------------------------------------------------------------------------
01910     // Find out which spread is in the centre of the view 
01911     // this is the spread that the pasted objects will be placed on
01912 
01913     ERROR2IF((!Spread)||(!Position),FALSE,"Invalid call to FindCentreInsertionPoint()");
01914     // Obtain the current DocView
01915     DocView* CurDocView = GetWorkingDocView();
01916 
01917     ERROR2IF(!CurDocView, FALSE, "The current DocView is NULL"); 
01918 
01919     WorkRect WrkViewRect = CurDocView->GetViewRect();
01920 
01921     ERROR2IF((WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) ), FALSE, "Invalid WorkRect");
01922     
01923     // Determine the centre of the view
01924     WorkCoord WrkCentreOfView; 
01925     WrkCentreOfView.x = WrkViewRect.lox + (WrkViewRect.Width()/2); 
01926     WrkCentreOfView.y = WrkViewRect.loy + (WrkViewRect.Height()/2);
01927     
01928     // FindEnclosing spread requires an OilCoord
01929     OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets()); 
01930 
01931     // Find out which spread to insert the pasteboard objects onto
01932     (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
01933     ERROR2IF(!(*Spread), FALSE, "No spread?!");
01934 
01935     // Phew
01936     // ---------------------------------------------------------------------------------
01937     // Now lets find the spread coordinate of the centre of the view
01938     DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
01939 
01940     ERROR2IF( ( (DocViewRect.IsEmpty()) || !(DocViewRect.IsValid())), FALSE, "DocViewRect is invalid" );
01941 
01942     // Find the centre of the DocViewRect
01943     DocCoord DocCentreOfView; 
01944     DocCentreOfView.x = DocViewRect.lox + (DocViewRect.Width()/2); 
01945     DocCentreOfView.y = DocViewRect.loy + (DocViewRect.Height()/2);
01946 
01947     // Now convert from DocCoords to spread coords
01948     (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView);
01949 
01950     // Finally, fill in the return value
01951     *Position = DocCentreOfView;
01952     
01953     return TRUE;  
01954 }

OpState BfxOp::GetState String_256 ,
OpDescriptor
[static]
 

For finding the BfxOp's state.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the BfxOp

Errors: -

See also:
-

Definition at line 1768 of file bfxdlg.cpp.

01769 {    
01770     OpState OpSt;
01771     return(OpSt);
01772 }

BOOL BfxOp::Init void   )  [static]
 

BlobyOp initialiser method.

Author:
Alex_Bligh (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Parameters:
- [INPUTS]
- [OUTPUTS]
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 1740 of file bfxdlg.cpp.

01741 {  
01742     return (UndoableOperation::RegisterOpDescriptor(
01743                                             0,
01744                                             _R(IDS_BFXOP),
01745                                             CC_RUNTIME_CLASS(BfxOp),
01746                                             OPTOKEN_BFXOP,
01747                                             BfxOp::GetState,
01748                                             0,  /* help ID */
01749                                             0,  /* bubble help ID */
01750                                             0   /* bitmap ID */)); 
01751 }


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