#include <opfeathr.h>
Inheritance diagram for ChangeFeatherSizeSliderOpDesc:
Public Member Functions | |
ChangeFeatherSizeSliderOpDesc (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, UINT32 AutoStateFlags=0) | |
virtual void | OnControlCreate (OpDescControlCreateMsg *CreateMsg) |
This function is called when the feathering bar is about to be shown. This function gets pointers to all of the the controls within the bar (after an indirect fashion) and stores these. These pointers can then be used within the other feathering OpDescs' to gain direct access .... | |
virtual void | OnSliderSet (OpDescControlMsg *SelChangedMsg) |
This function is called when the user stops dragging the feather size slider. It finishes of the resize-feather operation which was started when the user began dragging the slider. | |
virtual void | OnSliderChanging (OpDescControlMsg *SliderChangingMsg) |
This function is called when the feather size slider (which is 'linked' to ChangeFeatherSizeSliderOpDesc) value is changed by the user. It reads the new value from the slider, and sets our edit box accordingly. | |
virtual void | OnSelectionChange (OpDescControlMsg *SelChangedMsg, List *GadgetList) |
This function is called when the feather size edit box (which is 'linked' to ChangeFeatherSizeSliderOpDesc) value is changed by the user. It reads the new value from the edit box, and sets our slider accordingly. The edit box/slider will be reset to their previous values if the new value is not valid. | |
virtual void | OnSliderCancelled (OpDescControlMsg *SliderChangingMsg) |
This function is called when the feather size slider (which is 'linked' to ChangeFeatherSizeSliderOpDesc) is cancelled by the user. | |
Protected Member Functions | |
virtual MsgResult | Message (Msg *Msg) |
Needed to override this in order to respond to OpMsg messages (ie to update ui controls when undo of any of the feather ops occurs). | |
virtual BOOL | OnSelChangingMsg (SelChangingMsg::SelectionState State) |
virtual BOOL | OnCommonAttrsChangedMsg () |
Updating UI controls in response to selection changes. | |
virtual BOOL | OnOptionsChangingMsg (OptionsChangingMsg *Msg) |
Private Member Functions | |
BOOL | SetFeatherSizeForCurrentSel () |
BOOL | UpdateAllFeatherControls (String_256 *Str, MILLIPOINT InverseSliderVal) |
Update all feather UI controls. Str == NULL or InverseSliderVal < 0 are valid inputs - they just do nothing. | |
void | ConvertSizeToUnits (String_256 &StrSize, MILLIPOINT size) |
Convert the given value to appropriate units, returning the result as a text string. | |
INT32 | GetSliderValue (DialogOp *pDlg, CGadgetID SliderID) |
void | SetSliderValue (INT32 SliderVal, DialogOp *pDlg, CGadgetID SliderID) |
Private Attributes | |
OpChangeFeatherSize * | m_pOpChangeFeatherSize |
INT32 | LastOnscreenPixelSize |
Static Private Attributes | |
static const MILLIPOINT | MinSlider = 0 |
static const MILLIPOINT | MaxSlider = ((const MILLIPOINT) (MaxFeatherSize / 2 )) |
static const double | SliderChangeRate = 1.5 |
Definition at line 132 of file opfeathr.h.
|
Definition at line 169 of file opfeathr.cpp. 00184 : UndoableOpDescriptor(toolID, txID, Op, tok, gs, helpId, bubbleID, 00185 resourceID, controlID, ReceiveMessages, Smart, 00186 Clean, 0, AutoStateFlags ) 00187 { 00188 m_pOpChangeFeatherSize = NULL; 00189 }
|
|
Convert the given value to appropriate units, returning the result as a text string.
Definition at line 545 of file opfeathr.cpp. 00546 { 00547 Spread* pSpread = NULL; 00548 DimScale* pDimScale = NULL; 00549 Document* pDoc = Document::GetSelected(); 00550 if (pDoc != NULL) 00551 { 00552 pSpread = pDoc->GetSelectedSpread(); 00553 if (pSpread != NULL) 00554 { 00555 pDimScale = DimScale::GetPtrDimScale(pSpread); 00556 if (pDimScale != NULL) 00557 { 00558 pDimScale->ConvertToUnits(size, &StrSize); 00559 } 00560 } 00561 } 00562 00563 ERROR3IF(pDimScale == NULL, 00564 "ChangeFeatherSizeSliderOpDesc::ConvertSizeToUnits; error during method setup!"); 00565 }
|
|
Definition at line 487 of file opfeathr.cpp. 00488 { 00489 BOOL Valid; 00490 INT32 SliderVal = pDlg->GetLongGadgetValue(SliderID, MinSlider, MaxSlider, 0, &Valid); 00491 00492 if (!Valid) 00493 return -1; 00494 00495 SliderVal = (INT32)(MaxSlider * pow(SliderVal / (double)MaxSlider, SliderChangeRate)); 00496 00497 return SliderVal; 00498 }
|
|
Needed to override this in order to respond to OpMsg messages (ie to update ui controls when undo of any of the feather ops occurs).
Reimplemented from OpDescriptor. Definition at line 230 of file opfeathr.cpp. 00231 { 00232 if (MESSAGE_IS_A(pMessage, OpMsg)) 00233 { 00234 /* 00235 BEGIN, // An operation is about to be performed 00236 END, // An operation has successfully ended 00237 BEFORE_UNDO, // Sent prior to the operation being undone 00238 AFTER_UNDO, // Sent after the operation has been undone 00239 BEFORE_REDO, // Sent prior to the operation being redone 00240 AFTER_REDO // Sent after the operation has been redone 00241 */ 00242 00243 OpMsg* pMsg = (OpMsg*) pMessage; 00244 switch (pMsg->MsgType) 00245 { 00246 case OpMsg::AFTER_UNDO: 00247 case OpMsg::AFTER_REDO: 00248 if( /*pMsg->pOp->IS_KIND_OF(OpFeather) || 00249 pMsg->pOp->IS_KIND_OF(OpUnFeather) ||*/ 00250 pMsg->pOp->IS_KIND_OF(OpChangeFeatherSize) ) 00251 { 00252 SetFeatherSizeForCurrentSel(); 00253 } 00254 break; 00255 default: 00256 break; 00257 } 00258 } 00259 00260 return UndoableOpDescriptor::Message(pMessage); 00261 }
|
|
Updating UI controls in response to selection changes.
Reimplemented from MessageHandler. Definition at line 270 of file opfeathr.cpp. 00271 { 00272 // Not sure if sel changes from one feathered object to another will register 00273 // an attr change 00274 // Using this in place of OnSelChangingMsg (same as OpLineWidthOpDesc) 00275 return SetFeatherSizeForCurrentSel(); 00276 }
|
|
This function is called when the feathering bar is about to be shown. This function gets pointers to all of the the controls within the bar (after an indirect fashion) and stores these. These pointers can then be used within the other feathering OpDescs' to gain direct access ....
Reimplemented from OpDescriptor. Definition at line 205 of file opfeathr.cpp. 00206 { 00207 DialogOp* pDlg = CreateMsg->pDlgOp; 00208 CGadgetID GadgetID = CreateMsg->SetGadgetID; 00209 00210 BOOL IsHorizontal = TRUE; 00211 if (pDlg->IsKindOf(CC_RUNTIME_CLASS(DialogBarOp))) 00212 IsHorizontal = ((DialogBarOp *) pDlg)->IsHorizontal(); 00213 pDlg->SetGadgetRange (GadgetID, MinSlider, MaxSlider); 00214 if(IsHorizontal) 00215 pDlg->SetGadgetBitmaps (GadgetID, _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER)); 00216 else 00217 pDlg->SetGadgetBitmaps (GadgetID, _R(IDB_QUALITYBASEVERT), _R(IDB_QUALITYSLIDERVERT)); 00218 00219 SetFeatherSizeForCurrentSel(); 00220 }
|
|
Reimplemented from MessageHandler. Definition at line 280 of file opfeathr.cpp. 00281 { 00282 OptionsChangingMsg *OpsChangeMsg = (OptionsChangingMsg *) Msg; 00283 if( OpsChangeMsg->State == OptionsChangingMsg::NEWUNITS) 00284 { 00285 // ensure we don't have a cached feather 00286 SelRange* pSelRange = GetApplication()->FindSelection(); 00287 if (pSelRange != NULL) 00288 pSelRange->AttrsHaveChanged(); 00289 00290 return SetFeatherSizeForCurrentSel(); 00291 } 00292 00293 return TRUE; 00294 }
|
|
Reimplemented from MessageHandler. Definition at line 298 of file opfeathr.cpp. 00299 { 00300 // if nodes have been added/removed from the selection, then ensure that 00301 // we abort any drag currently in progress. 00302 // to prevent responding to messages sent from SlideFinished(), copy the ptr first. 00303 // if (State == SelChangingMsg::SelectionState::SELECTIONCHANGED) 00304 // { 00305 // if (m_pOpChangeFeatherSize != NULL) 00306 // { 00307 // OpChangeFeatherSize* pOp = m_pOpChangeFeatherSize; 00308 // m_pOpChangeFeatherSize = NULL; 00309 // pOp->SlideFinished(FALSE); 00310 // } 00311 // } 00312 00313 00314 return TRUE; 00315 }
|
|
This function is called when the feather size edit box (which is 'linked' to ChangeFeatherSizeSliderOpDesc) value is changed by the user. It reads the new value from the edit box, and sets our slider accordingly. The edit box/slider will be reset to their previous values if the new value is not valid.
Reimplemented from OpDescriptor. Definition at line 585 of file opfeathr.cpp. 00586 { 00587 DialogOp* pDlg = SelChangedMsg->pDlgOp; 00588 CGadgetID SetGadgetID = SelChangedMsg->SetGadgetID; 00589 00590 BOOL bSuccess; 00591 MILLIPOINT Result = pDlg->GetUnitGadgetValue(SetGadgetID, PIXELS, MinSlider, MaxFeatherSize, 00592 0, &bSuccess); 00593 00594 if (bSuccess) 00595 { 00596 MILLIPOINT mp = (Result > MaxSlider) ? MaxSlider : Result; 00597 OpChangeFeatherSize* pOp = new OpChangeFeatherSize(); 00598 if (pOp != NULL) 00599 { 00600 OpChangeFeatherSizeParam param(mp, OpChangeFeatherSize::GetEditContext()); 00601 pOp->DoWithParam(NULL, ¶m); 00602 pOp->DoSlide(mp); 00603 pOp->SlideFinished(); 00604 UpdateAllFeatherControls((String_256*)NULL, mp); 00605 } 00606 00607 else 00608 bSuccess = FALSE; 00609 } 00610 00611 if (!bSuccess) 00612 SetFeatherSizeForCurrentSel(); 00613 }
|
|
This function is called when the feather size slider (which is 'linked' to ChangeFeatherSizeSliderOpDesc) is cancelled by the user.
Reimplemented from OpDescriptor. Definition at line 722 of file opfeathr.cpp. 00723 { 00724 // to prevent responding to messages sent from SlideFinished(), copy the ptr first. 00725 if (m_pOpChangeFeatherSize != NULL) 00726 { 00727 OpChangeFeatherSize* pOp = m_pOpChangeFeatherSize; 00728 m_pOpChangeFeatherSize = NULL; 00729 pOp->SlideFinished(FALSE); 00730 SetFeatherSizeForCurrentSel(); 00731 } 00732 }
|
|
This function is called when the feather size slider (which is 'linked' to ChangeFeatherSizeSliderOpDesc) value is changed by the user. It reads the new value from the slider, and sets our edit box accordingly.
Reimplemented from OpDescriptor. Definition at line 659 of file opfeathr.cpp. 00660 { 00661 DialogOp* pDlg = SliderChangingMsg->pDlgOp; 00662 CGadgetID SetGadgetID = SliderChangingMsg->SetGadgetID; 00663 INT32 Result = GetSliderValue(pDlg, SetGadgetID); 00664 if (Result < 0) 00665 return; 00666 00667 const double dpi = (double)GRenderRegion::GetDefaultDPI(); 00668 const double MillipointsPerPixel = (dpi <= 0) ? 750.0 : MILLIPOINTS_PER_INCH / dpi; 00669 00670 MILLIPOINT mp = Result; 00671 00672 double fOnscreenPix = (mp / MillipointsPerPixel); 00673 fOnscreenPix *= GetCurrentViewScale().MakeDouble(); 00674 00675 if (fOnscreenPix > 1) 00676 mp = ConvertMeasurementToMillipointsAtCurrentViewScale((INT32)(fOnscreenPix + 0.5), PIXELS); 00677 00678 // if (OnscreenPix == LastOnscreenPixelSize) 00679 if (mp == LastOnscreenPixelSize) 00680 return; 00681 00682 // if we haven't already started a size change, then do so. 00683 if (m_pOpChangeFeatherSize == NULL) 00684 { 00685 m_pOpChangeFeatherSize = new OpChangeFeatherSize; 00686 if (m_pOpChangeFeatherSize != NULL) 00687 { 00688 OpChangeFeatherSizeParam param(mp, OpChangeFeatherSize::GetEditContext()); 00689 m_pOpChangeFeatherSize->DoWithParam(NULL, ¶m); 00690 } 00691 else 00692 return; 00693 } 00694 00695 // ok, we're currently in the middle of a slide, 00696 // so pass our slide information over to our op. 00697 // MILLIPOINT mp = ConvertMeasurementToMillipointsAtCurrentViewScale(OnscreenPix, PIXELS); 00698 m_pOpChangeFeatherSize->DoSlide(mp); 00699 00700 // update our last pixel size. 00701 // LastOnscreenPixelSize = OnscreenPix; 00702 LastOnscreenPixelSize = mp; 00703 00704 // update all the feather controls. 00705 String_256 Str; 00706 ConvertSizeToUnits(Str, mp); 00707 UpdateAllFeatherControls(&Str, mp); 00708 }
|
|
This function is called when the user stops dragging the feather size slider. It finishes of the resize-feather operation which was started when the user began dragging the slider.
Reimplemented from OpDescriptor. Definition at line 629 of file opfeathr.cpp. 00630 { 00631 // we can't tell our op to tidy itself up if it doesn't exist. 00632 if (m_pOpChangeFeatherSize == NULL) 00633 return; 00634 00635 // tell our op to finish changing the sizes. 00636 // to stop ourselves responding to any messages sent from SlideFinished, 00637 // use a copied ptr to our Op to call it. 00638 OpChangeFeatherSize* pOp = m_pOpChangeFeatherSize; 00639 m_pOpChangeFeatherSize = NULL; 00640 pOp->SlideFinished(); 00641 00642 // reinitialise ourself, ready for the next slide. 00643 LastOnscreenPixelSize = -1; 00644 }
|
|
Definition at line 319 of file opfeathr.cpp. 00320 { 00321 MILLIPOINT MpFeather = 0; 00322 String_256 StrFeather(""); 00323 SelRange::CommonAttribResult Result = Range::ATTR_NONE; 00324 AttrFeather* pAttr = NULL; 00325 00326 if (Document::GetSelected() != NULL) 00327 { 00328 // If we have a specific context within which we should be operating 00329 // use that 00330 Range* pLevelRange = OpChangeFeatherSize::GetEditContext(); 00331 if (pLevelRange==NULL) 00332 { 00333 // If not, go get a context from the current selection 00334 SelRange* pSelRange = GetApplication()->FindSelection(); 00335 pLevelRange = pSelRange->GetTopClassRange(CC_RUNTIME_CLASS(NodeFeatherEffect), FALSE, TRUE); 00336 } 00337 00338 if (pLevelRange) 00339 { 00340 Node* pNode = pLevelRange->FindFirst(); 00341 while (pNode) 00342 { 00343 if (pNode->IsEffect() && ((NodeEffect*)pNode)->IsFeatherEffect()) 00344 { 00345 NodeFeatherEffect* pEffect = (NodeFeatherEffect*)pNode; 00346 if (Result==Range::ATTR_COMMON && pEffect->GetFeatherSize() != MpFeather) 00347 { 00348 Result = Range::ATTR_MANY; 00349 break; 00350 } 00351 00352 if (Result==Range::ATTR_NONE && pEffect->GetFeatherSize() != 0) 00353 { 00354 Result = Range::ATTR_COMMON; 00355 MpFeather = pEffect->GetFeatherSize(); 00356 } 00357 } 00358 else 00359 if (pNode->IsAnObject()) // sanity check. 00360 { 00361 pAttr = (AttrFeather*)pNode->FindFirstChild(CC_RUNTIME_CLASS(AttrFeather)); 00362 if (pAttr) 00363 { 00364 if (Result==Range::ATTR_COMMON && pAttr->Value.GetFeatherSize() != MpFeather) 00365 { 00366 Result = Range::ATTR_MANY; 00367 break; 00368 } 00369 00370 if (Result==Range::ATTR_NONE && pAttr->Value.GetFeatherSize() != 0) 00371 { 00372 Result = Range::ATTR_COMMON; 00373 MpFeather = pAttr->Value.GetFeatherSize(); 00374 } 00375 } 00376 } 00377 00378 pNode = pLevelRange->FindNext(pNode); 00379 } 00380 } 00381 00382 // ------------------------------------------------- 00383 // Show the user the result 00384 switch (Result) 00385 { 00386 case Range::ATTR_COMMON: 00387 ConvertSizeToUnits(StrFeather, MpFeather); 00388 break; 00389 00390 case Range::ATTR_NONE: 00391 MpFeather = 0; 00392 StrFeather = String_256(_R(IDS_NONE)); 00393 break; 00394 00395 case Range::ATTR_MANY: 00396 MpFeather = 0; 00397 StrFeather = String_256(_R(IDS_MANY)); 00398 break; 00399 } 00400 } 00401 00402 // Set the string in all gadgets associated with the OpDescriptor 00403 return UpdateAllFeatherControls(&StrFeather, MpFeather); 00404 }
|
|
Definition at line 515 of file opfeathr.cpp. 00517 { 00518 static const double InverseChangeRate = 1 / SliderChangeRate; 00519 00520 if (SliderVal < 0) 00521 return; 00522 00523 SliderVal = (INT32)(MaxSlider * pow(SliderVal / (double)MaxSlider, InverseChangeRate)); 00524 pDlg->SetLongGadgetValue(SliderID, SliderVal); 00525 }
|
|
Update all feather UI controls. Str == NULL or InverseSliderVal < 0 are valid inputs - they just do nothing.
Definition at line 431 of file opfeathr.cpp. 00433 { 00434 // Don't update controls if we have update disabled 00435 if (OpChangeFeatherSize::IsUpdateDisabled()) 00436 return TRUE; 00437 00438 // Create a list for the dialogue manager to put gadget ID's on. 00439 List* pGadgetList = new List; 00440 if (pGadgetList == NULL) 00441 { 00442 InformError(_R(IDE_NOMORE_MEMORY)); 00443 return FALSE; 00444 } 00445 00446 if (BuildGadgetList(pGadgetList)) 00447 { 00448 GadgetListItem* GadgetItem; 00449 00450 for (GadgetItem = (GadgetListItem*) pGadgetList->GetHead(); 00451 GadgetItem != 0; 00452 GadgetItem = (GadgetListItem*) pGadgetList->GetNext(GadgetItem)) 00453 { 00454 UINT32 GadgetID = GadgetItem->gidGadgetID; 00455 DialogOp* pDlg = GadgetItem->pDialogOp; 00456 00457 if (Str != NULL) 00458 pDlg->SetStringGadgetValue(GadgetID, *Str, FALSE, -1); 00459 00460 // set the position of a cc_Slider or the slider component of a cc_CustomEdit... 00461 TRACEUSER("amb", _T("UpdateAllFeatherContrls: Set slider to %d in [%d .. %d]"), InverseSliderVal, MinSlider, MaxSlider); 00462 SetSliderValue(InverseSliderVal, pDlg, GadgetID); 00463 } 00464 } 00465 00466 pGadgetList->DeleteAll(); 00467 delete pGadgetList; 00468 00469 return TRUE; 00470 }
|
|
Definition at line 193 of file opfeathr.h. |
|
Definition at line 192 of file opfeathr.h. |
|
Definition at line 186 of file opfeathr.h. |
|
Definition at line 185 of file opfeathr.h. |
|
Definition at line 189 of file opfeathr.h. |