Example #1
0
//*****************************************************************************
//
// Function Name:  CHeadlineSheet::OnPaint
//
// Description:    WM_PAINT handler
//
// Returns:        VOID
//
// Exceptions:	   None
//
//*****************************************************************************
//
void CHeadlineSheet::OnPaint( )
	{
	PAINTSTRUCT ps;
	HDC hdc = ::BeginPaint( GetSafeHwnd( ), &ps );

	// Put it in a DcDrawingSurface
	RDcDrawingSurface drawingSurface;
	drawingSurface.Initialize( hdc );

	// Create a transform
	R2dTransform transform;

	// Scale to the device DPI
	RRealSize deviceDPI = drawingSurface.GetDPI( );
	transform.PreScale( (YFloatType)deviceDPI.m_dx / kSystemDPI, (YFloatType)deviceDPI.m_dy / kSystemDPI );

	// Get the preview rectangle
	RRealRect previewRect;
	GetPreviewRect( &previewRect );

	// Offset the transform by the top left corner of the preview rect
	transform.PreTranslate( previewRect.m_Left, previewRect.m_Top );

	// Render the preview headline
	m_pPreviewHeadline->Render( drawingSurface, transform, RRealRect( previewRect.WidthHeight( ) ), previewRect.WidthHeight( ) );

	drawingSurface.DetachDCs( );

	::EndPaint( GetSafeHwnd( ), &ps );
	}
Example #2
0
// ****************************************************************************
//
//  Function Name:	RWindowView::InvalidateVectorRect( )
//
//  Description:		Invalidates the given vector rect in this view
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RWindowView::InvalidateVectorRect( const RRealVectorRect& rect, BOOLEAN fErase )
	{
	//
	//	Only invalidate if we have a CWnd
	if( !GetCWnd() )
		return;

		// Get the bounding rect...
	RRealRect temp = rect.m_TransformedBoundingRect;

	// Get our transformation...
	R2dTransform	transform;
	ApplyTransform( transform, FALSE, FALSE );

	// Apply it to our bounds...
	temp *= transform;

	// Convert the bounds to device units
	::LogicalUnitsToDeviceUnits( temp, *this );

	// guard for roundoff...
		const YRealDimension	kRoundOffGuard	= 2.0;
	temp.Inflate( RRealSize( kRoundOffGuard, kRoundOffGuard ) );

	// Put it in a CRect and do the invalidate
	CRect crect( ::Round(temp.m_Left), ::Round(temp.m_Top), ::Round(temp.m_Right), ::Round(temp.m_Bottom) );
	GetCWnd( ).InvalidateRect( crect, fErase );
	}
