MouldInfoBarOp Class Reference

Class for handling the tool's information bar. More...

#include <moldtool.h>

Inheritance diagram for MouldInfoBarOp:

InformationBarOp DialogBarOp DialogOp Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 MouldInfoBarOp ()
 Constructor for the mould tool information bar operation.
MsgResult Message (Msg *Msg)
 Mould info bar dialog message handler.
virtual void UpdateState ()
 Overrides the empty UpdateState function provided by InformationBarOp making a call to the function in DialogBarOp.
void UpdateDefEnvButton (BOOL Selection)
 Sets the grey and select status of the default envelope button on the infobar.
void UpdateDefPerButton (BOOL Selection)
 Sets the grey and select status of the default perspective button on the infobar.
void UpdateDetachButton (BOOL Selection)
 Sets the grey and select status of the detach button on the infobar.
BOOL CheckSelection ()
 Checks for selected objects in the current document and returns whether there are any or not.
void SetTool (MouldTool *)
 Sets the mould info bar tool pointer private variable.
void SetDetachState (BOOL state)
 Sets the detach button state. As we have no sensible button that clicks down then.
BOOL GetDetachState () const

Static Public Member Functions

static INT32 SelInfo (NodeMould **)
 Find out how many moulds are selected and return a pointer to the last selected mould.

Private Member Functions

BOOL CanMouldSelection ()
 Tests the selection to see if all nodes can be moulded Mainly tests for NeedsParent() nodes - if any exist in the selection, then we can't mould !

Private Attributes

BOOL DetachState
BOOL GridState
MouldToolpMouldTool

Detailed Description

Class for handling the tool's information bar.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/94

Definition at line 222 of file moldtool.h.


Constructor & Destructor Documentation

MouldInfoBarOp::MouldInfoBarOp  ) 
 

Constructor for the mould tool information bar operation.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/01/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 971 of file moldtool.cpp.

00972 {
00973     DlgResID = _R(IDD_MOULDTOOLBAR);
00974     DetachState=FALSE;
00975 }


Member Function Documentation

BOOL MouldInfoBarOp::CanMouldSelection  )  [private]
 

Tests the selection to see if all nodes can be moulded Mainly tests for NeedsParent() nodes - if any exist in the selection, then we can't mould !

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/7/99
Parameters:
- [INPUTS]
Returns:
TRUE for the selection being able to be moulded, FALSE otherwise

Definition at line 1197 of file moldtool.cpp.

01198 {
01199     Range * pRng = GetApplication()->FindSelection();
01200 
01201     Node * pParent = NULL;
01202     Node * pNode = pRng->FindFirst(FALSE);
01203     Node * pChild = NULL;
01204 
01205     while (pNode)
01206     {
01207         pParent = pNode->FindParent();
01208 
01209         if (pParent)
01210         {
01211             if (pNode->NeedsParent(pParent))
01212             {
01213                 return FALSE;
01214             }
01215         }
01216 
01217         // check for any needs parent nodes in the node's child list
01218         pChild = pNode->FindFirstDepthFirst();
01219 
01220         while (pChild)
01221         {
01222             if (pChild->NeedsParent(NULL))
01223             {
01224                 return FALSE;
01225             }
01226 
01227             pChild = pChild->FindNextDepthFirst(pNode);
01228         }
01229 
01230         pNode = pRng->FindNext(pNode, FALSE);
01231     }
01232 
01233     return TRUE;
01234 }

BOOL MouldInfoBarOp::CheckSelection  ) 
 

Checks for selected objects in the current document and returns whether there are any or not.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/94
Parameters:
- [INPUTS]
Returns:
TRUE if there are selected objects in the current document FALSE if nothing is selected

Definition at line 1401 of file moldtool.cpp.

