Tool Class Reference

The Tool type reflects the latest Tool specification. Do NOT subclass from Tool, but use the latest Tool revision (e.g. Tool_v42). The Tool type should only be used by the Kernel and OIL layers, never by tools themselves. More...

#include <tool.h>

Inheritance diagram for Tool:

Tool_v1 List of all members.

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 OILToolGetOILTool (UINT32 ToolID)
 Given a Tool ID, returns a pointer to the OILTool object associated with this tool.
static ToolGetCurrent ()
 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 ToolListItemFind (UINT32 ToolID)
 Anyone can ask about a tool's presence by its ID.
static ToolListItemDeclare (Tool *, UINT32 ParentID)
 Called by OIL code to declare new tool types.
static ToolListItemGetFirstTool ()
 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 ToolListItemGetNextTool (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 ToolFindTool (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 ToolListTools = NULL
static ToolCurrent = NULL
static BOOL ToolChanging = FALSE
static BOOL PendingDeactivateTempTool = FALSE
static List TempToolList

Detailed Description

The Tool type reflects the latest Tool specification. Do NOT subclass from Tool, but use the latest Tool revision (e.g. Tool_v42). The Tool type should only be used by the Kernel and OIL layers, never by tools themselves.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
See also:
ToolInfo

Definition at line 416 of file tool.h.


Member Function Documentation

void Tool::ActivateTemporaryTool Tool pTempTool  )  [static]
 

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.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/05/94
Parameters:
pTempTool - the tool to be made active. [INPUTS]
See also:
Tool::DeactivateTemporaryTool

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 }

Tool::CC_DECLARE_MEMDUMP Tool   )  [private]
 

void Tool::DeactivateTemporaryTool  )  [static]
 

Deactivate the temporary tool and restore the original one.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/05/94
See also:
void Tool::DeactivateTemporaryTool()

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 }

ToolListItem * Tool::Declare Tool NewTool,
UINT32  ParentID
[static]
 

Called by OIL code to declare new tool types.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/7/93
Parameters:
NewTool - Pointer to a new Tool and its ID [INPUTS] ParentID - Module ID of the module that provides this tool.
None [OUTPUTS]
Returns:
Pointer to new tool list item.

Errors: Will return NULL if invalid ID or same tool ID used twice.

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 }

void Tool::DeinitTools  )  [static]
 

Deletes all allocated tools. Safe to call more than once.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None
Do NOT try to use any tools after calling this.

Returns:
Errors: None

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 }

void Tool::DeleteTempToolList  )  [static]
 

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).

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/12/94
Returns:
-
See also:
Tool::ActivateTemporaryTool; Tool::DeactivateTemporaryTool

Definition at line 874 of file tool.cpp.

00875 {
00876     TempToolList.DeleteAll();
00877 }

void Tool::EndDrag void   )  [static]
 

This is called when a drag ends.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/9/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
ServicePendingToolChange

Definition at line 1077 of file tool.cpp.

01078 {
01079     ServicePendingToolChange();
01080 }

ToolListItem * Tool::Find UINT32  ToolID  )  [static]
 

Anyone can ask about a tool's presence by its ID.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/7/93
Parameters:
Tool ID [INPUTS]
None [OUTPUTS]
Returns:
Pointer to required tool, or NULL if not found.

Errors: None

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 }

Tool * Tool::FindTool UINT32  ToolID  )  [static]
 

Anyone can ask about a tool's presence by its ID. But Geez! The caller doesn't want to know about ToolListItems!!!

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/11/2004
Parameters:
Tool ID [INPUTS]
None [OUTPUTS]
Returns:
Pointer to required tool, or NULL if not found.

Errors: None

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 }

Tool * Tool::GetCurrent  )  [static]
 

Determine the current tool. Scope: Public static.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/10/94
Returns:
A pointer to the current tool, or NULL if there isn't one.

Definition at line 1772 of file tool.cpp.

01773 {
01774     return Current;
01775 }

UINT32 Tool::GetCurrentID  )  [static]
 

Determine the current tool. Scope: Public static.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/10/94
Returns:
The ID of the current tool, or 0 if none is selected.

Definition at line 1809 of file tool.cpp.

01810 {
01811     if (Current)
01812         return Current->GetID();
01813     else
01814         return 0;
01815 }

ToolListItem * Tool::GetFirstTool  )  [static]
 

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.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/8/93
Returns:
A pointer to the first tool if list is not empty and NULL otherwise

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 }

UINT32 Tool::GetModuleID UINT32  ToolID  )  [static]
 

Particulary useful for error handling, it allows the owner module ID to be determined given just a tool ID.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/8/93
Parameters:
Tool ID [INPUTS]
None [OUTPUTS]
Returns:
Module ID of parent module, or 0 if not found.

