// $Revision: 1.2 $ // SelectionToolTarget.C // Copyright (C) 1994, 1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_SELECTIONTOOLTARGET #include "SelectionToolTarget.h" #endif #ifndef TaligentSamples_FEEDBACKER #include "Feedbacker.h" #endif #ifndef TaligentSamples_SELECTIONMAPPING #include "SelectionMapping.h" #endif //................................................................................ TaligentTypeExtensionMacro_Abstract(TSelectionToolTarget) TSelectionToolTarget::TSelectionToolTarget(MFeedbacker* feedbacker, MSelectionMapping* mapping) : MToolTarget(), fFeedbacker(feedbacker), fMapping(mapping), fFeedback(NIL), fCoordMapping() { Assertion(fFeedbacker != NIL && fMapping != NIL, "TSelectionToolTarget::TSelectionToolTarget"); TGPoint offset1(TGPoint::kOrigin); TGPoint offset2(1, 1); const TGRect source(offset1, offset2); fFeedbacker->GetFeedbackView().GetView()->LocalToGlobal(offset1); fMapping->GetMappingView().GetView()->GlobalToLocal(offset1); fFeedbacker->GetFeedbackView().GetView()->LocalToGlobal(offset2); fMapping->GetMappingView().GetView()->GlobalToLocal(offset2); fCoordMapping = TGrafMatrix(source, TGRect(offset1, offset2)); } TSelectionToolTarget::~TSelectionToolTarget() { if (fFeedback != NIL) { delete fFeedbacker->OrphanFeedback(*fFeedback); } } TGArea TSelectionToolTarget::GetSelectionDisplayArea() const { TGArea result(fMapping->GetSelectionDisplayArea(*GetSelection())); TGrafMatrix dummy(fCoordMapping); dummy.Invert(); result.TransformBy(dummy); return result; } void TSelectionToolTarget::AdoptFeedback(MGraphic* graphic) { if (fFeedback != NIL) { delete fFeedbacker->ReplaceFeedback(*fFeedback, graphic); } else { fFeedbacker->AdoptFeedback(graphic); } fFeedback = graphic; } MGraphic* TSelectionToolTarget::OrphanFeedback() { MGraphic* result = (fFeedback != NIL) ? fFeedbacker->OrphanFeedback(*fFeedback) : NIL; fFeedback = NIL; return result; } MGraphic* TSelectionToolTarget::ReplaceFeedback(MGraphic* newFeedback) { MGraphic* result; if (fFeedback != NIL) { result = fFeedbacker->ReplaceFeedback(*fFeedback, newFeedback); } else { result = NIL; fFeedbacker->AdoptFeedback(newFeedback); } fFeedback = newFeedback; return result; } TViewHandle TSelectionToolTarget::GetCoordinateView() const { return fFeedbacker->GetFeedbackView(); } MFeedbacker* TSelectionToolTarget::GetFeedbacker() const { return fFeedbacker; } MSelectionMapping* TSelectionToolTarget::GetMapping() const { return fMapping; } const TGrafMatrix* TSelectionToolTarget::GetCoordMapping() const { return &fCoordMapping; }