#include <attrappl.h>
Inheritance diagram for OpApplyAttribToNode:
Public Member Functions | |
OpApplyAttribToNode () | |
OpApplyAttribToNode constructor. | |
void | DoWithParam (OpDescriptor *OpDesc, OpParam *pOpParam) |
Performs the OpApplyAttribToNode operation. This function applies the NodeAttribute to all selected objects. | |
virtual void | GetOpName (String_256 *OpName) |
The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies. | |
Static Public Member Functions | |
static BOOL | Init () |
OpApplyAttribToNode initialiser method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding OpApplyAttribToNode state. | |
Private Member Functions | |
BOOL | DoApplyAttrib (NodeRenderableInk *InkNode, NodeAttribute *NewAttr, AttrTypeSet *pAttrTypesToBeApplied, ObjectSet *pLocalisedCompounds, BOOL InvalidateBounds=FALSE) |
Applies NewAttr to InkNode. | |
Private Attributes | |
UINT32 | UndoAttribStrID |
Definition at line 349 of file attrappl.h.
|
OpApplyAttribToNode constructor.
Definition at line 3412 of file attrappl.cpp. 03412 : OpApplyAttrib() 03413 { 03414 m_pAttr = NULL; 03415 }
|
|
Applies NewAttr to InkNode.
InvalidateBounds: When TRUE bounds will be invalidated.
Definition at line 3621 of file attrappl.cpp. 03625 { 03626 NodeAttribute* OtherAttr; 03627 03628 AttributeManager::pLastNodeAppliedTo = NULL; 03629 03630 ERROR3IF(InkNode==NULL,"InkNode == NULL"); 03631 ERROR3IF(NewAttr==NULL,"NewAttr == NULL"); 03632 if (InkNode == NULL) return FALSE; 03633 03634 03635 // Get a description of the attribute being applied so that we can use it to create the 03636 // undo string. 03637 UndoAttribStrID = NewAttr->GetAttrNameID(); 03638 03639 if (!AttrFillGeometry::HitList.IsEmpty()) 03640 { 03641 // Bodge Alert !! 03642 // This is not nice, but it cure the problem !! 03643 // When a colour drop occurs on a blob which is part of a multi-select 03644 // fill mesh, then the colour drop will have to change several fills 03645 // at once. 03646 // To make this happen, I have made the colour drop checking routine 03647 // build a list of all the hit fills, in the 'HitList'. 03648 03649 // The 'HitList' has some items in it, so lets apply the mutator to all 03650 // of the fills parents. 03651 03652 ListItem* pAttrPtr = AttrFillGeometry::HitList.GetHead(); 03653 03654 while (pAttrPtr != NULL) 03655 { 03656 // It's a list of Attribute Pointer Items, 03657 // so lets extract the pointer 03658 NodeAttribute* pAttr = ((NodeAttributePtrItem*)pAttrPtr)->NodeAttribPtr; 03659 NodeRenderableInk* pParent = (NodeRenderableInk*)pAttr->FindParent(); 03660 03661 // Before we apply the attributes, we localise all attrs of the same type 03662 if (!DoLocaliseForAttrChange(pParent, 03663 pAttrTypesToBeApplied, 03664 pLocalisedCompounds)) 03665 { 03666 return FALSE; 03667 } 03668 03669 if (!DoApply(pParent, NewAttr, NewAttr->IsAFillAttr(), InvalidateBounds)) 03670 { 03671 return FALSE; 03672 } 03673 03674 03675 // Some Attributes require a second attribute to be changed as well, 03676 // which has to be done within this op. 03677 03678 BOOL IsMutate; 03679 OtherAttr = AttributeManager::GetOtherAttrToApply(NewAttr, &IsMutate); 03680 03681 if (OtherAttr != NULL) 03682 { 03683 if (!DoApply(pParent, OtherAttr, IsMutate, InvalidateBounds)) 03684 { 03685 return FALSE; 03686 } 03687 delete OtherAttr; 03688 } 03689 03690 pAttrPtr = AttrFillGeometry::HitList.GetNext(pAttrPtr); 03691 } 03692 03693 // Now make sure the HitList is cleared out for next time 03694 AttrFillGeometry::HitList.DeleteAll(); 03695 } 03696 else 03697 { 03698 // Before we apply the attributes, we localise all attrs of the same type 03699 if (!DoLocaliseForAttrChange(InkNode, 03700 pAttrTypesToBeApplied, 03701 pLocalisedCompounds)) 03702 { 03703 return FALSE; 03704 } 03705 03706 if (!DoApply(InkNode, NewAttr, NewAttr->IsAFillAttr(), InvalidateBounds)) // The attrib is always a Mutator 03707 return FALSE; 03708 03709 // Some Attributes require a second attribute to be changed as well, 03710 // which has to be done within this op. 03711 03712 BOOL IsMutate; 03713 OtherAttr = AttributeManager::GetOtherAttrToApply(NewAttr, &IsMutate); 03714 03715 if (OtherAttr != NULL) 03716 { 03717 if (!DoApply(InkNode, OtherAttr, IsMutate, InvalidateBounds)) 03718 { 03719 return FALSE; 03720 } 03721 delete OtherAttr; 03722 } 03723 } 03724 03725 if (Document::GetSelected()) 03726 Document::GetSelected()->SetModified(TRUE); 03727 03728 03729 AttributeManager::LastAppliedBounds = InkNode->GetBoundingRect(); 03730 03731 return TRUE; 03732 }
|
|
Performs the OpApplyAttribToNode operation. This function applies the NodeAttribute to all selected objects.
Reimplemented from Operation. Definition at line 3435 of file attrappl.cpp. 03436 { 03437 ERROR3IF(pOpParam == NULL, "The OpApplyAttribToNode operation requires an attribute parameter"); 03438 03439 // Obtain a pointer to the attribute which we will need to apply to all selected nodes 03440 NodeRenderableInk* InkNode = (NodeRenderableInk*)(void *)pOpParam->Param1; 03441 NodeAttribute* NewAttr = (NodeAttribute*)(void *)pOpParam->Param2; 03442 m_pAttr = NewAttr; 03443 03444 ValueChangeType = NewAttr->GetRuntimeClass(); 03445 03446 if (NewAttr) 03447 UndoAttribStrID = NewAttr->GetAttrNameID(); 03448 03449 ObjectSet LocalisedCompoundSet; // Every time we localise a compound's attributes we will add the 03450 // compound to this set. 03451 03452 AttrTypeSet AttrTypes; // The attribute types to localise and factor out 03453 03454 BOOL OtherIsMutate; 03455 NodeAttribute* OtherAttr = AttributeManager::GetOtherAttrToApply(NewAttr, &OtherIsMutate); 03456 03457 // Prepare an ObjChangeParam for use when asking the ink node if we can do this op to it. 03458 ObjChangeFlags cFlags; 03459 cFlags.Attribute = TRUE; 03460 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this); 03461 03462 // If this attribute affects the bounds if its parents then we must take the blobs off 03463 // at the start. We can rely on the redraw at the end to put them back on 03464 BOOL AttrAffectsBounds = NewAttr->EffectsParentBounds(); 03465 if (!DoStartSelOp(AttrAffectsBounds, FALSE, TRUE, TRUE)) 03466 { 03467 goto End; 03468 } 03469 03470 // Find out the types of attribute about to be applied, and add them to the AttrTypes set 03471 ERROR3IF(NewAttr==NULL,"NewAttr == NULL"); 03472 AttrTypes.AddToSet((NewAttr->GetAttributeType())); 03473 03474 if (OtherAttr != NULL) 03475 { 03476 AttrTypes.AddToSet((OtherAttr->GetAttributeType())); 03477 } 03478 03479 // If we are applying an attribute to a VTN which is selected then apply the attribute 03480 // to this node and all other selected nodes. 03481 if (InkNode->IsAnAbstractTextChar() && InkNode->IsSelected()) 03482 { 03483 AbstractTextChar* Scan = (AbstractTextChar*)InkNode; 03484 AbstractTextChar* Last; 03485 03486 // Find the first selected AbstractTextChar 03487 do 03488 { 03489 InkNode = Scan; 03490 Scan = Scan->FindPrevAbstractTextCharInStory(); 03491 } while ((Scan != NULL) && (Scan->IsSelected())); 03492 03493 // Find the last 03494 Scan = (AbstractTextChar*)InkNode; 03495 do 03496 { 03497 Last = Scan; 03498 Scan = Scan->FindNextAbstractTextCharInStory(); 03499 } while ((Scan != NULL) && (Scan->IsSelected())); 03500 03501 Range SubSelRange(InkNode, Last, RangeControl(TRUE)); 03502 03503 // Will the ink node (and all its parents) allow this op to happen? 03504 if (!SubSelRange.AllowOp(&ObjChange)) 03505 { 03506 FailAndExecute(); 03507 goto End; 03508 } 03509 03510 // Invalidate the region before applying the attribute/s 03511 if (!DoInvalidateRegions(&SubSelRange, 03512 NewAttr, 03513 NewAttr->IsAFillAttr(), 03514 OtherAttr, 03515 OtherIsMutate)) //Mutators have to include bounds 03516 { 03517 goto End; 03518 } 03519 03520 // Apply the attr to all selected AbstractTextChars 03521 do 03522 { 03523 if (!DoApplyAttrib(InkNode, NewAttr, &AttrTypes, &LocalisedCompoundSet)) 03524 { 03525 // error will have been set 03526 FailAndExecute(); // Just make sure 03527 goto End; 03528 } 03529 InkNode = ((AbstractTextChar*)InkNode)->FindNextAbstractTextCharInStory(); 03530 } while ((InkNode != NULL) && (InkNode->IsSelected())); 03531 03532 03533 // Invalidate the region after applying the attribute/s 03534 if (!DoInvalidateRegions(&SubSelRange, 03535 NewAttr, 03536 NewAttr->IsAFillAttr(), 03537 OtherAttr, 03538 OtherIsMutate)) //Mutators have to include bounds 03539 { 03540 goto End; 03541 } 03542 } 03543 else 03544 { 03545 // Will the ink node (and all its parents) allow this op to happen? 03546 if (!InkNode->AllowOp(&ObjChange)) 03547 { 03548 FailAndExecute(); 03549 goto End; 03550 } 03551 03552 if (!DoApplyAttrib(InkNode, NewAttr, &AttrTypes, &LocalisedCompoundSet, TRUE)) 03553 { 03554 goto End; 03555 } 03556 03557 } 03558 03559 // Finally factor out the neccessary attributes 03560 if (!DoFactorOutAfterAttrChange(&LocalisedCompoundSet, 03561 &AttrTypes)) 03562 { 03563 goto End; 03564 } 03565 03566 // Update all effected parent nodes 03567 03568 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this); 03569 if (!UpdateChangedNodes(&ObjChange)) 03570 { 03571 FailAndExecute(); 03572 } 03573 03574 End: 03575 // First tidy up 03576 AttrTypes.DeleteAll(); 03577 LocalisedCompoundSet.DeleteAll(); 03578 03579 if (OtherAttr) 03580 { 03581 delete OtherAttr; 03582 } 03583 03584 // then end 03585 End(); // End of operation 03586 }
|
|
The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.
Reimplemented from Operation. Definition at line 3810 of file attrappl.cpp. 03811 { 03812 03813 *OpName = String_256(UndoAttribStrID); 03814 *OpName += String_256(_R(IDS_CHANGE)); 03815 }
|
|
For finding OpApplyAttribToNode state.
Definition at line 3783 of file attrappl.cpp.
|
|
OpApplyAttribToNode initialiser method.
Reimplemented from SimpleCCObject. Definition at line 3753 of file attrappl.cpp. 03754 { 03755 03756 // Register the opdescriptors for the OpApplyAttribToNode operation 03757 OpDescriptor* OpDesc = new OpDescriptor( 03758 0, 03759 _R(IDS_APPLYTONODEOP), 03760 CC_RUNTIME_CLASS(OpApplyAttribToNode), 03761 OPTOKEN_APPLYTONODE, 03762 OpApplyAttribToNode::GetState); 03763 03764 ERRORIF(!OpDesc, _R(IDE_NOMORE_MEMORY), FALSE); 03765 return(OpDesc != NULL); 03766 }
|
|
Definition at line 368 of file attrappl.h. |