OpChangeLineAttribOpDesc Class Reference

Abstract base-class OpDescriptor to allow the user to change a line-attribute of all selected objects, or to set the AttributeManager's current attribute if no objects are selected. More...

#include <la_base.h>

Inheritance diagram for OpChangeLineAttribOpDesc:

UndoableOpDescriptor OpDescriptor MessageHandler ListItem CCObject SimpleCCObject OpChangeLineCapOpDesc OpChangeLineJoinOpDesc List of all members.

Public Member Functions

 OpChangeLineAttribOpDesc (UINT32 nTxtID, const TCHAR *lpcszToken, UINT32 nBubbleID, UINT32 nControlID)
virtual void OnControlCreate (OpDescControlCreateMsg *CreateMsg)
 This function is called whenever a combo control associated with the ` OpDescriptor gets created.
virtual void OnSelectionChange (OpDescControlMsg *SelChangedMsg, List *GadgetList)
 This function gets called whenever a selection is made from a combo box. It invokes the operation to set the line width.
virtual BOOL OnDocChangingMsg (Document *pChangingDoc, DocChangingMsg::DocState State)
virtual BOOL OnCommonAttrsChangedMsg ()
 This gets called when the selection state has changed. This gets called when the common attributes have changed.

Static Public Member Functions

static OpState GetState (String_256 *Description, OpDescriptor *)
 Generic GetState function for the OpChangeLineAttribOpDesc and derivatives.

Protected Member Functions

void SetGadgetText (const String &str)
 Sets the text in the combos associated with this OpDescriptor.
virtual BOOL SetCurrentSelectedAttrib ()
 Sets the currently selected line width value.
virtual CCRuntimeClassGetAttribRuntimeClass () const =0
virtual UINT32 ConvertAttribToStringID (NodeAttribute *pAttr) const =0
virtual UINT32 GetItemStringID (INT32 nItemIndex) const =0
virtual NodeAttributeGetNewAttrib (INT32 nItemIndex) const =0

Detailed Description

Abstract base-class OpDescriptor to allow the user to change a line-attribute of all selected objects, or to set the AttributeManager's current attribute if no objects are selected.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/3/95
The OpDescriptor invokes the OpApplyAttribToSelected operation if nodes are selected.

Definition at line 124 of file la_base.h.


Constructor & Destructor Documentation

OpChangeLineAttribOpDesc::OpChangeLineAttribOpDesc UINT32  nTxtID,
const TCHAR lpcszToken,
UINT32  nBubbleID,
UINT32  nControlID
 

Definition at line 140 of file la_base.cpp.

00144   : UndoableOpDescriptor(0,
00145                          nTxtID,
00146                          CC_RUNTIME_CLASS(OpApplyAttribToNode),
00147                          (TCHAR*) lpcszToken,
00148                          GetState,
00149                          0,
00150                          nBubbleID,
00151                          0,
00152                          nControlID,
00153                          TRUE,                          // will receive messages
00154                          FALSE,
00155                          FALSE)
00156 {
00157     // Empty.
00158 }


Member Function Documentation

virtual UINT32 OpChangeLineAttribOpDesc::ConvertAttribToStringID NodeAttribute pAttr  )  const [protected, pure virtual]
 

Implemented in OpChangeLineJoinOpDesc, and OpChangeLineCapOpDesc.

virtual CCRuntimeClass* OpChangeLineAttribOpDesc::GetAttribRuntimeClass  )  const [protected, pure virtual]
 

Implemented in OpChangeLineJoinOpDesc, and OpChangeLineCapOpDesc.

virtual UINT32 OpChangeLineAttribOpDesc::GetItemStringID INT32  nItemIndex  )  const [protected, pure virtual]
 

Implemented in OpChangeLineJoinOpDesc, and OpChangeLineCapOpDesc.

virtual NodeAttribute* OpChangeLineAttribOpDesc::GetNewAttrib INT32  nItemIndex  )  const [protected, pure virtual]
 

Implemented in OpChangeLineJoinOpDesc, and OpChangeLineCapOpDesc.

OpState OpChangeLineAttribOpDesc::GetState String_256 Description,
OpDescriptor
[static]
 

Generic GetState function for the OpChangeLineAttribOpDesc and derivatives.

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

Errors: -

See also:
-

Definition at line 479 of file la_base.cpp.

00480 {
00481     OpState os;
00482     if (Document::GetSelected() == NULL) os.Greyed = TRUE;
00483     return os;
00484 }

BOOL OpChangeLineAttribOpDesc::OnCommonAttrsChangedMsg void   )  [virtual]
 

This gets called when the selection state has changed. This gets called when the common attributes have changed.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/94
Returns:
FALSE if we run out of memory

Reimplemented from MessageHandler.

Definition at line 438 of file la_base.cpp.

00439 {
00440     return (SetCurrentSelectedAttrib());
00441 }

void OpChangeLineAttribOpDesc::OnControlCreate OpDescControlCreateMsg pCreateMsg  )  [virtual]
 

This function is called whenever a combo control associated with the ` OpDescriptor gets created.

