X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e08b761b0c5ecb6df295785b78f1f3637331887..0d1dff0172e94487c4aa2d830c714f93be73c7ec:/contrib/src/fl/hintanimpl.cpp?ds=sidebyside

diff --git a/contrib/src/fl/hintanimpl.cpp b/contrib/src/fl/hintanimpl.cpp
index 3453fe877f..56752d6f1d 100644
--- a/contrib/src/fl/hintanimpl.cpp
+++ b/contrib/src/fl/hintanimpl.cpp
@@ -1,12 +1,12 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        No names yet.
-// Purpose:     Contrib. demo
+// Name:        hintanimpl.cpp
+// Purpose:     cbHintAnimationPlugin implementation.
 // Author:      Aleksandras Gluchovas
 // Modified by:
 // Created:     9/11/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Aleksandras Gluchovas
-// Licence:   	wxWindows license
+// Licence:       wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
@@ -37,111 +37,111 @@ IMPLEMENT_DYNAMIC_CLASS( cbHintAnimationPlugin, cbPluginBase )
 
 BEGIN_EVENT_TABLE( cbHintAnimationPlugin, cbPluginBase )
 
-	EVT_PL_DRAW_HINT_RECT( cbHintAnimationPlugin::OnDrawHintRect )
+    EVT_PL_DRAW_HINT_RECT( cbHintAnimationPlugin::OnDrawHintRect )
 
 END_EVENT_TABLE()
 
 cbHintAnimationPlugin::cbHintAnimationPlugin(void)
 
-	: mpScrDc( NULL ),
-	  mpAnimTimer( 0 ),
-	  mAnimStarted( FALSE ),
-	  
-	  mMorphDelay    ( 5   ),
-	  mMaxFrames     ( 20   ),
+    : mpScrDc( NULL ),
+      mpAnimTimer( 0 ),
+      mAnimStarted( FALSE ),
+      
+      mMorphDelay    ( 5   ),
+      mMaxFrames     ( 20   ),
       mInClientHintBorder( 4 ),
-	  mAccelerationOn( TRUE )
+      mAccelerationOn( TRUE )
 {}
 
 cbHintAnimationPlugin::cbHintAnimationPlugin( wxFrameLayout* pPanel, int paneMask )
 
-	: cbPluginBase( pPanel, paneMask ),
-	  mpScrDc( NULL ),
-	  mpAnimTimer( 0 ),
-	  mAnimStarted( FALSE ),
+    : cbPluginBase( pPanel, paneMask ),
+      mpScrDc( NULL ),
+      mpAnimTimer( 0 ),
+      mAnimStarted( FALSE ),
 
