#include <linwthop.h>
Inheritance diagram for OpChangeLineWidthOpDesc:
Public Member Functions | |
OpChangeLineWidthOpDesc (UINT32 toolID, UINT32 txID, CCRuntimeClass *Op, TCHAR *tok, pfnGetState gs, UINT32 helpId=0, UINT32 bubbleID=0, UINT32 resourceID=0, UINT32 controlID=0, BOOL ReceiveMessages=TRUE, BOOL Smart=FALSE, BOOL Clean=FALSE) | |
Simply calls the UndoableOpDescriptor::UndoableOpDescriptor base class. | |
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) |
To update the selection width combo whenever the document changes. | |
virtual BOOL | OnSelChangingMsg (SelChangingMsg::SelectionState State) |
This gets called when the selection state has changed. The SelWidth combo gets updated to reflect the new selection. | |
virtual BOOL | OnCommonAttrsChangedMsg () |
This gets called when the common attributes have changed. The SelWidth combo gets updated to reflect this. | |
BOOL | SetLineWidthGadgets (String_256 &Str) |
public interface to SetStringInGadget | |
Static Public Member Functions | |
static OpState | GetState (String_256 *Description, OpDescriptor *) |
GetState function for the OpChangeLineWidthOpDesc. | |
Private Member Functions | |
BOOL | SetCurrentSelWidth () |
Sets the currently selected line width value. | |
void | InitialiseControl (DialogOp *pDialogOp, CGadgetID gidGadgetID) |
This function checks to see if the combo's list has been initialised. if it has not then we add the list items. | |
BOOL | SetStringInGadgets (String_256 &Str) |
This function finds all gadgets associated with the OpDescriptor and sets the edit field in the gadgets to Str. |
Definition at line 124 of file linwthop.h.
|
Simply calls the UndoableOpDescriptor::UndoableOpDescriptor base class.
Definition at line 157 of file linwthop.cpp. 00170 :UndoableOpDescriptor(toolID, txID, Op, tok, gs, helpId, bubbleID, 00171 resourceID, controlID, ReceiveMessages, Smart, Clean, 0, 0 /*GREY_WHEN_NO_CURRENT_DOC*/) 00172 00173 { 00174 00175 }
|
|
GetState function for the OpChangeLineWidthOpDesc.
Definition at line 655 of file linwthop.cpp. 00656 { 00657 OpState Blobby; 00658 if (!Document::GetSelected()) Blobby.Greyed = TRUE; 00659 return Blobby; 00660 }
|
|
This function checks to see if the combo's list has been initialised. if it has not then we add the list items.
Definition at line 442 of file linwthop.cpp. 00443 { 00444 // We don't do anything if a Document does not exist 00445 if (Document::GetCurrent() != NULL) 00446 { 00447 // Does the combo's list need to be initialised ? 00448 INT32 NumItems = 0; 00449 00450 pDlg->GetValueCount(SetGadgetID, &NumItems); 00451 if (NumItems == 0) // combo has not been initialised. 00452 { 00453 // Make sure decimal points are localised. 00454 String_8 str025pt(TEXT("0.25pt")), str05pt(TEXT("0.5pt")); 00455 if (Convert::GetDecimalPointChar() != '.') 00456 { 00457 Convert::ReplaceDecimalPoint(&str025pt); 00458 Convert::ReplaceDecimalPoint(&str05pt); 00459 } 00460 00461 // Fill up the gadget combo-box. 00462 String_256 s; 00463 s=_R(IDS_NONE); pDlg->SetStringGadgetValue(SetGadgetID, s); 00464 pDlg->SetStringGadgetValue(SetGadgetID, str025pt); 00465 pDlg->SetStringGadgetValue(SetGadgetID, str05pt); 00466 s=_T("1pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00467 s=_T("2pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00468 s=_T("4pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00469 s=_T("8pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00470 s=_T("12pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00471 s=_T("16pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00472 s=_T("24pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00473 s=_T("36pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00474 s=_T("48pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00475 s=_T("72pt"); pDlg->SetStringGadgetValue(SetGadgetID, s); 00476 00477 // Set the default line width units 00478 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 250); // 0.25pt 00479 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 500); // 0.5pt 00480 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 1000); // 1pt 00481 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 2000); // 2pt 00482 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 4000); // 4t 00483 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 8000); // 8pt 00484 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 12000); // 12pt 00485 //pDlg->SetUnitGadgetValue(SetGadgetID, COMP_POINTS, 16000); // 16pt 00486 00487 pDlg->SetComboListLength(SetGadgetID); 00488 } 00489 } 00490 }
|
|
This gets called when the common attributes have changed. The SelWidth combo gets updated to reflect this.
Reimplemented from MessageHandler. Definition at line 610 of file linwthop.cpp. 00611 { 00612 return (SetCurrentSelWidth()); 00613 }
|
|
This function is called whenever a combo control associated with the ` OpDescriptor gets created. virtual void OpChangeLineWidthOpDesc::OnControlCreate(OpDescControlCreateMsg* CreateMsg);
Reimplemented from OpDescriptor. Definition at line 420 of file linwthop.cpp. 00421 { 00422 SetCurrentSelWidth(); 00423 }
|
|
To update the selection width combo whenever the document changes.
Reimplemented from MessageHandler. Definition at line 635 of file linwthop.cpp. 00636 { 00637 return (SetCurrentSelWidth()); 00638 }
|
|
This gets called when the selection state has changed. The SelWidth combo gets updated to reflect the new selection.
Reimplemented from MessageHandler. Definition at line 586 of file linwthop.cpp. 00587 { 00588 // We require more refined Sel msg handling here 00589 //if (State != SelChangingMsg::COLOURATTCHANGED) 00590 //{ 00591 // return (SetCurrentSelWidth()); 00592 //} 00593 //Moved to OnCommonAttrsChangedMsg 00594 return TRUE; 00595 }
|
|
This function gets called whenever a selection is made from a combo box. It invokes the operation to set the line width.
Reimplemented from OpDescriptor. Definition at line 512 of file linwthop.cpp. 00514 { 00515 DialogOp* pDlg = SelChangedMsg->pDlgOp; 00516 CGadgetID SetGadgetID = SelChangedMsg->SetGadgetID; 00517 00518 BOOL Valid; 00519 00520 // First check whether it's "none" or not 00521 String_256 str; 00522 str = pDlg->GetStringGadgetValue(SetGadgetID, &Valid, -1); 00523 00524 if (str.IsIdentical(String_8(_R(IDS_NONE)))) // it's "none" => no colour 00525 { 00526 // create a new attribute 00527 NodeAttribute *Attr = NULL; 00528 DocColour ColourToApply(COLOUR_TRANS); 00529 00530 Attr = new AttrStrokeColourChange(TRUE); 00531 if (Attr == NULL) 00532 return; 00533 00534 ((AttrStrokeColourChange *)Attr)->SetStartColour(&ColourToApply); 00535 00536 if (Attr == NULL) 00537 return; 00538 00539 // AttributeSelected knows what to do with a selected attribute 00540 AttributeManager::AttributeSelected(NULL,Attr); 00541 } 00542 else // it's another value 00543 { 00544 00545 // Obtain the value entered in the dialog 00546 MILLIPOINT LineWidth = 00547 pDlg->GetUnitGadgetValue(SetGadgetID, COMP_POINTS, 0, MAX_LINE_WIDTH_MP, 00548 _R(IDS_NOT_VALID_LINE_WIDTH), &Valid); 00549 00550 // Has a valid value been entered ? 00551 if (Valid) 00552 { 00553 // Create a new line width NodeAttribute 00554 AttrLineWidth* Attr = new AttrLineWidth(); 00555 00556 if (Attr == NULL) 00557 return; 00558 00559 Attr->Value.LineWidth = LineWidth; 00560 00561 // AttributeSelected knows what to do with a selected attribute 00562 AttributeManager::AttributeSelected(Attr); 00563 } 00564 } 00565 00566 // Update all Combos 00567 // Note we must do this even if we have just set a new attribute, as a SelChanging message will not be 00568 // always be broadcast. 00569 SetCurrentSelWidth(); // Reset to the selection 00570 }
|
|
Sets the currently selected line width value. BOOL OpChangeLineWidthOpDesc::SetCurrentSelWidth()
If all selected objects (which require a line width) share the same line width attribute then this is displayed. if the selected objects have more than one line width value then the string 'MANY' is displayed.
Definition at line 202 of file linwthop.cpp. 00203 { 00204 // This check should not be neccessary ! (It is a bodge, there should always be a 00205 // current tool, however at the moment it can be NULL ?? 00206 if (Tool::GetCurrent() != NULL) 00207 { 00208 00209 if (Document::GetCurrent() != NULL) 00210 { 00211 //AttrLineWidth* LineAttr; 00212 NodeAttribute* LineAttr; 00213 NodeAttribute* LineColour; 00214 00215 // Determine if there is a common attribute (line width) 00216 SelRange::CommonAttribResult Result = GetApplication()->FindSelection()-> 00217 FindCommonAttribute(CC_RUNTIME_CLASS(AttrLineWidth), 00218 &LineAttr); 00219 00220 String_256 StrLinWidth; 00221 00222 switch (Result) 00223 { 00224 case SelRange::ATTR_COMMON: 00225 // noparachute 00226 case SelRange::ATTR_NONE: 00227 { 00228 // When ATTR_NODE LineAttr will be the current line width attribute 00229 00230 if (LineAttr == NULL) // There is "no" line width currently 00231 return(TRUE); // - but it is not an error, so return TRUE 00232 00233 ENSURE(LineAttr->GetRuntimeClass() == CC_RUNTIME_CLASS(AttrLineWidth), 00234 "LineAttr of wrong type"); 00235 00236 SelRange *pSel = GetApplication()->FindSelection(); 00237 00238 // set to NO_COLOUR, but only if all the line colours are transparent 00239 00240 // Determine if there is a common attribute (colour) 00241 pSel->FindCommonAttribute(CC_RUNTIME_CLASS(AttrStrokeColour), &LineColour); 00242 00243 if ((LineColour != NULL) && 00244 ((AttrStrokeColour*)LineColour)->GetStartColour()->IsTransparent()) 00245 StrLinWidth = String_8(_R(IDS_NONE)); // there is a common attr and it's transparent 00246 else 00247 { 00248 // go through the selection and search the applied 00249 // line colour attributes for a transparent one 00250 00251 Node *pNode = pSel->FindFirst(); 00252 00253 while (pNode != NULL) 00254 { 00255 NodeAttribute *pAppliedAttr = NULL; 00256 00257 // find the applied line colour for this node 00258 if (pNode->IS_KIND_OF(NodeRenderableInk)) 00259 ((NodeRenderableInk *)pNode)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrStrokeColour), &pAppliedAttr); 00260 00261 // then check if it's transparent 00262 if ((pAppliedAttr) && 00263 ((AttrStrokeColour*)pAppliedAttr)->GetStartColour()->IsTransparent()) 00264 break; // found a transparent applied attr 00265 00266 // go to the next one 00267 pNode = pSel->FindNext(pNode); 00268 } 00269 00270 if (pNode != NULL) 00271 { 00272 // found a transparent attr, but not all are transparent, so set to 'Many' 00273 StrLinWidth = String_8(_R(IDS_MANY)); 00274 } 00275 else 00276 { 00277 // set the common line width 00278 00279 // Find the current line width attribute 00280 MILLIPOINT LineWidth = ((AttrLineWidth*)LineAttr)->Value.LineWidth; 00281 00282 // Convert the line width to a string using default number of decimal places 00283 Convert::MillipointsToString(LineWidth, COMP_POINTS, &StrLinWidth); 00284 } 00285 } 00286 00287 break; 00288 } 00289 case SelRange::ATTR_MANY: // it's either "many" or "none" 00290 { 00291 StrLinWidth = String_8(_R(IDS_MANY)); 00292 00293 // get the colour selection 00294 SelRange::CommonAttribResult Result = GetApplication()->FindSelection()-> 00295 FindCommonAttribute(CC_RUNTIME_CLASS(AttrStrokeColour), 00296 &LineColour); 00297 00298 // only one colour and it has to be transparent 00299 if (( (Result == SelRange::ATTR_NONE) || (Result == SelRange::ATTR_COMMON)) && 00300 (((AttrStrokeColour*)LineColour)->GetStartColour()->IsTransparent())) 00301 { 00302 // ok, so it's "none" 00303 StrLinWidth = String_8(_R(IDS_NONE)); 00304 } 00305 break; 00306 } 00307 } 00308 00309 // Set the string in all gadgets associated with the OpDescriptor 00310 if (!SetStringInGadgets(StrLinWidth)) 00311 return FALSE; 00312 } 00313 else 00314 { 00315 // There is no document so blank all gadgets 00316 String_256 dummy; 00317 if (!SetStringInGadgets(dummy)) 00318 return FALSE; 00319 } 00320 00321 } // end bodge if 00322 return TRUE; 00323 }
|
|
public interface to SetStringInGadget
Definition at line 398 of file linwthop.cpp. 00399 { 00400 return SetStringInGadgets(Str); 00401 }
|
|
This function finds all gadgets associated with the OpDescriptor and sets the edit field in the gadgets to Str.
Definition at line 344 of file linwthop.cpp. 00345 { 00346 // Create a list for the dialogue manager to put gadget ID's on. 00347 List* pGadgetList = new List; 00348 if (pGadgetList == 0) 00349 { 00350 InformError(_R(IDE_NOMORE_MEMORY)); 00351 return FALSE; 00352 } 00353 00354 // Obtain a list of all line width controls 00355 if (BuildGadgetList(pGadgetList)) 00356 { 00357 00358 GadgetListItem* GadgetItem; 00359 for (GadgetItem = (GadgetListItem*) pGadgetList->GetHead(); 00360 GadgetItem != 0; 00361 GadgetItem = (GadgetListItem*) pGadgetList->GetNext(GadgetItem)) 00362 { 00363 00364 // If the gadget has no items in its list then initialise it now 00365 InitialiseControl(GadgetItem->pDialogOp, GadgetItem->gidGadgetID); 00366 00367 GadgetItem->pDialogOp->SetStringGadgetValue(GadgetItem->gidGadgetID, 00368 Str, 00369 FALSE, 00370 -1); 00371 } 00372 } 00373 pGadgetList->DeleteAll(); 00374 delete pGadgetList; 00375 00376 return TRUE; 00377 }
|