01402 {
01403     BOOL Enabled = FALSE;
01404 
01405 /*
01406     if (Document::GetCurrent() != NULL)
01407     {
01408         SelRange* Selected = GetApplication()->FindSelection();
01409         Node* pNode = Selected->FindFirst();
01410         Enabled = (pNode!=NULL);
01411     }
01412 */
01413 
01414     // Get the selection and the number of selected objects
01415     SelRange* Selected = GetApplication()->FindSelection();
01416     INT32 Count = 0;
01417     if (Document::GetSelected() != NULL)
01418         Count = Selected->Count();
01419 
01420     // Are there any selected objects?
01421     if (Count > 0)
01422     {
01423         ObjChangeFlags cFlags;
01424 
01425         // If only one node selected, then it will just be replaced in the tree with another NodeRenderableInk node
01426         // Otherwise, the selected node could be moved, and if the node is a child of another node, effectively
01427         // delete a child node of a parent.
01428         /*
01429         if (Count == 1)
01430             cFlags.ReplaceNode = TRUE;
01431         else
01432             cFlags.DeleteNode  = TRUE;
01433         */
01434         // **** Above code commented out due to imcomplete implementation
01435         //
01436         // For now, just pretend that the op is as severe as deleting to get the mould tool buttons to grey out
01437         // when the mould is selected inside the blend. (Haven't got time to do this properly at the moment)
01438         cFlags.MultiReplaceNode  = TRUE;
01439 
01440         ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,NULL);
01441 
01442         Node* pNode = Selected->FindFirst();
01443     
01444         Enabled = TRUE;
01445         while (pNode != NULL && Enabled)
01446         {
01447             Enabled = pNode->AllowOp(&ObjChange,FALSE);
01448             pNode = Selected->FindNext(pNode);
01449         }
01450     }
01451 
01452     return Enabled;
01453 }

BOOL MouldInfoBarOp::GetDetachState  )  const [inline]
 

Definition at line 237 of file moldtool.h.

00237 { return DetachState; }

MsgResult MouldInfoBarOp::Message Msg Message  )  [virtual]
 

Mould info bar dialog message handler.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/94
Parameters:
Message = The message to handle [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from InformationBarOp.

Definition at line 1012 of file moldtool.cpp.

01013 {
01014     if (IS_OUR_DIALOG_MSG(Message))
01015     {
01016         DialogMsg* Msg = (DialogMsg*)Message;
01017 
01018         // Check if the message is a CANCEL
01019         switch (Msg->DlgMsg)
01020         {
01021             case DIM_CANCEL:
01022                 Close(); // Close the dialog 
01023                 break;
01024 
01025             case DIM_CREATE:
01026                 // Initialise the infobar controls here
01027                 // This is sent when you create the infobar in your tool startup code
01028                 break;
01029 
01030             case DIM_LFT_BN_CLICKED:
01031             {
01032                 if (pMouldTool !=NULL)
01033                 {
01034                     if (FALSE) {}
01035                     else if (Msg->GadgetID == _R(IDC_BTN_DEFAULTENVELOPE))
01036                     {
01037                         pMouldTool->CreateEnvelope(ENV_DEFAULT);
01038                         //pMouldTool->CreateEnvelope2x2(ENV_DEFAULT);
01039                     }
01040                     else if (Msg->GadgetID == _R(IDC_BTN_CIRCULARENVELOPE))
01041                     {
01042                         pMouldTool->CreateEnvelope(ENV_CIRCULAR);
01043                     }
01044                     else if (Msg->GadgetID == _R(IDC_BTN_ELLIPTICENVELOPE))
01045                     {
01046                         pMouldTool->CreateEnvelope(ENV_ELLIPTICAL);
01047                     }
01048                     else if (Msg->GadgetID == _R(IDC_BTN_CONCAVEENVELOPE))
01049                     {
01050                         pMouldTool->CreateEnvelope(ENV_CONCAVE);
01051                     }
01052                     else if (Msg->GadgetID == _R(IDC_BTN_BANNERENVELOPE))
01053                     {
01054                         pMouldTool->CreateEnvelope(ENV_BANNER);
01055                     }
01056                     else if (Msg->GadgetID == _R(IDC_BTN_DEFAULTPERSPECTIVE))
01057                     {
01058                         pMouldTool->CreatePerspective(PER_DEFAULT);
01059                     }
01060                     else if (Msg->GadgetID == _R(IDC_BTN_LEFTPERSPECTIVE))
01061                     {
01062                         pMouldTool->CreatePerspective(PER_LEFT);
01063                     }
01064                     else if (Msg->GadgetID == _R(IDC_BTN_RIGHTPERSPECTIVE))
01065                     {
01066                         pMouldTool->CreatePerspective(PER_RIGHT);
01067                     }
01068                     else if (Msg->GadgetID == _R(IDC_BTN_FLOORPERSPECTIVE))
01069                     {
01070                         pMouldTool->CreatePerspective(PER_FLOOR);
01071                     }
01072                     else if (Msg->GadgetID == _R(IDC_BTN_ROOFPERSPECTIVE))
01073                     {
01074                         pMouldTool->CreatePerspective(PER_ROOF);
01075                     }
01076                     else if (Msg->GadgetID ==_R(IDC_BTN_DETACHMOULD))
01077                     {
01078                         OpDetachMould* pOpDetachMould = new OpDetachMould;
01079                         if (pOpDetachMould)
01080                             pOpDetachMould->Do(NULL);
01081                         SetDetachState(!DetachState);
01082                     }
01083                     
01084                 }
01085             }
01086             break;
01087 
01088             case DIM_SELECTION_CHANGED:
01089             {
01090             }
01091             break;
01092 
01093             default:
01094                 break;
01095         }
01096     }
01097     // Pass the message on to the immediate mould class
01098     return (DialogBarOp::Message(Message));
01099 }    

INT32 MouldInfoBarOp::SelInfo NodeMould **  pMould  )  [static]
 