-	  mMorphDelay    ( 5   ),
-	  mMaxFrames     ( 20   ),
-	  mInClientHintBorder( 4 ),
-	  mAccelerationOn( TRUE )
+      mMorphDelay    ( 5   ),
+      mMaxFrames     ( 20   ),
+      mInClientHintBorder( 4 ),
+      mAccelerationOn( TRUE )
 {}
 
 cbHintAnimationPlugin::~cbHintAnimationPlugin()
 {
-	if ( mpScrDc ) delete mpScrDc;
+    if ( mpScrDc ) delete mpScrDc;
 }
 
 /*** rect-tracking related methods ***/
 
 void cbHintAnimationPlugin::OnDrawHintRect( cbDrawHintRectEvent& event )
 {
-	if ( !mAnimStarted && !mpScrDc ) 
-	{
-		StartTracking();
+    if ( !mAnimStarted && !mpScrDc ) 
+    {
+        StartTracking();
 
-		mPrevInClient = event.mIsInClient;
+        mPrevInClient = event.mIsInClient;
 
-		mPrevRect = event.mRect;
+        mPrevRect = event.mRect;
 
-		mStopPending = FALSE;
-	}
+        mStopPending = FALSE;
+    }
 
-	if ( !event.mEraseRect )
-	{
-		// pass on current hint-rect info to the animation "thread", in 
-		// order to make adjustments to the morph-target on-the-fly
+    if ( !event.mEraseRect )
+    {
+        // pass on current hint-rect info to the animation "thread", in 
+        // order to make adjustments to the morph-target on-the-fly
 
-		mCurRect.x = event.mRect.x;
-		mCurRect.y = event.mRect.y;
-		mCurRect.width  = event.mRect.width;
-		mCurRect.height = event.mRect.height;
-	}
+        mCurRect.x = event.mRect.x;
+        mCurRect.y = event.mRect.y;
+        mCurRect.width  = event.mRect.width;
+        mCurRect.height = event.mRect.height;
+    }
 
-	// check the amount of change in the shape of hint,
-	// and start morph-effect if change is "sufficient"
+    // check the amount of change in the shape of hint,
+    // and start morph-effect if change is "sufficient"
 
-	int change = abs( mCurRect.width  - mPrevRect.width  ) +
-			     abs( mCurRect.height - mPrevRect.height );
+    int change = abs( mCurRect.width  - mPrevRect.width  ) +
+                 abs( mCurRect.height - mPrevRect.height );
 
-	if ( change > 10 && !event.mLastTime && !event.mEraseRect )
-	{
-		if ( !mpAnimTimer )
+    if ( change > 10 && !event.mLastTime && !event.mEraseRect )
+    {
+        if ( !mpAnimTimer )
 
-			mpAnimTimer  = new cbHintAnimTimer();
+            mpAnimTimer  = new cbHintAnimTimer();
 
-		// init the animation "thread", or reinit if already started
+        // init the animation "thread", or reinit if already started
 
-		mpAnimTimer->Init( this, mAnimStarted );
+        mpAnimTimer->Init( this, mAnimStarted );
 
-		mAnimStarted = TRUE;
-	}
-	else
-	if ( !mAnimStarted )
-	{
-		DoDrawHintRect( event.mRect, event.mIsInClient );
+        mAnimStarted = TRUE;
+    }
+    else
+    if ( !mAnimStarted )
+    {
+        DoDrawHintRect( event.mRect, event.mIsInClient );
 
-		if ( event.mLastTime )
+        if ( event.mLastTime )
 
-			FinishTracking();
+            FinishTracking();
 
-		mPrevInClient = event.mIsInClient;
-	}
-	else
-	{
-		mCurInClient = event.mIsInClient;
+        mPrevInClient = event.mIsInClient;
+    }
+    else
+    {
+        mCurInClient = event.mIsInClient;
 
-		if ( event.mLastTime && mpAnimTimer ) 
-		{
-			mStopPending = TRUE;
+        if ( event.mLastTime && mpAnimTimer ) 
+        {
+            mStopPending = TRUE;
 
-			if ( mpAnimTimer->mPrevMorphed.x != POS_UNDEFINED )
+            if ( mpAnimTimer->mPrevMorphed.x != POS_UNDEFINED )
 
-				// erase previous rect
-				DoDrawHintRect( mpAnimTimer->mPrevMorphed, mPrevInClient );
-		}
-	}
+                // erase previous rect
+                DoDrawHintRect( mpAnimTimer->mPrevMorphed, mPrevInClient );
+        }
+    }
 
-	mPrevRect = event.mRect;
+    mPrevRect = event.mRect;
 }
 
 #define _IMG_A  0xAA    // Note: modified from _A to _IMG_A, _A was already defined (cygwin)
