#include <opdupbar.h>
Inheritance diagram for OpDuplicateBar:
Public Member Functions | |
OpDuplicateBar () | |
OpBarCreation constructor. | |
void | DoWithParam (OpDescriptor *token, OpParam *pOpParam) |
Clones a bar, but gives the bar a new name and each button in the bar and new name. This is so each bar can work independantly or together. If they are just copied they would have the same bar IDs and the same button names which is not likely to be what the user would expect. | |
String_256 | GetNewButtonName (String_256 &Name) |
Generates names for the new bar. | |
void | DuplicateBar (String_256 &OriginalBarName, String_256 &NewBarName, INT32 ButtonsToAdd=0, INT32 Spacing=0, BOOL IsHoriz=FALSE) |
Clones a bar, but gives the bar a new name and each button in the bar and new name. This is so each bar can work independantly or together. If they are just copied they would have the same bar IDs and the same button names which is not likely to be what the user would expect. | |
Node * | CopyBarMember (Node *pNode, const String_256 &OriginalBarName, const String_256 &NewBarName, Trans2DMatrix *pTransformer, const INT32 *pKnownButonIndex=NULL) |
Copies a single member of a bar. Any template attributes that relate to the old original bar are replaced with references to the new bar. Also will generate new stretching attributes for a new button based on those of the source. | |
Static Public Member Functions | |
static BOOL | Init () |
OpDuplicateBar initialiser method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding the operations state. | |
Private Attributes | |
INT32 | m_ButtonNumberList [20] |
TemplateAttribute ** | m_ppFoundButton [20] |
INT32 | m_ExistingButtonsInBar |
Definition at line 121 of file opdupbar.h.
|
OpBarCreation constructor.
Definition at line 160 of file opdupbar.cpp. 00160 : CarbonCopyOp() 00161 { 00162 m_ExistingButtonsInBar = 0; 00163 }
|
|
Copies a single member of a bar. Any template attributes that relate to the old original bar are replaced with references to the new bar. Also will generate new stretching attributes for a new button based on those of the source.
Definition at line 478 of file opdupbar.cpp. 00479 { 00480 // Make a copy of the current node 00481 Node* pTheCopy; 00482 00483 // Assumes that the parent of the wix attribute is the main node that needs 00484 // copying. This is a fair assumption being as that is where the bar creation 00485 // op puts it. 00486 Node* pCurrent = pNode->FindParent(); 00487 BOOL CopiedOK = TRUE; 00488 00489 String_256 Target = ""; // the button name of the selection 00490 String_256 Extender = ""; // the thing in this button that extends it 00491 DocRect rTarget; 00492 DocRect rExtender; 00493 BYTE ExtenderFlags = 0; 00494 INT32 RequiredLevel = 0; 00495 RequiredLevel = SliceHelper::FindTargetAndExtender(pCurrent, Target, Extender, RequiredLevel, &ExtenderFlags, &rTarget, &rExtender); 00496 00497 // no longer unselect the old bar as this fn is only used for adding buttons from button 1 really now 00498 //pCurrent->SetSelected(FALSE); 00499 00500 // where to insert this new node 00501 Node * pInsertPt = pCurrent->FindParent(); 00502 while (!pInsertPt->IsLayer()) 00503 pInsertPt = pInsertPt->FindParent(); 00504 00505 // create a copy of the node 00506 CALL_WITH_FAIL(pCurrent->NodeCopy(&pTheCopy), this, CopiedOK); 00507 if (!CopiedOK) return NULL; // couldn't copy -> fail 00508 00509 // insert the copy into the tree 00510 DoInsertNewNode((NodeRenderableBounded *)pTheCopy, pInsertPt, LASTCHILD, 00511 TRUE, // Do Invalidate region 00512 FALSE); // Don't Clear the selections 00513 // don't have any of these new nodes selected 00514 pTheCopy->SetSelected(FALSE); 00515 00516 // clean the attributes of the copy. 00517 // remove all references to the old bar and 00518 // replace with references to the new bar. 00519 // Also update the name given to the button set. 00520 Node* pAttrib = pTheCopy->FindFirstChild(); 00521 Node* pNext = NULL; 00522 00523 BOOL goon = TRUE; 00524 while(pAttrib && goon) 00525 { 00526 pNext = pAttrib->FindNext(); 00527 if (pAttrib->IsAnAttribute()) 00528 { 00529 if (IS_A(pAttrib, TemplateAttribute)) 00530 { 00531 String_256 ButtonName = ((TemplateAttribute *)pAttrib)->GetParam(); 00532 String_256 AttrName = ((TemplateAttribute *)pAttrib)->GetQuestion(); 00533 // found the actual button marker 00534 // since this has the marker of the bar name 00535 BOOL IsBarButton = (OriginalBarName.CompareTo(AttrName) == 0); 00536 BOOL IsExtender = (ButtonName.CompareTo(Extender) == 0); 00537 00538 if (IsBarButton || IsExtender) 00539 { 00540 String_256 NewButtonName = ""; 00541 00542 if (pKnownButtonIndex) 00543 NewButtonName.MakeMsg(_R(IDS_BUTTONNAME), m_ButtonNumberList[*pKnownButtonIndex]); 00544 else 00545 NewButtonName = GetNewButtonName(ButtonName); 00546 00547 String_256 ExtenderPostfix; 00548 ExtenderPostfix.Load(_R(IDS_EXTENDER_POSTFIX)); 00549 String_256 NewExtenderName = NewButtonName; 00550 NewExtenderName += ExtenderPostfix; 00551 00552 TemplateAttribute* pNewAttr = new TemplateAttribute(String_256(TEXT("ObjectName")), 00553 IsBarButton ? NewBarName : "", 00554 IsBarButton ? NewButtonName : NewExtenderName); 00555 00556 if (pNewAttr) // create the node ok 00557 { 00558 pNewAttr->AttachNode(pTheCopy, FIRSTCHILD); 00559 00560 if (IsBarButton) 00561 { 00562 if (!Target.IsEmpty() && RequiredLevel > 1) 00563 // create the properties for the button/Target that this extender extends 00564 SliceHelper::CreatePropertiesForSet(NewButtonName, NewBarName, TRUE, TRUE, FALSE, ExtenderFlags, 00565 NewExtenderName, FALSE, &rTarget, &rExtender, this); 00566 else // create none stretching attribs for the button 00567 SliceHelper::CreatePropertiesForSet(NewButtonName, NewBarName, TRUE, FALSE, FALSE, 0, 00568 TEXT(""), FALSE, NULL, NULL, this); 00569 00570 // test to see if this button is in fact a trigger for something bigger 00571 // if the source is ButtonName then add NewButtonName to that list 00572 SliceHelper::MakeTriggerLikeExample(NewButtonName, ButtonName); 00573 } 00574 else // create the properties for the extender 00575 { 00576 SliceHelper::CreatePropertiesForSet(NewExtenderName, TEXT(""), FALSE, FALSE, FALSE, 0, 00577 TEXT(""), FALSE, NULL, NULL, this); 00578 // test to see if this extender is in fact a trigger for something bigger 00579 // but not just the button we already know it to trigger 00580 // if the source is ButtonName then add NewButtonName to that list 00581 SliceHelper::MakeTriggerLikeExample(NewExtenderName, Extender, &Target); 00582 } 00583 00584 DoHideNode(pAttrib, TRUE); 00585 } 00586 } 00587 } 00588 } 00589 00590 pAttrib = pNext; 00591 } 00592 00593 // transform the node into its new location in the bar 00594 ((NodeRenderableBounded *)pTheCopy)->Transform(*pTransformer); 00595 00596 return pTheCopy; 00597 }
|
|
Clones a bar, but gives the bar a new name and each button in the bar and new name. This is so each bar can work independantly or together. If they are just copied they would have the same bar IDs and the same button names which is not likely to be what the user would expect.
Reimplemented from Operation. Definition at line 243 of file opdupbar.cpp. 00244 { 00245 if (DoStartSelOp(FALSE,TRUE)) // Try to record the selection state 00246 { 00247 // unpack the names of the bar to be copied and the new bars name from the params 00248 DuplicateBar(((OpParamBarDuplication *)pOpParam)->m_OldBarName, 00249 ((OpParamBarDuplication *)pOpParam)->m_NewBarName, 00250 ((OpParamBarDuplication *)pOpParam)->m_ButtonsToAdd, 00251 ((OpParamBarDuplication *)pOpParam)->m_Spacing, 00252 ((OpParamBarDuplication *)pOpParam)->m_IsHoriz); 00253 00254 00255 // end the op 00256 End(); 00257 00258 DialogBarOp::SetSystemStateChanged(); 00259 DialogBarOp::UpdateStateOfAllBars(); 00260 00261 } 00262 else 00263 { 00264 FailAndExecute(); 00265 End(); 00266 } 00267 }
|
|
Clones a bar, but gives the bar a new name and each button in the bar and new name. This is so each bar can work independantly or together. If they are just copied they would have the same bar IDs and the same button names which is not likely to be what the user would expect.
Definition at line 293 of file opdupbar.cpp. 00294 { 00295 00296 // scan each of the special state layers for the original bar members 00297 // pionters to these template attributes are stored in the BarList 00298 00299 // I don't want bar duplication at the moment thanks. 00300 // I just want to 00301 ASSERT (ButtonsToAdd > 0); 00302 00303 String_256 templayer; 00304 Layer * pLayer = NULL; 00305 00306 List BarList; 00307 00308 templayer.Load(_R(IDS_ROLLOVER_DEFAULT)); 00309 pLayer = SliceHelper::FindLayerCalled(templayer); 00310 Layer * pDefLayer = pLayer; 00311 if (pLayer) 00312 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName); 00313 00314 templayer.Load(_R(IDS_ROLLOVER_MOUSE)); 00315 pLayer = SliceHelper::FindLayerCalled(templayer); 00316 if (pLayer) 00317 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName); 00318 00319 templayer.Load(_R(IDS_ROLLOVER_CLICKED)); 00320 pLayer = SliceHelper::FindLayerCalled(templayer); 00321 if (pLayer) 00322 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName); 00323 00324 templayer.Load(_R(IDS_ROLLOVER_SELECTED)); 00325 pLayer = SliceHelper::FindLayerCalled(templayer); 00326 if (pLayer) 00327 SliceHelper::BuildListOfNodesInBar(&BarList, pLayer, OriginalBarName); 00328 00329 // calculate the dimensions of the bar 00330 // this is so we can work out where to place the bar copy 00331 // which is incidently placed either just to the right 00332 // or just bellow depending upon orientation 00333 00334 NodeListItem *pNodeListItem = (NodeListItem *)BarList.GetHead(); 00335 NodeListItem *pDelThisToo = NULL; 00336 00337 // find the number of buttons in the bar and what they are called 00338 m_ExistingButtonsInBar = 0; 00339 SliceHelper::CountButtonsInBarScan(pDefLayer, (TemplateAttribute **) m_ppFoundButton, &m_ExistingButtonsInBar, OriginalBarName); 00340 00341 templayer = ((TemplateAttribute *) m_ppFoundButton[0])->GetParam(); 00342 00343 DocRect BarDim; 00344 DocRect FirstButtonDim; 00345 00346 BarDim.MakeEmpty(); 00347 FirstButtonDim.MakeEmpty(); 00348 00349 while(pNodeListItem) 00350 { 00351 Node* pNode = pNodeListItem->pNode->FindParent(); 00352 if (pNode) 00353 { 00354 BarDim = BarDim.Union(((NodeRenderableBounded *) pNode)->GetBoundingRect()); 00355 if (templayer.CompareTo(((TemplateAttribute *)pNodeListItem->pNode)->GetParam()) == 0) 00356 FirstButtonDim = FirstButtonDim.Union(((NodeRenderableBounded *) pNode)->GetBoundingRect()); 00357 } 00358 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem); 00359 } 00360 00361 // calc the transform matrix to be applied to each element when we copy it 00362 Trans2DMatrix Transformer; 00363 00364 // test differences between the first button and the whole bar in with compared to height 00365 if (BarDim.hix - BarDim.lox + FirstButtonDim.hix - FirstButtonDim.lox > 00366 BarDim.hiy - BarDim.loy + FirstButtonDim.hiy - FirstButtonDim.loy) 00367 Transformer.SetTransform(0, BarDim.loy - BarDim.hiy); 00368 else 00369 Transformer.SetTransform(BarDim.hix - BarDim.lox, 0); 00370 00371 // find new names for the new buttons 00372 String_256 TempButtonName; 00373 INT32 i = 0, listbuttonno = 0; 00374 for (i = 0; i < MAX_BUTTONS_IN_A_BAR; i++) 00375 { 00376 m_ButtonNumberList[i] = i; 00377 if (i < max(m_ExistingButtonsInBar, ButtonsToAdd)) 00378 { 00379 // get the next free button name and put it into listbuttonno 00380 SliceHelper::GetNextFreeButtonName(listbuttonno); 00381 00382 m_ButtonNumberList[i] = listbuttonno; 00383 } 00384 } 00385 00386 // copy each item referenced by a template attrib marked with this bar ID 00387 pNodeListItem = (NodeListItem *)BarList.GetHead(); 00388 String_256 Name = ""; 00389 00390 // Prepare an ObjChangeParam so we can mark which nodes will allow this op to happen to them 00391 ObjChangeFlags cFlags; 00392 //cFlags.MultiReplaceNode = TRUE; 00393 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this); 00394 00395 while(pNodeListItem) 00396 { 00397 pDelThisToo = pNodeListItem; 00398 Node *pNode = pNodeListItem->pNode; 00399 if (pNode && pNode->AllowOp(&ObjChange)) 00400 { 00401 if (ButtonsToAdd == 0) // add the whole lot as a new bar 00402 { 00403 Node * NewNode = CopyBarMember(pNode, OriginalBarName, NewBarName, &Transformer); 00404 if (NewNode) 00405 NewNode->AllowOp(&ObjChange); 00406 } 00407 else 00408 { 00409 // add a few buttons on the end 00410 Name = ((TemplateAttribute *)pNode)->GetParam(); 00411 00412 // note it just copies the first button several times to make the new buttons 00413 if (Name.CompareTo(((TemplateAttribute *) m_ppFoundButton[0])->GetParam()) == 0) 00414 for (i = 0; i < ButtonsToAdd; i++) 00415 { 00416 // alter tranformer for each button 00417 if (IsHoriz) 00418 Transformer.SetTransform(BarDim.hix - BarDim.lox + (i+1)*(Spacing) + i*(FirstButtonDim.hix - FirstButtonDim.lox), 0); 00419 else 00420 Transformer.SetTransform(0, BarDim.loy - BarDim.hiy - ((i+1)*(Spacing) + i*( FirstButtonDim.hiy - FirstButtonDim.loy))); 00421 00422 Node * NewNode = CopyBarMember(pNode, OriginalBarName, OriginalBarName, &Transformer, &i); 00423 if (NewNode) 00424 NewNode->AllowOp(&ObjChange); 00425 } 00426 } 00427 } 00428 00429 pNodeListItem = (NodeListItem *)BarList.GetNext(pNodeListItem); 00430 00431 // tidy up the list as we go along 00432 BarList.RemoveItem((NodeListItem *)pDelThisToo); 00433 delete pDelThisToo; 00434 } 00435 00436 // touch the bar in question 00437 NameGallery * pNameGallery = NameGallery::Instance(); 00438 if (pNameGallery) 00439 { 00440 pNameGallery->m_TouchedBar = SliceHelper::GetBarNumberFromBarName(NewBarName); 00441 } 00442 00443 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this); 00444 UpdateChangedNodes(&ObjChange); 00445 00446 00447 BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED)); 00448 00449 }
|
|
Generates names for the new bar.
Definition at line 611 of file opdupbar.cpp. 00612 { 00613 String_256 TempButtonName; 00614 INT32 butno = -1; 00615 INT32 i = 0; 00616 for (i = 0; butno < 0 && i < m_ExistingButtonsInBar; i++) 00617 { 00618 if (Name.CompareTo(((TemplateAttribute *) m_ppFoundButton[i])->GetParam()) == 0) 00619 butno = i; 00620 } 00621 00622 // return the button if we have found the extender 00623 if (butno < 0) 00624 { 00625 String_256 ExtenderPostfix; 00626 ExtenderPostfix.Load(_R(IDS_EXTENDER_POSTFIX)); 00627 00628 for (i = 0; butno < 0 && i < m_ExistingButtonsInBar; i++) 00629 { 00630 TempButtonName = ((TemplateAttribute *) m_ppFoundButton[i])->GetParam(); 00631 TempButtonName += ExtenderPostfix; 00632 00633 if (Name.CompareTo(TempButtonName) == 0) 00634 butno = i; 00635 } 00636 } 00637 00638 if (butno < 0) 00639 butno = m_ExistingButtonsInBar; 00640 00641 TempButtonName.MakeMsg(_R(IDS_BUTTONNAME), m_ButtonNumberList[butno]); 00642 return TempButtonName; 00643 }
|
|
For finding the operations state.
Reimplemented from CarbonCopyOp. Definition at line 212 of file opdupbar.cpp. 00213 { 00214 OpState OpSt; 00215 00216 // if we don't allow it 00217 OpSt.Greyed = TRUE; 00218 Spread* pSpread = Document::GetSelectedSpread(); 00219 if (pSpread && !pSpread->FindActiveLayer()->IsFrame()) 00220 OpSt.Greyed = FALSE; 00221 00222 return(OpSt); 00223 }
|
|
OpDuplicateBar initialiser method.
Reimplemented from SimpleCCObject. Definition at line 181 of file opdupbar.cpp. 00182 { 00183 return (RegisterOpDescriptor(0, 00184 _R(IDS_BARDUPLICATIONOP), 00185 CC_RUNTIME_CLASS(OpDuplicateBar), 00186 OPTOKEN_BARDUPLICATIONOP, 00187 OpDuplicateBar::GetState, 00188 0, // help ID 00189 0, //_R(IDBBL_BARDUPLICATIONOP),// bubble help 00190 0, // resource ID 00191 0, //_R(IDC_BC_CREATE), // control ID 00192 SYSTEMBAR_ILLEGAL, // Bar ID 00193 TRUE, // Receive messages 00194 FALSE, 00195 FALSE, 00196 0, 00197 (GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE) )); 00198 }
|
|
Definition at line 137 of file opdupbar.h. |
|
Definition at line 139 of file opdupbar.h. |
|
Definition at line 138 of file opdupbar.h. |