#include <moldtool.h>
Inheritance diagram for MouldTool:
Public Member Functions | |
MouldTool () | |
Default Constructor. Other initialisation is done in MouldTool::Init which is called by the Tool Manager. | |
~MouldTool () | |
Destructor (Virtual). Does nothing. | |
BOOL | Init () |
Used to check if the Tool was properly constructed. | |
void | Describe (void *InfoPtr) |
Allows the tool manager to extract information about the tool. | |
UINT32 | GetID () |
virtual void | SelectChange (BOOL isSelected) |
Starts up and closes down the mould tool. | |
virtual void | OnClick (DocCoord, ClickType, ClickModifiers, Spread *) |
To handle a Mouse Click event for the Mould Tool. | |
virtual void | OnMouseMove (DocCoord PointerPos, Spread *pSpread, ClickModifiers ClickMods) |
To handle a Mouse Move event for the Mould Tool. | |
virtual void | RenderToolBlobs (Spread *pSpread, DocRect *pDocRect) |
Handles the RenderToolBlobs method. Renders the tool's blobs into the current doc view. | |
virtual BOOL | GetStatusLineText (String_256 *ptext, Spread *pSpread, DocCoord coord, ClickModifiers mods) |
generate up-to-date text for the status line (called on idles) | |
void | CreateEnvelope (EnvelopeType EnvType) |
Calls the CREATENEWMOULD operation with a default rectangular envelope shape. | |
void | CreateEnvelope2x2 (EnvelopeType EnvType) |
Calls the CREATENEWMOULD operation with a default rectangular envelope shape. | |
void | CreatePerspective (PerspectiveType PerType) |
Calls the CREATENEWMOULD operation with a default rectangular perspective shape. | |
void | PasteMould (MouldSpace m_space) |
Static Public Member Functions | |
static MouldInfoBarOp * | GetMouldInfoBarOp () |
static BOOL | IsCurrentTool () |
static void | DisplayStatusBarHelp (UINT32 StatusID) |
Displays the given status help string in the status bar. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (MouldTool) | |
BOOL | CreateCursors () |
Creates all the mould tool cursors. | |
void | DestroyCursors () |
Destroys all the mould tool cursors. | |
void | ChangeCursor (Cursor *cursor) |
Changes to the specified cursor. Will only change the cursor if it isn't already this cursor, so it doesn't flicker. | |
Cursor * | ChooseCursor (INT32) |
Returns a pointer to the correct cursor given a mould cursor type. | |
void | GenerateStatusLineText (INT32 msgres, String_256 *pStatusMsg) |
Loads up an appropriate help string into the text buffer pointed to by pStatusMsg, using the msgres resource identifier. | |
BOOL | DetermineClickEffect (DocCoord PointerPos, Spread *pSpread, ClickModifiers ClickMods, INT32 *ctype, INT32 *msgres) |
Used when single clicking. This routine determines what effect a click will have. In this tool, clicking will add a segment to the end of a line, adjust the last element of a path or start a new path entirely. | |
Private Attributes | |
Cursor * | pcNormalMouldCursor |
Cursor * | pcCurrentCursor |
Cursor * | pcTransOriginCursor |
Cursor * | pcTransCoordCursor |
INT32 | CurrentCursorID |
Static Private Attributes | |
static BOOL | CurrentTool = FALSE |
static MouldInfoBarOp * | pMouldInfoBarOp = NULL |
static TCHAR * | FamilyName = _T("Mould Tools") |
static TCHAR * | ToolName = _T("Mould Tool") |
static TCHAR * | Purpose = _T("Mould manipulation") |
static TCHAR * | Author = _T("Mike") |
Definition at line 154 of file moldtool.h.
|
Default Constructor. Other initialisation is done in MouldTool::Init which is called by the Tool Manager.
Definition at line 181 of file moldtool.cpp. 00182 { 00183 pcCurrentCursor = NULL; 00184 }
|
|
Destructor (Virtual). Does nothing.
Definition at line 196 of file moldtool.cpp.
|
|
|
|
Changes to the specified cursor. Will only change the cursor if it isn't already this cursor, so it doesn't flicker.
Definition at line 503 of file moldtool.cpp. 00504 { 00505 // only change if this cursor is different from the current cursor 00506 if (cursor != pcCurrentCursor) 00507 { 00508 // set this cursor as the current cursor and immediately display it 00509 CursorStack::GSetTop(cursor, CurrentCursorID); 00510 // remember this is our current cursor 00511 pcCurrentCursor = cursor; 00512 } 00513 }
|
|
Returns a pointer to the correct cursor given a mould cursor type.
Definition at line 469 of file moldtool.cpp. 00470 { 00471 switch (ctype) 00472 { 00473 case 1: 00474 return pcNormalMouldCursor; 00475 break; 00476 case 2: 00477 return pcTransOriginCursor; 00478 break; 00479 case 3: 00480 return pcTransCoordCursor; 00481 break; 00482 } 00483 return pcNormalMouldCursor; 00484 }
|
|
Creates all the mould tool cursors.
Definition at line 407 of file moldtool.cpp. 00408 { 00409 // This tool has just been selected. Create the cursors. 00410 pcNormalMouldCursor = new Cursor(this, _R(IDC_MOULDDEFAULTCURSOR)); // _R(IDCSR_SEL_NORMAL) 00411 pcTransCoordCursor = new Cursor(this, _R(IDC_MOVEMOULDCURSOR)); 00412 pcTransOriginCursor = new Cursor(this, _R(IDCSR_SEL_GRADPOINT)); 00413 00414 if ( pcNormalMouldCursor==NULL ) goto bincursors; 00415 if ( pcTransCoordCursor==NULL) goto bincursors; 00416 if ( pcTransOriginCursor==NULL ) goto bincursors; 00417 00418 if (!pcNormalMouldCursor->IsValid()) goto bincursors; 00419 if (!pcTransCoordCursor->IsValid()) goto bincursors; 00420 if (!pcTransOriginCursor->IsValid()) goto bincursors; 00421 00422 return TRUE; 00423 00424 bincursors: 00425 DestroyCursors(); 00426 return FALSE; 00427 }
|
|
Calls the CREATENEWMOULD operation with a default rectangular envelope shape.
Definition at line 796 of file moldtool.cpp. 00797 { 00798 // Make sure we have the operation ready 00799 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CREATENEWMOULD); 00800 if (pOpDesc) 00801 { 00802 // Create a manifold to use 00803 Path* pDefShape = new Path; 00804 if (pDefShape!=NULL) 00805 { 00806 BOOL LockAspect = FALSE; 00807 00808 if (pDefShape->Initialise(12,12)) 00809 { 00810 BOOL ok = FALSE; 00811 00812 switch (EnvType) 00813 { 00814 case ENV_DEFAULT: 00815 ok = EnvelopeShapes::Rectangular(pDefShape); 00816 break; 00817 00818 case ENV_CIRCULAR: 00819 ok = EnvelopeShapes::Circular(pDefShape); 00820 LockAspect = TRUE; 00821 break; 00822 00823 case ENV_ELLIPTICAL: 00824 ok = EnvelopeShapes::Circular(pDefShape); 00825 break; 00826 00827 case ENV_CONCAVE: 00828 ok = EnvelopeShapes::Concave(pDefShape); 00829 break; 00830 00831 case ENV_BANNER: 00832 ok = EnvelopeShapes::Banner(pDefShape); 00833 break; 00834 } 00835 00836 if (ok) 00837 { 00838 // now build the correct mould parameter and invoke the operation 00839 CreateMouldParam Param(pDefShape,MOULDSPACE_ENVELOPE,TRUE,LockAspect); 00840 pOpDesc->Invoke(&Param); 00841 } 00842 } 00843 } 00844 delete pDefShape; 00845 } 00846 }
|
|
Calls the CREATENEWMOULD operation with a default rectangular envelope shape.
Definition at line 859 of file moldtool.cpp. 00860 { 00861 // Make sure we have the operation ready 00862 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CREATENEWMOULD); 00863 if (pOpDesc) 00864 { 00865 // Create a manifold to use 00866 Path* pDefShape = new Path; 00867 if (pDefShape!=NULL) 00868 { 00869 BOOL LockAspect = FALSE; 00870 00871 if (pDefShape->Initialise(12,12)) 00872 { 00873 BOOL ok = FALSE; 00874 00875 switch (EnvType) 00876 { 00877 case ENV_DEFAULT: 00878 ok = EnvelopeShapes::Rectangular2x2(pDefShape); 00879 break; 00880 00881 default: 00882 break; 00883 } 00884 00885 if (ok) 00886 { 00887 // now build the correct mould parameter and invoke the operation 00888 CreateMouldParam Param(pDefShape,MOULDSPACE_ENVELOPE2X2,TRUE,LockAspect); 00889 pOpDesc->Invoke(&Param); 00890 } 00891 } 00892 } 00893 delete pDefShape; 00894 } 00895 }
|
|
Calls the CREATENEWMOULD operation with a default rectangular perspective shape.
Definition at line 909 of file moldtool.cpp. 00910 { 00911 // Make sure we have the operation ready 00912 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_CREATENEWMOULD); 00913 if (pOpDesc) 00914 { 00915 // Create a manifold to use 00916 Path* pDefShape = new Path; 00917 if (pDefShape!=NULL) 00918 { 00919 BOOL LockAspect = FALSE; 00920 00921 if (pDefShape->Initialise(12,12)) 00922 { 00923 BOOL ok = FALSE; 00924 00925 switch (PerType) 00926 { 00927 case PER_DEFAULT: 00928 ok = PerspectiveShapes::Rectangular(pDefShape); 00929 break; 00930 case PER_LEFT: 00931 ok = PerspectiveShapes::LeftWall(pDefShape); 00932 break; 00933 case PER_RIGHT: 00934 ok = PerspectiveShapes::RightWall(pDefShape); 00935 break; 00936 case PER_FLOOR: 00937 ok = PerspectiveShapes::Floor(pDefShape); 00938 break; 00939 case PER_ROOF: 00940 ok = PerspectiveShapes::Ceiling(pDefShape); 00941 break; 00942 } 00943 00944 if (ok) 00945 { 00946 // now build the correct mould parameter and invoke the operation 00947 CreateMouldParam Param(pDefShape,MOULDSPACE_PERSPECTIVE,TRUE,LockAspect); 00948 pOpDesc->Invoke(&Param); 00949 } 00950 } 00951 } 00952 delete pDefShape; 00953 } 00954 }
|
|
Allows the tool manager to extract information about the tool.
Reimplemented from Tool_v1. Definition at line 291 of file moldtool.cpp. 00292 { 00293 // Cast structure into the latest one we understand. 00294 ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr; 00295 00296 Info->InfoVersion = 1; 00297 00298 Info->InterfaceVersion = GetToolInterfaceVersion(); // You should always have this line. 00299 00300 // These are all arbitrary at present. 00301 Info->Version = 1; 00302 Info->ID = GetID(); 00303 Info->TextID = _R(IDS_MOULD_TOOL); 00304 00305 Info->Family = FamilyName; 00306 Info->Name = ToolName; 00307 Info->Purpose = Purpose; 00308 Info->Author = Author; 00309 00310 Info->BubbleID = _R(IDBBL_MOULD_TOOL); 00311 }
|
|
Destroys all the mould tool cursors.
Definition at line 443 of file moldtool.cpp. 00444 { 00445 if (pcNormalMouldCursor != NULL) delete pcNormalMouldCursor; 00446 if (pcTransCoordCursor != NULL) delete pcTransCoordCursor; 00447 if (pcTransOriginCursor != NULL) delete pcTransOriginCursor; 00448 00449 pcNormalMouldCursor = NULL; 00450 pcTransCoordCursor = NULL; 00451 pcTransOriginCursor = NULL; 00452 }
|
|
Used when single clicking. This routine determines what effect a click will have. In this tool, clicking will add a segment to the end of a line, adjust the last element of a path or start a new path entirely.
Definition at line 633 of file moldtool.cpp. 00634 { 00635 // Find the selected range of objects 00636 SelRange* Selected = GetApplication()->FindSelection(); 00637 Node* pNode = Selected->FindFirst(); 00638 Node* pNext; 00639 BOOL claimed = FALSE; 00640 00641 // Set up a default value first 00642 (*msgres)=0; 00643 00644 while ((pNode != NULL) && (!claimed)) 00645 { 00646 // Find the next selected node 00647 pNext = Selected->FindNext(pNode); 00648 if (pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeMould)) 00649 claimed = ((NodeMould*)pNode)->OnMouseMove(PointerPos, pSpread, ClickMods, ctype, msgres); 00650 pNode = pNext; 00651 } 00652 00653 return claimed; 00654 }
|
|
Displays the given status help string in the status bar.
Definition at line 777 of file moldtool.cpp. 00778 { 00779 String_256 StatusMsg(""); 00780 StatusMsg.Load(StatusID); 00781 GetApplication()->UpdateStatusBarText(&StatusMsg); 00782 }
|
|
Loads up an appropriate help string into the text buffer pointed to by pStatusMsg, using the msgres resource identifier.
Definition at line 712 of file moldtool.cpp. 00713 { 00714 switch (msgres) 00715 { 00716 case 2: 00717 pStatusMsg->Load(_R(IDS_DRAGVPOINT), Tool::GetModuleID(GetID())); 00718 return; 00719 break; 00720 case 3: 00721 pStatusMsg->Load(_R(IDS_DRAGCOORD), Tool::GetModuleID(GetID())); 00722 return; 00723 break; 00724 00725 default: 00726 pStatusMsg->Load(_R(IDS_MOULDDEFAULT), Tool::GetModuleID(GetID())); 00727 return; 00728 break; 00729 } 00730 }
|
|
Reimplemented from Tool_v1. Definition at line 166 of file moldtool.h. 00166 { return TOOLID_MOULD; }; // defined in kernel\tool.h
|
|
Definition at line 176 of file moldtool.h. 00176 { return pMouldInfoBarOp; }
|
|
generate up-to-date text for the status line (called on idles)
Reimplemented from Tool_v1. Definition at line 678 of file moldtool.cpp. 00679 { 00680 ERROR2IF(ptext==NULL,FALSE,"MouldTool::GetStatusLineText() passed a NULL text buffer"); 00681 00682 *ptext = ""; 00683 00684 // find what type of click we will generate 00685 INT32 ctype,msgres; 00686 DetermineClickEffect(coord, pSpread, mods, &ctype, &msgres); 00687 GenerateStatusLineText(msgres, ptext); 00688 00689 return TRUE; 00690 }
|
|
Used to check if the Tool was properly constructed.
Reimplemented from Tool_v1. Definition at line 213 of file moldtool.cpp. 00214 { 00215 // Declare all your ops here and only succeed if all declarations succeed 00216 00217 BOOL ok = TRUE; 00218 00219 // register our mould tool operations 00220 ok = OpCreateNewMould::Init(); 00221 if (ok) ok = OpRemoveMould::Init(); 00222 if (ok) ok = OpCopyMouldShape::Init(); 00223 if (ok) ok = OpPasteEnvelope::Init(); 00224 if (ok) ok = OpPastePerspective::Init(); 00225 if (ok) ok = OpToggleMouldGrid::Init(); 00226 if (ok) ok = OpDetachMould::Init(); 00227 if (ok) ok = OpRotateMould::Init(); 00228 if (ok) ok = OpRectangularEnvelope::Init(); 00229 if (ok) ok = OpRectangularPerspective::Init(); 00230 00231 #if 0 00232 if (ok) 00233 { 00234 // This section reads in the infobar definition and creates an instance of 00235 // MouldInfoBarOp. Also pMouldInfoBarOp, the ptr to the tool's infobar, is set up 00236 // after the infobar is successfully read and created. 00237 CCResTextFile file; // Resource File 00238 MouldInfoBarOpCreate BarCreate; // Object that creates MouldInfoBarOp objects 00239 00240 ok = file.open(_R(IDM_MOULDTOOL_BAR), _R(IDT_INFO_BAR_RES)); // Open resource 00241 if (ok) ok = DialogBarOp::ReadBarsFromFile(file,BarCreate); // Read and create info bar 00242 if (ok) file.close(); // Close resource 00243 00244 ENSURE(ok,"Unable to load mouldbar.ini from resource\n"); 00245 } 00246 00247 if (ok) 00248 { 00249 // Info bar now exists. Now get a pointer to it 00250 String_32 str = String_32(_R(IDS_MOLDTOOL_INFOBARNAME)); 00251 DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(str); 00252 00253 00254 ok = (pDialogBarOp != NULL); 00255 if (ok) ok = pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(MouldInfoBarOp)); 00256 if (ok) pMouldInfoBarOp = (MouldInfoBarOp*)pDialogBarOp; 00257 if (ok) pMouldInfoBarOp->SetTool(this); // Set a pointer from the op to this tool 00258 00259 ENSURE(ok,"Error finding the mould tool info bar"); 00260 } 00261 #endif 00262 00263 if (ok) 00264 { 00265 pMouldInfoBarOp = new MouldInfoBarOp(); 00266 ok = (pMouldInfoBarOp != NULL); 00267 00268 if (ok) pMouldInfoBarOp->SetTool(this); // Set a pointer from the op to this tool 00269 } 00270 00271 return (ok); 00272 }
|
|
Definition at line 177 of file moldtool.h. 00177 { return CurrentTool; }
|
|
To handle a Mouse Click event for the Mould Tool.
Reimplemented from DragTool. Definition at line 536 of file moldtool.cpp. 00538 { 00539 if (ClickMods.Menu) return; // Don't do anything if the user clicked the Menu button 00540 00541 // Now scan through the selected paths, and see if we've clicked on any moulds 00542 DocView* pDocView = DocView::GetCurrent(); 00543 ENSURE( pDocView != NULL, "MouldTool::BroadcastClick() Can't find current DocView"); 00544 if (pDocView==NULL) 00545 return; 00546 00547 // Find the selected range of objects 00548 SelRange* Selected = GetApplication()->FindSelection(); 00549 Node* pNode = Selected->FindFirst(); 00550 Node* pNext; 00551 BOOL claimed = FALSE; 00552 00553 while ((pNode != NULL) && (!claimed)) 00554 { 00555 // Find the next selected node 00556 pNext = Selected->FindNext(pNode); 00557 if (pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeMould)) 00558 claimed = ((NodeMould*)pNode)->OnClick(PointerPos, Click, ClickMods, pSpread); 00559 pNode = pNext; 00560 } 00561 00562 if (!claimed) 00563 { 00564 // call the base class .... 00565 00566 DragTool::OnClick (PointerPos, Click, ClickMods, pSpread); 00567 } 00568 }
|
|
To handle a Mouse Move event for the Mould Tool.
Reimplemented from Tool_v1. Definition at line 587 of file moldtool.cpp. 00588 { 00589 // Now scan through the selected moulds, and pass the move on 00590 DocView* pDocView = DocView::GetSelected(); 00591 ENSURE( pDocView != NULL, "MouldTool::OnMouseMove() Can't find selected DocView"); 00592 if (pDocView==NULL) 00593 return; 00594 00595 INT32 ctype,msgres; 00596 00597 BOOL claimed = DetermineClickEffect(PointerPos, pSpread, ClickMods, &ctype, &msgres); 00598 00599 if (!claimed) 00600 { 00601 ctype=1; 00602 msgres=1; 00603 } 00604 00605 // update the cursor if someones changed it 00606 Cursor* pCursor = ChooseCursor(ctype); 00607 if (pCursor!=NULL) 00608 ChangeCursor(pCursor); 00609 00610 String_256 StatusMsg(""); 00611 GenerateStatusLineText(msgres, &StatusMsg); 00612 GetApplication()->UpdateStatusBarText(&StatusMsg); 00613 }
|
|
|
|
Handles the RenderToolBlobs method. Renders the tool's blobs into the current doc view.
Reimplemented from Tool_v1. Definition at line 752 of file moldtool.cpp. 00753 { 00754 // Render into the selected doc view 00755 DocView* pDocView = DocView::GetSelected(); 00756 if (pDocView != NULL) 00757 { 00758 // render you tool's blobs (if any) here 00759 } 00760 }
|
|
Starts up and closes down the mould tool.
Reimplemented from Tool_v1. Definition at line 329 of file moldtool.cpp. 00330 { 00331 if (isSelected) 00332 { 00333 // This tool has just been selected. Create an appropriate cursor, and push it 00334 // onto the top of the cursor stack so it'll appear when the pointer moves into 00335 // our window. 00336 00337 if (!CreateCursors()) return; 00338 00339 // Push cursor but don't display now 00340 CurrentCursorID = CursorStack::GPush(pcNormalMouldCursor, FALSE); 00341 pcCurrentCursor = pcNormalMouldCursor; 00342 00343 // This tool is now the current one 00344 MouldTool::CurrentTool = TRUE; 00345 00346 // Create and display the tool's info bar 00347 if (pMouldInfoBarOp != NULL) 00348 pMouldInfoBarOp->Create(); 00349 00350 // Which blobs do I want displayed 00351 BlobManager* BlobMgr = GetApplication()->GetBlobManager(); 00352 if (BlobMgr != NULL) 00353 { 00354 // Decide which blobs we will display 00355 BlobStyle MyBlobs; 00356 MyBlobs.Object = TRUE; 00357 00358 // Tell the blob manager 00359 BlobMgr->ToolInterest(MyBlobs); 00360 } 00361 00362 00363 } 00364 else 00365 { 00366 // Deselection - destroy the tool's cursors, if they exist. 00367 if (pcCurrentCursor != NULL) 00368 { 00369 CursorStack::GPop(CurrentCursorID); 00370 pcCurrentCursor = NULL; 00371 CurrentCursorID = 0; 00372 } 00373 DestroyCursors(); 00374 00375 // Remove the info bar from view by deleting the actual underlying window 00376 if (pMouldInfoBarOp != NULL) 00377 pMouldInfoBarOp->Delete(); 00378 00379 // ensure any tool object blobs are removed. 00380 BlobManager* BlobMgr = GetApplication()->GetBlobManager(); 00381 if (BlobMgr != NULL) 00382 { 00383 BlobStyle bsRemoves; 00384 bsRemoves.ToolObject = TRUE; 00385 BlobMgr->RemoveInterest(bsRemoves); 00386 } 00387 00388 // We're no longer the current tool 00389 MouldTool::CurrentTool = FALSE; 00390 } 00391 }
|
|
Reimplemented from DragTool. Definition at line 206 of file moldtool.h. |
|
Definition at line 200 of file moldtool.h. |
|
Definition at line 193 of file moldtool.h. |
|
Reimplemented from DragTool. Definition at line 203 of file moldtool.h. |
|
Definition at line 197 of file moldtool.h. |
|
Definition at line 196 of file moldtool.h. |
|
Definition at line 199 of file moldtool.h. |
|
Definition at line 198 of file moldtool.h. |
|
Definition at line 194 of file moldtool.h. |
|
Reimplemented from DragTool. Definition at line 205 of file moldtool.h. |
|
Reimplemented from DragTool. Definition at line 204 of file moldtool.h. |