@@ -150,109 +150,109 @@ void cbHintAnimationPlugin::OnDrawHintRect( cbDrawHintRectEvent& event )
 #define _IMG_D  0x00    // Note: modified from _D to _IMG_D, for consistency reasons.
 
 static const unsigned char _gCheckerImg[16] = { _IMG_A,_IMG_B,_IMG_C,_IMG_D,
-											    _IMG_A,_IMG_B,_IMG_C,_IMG_D,
-											    _IMG_A,_IMG_B,_IMG_C,_IMG_D,
-											    _IMG_A,_IMG_B,_IMG_C,_IMG_D
-											  };
+                                                _IMG_A,_IMG_B,_IMG_C,_IMG_D,
+                                                _IMG_A,_IMG_B,_IMG_C,_IMG_D,
+                                                _IMG_A,_IMG_B,_IMG_C,_IMG_D
+                                              };
 
 void cbHintAnimationPlugin::StartTracking()
 {
-	mpScrDc = new wxScreenDC;
+    mpScrDc = new wxScreenDC;
 
-	wxScreenDC::StartDrawingOnTop(&mpLayout->GetParentFrame());
+    wxScreenDC::StartDrawingOnTop(&mpLayout->GetParentFrame());
 }
 
 void cbHintAnimationPlugin::DoDrawHintRect( wxRect& rect, bool isInClientRect)
 {
-	wxRect scrRect;
+    wxRect scrRect;
 
-	RectToScr( rect, scrRect );
+    RectToScr( rect, scrRect );
 
-	int prevLF = mpScrDc->GetLogicalFunction();
+    int prevLF = mpScrDc->GetLogicalFunction();
 
-	mpScrDc->SetLogicalFunction( wxXOR );
+    mpScrDc->SetLogicalFunction( wxXOR );
 
-	if ( isInClientRect )
-	{
-		// BUG BUG BUG (wx):: somehow stippled brush works only  
-		//					  when the bitmap created on stack, not
-		//					  as a member of the class
+    if ( isInClientRect )
+    {
+        // BUG BUG BUG (wx):: somehow stippled brush works only  
+        //                      when the bitmap created on stack, not
+        //                      as a member of the class
 
-		wxBitmap checker( (const char*)_gCheckerImg, 8,8 );
+        wxBitmap checker( (const char*)_gCheckerImg, 8,8 );
 
-		wxBrush checkerBrush( checker );
+        wxBrush checkerBrush( checker );
 
-		mpScrDc->SetPen( mpLayout->mNullPen );
-		mpScrDc->SetBrush( checkerBrush );
+        mpScrDc->SetPen( mpLayout->mNullPen );
+        mpScrDc->SetBrush( checkerBrush );
 
-		int half = mInClientHintBorder / 2;
+        int half = mInClientHintBorder / 2;
 
-		mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y - half,
-			                    scrRect.width + 2*half, mInClientHintBorder );
+        mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y - half,
+                                scrRect.width + 2*half, mInClientHintBorder );
 
-		mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + scrRect.height - half,
-			                    scrRect.width + 2*half, mInClientHintBorder );
+        mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + scrRect.height - half,
+                                scrRect.width + 2*half, mInClientHintBorder );
 
-		mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + half - 1,
-			                    mInClientHintBorder, scrRect.height - 2*half + 2);
+        mpScrDc->DrawRectangle( scrRect.x - half, scrRect.y + half - 1,
+                                mInClientHintBorder, scrRect.height - 2*half + 2);
 
-		mpScrDc->DrawRectangle( scrRect.x + scrRect.width - half,
-								scrRect.y + half - 1,
-			                    mInClientHintBorder, scrRect.height - 2*half + 2);
+        mpScrDc->DrawRectangle( scrRect.x + scrRect.width - half,
+                                scrRect.y + half - 1,
+                                mInClientHintBorder, scrRect.height - 2*half + 2);
 
