00001 // $Id: liveeffectstool.cpp 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 // The LiveEffects Tool 00099 // Created by Phil on 27/09/2004 00100 00101 /* 00102 */ 00103 00104 #include "camtypes.h" 00105 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 //#include "resource.h" // _R(IDS_OUTOFMEMORY) 00107 //#include "barsdlgs.h" 00108 //#include "mario.h" 00109 //#include "phil.h" 00110 //#include "markn.h" 00111 //#include "viewrc.h" 00112 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00113 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00114 #include "mainfrm.h" 00115 #include "infobar.h" 00116 #include "csrstack.h" 00117 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00118 #include "liveeffectsinfo.h" 00119 #include "liveeffectstool.h" 00120 //#include "liveeffectres.h" 00121 #include "opliveeffects.h" 00122 //#include "range.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00123 #include "module.h" 00124 #include "ezmodule.h" 00125 #include "oilfiles.h" 00126 #include "nodetxts.h" 00127 #include "nodeblnd.h" 00128 #include "ndbldpth.h" 00129 #include "blobs.h" 00130 #include "comattrmsg.h" 00131 #include "xpehost.h" 00132 #include "nodeliveeffect.h" 00133 00134 00135 // Set things up so that the tool will be listed in the Dialog box 00136 DECLARE_SOURCE("$Revision: 1282 $"); 00137 00138 00139 // These are still char* while we wait for resource technology to be developed for modules 00140 char* LiveEffectsTool::FamilyName = "PostProcessor Tools"; 00141 char* LiveEffectsTool::ToolName = "Live Effects Tool"; 00142 char* LiveEffectsTool::Purpose = "Apply live bitmap effects to drawn objects"; 00143 char* LiveEffectsTool::Author = "Phil"; 00144 00145 CC_IMPLEMENT_MEMDUMP( LiveEffectsTool, Tool_v1 ) 00146 00147 // Better memory tracking please 00148 #define new CAM_DEBUG_NEW 00149 00150 00151 /******************************************************************************************** 00152 00153 > LiveEffectsTool::LiveEffectsTool() 00154 00155 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00156 Created: 21/6/93 00157 Purpose: Dummp Constructor - It does nothing. All the real initialisation is done 00158 in LiveEffectsTool::Init which is called by the Tool Manager 00159 SeeAlso: LiveEffectsTool::Init 00160 00161 ********************************************************************************************/ 00162 00163 LiveEffectsTool::LiveEffectsTool() 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 } 00179 00180 00181 00182 /******************************************************************************************** 00183 00184 > LiveEffectsTool::~LiveEffectsTool() 00185 00186 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00187 Created: 21/6/93 00188 Purpose: Destructor (Virtual). Does nothing. 00189 00190 ********************************************************************************************/ 00191 00192 LiveEffectsTool::~LiveEffectsTool() 00193 { 00194 ScreenChanged(FALSE); 00195 } 00196 00197 00198 00199 /******************************************************************************************** 00200 00201 > BOOL LiveEffectsTool::Init( INT32 Pass ) 00202 00203 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00204 Created: 21/6/93 00205 Returns: FALSE if it does not want to be created, TRUE otherwise 00206 Purpose: Used to check if the Tool was properly constructed 00207 SeeAlso: LiveEffectsTool::LiveEffectsTool 00208 00209 ********************************************************************************************/ 00210 00211 BOOL LiveEffectsTool::Init() 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 } 00258 00259 00260 00261 00262 00263 /******************************************************************************************** 00264 00265 > void LiveEffectsTool::Describe(void *InfoPtr) 00266 00267 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00268 Created: 21/6/93 00269 Inputs: InfoPtr - A pointer to a tool info block. It is passed cast to void* as 00270 the version of the tool is unknown at this point. Later versions of the 00271 Tool class may have more items in this block, that this tool will not use 00272 Outputs: InfoPtr - The structure pointed to by InfoPtr will have had all the info 00273 that this version of the Tool knows about 00274 Purpose: Allows the tool manager to extract information about the tool 00275 00276 ********************************************************************************************/ 00277 00278 void LiveEffectsTool::Describe(void *InfoPtr) 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 } 00299 00300 00301 UINT32 LiveEffectsTool::GetID() 00302 { 00303 return TOOLID_LIVEEFFECT; 00304 } 00305 00306 00307 00308 // The LiveEffects Tools EventHandlers 00309 00310 /******************************************************************************************** 00311 00312 > virtual void LiveEffectsTool::SelectChange(BOOL isSelected) 00313 00314 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00315 Created: 24/11/93 00316 Inputs: IsSelected - TRUE if the tool is becoming selected, FALSE if it is loosing 00317 the selection 00318 Purpose: Called when the tool is selected or deselected. Creates and pushes the 00319 tool's cursor; pops and destroys it. 00320 Errors: Sends warning to debugging terminal if creating the cursor fails. 00321 00322 ********************************************************************************************/ 00323 00324 void LiveEffectsTool::SelectChange(BOOL isSelected) 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 } 00401 00402 00403 00404 /******************************************************************************************** 00405 00406 > BOOL LiveEffectsTool::LoadCursors() 00407 00408 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00409 Created: 21/10/94 00410 Returns: TRUE if it worked, FALSE if it did not 00411 Purpose: Loads all the cursors used by the freehand tool and pushs the normal 00412 one onto the top of the cursor stack 00413 Errors: ERROR1 (_R(IDE_FHAND_BADCURSORS)) if it fails to load the cursors 00414 00415 ********************************************************************************************/ 00416 00417 BOOL LiveEffectsTool::LoadCursors() 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 } 00447 00448 00449 00450 /******************************************************************************************** 00451 00452 > void LiveEffectsTool::RemoveCursors() 00453 00454 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00455 Created: 21/10/94 00456 Purpose: Pops the freehand tools cursor off the top of the cursor stack, frees the 00457 memory used by all the cursors in the freehand tool and sets all the pointers 00458 to NULL. 00459 SeeAlso: LiveEffectsTool::LoadCursors 00460 00461 ********************************************************************************************/ 00462 00463 void LiveEffectsTool::RemoveCursors() 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 } 00480 00481 00482 00483 00484 /******************************************************************************************** 00485 00486 > void LiveEffectsTool::ChangeCursor(Cursor* cursor) 00487 00488 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00489 Created: 16/3/94 00490 Inputs: ID of the cursor you want to flip to 00491 Purpose: Changes to the specified cursor. Will only change the cursor if it isn't already 00492 this cursor, so it doesn't flicker. 00493 Errors: can fail if the cursor cannot be created - the cursor code will fail. 00494 00495 ********************************************************************************************/ 00496 00497 void LiveEffectsTool::ChangeCursor(Cursor* pCursor) 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 } 00509 00510 00511 00512 00513 00514 00515 /******************************************************************************************** 00516 00517 > void LiveEffectsTool::OnClick( DocCoord PointerPos, ClickType Click, 00518 ClickModifiers ClickMods, Spread *pSpread ) 00519 00520 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00521 Created: 21/6/93 00522 Inputs: PointerPos - The Coords (in spread coords) of the point where the mouse 00523 button was clicked 00524 Click - Describes the type of click that was detected. 00525 ClickMods - Indicates which buttons caused the click and which modifers were 00526 pressed at the same time 00527 pSpread - the spread in which the click happened 00528 Returns: TRUE if it handled the Click, FALSE otherwise 00529 Purpose: To handle a Mouse Click event for the FreeHand Tool. It starts up a FreeHand 00530 Operation. 00531 SeeAlso: Tool::MouseClick; ClickType; ClickModifiers 00532 00533 ********************************************************************************************/ 00534 00535 void LiveEffectsTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, 00536 Spread* pSpread ) 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 } 00571 00572 00573 00574 00575 /******************************************************************************************** 00576 00577 > void LiveEffectsTool::OnMouseMove(DocCoord* coord, Spread* pSpread, ClickModifiers mods) 00578 00579 Author: Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> 00580 Created: 15/3/94 00581 Inputs: coordinate of mouse move, pointer to spread containing coord; click modifiers 00582 Purpose: This routine is called whenever the mouse moves while we're in the freehand 00583 tool. it sees what is under the pointer, and flips the cursor if clicking 00584 will have a different effect. The rules are: 00585 00586 Over space, no selection - freehand cursor 00587 Over selected endpoint - add freehand to line 00588 00589 ********************************************************************************************/ 00590 00591 void LiveEffectsTool::OnMouseMove(DocCoord Coord, Spread* pSpread, ClickModifiers mods) 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 } 00639 00640 00641 00642 /******************************************************************************************** 00643 00644 > BOOL LiveEffectsTool::GetStatusLineText(String_256* ptext, Spread*, DocCoord, ClickModifiers) 00645 00646 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00647 Created: 5/1/95 00648 Inputs: Others not used 00649 Outputs: pText - pointer to a string that will hold the text 00650 Returns: TRUE if it set the text, FALSE if not 00651 Purpose: Sets the status line text on request from the app. 00652 00653 ********************************************************************************************/ 00654 00655 BOOL LiveEffectsTool::GetStatusLineText(String_256* ptext, Spread*, DocCoord, ClickModifiers) 00656 { 00657 *ptext = StatusMsg; 00658 return TRUE; 00659 } 00660 00661 00662 00663 00664 /******************************************************************************************** 00665 00666 > void LiveEffectsTool::ScreenChanged() 00667 00668 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00669 Created: 05/10/2004 00670 Inputs: - 00671 Outputs: - 00672 Returns: - 00673 Purpose: Essentially - clear your cached info because it may be out of date 00674 00675 ********************************************************************************************/ 00676 00677 void LiveEffectsTool::ScreenChanged(BOOL WipeRegion) 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 } 00688 00689 00690 00691 00692 /******************************************************************************************** 00693 00694 > EffectsStack* LiveEffectsTool::GetEffectsStack() 00695 00696 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00697 Created: 06/10/2004 00698 Inputs: - 00699 Outputs: - 00700 Returns: - 00701 Purpose: Allow info bar to get at LE stack whenever it needs to 00702 00703 ********************************************************************************************/ 00704 00705 EffectsStack* LiveEffectsTool::GetEffectsStack() const 00706 { 00707 return m_pPPStack; 00708 } 00709 00710 00711 00712 00713 /******************************************************************************************** 00714 00715 > BOOL LiveEffectsTool::UpdatePPStack() 00716 00717 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00718 Created: 05/10/2004 00719 Inputs: - 00720 Outputs: - 00721 Returns: - 00722 Purpose: Get a list of LE nodes that are common to all selected nodes 00723 Only returns a list of ALL the selected nodes have identical stacks 00724 above them... 00725 00726 ********************************************************************************************/ 00727 00728 BOOL LiveEffectsTool::UpdatePPStack(BOOL bUCE) 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 } 00777 00778 00779 00780 00781 /******************************************************************************************** 00782 00783 > BOOL LiveEffectsTool::OnIdle() 00784 00785 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00786 Created: 06/10/2004 00787 Inputs: - 00788 Outputs: - 00789 Returns: TRUE if we don't need any more idles 00790 FALSE if we expect idle calls to continue 00791 Purpose: Ensure UI is up to date 00792 00793 ********************************************************************************************/ 00794 00795 BOOL LiveEffectsTool::OnIdle() 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 } 00823 00824 00825 00826 00827 IMPLEMENT_SIMPLE_MODULE( LiveEffectModule, MODULEID_LIVEFFECT, LiveEffectsTool, 00828 "Live Effect Tool", "To do bitmap things to drawn objects", "Phil" ); 00829 00830 00831 00832 00833