Exemplo n.º 1
0
void Tweaks::OnFileViewBuildTree(clCommandEvent& e)
{
    TWEAKS_ENABLED_EVENT_HANDLER();
    m_project2Icon.clear();
    if ( m_settings.GetProjects().empty() ) {
        e.Skip();
        return;
    }
    
    // See if we got a new image for a project
    wxImageList *images = new wxImageList(16, 16);
    wxImageList *old_images = m_mgr->GetTree(TreeFileView)->GetImageList();
    
    // Copy the old images to the new one
    for(int i=0; i<old_images->GetImageCount(); ++i) {
        images->Add( old_images->GetIcon(i) );
    }
    
    ProjectTweaks::Map_t::const_iterator iter = m_settings.GetProjects().begin();
    for(; iter != m_settings.GetProjects().end(); ++iter ) {
        wxString bmpfile = iter->second.GetBitmapFilename();
        bmpfile.Trim().Trim(false);
        if ( bmpfile.IsEmpty() ) {
            continue;
        }
        wxBitmap bmp(bmpfile, wxBITMAP_TYPE_ANY);
        if ( bmp.IsOk() ) {
            wxIcon icn;
            icn.CopyFromBitmap( bmp );
            int index = images->Add( icn );
            m_project2Icon.insert( std::make_pair(iter->first, index) );
        }
    }
    
    if ( m_project2Icon.empty() ) {
        e.Skip();
        wxDELETE(images);
        
    } else {
        // send back the new image list
        e.SetClientData( images );
    }
}