virtual void OpChangeLineAttribOpDesc::OnControlCreate(OpDescControlCreateMsg* pCreateMsg);

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

Errors: -

See also:
-

Reimplemented from OpDescriptor.

Definition at line 310 of file la_base.cpp.

00311 {
00312     // Initialise the combo-box with the join types.
00313     DialogOp* pDlg = pCreateMsg->pDlgOp;                                        
00314     CGadgetID SetGadgetID = pCreateMsg->SetGadgetID;
00315     
00316     // Set each item in the combo-box.
00317     for (INT32 i = 0; ; i++)
00318     {
00319         UINT32 nStringID = GetItemStringID(i);
00320         if (nStringID == 0) break;
00321         pDlg->SetStringGadgetValue(SetGadgetID, String(nStringID));
00322     }
00323     
00324     // Update the current selection within the combo etc.
00325     pDlg->SetComboListLength(SetGadgetID);
00326     SetCurrentSelectedAttrib(); 
00327 }

BOOL OpChangeLineAttribOpDesc::OnDocChangingMsg Document pChangingDoc,
DocChangingMsg::DocState  State
[virtual]
 

Reimplemented from MessageHandler.

Definition at line 459 of file la_base.cpp.

00460 {
00461     return SetCurrentSelectedAttrib();
00462 }

void OpChangeLineAttribOpDesc::OnSelectionChange OpDescControlMsg pSelChangedMsg,
List GadgetList
[virtual]
 

This function gets called whenever a selection is made from a combo box. It invokes the operation to set the line width.

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

Errors: -

See also:
-

Reimplemented from OpDescriptor.

Definition at line 346 of file la_base.cpp.

00347 {
00348     // Get the relevant fields.
00349     DialogOp* pDlg = pSelChangedMsg->pDlgOp;                                        
00350     CGadgetID idSetGadgetID = pSelChangedMsg->SetGadgetID;
00351 
00352     // Try to get the text entered (or selected) within the combo.
00353     BOOL fValid;
00354     String_256 strEntered = pDlg->GetStringGadgetValue(idSetGadgetID, &fValid, -1);
00355     if (!fValid)
00356     {
00357         TRACEUSER( "JustinF", _T("Invalid text in OpChangeLineAttribOpDesc::OnSelectionChange\n"));
00358         Beep();
00359         SetCurrentSelectedAttrib();
00360         return;
00361     }
00362 
00363     INT32 nItemIndex;
00364     // Compare the string to each item that was placed in the combo list.
00365     for (nItemIndex = 0; ; nItemIndex++)
00366     {
00367         // Ask the derived class to provide the string at the given index position.
00368         UINT32 nTxtID = GetItemStringID(nItemIndex);
00369         
00370         // If there are no more strings then simply reset the combo to the current value.
00371         // The user has entered junk!
00372         if (nTxtID == 0)
00373         {
00374             // This will "recalc" the current value and set it.
00375             Beep();
00376             SetCurrentSelectedAttrib();
00377             return;
00378         }
00379 
00380         // Compare the two strings.  If they match then break out now.
00381         if (strEntered == String_256(nTxtID)) break;
00382     }
00383 
00384     // Obtain the index selected in the combo and pass to the derived class, which will
00385     // create the appropriate attribute.
00386     NodeAttribute* pAttr = GetNewAttrib(nItemIndex);
00387     if (pAttr == NULL)
00388     {
00389         TRACEUSER( "JustinF", _T("Out of memory in OpChangeLineAttribOpDesc")
00390                              "::OnSelectionChange\n");
00391         return;
00392     }
00393 
00394     // Pass it to the attribute manager.
00395     AttributeManager::AttributeSelected(pAttr); 
00396 
00397     // Update all list-boxes.  Note we must do this even if we have just set a new
00398     // attribute, as a SelChanging message will not be always be broadcast.
00399     SetCurrentSelectedAttrib();
00400 }

BOOL OpChangeLineAttribOpDesc::SetCurrentSelectedAttrib  )  [protected, virtual]
 

Sets the currently selected line width value.

