#include <prnmks.h>
Public Member Functions | |
MarkFormatRegion () | |
MarkFormatRegion (const DocRect &Position) | |
virtual | ~MarkFormatRegion () |
void | Empty () |
void | SetPosition (const DocRect &Position) |
void | SetOrientation (BOOL orientX=TRUE) |
void | SetFlipRender (BOOL flip) |
virtual BOOL | AddMark (PrintMarkItem *pMark, MarkFormat *pForm) |
virtual void | Render (RenderRegion *pRRegion, const Matrix &Transform) |
Protected Member Functions | |
virtual BOOL | MakeMark (PrintMarkItem *pMark, DocCoord Anchor, BOOL cx, BOOL cy, BOOL posx, BOOL posy, INT32 shiftx, INT32 shifty, BOOL rotate, MarkList **pMarkList) |
Invented to add a mark to a marklist. This function really is a helper to AddMark and should not be used by itself unless you really want to. Imagine an arbitrarily shaped box with 9 format positions ie combinations of permutations of L,C,R,T,M,B. A Mark list will keep track of marks added to any of these regions. For instance, if you add a mark to TL ie top left, and then add another mark to this region, the TLeft array in the constructed marks list will contain two entries, holding the x,y positions of where the marks should be positioned. Marks will be added ie grow from the edges of the format region dependent on its orientation ie Vertical region orientation bottom edge - marks grow bottom to top left edge aligned at left middle edge - marks grow centrally right edge aligned at right top edge - marks grow top to bottom central align in centre Horizontal region orientation left edge - marks grow left to right centre edge - marks grow centrally right edge - marks grow right to left. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (MarkFormatRegion) | |
void | Render (RenderRegion *pRRegion, MarkList *pItem, const Matrix &Transform) |
void | RenderMark (RenderRegion *pRRegion, PrintMarkItem *pMark) |
Render the mark if it intersects the clip rect in the render region. | |
Node * | FindMarkChildToRender (Node *pParent, RenderRegion *const pRender) |
Node * | FindMarkNextForClippedInkRender (Node *pRoot, Node *pNode, RenderRegion *pRender) |
void | Init () |
Private Attributes | |
DocRect | TheBounds |
INT32 | MkCx |
INT32 | MkCy |
BOOL | OrientX |
BOOL | OnRenderFlipX |
MarkList * | BLeft |
MarkList * | BCentre |
MarkList * | BRight |
MarkList * | MLeft |
MarkList * | MCentre |
MarkList * | MRight |
MarkList * | TLeft |
MarkList * | TCentre |
MarkList * | TRight |
Definition at line 520 of file prnmks.h.
|
Definition at line 3130 of file prnmks.cpp. 03131 { 03132 Init(); 03133 }
|
|
Definition at line 3135 of file prnmks.cpp. 03136 { 03137 Init(); 03138 SetPosition(Position); 03139 }
|
|
Definition at line 3141 of file prnmks.cpp. 03142 { 03143 Empty(); 03144 }
|
|
Definition at line 3206 of file prnmks.cpp. 03207 { 03208 if (!pMark || !pForm) 03209 return FALSE; 03210 03211 BOOL ok=TRUE; 03212 03213 INT32 w = pMark->GetWidth(); 03214 INT32 h = pMark->GetHeight(); 03215 BOOL rt; 03216 03217 rt = (( OrientX && pMark->GetOrient()==MO_Vertical) || 03218 (!OrientX && pMark->GetOrient()==MO_Horizontal) ); 03219 03220 if (rt) 03221 { 03222 INT32 Tmp=w; w=h; h=Tmp; 03223 } 03224 03225 if (pForm->Left) 03226 { 03227 if (pForm->Top) 03228 { 03229 DocCoord anchor = DocCoord(TheBounds.lo.x,TheBounds.hi.y); 03230 ok = MakeMark(pMark, anchor, FALSE, FALSE, TRUE, FALSE, 0, h, rt, &TLeft); 03231 } 03232 03233 if (pForm->Middle) 03234 { 03235 DocCoord anchor = DocCoord(TheBounds.lo.x,MkCy); 03236 ok = MakeMark(pMark, anchor, FALSE, TRUE, TRUE, TRUE, 0, h>>1, rt, &MLeft); 03237 } 03238 03239 if (pForm->Bottom) 03240 { 03241 DocCoord anchor = DocCoord(TheBounds.lo.x,TheBounds.lo.y); 03242 ok = MakeMark(pMark, anchor, FALSE, FALSE, TRUE, TRUE, 0, 0, rt, &BLeft); 03243 } 03244 } 03245 03246 if (pForm->Centre) 03247 { 03248 if (pForm->Top) 03249 { 03250 DocCoord anchor = DocCoord(MkCx,TheBounds.hi.y); 03251 ok = MakeMark(pMark, anchor, TRUE, FALSE, TRUE, FALSE, w>>1, h, rt, &TCentre); 03252 } 03253 03254 if (pForm->Middle) 03255 { 03256 DocCoord anchor = DocCoord(MkCx,MkCy); 03257 ok = MakeMark(pMark, anchor, TRUE, TRUE, TRUE, TRUE, w>>1, h>>1, rt, &MCentre); 03258 } 03259 03260 if (pForm->Bottom) 03261 { 03262 DocCoord anchor = DocCoord(MkCx,TheBounds.lo.y); 03263 ok = MakeMark(pMark, anchor, TRUE, FALSE, TRUE, TRUE, w>>1, 0, rt, &BCentre); 03264 } 03265 } 03266 03267 if (pForm->Right) 03268 { 03269 if (pForm->Top) 03270 { 03271 DocCoord anchor = DocCoord(TheBounds.hi.x,TheBounds.hi.y); 03272 ok = MakeMark(pMark, anchor, FALSE, FALSE, FALSE, FALSE, w, h, rt, &TRight); 03273 } 03274 03275 if (pForm->Middle) 03276 { 03277 DocCoord anchor = DocCoord(TheBounds.hi.x,MkCy); 03278 ok = MakeMark(pMark, anchor, FALSE, TRUE, FALSE, TRUE, w, h>>1, rt, &MRight); 03279 } 03280 03281 if (pForm->Bottom) 03282 { 03283 DocCoord anchor = DocCoord(TheBounds.hi.x,TheBounds.lo.y); 03284 ok = MakeMark(pMark, anchor, FALSE, FALSE, FALSE, TRUE, w, 0, rt, &BRight); 03285 } 03286 } 03287 03288 return ok; 03289 }
|
|
|
|
Definition at line 3156 of file prnmks.cpp. 03157 { 03158 if (BLeft) delete BLeft; 03159 if (BCentre) delete BCentre; 03160 if (BRight) delete BRight; 03161 03162 if (MLeft) delete MLeft; 03163 if (MCentre) delete MCentre; 03164 if (MRight) delete MRight; 03165 03166 if (TLeft) delete TLeft; 03167 if (TCentre) delete TCentre; 03168 if (TRight) delete TRight; 03169 03170 BLeft = BCentre = BRight = NULL; 03171 MLeft = MCentre = MRight = NULL; 03172 TLeft = TCentre = TRight = NULL; 03173 }
|
|
|
|
|
|
Definition at line 3146 of file prnmks.cpp. 03147 { 03148 OrientX=TRUE; 03149 MkCx = MkCy = 0; 03150 BLeft = BCentre = BRight = NULL; 03151 MLeft = MCentre = MRight = NULL; 03152 TLeft = TCentre = TRight = NULL; 03153 OnRenderFlipX=FALSE; 03154 }
|
|
Invented to add a mark to a marklist. This function really is a helper to AddMark and should not be used by itself unless you really want to. Imagine an arbitrarily shaped box with 9 format positions ie combinations of permutations of L,C,R,T,M,B. A Mark list will keep track of marks added to any of these regions. For instance, if you add a mark to TL ie top left, and then add another mark to this region, the TLeft array in the constructed marks list will contain two entries, holding the x,y positions of where the marks should be positioned. Marks will be added ie grow from the edges of the format region dependent on its orientation ie Vertical region orientation bottom edge - marks grow bottom to top left edge aligned at left middle edge - marks grow centrally right edge aligned at right top edge - marks grow top to bottom central align in centre Horizontal region orientation left edge - marks grow left to right centre edge - marks grow centrally right edge - marks grow right to left.
Definition at line 3348 of file prnmks.cpp. 03358 { 03359 MarkList *pItem = (*pMarkList); 03360 03361 if (pItem==NULL) 03362 { 03363 pItem = new MarkList; 03364 if (pItem==NULL) 03365 return FALSE; 03366 03367 pItem->curpos = Anchor; 03368 } 03369 03370 INT32 width = pMark->GetWidth(); 03371 INT32 height = pMark->GetHeight(); 03372 if (rotate) 03373 { 03374 INT32 Tmp=width; width=height; height=Tmp; 03375 } 03376 03377 if (pItem->count<MAXREGIONMARKS) 03378 { 03379 pItem->MarkPos[pItem->count].pMarkItem = pMark; 03380 pItem->MarkPos[pItem->count].dim = DocCoord(width,height); 03381 pItem->MarkPos[pItem->count].rotate = rotate; 03382 pItem->count++; 03383 03384 if (OrientX) 03385 { 03386 pItem->MarkPos[pItem->count-1].pos.y = pItem->curpos.y - shifty; 03387 if (cx) 03388 { 03389 pItem->size.x += width; 03390 INT32 x=0; 03391 for (INT32 i=0; i<pItem->count; i++) 03392 { 03393 pItem->MarkPos[i].pos.x = MkCx - ((pItem->size.x)>>1) + x; 03394 x+=pItem->MarkPos[i].dim.x; 03395 } 03396 } 03397 else 03398 { 03399 pItem->MarkPos[pItem->count-1].pos.x = pItem->curpos.x - shiftx; 03400 pItem->curpos.x += ((posx) ? (+width) : (-width)); 03401 } 03402 } 03403 else 03404 { 03405 pItem->MarkPos[pItem->count-1].pos.x = pItem->curpos.x - shiftx; 03406 if (cy) 03407 { 03408 pItem->size.y += height; 03409 INT32 y=0; 03410 for (INT32 i=0; i<pItem->count; i++) 03411 { 03412 pItem->MarkPos[i].pos.y = MkCy - ((pItem->size.y)>>1) + y; 03413 y+=pItem->MarkPos[i].dim.y; 03414 } 03415 } 03416 else 03417 { 03418 pItem->MarkPos[pItem->count-1].pos.y = pItem->curpos.y - shifty; 03419 pItem->curpos.y += ((posy) ? (+height) : (-height)); 03420 } 03421 } 03422 } 03423 03424 if (*pMarkList==NULL) 03425 *pMarkList=pItem; 03426 03427 return TRUE; 03428 }
|
|
void MarkFormatRegion::Render(RenderRegion *pRRegion, MarkList *pMarkLst) Definition at line 3453 of file prnmks.cpp. 03454 { 03455 PrintMarkItem* pPMI; 03456 DocRect bounds; 03457 DocCoord pos,pos1; 03458 Trans2DMatrix Trans2DMat; 03459 03460 // Calculate the inverse of the render matrix, this allows us to render 03461 // through a scaling render region and prevent our marks being scaled. 03462 Matrix ViewTrans = pRRegion->GetMatrix(); 03463 ViewTrans = ViewTrans.Inverse(); 03464 03465 Matrix Transform; 03466 Matrix ITransform; 03467 Matrix Identity; 03468 03469 for (INT32 i=0; i<pMarkLst->count; i++) 03470 { 03471 pPMI = pMarkLst->MarkPos[i].pMarkItem; 03472 pos = pPMI->GetOrigin(); 03473 // Initialise to the identity 03474 Transform = Identity; 03475 // translation mark to origin 03476 Transform.SetTranslation(-pos.x, -pos.y); 03477 03478 // spin the mark around if necessary 03479 03480 INT32 w = pPMI->GetWidth(); 03481 INT32 h = pPMI->GetHeight(); 03482 if (pMarkLst->MarkPos[i].rotate) 03483 { 03484 Transform *= Matrix((ANGLE)270); 03485 Transform *= Matrix(0,w); 03486 } 03487 03488 // Take into account any flipping 03489 if (OnRenderFlipX) 03490 { 03491 if (pMarkLst->MarkPos[i].rotate) 03492 Transform *= Matrix(FIXED16(-1), FIXED16(0), FIXED16(0), FIXED16(1), h, 0); 03493 else 03494 Transform *= Matrix(FIXED16(-1), FIXED16(0), FIXED16(0), FIXED16(1), w, 0); 03495 } 03496 03497 // Now translate into the final position 03498 Transform = Transform * Matrix(pMarkLst->MarkPos[i].pos); 03499 // Finally apply the outer transform before rendering 03500 Transform = Transform * OuterTransform; 03501 // ok now we need to compensate for the render region matrix 03502 Transform = Transform * ViewTrans; 03503 // calculate the inverse for transforming back again. 03504 ITransform = Transform.Inverse(); 03505 03506 // Apply the transform to the mark, we need to make sure line widths get scaled 03507 Trans2DMat.SetTransform(Transform); 03508 Trans2DMat.TransLines = TRUE; 03509 pPMI->GetMarkGlyph()->Transform(Trans2DMat); 03510 03511 // once transformed lets render it. 03512 RenderMark(pRRegion, pPMI); 03513 03514 // now transform back again (without loss of accuracy ha!) 03515 Trans2DMat.SetTransform(ITransform); 03516 Trans2DMat.TransLines = TRUE; 03517 pPMI->GetMarkGlyph()->Transform(Trans2DMat); 03518 } 03519 }
|
|
void MarkFormatRegion::Render(RenderRegion *pRRegion, const Matrix& Transform) Definition at line 3435 of file prnmks.cpp. 03436 { 03437 if (BLeft) Render(pRRegion, BLeft, Transform); 03438 if (BCentre) Render(pRRegion, BCentre, Transform); 03439 if (BRight) Render(pRRegion, BRight, Transform); 03440 if (MLeft) Render(pRRegion, MLeft, Transform); 03441 if (MCentre) Render(pRRegion, MCentre, Transform); 03442 if (MRight) Render(pRRegion, MRight, Transform); 03443 if (TLeft) Render(pRRegion, TLeft, Transform); 03444 if (TCentre) Render(pRRegion, TCentre, Transform); 03445 if (TRight) Render(pRRegion, TRight, Transform); 03446 }
|
|
Render the mark if it intersects the clip rect in the render region.
Definition at line 3536 of file prnmks.cpp. 03537 { 03538 // Get the root node and render the entire subtree 03539 Node* pFirstNode = pMark->GetMarkGlyph(); 03540 if (pFirstNode!=NULL) 03541 pRRegion->RenderTree(pFirstNode, FALSE, TRUE); 03542 }
|
|
Definition at line 3189 of file prnmks.cpp. 03190 { 03191 OnRenderFlipX=flip; 03192 }
|
|
Definition at line 3184 of file prnmks.cpp. 03185 { 03186 OrientX=orientX; 03187 }
|
|
Definition at line 3176 of file prnmks.cpp. 03177 { 03178 TheBounds = Position; 03179 MkCx = (TheBounds.lo.x + TheBounds.hi.x)>>1; 03180 MkCy = (TheBounds.lo.y + TheBounds.hi.y)>>1; 03181 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|