wxBitmap* CSimpleProjectPanel::GetProjectSpecificBitmap(char* project_url) {
	char defaultIcnPath[256];
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();

    wxASSERT(pSkinSimple);

	// Only update if it is project specific is found
	if(boinc_resolve_filename(GetProjectIconLoc(project_url).c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0) {
		wxBitmap* projectBM = new wxBitmap();
		if ( projectBM->LoadFile(wxString(defaultIcnPath,wxConvUTF8), wxBITMAP_TYPE_ANY) ) {
			return projectBM;
		}
	}
    return pSkinSimple->GetProjectImage()->GetBitmap();
}
Ejemplo n.º 2
0
wxBitmap* CSimpleProjectPanel::GetProjectSpecificBitmap(char* project_url) {
    char defaultIcnPath[256];
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();

    wxASSERT(pSkinSimple);

    // Only update it if project specific is found
    if(boinc_resolve_filename(GetProjectIconLoc(project_url).c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0) {
        wxBitmap* projectBM;
        wxString strIconPath = wxString(defaultIcnPath,wxConvUTF8);
        if (wxFile::Exists(strIconPath)) {
#ifdef __WXMSW__
            if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) {
                wxImage img = wxImage(strIconPath, wxBITMAP_TYPE_ANY);
                if (img.IsOk()) {
                    img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), 
                                (int) (img.GetHeight()*GetYDPIScaling()), 
                                wxIMAGE_QUALITY_BILINEAR
                            );
                    projectBM = new wxBitmap(img);
                    if (projectBM->IsOk()) {
                        return projectBM;
                    }
                }
            } else 
#endif
            {
                projectBM = new wxBitmap();
                if ( projectBM->LoadFile(strIconPath, wxBITMAP_TYPE_ANY) ) {
                    return projectBM;
                }
            }
        }
    }
    return pSkinSimple->GetProjectImage()->GetBitmap();
}
Ejemplo n.º 3
0
CSimpleProjectPanel::CSimpleProjectPanel( wxWindow* parent ) :
    CSimplePanelBase( parent )
{
    wxSize sz;
    wxString str = wxEmptyString;
    wxWindowDC dc(this);

    m_UsingAccountManager = -1; // Force action the first time
    m_CurrentSelectedProjectURL[0] = '\0';

    m_sAddProjectString = _("Add Project");
    m_sSynchronizeString = _("Synchronize");
    m_sTotalWorkDoneString = _("Work done for this project");
    
    m_sAddProjectToolTip = _("Volunteer for any or all of 30+ projects in many areas of science");
    m_sSynchronizeToolTip = _("Synchronize projects with account manager system");
    
    m_GotBGBitMap = false; // Can't be made until parent has been laid out.
    SetForegroundColour(*wxBLACK);
    
    wxBoxSizer* bSizer1;
    bSizer1 = new wxBoxSizer( wxVERTICAL );

    wxBoxSizer* bSizer2;
    bSizer2 = new wxBoxSizer( wxHORIZONTAL );
    
    bSizer1->AddSpacer(ADJUSTFORYDPI(5));
    m_myProjectsLabel = new CTransparentStaticText( this, wxID_ANY, _("Projects:"), wxDefaultPosition, wxDefaultSize, 0 );
    m_myProjectsLabel->Wrap( -1 );
    bSizer2->Add( m_myProjectsLabel, 0, wxRIGHT, ADJUSTFORXDPI(5) );
    bSizer2->AddStretchSpacer();

    int addProjectWidth, synchronizeWidth, y;
    GetTextExtent(m_sAddProjectString, &addProjectWidth, &y);
    GetTextExtent(m_sSynchronizeString, &synchronizeWidth, &y);
    m_TaskAddProjectButton = new CTransparentButton( this, ID_ADDROJECTBUTTON, 
        (addProjectWidth > synchronizeWidth) ? m_sAddProjectString : m_sSynchronizeString,
        wxDefaultPosition, wxDefaultSize, 0
    );
                            
    bSizer2->Add( m_TaskAddProjectButton, 0, wxRIGHT | wxEXPAND | wxALIGN_RIGHT, SIDEMARGINS );
    bSizer1->Add( bSizer2, 0, wxEXPAND | wxTOP | wxLEFT, ADJUSTFORXDPI(10) );

#ifndef __WXMAC__
    bSizer1->AddSpacer(ADJUSTFORYDPI(5));
#endif
    
#if TESTBIGICONPOPUP
    m_ProjectSelectionCtrl = new CBOINCBitmapComboBox( this, ID_SGPROJECTSELECTOR, wxT(""), wxDefaultPosition, wxSize(-1, 42), 4, tempArray, wxCB_READONLY ); 
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
    bmArray[0] = *pSkinSimple->GetProjectImage()->GetBitmap();
    m_ProjectSelectionCtrl->SetItemBitmap(0, bmArray[0]);
    bmArray[1] = wxBitmap((const char**)sah_40_xpm);
    m_ProjectSelectionCtrl->SetItemBitmap(1, bmArray[1]);
    bmArray[2] = wxBitmap((const char**)einstein_icon_xpm);
    m_ProjectSelectionCtrl->SetItemBitmap(3, bmArray[2]);
//    m_ProjectSelectionCtrl->SetStringSelection(tempArray[1]);
    m_ProjectSelectionCtrl->SetSelection(1);
#else
    m_ProjectSelectionCtrl = new CBOINCBitmapComboBox( this, ID_SGPROJECTSELECTOR, wxT(""), wxDefaultPosition, wxSize(-1, 42), 0, NULL, wxCB_READONLY); 
#endif
    // TODO: Might want better wording for Project Selection Combo Box tooltip
    str = _("Select a project to access with the controls below");
    m_ProjectSelectionCtrl->SetToolTip(str);
    bSizer1->Add( m_ProjectSelectionCtrl, 0, wxLEFT | wxRIGHT | wxEXPAND, SIDEMARGINS );

#ifndef __WXMAC__
    bSizer1->AddSpacer(ADJUSTFORYDPI(8));
#endif
    
    // Make sure m_TotalCreditValue string is large enough 
    m_fDisplayedCredit = 9999999999.99;
    str.Printf(wxT("%s: %.0f"), m_sTotalWorkDoneString.c_str(), m_fDisplayedCredit);
    m_TotalCreditValue = new CTransparentStaticText( this, wxID_ANY, str, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE );
    m_TotalCreditValue->Wrap( -1 );
    
    bSizer1->Add( m_TotalCreditValue, 0, wxLEFT | wxRIGHT | wxEXPAND, SIDEMARGINS );

    bSizer1->AddSpacer(ADJUSTFORYDPI(5));

    wxBoxSizer* bSizer3;
    bSizer3 = new wxBoxSizer( wxHORIZONTAL );

    m_ProjectWebSitesButton = new CSimpleProjectWebSitesPopupButton( this, ID_PROJECTWEBSITESBUTTON, _("Project Web Pages"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer3->Add( m_ProjectWebSitesButton, 0, wxEXPAND | wxALIGN_LEFT, 0 );
    bSizer3->AddStretchSpacer();

    m_ProjectCommandsButton = new CSimpleProjectCommandPopupButton( this, ID_PROJECTCOMMANDBUTTON, _("Project Commands"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer3->Add( m_ProjectCommandsButton, 0, wxEXPAND | wxALIGN_RIGHT, 0 );

    bSizer1->Add( bSizer3, 0, wxLEFT | wxRIGHT | wxEXPAND, SIDEMARGINS );
    
    bSizer1->AddSpacer(ADJUSTFORYDPI(10));

    // Temporarily insert a dummy entry so sizer can 
    // get correct height of m_ProjectSelectionCtrl
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
    wxBitmap* defaultBM = pSkinSimple->GetProjectImage()->GetBitmap();
    m_ProjectSelectionCtrl->Insert("", *defaultBM, 0, (void*)NULL);

    this->SetSizer( bSizer1 );
    this->Layout();
    
    // Remove the dummy entry
    m_ProjectSelectionCtrl->Delete(0);

    m_TaskAddProjectButton->SetToolTip(wxEmptyString);
    m_TaskAddProjectButton->Disable();
}