-		mpScrDc->SetBrush( wxNullBrush );
-	}
-	else
-	{
-		// otherwise draw 1-pixel thin borders
+        mpScrDc->SetBrush( wxNullBrush );
+    }
+    else
+    {
+        // otherwise draw 1-pixel thin borders
 
-		mpScrDc->SetPen( mpLayout->mBlackPen );
+        mpScrDc->SetPen( mpLayout->mBlackPen );
 
-		mpScrDc->DrawLine( scrRect.x, scrRect.y, 
-						   scrRect.x + scrRect.width, scrRect.y );
+        mpScrDc->DrawLine( scrRect.x, scrRect.y, 
+                           scrRect.x + scrRect.width, scrRect.y );
 
-		mpScrDc->DrawLine( scrRect.x, scrRect.y + 1, 
-						   scrRect.x, scrRect.y + scrRect.height );
+        mpScrDc->DrawLine( scrRect.x, scrRect.y + 1, 
+                           scrRect.x, scrRect.y + scrRect.height );
 
-		mpScrDc->DrawLine( scrRect.x+1, scrRect.y + scrRect.height, 
-						   scrRect.x + scrRect.width, scrRect.y + scrRect.height );
+        mpScrDc->DrawLine( scrRect.x+1, scrRect.y + scrRect.height, 
+                           scrRect.x + scrRect.width, scrRect.y + scrRect.height );
 
-		mpScrDc->DrawLine( scrRect.x + scrRect.width , scrRect.y, 
-						   scrRect.x + scrRect.width, scrRect.y + scrRect.height + 1);
-	}
+        mpScrDc->DrawLine( scrRect.x + scrRect.width , scrRect.y, 
+                           scrRect.x + scrRect.width, scrRect.y + scrRect.height + 1);
+    }
 
-	mpScrDc->SetLogicalFunction( prevLF );
+    mpScrDc->SetLogicalFunction( prevLF );
 }
 
 void cbHintAnimationPlugin::DrawHintRect ( wxRect& rect, bool isInClientRect)
 {
-	DoDrawHintRect( rect, isInClientRect );	
+    DoDrawHintRect( rect, isInClientRect );    
 }
 
 void cbHintAnimationPlugin::EraseHintRect( wxRect& rect, bool isInClientRect)
 {
-	DoDrawHintRect( rect, isInClientRect );	
+    DoDrawHintRect( rect, isInClientRect );    
 }
 
 void cbHintAnimationPlugin::FinishTracking()
 {
-	wxScreenDC::EndDrawingOnTop();
+    wxScreenDC::EndDrawingOnTop();
 
-	delete mpScrDc;
+    delete mpScrDc;
 
-	mpScrDc = NULL;
+    mpScrDc = NULL;
 }
 
 void cbHintAnimationPlugin::RectToScr( wxRect& frameRect, wxRect& scrRect )
 {
-	scrRect = frameRect;
+    scrRect = frameRect;
 
-	int x = frameRect.x, y = frameRect.y;
+    int x = frameRect.x, y = frameRect.y;
 
-	mpLayout->GetParentFrame().ClientToScreen( &x, &y );
+    mpLayout->GetParentFrame().ClientToScreen( &x, &y );
 
-	scrRect.x = x;
-	scrRect.y = y;
+    scrRect.x = x;
+    scrRect.y = y;
 }
 
 /***** Implementation for class cbHintAnimTimer *****/