Example #3
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::GetBoundingRectIncludingHandles
//
//  Description:		Calculates a bounding rect for the specified object that
//							includes the resize and rotate handles
//
//  Returns:			See above.
//
//  Exceptions:		None
//
// ****************************************************************************
//
RRealRect RCompositeSelection::GetBoundingRectIncludingHandles( ) const
{
    TpsAssert( !IsEmpty( ), "Nothing selected" );

    YSelectionIterator iterator = Start( );

    // Use the first rectangle as the starting point, and union from there
    RRealRect boundingRect = RSingleSelection::GetBoundingRectIncludingHandles( *iterator );
    ++iterator;

    for( ; iterator != End( ); ++iterator )
        boundingRect.Union( boundingRect, RSingleSelection::GetBoundingRectIncludingHandles( *iterator ) );

    return boundingRect;
}
Example #4
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::GetBoundingRect( )
//
//  Description:		Gets the bounding rect of all objects in this selection
//
//  Returns:			The bounding rect
//
//  Exceptions:		None
//
// ****************************************************************************
//
RRealRect RCompositeSelection::GetBoundingRect( ) const
{
    TpsAssert( !IsEmpty( ), "Nothing selected" );

    YSelectionIterator iterator = Start( );

    // Use the first rectangle as the starting point, and union from there
    RRealRect boundingRect = ( *iterator )->GetBoundingRect( ).m_TransformedBoundingRect;
    ++iterator;

    for( ; iterator != End( ); ++iterator )
        boundingRect.Union( boundingRect, ( *iterator )->GetBoundingRect( ).m_TransformedBoundingRect );

    return boundingRect;
}
Example #5
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::GetDragTrackingFeedbackBoundingRect( )
//
//  Description:		Gets the bounding rect of drag tracking feedback
//
//  Returns:			Bounding rect
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RRealRect RCompositeSelection::GetDragTrackingFeedbackBoundingRect( const R2dTransform& transform,
        const RRealSize& offset ) const
{
    TpsAssert( !IsEmpty( ), "Nothing selected" );

    YSelectionCollectionIterator iterator = m_SelectionCollection.Start( );

    // Use the first rectangle as the starting point, and union from there
    RRealRect boundingRect = ( *iterator )->GetDragTrackingFeedbackBoundingRect( transform, offset );
    ++iterator;

    for( ; iterator != m_SelectionCollection.End( ); ++iterator )
        boundingRect.Union( boundingRect, ( *iterator )->GetDragTrackingFeedbackBoundingRect( transform, offset ) );

    return boundingRect;
}
Example #6
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::GetSelectionBoundingRect( )
//
//  Description:		Retrieves the bounding rect of this selection
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
void RCompositeSelection::GetSelectionBoundingRect( YSelectionBoundingRect& boundingRect ) const
{
    // Get the first bounding rect
    YSelectionCollectionIterator iterator = m_SelectionCollection.Start( );
    ( *iterator )->GetSelectionBoundingRect( boundingRect );
    RRealRect unionRect = boundingRect.m_TransformedBoundingRect;
    ++iterator;

    // Union in the rest of the bounding rects
    for( ; iterator != m_SelectionCollection.End( ); ++iterator )
    {
        ( *iterator )->GetSelectionBoundingRect( boundingRect );
        unionRect.Union( unionRect, boundingRect.m_TransformedBoundingRect );
    }

    // Set the rect
    boundingRect.Set( unionRect );
}
Example #7
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::GetResizeTrackingFeedbackBoundingRect( )
//
//  Description:		Gets the bounding rect of resize tracking feedback
//
//  Returns:			Bounding rect
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RRealRect RCompositeSelection::GetResizeTrackingFeedbackBoundingRect( const R2dTransform& transform,
        const RRealPoint& scalingCenter,
        const RRealSize& scaleFactor,
        BOOLEAN fMaintainAspectRatio ) const
{
    TpsAssert( !IsEmpty( ), "Nothing selected" );

    YSelectionCollectionIterator iterator = m_SelectionCollection.Start( );

    // Use the first rectangle as the starting point, and union from there
    RRealRect boundingRect = ( *iterator )->GetResizeTrackingFeedbackBoundingRect( transform, scalingCenter, scaleFactor, fMaintainAspectRatio );
    ++iterator;

    for( ; iterator != m_SelectionCollection.End( ); ++iterator )
        boundingRect.Union( boundingRect, ( *iterator )->GetResizeTrackingFeedbackBoundingRect( transform, scalingCenter, scaleFactor, fMaintainAspectRatio ) );

    return boundingRect;
}
Example #8
0
// ****************************************************************************
//
//  Function Name:	RRotateSelectionTracker::GetFeedbackBoundingRect( )
//
//  Description:		Returns the feedback bounding rect
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
RRealRect RRotateSelectionTracker::GetFeedbackBoundingRect( const RRealPoint& point ) const
	{
	// Get the view transform
	R2dTransform transform;
	m_pView->GetViewTransform( transform, TRUE );

	// Calculate the angle
	YAngle angle = CalcAngle( point );

	// Get the bounding rect, in device units
	RRealRect boundingRect = m_pSelection->GetRotateTrackingFeedbackBoundingRect( transform, m_TrackingRotationCenter, angle );

	// Convert back to logical units
	transform.Invert( );
	boundingRect *= transform;

	// Add the feedback line
	boundingRect.AddPointToRect( point );

	return boundingRect;
	}
Example #9
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::Invalidate( )
//
//  Description:		Invalidates the region occupied by this selection in the
//							given view.
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
void RSingleSelection::Invalidate( BOOLEAN fInvalidateIfLocked ) const
	{
	if( fInvalidateIfLocked || m_pSelectedObject->GetComponentAttributes( ).IsLocked( ) == FALSE )
		{
		// Get the full soft effects bounding rect and invalidate it
		YSelectionBoundingRect boundingRect;
		boundingRect = m_pSelectedObject->GetFullSoftEffectsBoundingRect();
		SelectionRectFromObjectRect( boundingRect, m_pView, TRUE );
		RRealRect invalidRect = boundingRect.m_TransformedBoundingRect;
		
		// Extend the rectangle to contain the rotate handle
		invalidRect.AddPointToRect( GetRotateHandleCenterPoint( ) );
			
		// Inflate by the rotate handle size
		RRealSize rotateHandleSize( kRotateHandleRenderSize + 1, kRotateHandleRenderSize + 1);
		::DeviceUnitsToLogicalUnits( rotateHandleSize, *m_pView );
		invalidRect.Inflate( rotateHandleSize );
		
		// Do the invalidate
		m_pView->InvalidateVectorRect( invalidRect );
		}
	}
