Esempio n. 1
0
void CSlideShowPanel::AdvanceSlideShow(bool changeSlide, bool reload) {
    double xRatio, yRatio, ratio;
    unsigned int i;
    wxString s;
    TaskSelectionData* selData = ((CSimpleTaskPanel*)GetParent())->GetTaskSelectionData();
    if (selData == NULL) return;

    if (reload) {
        m_bCurrentSlideIsDefault = false;
        selData->lastSlideShown = -1;
    }

    int numSlides = (int)selData->slideShowFileNames.size();
#if TESTALLDESCRIPTIONS // For testing
numSlides = 0;
#endif
    if (numSlides <= 0) {
#if HIDEDEFAULTSLIDE
        if (!reload) {
            return;
        }
        wxRect r = GetRect();
        wxBitmap backgroundBitmap = ((CSimpleTaskPanel*)GetParent())->GetBackgroundBmp().GetSubBitmap(r);
        wxWindowDC dc(this);
        dc.DrawBitmap(backgroundBitmap, 0, 0);

        // Force redraws if text unchanged; hide all if not in all-projects list
        m_institution->Show(false);
        m_scienceArea->Show(false);
        m_description->Show(false);
        Enable( false );
        
        if (!m_bGotAllProjectsList) {
            CMainDocument* pDoc = wxGetApp().GetDocument();
            wxASSERT(pDoc);

            pDoc->rpc.get_all_projects_list(m_AllProjectsList);
            m_bGotAllProjectsList = true;
        }
        
        for (i=0; i<m_AllProjectsList.projects.size(); i++) {
            if (!strcmp(m_AllProjectsList.projects[i]->url.c_str(), selData->project_url)) {
                s = wxString(m_AllProjectsList.projects[i]->home.c_str(), wxConvUTF8);
                m_institution->SetLabel(wxGetTranslation(s));
                s = wxString(m_AllProjectsList.projects[i]->specific_area.c_str(), wxConvUTF8);
                m_scienceArea->SetLabel(wxGetTranslation(s));
                s = wxString(m_AllProjectsList.projects[i]->description.c_str(), wxConvUTF8);
                m_description->SetValue(wxGetTranslation(s));

                m_institution->Show(true);
                m_scienceArea->Show(true);
                m_description->Show(true);
                Enable( true );
                m_description->Enable();
                this->Layout();
                break;
            }
        }
        return;
#else   // HIDEDEFAULTSLIDE
        SetBackgroundColour(*wxBLACK);

        if (m_bCurrentSlideIsDefault) return;
        
        CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
        wxASSERT(pSkinSimple);
        wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));

        m_SlideBitmap = *pSkinSimple->GetWorkunitAnimationImage()->GetBitmap();
        if (m_SlideBitmap.Ok()) {
            m_bCurrentSlideIsDefault = true;
        }
