예제 #1
0
bool ProjectViewModel::GetAttr( const wxDataViewItem& item, unsigned int column, wxDataViewItemAttr& attr ) const
{
    if ( !item.IsOk() )
    {
        return false;
    }

    ProjectViewModelNode *node = static_cast< ProjectViewModelNode* >( item.GetID() );
    HELIUM_ASSERT( node );

    // bold the entry if the node is active
    attr.SetBold( node->m_IsActive );

    // italicize the entry if it is modified
    attr.SetItalic( ( node->GetDocument() && node->GetDocument()->HasChanged() ) );

    Path nodePath = node->GetPath().GetAbsolutePath( m_Project->a_Path.Get() );
    if ( !nodePath.Exists() )
    {
        attr.SetColour( *wxRED );
    }
    else
    {
        attr.SetColour( *wxBLACK );
    }

    return true;
}
예제 #2
0
void ProjectPanel::OnActivateItem( wxDataViewEvent& event )
{
    ProjectViewModelNode *node = static_cast< ProjectViewModelNode* >( event.GetItem().GetID() );
    if ( !node )
    {
        return;
    }

    const FilePath& path = node->GetPath().GetAbsolutePath( m_Project->a_Path.Get() );
    HELIUM_ASSERT( !path.empty() );

    if ( !path.Exists() )
    {
#pragma TODO( "Walk the user through locating the missing file." )
        wxMessageBox( wxT( "Unfortunately, the file you're trying to load does not exist.  In the future, we'll help you find and fix this reference.  For now, all we can do is apologize." ), wxT( "Nonexistent File" ), wxOK | wxICON_ERROR );
        return;
    }

    if ( path.HasExtension( TXT( "HeliumScene" ) ) )
    {
        wxGetApp().GetFrame()->CloseAllScenes();
        wxGetApp().GetFrame()->OpenScene( path );
        return;
    }

    // we've gotten to an item we don't know how to activate yet
    HELIUM_BREAK();
}
예제 #3
0
void ProjectViewModel::RemoveItem( const wxDataViewItem& item )
{
    ProjectViewModelNode *node = static_cast< ProjectViewModelNode* >( item.GetID() );
    if ( !node )
    {
        return;
    }

    // remove all of childNode's children
    while( node->GetChildren().size() > 0 )
    {
        RemoveItem( wxDataViewItem( (void*)( *node->GetChildren().begin() ) ) );
    }

    // remove it from the multimap
    for ( MM_ProjectViewModelNodesByPath::iterator lower = m_MM_ProjectViewModelNodesByPath.lower_bound( node->GetPath() ),
        upper = m_MM_ProjectViewModelNodesByPath.upper_bound( node->GetPath() );
        lower != upper && lower != m_MM_ProjectViewModelNodesByPath.end();
    ++lower )
    {
        if ( lower->second == node )
        {
            m_MM_ProjectViewModelNodesByPath.erase( lower );
            break;
        }
    }

    if ( node == m_RootNode )
    {
        return;
    }

    // Remove from the parent's childern
    // this should free the node if there are no more references to it
    ProjectViewModelNode *parentNode = node->GetParent();
    if ( parentNode )
    {
        parentNode->GetChildren().erase( node );
    }

    if ( parentNode == m_RootNode.Ptr() )
    {
        parentNode = NULL;
    }

    ItemDeleted( wxDataViewItem( (void*) parentNode ), item );
}
예제 #4
0
void ProjectViewModel::GetValue( wxVariant& variant, const wxDataViewItem& item, unsigned int column ) const
{
    if ( !item.IsOk()
        || ( column < 0 )
        || ( column >= m_ColumnLookupTable.size() ) )
    {
        return;
    }

    ProjectViewModelNode *node = static_cast< ProjectViewModelNode* >( item.GetID() );
    if ( !node )
    {
        return;
    }

    switch( m_ColumnLookupTable.at( column ) )
    {
    default:
        break;

    case ProjectModelColumns::Name:
        {            
            uint32_t docStatus = node->GetDocumentStatus();

            wxString name = node->GetName();
            if ( HasFlags<uint32_t>( docStatus, DocumentStatus::Changed ) )
            {
                name = wxString( TXT( '*' ) ) + name; 
            }

            wxBitmap bitmap = wxArtProvider::GetBitmap( GetArtIDFromPath( node->GetPath() ), wxART_OTHER, wxSize(16, 16) );
            if ( docStatus > 0 )
            {
                wxImage image = bitmap.ConvertToImage();
                HELIUM_ASSERT( image.Ok() );

                int overlayWidth = image.GetWidth() / 2;
                int overlayHeight = image.GetHeight() / 2;

                wxImage overlayImage;

                if ( HasFlags<uint32_t>( docStatus, DocumentStatus::Saving ) )
                {
                    overlayImage = wxArtProvider::GetBitmap( ArtIDs::Status::Busy, wxART_OTHER, wxSize( overlayWidth, overlayHeight ) ).ConvertToImage();
                    HELIUM_ASSERT( overlayImage.Ok() );
                }
                else if ( HasFlags<uint32_t>( docStatus, DocumentStatus::Loading ) )
                {
                    overlayImage = wxArtProvider::GetBitmap( ArtIDs::Status::Busy, wxART_OTHER, wxSize( overlayWidth, overlayHeight ) ).ConvertToImage();
                    HELIUM_ASSERT( overlayImage.Ok() );
                }
                else if ( HasFlags<uint32_t>( docStatus, DocumentStatus::Changed ) )
                {
                    overlayImage = wxArtProvider::GetBitmap( ArtIDs::Actions::Edit, wxART_OTHER, wxSize( overlayWidth, overlayHeight ) ).ConvertToImage();
                    HELIUM_ASSERT( overlayImage.Ok() );
                }

                if ( overlayImage.Ok() )
                {
                    if ( overlayImage.GetWidth() != overlayWidth || overlayImage.GetHeight() != overlayHeight )
                    {
                        overlayImage.Rescale( overlayWidth, overlayHeight );
                    }

                    int x = 0;
                    int y = 0;
                    IconArtFile::CalculatePlacement( image, overlayImage, OverlayQuadrants::BottomRight, x, y );
                    image.Paste( overlayImage, x, y, wxIMAGE_ALPHA_BLEND_COMPOSITE );
                }

                bitmap = wxBitmap( image );
            }

            wxIcon icon;
            icon.CopyFromBitmap( bitmap );

            variant << wxDataViewIconText( name, icon );

        }
        break;

    //case ProjectModelColumns::Icon:
    //    {
    //        int32_t imageID = GlobalFileIconsTable().GetIconIDFromPath( node->GetPath() );
    //        wxVariant bitmapVariant;
    //        bitmapVariant.
    //        variant = GlobalFileIconsTable().GetSmallImageList()->GetBitmap( imageID );
    //    }
    //    break;

    case ProjectModelColumns::Details:
        {
            variant = node->GetDetails();
        }
        break;

    case ProjectModelColumns::FileSize:
        {
            variant = node->GetFileSize();
        }
        break;
    }
}