home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-14 | 2.1 KB | 86 lines | [TEXT/CWIE] |
- //Copyright (c) 1997 Aidan Cully
- //All rights reserved
-
- #include "ConicViewManager.h"
- #include "Messages.h"
-
- TViewManagerHolder::TViewManagerHolder( TLayoutBranch *super, TConic *conic, TPlane *plane ):
- TLayoutBranch( super )
- {
- mConic= conic;
- mPlane= plane;
- }
-
- void TViewManagerHolder::BuildChildren()
- {
- TConicViewManager *child;
- Rect contRect= mContentRect;
- contRect.right= 40;
- Boolean bind[4];
- bind[0]= true;
- bind[1]= true;
- bind[2]= false;
- bind[3]= false;
- for( int temp=kOrientationPlaneClockwise; temp<=kOrientationPlaneOut; temp++ ) {
- child= new TConicViewManager( this, 1000+temp, mConic, mPlane, temp );
- child->Init();
- AddChild( child, contRect, bind );
- ::OffsetRect( &contRect, 40, 0 );
- }
- }
-
- TConicViewManager::TConicViewManager( TLayoutBranch *super, SInt16 resID, TConic *conic,
- TPlane *plane, int orientation ):
- TPicControl( super, resID )
- {
- mConic = conic;
- mPlane = plane;
- mOrientation = orientation;
- }
-
- void TConicViewManager::TrackMouseWithin( TMouseEvent *event )
- {
- int timeDis= event->when-mPrevTime;
- mPrevTime= event->when;
-
- switch( mOrientation ) {
- case kOrientationPlaneClockwise:
- mPlane->SetAngle( mPlane->GetAngle()-timeDis );
- mConic->CalcIntersect( *mPlane );
- mPlane->SendMessage( (UINT32)kUpdateWindow );
- break;
- case kOrientationPlaneCounter:
- mPlane->SetAngle( mPlane->GetAngle()+timeDis );
- mConic->CalcIntersect( *mPlane );
- mPlane->SendMessage( (UINT32)kUpdateWindow );
- break;
- case kOrientationPlaneIn:
- mPlane->SetDistance( mPlane->GetDistance()-timeDis/32.0 );
- mConic->CalcIntersect( *mPlane );
- mPlane->SendMessage( (UINT32)kUpdateWindow );
- break;
- case kOrientationPlaneOut:
- mPlane->SetDistance( mPlane->GetDistance()+timeDis/32.0 );
- mConic->CalcIntersect( *mPlane );
- mPlane->SendMessage( (UINT32)kUpdateWindow );
- break;
- default:
- return;
- }
- }
-
- void TConicViewManager::TrackMouseChange( TMouseEvent *event, Boolean inside )
- {
- if( inside )
- mPrevTime= event->when;
- else
- mPrevTime= 0;
- TPicControl::TrackMouseChange( event, inside );
- }
-
- void TConicViewManager::TrackMouseDown( TMouseEvent *event )
- {
- mPrevTime= event->when-1;
- TPicControl::TrackMouseDown( event );
- TrackMouseWithin( event );
- }