OpCreateNodeBitmap Class Reference

Creates a new Node Bitmap, at a specific position on the page. More...

#include <nodebmp.h>

Inheritance diagram for OpCreateNodeBitmap:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

void DoWithParam (OpDescriptor *OpDesc, OpParam *pOpParam)
 Creates a new bitmap object.
virtual void GetOpName (String_256 *OpName)
 To get the name of the operation.
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

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

Private Member Functions

 CC_DECLARE_DYNCREATE (OpCreateNodeBitmap)

Detailed Description

Creates a new Node Bitmap, at a specific position on the page.

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

Definition at line 254 of file nodebmp.h.


Member Function Documentation

OpCreateNodeBitmap::CC_DECLARE_DYNCREATE OpCreateNodeBitmap   )  [private]
 

void OpCreateNodeBitmap::DoWithParam OpDescriptor OpDesc,
OpParam pOpParam
[virtual]
 

Creates a new bitmap object.

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

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 2762 of file nodebmp.cpp.

02777     {
02778         // It didn't use the bitmap we gave it, so we can delete it
02779         delete KernelBmp;
02780     }
02781 
02782     {
02783         DocRect BoundsRect;
02784         BitmapInfo Info;
02785 
02786         // Import worked - try to add the bitmap object into the tree.
02787         // First, set the rectangle to the right size for the bitmap...
02788         pNodeBitmap->GetBitmap()->ActualBitmap->GetInfo(&Info);
02789 
02790         // When pasting from XPE we don't have a docview, so fabricate 96dpi measurement (NB this gives
02791         // no remainder, just expressed as division to make derivation clear)
02792         FIXED16     pixHorz = NULL != pDocView ? pDocView->GetPixelWidth()  : FIXED16( 72000 / 96 );
02793         FIXED16     pixVert = NULL != pDocView ? pDocView->GetPixelHeight() : FIXED16( 72000 / 96 );
02794         const INT32 HPixelSize = ( pixHorz + 0.5 ).MakeLong();  // Size of output pixel in millipoints
02795         const INT32 VPixelSize = ( pixVert + 0.5 ).MakeLong();  // Size of output pixel in millipoints
02796 
02797         // Make sure that this is snapped to a pixel grid
02798         BoundsRect.lo.x = DropPos.x - ( Info.RecommendedWidth / 2 );
02799         BoundsRect.lo.y = DropPos.y - ( Info.RecommendedHeight / 2 );
02800         BoundsRect.lo.x = GridLock(BoundsRect.lo.x, HPixelSize);
02801         BoundsRect.lo.y = GridLock(BoundsRect.lo.y, VPixelSize);
02802         // And now add in the rest of the bounds
02803         BoundsRect.hi.x = BoundsRect.lo.x + Info.RecommendedWidth;
02804         BoundsRect.hi.y = BoundsRect.lo.y + Info.RecommendedHeight;
02805         BoundsRect.hi.x = GridLock(BoundsRect.hi.x, HPixelSize);
02806         BoundsRect.hi.y = GridLock(BoundsRect.hi.y, VPixelSize);
02807 
02808         // And set this in our bitmap node
02809         pNodeBitmap->CreateShape(BoundsRect);
02810 
02811         // Set the default attrs
02812         // This Must be done before the NodeBitmap is inserted into the tree
02813         if (!pNodeBitmap->ApplyDefaultBitmapAttrs(this))
02814             goto EndOp;
02815             
02816         // Insert the node
02817         if (!DoInsertNewNode(pNodeBitmap, pSpread, TRUE))
02818         {
02819             // It didn't work - delete the sub-tree we just created.
02820             delete pNodeBitmap;
02821             goto EndOp;
02822         }
02823     
02824         // Get the spread's bounding rectangle and convert it to spread coords.
02825         DocRect SpreadRect = pSpread->GetPasteboardRect();
02826         pSpread->DocCoordToSpreadCoord(&SpreadRect);
02827 
02828         // If bounding box off the spread - limit it to the edge of the spread:
02829 
02830         // (a) Horizontal adjustment
02831         DocCoord Offset(0,0);
02832         if (BoundsRect.lo.x < SpreadRect.lo.x)
02833             Offset.x += (SpreadRect.lo.x - BoundsRect.lo.x);
02834         else if (BoundsRect.hi.x > SpreadRect.hi.x)
02835             Offset.x -= (BoundsRect.hi.x - SpreadRect.hi.x);
02836 
02837         // (b) Vertical adjustment (most useful to clip hi co-ords)
02838         if (BoundsRect.hi.y > SpreadRect.hi.y)
02839             Offset.y -= (BoundsRect.hi.y - SpreadRect.hi.y);
02840         else
02841         if (BoundsRect.lo.y < SpreadRect.lo.y)
02842             Offset.y += (SpreadRect.lo.y - BoundsRect.lo.y);
02843 
02844         // Actually do the translation if needed
02845         if( 0 != Offset.x ||
02846             0 != Offset.y )
02847         {
02848             Offset.x = GridLock(Offset.x, HPixelSize);
02849             Offset.y = GridLock(Offset.y, VPixelSize);
02850 
02851             // Build the matrix and transform the bitmap to the correct place
02852             Trans2DMatrix Xlate(Offset.x, Offset.y);
02853             pNodeBitmap->Transform(Xlate);
02854         }
02855 
02856         // We can't do this without a docview
02857         if( NULL != pDocView )
02858         {
02859             // Does the bitmap fit with our current view?
02860             DocRect     docrectBounds = pNodeBitmap->GetBoundingRect();
02861             DocRect     docrectView = pDocView->GetDocViewRect( pSpread );
02862             pSpread->DocCoordToSpreadCoord( &docrectView );
02863             if( ( docrectBounds.lo.x < docrectView.lo.x ||
02864                   docrectBounds.lo.y < docrectView.lo.y ||
02865                   docrectBounds.hi.x > docrectView.hi.x ||
02866                   docrectBounds.hi.y > docrectView.hi.y ) &&
02867                   BaseBitmapFilter::GetZoomOnImport() )
02868             {
02869                 // Calculate bounding rect of view plus new photo and then make sure that edges in
02870                 // in both axes grow by same amount. We make use of the fact that zoom code only allows
02871                 // zooming in both axes by the same amount, so we don't need to make sure that growth in
02872                 // both axes is by the same percentage.
02873                 docrectBounds = docrectBounds.Union( docrectView );
02874                 if( docrectView.lo.x - docrectBounds.lo.x > docrectBounds.hi.x - docrectView.hi.x )
02875                     docrectBounds.hi.x = docrectView.hi.x + docrectView.lo.x - docrectBounds.lo.x;
02876                 else
02877                     docrectBounds.lo.x = docrectView.lo.x - docrectBounds.hi.x + docrectView.hi.x;
02878                 if( docrectView.lo.y - docrectBounds.lo.y > docrectBounds.hi.y - docrectView.hi.y )
02879                     docrectBounds.hi.y = docrectView.hi.y + docrectView.lo.y - docrectBounds.lo.y;
02880                 else
02881                     docrectBounds.lo.y = docrectView.lo.y - docrectBounds.hi.y + docrectView.hi.y;
02882                 
02883                 // No, zoom out so the all the bitmap can be seen
02884                 OpZoomFitRectDescriptor* pOpDesc = (OpZoomFitRectDescriptor*)OpDescriptor::FindOpDescriptor( OPTOKEN_ZOOMRECT );
02885                 if( NULL != pOpDesc )
02886                 {
02887                     pOpDesc->SetZoomRect( docrectBounds );
02888                     pOpDesc->Invoke();
02889                 }
02890 
02891                 // Keep user informed about the zoom operation
02892                 if( !BaseBitmapFilter::GetWarnedZoomOnImport() )
02893                 {
02894                     ErrorInfo   Info;
02895                     memset( &Info, 0, sizeof(Info) );
02896                     Info.ErrorMsg   = _R(IDS_ZOOM_ON_IMAGE_IMPORT);
02897                     Info.Button[0]  = _R(IDS_OK);
02898                     Info.Button[1]  = _R(IDS_DONT_SHOW_AGAIN);
02899                     Info.OK         = 1;
02900                     if( _R(IDS_DONT_SHOW_AGAIN) == UINT32(InformMessage( &Info )) )
02901                         BaseBitmapFilter::SetWarnedZoomOnImport( TRUE );
02902                 }
02903             }
02904         }
02905     }
02906 
02907     ok = TRUE;
02908 
02909 EndOp:
02910     if (!ok)
02911         FailAndExecute();
02912 
02913     End();
02914 }
02915 
02916 void OpCreateNodeBitmap::GetOpName(String_256* OpName)
02917 {
02918     OpName->Load(_R(IDS_K_NODEBMP_CREATEBITMAP));
02919 }
02920 

void OpCreateNodeBitmap::GetOpName String_256 OpName  )  [virtual]
 

To get the name of the operation.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/93
Parameters:
The name of the operation [OUTPUTS]

Reimplemented from Operation.

Definition at line 2922 of file nodebmp.cpp.

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

For finding the OpCreateNodeBitmap's state.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/1/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpCreateNodeBitmap operation

Errors: -

See also:
-

Definition at line 2737 of file nodebmp.cpp.

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

BOOL OpCreateNodeBitmap::Init void   )  [static]
 

OpCreateNodeBitmap initialiser method.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/1/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 2709 of file nodebmp.cpp.

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

virtual BOOL OpCreateNodeBitmap::MayChangeNodeBounds  )  const [inline, virtual]
 

Reimplemented from UndoableOperation.

Definition at line 267 of file nodebmp.h.

00267 { return TRUE; }


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