// $Revision: 1.4 $ // Copyright (c) 1994-1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_SETPOINTWINTERACTOR #include "SetPointInteractor.h" #endif #ifndef Taligent_ASSERTIONS #include #endif VersionDefinitionsMacro(TSetPointInteractor, 0); TSetPointInteractor::TSetPointInteractor(TGraphicView* view) : TInteractor(), MMouseEventHandler(), fViewHandle(*view) { Assertion(view != NIL); SetCoordinateView(fViewHandle); view->AddInteractor(this); } TSetPointInteractor::~TSetPointInteractor() { TGraphicView* view = (TGraphicView*)fViewHandle.GetView(); if (view) { view->RemoveInteractor(*this); } } // We can't start mouse moved events from a HandleActivate override since // we don't know which mouse to watch until we have an event. A pity since // that would be the best place for this. // We can't start mouse moved events from MouseMoved itself since it will // not be called unless StartMouseMovedEvents has already been called! // So we must start mouse moved events in MouseDown. If we are being used // as a sub-interactor, either the parent interactor must call // StartMouseMovedEvents for us, or must be sure to start us with a // TMouseDownEvent so we can call it ourselves. bool TSetPointInteractor::MouseButtonDown(TMouseDownEvent& mouseDown, short) { StartMouseMovedEvents(*mouseDown.GetMouseInputDevice()); SetPoint(mouseDown.GetEventPosition()); return true; } bool TSetPointInteractor::MouseButtonUp(TMouseUpEvent& mouseUp, short) { StopMouseMovedEvents(); SetDone(true); return true; } bool TSetPointInteractor::MouseMoved(TMouseMovedEvent& mouseMoved) { SetPoint(mouseMoved.GetEventPosition()); return true; } void TSetPointInteractor::SetPoint(const TGPoint& point) { TGraphicView* view = (TGraphicView*)fViewHandle.GetView(); if (view) { view->SetPoint(point); } }