#include <tool.h>
Inheritance diagram for Tool:
Public Member Functions | |
void | SetCurrent () |
Sets the 'this' tool to be the current tool. | |
void | SetButtons (BOOL State) |
Selects/Deselects the buttons associated with this buttons. | |
Static Public Member Functions | |
static BOOL | InitToolList () |
Initialise the static ToolList object which holds all tools that the kernel knows about. | |
static BOOL | InitTools () |
Called at the end of initialisation (as it may well need all other initialisations to have been done) to add Tools and Modules to the Kernel's knowledgebase. | |
static void | SelectFirstTool () |
Selects the tool that is retrieved from the prefs file. If no pref is found will default to Selector Tool - If the appropriate tool can't be found the first will be used instead. | |
static void | DeinitTools () |
Deletes all allocated tools. Safe to call more than once. | |
static OILTool * | GetOILTool (UINT32 ToolID) |
Given a Tool ID, returns a pointer to the OILTool object associated with this tool. | |
static Tool * | GetCurrent () |
Determine the current tool. Scope: Public static. | |
static UINT32 | GetCurrentID () |
Determine the current tool. Scope: Public static. | |
static void | SetNoCurrent () |
Sets no tool as the current tool. Scope: Public static. | |
static UINT32 | GetNumTools () |
Find out how many tools have registered and initialised successfully. | |
static ToolListItem * | Find (UINT32 ToolID) |
Anyone can ask about a tool's presence by its ID. | |
static ToolListItem * | Declare (Tool *, UINT32 ParentID) |
Called by OIL code to declare new tool types. | |
static ToolListItem * | GetFirstTool () |
Called for the currently-selected tool when the current DocView changes. Called when the selected DocView changes, ie. the user has moved the focus to another document view window. Allows the Tool to update the info bar according to its internal settings and values. Usually called when the info bar is first created and when a new tool becomes selected.Allows the tool to handle UI events from the info bar. It is similar to the DialogOp::HandleMessage function. returns the first Tool in the list. | |
static ToolListItem * | GetNextTool (ToolListItem *CurrTool) |
return the next Tool in the list | |
static UINT32 | GetModuleID (UINT32 ToolID) |
Particulary useful for error handling, it allows the owner module ID to be determined given just a tool ID. | |
static BOOL | SelectATool () |
static Tool * | FindTool (UINT32 ToolID) |
Anyone can ask about a tool's presence by its ID. But Geez! The caller doesn't want to know about ToolListItems!!! | |
static void | ActivateTemporaryTool (Tool *) |
Temporarily invoke the specified tool. This is called when the user holds down modifier keys to switch tools - this function remembers the currently active tool and will switch back to it when you call Tool::DeactivateTemporaryTool(). It is ok to keep calling this without first deactivating the temporary tool - the system will correctly remember which tool was originally active and restore it when all DeactivateTemporaryTool() is called. | |
static void | DeactivateTemporaryTool () |
Deactivate the temporary tool and restore the original one. | |
static BOOL | SwitchTool (KeyPress *pKeyPress) |
The place where tool switching takes place. | |
static void | RemoveDirectRegToolSwitches (Tool *pThisTool) |
This goes through the list of registered tool switches and removes all switches that belong to the given tool and were defined directly, i.e. ones that were NOT defined via a file. | |
static void | DeleteTempToolList () |
This deletes all temp tool items in the list temp tools. After this call, the temp tool stacking info is lost. This should be called whenever a user selects a new tool directly (i.e. via clicking on the tool icon, a hot key, or menu item). | |
static void | SetToolChangingState (BOOL state) |
Check to see if the currently active tool is permanently or temporarily active. If, e.g. the user is holding down ALT to get the selector tool, then this returns TRUE. Lets you set the ToolChanging flag. | |
static BOOL | IsToolChanging () |
Lets you see the state of the ToolChanging flag. | |
static void | OnActivateApp (BOOL bActive) |
This is called when the app's active state changes. | |
static void | EndDrag () |
This is called when a drag ends. | |
static void | ServicePendingToolChange () |
This is called when a drag ends, or the app's active state changes This will deactivate the temporary tool if a deactivate key event was encounted during a drag. | |
Static Public Attributes | |
static UINT32 | InitTool |
Private Member Functions | |
CC_DECLARE_MEMDUMP (Tool) | |
Static Private Attributes | |
static ToolList * | Tools = NULL |
static Tool * | Current = NULL |
static BOOL | ToolChanging = FALSE |
static BOOL | PendingDeactivateTempTool = FALSE |
static List | TempToolList |
Definition at line 416 of file tool.h.
|
Temporarily invoke the specified tool. This is called when the user holds down modifier keys to switch tools - this function remembers the currently active tool and will switch back to it when you call Tool::DeactivateTemporaryTool(). It is ok to keep calling this without first deactivating the temporary tool - the system will correctly remember which tool was originally active and restore it when all DeactivateTemporaryTool() is called.
Definition at line 785 of file tool.cpp. 00786 { 00787 // If the current tool is not temporary, then remember it so we can revert 00788 // to it when the user lets go of the hot-keys. 00789 00790 // NB. We have to make this test so if the user invokes one tool, then another in such 00791 // a way that the original tool si not switched back to inbetween, then things will 00792 // go wrong and we won't return to the original tool. 00793 00794 TempToolItem* pTempToolItem = new TempToolItem; 00795 if (pTempToolItem != NULL) 00796 { 00797 pTempToolItem->SetPrevTool(Current); 00798 pTempToolItem->SetTempTool(pTempTool); 00799 TempToolList.AddHead(pTempToolItem); 00800 00801 // if (PrevTool == NULL) 00802 // PrevTool = Current; 00803 //Current->SelectChange(FALSE); 00804 // Find the instance of the ToolOpDescriptor 00805 String_64 OpToken; 00806 camSnprintf( OpToken, 64, _T("TOOL%u"), pTempTool->GetID() ); 00807 ToolOpDescriptor* ToolOp = (ToolOpDescriptor *) OpDescriptor::FindOpDescriptor(OpToken); 00808 00809 // Use the OpDescriptor to invoke the tool (i.e. make it become the selected tool) 00810 ToolOp->Invoke(); 00811 } 00812 }
|
|
|
|
Deactivate the temporary tool and restore the original one.
Definition at line 825 of file tool.cpp. 00826 { 00827 /* // Do nothing if we don't have a previous tool 00828 if (PrevTool == NULL) return; 00829 00830 // If the previous tool is the current one, don't have to do nowt 00831 if (PrevTool == Current) return; 00832 */ 00833 TempToolItem* pTempToolItem = (TempToolItem*)TempToolList.RemoveHead(); 00834 00835 // Only do something if we have a temp tool item 00836 if (pTempToolItem != NULL) 00837 { 00838 UINT32 PrevToolID = pTempToolItem->GetPrevTool()->GetID(); 00839 00840 // We don't need this temp tool item any more. 00841 delete pTempToolItem; 00842 pTempToolItem = NULL; 00843 00844 // Find the instance of the ToolOpDescriptor 00845 String_64 OpToken; 00846 camSnprintf( OpToken, 64, _T("TOOL%u"), PrevToolID ); 00847 ToolOpDescriptor* ToolOp = (ToolOpDescriptor *) OpDescriptor::FindOpDescriptor(OpToken); 00848 00849 // Use the OpDescriptor to invoke the tool (i.e. make it become the selected tool) 00850 ToolOp->Invoke(); 00851 } 00852 00853 00854 // Not temporary any more 00855 // PrevTool = NULL; 00856 }
|
|
Called by OIL code to declare new tool types.
Definition at line 454 of file tool.cpp. 00455 { 00456 // Try to add the tool to the kernel's list. 00457 ToolListItem *NewItem = Tools->Add(NewTool, ParentID); 00458 00459 if (NewItem == NULL) 00460 { 00461 // Tool has invalid ID - print error message and destroy tool. 00462 ToolInfo Info; 00463 NewTool->Describe(&Info); 00464 TRACE( _T("Tool %u is invalid\n"), Info.ID); 00465 delete NewTool; 00466 } 00467 00468 return NewItem; 00469 }
|
|
Deletes all allocated tools. Safe to call more than once.
Definition at line 720 of file tool.cpp. 00721 { 00722 if (Tools != NULL) 00723 { 00724 // Deselect the current tool, if there is one. 00725 if (Current) 00726 { 00727 Current->SelectChange(FALSE); 00728 Current = 0; 00729 } 00730 00731 // Delete the tool list. 00732 delete Tools; 00733 Tools = NULL; 00734 } 00735 00736 ToolSwitchList.DeleteAll(); 00737 DeleteTempToolList(); 00738 }
|
|
This deletes all temp tool items in the list temp tools. After this call, the temp tool stacking info is lost. This should be called whenever a user selects a new tool directly (i.e. via clicking on the tool icon, a hot key, or menu item).
Definition at line 874 of file tool.cpp. 00875 { 00876 TempToolList.DeleteAll(); 00877 }
|
|
This is called when a drag ends.
Definition at line 1077 of file tool.cpp. 01078 { 01079 ServicePendingToolChange(); 01080 }
|
|
Anyone can ask about a tool's presence by its ID.
Definition at line 508 of file tool.cpp. 00509 { 00510 // Simple search of list for ID 00511 00512 ToolListItem *Item = (ToolListItem *) Tools->GetHead(); 00513 00514 while (Item != NULL) 00515 { 00516 if (Item->m_ToolInfo.ID == ToolID) 00517 // Found ID - return pointer to its tool. 00518 return Item; 00519 00520 Item = (ToolListItem *) Tools->GetNext(Item); 00521 } 00522 00523 // Not found 00524 return NULL; 00525 }
|
|
Anyone can ask about a tool's presence by its ID. But Geez! The caller doesn't want to know about ToolListItems!!!
Definition at line 544 of file tool.cpp. 00545 { 00546 ToolListItem* pItem = Find(ToolID); 00547 if (pItem) 00548 return pItem->m_pTool; 00549 00550 return NULL; 00551 }
|
|
Determine the current tool. Scope: Public static.
Definition at line 1772 of file tool.cpp. 01773 { 01774 return Current; 01775 }
|
|
Determine the current tool. Scope: Public static.
Definition at line 1809 of file tool.cpp.
|
|
Called for the currently-selected tool when the current DocView changes. Called when the selected DocView changes, ie. the user has moved the focus to another document view window. Allows the Tool to update the info bar according to its internal settings and values. Usually called when the info bar is first created and when a new tool becomes selected.Allows the tool to handle UI events from the info bar. It is similar to the DialogOp::HandleMessage function. returns the first Tool in the list.
Definition at line 1728 of file tool.cpp. 01729 { 01730 if (Tool::Tools) 01731 return (ToolListItem*) Tool::Tools->GetHead(); 01732 else 01733 return NULL; 01734 }
|
|
Particulary useful for error handling, it allows the owner module ID to be determined given just a tool ID.
Definition at line 570 of file tool.cpp. 00571 { 00572 if ( ToolID == TOOLID_INVALID ) return 0; // If unknown tool do nothing! 00573 00574 const ToolListItem *Tool = Tool::Find(ToolID); 00575 00576 if (Tool) 00577 return Tool->m_ToolInfo.ParentModuleID; // return ID if found 00578 else 00579 return 0; // 0=not found 00580 }
|
|
return the next Tool in the list
Definition at line 1749 of file tool.cpp. 01750 { 01751 if (Tool::Tools) 01752 return (ToolListItem*) Tool::Tools->GetNext( CurrTool ); 01753 else 01754 return NULL; 01755 }
|
|
Find out how many tools have registered and initialised successfully.
Definition at line 484 of file tool.cpp. 00485 { 00486 if (Tools == NULL) 00487 return 0; 00488 else 00489 return (UINT32) Tools->GetCount(); 00490 }
|
|
Given a Tool ID, returns a pointer to the OILTool object associated with this tool.
Definition at line 759 of file tool.cpp. 00760 { 00761 /*ToolListItem *Item =*/ Find(ID); 00762 // return Item ? Item->m_pOILTool : NULL; 00763 return NULL; 00764 }
|
|
Initialise the static ToolList object which holds all tools that the kernel knows about.
Definition at line 314 of file tool.cpp. 00315 { 00316 ENSURE(Tools == NULL, "Attempt to initialise the ToolList more than once"); 00317 Tools = new ToolList; 00318 return (Tools != NULL); 00319 }
|
|
Called at the end of initialisation (as it may well need all other initialisations to have been done) to add Tools and Modules to the Kernel's knowledgebase.
Definition at line 340 of file tool.cpp. 00341 { 00342 BOOL Finished; 00343 00344 do 00345 { 00346 // All the tools have been 'new'ed now. We can now ask them to initialise themselves. 00347 // If they don't want to, they get 'delete'ed. 00348 00349 ToolListItem *Item = (ToolListItem *) Tools->GetHead(); 00350 00351 Finished = TRUE; 00352 00353 while (Item != NULL) 00354 { 00355 Tool *Tool = Item->m_pTool; 00356 00357 // If this tool exists and has not been initialised yet, then try to 00358 // initialise it. If it initialises ok, set the item's flag, and force 00359 // another scan of the remaining tools in case one of them depends on 00360 // this tool being present. 00361 if( NULL != Tool && 00362 !Item->m_fInitialised && 00363 Tool->Init() ) 00364 { 00365 Item->m_fInitialised = TRUE; // Tool initialised ok. 00366 Finished = FALSE; // At least one more loop to try 00367 } 00368 00369 // Try the next tool 00370 Item = (ToolListItem *) Tools->GetNext(Item); 00371 } 00372 00373 } while (!Finished); 00374 00375 // Delete any un-initialised tools 00376 ToolListItem *Item = (ToolListItem *) Tools->GetHead(); 00377 00378 while (Item != NULL) 00379 { 00380 ToolListItem *NextItem = (ToolListItem*) Tools->GetNext(Item); 00381 00382 if ((Item->m_pTool != NULL) && (!Item->m_fInitialised)) 00383 { 00384 // the Tool didn't want to play, so remove it 00385 00386 // we've already got the next item, so its OK to kill the old one 00387 00388 delete Tools->RemoveItem( Item ); // remove from list & free up 00389 } 00390 00391 // Try the next tool 00392 Item = NextItem; 00393 } 00394 00395 00396 // default to Selector tool in case we cant find a pref 00397 InitTool = TOOLID_SELECTOR; 00398 00399 // declare a pref 00400 if( Camelot.DeclareSection( _T("InitialTool"), 1 ) ) 00401 Camelot.DeclarePref( _T("InitialTool"), _T("InitTool"), &InitTool ); 00402 00403 return TRUE; // no error return possible at present 00404 }
|
|
Lets you see the state of the ToolChanging flag.
Definition at line 937 of file tool.cpp. 00938 { 00939 return (ToolChanging); 00940 }
|
|
This is called when the app's active state changes.
Definition at line 1096 of file tool.cpp. 01097 { 01098 ServicePendingToolChange(); 01099 }
|
|
This goes through the list of registered tool switches and removes all switches that belong to the given tool and were defined directly, i.e. ones that were NOT defined via a file.
Definition at line 1141 of file tool.cpp. 01142 { 01143 ToolSwitch* pToolSwitch; 01144 ToolSwitch* pNextToolSwitch = (ToolSwitch*)ToolSwitchList.GetHead(); 01145 01146 while (pNextToolSwitch != NULL) 01147 { 01148 pToolSwitch = pNextToolSwitch; 01149 pNextToolSwitch = (ToolSwitch*)ToolSwitchList.GetNext(pNextToolSwitch); 01150 01151 if (pToolSwitch->pTool == pThisTool && !pToolSwitch->DefFromFile) 01152 { 01153 // if this tool switch belongs to the given tool 01154 // and it was a directly defined one, remove it from 01155 // the list and delete it 01156 01157 ToolSwitchList.RemoveItem(pToolSwitch); 01158 delete pToolSwitch; 01159 } 01160 } 01161 }
|
|
|
|
Selects the tool that is retrieved from the prefs file. If no pref is found will default to Selector Tool - If the appropriate tool can't be found the first will be used instead.
Definition at line 423 of file tool.cpp. 00424 { 00425 00426 // look for the initial tool 00427 ToolListItem* pItem = (ToolListItem*) Find(InitTool); 00428 00429 // if we can't find it go for the first 00430 if(pItem == NULL) 00431 pItem = (ToolListItem*) Tools->GetHead(); 00432 00433 if (pItem != NULL && pItem->m_pTool != NULL) pItem->m_pTool->SetCurrent(); 00434 00435 }
|
|
This is called when a drag ends, or the app's active state changes This will deactivate the temporary tool if a deactivate key event was encounted during a drag.
Definition at line 1117 of file tool.cpp. 01118 { 01119 if (PendingDeactivateTempTool) 01120 { 01121 DeactivateTemporaryTool(); 01122 PendingDeactivateTempTool = FALSE; 01123 } 01124 }
|
|
Selects/Deselects the buttons associated with this buttons.
Definition at line 596 of file tool.cpp. 00597 { 00598 #if !defined(EXCLUDE_FROM_RALPH) 00599 String OpToken; 00600 camSnprintf(OpToken, 16, _T("TOOL%u"), GetID()); 00601 ToolOpDescriptor* ToolOp = (ToolOpDescriptor *) OpDescriptor::FindOpDescriptor(OpToken); 00602 00603 // Keep Select state in the OpDescriptor 00604 ToolOp->SetCurrentTool(State); 00605 00606 List * pGadgetList = new List; 00607 if (pGadgetList == 0) 00608 { 00609 InformError(); 00610 return; 00611 } 00612 //Build list of all controls linked to this Op 00613 if (!ToolOp->BuildGadgetList(pGadgetList)) 00614 { 00615 TRACEUSER( "Chris", _T("Couldn't build gadget list in Tool::SetCurrent\n")); 00616 delete pGadgetList; 00617 return; 00618 } 00619 ListItem* pListItem = pGadgetList->GetHead(); 00620 while (pListItem != NULL) 00621 { 00622 // Set the Select State of each gadget 00623 GadgetListItem* pGadgetItem = (GadgetListItem*) pListItem; 00624 pGadgetItem->pDialogOp->SetLongGadgetValue(pGadgetItem->gidGadgetID, 00625 State, 00626 FALSE, 00627 FALSE); 00628 // Do the next control in the list, if any. 00629 pListItem = pGadgetList->GetNext(pListItem); 00630 } 00631 00632 // Don't forget to delete the list afterwards! 00633 pGadgetList->DeleteAll(); 00634 delete pGadgetList; 00635 #endif 00636 }
|
|
Sets the 'this' tool to be the current tool.
Definition at line 652 of file tool.cpp. 00653 { 00654 if(Current == this) 00655 { 00656 // Ensure the buttons are set right 00657 Current->SetButtons(SELECTED); 00658 return ; 00659 } 00660 00661 SetToolChangingState(TRUE); 00662 // Deselect current tool 00663 00664 00665 if (Current) 00666 { 00667 Current->SetButtons(DESELECTED); 00668 Current->SelectChange(FALSE); 00669 OpDescriptor::RemoveAllAliases(); 00670 } 00671 00672 // Find the CurrentAttributeGroup associated with the Tool we are switching away from 00673 CCRuntimeClass* OldCurrentAttrGroup = NULL; 00674 if (Current) 00675 OldCurrentAttrGroup = Current->Parent->m_ToolInfo.CurrentAttributeGroup; 00676 00677 // Select new tool. 00678 Current = this; 00679 00680 SetButtons(SELECTED); 00681 00682 // Inform tool that it has been selected. 00683 SelectChange(TRUE); 00684 00685 // save ID in preference 00686 InitTool = GetID(); 00687 00688 SetToolChangingState(FALSE); 00689 00690 TempToolItem* pTempToolItem = (TempToolItem*)TempToolList.GetHead(); 00691 if (pTempToolItem != NULL && pTempToolItem->GetTempTool() != Current) 00692 DeleteTempToolList(); 00693 00694 // Finally if the CurrentAttributeGroup has changed then tell people 00695 if (Parent->m_ToolInfo.CurrentAttributeGroup != OldCurrentAttrGroup) 00696 { 00697 BROADCAST_TO_ALL(ToolsCurrentAttrGroupChangedMsg); 00698 } 00699 }
|
|
Sets no tool as the current tool. Scope: Public static.
Definition at line 1788 of file tool.cpp. 01789 { 01790 if (Current) 01791 { 01792 Current->SelectChange(FALSE); 01793 } 01794 Current = NULL; 01795 }
|
|
Check to see if the currently active tool is permanently or temporarily active. If, e.g. the user is holding down ALT to get the selector tool, then this returns TRUE. Lets you set the ToolChanging flag.
Definition at line 917 of file tool.cpp. 00918 { 00919 ToolChanging = state; 00920 }
|
|
The place where tool switching takes place.
Definition at line 957 of file tool.cpp. 00958 { 00959 BOOL Processed = FALSE; 00960 00961 BOOL DuringADrag = (Operation::GetCurrentDragOp() != NULL); 00962 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00963 DuringADrag = (DuringADrag || BaseBar::IsDragging()); 00964 #endif 00965 00966 ToolSwitch* pToolSwitch = (ToolSwitch*)ToolSwitchList.GetHead(); 00967 while (pToolSwitch != NULL && !Processed) 00968 { 00969 // Is it a tool switch key press? 00970 if (*pToolSwitch->pKeyPress == *pKeyPress) 00971 { 00972 // This key press is a tool switch combination for a tool 00973 00974 // Are we waiting to deactivate the temp tool at the end of a drag? 00975 if (!PendingDeactivateTempTool) 00976 { 00977 // We are NOT wait to deactivate the temp tool at the end of a drag, so proceed 00978 00979 // pTool is the ptr to the tool in question 00980 Tool* pTool = pToolSwitch->pTool; 00981 00982 // Is it a "key down" key press? 00983 if (pKeyPress->IsPress()) 00984 { 00985 // It's a "key down" event 00986 00987 // Is it the first "key down", or has it auto-repeated? 00988 if (!pKeyPress->IsRepeat()) 00989 { 00990 // It's the first press 00991 00992 // is it already the current tool? 00993 if (pTool != Current) 00994 { 00995 // We now have the first "key down" of a tool switch for a tool that 00996 // is NOT the current tool 00997 00998 // is a drag happening? 00999 if (!DuringADrag) 01000 { 01001 // If we are not doing this during a drag, make it the current tool. 01002 // Also, set the Temp flag to FALSE as it may be a permanent change 01003 ActivateTemporaryTool(pTool); 01004 pToolSwitch->Temp = FALSE; 01005 } 01006 } 01007 else 01008 { 01009 // We now have the first "key down" of a tool switch for a tool that 01010 // IS the current tool 01011 01012 // If we are not dragging, deactivate the tool 01013 if (!DuringADrag) 01014 DeactivateTemporaryTool(); 01015 else 01016 // Remember to deactivate the tool after the drag has ended 01017 PendingDeactivateTempTool = TRUE; 01018 } 01019 } 01020 else 01021 { 01022 // It's an auto-repeated key press 01023 01024 // if the switch belongs to the current tool, and is auto-repeated 01025 // make the switch temporary 01026 if (pTool == Current) 01027 pToolSwitch->Temp = TRUE; 01028 } 01029 } 01030 else 01031 { 01032 // It's a "key up" event 01033 01034 // Does it belong to the current tool? 01035 if (pTool == Current) 01036 { 01037 // "Key up" on a tool switch for the current tool. 01038 // If the current tool was selected temporarily, select the previous current tool 01039 if (pToolSwitch->Temp) 01040 { 01041 // If we are not dragging, deactivate the tool 01042 if (!DuringADrag) 01043 DeactivateTemporaryTool(); 01044 else 01045 // Remember to deactivate the tool after the drag has ended 01046 PendingDeactivateTempTool = TRUE; 01047 } 01048 } 01049 } 01050 } 01051 01052 // The key press object was a tool switching one, so we have processed the key press 01053 Processed = TRUE; 01054 } 01055 01056 // Get the next tool switch in the list 01057 pToolSwitch = (ToolSwitch*)ToolSwitchList.GetNext(pToolSwitch); 01058 } 01059 01060 return Processed; 01061 }
|
|
|
|
|
|
|
|
|
|
|
|
|