#include <backgrnd.h>
Inheritance diagram for OpBackground:
Public Member Functions | |
OpBackground () | |
Default constructor. | |
~OpBackground () | |
Default destructor. | |
virtual void | DoWithParam (OpDescriptor *pOpDesc, OpParam *pParam) |
This function is used to create a guideline in the selected spread. It calls DoAddNewGuideline() with pParam->Param1 specifying the guideline type. | |
void | GetOpName (String_256 *OpName) |
Returns a desc of the op. Mainly used to fill in the menu item for the undo/redo ops. | |
Static Public Member Functions | |
static BOOL | Init () |
Called when the op is undone. This broadcasts a 'Guidelines changed' layer message Called when the op is redone. This broadcasts a 'Guidelines changed' layer message Registers an op desc for this op. | |
static OpState | GetState (String_256 *Description, OpDescriptor *) |
Func for determining the usability of this op. | |
static BOOL | FixBackgroundLayer (Layer *pLayer, const DocRect &NewPagesRect, const DocRect &OldPagesRect) |
This tries to fix up the special page background layer so that the rectangle on it is resized to the cover the newly resized pages on the spread. | |
static BOOL | MakePageBackground (UndoableOperation *pOp, Spread *pSpread, DocColour *pDocColour) |
Tries to apply the DocColour or bitmap as a new page background. | |
static BOOL | MakePageBackground (UndoableOperation *pOp, Spread *pSpread, KernelBitmap *pBitmap) |
Tries to apply the DocColour or bitmap as a new page background. | |
static BOOL | GetPageColour (Spread *pSpread, KernelBitmap **pOutBitmap, DocColour **pOutColour) |
Gets the page's fill attribute, which could only be either a colour, or a bitmap. | |
Static Protected Member Functions | |
static BOOL | DoMakePageBackground (UndoableOperation *pOp, Spread *pSpread, KernelBitmap *pBitmap, DocColour *pDocColour=NULL) |
Tries to apply the DocColour or bitmap as a new page background. | |
static Layer * | CreateBackgroundLayer () |
This does everything required in creating a layer fit to be called the background layer. | |
static Layer * | DoCreateBackgroundLayer (UndoableOperation *pOp, Spread *pSpread) |
This returns a ptr to the background layer. | |
static NodeRegularShape * | DoFindPageRectangle (Spread *pSpread, Layer *pBackgroundLayer) |
Tries to find the page filling rectangle on the specified layer. | |
static NodeRegularShape * | DoCreateRectangle (Spread *pSpread) |
Returns a new rectangle the size of the current spread. | |
static NodeRegularShape * | FindPageRectangle (Layer *pBackgroundLayer, const DocRect &PagesRect) |
Tries to find the page filling rectangle on the specified layer. | |
static BOOL | ApplyDocColour (DocColour *pColourToApply, NodeRegularShape *pShape) |
Applies the specified colour to the specified NodeRegularShape. | |
static BOOL | ApplyBitmap (KernelBitmap *pBitmapToApply, NodeRegularShape *pShape) |
Applies the specified bitmap to the specified NodeRegularShape. | |
static BOOL | ApplyDefaultAttributes (NodeRegularShape *pShape) |
Applies some useful default attributes to the specified NodeRegularShape. | |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpBackground) |
Definition at line 150 of file backgrnd.h.
|
Default constructor.
Definition at line 144 of file backgrnd.cpp. 00145 { 00146 // m_pDoc = NULL; 00147 // m_pSpread = NULL; 00148 // m_pDocColour = NULL; 00149 // m_pBitmap = NULL; 00150 00151 // Versions of the parameters used in the drag and drop process 00152 // m_pDroppedBitmap = NULL; 00153 // m_pDroppedDocColour = NULL; 00154 }
|
|
Default destructor.
Definition at line 171 of file backgrnd.cpp.
|
|
Applies the specified bitmap to the specified NodeRegularShape.
Definition at line 628 of file backgrnd.cpp. 00629 { 00630 ERROR2IF(pBitmapToApply == NULL || pShape == NULL,FALSE,"OpBackground::ApplyBitmap Bar params!"); 00631 00632 // Set up a fill colour attribute 00633 AttrBitmapColourFill *pBitmapFillAttr = new AttrBitmapColourFill(); 00634 if (pBitmapFillAttr == NULL) 00635 { 00636 InformError(); 00637 return(FALSE); 00638 } 00639 00640 // Set the coordinates of the fill end points 00641 // We want to start the fill at the top left of the regular shape 00642 // The bounding rect should be roughly what we want 00643 DocRect Rect = pShape->GetBoundingRect(TRUE, FALSE); 00644 00645 // Get the size of the bitmap taking into account its DPI 00646 INT32 Width = pBitmapToApply->GetRecommendedWidth(); 00647 INT32 Height = pBitmapToApply->GetRecommendedHeight(); 00648 // You would think that the handles on the fill correspond to where you place them 00649 // but oh now the displayed handles are shown at different points. So instead of 00650 // positioning the start in the centre of the bitmap, you need to position it bottom left 00651 // The End should be centre and right but needs to be bottom right. 00652 // The End2 should be centre and top but needs to be top left. 00653 00654 // We want the start point to be half the height of the bitmap below this 00655 //DocCoord Start(Rect.lo.x + Width/2, Rect.hi.y - Height/2); 00656 DocCoord Start(Rect.lo.x, Rect.hi.y - Height); 00657 // We want the other end point to be same height as the centre point 00658 // but on the far right of the rectangle i.e the full width across 00659 //DocCoord End(Rect.lo.x + Width, Rect.hi.y - Height/2); 00660 DocCoord End(Rect.lo.x + Width, Rect.hi.y - Height); 00661 // We want the end point to be middle and top of the rectangle 00662 //DocCoord End2(Rect.lo.x + Width/2, Rect.hi.y); 00663 DocCoord End2(Rect.lo.x, Rect.hi.y); 00664 00665 ((AttrFillGeometry*)pBitmapFillAttr)->SetStartPoint(&Start); 00666 ((AttrFillGeometry*)pBitmapFillAttr)->SetEndPoint(&End); 00667 ((AttrFillGeometry*)pBitmapFillAttr)->SetEndPoint2(&End2); 00668 00669 // Now attach the correct bitmap to the fill 00670 ((AttrFillGeometry*)pBitmapFillAttr)->AttachBitmap(pBitmapToApply); 00671 00672 // And now insert it as a child of the regular shape 00673 // Factoring should be ok as the Regular Shape is assumed to be the child of 00674 // layer 00675 pBitmapFillAttr->AttachNode(pShape, FIRSTCHILD); 00676 00677 return TRUE; 00678 }
|
|
Applies some useful default attributes to the specified NodeRegularShape.
Definition at line 694 of file backgrnd.cpp. 00695 { 00696 ERROR2IF(pShape == NULL,FALSE,"OpBackground::ApplyDefaultAttributes Bar params!"); 00697 00698 // ***** 00699 // Set up a no colour line colour 00700 AttrStrokeColour * pLineColAttr = new AttrStrokeColour(); 00701 if (pLineColAttr == NULL) 00702 { 00703 InformError(); 00704 return(FALSE); 00705 } 00706 00707 DocColour ColNone(COLOUR_NONE); 00708 ((AttrFillGeometry*)pLineColAttr)->SetStartColour(&ColNone); 00709 // And now insert it as a child of the regular shape 00710 // Factoring should be ok as the Regular Shape is assumed to be the child of 00711 // layer 00712 pLineColAttr->AttachNode(pShape, LASTCHILD); 00713 00714 00715 00716 // ***** 00717 // Set up a line width attribute 00718 AttrLineWidth *pLineWidthAttr = new AttrLineWidth(); 00719 if (pLineWidthAttr == NULL) 00720 { 00721 InformError(); 00722 return(FALSE); 00723 } 00724 00725 ((AttrLineWidth*)pLineWidthAttr)->Value.LineWidth = 0; 00726 00727 // And now insert it as a child of the regular shape 00728 // Factoring should be ok as the Regular Shape is assumed to be the child of 00729 // layer 00730 pLineWidthAttr->AttachNode(pShape, LASTCHILD); 00731 00732 00733 // ***** 00734 // Set up a join type attribute 00735 AttrJoinType * pJoinTypeAttr = new AttrJoinType(); 00736 if (pLineWidthAttr == NULL) 00737 { 00738 InformError(); 00739 return(FALSE); 00740 } 00741 00742 // We will use a default constructed one as this should be vaguely correct 00743 // ((AttrLineWidth*)pJoinTypeAttr)->Value.LineWidth = 0; 00744 00745 // And now insert it as a child of the regular shape 00746 // Factoring should be ok as the Regular Shape is assumed to be the child of 00747 // layer 00748 pJoinTypeAttr->AttachNode(pShape, LASTCHILD); 00749 00750 return TRUE; 00751 }
|
|
Applies the specified colour to the specified NodeRegularShape.
Definition at line 591 of file backgrnd.cpp. 00592 { 00593 ERROR2IF(pColourToApply == NULL || pShape == NULL,FALSE,"OpBackground::ApplyDocColour Bar params!"); 00594 00595 // Set up a fill colour attribute 00596 AttrFlatColourFill *pFillColAttr = new AttrFlatColourFill(); 00597 if (pFillColAttr == NULL) 00598 { 00599 InformError(); 00600 return(FALSE); 00601 } 00602 00603 ((AttrFillGeometry*)pFillColAttr)->SetStartColour(pColourToApply); 00604 00605 // And now insert it as a child of the regular shape 00606 // Factoring should be ok as the Regular Shape is assumed to be the child of 00607 // layer 00608 pFillColAttr->AttachNode(pShape, FIRSTCHILD); 00609 00610 return TRUE; 00611 }
|
|
|
|
This does everything required in creating a layer fit to be called the background layer.
Definition at line 827 of file backgrnd.cpp. 00828 { 00829 Layer* pNewLayer = new Layer; 00830 if (pNewLayer != NULL) 00831 { 00832 String_256 LayerName(_R(IDS_BACKGROUNDLAYERNAME)); 00833 00834 pNewLayer->SetVisible(TRUE); 00835 pNewLayer->SetLocked(TRUE); 00836 pNewLayer->SetPrintable(FALSE); 00837 pNewLayer->SetBackground(TRUE); 00838 pNewLayer->SetOutline(FALSE); 00839 pNewLayer->SetGuide(FALSE); 00840 pNewLayer->SetPageBackground(TRUE); // This is the special page background layer flag 00841 pNewLayer->SetLayerID(LayerName); 00842 00843 /* // Ensure we are always rendered at maximum quality so that turning WYSIWYG 00844 // down does not remove the page background! 00845 Quality Qual; 00846 Qual.SetQuality(QUALITY_MAX); 00847 QualityAttribute QualAttr(Qual); 00848 NodeAttribute* pNodeAttr = QualAttr.MakeNode(); 00849 pNodeAttr->AttachNode(pNewLayer, FIRSTCHILD); */ 00850 } 00851 00852 return pNewLayer; 00853 }
|
|
This returns a ptr to the background layer.
If there isn't a background layer, it is created and inserted into the doc tree. If this fails the func returns NULL
Definition at line 775 of file backgrnd.cpp. 00776 { 00777 ERROR2IF(pOp == NULL || pSpread == NULL,FALSE,"OpBackground::DoCreateBackgroundLayer Bad params error!"); 00778 00779 // Search for our special page background layer 00780 Layer* pFoundLayer = pSpread->FindFirstPageBackgroundLayer(); 00781 // If we have found it then return this to the caller as we don't want 00782 // more than one present! 00783 if (pFoundLayer != NULL) 00784 return pFoundLayer; 00785 00786 // We didn't find a page background layer so go and create a new one 00787 Layer* pNewLayer = CreateBackgroundLayer(); 00788 if (pNewLayer != NULL) 00789 { 00790 // If we insert the new layer as the FIRSTCHILD then this will be like the guidelayer 00791 // and behind the page. If we insert as the last child then we will be at the front of 00792 // the stacking order. We need to insert ourselves as the node after the last page node 00793 Page *pLastPage = pSpread->FindLastPageInSpread(); 00794 00795 // Insert the new layer as the next node after the last page. 00796 if (pLastPage && pOp->DoInsertNewNode(pNewLayer, pLastPage, NEXT, FALSE,FALSE,FALSE,FALSE)) 00797 { 00798 pNewLayer->EnsureUniqueLayerID(); 00799 BROADCAST_TO_ALL(SpreadMsg(pSpread, SpreadMsg::LAYERCHANGES)); 00800 } 00801 else 00802 { 00803 delete pNewLayer; 00804 pNewLayer = NULL; 00805 } 00806 } 00807 00808 return pNewLayer; 00809 }
|
|
Returns a new rectangle the size of the current spread.
Definition at line 524 of file backgrnd.cpp. 00525 { 00526 ERROR2IF(pSpread == NULL,FALSE,"OpBackground::DoCreateRectangle Bad params error!"); 00527 00528 if (pSpread == NULL) 00529 return NULL; 00530 00531 // This assumes that we have already checked to see if there is a page covering rectangle 00532 // already present on this layer. 00533 00534 // Create a new rectangle node on the layer 00535 NodeRegularShape *pShape = new NodeRegularShape; 00536 if (pShape != NULL) 00537 { 00538 BOOL ok = pShape->SetUpShape(); 00539 00540 if (!ok) 00541 { 00542 // Do something sensible in here 00543 delete pShape; 00544 return NULL; 00545 } 00546 00547 // We want to make the rectangle the same size as the current union of 00548 // all the pages on the current spread 00549 DocRect Rect; 00550 pSpread->GetPagesRect(&Rect); 00551 00552 /* // We must expand the rectangle by a single pixel as the page redraw 00553 // draws a single pixel line around the outside. 00554 const MILLIPOINT pixel = (MILLIPOINT)(72000.0/96.0); 00555 Rect.Inflate(pixel); */ 00556 00557 const INT32 CornerRadius = 0; // No curvature 00558 00559 if (pShape->MakeRectangle(Rect.Width(), Rect.Height(), CornerRadius)) 00560 { 00561 // Translate centre from 0,0 to required position relative to page 00562 INT32 XTrans = Rect.lo.x + (Rect.Width()/2); 00563 INT32 YTrans = Rect.lo.y + (Rect.Height()/2); 00564 Trans2DMatrix Trans(XTrans, YTrans); 00565 00566 pShape->Transform(Trans); 00567 00568 // finish off the shape 00569 pShape->InvalidateBoundingRect(); 00570 } 00571 } 00572 00573 return pShape; 00574 }
|
|
Tries to find the page filling rectangle on the specified layer.
Definition at line 443 of file backgrnd.cpp. 00444 { 00445 if (pSpread == NULL || pBackgroundLayer == NULL) 00446 return NULL; 00447 00448 // We want to find the rectangle which should be the same size as the current union of 00449 // all the pages on the current spread 00450 DocRect PagesRect; 00451 pSpread->GetPagesRect(&PagesRect); 00452 00453 return FindPageRectangle(pBackgroundLayer, PagesRect); 00454 }
|
|
Tries to apply the DocColour or bitmap as a new page background.
Definition at line 303 of file backgrnd.cpp. 00305 { 00306 TRACEUSER("Gerry", _T("OpBackground::DoMakePageBackground")); 00307 00308 // Our inputs are actually set up in the class variables, so check them 00309 ERROR2IF(pSpread == NULL || pOp == NULL,FALSE,"DoMakePageBackground Bad params!"); 00310 ERROR2IF(pDocColour == NULL && pBitmap == NULL,FALSE,"DoMakePageBackground Bad params!"); 00311 00312 BOOL ok = TRUE; 00313 Page *pPage = pSpread->FindFirstPageInSpread (); 00314 DocRect Bounds = pPage->GetPageRect (); 00315 00316 // If there's a transparent background colour, just hide the existing node. 00317 if ( pDocColour != NULL && pDocColour->IsTransparent () ) 00318 { 00319 Layer* pOldLayer = pSpread->FindFirstPageBackgroundLayer (); 00320 00321 // Attempt to remove the old background layer. 00322 if ( pOldLayer != NULL ) 00323 { 00324 TRACEUSER("Gerry", _T("Removing old background")); 00325 if ( !pOp->DoHideNode(pOldLayer, TRUE ) ) 00326 { 00327 // Something went wrong, so handle the error. 00328 ERROR3( "OpBackground failed to hide the old page background" ); 00329 pOp->FailAndExecute (); 00330 ok = FALSE; 00331 } 00332 } 00333 } 00334 00335 // Otherwise create a new background layer. 00336 else 00337 { 00338 TRACEUSER("Gerry", _T("Creating new background")); 00339 Layer* pBackgroundLayer = DoCreateBackgroundLayer(pOp, pSpread); 00340 00341 if (pBackgroundLayer == NULL) 00342 { 00343 ERROR3("Something went wrong with the layer creation"); 00344 pOp->FailAndExecute(); 00345 ok = FALSE; 00346 } 00347 else 00348 { 00349 // Try and find an existing page filling rectangle on this layer 00350 NodeRegularShape * pShape = DoFindPageRectangle(pSpread, pBackgroundLayer); 00351 00352 // If not found then create a new one 00353 if (pShape != NULL) 00354 { 00355 // Hide the old version of the rectangle 00356 if (!pOp->DoHideNode(pShape, TRUE)) 00357 { 00358 ERROR3("OpBackground failed to hide the old node"); 00359 pOp->FailAndExecute(); 00360 ok = FALSE; 00361 } 00362 } 00363 00364 if (ok) 00365 { 00366 // Make a new rectangle of the correct size 00367 pShape = DoCreateRectangle(pSpread); 00368 00369 // Apply the bitmap or the colour to it before we insert it into the tree. 00370 if (pDocColour) 00371 { 00372 // Set the colour to be the background. 00373 ok = ApplyDocColour(pDocColour, pShape); 00374 } 00375 else if (pBitmap) 00376 { 00377 ok = ApplyBitmap(pBitmap, pShape); 00378 } 00379 else 00380 { 00381 ERROR3("OpBackground Haven't got anything to apply"); 00382 pOp->FailAndExecute(); 00383 ok = FALSE; 00384 } 00385 00386 // Apply a useful set of default attibutes on top of the fill colour 00387 // or bitmap fill. 00388 if ( pShape != NULL ) 00389 { 00390 ApplyDefaultAttributes(pShape); 00391 } 00392 } 00393 00394 // We must make the layer unlocked so that we don't get the stupid 00395 // inserting on locked layer message 00396 pBackgroundLayer->SetLocked(FALSE); 00397 00398 // And now insert it into the background layer 00399 if (ok && !pOp->DoInsertNewNode(pShape, pBackgroundLayer, FIRSTCHILD,FALSE, 00400 FALSE,FALSE,FALSE)) 00401 { 00402 delete pShape; 00403 pShape = NULL; 00404 pOp->FailAndExecute(); 00405 ok = FALSE; 00406 } 00407 00408 // Set the layer back to locked as we have finished inserting onto the layer 00409 pBackgroundLayer->SetLocked(TRUE); 00410 00411 // Since we prevented DoInsertnewNode from invalidating, it won't have cleared 00412 // the cache appropriately so we will have to do that ourselves... 00413 if (ok) 00414 pBackgroundLayer->ReleaseCached(); 00415 } 00416 } 00417 00418 // Force a redraw of the new background layer. 00419 if ( ok && !pOp->DoInvalidateRegion ( pSpread, Bounds ) ) 00420 { 00421 pOp->FailAndExecute(); 00422 ok = FALSE; 00423 } 00424 00425 return ok; 00426 }
|
|
This function is used to create a guideline in the selected spread. It calls DoAddNewGuideline() with pParam->Param1 specifying the guideline type.
Reimplemented from Operation. Definition at line 191 of file backgrnd.cpp. 00192 { 00193 ERROR3IF(pParam == NULL,"pParam is NULL"); 00194 00195 TRACEUSER("Gerry", _T("OpBackground::DoWithParam")); 00196 00197 if (pParam != NULL) 00198 { 00199 BOOL ok = TRUE; 00200 00201 OpBackgroundParam* pOpBackgroundParam = (OpBackgroundParam*)pParam; 00202 // Document * pDoc = pOpBackgroundParam->pDoc; 00203 Spread * pSpread = pOpBackgroundParam->pSpread; 00204 DocColour * pDocColour = pOpBackgroundParam->pDocColour; 00205 KernelBitmap * pBitmap = pOpBackgroundParam->pBitmap; 00206 00207 // If no spread is given then use the selected one 00208 if (pSpread == NULL) 00209 { 00210 // We will work off the currently selected spread 00211 pSpread = Document::GetSelectedSpread(); 00212 } 00213 00214 // Go and do the job of making the page background 00215 ok = DoMakePageBackground(this, pSpread, pBitmap, pDocColour); 00216 } 00217 00218 End(); 00219 }
|
|
Tries to find the page filling rectangle on the specified layer.
Definition at line 471 of file backgrnd.cpp. 00472 { 00473 ERROR2IF(pBackgroundLayer == NULL,FALSE,"OpBackground::FindPageRectangle Bad params error!"); 00474 00475 NodeRegularShape *pShape = NULL; 00476 NodeRegularShape *pRegNode = NULL; 00477 Node * pNode = pBackgroundLayer->FindFirstChild(); 00478 DocRect rect; 00479 const MILLIPOINT delta = 1000; 00480 while (pNode != NULL) 00481 { 00482 // Only check regular shape nodes 00483 if (pNode->IS_KIND_OF(NodeRegularShape)) 00484 { 00485 // Only check rectangles 00486 pRegNode = (NodeRegularShape *)pNode; 00487 if (pRegNode->IsARectangle()) 00488 { 00489 //DocCoord MinorAxis NodeRegularShape::GetMinorAxes(); 00490 // The bounding rect should be roughly what we want 00491 rect = pRegNode->GetBoundingRect(TRUE, FALSE); 00492 if ( 00493 (PagesRect.lo.x > rect.lo.x - delta) && (PagesRect.lo.x < rect.lo.x + delta) && 00494 (PagesRect.hi.x > rect.hi.x - delta) && (PagesRect.hi.x < rect.hi.x + delta) && 00495 (PagesRect.lo.y > rect.lo.y - delta) && (PagesRect.lo.y < rect.lo.y + delta) && 00496 (PagesRect.hi.y > rect.hi.y - delta) && (PagesRect.hi.y < rect.hi.y + delta) 00497 ) 00498 { 00499 pShape = pRegNode; 00500 } 00501 } 00502 } 00503 00504 pNode = pNode->FindNext(); 00505 } 00506 00507 return pShape; 00508 }
|
|
This tries to fix up the special page background layer so that the rectangle on it is resized to the cover the newly resized pages on the spread.
Definition at line 873 of file backgrnd.cpp. 00875 { 00876 ERROR2IF(pBackgroundLayer == NULL,FALSE,"OpBackground::FixBackgroundLayer Bad params!"); 00877 00878 //BOOL ok = TRUE; 00879 00880 // There should be a rectangle on the page encompassing the old position of the pages 00881 // so go and try and find it 00882 NodeRegularShape * pShape = FindPageRectangle(pBackgroundLayer, OldPagesRect); 00883 // If no rectangle is found then something might be slightly wrong. Should we error? 00884 if (pShape) 00885 { 00886 const INT32 CornerRadius = 0; // No curvature 00887 if (pShape->MakeRectangle(NewPagesRect.Width(), NewPagesRect.Height(), CornerRadius)) 00888 { 00889 // Translate centre from 0,0 to required position relative to page 00890 INT32 XTrans = NewPagesRect.lo.x + (NewPagesRect.Width()/2); 00891 INT32 YTrans = NewPagesRect.lo.y + (NewPagesRect.Height()/2); 00892 Trans2DMatrix Trans(XTrans, YTrans); 00893 00894 pShape->Transform(Trans); 00895 00896 // finish off the shape 00897 pShape->InvalidateBoundingRect(); 00898 } 00899 00900 // Find any bitmap fills and fix up the fill origin etc. 00901 Node * pNode = pShape->FindFirstChild(); 00902 while (pNode != NULL) 00903 { 00904 // Only check and fix bitmap colour fill attributes of the regular shape nodes 00905 if (pNode->IS_KIND_OF(AttrBitmapColourFill)) 00906 { 00907 // Convert the pointer to the correct type 00908 AttrBitmapColourFill * pBitmapFillAttr = (AttrBitmapColourFill*)pNode; 00909 00910 // Set the coordinates of the fill end points 00911 // We want to start the fill at the top left of the regular shape 00912 // The bounding rect should be roughly what we want 00913 DocRect Rect = pShape->GetBoundingRect(TRUE, FALSE); 00914 00915 KernelBitmap * pBitmap = ((AttrFillGeometry*)pBitmapFillAttr)->GetBitmap(); 00916 // Get the size of the bitmap taking into account its DPI 00917 INT32 Width = pBitmap->GetRecommendedWidth(); 00918 INT32 Height = pBitmap->GetRecommendedHeight(); 00919 // You would think that the handles on the fill correspond to where you place them 00920 // but oh now the displayed handles are shown at different points. So instead of 00921 // positioning the start in the centre of the bitmap, you need to position it bottom left 00922 // The End should be centre and right but needs to be bottom right. 00923 // The End2 should be centre and top but needs to be top left. 00924 00925 // We want the start point to be half the height of the bitmap below this 00926 //DocCoord Start(Rect.lo.x + Width/2, Rect.hi.y - Height/2); 00927 DocCoord Start(Rect.lo.x, Rect.hi.y - Height); 00928 // We want the other end point to be same height as the centre point 00929 // but on the far right of the rectangle i.e the full width across 00930 //DocCoord End(Rect.lo.x + Width, Rect.hi.y - Height/2); 00931 DocCoord End(Rect.lo.x + Width, Rect.hi.y - Height); 00932 // We want the end point to be middle and top of the rectangle 00933 //DocCoord End2(Rect.lo.x + Width/2, Rect.hi.y); 00934 DocCoord End2(Rect.lo.x, Rect.hi.y); 00935 00936 ((AttrFillGeometry*)pBitmapFillAttr)->SetStartPoint(&Start); 00937 ((AttrFillGeometry*)pBitmapFillAttr)->SetEndPoint(&End); 00938 ((AttrFillGeometry*)pBitmapFillAttr)->SetEndPoint2(&End2); 00939 } 00940 00941 pNode = pNode->FindNext(); 00942 } 00943 } 00944 00945 return TRUE; 00946 }
|
|
Returns a desc of the op. Mainly used to fill in the menu item for the undo/redo ops.
Reimplemented from Operation. Definition at line 1131 of file backgrnd.cpp. 01132 { 01133 *OpName = String_256(_R(IDS_UNDO_SETBACKGROUND)); 01134 }
|
|
Gets the page's fill attribute, which could only be either a colour, or a bitmap.
Definition at line 964 of file backgrnd.cpp. 00966 { 00967 ERROR2IF(pSpread == NULL,FALSE,"OpBackground::GetPageColour Bad params error!"); 00968 ERROR2IF(ppOutBitmap == NULL || ppOutColour == NULL,FALSE,"OpBackground::GetPageColour Bad params error!"); 00969 00970 // Search for our special page background layer 00971 Layer* pFoundLayer = pSpread->FindFirstPageBackgroundLayer(); 00972 if (pFoundLayer == NULL) 00973 return FALSE; 00974 00975 // search for our page node 00976 NodeRegularShape *pNode = DoFindPageRectangle(pSpread, pFoundLayer); 00977 00978 if (!pNode) 00979 return FALSE; 00980 00981 // find the fill attribute applied to the page 00982 NodeAttribute *pAppliedAttr = NULL; 00983 pNode->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pAppliedAttr); 00984 00985 if (pAppliedAttr != NULL) 00986 { 00987 if (IS_A(pAppliedAttr, AttrFlatColourFill)) // flat colour fill? 00988 { 00989 // get the colour attribute 00990 ColourFillAttribute *pColAttr = (ColourFillAttribute *)(pAppliedAttr->GetAttributeValue()); 00991 00992 // set the colour pointer to the doc colour, and the bitmap pointer to NULL 00993 *ppOutBitmap = NULL; 00994 *ppOutColour = pColAttr->GetStartColour(); 00995 00996 } 00997 else if (IS_A(pAppliedAttr, AttrBitmapColourFill)) // bitmap fill 00998 { 00999 01000 // set the colour pointer to NULL, and the bitmap pointer to the kernel bitmap 01001 *ppOutBitmap = ((AttrFillGeometry *)pAppliedAttr)->GetBitmap(); 01002 *ppOutColour = NULL; 01003 } 01004 else 01005 return FALSE; 01006 } 01007 else 01008 return FALSE; 01009 01010 return TRUE; 01011 }
|
|
Func for determining the usability of this op.
Definition at line 1111 of file backgrnd.cpp. 01112 { 01113 OpState State; 01114 return State; 01115 }
|
|
Called when the op is undone. This broadcasts a 'Guidelines changed' layer message Called when the op is redone. This broadcasts a 'Guidelines changed' layer message Registers an op desc for this op.
Reimplemented from SimpleCCObject. Definition at line 1081 of file backgrnd.cpp. 01082 { 01083 BOOL ok = RegisterOpDescriptor( 01084 0, 01085 0, 01086 CC_RUNTIME_CLASS(OpBackground), 01087 OPTOKEN_BACKGROUND, 01088 OpBackground::GetState, 01089 0, /* help ID */ 01090 0, /* bubble ID */ 01091 0 /* bitmap ID */ 01092 ); 01093 return ok; 01094 }
|
|
Tries to apply the DocColour or bitmap as a new page background.
Definition at line 271 of file backgrnd.cpp. 00272 { 00273 ERROR2IF(pOp == NULL || pSpread == NULL || pBitmap == NULL,FALSE,"MakePageBackground Bad params!"); 00274 00275 // Get the op to do its stuff 00276 BOOL ok = DoMakePageBackground(pOp, pSpread, pBitmap); 00277 00278 return ok; 00279 }
|
|
Tries to apply the DocColour or bitmap as a new page background.
Definition at line 241 of file backgrnd.cpp. 00242 { 00243 ERROR2IF(pOp == NULL || pSpread == NULL || pDocColour == NULL,FALSE,"MakePageBackground Bad params!"); 00244 00245 // Get the op to do its stuff 00246 BOOL ok = DoMakePageBackground(pOp, pSpread, NULL, pDocColour); 00247 00248 return ok; 00249 }
|