Esempio n. 1
0
// ****************************************************************************
//
//  Function Name:	RDragSelectionTracker::Validate( )
//
//  Description:		Validate the Object.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RRotateSelectionTracker::Validate( ) const
	{
	RMouseTracker::Validate( );
	TpsAssertIsObject( RRotateSelectionTracker, this );
	TpsAssertValid( m_pView );
	TpsAssertValid( m_pSelection );
	}
Esempio n. 2
0
// ****************************************************************************
//
//  Function Name:	REditComponentAttributesAction::Validate( )
//
//  Description:		Validates the object
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void REditComponentAttributesAction::Validate( ) const
	{
	RAction::Validate( );
	TpsAssertIsObject( REditComponentAttributesAction, this );
	TpsAssertValid( m_pCurrentSelection );
	TpsAssertValid( m_pComponentDocument );
	TpsAssertValid( &m_OldComponentAttributes );
	}
Esempio n. 3
0
// ****************************************************************************
//
//  Function Name:	RNewComponentAction::Validate( )
//
//  Description:		Validates the object
//
//  Returns:			Nothing
//
//  Exceptions:		None
///
// ****************************************************************************
//
void RNewComponentAction::Validate( ) const
	{
	RAction::Validate( );
	TpsAssertIsObject( RNewComponentAction, this );
	if( m_pComponentDocument )
		TpsAssertValid( m_pComponentDocument );
	TpsAssertValid( m_pParentDocument );
	}
Esempio n. 4
0
// ****************************************************************************
//
//  Function Name:	RNewComponentAction::RNewComponentAction( )
//
//  Description:		Constructor
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RNewComponentAction::RNewComponentAction( RComponentDocument* pComponentDocument,
														RDocument* pParentDocument,
														RCompositeSelection* pCurrentSelection,
														YResourceId undoRedoPairId )
	: RUndoableAction( m_ActionId, undoRedoPairId, undoRedoPairId + 1 ),
	  m_pParentDocument( pParentDocument ),
	  m_pCurrentSelection( pCurrentSelection ),
	  m_pComponentDocument( pComponentDocument ),
	  m_pActiveView( NULL )
	{
	// Validate parameters
	TpsAssertValid( pParentDocument );
	TpsAssertValid( pCurrentSelection );
	}
Esempio n. 5
0
// ****************************************************************************
//
//  Function Name:	REditComponentAttributesAction::REditComponentAttributesAction( )
//
//  Description:		Constructor
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
REditComponentAttributesAction::REditComponentAttributesAction( RCompositeSelection* pCurrentSelection )
	: RUndoableAction( m_ActionId, STRING_UNDO_EDIT_COMPONENT_ATTRIBUTES, STRING_REDO_EDIT_COMPONENT_ATTRIBUTES ),
	  m_pCurrentSelection( pCurrentSelection ),
	  m_OldZOrder( pCurrentSelection->GetView( )->GetZOrderState( ) ),
	  m_fAttributesChanged( FALSE )
	{
	// Validate parameters
	TpsAssertValid( pCurrentSelection );
	TpsAssert( m_pCurrentSelection->Count( ) == 1, "Edit Component Attributes action only operates on one object." );

	// Get the component document. This is where attributes are stored
	m_pComponentDocument = ( *m_pCurrentSelection->Start( ) )->GetComponentDocument( );

	// Get and save the component attributes
	m_OldComponentAttributes = m_pComponentDocument->GetComponentAttributes( );
	m_NewComponentAttributes = m_OldComponentAttributes;

	// Create and do the Edit Component Attributes dialog
	REditComponentAttributesDialog dialog( m_OldComponentAttributes );
	if( dialog.DoModal( ) == IDOK )
		{
		// Get the new attributes
		dialog.FillInComponentAttributes( m_NewComponentAttributes );
		m_fAttributesChanged	= TRUE;
		}
	}
Esempio n. 6
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::Select( )
//
//  Description:		Adds a selection to this composite
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
void RCompositeSelection::Select( const RComponentView* pSelectableObject, BOOLEAN fRender )
{
    // Validate
    TpsAssert( pSelectableObject, "NULL Selection" );
    TpsAssertValid( pSelectableObject );

    // Dont select if it is not selectable
    if( !pSelectableObject->GetComponentAttributes( ).IsSelectable( ) )
        return;

    // Check to see if it already in the selection list
    TpsAssert( IsSelected( pSelectableObject ) == FALSE, "Selection is already in this composite." );

    // Create a new selection and add it
    RSingleSelection* pNewSelection = new RSingleSelection( pSelectableObject, m_pView );
    m_SelectionCollection.InsertAtEnd( pNewSelection );

    // Create a drawing surface and transform
    RViewDrawingSurface drawingSurface( m_pView );
    R2dTransform transform;
    SetupRender( drawingSurface, transform );
    RRealRect rect( m_pView->GetSize( ) );

    if( fRender && ShouldRenderSelection( ) )
        pNewSelection->Render( drawingSurface, transform, rect );

    // Tell the view the selection is changing
    m_pView->OnChangeSelection( );
}
Esempio n. 7
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::Validate( )
//
//  Description:		Validates the object
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RSingleSelection::Validate( )	const
	{
	RSelection::Validate( );
	TpsAssertIsObject( RSingleSelection, this );
	TpsAssert( m_pSelectedObject, "NULL selected object." );
	TpsAssertValid( m_pSelectedObject );
	}