@@ -260,138 +260,138 @@ void cbHintAnimationPlugin::RectToScr( wxRect& frameRect, wxRect& scrRect )
 cbHintAnimTimer::cbHintAnimTimer(void)
 {
 #ifdef __WINDOWS__
-	mLock = 0L;
+    mLock = 0L;
 #endif
 
-	mPrevMorphed.x = POS_UNDEFINED;
+    mPrevMorphed.x = POS_UNDEFINED;
 }
 
 void cbHintAnimTimer::MorphPoint( wxPoint& origin, MorphInfoT& info, wxPoint& point )
 {
-	// simulate lienar movement (FOR NOW:: without acceleration)
+    // simulate lienar movement (FOR NOW:: without acceleration)
 
-	double k;
-	
-	if ( mpPl->mAccelerationOn )
-		
-		k = double( mCurIter*mCurIter ) / 
-		    double( (mpPl->mMaxFrames - 1)*(mpPl->mMaxFrames - 1) );
-	else
-		k = double( mCurIter ) / double( mpPl->mMaxFrames - 1 );
+    double k;
+    
+    if ( mpPl->mAccelerationOn )
+        
+        k = double( mCurIter*mCurIter ) / 
+            double( (mpPl->mMaxFrames - 1)*(mpPl->mMaxFrames - 1) );
+    else
+        k = double( mCurIter ) / double( mpPl->mMaxFrames - 1 );
 
-	point.x = int ( double ( info.mFrom.x + double (info.mTill.x - info.mFrom.x) * k ) );
+    point.x = int ( double ( info.mFrom.x + double (info.mTill.x - info.mFrom.x) * k ) );
 
-	point.y = int ( double ( info.mFrom.y + double (info.mTill.y - info.mFrom.y) * k ) );
+    point.y = int ( double ( info.mFrom.y + double (info.mTill.y - info.mFrom.y) * k ) );
 
-	point.x += origin.x;
-	point.y += origin.y;
+    point.x += origin.x;
+    point.y += origin.y;
 }
 
 void cbHintAnimTimer::Notify(void)
 {
-	// FIXME:: "clean" implementation should use mutex to sync
-	//         between GUI and animation threads
+    // FIXME:: "clean" implementation should use mutex to sync
+    //         between GUI and animation threads
 
-	if ( mpPl->mStopPending )
-	{
-		Stop(); // top timer
+    if ( mpPl->mStopPending )
+    {
+        Stop(); // top timer
 
-		mpPl->FinishTracking();
+        mpPl->FinishTracking();
 
-		mpPl->mStopPending = FALSE;
-		mpPl->mpAnimTimer  = NULL;
-		mpPl->mAnimStarted = FALSE;
+        mpPl->mStopPending = FALSE;
+        mpPl->mpAnimTimer  = NULL;
+        mpPl->mAnimStarted = FALSE;
 
-		mPrevMorphed.x = POS_UNDEFINED;
+        mPrevMorphed.x = POS_UNDEFINED;
 
-		delete this;
+        delete this;
 
-		return;
-	}
+        return;
+    }
 
-	wxPoint origin( mpPl->mCurRect.x, mpPl->mCurRect.y );
+    wxPoint origin( mpPl->mCurRect.x, mpPl->mCurRect.y );
 
-	wxPoint curUpper, curLower;
+    wxPoint curUpper, curLower;
 
-	MorphPoint( origin, mUpperLeft,  curUpper  );
-	MorphPoint( origin, mLowerRight, curLower );
+    MorphPoint( origin, mUpperLeft,  curUpper  );
+    MorphPoint( origin, mLowerRight, curLower );
 
-	if ( mPrevMorphed.x != POS_UNDEFINED )
+    if ( mPrevMorphed.x != POS_UNDEFINED )
 
-		// erase previous rect
-		mpPl->DoDrawHintRect( mPrevMorphed, mpPl->mPrevInClient );
+        // erase previous rect
+        mpPl->DoDrawHintRect( mPrevMorphed, mpPl->mPrevInClient );
 
-	wxRect morphed( curUpper.x,  curUpper.y,
-			        curLower.x - curUpper.x,
-					curLower.y - curUpper.y );
+    wxRect morphed( curUpper.x,  curUpper.y,
+                    curLower.x - curUpper.x,
+                    curLower.y - curUpper.y );
 
-	// draw rect of current iteration
-	mpPl->DoDrawHintRect( morphed, 
-						  ( mCurIter != mpPl->mMaxFrames - 1 ) 
-						  ? mpPl->mPrevInClient : mpPl->mCurInClient );
+    // draw rect of current iteration
+    mpPl->DoDrawHintRect( morphed, 
+                          ( mCurIter != mpPl->mMaxFrames - 1 ) 
+                          ? mpPl->mPrevInClient : mpPl->mCurInClient );
 
-	mPrevMorphed = morphed;
+    mPrevMorphed = morphed;
 
-	if ( mCurIter == mpPl->mMaxFrames - 1 ) 
-	{
-		Stop(); // top timer
-		
-		mpPl->FinishTracking();
-		mpPl->mpAnimTimer  = NULL;
-		mpPl->mAnimStarted = FALSE;
+    if ( mCurIter == mpPl->mMaxFrames - 1 ) 
+    {
+        Stop(); // top timer
+        
+        mpPl->FinishTracking();
+        mpPl->mpAnimTimer  = NULL;
+        mpPl->mAnimStarted = FALSE;
 
-		mPrevMorphed.x = POS_UNDEFINED;
+        mPrevMorphed.x = POS_UNDEFINED;
 
-		delete this;
-	}
-	else
-		++mCurIter;
+        delete this;
+    }
+    else
+        ++mCurIter;
 }
 
 bool cbHintAnimTimer::Init( cbHintAnimationPlugin* pAnimPl, bool reinit )
 {
 
-	mpPl = pAnimPl;
+    mpPl = pAnimPl;
 
-	// morph-points are set up relatively to the upper-left corner
-	// of the current hint-rectangle
+    // morph-points are set up relatively to the upper-left corner
+    // of the current hint-rectangle
 
-	if ( !reinit )
-	{
-		mUpperLeft.mFrom.x = mpPl->mPrevRect.x - mpPl->mCurRect.x;
-		mUpperLeft.mFrom.y = mpPl->mPrevRect.y - mpPl->mCurRect.y;
+    if ( !reinit )
+    {
+        mUpperLeft.mFrom.x = mpPl->mPrevRect.x - mpPl->mCurRect.x;
+        mUpperLeft.mFrom.y = mpPl->mPrevRect.y - mpPl->mCurRect.y;
 
-		mLowerRight.mFrom.x = ( mUpperLeft.mFrom.x + mpPl->mPrevRect.width  );
-		mLowerRight.mFrom.y = ( mUpperLeft.mFrom.y + mpPl->mPrevRect.height );
-	}
-	else
-	{
-		wxPoint origin( mpPl->mPrevRect.x, mpPl->mPrevRect.y );
+        mLowerRight.mFrom.x = ( mUpperLeft.mFrom.x + mpPl->mPrevRect.width  );
+        mLowerRight.mFrom.y = ( mUpperLeft.mFrom.y + mpPl->mPrevRect.height );
+    }
+    else
+    {
+        wxPoint origin( mpPl->mPrevRect.x, mpPl->mPrevRect.y );
 
-		wxPoint curUpper, curLower;
+        wxPoint curUpper, curLower;
 
-		MorphPoint( origin, mUpperLeft,  curUpper  );
-		MorphPoint( origin, mLowerRight, curLower );
+        MorphPoint( origin, mUpperLeft,  curUpper  );
+        MorphPoint( origin, mLowerRight, curLower );
 
-		mUpperLeft.mFrom.x = curUpper.x - mpPl->mCurRect.x;
-		mUpperLeft.mFrom.y = curUpper.y - mpPl->mCurRect.y;
+        mUpperLeft.mFrom.x = curUpper.x - mpPl->mCurRect.x;
+        mUpperLeft.mFrom.y = curUpper.y - mpPl->mCurRect.y;
 
-		mLowerRight.mFrom.x = ( mUpperLeft.mFrom.x + curLower.x - curUpper.x );
-		mLowerRight.mFrom.y = ( mUpperLeft.mFrom.y + curLower.y - curUpper.y );
-	}
+        mLowerRight.mFrom.x = ( mUpperLeft.mFrom.x + curLower.x - curUpper.x );
+        mLowerRight.mFrom.y = ( mUpperLeft.mFrom.y + curLower.y - curUpper.y );
+    }
 
-	mUpperLeft.mTill.x = 0;
-	mUpperLeft.mTill.y = 0;
+    mUpperLeft.mTill.x = 0;
+    mUpperLeft.mTill.y = 0;
 
-	mLowerRight.mTill.x = mpPl->mCurRect.width;
-	mLowerRight.mTill.y = mpPl->mCurRect.height;
+    mLowerRight.mTill.x = mpPl->mCurRect.width;
+    mLowerRight.mTill.y = mpPl->mCurRect.height;
 
-	mCurIter = 1;
-	
-	if ( !reinit )
+    mCurIter = 1;
+    
+    if ( !reinit )
 
-		Start( mpPl->mMorphDelay );
+        Start( mpPl->mMorphDelay );
 
-	return TRUE;
+    return TRUE;
 }