#include <liveeffectstool.h>
Inheritance diagram for LiveEffectsTool:
Public Member Functions | |
LiveEffectsTool () | |
Dummp Constructor - It does nothing. All the real initialisation is done in LiveEffectsTool::Init which is called by the Tool Manager. | |
~LiveEffectsTool () | |
Destructor (Virtual). Does nothing. | |
BOOL | Init () |
Used to check if the Tool was properly constructed. | |
void | Describe (void *InfoPtr) |
Allows the tool manager to extract information about the tool. | |
UINT32 | GetID () |
virtual void | SelectChange (BOOL) |
Called when the tool is selected or deselected. Creates and pushes the tool's cursor; pops and destroys it. | |
virtual void | OnClick (DocCoord, ClickType, ClickModifiers, Spread *) |
To handle a Mouse Click event for the FreeHand Tool. It starts up a FreeHand Operation. | |
virtual void | OnMouseMove (DocCoord, Spread *, ClickModifiers) |
This routine is called whenever the mouse moves while we're in the freehand tool. it sees what is under the pointer, and flips the cursor if clicking will have a different effect. The rules are:. | |
virtual BOOL | GetStatusLineText (String_256 *ptext, Spread *, DocCoord, ClickModifiers) |
Sets the status line text on request from the app. | |
virtual BOOL | OnIdle () |
Ensure UI is up to date. | |
LiveEffectsInfoBarOp * | GetInfoBar () const |
void | ScreenChanged (BOOL WipeRegion) |
Essentially - clear your cached info because it may be out of date. | |
EffectsStack * | GetEffectsStack () const |
Allow info bar to get at LE stack whenever it needs to. | |
String_256 | GetCurrentEffectID () const |
void | SetCurrentEffectID (String_256 strNewEffectID) |
INT32 | GetCurrentStackPos () |
void | SetCurrentStackPos (INT32 iNewPos) |
BOOL | UpdatePPStack (BOOL bUCE=TRUE) |
Get a list of LE nodes that are common to all selected nodes Only returns a list of ALL the selected nodes have identical stacks above them... | |
Protected Member Functions | |
BOOL | LoadCursors () |
Loads all the cursors used by the freehand tool and pushs the normal one onto the top of the cursor stack. | |
void | RemoveCursors () |
Pops the freehand tools cursor off the top of the cursor stack, frees the memory used by all the cursors in the freehand tool and sets all the pointers to NULL. | |
void | ChangeCursor (Cursor *pCursor) |
Changes to the specified cursor. Will only change the cursor if it isn't already this cursor, so it doesn't flicker. | |
Protected Attributes | |
String_256 | StatusMsg |
DocCoord | StartPos |
Spread * | StartSpread |
Cursor * | pNormalCursor |
Cursor * | pActiveCursor |
INT32 | CurrentCursorID |
LiveEffectsInfoBarOp * | m_pInfoBarOp |
EffectsStack * | m_pPPStack |
String_256 | m_strCurrentEffectID |
INT32 | m_iCurrentStackPos |
Static Protected Attributes | |
static char * | FamilyName = "PostProcessor Tools" |
static char * | ToolName = "Live Effects Tool" |
static char * | Purpose = "Apply live bitmap effects to drawn objects" |
static char * | Author = "Phil" |
Private Member Functions | |
CC_DECLARE_MEMDUMP (LiveEffectsTool) |
Definition at line 133 of file liveeffectstool.h.
|
Dummp Constructor - It does nothing. All the real initialisation is done in LiveEffectsTool::Init which is called by the Tool Manager.
Definition at line 163 of file liveeffectstool.cpp. 00164 { 00165 // No info bar or previous path by default 00166 m_pInfoBarOp = NULL; 00167 00168 // Set the cursor pointers to null 00169 pNormalCursor = NULL; 00170 pActiveCursor = NULL; 00171 00172 // Make sure that the status line text is a valid string 00173 StatusMsg = String_256(""); 00174 00175 m_pPPStack = NULL; 00176 m_strCurrentEffectID = String_256(""); 00177 m_iCurrentStackPos = 0; 00178 }
|
|
Destructor (Virtual). Does nothing.
Definition at line 192 of file liveeffectstool.cpp. 00193 { 00194 ScreenChanged(FALSE); 00195 }
|
|
|
|
Changes to the specified cursor. Will only change the cursor if it isn't already this cursor, so it doesn't flicker.
Definition at line 497 of file liveeffectstool.cpp. 00498 { 00499 // only change if this cursor is different from the current cursor 00500 if ((pCursor!=pActiveCursor) && (pCursor!=NULL)) 00501 { 00502 // set this cursor as the current cursor and immediately display it 00503 CursorStack::GSetTop(pCursor, CurrentCursorID); 00504 00505 // remember this is our current cursor 00506 pActiveCursor = pCursor; 00507 } 00508 }
|
|
Allows the tool manager to extract information about the tool.
Reimplemented from Tool_v1. Definition at line 278 of file liveeffectstool.cpp. 00279 { 00280 // Cast structure into the latest one we understand. 00281 ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr; 00282 00283 Info->InfoVersion = 1; 00284 Info->InterfaceVersion = GetToolInterfaceVersion(); // You should always have this line. 00285 00286 // These are all arbitrary at present. 00287 Info->Version = 1; 00288 Info->ID = GetID(); 00289 Info->TextID = _R(IDS_LIVEEFFECT_TOOL); 00290 Info->BubbleID = _R(IDBBL_LIVEEFFECT_TOOLBOX); 00291 00292 Info->Family = FamilyName; 00293 Info->Name = ToolName; 00294 Info->Purpose = Purpose; 00295 Info->Author = Author; 00296 00297 Info->InfoBarDialog = _R(IDD_LIVEEFFECTSTOOL); 00298 }
|
|
Definition at line 158 of file liveeffectstool.h. 00158 {return m_strCurrentEffectID;}
|
|
Definition at line 160 of file liveeffectstool.h. 00160 {return m_iCurrentStackPos;}
|
|
Allow info bar to get at LE stack whenever it needs to.
Definition at line 705 of file liveeffectstool.cpp. 00706 { 00707 return m_pPPStack; 00708 }
|
|
Reimplemented from Tool_v1. Definition at line 301 of file liveeffectstool.cpp. 00302 { 00303 return TOOLID_LIVEEFFECT; 00304 }
|
|
Definition at line 155 of file liveeffectstool.h. 00155 { return m_pInfoBarOp;}
|
|
Sets the status line text on request from the app.
Reimplemented from Tool_v1. Definition at line 655 of file liveeffectstool.cpp.
|
|
Used to check if the Tool was properly constructed.
Reimplemented from Tool_v1. Definition at line 211 of file liveeffectstool.cpp. 00212 { 00213 // This should be set to NULL by default. It will be set properly below, if 00214 // everthing is working as it should 00215 m_pInfoBarOp = NULL; 00216 00217 // Now we have to declare all our operations and if that works, try to find 00218 // the liveeffects tools info bar and create it 00219 if (OpLiveEffect::Init()) 00220 { 00221 // Resource File and Object that creates FreeHandInfoBarOp objects 00222 CCResTextFile ResFile; 00223 LiveEffectsInfoBarOpCreate BarCreate; 00224 00225 if (ResFile.open(_R(IDM_LIVEEFFECTS_BAR), _R(IDT_INFO_BAR_RES))) 00226 { 00227 // Found the file and opened it 00228 if (DialogBarOp::ReadBarsFromFile(ResFile,BarCreate)) 00229 { 00230 // read it in ok, so close it 00231 ResFile.close(); 00232 00233 // Info bar now exists. Now get a pointer to it 00234 String_32 str = String_32(_R(IDS_LIVEEFFECTS_INFOBARNAME)); 00235 DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(str); 00236 00237 // Should have a dialog bar op by now 00238 if (pDialogBarOp != NULL) 00239 { 00240 // Make sure it is what we were expecting and set it 00241 if (pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(LiveEffectsInfoBarOp))) 00242 { 00243 m_pInfoBarOp = (LiveEffectsInfoBarOp*) pDialogBarOp; 00244 m_pInfoBarOp->m_pTool = this; 00245 } 00246 } 00247 } 00248 } 00249 } 00250 00251 // See if it all worked and return depending on the result 00252 ENSURE(m_pInfoBarOp!=NULL, "Failed to create LiveEffects Info Bar" ); 00253 if (m_pInfoBarOp==NULL) 00254 return FALSE; 00255 else 00256 return TRUE; 00257 }
|
|
Loads all the cursors used by the freehand tool and pushs the normal one onto the top of the cursor stack.
Definition at line 417 of file liveeffectstool.cpp. 00418 { 00419 // This tool has just been selected, so it is not displaying a cursor 00420 pActiveCursor = NULL; 00421 00422 // Try to create all our cursors - The normal cursor 00423 pNormalCursor = new Cursor(this, _R(IDC_LIVEEFFECTSTOOLCURSOR)); 00424 00425 // did we get all the cursors ok 00426 if ((pNormalCursor==NULL) || (!pNormalCursor->IsValid())) 00427 { 00428 // No, at least one of them was NULL, so delete them all 00429 // Deleting the null cursor will be ok 00430 delete pNormalCursor; 00431 00432 // and ensure that the pointers are set to NULL 00433 pNormalCursor = NULL; 00434 00435 // and set an error and return 00436 ERROR1(FALSE, _R(IDE_LIVEEFFECT_BADCURSORS)); 00437 } 00438 00439 // All the cursors loaded ok if we got to here 00440 // So push the normal cursor onto the stack and mark it as active 00441 CurrentCursorID = CursorStack::GPush(pNormalCursor, FALSE); 00442 pActiveCursor = pNormalCursor; 00443 00444 // return that it worked 00445 return TRUE; 00446 }
|
|
To handle a Mouse Click event for the FreeHand Tool. It starts up a FreeHand Operation.
Reimplemented from DragTool. Definition at line 535 of file liveeffectstool.cpp. 00537 { 00538 // Stub out this function if the tool isn't wanted 00539 #ifndef NO_ADVANCED_TOOLS 00540 00541 if (ClickMods.Menu) return; // Don't do anything if the user clicked the Menu button 00542 00543 // See if there is already a drag going on 00544 if (Operation::GetCurrentDragOp()!=NULL) 00545 return; 00546 00547 // If we get a click, treat it like a mouse move, allowing the tool to set up 00548 // any info that is passed to the operation in the drag 00549 // NEW 17/4/2000 Now we also want to click-select in the Freehand tool 00550 if (Click==CLICKTYPE_SINGLE) 00551 { 00552 OnMouseMove(PointerPos, pSpread, ClickMods); 00553 DragTool::OnClick (PointerPos, Click, ClickMods, pSpread); 00554 } 00555 00556 if (Click == CLICKTYPE_UP) 00557 { 00558 // so long as we are not interfering with any drawing operations we will 00559 // try and change the selection 00560 //if (JoinInfo.pJoinPath == NULL) 00561 { 00562 DragTool::OnClick (PointerPos, Click, ClickMods, pSpread); 00563 SelRange* pSelRange = GetApplication()->FindSelection(); 00564 if (pSelRange) pSelRange->MakePartialSelectionWhole(TRUE, FALSE, TRUE); 00565 00566 BROADCAST_TO_ALL(CommonAttrsChangedMsg); 00567 } 00568 } 00569 #endif // NO_ADVANCED_TOOLS 00570 }
|
|
Ensure UI is up to date.
Reimplemented from Tool_v1. Definition at line 795 of file liveeffectstool.cpp. 00796 { 00797 // just check that we have a document 00798 if (Document::GetCurrent() == NULL) 00799 return FALSE; 00800 00801 // If any of our cached information about the selection is out of date 00802 // update it and reflect those changes in the Infobar 00803 BOOL bChanged = UpdatePPStack(); 00804 if (bChanged && m_pInfoBarOp!=NULL) 00805 { 00806 // m_pInfoBarOp->PopulateOrderDropdown(m_pPPStack, m_iCurrentStackPos); 00807 00808 // INT32 iPos = m_iCurrentStackPos; 00809 // ListRange* pLevelRange = NULL; 00810 // if (m_pPPStack) 00811 // pLevelRange = m_pPPStack->GetLevelRange(&iPos); 00812 // m_pInfoBarOp->PopulateResolutionDropdown(pLevelRange); 00813 // m_pInfoBarOp->UpdateLockButton(pLevelRange); 00814 // m_pInfoBarOp->UpdateLockAllButton(); 00815 m_pInfoBarOp->UpdateState(); 00816 00817 // IXMLDOMDocumentPtr pDoc = XPEHost::GetEditorsList(); 00818 // m_pInfoBarOp->PopulateTypeDropdown(pDoc, m_strCurrentEffectName); // overkill - we only want to update the selected item 00819 } 00820 00821 return FALSE; 00822 }
|
|
This routine is called whenever the mouse moves while we're in the freehand tool. it sees what is under the pointer, and flips the cursor if clicking will have a different effect. The rules are:.
Reimplemented from Tool_v1. Definition at line 591 of file liveeffectstool.cpp. 00592 { 00593 // Stub out this function if the tool isn't wanted 00594 #ifndef NO_ADVANCED_TOOLS 00595 00596 // We are interested in any selected paths that the cursor is over 00597 // we will also be needing the current docview 00598 SelRange* Selected = GetApplication()->FindSelection(); 00599 Node* pNode = Selected->FindFirst(); 00600 00601 // Check to see if the selection is on the same spread as the mouse 00602 if (pNode!=NULL) 00603 { 00604 // Get the spread and return if it is different from the one with the cursor 00605 Spread* pNodeSpread = pNode->FindParentSpread(); 00606 if (pNodeSpread!=pSpread) 00607 return; 00608 } 00609 00610 // Find the Blob manager, so we can find out how big a rect to use 00611 BlobManager* pBlobMgr = GetApplication()->GetBlobManager(); 00612 if (pBlobMgr==NULL) 00613 return; 00614 00615 // Find the Rect round the mouse pos that counts as a hit 00616 DocRect BlobRect; 00617 pBlobMgr->GetBlobRect(Coord, &BlobRect); 00618 00619 // Work out the square of the distance that we will count as 'close' to the line 00620 INT32 Range = BlobRect.Width() / 2; 00621 Range *= Range; 00622 00623 // // loop through the selection 00624 // while (pNode!=NULL) 00625 // { 00626 // // Now find the next selected node 00627 // pNode = Selected->FindNext(pNode); 00628 // } 00629 00630 // We did not find anything good, so set the cursor to the normal one 00631 ChangeCursor(pNormalCursor); 00632 00633 // And set the status bar text 00634 StatusMsg.Load(_R(IDS_LIVEEFFECTSTART), Tool::GetModuleID(GetID())); 00635 GetApplication()->UpdateStatusBarText(&StatusMsg); 00636 00637 #endif // NO_ADVANCED_TOOLS 00638 }
|
|
Pops the freehand tools cursor off the top of the cursor stack, frees the memory used by all the cursors in the freehand tool and sets all the pointers to NULL.
Definition at line 463 of file liveeffectstool.cpp. 00464 { 00465 // If we ever had a cursor 00466 if (pActiveCursor!=NULL) 00467 { 00468 // pop it off the stack 00469 CursorStack::GPop(CurrentCursorID); 00470 00471 // and free up the cursors we allocated 00472 delete pNormalCursor; 00473 00474 // and set them all to NULL 00475 pNormalCursor = NULL; 00476 pActiveCursor = NULL; 00477 CurrentCursorID = 0; 00478 } 00479 }
|
|
Essentially - clear your cached info because it may be out of date.
Definition at line 677 of file liveeffectstool.cpp. 00678 { 00679 // Get rid of our record of common LiveEffects in the stack above the selection 00680 if (m_pPPStack) 00681 { 00682 delete m_pPPStack; 00683 m_pPPStack = NULL; 00684 } 00685 00686 // m_iCurrentStackPos = 0; 00687 }
|
|
Called when the tool is selected or deselected. Creates and pushes the tool's cursor; pops and destroys it.
Reimplemented from Tool_v1. Definition at line 324 of file liveeffectstool.cpp. 00325 { 00326 // Stub out this function if the tool isn't wanted 00327 #ifndef NO_ADVANCED_TOOLS 00328 00329 if (isSelected) 00330 { 00331 //MessageBox(NULL, "SelectChange 1", "Debug", MB_OK); 00332 // Load the cursors 00333 if (!LoadCursors()) 00334 InformError(); 00335 00336 // Update the list of plug-ins 00337 //MessageBox(NULL, "SelectChange 2", "Debug", MB_OK); 00338 XPEHost::UpdateEditorsList(); 00339 //MessageBox(NULL, "SelectChange 3", "Debug", MB_OK); 00340 SelRange* pSelRange = GetApplication()->FindSelection(); 00341 if (pSelRange) pSelRange->MakePartialSelectionWhole(TRUE, FALSE, TRUE); 00342 ScreenChanged(FALSE); 00343 //MessageBox(NULL, "SelectChange 4", "Debug", MB_OK); 00344 00345 // Find the blob manager ready for later 00346 BlobManager* BlobMgr = GetApplication()->GetBlobManager(); 00347 00348 // Create and display my info bar please 00349 if (m_pInfoBarOp != NULL) 00350 { 00351 m_pInfoBarOp->Create(); 00352 m_pInfoBarOp->SetToolActiveState(TRUE); 00353 } 00354 00355 // Make sure that Objects blobs are on 00356 if (BlobMgr != NULL) 00357 { 00358 // Decide which blobs to display 00359 BlobStyle MyBlobs; 00360 MyBlobs.Object = TRUE; 00361 00362 // tell the blob manager 00363 BlobMgr->ToolInterest(MyBlobs); 00364 } 00365 //MessageBox(NULL, "SelectChange 5", "Debug", MB_OK); 00366 00367 } 00368 else 00369 { 00370 // Deselection of the tool 00371 // Get rid of all the tools cursors 00372 RemoveCursors(); 00373 00374 // Close any open XPE editing 00375 XPEHost::EndEditLiveEffect(); 00376 00377 // Hide and destroy my info bar please 00378 if (m_pInfoBarOp != NULL) 00379 { 00380 m_pInfoBarOp->SetToolActiveState(FALSE); 00381 00382 // Close any open dialogs related to the info bar here 00383 00384 m_pInfoBarOp->Delete(); 00385 } 00386 00387 // ensure that the colour picker is working 00388 // SetColourEditorProcessing(TRUE); 00389 00390 // ensure any tool object blobs are removed. 00391 BlobManager* BlobMgr = GetApplication()->GetBlobManager(); 00392 if (BlobMgr != NULL) 00393 { 00394 BlobStyle bsRemoves; 00395 bsRemoves.ToolObject = TRUE; 00396 BlobMgr->RemoveInterest(bsRemoves); 00397 } 00398 } 00399 #endif // NO_ADVANCED_TOOLS 00400 }
|
|
Definition at line 159 of file liveeffectstool.h. 00159 {m_strCurrentEffectID = strNewEffectID;}
|
|
Definition at line 161 of file liveeffectstool.h. 00161 {m_iCurrentStackPos = iNewPos;}
|
|
Get a list of LE nodes that are common to all selected nodes Only returns a list of ALL the selected nodes have identical stacks above them...
Definition at line 728 of file liveeffectstool.cpp. 00729 { 00730 if (m_pPPStack!=NULL) 00731 return FALSE; 00732 00733 m_pPPStack = EffectsStack::GetEffectsStackFromSelection(); 00734 00735 BOOL bOK; 00736 00737 // If we know what type of effect we were last editing, try to find that type again 00738 if (!m_strCurrentEffectID.IsEmpty()) 00739 { 00740 bOK = m_pPPStack->FindBestProcessor(&m_strCurrentEffectID, &m_iCurrentStackPos); 00741 if (!bOK) 00742 { 00743 m_strCurrentEffectID.Empty(); 00744 m_iCurrentStackPos = STACKPOS_TOP; 00745 } 00746 } 00747 00748 // If we don't have a current effect set for the current stack then try to 00749 // find the topmost effect 00750 if (m_strCurrentEffectID.IsEmpty()) 00751 { 00752 m_iCurrentStackPos = STACKPOS_TOP; 00753 bOK = m_pPPStack->GetLevelInfo(&m_strCurrentEffectID, &m_iCurrentStackPos); 00754 if (!bOK) 00755 { 00756 m_strCurrentEffectID.Empty(); 00757 m_iCurrentStackPos = STACKPOS_TOP; 00758 } 00759 } 00760 00761 // Tell any running XPE editor that things have changed 00762 if (bUCE) 00763 OpLiveEffect::UpdateCurrentEditor(); 00764 00765 // Safety net: UpdateCurrentEditor should not leave m_pPPStack NULL! 00766 ERROR3IF(m_pPPStack==NULL, "Effect tool's effect stack is NULL in UpdatePPStack!"); 00767 if (m_pPPStack==NULL) 00768 m_pPPStack = EffectsStack::GetEffectsStackFromSelection(); 00769 00770 // Safety net: UpdateCurrentEditor should not leave m_pPPStack NULL! 00771 ERROR3IF(m_pPPStack==NULL, "Effect tool's effect stack is NULL in UpdatePPStack!"); 00772 if (m_pPPStack==NULL) 00773 m_pPPStack = EffectsStack::GetEffectsStackFromSelection(); 00774 00775 return TRUE; 00776 }
|
|
Reimplemented from DragTool. Definition at line 175 of file liveeffectstool.h. |
|
Definition at line 187 of file liveeffectstool.h. |
|
Reimplemented from DragTool. Definition at line 172 of file liveeffectstool.h. |
|
Definition at line 197 of file liveeffectstool.h. |
|
Definition at line 190 of file liveeffectstool.h. |
|
Definition at line 193 of file liveeffectstool.h. |
|
Definition at line 196 of file liveeffectstool.h. |
|
Definition at line 186 of file liveeffectstool.h. |
|
Definition at line 185 of file liveeffectstool.h. |
|
Reimplemented from DragTool. Definition at line 174 of file liveeffectstool.h. |
|
Definition at line 181 of file liveeffectstool.h. |
|
Definition at line 182 of file liveeffectstool.h. |
|
Definition at line 178 of file liveeffectstool.h. |
|
Reimplemented from DragTool. Definition at line 173 of file liveeffectstool.h. |