00001 // $Id: brushop.cpp 1732 2006-09-03 14:08:16Z 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 00099 // brush operation implementation 00100 00101 #include "camtypes.h" 00102 #include "brshattr.h" 00103 #include "ppbrush.h" 00104 #include "brushop.h" 00105 //#include "rik.h" 00106 //#include "markn.h" 00107 #include "brushmsg.h" 00108 #include "brushdlg.h" 00109 #include "freehand.h" 00110 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00111 #include "sgline.h" 00112 #include "freeinfo.h" 00113 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00114 #include "toollist.h" 00115 //#include "bitmapcache.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00116 00117 CC_IMPLEMENT_DYNCREATE( OpChangeBrushDefinition, UndoableOperation ); 00118 CC_IMPLEMENT_DYNCREATE(ChangeBrushDefAction, Action); 00119 CC_IMPLEMENT_DYNAMIC(ChangeBrushDefOpParam, ChangeBrushOpParam); 00120 CC_IMPLEMENT_DYNCREATE(OpSelectBrush, UndoableOperation); 00121 CC_IMPLEMENT_DYNCREATE(OpDeactivateBrush, UndoableOperation); 00122 CC_IMPLEMENT_DYNCREATE(DeactivateBrushDefAction, Action); 00123 00125 // OpChangeBrushDefinition - to change the features of the brush definition 00127 00128 00129 /******************************************************************************************** 00130 00131 > OpChangeBrushDefinition::OpChangeBrushDefinition() 00132 00133 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00134 Created: 18/11/99 00135 Returns: - 00136 Purpose: Constructor 00137 00138 ********************************************************************************************/ 00139 00140 OpChangeBrushDefinition::OpChangeBrushDefinition() 00141 { 00142 ChangeType = CHANGEBRUSH_NONE; 00143 } 00144 00145 00146 /******************************************************************************************** 00147 00148 > OpChangeBrushDefinition::~OpChangeBrushDefinition() 00149 00150 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00151 Created: 18/11/99 00152 Returns: - 00153 Purpose: destructor 00154 ********************************************************************************************/ 00155 00156 OpChangeBrushDefinition::~OpChangeBrushDefinition() 00157 { 00158 00159 } 00160 00161 /******************************************************************************************** 00162 00163 > BOOL OpChangeBrushDefinition::Declare() 00164 00165 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00166 Created: 18/11/99 00167 Returns: TRUE if all went OK, FALSE otherwise 00168 Purpose: Adds the operation to the list of all known operations 00169 00170 ********************************************************************************************/ 00171 00172 BOOL OpChangeBrushDefinition::Declare() 00173 { 00174 return (RegisterOpDescriptor( 00175 0, 00176 0, 00177 CC_RUNTIME_CLASS(OpChangeBrushDefinition), 00178 OPTOKEN_CHANGEBRUSHDEF, 00179 OpChangeBrushDefinition::GetState, 00180 0, /* help ID */ 00181 0, /* bubble ID */ 00182 0 /* bitmap ID */ 00183 )); 00184 } 00185 00186 00187 00188 /******************************************************************************************** 00189 00190 > static OpState OpChangeBrushDefinition::GetState(String_256* Description, OpDescriptor*) 00191 00192 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00193 Created: 18/11/99 00194 Outputs: Description - GetState fills this string with an approriate description 00195 of the current state of the operation 00196 Returns: The state of the operation, so that menu items (ticks and greying) can be 00197 done properly 00198 Purpose: Find out the state of the operation at the specific time 00199 00200 ********************************************************************************************/ 00201 00202 OpState OpChangeBrushDefinition::GetState(String_256* Description, OpDescriptor*) 00203 { 00204 OpState Bob; 00205 00206 00207 return Bob; 00208 00209 } 00210 00211 /******************************************************************************************** 00212 00213 > virtual void OpChangeBrushDefinition::GetOpName(String_256* OpName) 00214 00215 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00216 Created: 18/11/99 00217 Inputs: - 00218 Outputs: The undo string for the operation 00219 Returns: 00220 Purpose: The GetOpName fn is overridden so that we return back a description 00221 appropriate to the type of attribute that the operation applies. 00222 Although this looks identical to the OpChangeBrush fn. it is worth 00223 keeping this separate because the ChangeAll string needs to be used 00224 for saving the brush definition 00225 Errors: - 00226 SeeAlso: - 00227 00228 ********************************************************************************************/ 00229 00230 00231 void OpChangeBrushDefinition::GetOpName(String_256* OpName) 00232 { 00233 UINT32 IDS = _R(IDS_MARKN_EMPTY); 00234 00235 switch (ChangeType) 00236 { 00237 case CHANGEBRUSH_NONE: break; 00238 case CHANGEBRUSH_SPACING: IDS = _R(IDS_BRUSHSPACING_UNDO); break; 00239 case CHANGEBRUSH_SPACING_INCRPROP: IDS = _R(IDS_BRUSHSPACING_INCR); break; 00240 case CHANGEBRUSH_SPACING_INCRCONST: IDS = _R(IDS_BRUSHSPACING_INCR); break; 00241 case CHANGEBRUSH_SPACING_MAXRAND: IDS = _R(IDS_BRUSHSPACING_MAXRAND); break; 00242 case CHANGEBRUSH_SPACING_RANDSEED: IDS = _R(IDS_BRUSHSPACING_RANDSEED); break; 00243 case CHANGEBRUSH_SCALING: IDS = _R(IDS_BRUSHSCALING_UNDO); break; 00244 case CHANGEBRUSH_SCALING_INCR: IDS = _R(IDS_BRUSHSCALING_INCR); break; 00245 case CHANGEBRUSH_SCALING_INCRCONST: IDS = _R(IDS_BRUSHSCALING_INCR); break; 00246 case CHANGEBRUSH_SCALING_MAXRAND: IDS = _R(IDS_BRUSHSCALING_MAXRAND); break; 00247 case CHANGEBRUSH_SCALING_RANDSEED: IDS = _R(IDS_BRUSHSCALING_RANDSEED); break; 00248 case CHANGEBRUSH_OFFSET_TYPE: IDS = _R(IDS_BRUSHOFFSET_TYPE_UNDO);break; 00249 case CHANGEBRUSH_OFFSET_TYPE_SEED: IDS = _R(IDS_OFFSETTYPE_RANDSEED); break; 00250 case CHANGEBRUSH_OFFSET_VAL: IDS = _R(IDS_BRUSHOFFSET_VAL_UNDO); break; 00251 case CHANGEBRUSH_OFFSET_VALSEED: IDS = _R(IDS_OFFSETVAL_RANDSEED); break; 00252 case CHANGEBRUSH_OFFSET_INCRPROP: IDS = _R(IDS_BRUSHOFFSET_INCR); break; 00253 case CHANGEBRUSH_OFFSET_INCRCONST: IDS = _R(IDS_BRUSHOFFSET_INCR); break; 00254 case CHANGEBRUSH_OFFSET_MAXRAND: IDS = _R(IDS_OFFSETVAL_MAXRAND); break; 00255 case CHANGEBRUSH_TILED: IDS = _R(IDS_BRUSHTILE_UNDO); break; 00256 case CHANGEBRUSH_TANGENTIAL: IDS = _R(IDS_BRUSHROTATE_UNDO); break; 00257 case CHANGEBRUSH_ROTATE_ANGLE: IDS = _R(IDS_BRUSHROTATE_ANGLE_UNDO); break; 00258 case CHANGEBRUSH_ROTATE_PRESSURE: IDS = _R(IDS_BRUSHROTATE_PRESSURE); break; 00259 case CHANGEBRUSH_NAME: IDS = _R(IDS_BRUSHNAME_UNDO); break; 00260 case CHANGEBRUSH_SEQUENCE: IDS = _R(IDS_BRUSHNAME_UNDO); break; 00261 case CHANGEBRUSH_SEQUENCE_RANDSEED: IDS = _R(IDS_SEQUENCE_RANDSEED); break; 00262 case CHANGEBRUSH_USELOCALFILLCOL: IDS = _R(IDS_BRUSH_USELOCAL_FILLCOL); break; 00263 case CHANGEBRUSH_ALL: IDS = _R(IDS_BRUSH_SAVEDEFINITION); break; 00264 case CHANGEBRUSH_ROTATE_MAXRAND: IDS = _R(IDS_ROTATE_MAXRAND); break; 00265 case CHANGEBRUSH_ROTATE_RANDSEED: IDS = _R(IDS_ROTATE_RANDSEED); break; 00266 case CHANGEBRUSH_TIMESTAMP: IDS = _R(IDS_TIMESTAMP_PERIOD); break; 00267 case CHANGEBRUSH_REGEN: break; 00268 00269 default: ERROR3_PF(("Unknown flag type (%d)",ChangeType)); break; 00270 } 00271 00272 *OpName = String_256(IDS); 00273 } 00274 00275 00276 /******************************************************************************************** 00277 00278 > void OpChangeBrushDefinition::DoWithParam(OpDescriptor*,OpParam* pOpParam) 00279 00280 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00281 Created: 18/11/99 00282 Returns: - 00283 Purpose: This changes the flag specified in FlagType (given in pOpParam->Param1) in all the 00284 selected brush objects to have the same as state of pOpParam->Param2. 00285 00286 ********************************************************************************************/ 00287 00288 void OpChangeBrushDefinition::DoWithParam(OpDescriptor*,OpParam* pOpParam) 00289 { 00290 ERROR3IF(pOpParam == NULL,"NULL OpParam ptr"); 00291 if (pOpParam == NULL) 00292 { 00293 FailAndExecute(); 00294 return; 00295 } 00296 00297 ChangeBrushDefOpParam* pChangeParam = (ChangeBrushDefOpParam*)pOpParam; 00298 00299 // no point doing anything if we have a default brush 00300 if (pChangeParam->m_Handle == BrushHandle_NoBrush) 00301 { 00302 FailAndExecute(); 00303 return; 00304 } 00305 00306 ChangeBrushDefAction* pAction; 00307 00308 // change the brush in an undoable way 00309 BOOL ok = ChangeBrushDefAction::Init(this,&UndoActions, 00310 pChangeParam,&pAction) != AC_FAIL; 00311 00312 if (ok) 00313 { 00314 // Note the way the selected brush were changed 00315 ChangeType = pChangeParam->ChangeType; 00316 } 00317 else 00318 FailAndExecute(); 00319 00320 End(); 00321 } 00322 00323 //------------------------------------------------------------------------------------------------ 00324 //------------------------------------------------------------------------------------------------ 00325 //------------------------------------------------------------------------------------------------ 00326 // The ChangeBrushDefAction class 00327 00328 /******************************************************************************************** 00329 00330 > ChangeBrushDefAction::ChangeBrushDefAction() 00331 00332 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00333 Created: 18/11/99 00334 Inputs: - 00335 Outputs: - 00336 Returns: - 00337 Purpose: Constructor for the action 00338 Errors: - 00339 SeeAlso: - 00340 00341 ********************************************************************************************/ 00342 00343 ChangeBrushDefAction::ChangeBrushDefAction() 00344 { 00345 } 00346 00347 00348 /******************************************************************************************** 00349 00350 > ChangeBrushDefAction::~ChangeBrushDefAction() 00351 00352 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00353 Created: 18/11/99 00354 Inputs: - 00355 Outputs: - 00356 Returns: - 00357 Purpose: destructor for the action 00358 Errors: - 00359 SeeAlso: - 00360 00361 ********************************************************************************************/ 00362 00363 00364 ChangeBrushDefAction::~ChangeBrushDefAction() 00365 { 00366 } 00367 00368 /******************************************************************************************** 00369 00370 > ActionCode ChangeBrushDefAction::Init( Operation* pOp, 00371 ActionList* pActionList, 00372 NodeRenderableInk * pNodeBrush, 00373 ChangeBrushOpParam *pChangeParam, 00374 ChangeBrushDefAction** ppNewAction); 00375 00376 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00377 Created: 18/11/99 00378 Inputs: pOp = ptr to the operation to which this action belongs 00379 pActionList = ptr to action list to which this action should be added 00380 pBrushedNode = ptr to node with brush attribute to change 00381 pChangeParam = ptr to class that details how the blend should be changed. 00382 Outputs: ppNewAction = ptr to a ptr to an action, allowing the function to return 00383 a pointer to the created action 00384 Returns: ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL 00385 Purpose: This is the function which creates an instance of this action. If there is no room 00386 in the undo buffer (which is determined by the base class Init function called within) 00387 the function will either return AC_NO_RECORD which means the operation can continue, 00388 but no undo information needs to be stored, or AC_OK which means the operation should 00389 continue AND record undo information. If the function returns AC_FAIL, there was not 00390 enough memory to record the undo information, and the user has decided not to continue 00391 with the operation. 00392 00393 This function actually changes the blend node in a way specified in pChangeParam 00394 Errors: - 00395 SeeAlso: Action::Init() 00396 00397 ********************************************************************************************/ 00398 00399 00400 00401 ActionCode ChangeBrushDefAction::Init( Operation* pOp, 00402 ActionList* pActionList, 00403 ChangeBrushDefOpParam* pChangeParam, 00404 ChangeBrushDefAction** ppNewAction) 00405 { 00406 ERROR2IF(pChangeParam == NULL,AC_FAIL,"pChangeParam is NULL"); 00407 00408 // just check that we do actually have a brush definition 00409 00410 // get the brush component from the document 00411 Document* pDoc = Document::GetCurrent(); 00412 ERROR2IF(pDoc == NULL, AC_FAIL, "Wheres the document?"); 00413 BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent)); 00414 ERROR2IF(pBrushComp == NULL, AC_FAIL, "No brush component"); 00415 00416 BrushDefinition* pBrushDef = pBrushComp->FindBrushDefinition(pChangeParam->m_Handle); 00417 if (pBrushDef == NULL) 00418 return AC_FAIL; 00419 00420 // make the new action 00421 UINT32 ActSize = sizeof(ChangeBrushDefAction); 00422 ChangeBrushDefAction* pNewAction; 00423 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(ChangeBrushDefAction),(Action**)&pNewAction); 00424 *ppNewAction = pNewAction; 00425 00426 if (Ac != AC_FAIL && pNewAction != NULL) 00427 { 00428 00429 ChangeBrushType ChangeType = pChangeParam->ChangeType; 00430 // set data in the new action 00431 pNewAction->m_ChangeParam.ChangeType = ChangeType; 00432 pNewAction->m_ChangeParam.SetOldValues(pBrushDef); 00433 pNewAction->m_ChangeParam.m_Handle = pChangeParam->m_Handle; 00434 00435 switch (ChangeType) 00436 { 00437 case CHANGEBRUSH_SPACING: 00438 if (ChangeBrushSpacing(pChangeParam->m_NewSpacing, pBrushDef) == FALSE) 00439 Ac = AC_FAIL; 00440 break; 00441 case CHANGEBRUSH_SPACING_INCRPROP: 00442 if (!ChangeSpacingIncrProp(pChangeParam->m_NewSpacingIncrProp, pBrushDef)) 00443 Ac = AC_FAIL; 00444 break; 00445 case CHANGEBRUSH_SPACING_INCRCONST: 00446 if (!ChangeSpacingIncrConst(pChangeParam->m_NewSpacingIncrConst, pBrushDef)) 00447 Ac = AC_FAIL; 00448 break; 00449 case CHANGEBRUSH_SCALING_INCR: 00450 if (!ChangeScalingIncr(pChangeParam->m_NewScalingIncr, pBrushDef)) 00451 Ac = AC_FAIL; 00452 break; 00453 case CHANGEBRUSH_SCALING_INCRCONST: 00454 if (!ChangeScalingIncrConst(pChangeParam->m_NewScalingIncrConst, pBrushDef)) 00455 Ac = AC_FAIL; 00456 break; 00457 case CHANGEBRUSH_SCALING: 00458 if (ChangeBrushScaling(pChangeParam->m_NewScaling, pBrushDef) == FALSE) 00459 Ac = AC_FAIL; 00460 break; 00461 case CHANGEBRUSH_SCALING_MAXRAND: 00462 if (!ChangeScalingMaxRand(pChangeParam->m_NewScalingMaxRand, pBrushDef)) 00463 Ac = AC_FAIL; 00464 break; 00465 case CHANGEBRUSH_SCALING_RANDSEED: 00466 if (!ChangeScalingRandSeed(pChangeParam->m_NewScalingRandSeed, pBrushDef)) 00467 Ac = AC_FAIL; 00468 break; 00469 case CHANGEBRUSH_SCALING_PRESSURE: 00470 if (!ChangeScalingPressure(pChangeParam->m_NewScalingMaxPressure, pBrushDef)) 00471 Ac = AC_FAIL; 00472 break; 00473 case CHANGEBRUSH_TILED: 00474 ChangeBrushTile(pChangeParam->m_bNewTiled, pBrushDef); 00475 break; 00476 case CHANGEBRUSH_TANGENTIAL: 00477 ChangeTangential(pChangeParam->m_bNewRotated, pBrushDef); 00478 break; 00479 case CHANGEBRUSH_OFFSET_TYPE: 00480 if (!ChangeOffsetType(pChangeParam->m_NewPathOffsetType, pBrushDef)) 00481 Ac = AC_FAIL; 00482 break; 00483 case CHANGEBRUSH_OFFSET_TYPE_SEED: 00484 if (!ChangeOffsetTypeSeed(pChangeParam->m_NewOffsetTypeRandSeed, pBrushDef)) 00485 Ac = AC_FAIL; 00486 break; 00487 case CHANGEBRUSH_OFFSET_VAL: 00488 if (!ChangeOffsetValue(pChangeParam->m_NewPathOffsetVal, pBrushDef)) 00489 Ac = AC_FAIL; 00490 break; 00491 case CHANGEBRUSH_OFFSET_INCRPROP: 00492 if (!ChangeOffsetIncrProp(pChangeParam->m_NewOffsetIncrProp, pBrushDef)) 00493 Ac = AC_FAIL; 00494 break; 00495 case CHANGEBRUSH_OFFSET_INCRCONST: 00496 if (!ChangeOffsetIncrConst(pChangeParam->m_NewOffsetIncrConst, pBrushDef)) 00497 Ac = AC_FAIL; 00498 break; 00499 case CHANGEBRUSH_OFFSET_MAXRAND: 00500 if (!ChangeOffsetValMaxRand(pChangeParam->m_NewOffsetValMaxRand, pBrushDef)) 00501 Ac = AC_FAIL; 00502 break; 00503 case CHANGEBRUSH_OFFSET_VALSEED: 00504 if (!ChangeOffsetValRandSeed(pChangeParam->m_NewOffsetValRandSeed, pBrushDef)) 00505 Ac = AC_FAIL; 00506 break; 00507 case CHANGEBRUSH_ROTATE_ANGLE: 00508 if (!ChangeRotation(pChangeParam->m_NewRotateAngle, pBrushDef)) 00509 Ac = AC_FAIL; 00510 break; 00511 case CHANGEBRUSH_ROTATE_MAXRAND: 00512 if (!ChangeRotationMaxRand(pChangeParam->m_NewRotateMaxRand, pBrushDef)) 00513 Ac = AC_FAIL; 00514 break; 00515 case CHANGEBRUSH_ROTATE_RANDSEED: 00516 if (!ChangeRotationRandSeed(pChangeParam->m_NewRotateRandSeed, pBrushDef)) 00517 Ac = AC_FAIL; 00518 break; 00519 case CHANGEBRUSH_ROTATE_PRESSURE: 00520 if (!ChangeRotationMaxPressure(pChangeParam->m_NewRotationMaxPressure, pBrushDef)) 00521 Ac = AC_FAIL; 00522 break; 00523 case CHANGEBRUSH_SPACING_MAXRAND: 00524 if (!ChangeSpacingMaxRand(pChangeParam->m_NewSpacingMaxRand, pBrushDef)) 00525 Ac = AC_FAIL; 00526 break; 00527 case CHANGEBRUSH_SPACING_RANDSEED: 00528 if (!ChangeSpacingRandSeed(pChangeParam->m_NewSpacingRandSeed, pBrushDef)) 00529 Ac = AC_FAIL; 00530 break; 00531 case CHANGEBRUSH_USELOCALFILLCOL: 00532 if (!ChangeUseLocalFillColour(pChangeParam->m_bNewUseLocalFillColour, pBrushDef)) 00533 Ac = AC_FAIL; 00534 break; 00535 case CHANGEBRUSH_SEQUENCE: 00536 if (!ChangeSequenceType(pChangeParam->m_NewSequenceType, pBrushDef)) 00537 Ac = AC_FAIL; 00538 break; 00539 case CHANGEBRUSH_SEQUENCE_RANDSEED: 00540 if (!ChangeSequenceSeed(pChangeParam->m_NewSequenceRandSeed, pBrushDef)) 00541 Ac = AC_FAIL; 00542 break; 00543 case CHANGEBRUSH_TIMESTAMP: 00544 if (!ChangeTimeStamp(pChangeParam->m_NewTimeStampValue, pBrushDef)) 00545 Ac = AC_FAIL; 00546 break; 00547 case CHANGEBRUSH_NAME: 00548 if (!ChangeBrushName(pChangeParam->m_NewBrushName, pBrushDef)) 00549 Ac = AC_FAIL; 00550 break; 00551 case CHANGEBRUSH_ALL: 00552 if (!ChangeAll(pChangeParam, pBrushDef)) 00553 Ac = AC_FAIL; 00554 break; 00555 default : ERROR2(AC_FAIL,"Unknown change brush type"); break; 00556 00557 } // end switch 00558 00559 // set the new values for the undo 00560 pNewAction->m_ChangeParam.SetNewValues(pBrushDef); 00561 00562 // send a message to whoever is interested 00563 BROADCAST_TO_ALL(BrushDefMsg(pChangeParam->m_Handle)); 00564 } // end if (AC != .. 00565 00566 00567 LineGallery* pGallery = LineGallery::GetInstance(); 00568 if (pGallery != NULL) 00569 pGallery->UpdateBrushItem(pChangeParam->m_Handle); 00570 00571 return Ac; 00572 } 00573 00574 00575 00576 /******************************************************************************************** 00577 00578 > ActionCode ChangeBrushDefAction::Execute(); 00579 00580 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00581 Created: 18/11/99 00582 Inputs: - 00583 Outputs: - 00584 Returns: ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL 00585 Purpose: Executes the action. This will reset the brush variables to their old values 00586 Errors: - 00587 SeeAlso: Action::Init() 00588 00589 ********************************************************************************************/ 00590 00591 ActionCode ChangeBrushDefAction::Execute() 00592 { 00593 m_ChangeParam.SwapOldAndNew(); 00594 00595 ActionCode Act; 00596 ChangeBrushDefAction* pAction; 00597 Act = ChangeBrushDefAction::Init(pOperation,pOppositeActLst,&m_ChangeParam,&pAction); 00598 00599 return Act; 00600 } 00601 00602 00603 00604 /******************************************************************************************** 00605 00606 > BOOL ChangeBrushDefAction::ChangeBrushName(String_32 Name, BrushDefinition* pBrushDef) 00607 00608 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00609 Created: 18/11/99 00610 Inputs: Name - the new name to set 00611 Outputs: pBrushDef - the brush attribute to change 00612 Returns: TRUE if successful, FALSE otherwise 00613 Purpose: Sets the name member for this brush 00614 SeeAlso: - 00615 00616 ********************************************************************************************/ 00617 00618 BOOL ChangeBrushDefAction::ChangeBrushName(String_32 Name, BrushDefinition* pBrushDef) 00619 { 00620 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00621 00622 pBrushDef->SetLineName(&Name); 00623 00624 return TRUE; 00625 } 00626 00627 00628 /******************************************************************************************** 00629 00630 > BOOL ChangeBrushDefAction::ChangeBrushSpacing(MILLIPOINT NewSpacing, BrushDefinition* pBrushDef) 00631 00632 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00633 Created: 18/11/99 00634 Inputs: NewSpacing - the value to set 00635 Outputs: pBrushDef - the brush attribute to change 00636 Returns: TRUE if successful, FALSE otherwise 00637 Purpose: To set the brush spacing of this attribute node 00638 SeeAlso: - 00639 00640 ********************************************************************************************/ 00641 00642 BOOL ChangeBrushDefAction::ChangeBrushSpacing(MILLIPOINT NewSpacing, BrushDefinition* pBrushDef) 00643 { 00644 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00645 00646 return pBrushDef->SetSpacing(NewSpacing); 00647 } 00648 00649 00650 /******************************************************************************************** 00651 00652 > BOOL ChangeBrushDefAction::ChangeSpacingIncrProp(double NewIncrProp, BrushDefinition* pBrushDef) 00653 00654 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00655 Created: 18/11/99 00656 Inputs: NewSpacing - the value to set 00657 Outputs: pBrushDef - the brush attribute to change 00658 Returns: TRUE if successful, FALSE otherwise 00659 Purpose: To set the brush spacing of this attribute node 00660 SeeAlso: - 00661 00662 ********************************************************************************************/ 00663 00664 BOOL ChangeBrushDefAction::ChangeSpacingIncrProp(double NewIncr, BrushDefinition* pBrushDef) 00665 { 00666 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00667 00668 return pBrushDef->SetSpacingIncrProp(NewIncr); 00669 } 00670 00671 00672 /******************************************************************************************** 00673 00674 > BOOL ChangeBrushDefAction::ChangeSpacingIncrConst(MILLIPOINT NewIncr, BrushDefinition* pBrushDef) 00675 00676 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00677 Created: 18/11/99 00678 Inputs: NewSpacing - the value to set 00679 Outputs: pBrushDef - the brush attribute to change 00680 Returns: TRUE if successful, FALSE otherwise 00681 Purpose: To set the brush spacing of this attribute node 00682 SeeAlso: - 00683 00684 ********************************************************************************************/ 00685 00686 BOOL ChangeBrushDefAction::ChangeSpacingIncrConst(MILLIPOINT NewIncr, BrushDefinition* pBrushDef) 00687 { 00688 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00689 00690 return pBrushDef->SetSpacingIncrConst(NewIncr); 00691 } 00692 00693 00694 /******************************************************************************************** 00695 00696 > BOOL ChangeBrushDefAction::ChangeBrushScaling(double NewScaling, BrushDefinition* pBrushDef) 00697 00698 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00699 Created: 18/11/99 00700 Inputs: NewScaling - the value to set 00701 Outputs: pBrushDef - the brush attribute to change 00702 Returns: TRUE if successful, FALSE otherwise 00703 Purpose: To set the brush scaling of this attribute node 00704 SeeAlso: - 00705 00706 ********************************************************************************************/ 00707 00708 BOOL ChangeBrushDefAction::ChangeBrushScaling(double NewScaling, BrushDefinition* pBrushDef) 00709 { 00710 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00711 00712 return pBrushDef->SetBrushScaling(NewScaling); 00713 } 00714 00715 00716 /******************************************************************************************** 00717 00718 > BOOL ChangeBrushDefAction::ChangeScalingIncr(double NewScaling, BrushDefinition* pBrushDef) 00719 00720 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00721 Created: 18/11/99 00722 Inputs: NewScaling - the value to set 00723 Outputs: pBrushDef - the brush attribute to change 00724 Returns: TRUE if successful, FALSE otherwise 00725 Purpose: To set the brush scaling of this attribute node 00726 SeeAlso: - 00727 00728 ********************************************************************************************/ 00729 00730 BOOL ChangeBrushDefAction::ChangeScalingIncr(double NewIncr, BrushDefinition* pBrushDef) 00731 { 00732 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00733 00734 return pBrushDef->SetBrushScalingIncr(NewIncr); 00735 } 00736 00737 00738 /******************************************************************************************** 00739 00740 > BOOL ChangeBrushDefAction::ChangeScalingIncrConst(double Incr, BrushDefinition* pBrushDef) 00741 00742 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00743 Created: 18/11/99 00744 Inputs: Incr - the value to set 00745 Outputs: pBrushDef - the brush definition to change 00746 Returns: TRUE if successful, FALSE otherwise 00747 Purpose: To set the brush scaling of this attribute node 00748 SeeAlso: - 00749 00750 ********************************************************************************************/ 00751 00752 BOOL ChangeBrushDefAction::ChangeScalingIncrConst(double Incr, BrushDefinition* pBrushDef) 00753 { 00754 ERROR2IF(pBrushDef == NULL, FALSE, "brush definition is NULL"); 00755 00756 return pBrushDef->SetBrushScalingIncrConst(Incr); 00757 } 00758 00759 /******************************************************************************************** 00760 00761 > BOOL ChangeBrushDefAction::ChangeScalingMaxRand(UINT32 NewMax, BrushDefinition* pBrushDef) 00762 00763 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00764 Created: 18/11/99 00765 Inputs: NewMax - the value to set 00766 Outputs: pBrushDef - the brush attribute to change 00767 Returns: TRUE if successful, FALSE otherwise 00768 Purpose: To set the amount of brush scaling determined by randomness 00769 SeeAlso: - 00770 00771 ********************************************************************************************/ 00772 00773 BOOL ChangeBrushDefAction::ChangeScalingMaxRand(UINT32 NewMax, BrushDefinition* pBrushDef) 00774 { 00775 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00776 00777 return pBrushDef->SetScalingMaxRand(NewMax); 00778 } 00779 00780 00781 /******************************************************************************************** 00782 00783 > BOOL ChangeBrushDefAction::ChangeScalingRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 00784 00785 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00786 Created: 18/11/99 00787 Inputs: NewSeed - the value to set 00788 Outputs: pBrushDef - the brush attribute to change 00789 Returns: TRUE if successful, FALSE otherwise 00790 Purpose: Sets a new seed for the scaling RNG 00791 SeeAlso: - 00792 00793 ********************************************************************************************/ 00794 00795 BOOL ChangeBrushDefAction::ChangeScalingRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 00796 { 00797 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00798 00799 pBrushDef->SetScalingRandSeed(NewSeed); 00800 return TRUE; 00801 } 00802 00803 00804 /******************************************************************************************** 00805 00806 > BOOL ChangeBrushDefAction::ChangeScalingRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 00807 00808 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00809 Created: 18/11/99 00810 Inputs: NewSeed - the value to set 00811 Outputs: pBrushDef - the brush attribute to change 00812 Returns: TRUE if successful, FALSE otherwise 00813 Purpose: Sets a new seed for the scaling RNG 00814 SeeAlso: - 00815 00816 ********************************************************************************************/ 00817 00818 BOOL ChangeBrushDefAction::ChangeScalingPressure(UINT32 Pressure, BrushDefinition* pBrushDef) 00819 { 00820 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00821 00822 return pBrushDef->SetScalingMaxPressure(Pressure); 00823 } 00824 00825 /******************************************************************************************** 00826 00827 > BOOL ChangeBrushDefAction::Rotation(double NewAngle, BrushDefinition* pBrushDef) 00828 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00829 Created: 18/11/99 00830 Inputs: NewAngle - the value to set 00831 Outputs: pBrushDef - the brush attribute to change 00832 Returns: TRUE if successful, FALSE otherwise 00833 Purpose: To set the brush scaling of this attribute node 00834 SeeAlso: - 00835 00836 ********************************************************************************************/ 00837 00838 BOOL ChangeBrushDefAction::ChangeRotation(double NewAngle, BrushDefinition* pBrushDef) 00839 { 00840 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00841 00842 return pBrushDef->SetRotationAngle(NewAngle); 00843 } 00844 00845 00846 /******************************************************************************************** 00847 00848 > BOOL ChangeBrushDefAction::ChangeRotationMaxRand(UINT32 NewMax, BrushDefinition* pBrushDef) 00849 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00850 Created: 18/11/99 00851 Inputs: NewMax - the value to set 00852 Outputs: pBrushDef - the brush attribute to change 00853 Returns: TRUE if successful, FALSE otherwise 00854 Purpose: To set the maximum random effect on the rotation of this brush 00855 SeeAlso: - 00856 00857 ********************************************************************************************/ 00858 00859 BOOL ChangeBrushDefAction::ChangeRotationMaxRand(UINT32 NewMax, BrushDefinition* pBrushDef) 00860 { 00861 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00862 00863 return pBrushDef->SetRotationMaxRand(NewMax); 00864 } 00865 00866 00867 /******************************************************************************************** 00868 00869 > BOOL ChangeBrushDefAction::ChangeRotationRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 00870 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00871 Created: 18/11/99 00872 Inputs: NewSeed - the value to set 00873 Outputs: pBrushDef - the brush attribute to change 00874 Returns: TRUE if successful, FALSE otherwise 00875 Purpose: To set the seed for the rotation random number generator 00876 SeeAlso: - 00877 00878 ********************************************************************************************/ 00879 00880 BOOL ChangeBrushDefAction::ChangeRotationRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 00881 { 00882 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00883 00884 pBrushDef->SetRotationRandSeed(NewSeed); 00885 00886 return TRUE; 00887 } 00888 00889 00890 /******************************************************************************************** 00891 00892 > BOOL ChangeBrushDefAction::ChangeRotationRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 00893 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00894 Created: 18/11/99 00895 Inputs: NewSeed - the value to set 00896 Outputs: pBrushDef - the brush attribute to change 00897 Returns: TRUE if successful, FALSE otherwise 00898 Purpose: To set the seed for the rotation random number generator 00899 SeeAlso: - 00900 00901 ********************************************************************************************/ 00902 00903 BOOL ChangeBrushDefAction::ChangeRotationMaxPressure(UINT32 Pressure, BrushDefinition* pBrushDef) 00904 { 00905 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00906 00907 return pBrushDef->SetRotationMaxPressure(Pressure); 00908 } 00909 00910 /******************************************************************************************** 00911 00912 > BOOL ChangeBrushDefAction::ChangeTiled(BOOL bTile, BrushDefinition* pBrushDef) 00913 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00914 Created: 18/11/99 00915 Inputs: bTile, to tile, or not 00916 Outputs: pBrushDef - the brush attribute to change 00917 Returns: TRUE if successful, FALSE otherwise 00918 Purpose: To set the tiling of this attribute node 00919 SeeAlso: - 00920 00921 ********************************************************************************************/ 00922 BOOL ChangeBrushDefAction::ChangeBrushTile(BOOL bTile, BrushDefinition* pBrushDef) 00923 { 00924 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00925 pBrushDef->SetTiling(bTile); 00926 00927 return TRUE; 00928 } 00929 00930 00931 /******************************************************************************************** 00932 00933 > BOOL ChangeBrushDefAction::ChangeTangential(BOOL bRotate, BrushDefinition* pBrushDef) 00934 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00935 Created: 18/11/99 00936 Inputs: bTile, to tile, or not 00937 Outputs: pBrushDef - the brush attribute to change 00938 Returns: TRUE if successful, FALSE otherwise 00939 Purpose: To set the tiling of this attribute node 00940 SeeAlso: - 00941 00942 ********************************************************************************************/ 00943 00944 BOOL ChangeBrushDefAction::ChangeTangential(BOOL bRotate, BrushDefinition* pBrushDef) 00945 { 00946 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00947 00948 pBrushDef->SetRotated(bRotate); 00949 00950 return TRUE; 00951 } 00952 00953 00954 /******************************************************************************************** 00955 00956 > BOOL ChangeBrushDefAction::ChangeOffsetValue(MILLIPOINT NewOfdfset, BrushDefinition* pBrushDef) 00957 00958 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00959 Created: 18/11/99 00960 Inputs: NewOffset - the value to set 00961 Outputs: pBrushDef - the brush attribute to change 00962 Returns: TRUE if successful, FALSE otherwise 00963 Purpose: To set the offset value of this attribute node 00964 SeeAlso: - 00965 00966 ********************************************************************************************/ 00967 00968 BOOL ChangeBrushDefAction::ChangeOffsetValue(MILLIPOINT NewOffset, BrushDefinition* pBrushDef) 00969 { 00970 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00971 00972 pBrushDef->SetPathOffsetValue(NewOffset); 00973 00974 return TRUE; 00975 } 00976 00977 00978 /******************************************************************************************** 00979 00980 > BOOL ChangeBrushDefAction::ChangeOffsetIncrProp(double NewIncrProp, BrushDefinition* pBrushDef) 00981 00982 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00983 Created: 18/11/99 00984 Inputs: NewIncrProp - the value to set 00985 Outputs: pBrushDef - the brush attribute to change 00986 Returns: TRUE if successful, FALSE otherwise 00987 Purpose: To set the offset value of this attribute node 00988 SeeAlso: - 00989 00990 ********************************************************************************************/ 00991 00992 BOOL ChangeBrushDefAction::ChangeOffsetIncrProp(double NewIncrProp, BrushDefinition* pBrushDef) 00993 { 00994 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 00995 00996 pBrushDef->SetPathOffsetIncrProp(NewIncrProp); 00997 00998 return TRUE; 00999 } 01000 01001 01002 01003 /******************************************************************************************** 01004 01005 > BOOL ChangeBrushDefAction::ChangeOffsetIncrConst(MILLIPOINT NewIncr, BrushDefinition* pBrushDef) 01006 01007 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01008 Created: 18/11/99 01009 Inputs: NewIncrProp - the value to set 01010 Outputs: pBrushDef - the brush attribute to change 01011 Returns: TRUE if successful, FALSE otherwise 01012 Purpose: To set the offset value of this attribute node 01013 SeeAlso: - 01014 01015 ********************************************************************************************/ 01016 01017 BOOL ChangeBrushDefAction::ChangeOffsetIncrConst(MILLIPOINT NewIncrConst, BrushDefinition* pBrushDef) 01018 { 01019 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01020 01021 pBrushDef->SetPathOffsetIncrConst(NewIncrConst); 01022 01023 return TRUE; 01024 } 01025 01026 01027 01028 /******************************************************************************************** 01029 01030 > BOOL ChangeBrushDefAction::ChangeOffsetValMaxRand(UINT32 NewMax, BrushDefinition* pBrushDef) 01031 01032 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01033 Created: 18/11/99 01034 Inputs: NewMax - the value to set 01035 Outputs: pBrushDef - the brush attribute to change 01036 Returns: TRUE if successful, FALSE otherwise 01037 Purpose: To set how much the offset is determined randomly 01038 SeeAlso: - 01039 01040 ********************************************************************************************/ 01041 01042 BOOL ChangeBrushDefAction::ChangeOffsetValMaxRand(UINT32 NewMax, BrushDefinition* pBrushDef) 01043 { 01044 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01045 01046 pBrushDef->SetOffsetValueMaxRand(NewMax); 01047 01048 return TRUE; 01049 } 01050 01051 01052 /******************************************************************************************** 01053 01054 > BOOL ChangeBrushDefAction::ChangeOffsetValRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 01055 01056 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01057 Created: 18/11/99 01058 Inputs: NewSeed - the value to set 01059 Outputs: pBrushDef - the brush attribute to change 01060 Returns: TRUE if successful, FALSE otherwise 01061 Purpose: To set the seed for the offset value RNG 01062 SeeAlso: - 01063 01064 ********************************************************************************************/ 01065 01066 BOOL ChangeBrushDefAction::ChangeOffsetValRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 01067 { 01068 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01069 01070 pBrushDef->SetOffsetValueRandSeed(NewSeed); 01071 01072 return TRUE; 01073 } 01074 01075 /******************************************************************************************** 01076 01077 > BOOL ChangeBrushDefAction::ChangeOffsetType(PathOffset NewOffset, BrushDefinition* pBrushDef) 01078 01079 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01080 Created: 18/11/99 01081 Inputs: NewOffset - the offset type to set 01082 Outputs: pBrushDef - the brush attribute to change 01083 Returns: TRUE if successful, FALSE otherwise 01084 Purpose: To set the offset value of this attribute node 01085 SeeAlso: - 01086 01087 ********************************************************************************************/ 01088 01089 BOOL ChangeBrushDefAction::ChangeOffsetType(PathOffset NewOffset, BrushDefinition* pBrushDef) 01090 { 01091 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01092 01093 pBrushDef->SetPathOffsetType(NewOffset); 01094 return TRUE; 01095 } 01096 01097 01098 /******************************************************************************************** 01099 01100 > BOOL ChangeBrushDefAction::ChangeOffsetTypeRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 01101 01102 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01103 Created: 18/11/99 01104 Inputs: NewSeed - the offset type to set 01105 Outputs: pBrushDef - the brush attribute to change 01106 Returns: TRUE if successful, FALSE otherwise 01107 Purpose: Sets the seed for the offset type RNG 01108 SeeAlso: - 01109 01110 ********************************************************************************************/ 01111 01112 BOOL ChangeBrushDefAction::ChangeOffsetTypeSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 01113 { 01114 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01115 01116 pBrushDef->SetOffsetTypeRandSeed(NewSeed); 01117 01118 return TRUE; 01119 } 01120 01121 01122 01123 01124 /******************************************************************************************** 01125 01126 > BOOL ChangeBrushDefAction::ChangeSpacingMaxRand(UINT32 MaxRand, BrushDefinition* pBrushDef) 01127 01128 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01129 Created: 18/11/99 01130 Inputs: MaxRand - the new maximum random number 01131 Outputs: pBrushDef - the brush attribute to change 01132 Returns: TRUE if successful, FALSE otherwise 01133 Purpose: To set the maximum random value for spacing for this attribute node 01134 SeeAlso: - 01135 01136 ********************************************************************************************/ 01137 01138 BOOL ChangeBrushDefAction::ChangeSpacingMaxRand(UINT32 NewMaxRand, BrushDefinition* pBrushDef) 01139 { 01140 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01141 01142 pBrushDef->SetSpacingMaxRand(NewMaxRand); 01143 01144 return TRUE; 01145 } 01146 01147 01148 /******************************************************************************************** 01149 01150 > BOOL ChangeBrushDefAction::ChangeSpacingRandSeed(UINT32 RandSeed, BrushDefinition* pBrushDef) 01151 01152 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01153 Created: 18/11/99 01154 Inputs: RandSeed - seed to use for random spacing 01155 Outputs: pBrushDef - the brush attribute to change 01156 Returns: TRUE if successful, FALSE otherwise 01157 Purpose: To set the random seed for spacing for this attribute node 01158 SeeAlso: - 01159 01160 ********************************************************************************************/ 01161 01162 BOOL ChangeBrushDefAction::ChangeSpacingRandSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 01163 { 01164 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01165 01166 pBrushDef->SetSpacingRandSeed(NewSeed); 01167 01168 return TRUE; 01169 } 01170 01171 01172 /******************************************************************************************** 01173 01174 > BOOL ChangeBrushDefAction::ChangeUseLocalfillColour(BOOL UseLocal, BrushDefinition* pBrushDef) 01175 01176 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01177 Created: 18/11/99 01178 Inputs: UseLocal - the flag to set 01179 Outputs: pBrushDef - the brush attribute to change 01180 Returns: TRUE if successful, FALSE otherwise 01181 Purpose: Sets the flag telling this attribute whether to use local attributes 01182 SeeAlso: - 01183 01184 ********************************************************************************************/ 01185 01186 BOOL ChangeBrushDefAction::ChangeUseLocalFillColour(BOOL bUseLocal, BrushDefinition* pBrushDef) 01187 { 01188 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01189 01190 return TRUE; 01191 } 01192 01193 01194 /******************************************************************************************** 01195 01196 > BOOL ChangeBrushDefAction::ChangeSequenceType(SequenceType NewSeq, BrushDefinition* pBrushDef) 01197 01198 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01199 Created: 18/11/99 01200 Inputs: NewSeq - the sequence type to set 01201 Outputs: pBrushDef - the brush attribute to change 01202 Returns: TRUE if successful, FALSE otherwise 01203 Purpose: Sets the flag telling this attribute what type of object sequence to use 01204 SeeAlso: - 01205 01206 ********************************************************************************************/ 01207 01208 BOOL ChangeBrushDefAction::ChangeSequenceType(SequenceType NewSeq, BrushDefinition* pBrushDef) 01209 { 01210 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01211 01212 pBrushDef->SetSequenceType(NewSeq); 01213 return TRUE; 01214 } 01215 01216 01217 01218 /******************************************************************************************** 01219 01220 > BOOL ChangeBrushDefAction::ChangeSequenceType(UINT32 NewSeed, BrushDefinition* pBrushDef) 01221 01222 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01223 Created: 18/11/99 01224 Inputs: NewSeed - the seed to set 01225 Outputs: pBrushDef - the brush attribute to change 01226 Returns: TRUE if successful, FALSE otherwise 01227 Purpose: Seeds the sequence random number generator 01228 SeeAlso: - 01229 01230 ********************************************************************************************/ 01231 01232 BOOL ChangeBrushDefAction::ChangeSequenceSeed(UINT32 NewSeed, BrushDefinition* pBrushDef) 01233 { 01234 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01235 01236 pBrushDef->SetSequenceSeed(NewSeed); 01237 return TRUE; 01238 } 01239 01240 01241 01242 /******************************************************************************************** 01243 01244 > BOOL ChangeBrushDefAction::ChangeTimeStamp(double NewTime, BrushDefinition* pBrushDef) 01245 01246 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01247 Created: 18/11/99 01248 Inputs: NewTime - the timestamping value to set (in ms) 01249 Outputs: pBrushDef - the brush attribute to change 01250 Returns: TRUE if successful, FALSE otherwise 01251 Purpose: sets the timestamping value for this definition 01252 SeeAlso: - 01253 01254 ********************************************************************************************/ 01255 01256 BOOL ChangeBrushDefAction::ChangeTimeStamp(double NewTime, BrushDefinition* pBrushDef) 01257 { 01258 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL"); 01259 01260 return pBrushDef->SetTimeStampingPeriod(NewTime); 01261 } 01262 01263 /******************************************************************************************** 01264 01265 > BOOL ChangeBrushDefAction::ChangeAll(ChangeBrushOpParam* pParam, BrushDefinition* pBrushDef) 01266 01267 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01268 Created: 18/11/99 01269 Inputs: pParam - the opparam containing the data to change in our brush 01270 Outputs: pBrushDef - the brush attribute to change 01271 Returns: TRUE if successful, FALSE otherwise 01272 Purpose: Sets all the variables in the opparam 01273 SeeAlso: - 01274 01275 ********************************************************************************************/ 01276 01277 BOOL ChangeBrushDefAction::ChangeAll(ChangeBrushOpParam* pParam, BrushDefinition* pBrushDef) 01278 { 01279 ERROR2IF(pBrushDef == NULL, FALSE, "brush attribute is NULL in ChangeBrushDefAction::ChangeAll"); 01280 ERROR2IF(pParam == NULL, FALSE, "OpParam is NULL in ChangeBrushDefAction::ChangeAll"); 01281 01282 01283 // scaling members 01284 BOOL ok = pBrushDef->SetBrushScaling(pParam->m_NewScaling); 01285 if (ok) ok = pBrushDef->SetBrushScalingIncr(pParam->m_NewScalingIncr); 01286 if (ok) ok = pBrushDef->SetBrushScalingIncrConst(pParam->m_NewScalingIncrConst); 01287 pBrushDef->SetScalingMaxRand(pParam->m_NewScalingMaxRand); 01288 pBrushDef->SetScalingRandSeed(pParam->m_NewScalingRandSeed); 01289 if (ok) ok = pBrushDef->SetScalingMaxPressure(pParam->m_NewScalingMaxPressure); 01290 01291 // spacing members 01292 if (ok) ok = pBrushDef->SetSpacing(pParam->m_NewSpacing); 01293 if (ok) ok = pBrushDef->SetSpacingIncrConst(pParam->m_NewSpacingIncrConst); 01294 if (ok) ok = pBrushDef->SetSpacingIncrProp(pParam->m_NewSpacingIncrProp); 01295 pBrushDef->SetSpacingMaxRand(pParam->m_NewSpacingMaxRand); 01296 pBrushDef->SetSpacingRandSeed(pParam->m_NewSpacingRandSeed); 01297 01298 01299 // offset members 01300 pBrushDef->SetPathOffsetType(pParam->m_NewPathOffsetType); 01301 pBrushDef->SetPathOffsetValue(pParam->m_NewPathOffsetVal); 01302 if (ok) ok = pBrushDef->SetPathOffsetIncrConst(pParam->m_NewOffsetIncrConst); 01303 if (ok) ok = pBrushDef->SetPathOffsetIncrProp(pParam->m_NewOffsetIncrProp); 01304 pBrushDef->SetOffsetTypeRandSeed(pParam->m_NewOffsetTypeRandSeed); 01305 if (ok) ok = pBrushDef->SetOffsetValueMaxRand(pParam->m_NewOffsetValMaxRand); 01306 pBrushDef->SetOffsetValueRandSeed(pParam->m_NewOffsetValRandSeed); 01307 01308 // rotation members 01309 pBrushDef->SetRotated(pParam->m_bNewRotated); 01310 if (ok) ok = pBrushDef->SetRotationAngle(pParam->m_NewRotateAngle); 01311 pBrushDef->SetRotationIncrConst(pParam->m_NewRotationIncrConst); 01312 pBrushDef->SetRotationIncrProp(pParam->m_NewRotationIncrProp); 01313 pBrushDef->SetRotationMaxRand(pParam->m_NewRotateMaxRand); 01314 pBrushDef->SetRotationMaxPressure(pParam->m_NewRotationMaxPressure); 01315 01316 // sequence members 01317 pBrushDef->SetSequenceType(pParam->m_NewSequenceType); 01318 pBrushDef->SetSequenceSeed(pParam->m_NewSequenceRandSeed); 01319 pBrushDef->SetTiling(pParam->m_bNewTiled); 01320 01321 if (ok) ok = pBrushDef->SetHueIncrement(1.0); 01322 if (ok) ok = pBrushDef->SetHueMaxRand(pParam->m_NewHueMaxRand); 01323 if (ok) ok = pBrushDef->SetHueRandSeed(pParam->m_NewHueRandSeed); 01324 if (ok) ok = pBrushDef->SetSatIncrement(0.0); 01325 if (ok) ok = pBrushDef->SetSatMaxRand(pParam->m_NewSatMaxRand); 01326 if (ok) ok = pBrushDef->SetSatRandSeed(pParam->m_NewSatRandSeed); 01327 01328 if (ok) ok = pBrushDef->SetBrushTransparency(pParam->m_NewTransp); 01329 if (ok) ok = pBrushDef->SetTransparencyPressure(pParam->m_NewTranspPressure); 01330 return ok; 01331 } 01332 01333 /*------------------------------------------------------------------------------------------ 01334 ------------------------CHANGEBRUSHDEFOPPARAM CLASS IMPLEMENTATION-------------------------- 01335 --------------------------------------------------------------------------------------------*/ 01336 01337 01338 /******************************************************************************************** 01339 01340 > ChangeBrushDefOpParam::ChangeBrushDefOpParam(const ChangeBrushOpParam& Other) 01341 01342 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01343 Created: 20/3/95 01344 Inputs: Other the ChangeBrushOpParam whose values we wish to assign 01345 Outputs: - 01346 Returns: - 01347 Purpose: kind of a copy constructor, but takes a member of the base class 01348 Errors: - 01349 01350 ********************************************************************************************/ 01351 01352 ChangeBrushDefOpParam::ChangeBrushDefOpParam(const ChangeBrushOpParam& Other) 01353 { 01354 01355 } 01356 /******************************************************************************************** 01357 01358 > ChangeBrushDefOpParam ChangeBrushDefOpParam::operator=(const ChangeBrushOpParam& Other) 01359 01360 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01361 Created: 20/3/95 01362 Inputs: Other the ChangeBrushOpParam whose values we wish to assign 01363 Outputs: - 01364 Returns: - 01365 Purpose: overrides assignment operator 01366 Errors: - 01367 01368 ********************************************************************************************/ 01369 01370 ChangeBrushOpParam ChangeBrushDefOpParam::operator=(const ChangeBrushOpParam& Other) 01371 { 01372 ChangeBrushOpParam::operator =(Other); 01373 if (Other.IsKindOf(CC_RUNTIME_CLASS(ChangeBrushDefOpParam))) 01374 { 01375 ChangeBrushDefOpParam* pOther = (ChangeBrushDefOpParam*)&Other; 01376 m_Handle = pOther->m_Handle; 01377 } 01378 return *this; 01379 } 01380 01381 01382 /******************************************************************************************** 01383 01384 > void ChangeBrushDefOpParam::SetOldValues(BrushDefinition* pBrushDef) 01385 01386 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01387 Created: 20/3/95 01388 Inputs: pAttrBrush - pointer to brush attribute which is being changed 01389 Outputs: - 01390 Returns: - 01391 Purpose: Copies the current state of the brush node into this classes Old member vars 01392 Errors: - 01393 01394 ********************************************************************************************/ 01395 01396 void ChangeBrushDefOpParam::SetOldValues(BrushDefinition* pBrushDef) 01397 { 01398 if (pBrushDef == NULL) 01399 { 01400 ERROR3("Attribute is NULL"); 01401 return; 01402 } 01403 01404 // spacing 01405 m_OldSpacing = pBrushDef->GetSpacing(); 01406 m_OldSpacingMaxRand = pBrushDef->GetSpacingMaxRand(); 01407 m_OldSpacingRandSeed = pBrushDef->GetSpacingRandSeed(); 01408 m_OldSpacingIncrProp = pBrushDef->GetSpacingIncrProp(); 01409 m_OldSpacingIncrConst = pBrushDef->GetSpacingIncrConst(); 01410 01411 // scaling 01412 m_OldScaling = pBrushDef->GetBrushScaling(); 01413 m_OldScalingIncr = pBrushDef->GetBrushScalingIncr(); 01414 m_OldScalingIncrConst = pBrushDef->GetBrushScalingIncrConst(); 01415 m_OldScalingMaxPressure = pBrushDef->GetScalingMaxPressure(); 01416 m_OldScalingMaxRand = pBrushDef->GetScalingMaxRand(); 01417 m_OldScalingRandSeed = pBrushDef->GetScalingRandSeed(); 01418 01419 // offset 01420 m_OldPathOffsetVal = pBrushDef->GetPathOffsetValue(); 01421 m_OldOffsetIncrProp = pBrushDef->GetPathOffsetIncrProp(); 01422 m_OldOffsetIncrConst = pBrushDef->GetPathOffsetIncrConst(); 01423 m_OldPathOffsetType = pBrushDef->GetPathOffsetType(); 01424 m_OldOffsetValMaxRand = pBrushDef->GetOffsetValueMaxRand(); 01425 m_OldOffsetValRandSeed = pBrushDef->GetOffsetValueRandSeed(); 01426 m_OldOffsetTypeRandSeed = pBrushDef->GetOffsetTypeRandSeed(); 01427 01428 m_bOldTiled = pBrushDef->IsTiled(); 01429 01430 // rotation 01431 m_bOldRotated = pBrushDef->IsRotated(); 01432 m_OldRotateAngle = pBrushDef->GetRotationAngle(); 01433 m_OldRotateRandSeed = pBrushDef->GetRotationRandSeed(); 01434 m_OldRotateMaxRand = pBrushDef->GetRotationMaxRand(); 01435 m_OldRotationMaxPressure = pBrushDef->GetRotationMaxPressure(); 01436 m_OldRotationIncrConst = pBrushDef->GetRotationIncrConst(); 01437 01438 // sequence 01439 m_OldSequenceRandSeed = pBrushDef->GetSequenceSeed(); 01440 m_OldSequenceType = pBrushDef->GetSequenceType(); 01441 01442 // fills 01443 m_OldHueIncrement = pBrushDef->GetHueIncrement(); 01444 m_OldHueMaxRand = pBrushDef->GetHueMaxRand(); 01445 m_OldHueRandSeed = pBrushDef->GetHueRandSeed(); 01446 01447 m_OldSatMaxRand = pBrushDef->GetSatMaxRand(); 01448 m_OldSatRandSeed = pBrushDef->GetSatRandSeed(); 01449 01450 m_OldTransp = pBrushDef->GetBrushTransparency(); 01451 m_OldTranspPressure = pBrushDef->GetTransparencyPressure(); 01452 } 01453 01454 01455 /******************************************************************************************** 01456 01457 > void ChangeBrushDefOpParam::SetNewValues(BrushDefinition* pBrushDef) 01458 01459 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01460 Created: 20/3/95 01461 Inputs: pAttrBrush - the attribute being changed by the operation 01462 Outputs: - 01463 Returns: - 01464 Purpose: Copies the current state of the brush node into this classes New member vars 01465 Errors: - 01466 01467 ********************************************************************************************/ 01468 01469 void ChangeBrushDefOpParam::SetNewValues(BrushDefinition* pBrushDef) 01470 { 01471 if (pBrushDef == NULL) 01472 { 01473 ERROR3("Brush Definition is NULL"); 01474 return; 01475 } 01476 01477 // spacing 01478 m_NewSpacing = pBrushDef->GetSpacing(); 01479 m_NewSpacingMaxRand = pBrushDef->GetSpacingMaxRand(); 01480 m_NewSpacingRandSeed = pBrushDef->GetSpacingRandSeed(); 01481 m_NewSpacingIncrProp = pBrushDef->GetSpacingIncrProp(); 01482 m_NewSpacingIncrConst = pBrushDef->GetSpacingIncrConst(); 01483 01484 // scaling 01485 m_NewScaling = pBrushDef->GetBrushScaling(); 01486 m_NewScalingIncr = pBrushDef->GetBrushScalingIncr(); 01487 m_NewScalingIncrConst = pBrushDef->GetBrushScalingIncrConst(); 01488 m_NewScalingMaxPressure = pBrushDef->GetScalingMaxPressure(); 01489 01490 m_NewPathOffsetVal = pBrushDef->GetPathOffsetValue(); 01491 m_NewOffsetIncrProp = pBrushDef->GetPathOffsetIncrProp(); 01492 m_NewOffsetIncrConst = pBrushDef->GetPathOffsetIncrConst(); 01493 m_NewPathOffsetType = pBrushDef->GetPathOffsetType(); 01494 m_bNewTiled = pBrushDef->IsTiled(); 01495 m_bNewRotated = pBrushDef->IsRotated(); 01496 m_NewRotateAngle = pBrushDef->GetRotationAngle(); 01497 01498 m_NewOffsetTypeRandSeed = pBrushDef->GetOffsetTypeRandSeed(); 01499 m_NewSequenceRandSeed = pBrushDef->GetSequenceSeed(); 01500 m_NewSequenceType = pBrushDef->GetSequenceType(); 01501 m_NewTimeStampValue = (UINT32)pBrushDef->GetTimeStampingPeriod(); 01502 01503 01504 } 01505 01506 /*------------------------------------------------------------------------------------------ 01507 -------------------------------------------------------------------------------------------- 01508 ------------------------OpSelectBrush------------------------------------------------------- 01509 ------------------------------------------------------------------------------------------*/ 01510 01511 01512 /******************************************************************************************** 01513 01514 > OpSelectBrush::OpSelectBrush() 01515 01516 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01517 Created: 18/11/99 01518 Returns: - 01519 Purpose: Constructor 01520 01521 ********************************************************************************************/ 01522 01523 OpSelectBrush::OpSelectBrush() 01524 { 01525 01526 } 01527 01528 01529 /******************************************************************************************** 01530 01531 > OpSelectBrush::~OpSelectBrush() 01532 01533 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01534 Created: 18/11/99 01535 Returns: - 01536 Purpose: destructor 01537 ********************************************************************************************/ 01538 01539 OpSelectBrush::~OpSelectBrush() 01540 { 01541 01542 } 01543 01544 /******************************************************************************************** 01545 01546 > BOOL OpSelectBrush::Declare() 01547 01548 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01549 Created: 18/11/99 01550 Returns: TRUE if all went OK, FALSE otherwise 01551 Purpose: Adds the operation to the list of all known operations 01552 01553 ********************************************************************************************/ 01554 01555 BOOL OpSelectBrush::Declare() 01556 { 01557 return (RegisterOpDescriptor( 01558 0, 01559 _R(IDS_BRUSH_MAKESELECTED), 01560 CC_RUNTIME_CLASS(OpSelectBrush), 01561 OPTOKEN_SELECTBRUSH, 01562 OpSelectBrush::GetState, 01563 0, /* help ID */ 01564 0, /* bubble ID */ 01565 0 /* bitmap ID */ 01566 )); 01567 } 01568 01569 01570 01571 /******************************************************************************************** 01572 01573 > static OpState OpSelectBrush::GetState(String_256* Description, OpDescriptor*) 01574 01575 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01576 Created: 18/11/99 01577 Outputs: Description - GetState fills this string with an approriate description 01578 of the current state of the operation 01579 Returns: The state of the operation, so that menu items (ticks and greying) can be 01580 done properly 01581 Purpose: Find out the state of the operation at the specific time, in this instance 01582 the operation can only be launched when we are in the freehand tool. 01583 01584 ********************************************************************************************/ 01585 01586 OpState OpSelectBrush::GetState(String_256* Description, OpDescriptor*) 01587 { 01588 OpState State; 01589 01590 // make sure we have one and only one brush in the selection before we launch the op 01591 AttrBrushType* pAttrBrush = CBrushEditDlg::GetSingleSelectedBrushAttribute(); 01592 BrushHandle Handle = BrushHandle_NoBrush; 01593 if (pAttrBrush != NULL) 01594 Handle = pAttrBrush->GetBrushHandle(); 01595 01596 // likewise we must be in the freehand tool 01597 Tool* pTool = Tool::GetCurrent(); 01598 if (pTool != NULL && pTool->GetID() != TOOLID_FREEHAND) 01599 pTool = NULL; 01600 01601 // plus its only worth doing if we are selecting an actual brush 01602 if (Handle != BrushHandle_NoBrush && pTool != NULL) 01603 State.Greyed = FALSE; 01604 else 01605 State.Greyed = TRUE; 01606 01607 return State; 01608 01609 } 01610 01611 /******************************************************************************************** 01612 01613 > virtual void OpSelectBrush::GetOpName(String_256* OpName) 01614 01615 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01616 Created: 18/11/99 01617 Inputs: - 01618 Outputs: The undo string for the operation 01619 Returns: 01620 Purpose: like the title says 01621 Errors: - 01622 SeeAlso: - 01623 01624 ********************************************************************************************/ 01625 01626 void OpSelectBrush::GetOpName(String_256* OpName) 01627 { 01628 *OpName = String_256(_R(IDS_BRUSH_MAKESELECTED)); 01629 } 01630 01631 01632 /******************************************************************************************** 01633 01634 > void OpSelectBrush::Do(OpDescriptor* pOpDesc) 01635 01636 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01637 Created: 18/11/99 01638 Inputs: - 01639 Outputs: - 01640 Returns: 01641 Purpose: the all-important Do function 01642 Errors: - 01643 SeeAlso: - 01644 01645 ********************************************************************************************/ 01646 01647 void OpSelectBrush::Do(OpDescriptor* pOpDesc) 01648 { 01649 01650 AttrBrushType* pSelBrush = CBrushEditDlg::GetSingleSelectedBrushAttribute(); 01651 01652 if (pSelBrush == NULL) 01653 { 01654 ERROR3("No selected brush in OpSelectBrush::Do"); 01655 return; 01656 } 01657 01658 BrushHandle SelHandle = pSelBrush->GetBrushHandle(); 01659 01660 // all we need to do is send a message 01661 BROADCAST_TO_ALL(BrushMsg(SelHandle)); 01662 01663 End(); 01664 } 01665 01666 01667 /*-------------------------------------------------------------------------------------------- 01668 -----------------------OpDeactivateBrush implementation--------------------------------------- 01669 ---------------------------------------------------------------------------------------------*/ 01670 01671 01672 /******************************************************************************************** 01673 01674 > OpDeactivateBrush::OpDeactivateBrush() 01675 01676 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01677 Created: 18/11/99 01678 Returns: - 01679 Purpose: Constructor 01680 01681 ********************************************************************************************/ 01682 01683 OpDeactivateBrush::OpDeactivateBrush() 01684 { 01685 01686 } 01687 01688 01689 /******************************************************************************************** 01690 01691 > OpDeactivateBrush::~OpDeactivateBrush() 01692 01693 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01694 Created: 18/11/99 01695 Returns: - 01696 Purpose: destructor 01697 ********************************************************************************************/ 01698 01699 OpDeactivateBrush::~OpDeactivateBrush() 01700 { 01701 01702 } 01703 01704 /******************************************************************************************** 01705 01706 > BOOL OpDeactivateBrush::Declare() 01707 01708 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01709 Created: 18/11/99 01710 Returns: TRUE if all went OK, FALSE otherwise 01711 Purpose: Adds the operation to the list of all known operations 01712 01713 ********************************************************************************************/ 01714 01715 BOOL OpDeactivateBrush::Declare() 01716 { 01717 return (RegisterOpDescriptor( 01718 0, 01719 0, 01720 CC_RUNTIME_CLASS(OpDeactivateBrush), 01721 OPTOKEN_DELETEBRUSH, 01722 OpDeactivateBrush::GetState, 01723 0, /* help ID */ 01724 0, /* bubble ID */ 01725 0 /* bitmap ID */ 01726 )); 01727 } 01728 01729 01730 01731 /******************************************************************************************** 01732 01733 > static OpState OpDeactivateBrush::GetState(String_256* Description, OpDescriptor*) 01734 01735 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01736 Created: 18/11/99 01737 Outputs: Description - GetState fills this string with an approriate description 01738 of the current state of the operation 01739 Returns: The state of the operation, so that menu items (ticks and greying) can be 01740 done properly 01741 Purpose: Find out the state of the operation at the specific time 01742 01743 ********************************************************************************************/ 01744 01745 OpState OpDeactivateBrush::GetState(String_256* Description, OpDescriptor*) 01746 { 01747 OpState Bob; 01748 01749 01750 return Bob; 01751 01752 } 01753 01754 01755 /******************************************************************************************** 01756 01757 > virtual void OpDeactivateBrush::GetOpName(String_256* OpName) 01758 01759 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01760 Created: 18/11/99 01761 Inputs: - 01762 Outputs: The undo string for the operation 01763 Returns: 01764 Purpose: like the title says 01765 Errors: - 01766 SeeAlso: - 01767 01768 ********************************************************************************************/ 01769 01770 void OpDeactivateBrush::GetOpName(String_256* OpName) 01771 { 01772 *OpName = String_256(_R(IDS_BRUSHDELETE)); 01773 } 01774 01775 /******************************************************************************************** 01776 01777 > void OpDeactivateBrush::DoWithParam(OpDescriptor*,OpParam* pOpParam) 01778 01779 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01780 Created: 18/11/99 01781 Returns: - 01782 Purpose: Deactivates a brush definition so that it no longer appears in the line gallery 01783 or brush combo, and all existing attributes that make use of it will appear 01784 as if they were a straight line. 01785 01786 ********************************************************************************************/ 01787 01788 void OpDeactivateBrush::DoWithParam(OpDescriptor*,OpParam* pParam) 01789 { 01790 BrushHandle Handle = static_cast<BrushHandle> (pParam->Param1); 01791 01792 if (Handle != BrushHandle_NoBrush) 01793 { 01794 DeactivateBrushDefAction* pAction; 01795 if (DeactivateBrushDefAction::Init(this,&UndoActions,Handle, &pAction) == AC_FAIL) 01796 FailAndExecute(); 01797 End(); 01798 } 01799 01800 } 01801 01802 01803 01804 01805 //------------------------------------------------------------------------------------------------ 01806 //------------------------------------------------------------------------------------------------ 01807 //------------------------------------------------------------------------------------------------ 01808 // The DeactivateBrushDefAction class 01809 01810 01811 /******************************************************************************************** 01812 01813 > ActionCode DeactivateBrushDefAction::Init(Operation* pOp, ActionList* pActionList, BrushHandle Handle, 01814 DeactivateBrushDefAction** ppNewAction) 01815 01816 01817 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01818 Created: 18/11/99 01819 Inputs: pOp = ptr to the operation to which this action belongs 01820 pActionList = ptr to action list to which this action should be added 01821 Handle - handle to the definition to (de)activate 01822 Outputs: ppNewAction = ptr to a ptr to an action, allowing the function to return 01823 a pointer to the created action 01824 Returns: ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL 01825 Purpose: To de/reactivate a brush definition in an undoable way 01826 Errors: - 01827 SeeAlso: Action::Init() 01828 01829 ********************************************************************************************/ 01830 01831 ActionCode DeactivateBrushDefAction::Init(Operation* pOp, ActionList* pActionList, BrushHandle Handle, 01832 DeactivateBrushDefAction** ppNewAction) 01833 01834 01835 { 01836 // get the brush component from the document 01837 Document* pDoc = Document::GetCurrent(); 01838 ERROR2IF(pDoc == NULL, AC_FAIL, "Wheres the document?"); 01839 BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent)); 01840 ERROR2IF(pBrushComp == NULL, AC_FAIL, "No brush component"); 01841 01842 BrushDefinition* pDef = pBrushComp->FindBrushDefinition(Handle); 01843 ERROR2IF(pDef == NULL, AC_FAIL, "Invalid handle passed to DeactivateBrushDefAction::Init"); 01844 01845 // make the new action 01846 UINT32 ActSize = sizeof(DeactivateBrushDefAction); 01847 DeactivateBrushDefAction* pNewAction; 01848 ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(DeactivateBrushDefAction),(Action**)&pNewAction); 01849 *ppNewAction = pNewAction; 01850 01851 pNewAction->m_Handle = Handle; 01852 01853 // get the line gallery 01854 LineGallery* pGallery = LineGallery::GetInstance(); 01855 ERROR2IF(pGallery == NULL, AC_FAIL, "Unable to get line gallery in DeactivateBrushDefAction::Init"); 01856 01857 // get the freehand tool 01858 ToolListItem* pToolItem = Tool::Find(TOOLID_FREEHAND); 01859 ERROR2IF(pToolItem == NULL, AC_FAIL, "Unable to get tool item in DeactivateBrushDefAction::Init"); 01860 01861 FreeHandTool* pTool = (FreeHandTool*)pToolItem->m_pTool; 01862 ERROR2IF(pTool == NULL, AC_FAIL, "Unable to get tool in DeactivateBrushDefAction::Init"); 01863 01864 if (pDef->IsActivated()) 01865 { 01866 // we are deactivating, we need to delete from the line gallery and freehandinfo bar 01867 pDef->SetActivated(FALSE); 01868 01869 pGallery->DeleteBrushItem(Handle); 01870 01871 pTool->BrushDeleted(Handle); 01872 01873 } 01874 else 01875 { 01876 // we are activating: 01877 pDef->SetActivated(TRUE); 01878 01879 // make a new atttibute to add to the line gallery 01880 PathProcessorBrush* pNewPathProc = new PathProcessorBrush; 01881 if (pNewPathProc == NULL) 01882 { 01883 ERROR3("Failed to allocate path processor"); 01884 return AC_FAIL; 01885 } 01886 01887 // tell it which brush definition to use 01888 pNewPathProc->SetBrushDefinition(Handle); 01889 01890 // transfer all the data 01891 pDef->CopyDataToProcessor(pNewPathProc); 01892 01893 // make a new attribute value for use by the line gallery 01894 BrushAttrValue* pVal = new BrushAttrValue(pNewPathProc); 01895 if (pVal == NULL) 01896 { 01897 ERROR3("Unable to allocate new BrushAttrVal"); 01898 return AC_FAIL; 01899 } 01900 01901 // add it to the line gallery 01902 LineGallery::AddNewBrushItem(pVal); 01903 01904 01905 // get the infobar 01906 FreeHandInfoBarOp* pInfoBar = ((FreeHandTool*)pTool)->GetInfoBar(); 01907 ERROR2IF(pInfoBar == NULL, AC_FAIL, "Unable to get InfoBar in DeactivateBrushDefAction::Init"); 01908 01909 // add to the freehand infobar 01910 pInfoBar->AddBrush(Handle); 01911 } 01912 01913 // force a redraw of the document 01914 if (pDoc != NULL) 01915 { 01916 CBitmapCache* pBC = Camelot.GetBitmapCache(); 01917 if (pBC) pBC->DeInitialise(); 01918 pDoc->ForceRedraw(); 01919 } 01920 01921 return Ac; 01922 } 01923 01924 01925 01926 01927 /******************************************************************************************** 01928 01929 > ActionCode ChangeBrushDefAction::Execute(); 01930 01931 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 01932 Created: 18/11/99 01933 Inputs: - 01934 Outputs: - 01935 Returns: ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL 01936 Purpose: Executes the action. This will reset the brush variables to their old values 01937 Errors: - 01938 SeeAlso: Action::Init() 01939 01940 ********************************************************************************************/ 01941 01942 ActionCode DeactivateBrushDefAction::Execute() 01943 { 01944 ActionCode Act; 01945 DeactivateBrushDefAction* pAction; 01946 Act = DeactivateBrushDefAction::Init(pOperation,pOppositeActLst,m_Handle,&pAction); 01947 01948 return Act; 01949 }