Find out how many moulds are selected and return a pointer to the last selected mould.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/03/95
Parameters:
pMould = a pointer to a mould object pointer to be used as a return parameter [INPUTS]
pMould = a pointer to the last selected mould object [OUTPUTS]
Returns:
The number of mould objects selected

Definition at line 1365 of file moldtool.cpp.

01366 {
01367     SelRange* Selection = GetApplication()->FindSelection();
01368     Node* pNode = Selection->FindFirst();
01369     NodeMould* pLastMould=NULL;
01370 
01371     INT32 num = 0;
01372     while (pNode!=NULL)
01373     {
01374         if (IS_A(pNode, NodeMould) && pNode->IsSelected())
01375         {
01376             num++;
01377             pLastMould = (NodeMould*)pNode;
01378         }
01379         pNode = Selection->FindNext(pNode);
01380     }
01381 
01382     (*pMould)=pLastMould;
01383     return num;
01384 }    

void MouldInfoBarOp::SetDetachState BOOL  state  ) 
 

Sets the detach button state. As we have no sensible button that clicks down then.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/03/95
Parameters:
- [INPUTS]

Definition at line 1342 of file moldtool.cpp.

01343 {
01344     // Is it down or up?
01345     SetLongGadgetValue(_R(IDC_BTN_DETACHMOULD), state);
01346     DetachState = state;
01347 }

void MouldInfoBarOp::SetTool MouldTool pTool  ) 
 

Sets the mould info bar tool pointer private variable.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
pTool,the pointer to the mould tool instance [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 991 of file moldtool.cpp.

00992 {
00993     pMouldTool = pTool;
00994 }

void MouldInfoBarOp::UpdateDefEnvButton BOOL  Selection  ) 
 

Sets the grey and select status of the default envelope button on the infobar.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/94
Parameters:
- [INPUTS]

Definition at line 1141 of file moldtool.cpp.

01142 {
01143     // Check for the existance of an info bar first
01144     if (WindowID)
01145     {
01146         if (!CanMouldSelection())
01147         {
01148             // if we can't mould the selection, then disable all gadgets
01149             Selection = FALSE;
01150         }
01151         
01152         EnableGadget(_R(IDC_BTN_DEFAULTENVELOPE), Selection);
01153         EnableGadget(_R(IDC_BTN_CIRCULARENVELOPE), Selection);
01154         EnableGadget(_R(IDC_BTN_ELLIPTICENVELOPE), Selection);
01155         EnableGadget(_R(IDC_BTN_CONCAVEENVELOPE), Selection);
01156         EnableGadget(_R(IDC_BTN_BANNERENVELOPE), Selection);
01157 
01158         // if we have NOT enabled any of the above, then we should NOT allow you to paste a mould either!
01159         // This is a BODGE - that works!  There is basically something wrong with the AllowOp mechanism,
01160         // and I do not have enough time to fix it ....
01161 
01162         if (!Selection)
01163         {
01164             EnableGadget(_R(IDC_BTN_PASTEENVELOPE), Selection);
01165         }
01166         else
01167         {
01168             String_256 Desc; 
01169             OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor (CC_RUNTIME_CLASS (OpPasteEnvelope));
01170 
01171             if (OpDesc != NULL)
01172             {
01173                 OpState NewState = OpDesc->GetOpsState(&Desc);
01174 
01175                 if (NewState.Greyed == FALSE)
01176                 {
01177                     EnableGadget(_R(IDC_BTN_PASTEENVELOPE), Selection);
01178                 }
01179             }
01180         }
01181     }
01182 }

