HandleDraw
void
TSRTBoxFeedbacker::HandleDraw (TGrafPort& port) const
{
TGRect bounds = HandleGetBounds ();
port.Draw (bounds);
// We set the inset equal to at least 5x5 in case the graphic is too small to be visible
GCoordinate hInset = Max(bounds.GetWidth() / 6.0, 5.0);
GCoordinate vInset = Max(bounds.GetHeight() / 6.0, 5.0);
bounds.Inset (TGPoint(hInset,0));
port.Draw (bounds);
bounds.Inset (TGPoint(-hInset,vInset));
port.Draw (bounds);
}
HandleCreateInteractor
// Copyright (C) 1995 Taligent, Inc. All rights reserved.
TCanvasInteractor*
TSRTBoxFeedbacker::HandleCreateInteractor
(MCanvasSelection* adoptTarget, MToolHandler* handler, const TGPoint& point) const
{
TGRect bounds = HandleGetBounds ();
TGPoint center = bounds.GetCenter();
GCoordinate hInset = Max(bounds.GetWidth() / 6.0, 5.0);
GCoordinate vInset = Max(bounds.GetHeight() / 6.0, 5.0);
// Translating case (center)
bounds.Inset (TGPoint(hInset,vInset));
if ( bounds.Contains(point) ) return CreateTranslatingInteractor (adoptTarget, handler);
// Rotating cases (allow overlap with center which has already been ruled out)
bounds.Inset (TGPoint(-hInset,0));
if ( bounds.Contains(point) ) return CreateRotatingInteractor (adoptTarget, handler, center);
bounds.Inset (TGPoint(hInset,-vInset));
if ( bounds.Contains(point) ) return CreateRotatingInteractor (adoptTarget, handler, center);
// Scaling case - all remaining points (the four corners)
bounds.Inset (TGPoint(-hInset,0));
if ( bounds.Contains(point) ) {
// Now, depending on which corner the point is in,
// return a scale center point equivalent
// to the opposite corner. This pinpoints the scale origin.
TGRect inner = bounds;
inner.Inset (TGPoint(hInset,vInset));
TGRect topLeft = TGRect(bounds.GetTopLeft(), inner.GetTopLeft());
TGRect topRight = TGRect(TGPoint(inner.GetTopRight().fX, bounds.GetTopRight().fY),
TGPoint(bounds.GetTopRight().fX, inner.GetTopRight().fY));
TGRect bottomLeft = TGRect(TGPoint(bounds.GetBottomLeft().fX, inner.GetBottomLeft().fY),
TGPoint(inner.GetBottomLeft().fX, bounds.GetBottomLeft().fY));
TGRect bottomRight = TGRect(inner.GetBottomRight(), bounds.GetBottomRight());
if (topLeft.Contains(point)) center = inner.GetBottomRight();
if (topRight.Contains(point)) center = inner.GetBottomLeft();
if (bottomLeft.Contains(point)) center = inner.GetTopRight();
if (bottomRight.Contains(point)) center = inner.GetTopLeft();
return CreateScalingInteractor (adoptTarget, handler, center);
}
delete adoptTarget;
return NIL;
}
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.