Errors: 0 if cannot be found.

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 }

ToolListItem * Tool::GetNextTool ToolListItem CurrTool  )  [static]
 

return the next Tool in the list

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/8/93
Parameters:
pointer to last Tool return by GetFirst ot GetNextDescriptor [INPUTS]
Returns:
A pointer to the first tool if list is not empty and NULL otherwise

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 }

UINT32 Tool::GetNumTools  )  [static]
 

Find out how many tools have registered and initialised successfully.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/93
Returns:
The number of tools registered with the kernel.

Definition at line 484 of file tool.cpp.

00485 {
00486     if (Tools == NULL)
00487         return 0;
00488     else
00489         return (UINT32) Tools->GetCount();
00490 }

OILTool * Tool::GetOILTool UINT32  ID  )  [static]
 

Given a Tool ID, returns a pointer to the OILTool object associated with this tool.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
ID - The ID of the Tool [INPUTS]
- [OUTPUTS]
Returns:
Pointer to the OILTool object for this tool.

Errors: Returns NULL if the associated OILTool object does not exist (maybe the tool ID is invalid?)

See also:
ToolListItem

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 }

BOOL Tool::InitToolList  )  [static]
 

Initialise the static ToolList object which holds all tools that the kernel knows about.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if list initialised ok, FALSE otherwise.

Errors: Assert if list is already initialised.

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 }

BOOL Tool::InitTools  )  [static]
 

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.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
TRUE if OK, FALSE for catastrophic failure

Errors: None Scope: Public

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 }

BOOL Tool::IsToolChanging  )  [static]
 

Lets you see the state of the ToolChanging flag.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/05/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE - tool is in the middle of changing FALSE - oh no it's not!
See also:
-

Definition at line 937 of file tool.cpp.

00938 {
00939     return (ToolChanging);
00940 }

void Tool::OnActivateApp BOOL  bActive  )  [static]
 

This is called when the app's active state changes.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/2/96
Parameters:
bActive - this is ignored [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
ServicePendingToolChange

Definition at line 1096 of file tool.cpp.

01097 {
01098     ServicePendingToolChange();
01099 }

void Tool::RemoveDirectRegToolSwitches Tool pThisTool  )  [static]
 

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.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/94
Parameters:
pThisTool = the tool in question [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

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 }

static BOOL Tool::SelectATool  )  [static]
 

void Tool::SelectFirstTool  )  [static]
 

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.

Author:
Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/1/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
Tool::InitTools

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 }

void Tool::ServicePendingToolChange  )  [static]
 

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.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/2/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
EndDrag(), OnActivateApp()

Definition at line 1117 of file tool.cpp.

01118 {
01119     if (PendingDeactivateTempTool)
01120     {
01121         DeactivateTemporaryTool();
01122         PendingDeactivateTempTool = FALSE;
01123     }
01124 }

void Tool::SetButtons BOOL  State  ) 
 

Selects/Deselects the buttons associated with this buttons.

Author:
Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
State to set buttons to [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

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 }

void Tool::SetCurrent  ) 
 

Sets the 'this' tool to be the current tool.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/8/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: None

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 }

void Tool::SetNoCurrent  )  [static]
 

Sets no tool as the current tool. Scope: Public static.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/10/94

Definition at line 1788 of file tool.cpp.

01789 {
01790     if (Current)
01791     {
01792         Current->SelectChange(FALSE);
01793     }
01794     Current = NULL; 
01795 }

void Tool::SetToolChangingState BOOL  state  )  [static]
 

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.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/05/94
Parameters:
state - boolean used to set ToolChanging flag [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 917 of file tool.cpp.

00918 {
00919     ToolChanging = state;
00920 }

BOOL Tool::SwitchTool KeyPress pKeyPress  )  [static]
 

The place where tool switching takes place.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/8/94
Parameters:
pKeyPress = ptr to the key press that's just occurred [INPUTS]
- [OUTPUTS]
Returns:
TRUE - the key press caused a tool switch, do not pass on FALSE - no tool switching, see if anyone else wants it
See also:
-

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 }


Member Data Documentation

Tool * Tool::Current = NULL [static, private]
 

Definition at line 466 of file tool.h.

UINT32 Tool::InitTool [static]
 

Definition at line 436 of file tool.h.

BOOL Tool::PendingDeactivateTempTool = FALSE [static, private]
 

Definition at line 470 of file tool.h.

List Tool::TempToolList [static, private]
 

Definition at line 471 of file tool.h.

BOOL Tool::ToolChanging = FALSE [static, private]
 

Definition at line 469 of file tool.h.

ToolList * Tool::Tools = NULL [static, private]
 

Definition at line 465 of file tool.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:58 2007 for Camelot by  doxygen 1.4.4