Esempio n. 8
0
// ****************************************************************************
//
//  Function Name:	RCopySelectionAction::RCopySelectionAction( )
//
//  Description:		Constructor
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
RCopySelectionAction::RCopySelectionAction( RCompositeSelection* pCurrentSelection, RDataTransferTarget* pDataTransferTarget, BOOLEAN fDelayRenderComponents, RScript& script )
	: RAction( m_ActionId, script ),
	  m_pCurrentSelection( pCurrentSelection ),
	  m_pDataTransferTarget( pDataTransferTarget ),
	  m_fDelayRenderComponents( fDelayRenderComponents )
	{
	// Validate parameters
	TpsAssertValid( pCurrentSelection );
	}
Esempio n. 9
0
// ****************************************************************************
//
//  Function Name:	RStandaloneDocument::SendAction( )
//
//  Description:		Component API function to send an action to a Component
//
//  Returns:			TODO: What does this return?
//
//  Exceptions:		None
//
// ****************************************************************************
//
BOOLEAN RStandaloneDocument::SendAction( RAction* pAction )
	{
	BOOLEAN					fReturnValue	= FALSE;
	RAutoCleanupAction	cleanup( pAction );

	//	First Always, try to write the script as it is in its state before the 
	//	Do occurs. This will allow us to Create the Action and then call Do
	//	in the script processing.
	try
		{
		if ( GetRecordingScript( ) )
			{
			RScript&	script	= *GetRecordingScript( );
			script << pAction->GetActionId( );
			pAction->WriteScript( script );
			}
		}
	catch( YException exception )
		{
		::ReportException( exception );///xxx	TODO: Script Dumping Failed... Alert user and continue
		}

	if( pAction->Do( ) )
		{
		fReturnValue = TRUE;
			//	Action was Done and the script was written, we succeded.
			//	If action is undoable, give it to the undo mananger...
			//	If it is not undoable, we are done with it so delete it...
		if( pAction->IsUndoable( ) )
			{
			RUndoableAction*	pUndoAction = dynamic_cast<RUndoableAction*>( pAction );
			TpsAssert( pUndoAction, "The given undoable action is not derived from RUndoableAction");
			TpsAssertValid( m_pUndoManager );	
			m_pUndoManager->AddAction( pUndoAction );
			//
			//	Tell cleanup class to release control of the object, the action object
			//	ownership has passed to the undo manager
			cleanup.Release( );

			//	Error should be presented by the UndoManager for not
			//		being able to add the action to its list...
			}

		}
	else
		{
		;///xxx	TODO: Do processing Failed... Alert user and throw an error...
		}

	return fReturnValue;
	}
Esempio n. 10
0
// ****************************************************************************
//
//  Function Name:	RGroupSelectionAction::RGroupSelectionAction( )
//
//  Description:		Constructor
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
RGroupSelectionAction::RGroupSelectionAction( RCompositeSelection* pCurrentSelection )
	: RUndoableAction( m_ActionId, STRING_UNDO_GROUP_SELECTION, STRING_REDO_GROUP_SELECTION ),
	  m_pCurrentSelection( pCurrentSelection ),
	  m_OldSelection( *pCurrentSelection ),
	  m_OldZOrder( pCurrentSelection->GetView( )->GetZOrderState( ) )
	{
	// Validate parameters
	TpsAssertValid( pCurrentSelection );

	//	Search the m_OldSelection and remove any components that are not in the kNormalZLayer
	YSelectionIterator	iterator		= m_OldSelection.Start( );
	YSelectionIterator	iteratorEnd	= m_OldSelection.End( );
	for ( ; iterator != iteratorEnd; )
		{
		RComponentView*	pView	= (*iterator);
		if ( pView->GetComponentAttributes().GetZLayer() != kNormalZLayer )
			{
			m_OldSelection.Unselect( pView, FALSE );
			//	Something remove, so reset and start over
			iterator		= m_OldSelection.Start( );
			iteratorEnd	= m_OldSelection.End( );
			}
		else	//	Valid so advance
			++iterator;
		}

	// Sort the selection by z-order first
	m_OldSelection.SortByZOrder( );

	// Get the bounding rect of the selected objects
	m_GroupBoundingRect = RComponentCollection( m_OldSelection ).GetBoundingRect( );

	// Get the parent document
	m_pParentDocument = pCurrentSelection->GetView( )->GetRDocument( );

	// Create a new group component
	m_pGroupDocument = ::GetComponentManager( ).CreateNewComponent( kGroupComponent,
																						 m_pParentDocument,
																						 pCurrentSelection->GetView( ),
																						 RComponentAttributes::GetDefaultComponentAttributes( kGroupComponent ),
																						 m_GroupBoundingRect,
																						 FALSE );

	// If we couldnt create the component, throw a memory exception
	if( !m_pGroupDocument )
		::ThrowException( kMemory );
	}