void MouldInfoBarOp::UpdateDefPerButton BOOL  Selection  ) 
 

Sets the grey and select status of the default perspective button on the infobar.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/94
Parameters:
- [INPUTS]

Definition at line 1248 of file moldtool.cpp.

01249 {
01250     // Check for the existance of an info bar first
01251     if (WindowID)
01252     {
01253         if (!CanMouldSelection())
01254         {
01255             // if we can't mould the selection, then disable all gadgets
01256             Selection = FALSE;
01257         }
01258 
01259         EnableGadget(_R(IDC_BTN_DEFAULTPERSPECTIVE), Selection);
01260         EnableGadget(_R(IDC_BTN_LEFTPERSPECTIVE), Selection);
01261         EnableGadget(_R(IDC_BTN_RIGHTPERSPECTIVE), Selection);
01262         EnableGadget(_R(IDC_BTN_FLOORPERSPECTIVE), Selection);
01263         EnableGadget(_R(IDC_BTN_ROOFPERSPECTIVE), Selection);
01264 
01265         // if we have NOT enabled any of the above, then we should NOT allow you to paste a mould either!
01266         // This is a BODGE - that works!  There is basically something wrong with the AllowOp mechanism,
01267         // and I do not have enough time to fix it ....
01268 
01269         if (!Selection)
01270         {
01271             EnableGadget(_R(IDC_BTN_PASTEPERSPECTIVE), Selection);
01272         }
01273         else
01274         {
01275             String_256 Desc; 
01276             OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor (CC_RUNTIME_CLASS (OpPastePerspective));
01277 
01278             if (OpDesc != NULL)
01279             {
01280                 OpState NewState = OpDesc->GetOpsState(&Desc);
01281 
01282                 if (NewState.Greyed == FALSE)
01283                 {
01284                     EnableGadget(_R(IDC_BTN_PASTEPERSPECTIVE), Selection);
01285                 }
01286             }
01287         }
01288     }
01289 }

void MouldInfoBarOp::UpdateDetachButton BOOL  Selection  ) 
 

Sets the grey and select status of the detach button on the infobar.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/03/95
Parameters:
- [INPUTS]

Definition at line 1303 of file moldtool.cpp.

01304 {
01305     if (WindowID!=NULL)
01306     {
01307         if (!CanMouldSelection())
01308         {
01309             // if we can't mould the selection, then disable all gadgets
01310             Selection = FALSE;
01311         }
01312 
01313         EnableGadget(_R(IDC_BTN_DETACHMOULD), Selection);
01314         // if the button is enabled then set its state
01315         if (Selection)
01316         {       
01317             NodeMould* pLastMould;
01318             INT32 nmoulds = SelInfo(&pLastMould);
01319 
01320             // Set the detach button dependent on how many moulds are selected.
01321             BOOL Enabled = (nmoulds>0);
01322             BOOL PressedIn = ((nmoulds==1) && pLastMould->IsDetached());
01323 
01324             EnableGadget(_R(IDC_BTN_DETACHMOULD), Enabled);
01325             SetDetachState(PressedIn);
01326         }
01327     }
01328 }

void MouldInfoBarOp::UpdateState  )  [virtual]
 

Overrides the empty UpdateState function provided by InformationBarOp making a call to the function in DialogBarOp.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/94

Reimplemented from DialogBarOp.

Definition at line 1114 of file moldtool.cpp.

01115 {
01116     // check that our tool is enabled and is current
01117     if (!pMouldTool) return;
01118     if (!pMouldTool->IsCurrent()) return;
01119 
01120     DialogBarOp::UpdateState();
01121     BOOL Selection = CheckSelection();
01122     UpdateDefEnvButton(Selection);
01123     UpdateDefPerButton(Selection);
01124     UpdateDetachButton(Selection);
01125 }


Member Data Documentation

BOOL MouldInfoBarOp::DetachState [private]
 

Definition at line 240 of file moldtool.h.

BOOL MouldInfoBarOp::GridState [private]
 

Definition at line 241 of file moldtool.h.

MouldTool* MouldInfoBarOp::pMouldTool [private]
 

Definition at line 242 of file moldtool.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:18 2007 for Camelot by  doxygen 1.4.4