#include <page.h>
Inheritance diagram for Page:
Public Member Functions | |
Page () | |
This constructor creates a Page linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles. | |
Page (Node *ContextNode, AttachNodeDirection Direction, const DocRect &NewPageRect, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE) | |
This method initialises the page node and links it to ContextNode in the direction specified by Direction. The sizes of the pasteboard rectangles of all paper nodes above this page are recalculated, and the document extents changed. | |
String | Describe (BOOL Plural, BOOL Verbose) |
To return a description of the Node object in either the singular or the plural. This method is called by the DescribeRange method. | |
void | Render (RenderRegion *pRender) |
Renders page items: White page rectangle, page divider, print margin, and grid. | |
const DocRect & | GetPageRect (void) const |
For obtaining the page rectangle. | |
BOOL | SetPageRect (DocRect NewPageRect) |
For setting up a new page rectangle. | |
Page * | FindNextPage (void) |
To find the next sibling page. | |
Page * | FindRightPage (void) |
To find the page joined to the right of this page. | |
Page * | FindBottomPage (void) |
To find the page joined to the bottom of this page. | |
void | CopyIntoSpread (Page *pContextPage, LinkDirection ld) |
To make a copy of the current page and attach it to ContextPage in the direction specified by ld. | |
virtual UINT32 | GetNodeSize () const |
For finding the size of the node. | |
virtual void | GetDebugDetails (StringBase *Str) |
For obtaining debug information about the Node. | |
virtual BOOL | Snap (DocCoord *pDocCoord) |
Snaps to given coord to the nearest point on the page boundary. | |
virtual BOOL | Snap (DocRect *pDocRect, const DocCoord &PrevCoord, const DocCoord &CurCoord) |
Snaps the given rect to the page, preserving its width and height. | |
virtual BOOL | WritePreChildrenWeb (BaseCamelotFilter *pFilter) |
Writes the Page record to the filter (if it's required). | |
virtual BOOL | WritePreChildrenNative (BaseCamelotFilter *pFilter) |
virtual void | PolyCopyNodeContents (NodeRenderable *pNodeCopy) |
Polymorphically copies the contents of this node to another. | |
Static Public Member Functions | |
static void | SetPageColour (DocColour &NewColour) |
Sets the page colour to NewColour. | |
static DocColour & | GetPageColour (void) |
For finding the colour of a page. | |
Static Public Attributes | |
static DocColour | PageColour |
Protected Member Functions | |
virtual Node * | SimpleCopy () |
This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes. | |
void | CopyNodeContents (Page *NodeCopy) |
This method copies the node's contents to the node pointed to by NodeCopy. | |
Protected Attributes | |
DocRect | PageRect |
Private Member Functions | |
INT32 | SnapOrdinate (INT32 Lo, INT32 Hi, INT32 Src, INT32 SnapDist) |
This function will return either Lo, Hi, or Src depending on the following:. |
Definition at line 125 of file page.h.
|
This constructor creates a Page linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.
Definition at line 145 of file page.cpp. 00145 : NodeRenderablePaper() 00146 { 00147 }
|
|
This method initialises the page node and links it to ContextNode in the direction specified by Direction. The sizes of the pasteboard rectangles of all paper nodes above this page are recalculated, and the document extents changed.
Specifies the direction in which this 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 PasteRect : Page's pasteboard rectangle PageWidth : The width of the page PageHeight: The height of the page 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 ?
Definition at line 202 of file page.cpp. 00210 :NodeRenderablePaper(ContextNode, Direction, Locked, Mangled, 00211 Marked, Selected) 00212 { 00213 PageRect = NewPageRect; 00214 }
|
|
To make a copy of the current page and attach it to ContextPage in the direction specified by ld.
Definition at line 632 of file page.cpp.
|
|
This method copies the node's contents to the node pointed to by NodeCopy.
Definition at line 427 of file page.cpp. 00428 { 00429 ENSURE(NodeCopy != NULL,"Trying to copy a page's contents to a NULL node"); 00430 NodeRenderablePaper::CopyNodeContents(NodeCopy); 00431 NodeCopy->PageRect = PageRect; 00432 NodeCopy->PageColour = PageColour; 00433 }
|
|
To return a description of the Node object in either the singular or the plural. This method is called by the DescribeRange method.
Reimplemented from Node. Definition at line 243 of file page.cpp. 00244 { 00245 if (Plural) 00246 return(String(_R(IDS_PAGE_DESCRP))); 00247 else 00248 return(String(_R(IDS_PAGE_DESCRS))); 00249 };
|
|
To find the page joined to the bottom of this page.
Definition at line 592 of file page.cpp. 00593 { 00594 Page* SiblingPage = FindNextPage(); 00595 while (SiblingPage != NULL) 00596 { 00597 DocRect SiblingPageRect = SiblingPage->GetPageRect(); 00598 // For two pages joined together vertically the hi.y of the lower page must be 00599 // equal to lo.y of the upper page, also the two pages will have identical x 00600 // coordinates (i.e. they have the same width and are in the same place horizontally). 00601 // This condition could be optimised 00602 if ( ((SiblingPageRect.HighCorner().y) == (PageRect.LowCorner().y)) && 00603 ((SiblingPageRect.HighCorner().x) == (PageRect.HighCorner().x)) && 00604 ((SiblingPageRect.LowCorner().x) == (PageRect.LowCorner().x)) 00605 ) 00606 return(SiblingPage); 00607 SiblingPage = SiblingPage->FindNextPage(); 00608 } 00609 return (NULL); // No page was found to be joined beneath this page 00610 }
|
|
To find the next sibling page.
Definition at line 522 of file page.cpp. 00523 { 00524 Node* CurrentNode = FindNext(); 00525 while (CurrentNode != NULL) 00526 { 00527 if(CurrentNode->IsKindOf(CC_RUNTIME_CLASS(Page))) 00528 return ((Page*) CurrentNode); 00529 CurrentNode = CurrentNode->FindNext(); 00530 } 00531 return (NULL); // No page found 00532 }
|
|
To find the page joined to the right of this page.
Definition at line 550 of file page.cpp. 00551 { 00552 Page* SiblingPage = FindNextPage(); 00553 00554 if (SiblingPage != NULL) 00555 { 00556 const DocRect& SiblingPageRect = SiblingPage->GetPageRect(); 00557 00558 //For two pages joined together horizontally the hi.x of the left-hand page must 00559 //be equal to the lo.x of the right hand page, also the two pages will have 00560 //identical y coordinates (i.e. they have the same height and are in the same place 00561 //vertically. 00562 00563 // This can be optimised ** 00564 if (((PageRect.HighCorner().x) == (SiblingPageRect.LowCorner().x)) && 00565 ((PageRect.LowCorner().y ) == (SiblingPageRect.LowCorner().y)) && 00566 ((PageRect.HighCorner().y) == (SiblingPageRect.HighCorner().y)) 00567 ) 00568 return (SiblingPage); 00569 else 00570 return (NULL); 00571 } 00572 return (NULL); 00573 }
|
|
For obtaining debug information about the Node.
Reimplemented from NodeRenderablePaper. Definition at line 703 of file page.cpp. 00704 { 00705 #ifdef _DEBUG 00706 NodeRenderablePaper::GetDebugDetails(Str); 00707 String_256 TempStr; 00708 if (!PageRect.IsValid()) 00709 { 00710 TempStr = TEXT("\r\nPage Rectangle = *INVALID*\r\n"); 00711 } 00712 else 00713 TempStr._MakeMsg(TEXT("\r\nPage Rectangle\r\n Low(#1%ld, #2%ld)\r\n High(#3%ld, #4%ld)\r\n"), 00714 PageRect.LowCorner().x, 00715 PageRect.LowCorner().y, 00716 PageRect.HighCorner().x, 00717 PageRect.HighCorner().y); 00718 (*Str)+=TempStr; 00719 #endif 00720 }
|
|
For finding the size of the node.
Reimplemented from Node. Definition at line 737 of file page.cpp. 00738 { 00739 return (sizeof(Page)); 00740 }
|
|
For finding the colour of a page.
Definition at line 682 of file page.cpp. 00683 { 00684 return (PageColour); 00685 }
|
|
For obtaining the page rectangle.
Definition at line 476 of file page.cpp. 00477 { 00478 return (PageRect); 00479 }
|
|
Polymorphically copies the contents of this node to another.
Reimplemented from NodeRenderablePaper. Definition at line 448 of file page.cpp. 00449 { 00450 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node"); 00451 ENSURE(IS_A(pNodeCopy, Page), "PolyCopyNodeContents given wrong dest node type"); 00452 00453 if (IS_A(pNodeCopy, Page)) 00454 CopyNodeContents((Page*)pNodeCopy); 00455 }
|
|
Renders page items: White page rectangle, page divider, print margin, and grid.
Reimplemented from Node. Definition at line 269 of file page.cpp. 00270 { 00271 // If we should blow up, then blow up - don't worry, this is a very quick inline check 00272 OpException::BlowUpOnCrashMe(); 00273 00274 // Sanity check 00275 ERROR3IF(pRender == NULL,"Page::Render null render region!"); 00276 if (pRender == NULL) 00277 return; 00278 00279 // If we have the new page background layer present then we needn't bother redrawing the 00280 // page as we might get a flash of white as we redraw 00281 Node * pCurrent = FindParent(); 00282 if (pCurrent->GetRuntimeClass() == CC_RUNTIME_CLASS(Spread)) 00283 { 00284 // We have found the spread 00285 Spread * pSpread = (Spread *)pCurrent; 00286 // Is there a page background layer on the spread? 00287 Layer* pLayer = pSpread->FindFirstPageBackgroundLayer(); 00288 // Yes, the layer is present but is it visible and does the quality level 00289 // dictate that we should show it? 00290 if ( 00291 pLayer && pLayer->IsVisible() && 00292 (pRender->RRQuality.GetFillQuality() >= Quality::NoFill) 00293 ) 00294 return; 00295 } 00296 00297 // This conditional replaces the correct code (directly below in the IF clause) in favour 00298 // of a bodged version that renders the single pixel page outline using filled rectangles 00299 // (the code in the ELSE clause). This is required because although GDI and GDraw fills 00300 // can be made to match up, their outlines can't (at the time of writing). 00301 // 00302 // By the way, Gavin says, it's faster to plot four upright rects than to stroke a path 00303 // to become the outline of the page!!! 00304 // 00305 #if 0 00306 // Set up attributes for drawing page rectangle 00307 pRender->SetLineWidth(0); // Means single-pixel lines 00308 pRender->SetLineColour(DocColour(BLACK)); 00309 pRender->SetFillColour(PageColour); 00310 00311 // Draw a rectangle covering the page 00312 pRender->DrawRect(&PageRect); 00313 00314 #else 00315 // Draw a rectangle covering the page 00316 // Set up attributes for drawing page rectangle 00317 pRender->SetLineWidth(0); // Means single-pixel lines 00318 pRender->SetLineColour(COLOUR_TRANS); 00319 00320 // randomly change page colour to see which bit is redrawing 00321 #if 0 00322 static COLORREF pc = 0x00000000; 00323 switch (pc) 00324 { 00325 case 0x007FFFFF: pc = 0x00FF7FFF; break; 00326 case 0x00FF7FFF: pc = 0x00FFFF7F; break; 00327 case 0x00FFFF7F: pc = 0x007FFFFF; break; 00328 default: pc = 0x007FFFFF; 00329 } 00330 pRender->SetFillColour(DocColour((pc>>16)&0xFF,(pc>>8)&0xFF,pc&0xFF)); 00331 #else 00332 pRender->SetFillColour(PageColour); 00333 #endif 00334 pRender->DrawRect(&PageRect); 00335 00336 00337 #ifndef NO_PAGE 00338 // This is the default non-Ralph behaviour 00339 00340 pRender->SetFillColour(COLOUR_BLACK); 00341 pRender->DrawPixelRect(&PageRect); 00342 #else 00343 // Ralph Docs only render paper in some modes 00344 00345 //find the parent NodeDocument 00346 Node* pCurrentNode = FindParent(); 00347 while(pCurrentNode != NULL) 00348 { 00349 if (pCurrentNode->IsNodeDocument()) 00350 break; 00351 pCurrentNode = pCurrentNode->FindParent(); 00352 } 00353 BaseDocument * pDoc =NULL; 00354 // get a Document * 00355 if(pCurrentNode) 00356 pDoc = ((NodeDocument*)(pCurrentNode))->GetParentDoc(); 00357 // should we render paper ? 00358 if(((Document*)pDoc)->RalphDontShowPaper()==FALSE) 00359 { 00360 pRender->SetFillColour(COLOUR_BLACK); 00361 pRender->DrawPixelRect(&PageRect); 00362 } 00363 #endif // NO_PAGE 00364 00365 #endif // simple redraw or redraw lines and page as filled rects 00366 00367 //Draw print margin 00368 //if Document::PrintSpreads ***** 00369 //DocColour Red(0.87,0,0) 00370 // DocColour Transparent(TRANS); 00371 00372 //obtain the printer margin from the PrintView 00373 // pCurrentRenderRegion->DrawRect(&PrintMarginRect) 00374 00375 // The rendering of the grid will have to wait until the grid exists. 00376 }
|
|
Sets the page colour to NewColour.
Definition at line 662 of file page.cpp. 00663 { 00664 PageColour = NewColour; 00665 }
|
|
For setting up a new page rectangle.
Definition at line 498 of file page.cpp.
|
|
This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.
Reimplemented from NodeRenderablePaper. Definition at line 398 of file page.cpp. 00399 { 00400 Page* NodeCopy; 00401 NodeCopy = new Page(); 00402 ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 00403 CopyNodeContents(NodeCopy); 00404 return (NodeCopy); 00405 }
|
|
Snaps the given rect to the page, preserving its width and height.
To force the bottom left hand corner of the rect to be snapped, supply PrevCoord=(0,0) and CurCoord(-1,-1). ALWAYS RETURNS FALSE currently. Scope: public Reimplemented from NodeRenderableBounded. Definition at line 853 of file page.cpp. 00854 { 00855 #if !defined(EXCLUDE_FROM_RALPH) 00856 ERROR3IF(pDocRect == NULL,"pDocRect == NULL"); 00857 if (pDocRect == NULL) return FALSE; 00858 00859 DocCoord OrigCoord; 00860 00861 if (PrevCoord.x < CurCoord.x) 00862 OrigCoord.x = pDocRect->hi.x; 00863 else 00864 OrigCoord.x = pDocRect->lo.x; 00865 00866 if (PrevCoord.y < CurCoord.y) 00867 OrigCoord.y = pDocRect->hi.y; 00868 else 00869 OrigCoord.y = pDocRect->lo.y; 00870 00871 DocCoord SnapCoord = OrigCoord; 00872 00873 if (Snap(&SnapCoord)) 00874 { 00875 INT32 DeltaX = SnapCoord.x - OrigCoord.x; 00876 INT32 DeltaY = SnapCoord.y - OrigCoord.y; 00877 00878 pDocRect->Translate(DeltaX,DeltaY); 00879 00880 return TRUE; 00881 } 00882 else 00883 #endif 00884 return FALSE; 00885 }
|
|
Snaps to given coord to the nearest point on the page boundary.
Reimplemented from NodeRenderableBounded. Definition at line 802 of file page.cpp. 00803 { 00804 ERROR3IF(pDocCoord == NULL,"pDocCoord == NULL"); 00805 if (pDocCoord == NULL) return FALSE; 00806 00807 MILLIPOINT SnapDist = CSnap::GetSnapDist(); 00808 00809 DocRect BigRect = PageRect; 00810 DocRect SmallRect = PageRect; 00811 00812 BigRect.Inflate(SnapDist); 00813 SmallRect.Inflate(-SnapDist); 00814 00815 if (BigRect.ContainsCoord(*pDocCoord) && !SmallRect.ContainsCoord(*pDocCoord)) 00816 { 00817 pDocCoord->x = SnapOrdinate(PageRect.lo.x,PageRect.hi.x,pDocCoord->x,SnapDist); 00818 pDocCoord->y = SnapOrdinate(PageRect.lo.y,PageRect.hi.y,pDocCoord->y,SnapDist); 00819 00820 return TRUE; 00821 } 00822 return FALSE; 00823 }
|
|
This function will return either Lo, Hi, or Src depending on the following:.
Otherwise Src is returned back.
Definition at line 766 of file page.cpp. 00767 { 00768 INT32 DistLo = abs(Lo-Src); 00769 INT32 DistHi = abs(Hi-Src); 00770 00771 if (DistLo < DistHi) 00772 { 00773 if (DistLo <= SnapDist) 00774 Src = Lo; 00775 } 00776 else 00777 { 00778 if (DistHi <= SnapDist) 00779 Src = Hi; 00780 } 00781 00782 return Src; 00783 }
|
|
Reimplemented from Node. Definition at line 913 of file page.cpp. 00914 { 00915 #if 0 //NEW_NATIVE_FILTER // New native filters, only available to those who need them at present 00916 ERROR2IF(pFilter == NULL,FALSE,"Page - NULL filter param"); 00917 00918 // Only write out in the native file format 00919 // Just write out the position of this page as other information such as 00920 // show bleed is spread related and written in the spread information record 00921 BOOL RecordWritten = TRUE; 00922 BOOL ok = TRUE; 00923 00924 CXaraFileRecord Rec(TAG_PAGE,TAG_PAGE_SIZE); 00925 00926 ok = Rec.Init(); 00927 00928 if (ok) ok = Rec.WriteCoord(PageRect.lo); // write out low corner details 00929 if (ok) ok = Rec.WriteCoord(PageRect.hi); // write out high corner details 00930 00931 // Finally, write the record out to file 00932 // In the process get the record number that this was written out as 00933 INT32 RecordNumber = 0L; 00934 if (ok) RecordNumber = pFilter->Write(&Rec); 00935 00936 // If we have had a problem at any of the stages then return that to the caller 00937 if (!ok || RecordNumber <= 0) 00938 RecordWritten = FALSE; 00939 00940 return RecordWritten; 00941 #else 00942 return TRUE; 00943 #endif //NEW_NATIVE_FILTER 00944 }
|
|
Writes the Page record to the filter (if it's required).
Reimplemented from Node. Definition at line 904 of file page.cpp. 00905 { 00906 // This is not required in the web format 00907 return TRUE; 00908 }
|
|
|
|
|