Esempio n. 11
0
// ****************************************************************************
//
//  Function Name:	RBreakGroupAction::RBreakGroupAction( )
//
//  Description:		Constructor
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
RBreakGroupAction::RBreakGroupAction( RCompositeSelection* pCurrentSelection )
	: RUndoableAction( m_ActionId, STRING_UNDO_BREAKGROUP, STRING_REDO_BREAKGROUP ),
	  m_pCurrentSelection( pCurrentSelection ),
	  m_OldSelection( *pCurrentSelection )
	{
	// Validate parameters
	TpsAssertValid( pCurrentSelection );
	TpsAssert( m_pCurrentSelection->Count( ) == 1, "Break Group action only operates on one object." );
	TpsAssertIsObject( RComponentDocument, ( *m_pCurrentSelection->Start( ) )->GetRDocument( ) );

	m_pGroupDocument = static_cast<RComponentDocument*>( ( *m_pCurrentSelection->Start( ) )->GetRDocument( ) );
	TpsAssert( m_pGroupDocument->GetComponentType( ) == kGroupComponent, "Not a group." );

	// Get the parent document
	m_pParentDocument = pCurrentSelection->GetView( )->GetRDocument( );

	// Get the bounding rect of the group
	YSelectionBoundingRect boundingRect;
	pCurrentSelection->GetSelectionBoundingRect( boundingRect );
	m_GroupBoundingRect = boundingRect.m_TransformedBoundingRect;
	}
Esempio n. 12
0
// ****************************************************************************
//
//  Function Name:	RStandaloneDocument::OnRedo( )
//
//  Description:		Command handler
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RStandaloneDocument::OnRedo( )
	{
	TpsAssertValid( m_pUndoManager );
	m_pUndoManager->RedoAction( );
	}
Esempio n. 13
0
// ****************************************************************************
//
//  Function Name:	RGpDrawingSurface::BlitDrawingSurface( )
//
//  Description:		Copy from one the given drawing surface to this one
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
void RGpDrawingSurface::BlitDrawingSurface( const RDrawingSurface& rSrcDS, RIntRect rSrcRect, RIntRect rDestRect, EBlitMode eBlitMode )
{
    short			mode;
    Rect			srcRect, destRect;
    GrafPtr		pSrcGrafPort, pDestGrafPort;
    GrafPtr		savePort;
    RGBColor		whiteColor, blackColor, foreColor, backColor;

    TpsAssertValid( this );
    TpsAssertIsObject( RGpDrawingSurface, this );
    TpsAssertIsObject(RGpDrawingSurface, &rSrcDS);

    pSrcGrafPort = (GrafPtr)rSrcDS.GetSurface();
    pDestGrafPort = (GrafPtr)GetSurface();
    TpsAssert( ( pSrcGrafPort != NULL ), "Source device is nil.");
    TpsAssert( ( pDestGrafPort != NULL ), "Destination device is nil.");

    // Set the port to the dest port
    GetPort(&savePort);
    SetPort(pDestGrafPort);

    switch ( eBlitMode )
    {
    case kBlitSourceCopy :
        mode = srcCopy;
        break;
    case kBlitSourceAnd :
        mode = srcBic;
        break;
    case kBlitSourcePaint :
        mode = srcOr;
        break;
    case kBlitNotSourceAnd :
        mode = notSrcBic;
        break;
    case kBlitMergePaint :
        mode = notSrcOr;
        break;
    case kBlitSourceErase :
    default:
        TpsAssertAlways( "Invalid blit mode" );
        break;
    }
    ::SetRect( &srcRect, rSrcRect.m_Left, rSrcRect.m_Top, rSrcRect.m_Right, rSrcRect.m_Bottom );
    ::SetRect( &destRect, rDestRect.m_Left, rDestRect.m_Top, rDestRect.m_Right, rDestRect.m_Bottom );

    ::GetBackColor( &backColor );
    ::GetForeColor( &foreColor );
    whiteColor.red = 0xFFFF;
    whiteColor.green = 0xFFFF;
    whiteColor.blue = 0xFFFF;
    blackColor.red = 0x0000;
    blackColor.green = 0x0000;
    blackColor.blue = 0x0000;
    ::RGBForeColor( &blackColor );
    ::RGBBackColor( &whiteColor );

    ::CopyBits( &(pSrcGrafPort->portBits), &(pDestGrafPort->portBits), &srcRect, &destRect, mode, nil );

    ::RGBForeColor( &foreColor );
    ::RGBBackColor( &backColor );

    // Restore the saved port
    SetPort(savePort);
}