Example #10
0
// ****************************************************************************
//
//  Function Name:	SingleSelection::GetBoundingRectIncludingHandles
//
//  Description:		Calculates a bounding rect for the specified object that
//							includes the resize and rotate handles
//
//  Returns:			See above.
//
//  Exceptions:		None
//
// ****************************************************************************
//
RRealRect RSingleSelection::GetBoundingRectIncludingHandles( const RComponentView* pComponentView )
	{
	// Create a new single selection
	RSingleSelection selection( pComponentView, pComponentView->GetParentView( ) );

	// Get the bounding rect of the component
	RRealRect rect = pComponentView->GetBoundingRect( ).m_TransformedBoundingRect;

	// Get the component attributes
	const RComponentAttributes& componentAttributes = pComponentView->GetComponentAttributes( );

	RRealRect handleRect;

	// Get the resize handles
	if( componentAttributes.IsResizable( ) )
		{
		R2dTransform	transform;
		selection.GetResizeSelectionHandle( handleRect, transform, kTopLeftResizeHandle, TRUE );
		rect.AddRectToRect( handleRect );

		selection.GetResizeSelectionHandle( handleRect, transform, kTopRightResizeHandle, TRUE );
		rect.AddRectToRect( handleRect );

		selection.GetResizeSelectionHandle( handleRect, transform, kBottomRightResizeHandle, TRUE );
		rect.AddRectToRect( handleRect );

		selection.GetResizeSelectionHandle( handleRect, transform, kBottomLeftResizeHandle, TRUE );
		rect.AddRectToRect( handleRect );
		}

	// Get the rotate handle
	if( componentAttributes.IsRotatable( ) )
		{
		RRealVectorRect	vRect;
		selection.GetRotateHandle( vRect );
		rect.AddRectToRect( vRect.m_TransformedBoundingRect );
		}

	return rect;
	}
Example #11
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::HitTest( )
//
//  Description:		Hits test this selection
//
//  Returns:			The location of this selection that was hit
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RSelection::EHitLocation RSingleSelection::HitTest( const RRealPoint& point ) const
	{
	RRealRect	rect;
	RRealSize	scaleFactor(kDummyScale,kDummyScale);	//	This is just to be able to see if the object is constrainted

	scaleFactor = m_pSelectedObject->ApplyResizeConstraint( scaleFactor );

	// Get the component attributes
	const RComponentAttributes& componentAttributes = m_pSelectedObject->GetComponentAttributes( );

	if( componentAttributes.IsResizable( ) )
		{
		R2dTransform	transform;
		// Test the resize handles
		GetResizeSelectionHandle( rect, transform, kTopLeftResizeHandle, FALSE );
		if( rect.PointInRect( point ) )
			return kTopLeftResizeHandle;

		GetResizeSelectionHandle( rect, transform, kTopRightResizeHandle, FALSE );
		if( rect.PointInRect( point ) )
			return kTopRightResizeHandle;

		GetResizeSelectionHandle( rect, transform, kBottomRightResizeHandle, FALSE );
		if( rect.PointInRect( point ) )
			return kBottomRightResizeHandle;

		GetResizeSelectionHandle( rect, transform, kBottomLeftResizeHandle, FALSE );
		if( rect.PointInRect( point ) )
			return kBottomLeftResizeHandle;

		if ( !AreFloatsEqual( scaleFactor.m_dy, kConstrainedScale ) )
			{
			GetResizeSelectionHandle( rect, transform, kTopResizeHandle, FALSE );
			if( rect.PointInRect( point ) )
				return kTopResizeHandle;

			GetResizeSelectionHandle( rect, transform, kBottomResizeHandle, FALSE );
			if( rect.PointInRect( point ) )
				return kBottomResizeHandle;
			}

		if ( !AreFloatsEqual( scaleFactor.m_dx, kConstrainedScale ) )
			{
			GetResizeSelectionHandle( rect, transform, kRightResizeHandle, FALSE );
			if( rect.PointInRect( point ) )
				return kRightResizeHandle;

			GetResizeSelectionHandle( rect, transform, kLeftResizeHandle, FALSE );
			if( rect.PointInRect( point ) )
				return kLeftResizeHandle;
			}

		}

	// Test the selection rect
	if( componentAttributes.IsMovable( ) )
		{
		if( m_pSelectedObject->HitTestSelectionFrame( point ) )
			return kInside;
		}

	// Test the rotate handle
	if( componentAttributes.IsRotatable( ) )
		{
		RRealVectorRect	vRect;
		GetRotateHandle( vRect );
		if( vRect.PointInRect( point ) )
			return kRotateHandle;
		}

	return kNothing;
	}