BOOL OpChangeLineAttribOpDesc::SetCurrentSelJoin()

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/3/95
Parameters:
- [OUTPUTS]
Returns:
FALSE if we run out of memory etc.
If no objects are selected, or no selected objects require a join type attribute then the current join type attribute for the tool is displayed.

If all selected objects (which require a join type) share the same join type attribute then this is displayed.

if the selected objects have more than one join type value then the string 'MANY' is displayed.

Returns:
Errors: ERROR is set if we run out of memory Scope: private
See also:
-

Definition at line 228 of file la_base.cpp.

00229 {
00230     // Nothing to do if no current document.
00231     if (Document::GetCurrent() == NULL)
00232     {
00233 /*      TRACEUSER( "JustinF", _T("No current document in OpChangeLineAttribOpDesc")
00234                              "::SetCurrentSelectedAttrib\n");
00235 */      
00236         // There is no document so blank all gadgets.
00237         SetGadgetText(String(_T("")));
00238         return TRUE;
00239     }
00240 
00241     // Determine if there is a common attribute.
00242     NodeAttribute* pAttr;
00243     SelRange::CommonAttribResult eResult;
00244     eResult = GetApplication()->
00245                  FindSelection()->
00246                      FindCommonAttribute(GetAttribRuntimeClass(), &pAttr);
00247 
00248     // Work out what to put in the combo-box according to the returned result.
00249     UINT32 nTxtID;
00250     switch (eResult)
00251     {
00252         case SelRange::ATTR_COMMON:
00253         case SelRange::ATTR_NONE:
00254         {
00255             // If there isn't an attribute we just return (this logic is copied from the
00256             // line-width combo OpDescriptor code).
00257             if (pAttr == NULL)
00258             {
00259 /*              TRACEUSER( "JustinF", _T("No attribute in OpChangeLineAttribOpDesc")
00260                                      "::SetCurrentSelectedAttrib\n");
00261 */              return TRUE;
00262             }
00263 
00264             // Check for something screwy.
00265             ERROR3IF(pAttr->GetRuntimeClass() != GetAttribRuntimeClass(),
00266                      "Wrong kind of attribute in OpChangeLineAttribOpDesc"
00267                      "::SetCurrentSelectedAttrib");
00268 
00269             // There is, so call the derived class to provide some text.
00270             nTxtID = ConvertAttribToStringID(pAttr);
00271             if (nTxtID == 0)
00272             {
00273                 ERROR3("Unexpected attribute type in OpChangeLineAttribOpDesc"
00274                        "::SetCurrentSelectedAttrib!");
00275                 return FALSE;
00276             }
00277             break; 
00278         }
00279 
00280         case SelRange::ATTR_MANY:
00281             nTxtID = _R(IDS_MANY);
00282             break;
00283 
00284         default:
00285             ERROR3("Unexpected case in OpChangeLineAttribOpDesc::SetCurrentSelectedAttrib!");
00286             return FALSE;
00287     }
00288 
00289     // Set the gadget's text.
00290     SetGadgetText(String(nTxtID));
00291     return TRUE;
00292 }

void OpChangeLineAttribOpDesc::SetGadgetText const String strGadgetText  )  [protected]
 

Sets the text in the combos associated with this OpDescriptor.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/95
Parameters:
strGadgetText the text to show in the OpDescriptor's gadgets [INPUTS]

Definition at line 171 of file la_base.cpp.

00172 {
00173     // Create a list for the dialogue manager to put gadget ID's on.
00174     List* pGadgetList = new List;
00175     if (pGadgetList == NULL)
00176     {
00177         InformError(_R(IDE_NOMORE_MEMORY));
00178         return;
00179     }
00180 
00181     // Obtain a list of all the combo controls.
00182     if (BuildGadgetList(pGadgetList))
00183     {
00184         // Iterate over each control in the list.
00185         for (GadgetListItem* pGadgetItem = (GadgetListItem*) pGadgetList->GetHead(); 
00186              pGadgetItem != NULL; 
00187              pGadgetItem = (GadgetListItem*) pGadgetList->GetNext(pGadgetItem))
00188         {
00189             // Set each control to display the text.
00190             pGadgetItem->pDialogOp->SetStringGadgetValue(pGadgetItem->gidGadgetID, 
00191                                                             ((String&) strGadgetText),
00192                                                             FALSE, -1);
00193         }
00194 
00195         // Tidy up.
00196         pGadgetList->DeleteAll();
00197     }
00198 
00199     // Deallocate gadget list.
00200     delete pGadgetList;
00201 } 


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