#endif  // HIDEDEFAULTSLIDE
    } else {
#if HIDEDEFAULTSLIDE
        m_institution->Show(false);
        m_scienceArea->Show(false);
        m_description->Show(false);
        Enable( false );

#endif  // HIDEDEFAULTSLIDE
        // TODO: Should we allow slide show to advance if task is not running?
        int newSlide = selData->lastSlideShown;
        
        if (selData->dotColor == runningIcon) {    // Advance only if running
            if (changeSlide) {
                if (++newSlide >= numSlides) {
                    newSlide = 0;
                }
            }
        }
        if (newSlide < 0) {
            newSlide = 0;
        }
        
        if (selData->lastSlideShown != newSlide) {  // Don't update if only one slide
        
            selData->lastSlideShown = newSlide;

            wxBitmap *bm = new wxBitmap();
            bm->LoadFile(selData->slideShowFileNames[newSlide], wxBITMAP_TYPE_ANY);
            if (bm->Ok()) {
                m_SlideBitmap = *bm;
                delete bm;
                m_bCurrentSlideIsDefault = false;
            }
        }
    }
    if (m_SlideBitmap.Ok()) {
        // Check to see if they need to be rescaled to fit in the window
        ratio = 1.0;
        xRatio = ((double) GetSize().GetWidth() - (2*SLIDESHOWBORDER))/((double) m_SlideBitmap.GetWidth());
        yRatio = ((double) GetSize().GetHeight() - (2*SLIDESHOWBORDER))/((double) m_SlideBitmap.GetHeight());
        if ( xRatio < ratio ) {
            ratio = xRatio;
        }
        if ( yRatio < ratio ) {
            ratio = yRatio;
        }
        if ( ratio < 1.0 ) {
            wxImage img = m_SlideBitmap.ConvertToImage();
            img.Rescale((int) (m_SlideBitmap.GetWidth()*ratio), (int) (m_SlideBitmap.GetHeight()*ratio));
            wxBitmap *bm = new wxBitmap(img);
            m_SlideBitmap = *bm;
            delete bm;
        }
        Refresh();
    }
}
Esempio n. 2
0
void CSlideShowPanel::AdvanceSlideShow(bool changeSlide, bool reload) {
    double xRatio, yRatio, ratio;
    TaskSelectionData* selData = ((CSimpleTaskPanel*)GetParent())->GetTaskSelectionData();
    if (selData == NULL) return;

    if (reload) {
        m_bCurrentSlideIsDefault = false;
        selData->lastSlideShown = -1;
    }

    int numSlides = (int)selData->slideShowFileNames.size();
#if TESTALLDESCRIPTIONS // For testing
numSlides = 0;
#endif
    if (numSlides <= 0) {
#if HIDEDEFAULTSLIDE
        if (!reload) {
            return;
        }
        wxRect r = GetRect();
        wxBitmap backgroundBitmap = ((CSimpleTaskPanel*)GetParent())->GetBackgroundBmp().GetSubBitmap(r);
        wxWindowDC dc(this);
        dc.DrawBitmap(backgroundBitmap, 0, 0);

        // Force redraws if text unchanged; hide all if not in all-projects list
        m_description->Show(false);
        Enable( false );
        
        if (!m_bGotAllProjectsList) {
            CMainDocument* pDoc = wxGetApp().GetDocument();
            wxASSERT(pDoc);

            pDoc->rpc.get_all_projects_list(m_AllProjectsList);
            m_bGotAllProjectsList = true;
        }
        
        SetDescriptionText();

        return;
#else   // HIDEDEFAULTSLIDE
        SetBackgroundColour(*wxBLACK);

        if (m_bCurrentSlideIsDefault) return;
        
        CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();
        wxASSERT(pSkinSimple);
        wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));

        m_SlideBitmap = *pSkinSimple->GetWorkunitAnimationImage()->GetBitmap();
        if (m_SlideBitmap.Ok()) {
            m_bCurrentSlideIsDefault = true;
        }
#endif  // HIDEDEFAULTSLIDE
    } else {
#if HIDEDEFAULTSLIDE
        m_description->Show(false);
        Enable( false );

#endif  // HIDEDEFAULTSLIDE
        // TODO: Should we allow slide show to advance if task is not running?
        int newSlide = selData->lastSlideShown;
        
        if (selData->dotColor == runningIcon) {    // Advance only if running
            if (changeSlide) {
                if (++newSlide >= numSlides) {
                    newSlide = 0;
                }
            }
        }
        if (newSlide < 0) {
            newSlide = 0;
        }
        
        if (selData->lastSlideShown != newSlide) {  // Don't update if only one slide
        
            selData->lastSlideShown = newSlide;

            wxBitmap *bm = new wxBitmap();
            bm->LoadFile(selData->slideShowFileNames[newSlide], wxBITMAP_TYPE_ANY);
            if (bm->Ok()) {
                m_SlideBitmap = *bm;
                delete bm;
                m_bCurrentSlideIsDefault = false;
            }
        }
    }
    if (m_SlideBitmap.Ok()) {
        // Check to see if they need to be rescaled to fit in the window
        ratio = 1.0;
        xRatio = (double)SLIDESHOWWIDTH / (double)m_SlideBitmap.GetWidth();
        yRatio = (double)SLIDESHOWHEIGHT / (double)m_SlideBitmap.GetHeight();
        ratio = xRatio;
        if ( yRatio < ratio ) {
            ratio = yRatio;
        }
        if ( (ratio < 0.95) || (ratio > 1.05) ) {
            wxImage img = m_SlideBitmap.ConvertToImage();
            img.Rescale((int) (m_SlideBitmap.GetWidth()*ratio), 
						(int) (m_SlideBitmap.GetHeight()*ratio), 
						(ratio > 1.0) ? wxIMAGE_QUALITY_BILINEAR : wxIMAGE_QUALITY_BOX_AVERAGE
					);
            wxBitmap *bm = new wxBitmap(img);
            m_SlideBitmap = *bm;
            delete bm;
        }

        Refresh();
    }
}