//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ControlPanel::Redo( void )
{
	CExpClass *active = expressions->GetActiveClass();
	if ( !active )
		return;
	int index = active->GetSelectedExpression();
	if ( index != -1 )
	{
		RedoExpression( index );
	}
}
void ControlPanel::ChangeModel( const char *filename )
{
	// init all the selection tabs based on the current model
	initSequenceChoices();
	initBodypartChoices();
	initBoneControllerChoices();
	initSkinChoices();

	setModelInfo();

	SetCloseCaptionLanguageId( g_viewerSettings.cclanguageid, true );

	g_viewerSettings.m_iEditAttachment = -1;

	g_viewerSettings.enableIK = true;
	g_viewerSettings.enableTargetIK = false;

	setSequence( models->GetActiveStudioModel()->GetSequence() );
	setSpeed( g_viewerSettings.speedScale );

	mx_setcwd (mx_getpath (filename));

	g_pFlexPanel->initFlexes();
	
	//	centerView();
	//	CenterOnFace();

	IFacePoserToolWindow::ModelChanged();
	
	CExpClass *cl = expressions->GetActiveClass();
	if ( cl )
	{
		cl->SelectExpression( cl->GetSelectedExpression() );
	}

	SetSuffix( va( " - %s.mdl", models->GetActiveModelName() ) );
	redraw();
}
void mxExpressionTray::redraw()
{
	if ( !ToolCanDraw() )
		return;

	bool updateSelection = false;

	CExpClass *active = expressions->GetActiveClass();
	if ( active && active->GetNumExpressions() != m_nPreviousExpressionCount )
	{
		m_nTopOffset = 0;

		RepositionSlider();
		m_nPreviousExpressionCount = active->GetNumExpressions();
	}

	CChoreoWidgetDrawHelper helper( this, GetSysColor( COLOR_BTNFACE ) );
	HandleToolRedraw( helper );

	int w, h;
	w = w2();
	h = h2();

	if ( active )
	{
		RECT clipRect;
		helper.GetClientRect( clipRect );
		
		clipRect.top += TOP_GAP + GetCaptionHeight();

		helper.StartClipping( clipRect );

		if ( m_nLastNumExpressions != active->GetNumExpressions() )
		{
			m_nTopOffset = 0;
			m_nLastNumExpressions = active->GetNumExpressions();
			RepositionSlider();
			updateSelection = true;
		}

		int selected = active->GetSelectedExpression();

		int rcx, rcy, rcw, rch;

		int c = 0;
		while ( c < active->GetNumExpressions() )
		{
			if ( !ComputeRect( c, rcx, rcy, rcw, rch ) )
			{
				c++;
				continue;
			}

			CExpression *current = active->GetExpression( c );
			if ( !current )
				break;

			DrawThumbNail( active, current, helper, rcx, rcy, rcw, rch, c, selected, updateSelection );

			c++;
		}

		helper.StopClipping();

	}
	else
	{

		RECT rc;
		helper.GetClientRect( rc );

		// Arial 36 normal
		char sz[ 256 ];
		sprintf( sz, "No expression file loaded" );

		int pointsize = 18;

		int textlen = helper.CalcTextWidth( "Arial", pointsize, FW_NORMAL, sz );

		RECT rcText;
		rcText.top = ( rc.bottom - rc.top ) / 2 - pointsize / 2;
		rcText.bottom = rcText.top + pointsize + 10;
		int fullw = rc.right - rc.left;

		rcText.left = rc.left + ( fullw - textlen ) / 2;
		rcText.right = rcText.left + textlen;

		helper.DrawColoredText( "Arial", pointsize, FW_NORMAL,  RGB( 80, 80, 80 ), rcText, sz );
	}


// 	ValidateRect( (HWND)getHandle(), &rc );
}