void CSimpleTaskPanel::UpdatePanel(bool delayShow) { wxString s = wxEmptyString; wxString projName = wxEmptyString; TaskSelectionData *selData; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); int workCount = pDoc->GetSimpleGUIWorkCount(); // Workaround for Linux refresh problem static bool wasDelayed = false; #ifndef __WXMAC__ Freeze(); #endif if ((workCount <= 0) || delayShow) { if ((workCount != m_oldWorkCount) || delayShow) { wasDelayed = true; m_myTasksLabel->Hide(); m_TaskSelectionCtrl->Hide(); m_TaskProjectLabel->Hide(); m_TaskProjectName->Hide(); #if SELECTBYRESULTNAME m_TaskApplicationName->Hide(); #endif // SELECTBYRESULTNAME m_SlideShowArea->Hide(); m_ElapsedTimeValue->Hide(); m_TimeRemainingValue->Hide(); if (m_iPctDoneX10 >= 0) { m_iPctDoneX10 = -1; m_ProgressBar->Hide(); } m_ProgressValueText->Hide(); m_TaskCommandsButton->Hide(); this->Layout(); #ifdef __WXMAC__ m_ProgressRect = m_ProgressBar->GetRect(); m_ProgressRect.Inflate(0, -2); m_ProgressRect.Offset(0, -2); #endif } DisplayIdleState(); } else { if ((m_oldWorkCount == 0) || wasDelayed) { wasDelayed = false; m_myTasksLabel->Show(); m_TaskSelectionCtrl->Show(); m_TaskProjectLabel->Show(); m_TaskProjectName->Show(); #if SELECTBYRESULTNAME m_TaskApplicationName->Show(); #endif // SELECTBYRESULTNAME m_SlideShowArea->Show(); m_ElapsedTimeValue->Show(); m_TimeRemainingValue->Show(); m_ProgressBar->Show(); m_ProgressValueText->Show(); m_TaskCommandsButton->Show(); this->Layout(); #ifdef __WXMAC__ m_ProgressRect = m_ProgressBar->GetRect(); m_ProgressRect.Inflate(0, -2); m_ProgressRect.Offset(0, -2); #endif } UpdateTaskSelectionList(false); // We now have valid result pointers, so extract our data int count = m_TaskSelectionCtrl->GetCount(); if (count <= 0) { m_CurrentTaskSelection = -1; } else { if ((m_CurrentTaskSelection < 0) || (m_CurrentTaskSelection > count -1)) { m_TaskSelectionCtrl->SetSelection(0); m_CurrentTaskSelection = 0; m_bStableTaskInfoChanged = true; } selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(m_CurrentTaskSelection); RESULT* result = selData->result; if (result) { if (m_bStableTaskInfoChanged) { #if SELECTBYRESULTNAME wxString str = wxEmptyString; GetApplicationAndProjectNames(result, &s, &projName); str.Printf(_("Application: %s"), s.c_str()); UpdateStaticText(&m_TaskApplicationName, str); UpdateStaticText(&m_TaskProjectName, projName); #else // SELECTBYRESULTNAME GetApplicationAndProjectNames(result, NULL, &projName); #endif // SELECTBYRESULTNAME UpdateStaticText(&m_TaskProjectName, projName); m_SlideShowArea->AdvanceSlideShow(false, true); m_bStableTaskInfoChanged = false; } float f = result->elapsed_time; if (f == 0.) f = result->current_cpu_time; // f = result->final_elapsed_time; UpdateStaticText(&m_ElapsedTimeValue, GetElapsedTimeString(f)); UpdateStaticText(&m_TimeRemainingValue, GetTimeRemainingString(result->estimated_cpu_time_remaining)); int pctDoneX10 = result->fraction_done * 1000.0; if (m_iPctDoneX10 != pctDoneX10) { int pctDone = pctDoneX10 / 10; if (m_iPctDoneX10 != (pctDone * 10)) { m_ProgressBar->SetValue(pctDone); } s.Printf(_("%.3f%%"), result->fraction_done*100); m_iPctDoneX10 = pctDoneX10; UpdateStaticText(&m_ProgressValueText, s); } UpdateStaticText(&m_StatusValueText, GetStatusString(result)); } else { UpdateStaticText(&m_TaskProjectName, m_sNotAvailableString); #if SELECTBYRESULTNAME UpdateStaticText(&m_TaskApplicationName, _("Application: Not available") ); #endif // SELECTBYRESULTNAME UpdateStaticText(&m_ElapsedTimeValue, GetElapsedTimeString(-1.0)); UpdateStaticText(&m_TimeRemainingValue, GetTimeRemainingString(-1.0)); if (m_iPctDoneX10 >= 0) { m_iPctDoneX10 = -1; m_ProgressBar->Hide(); } UpdateStaticText(&m_ProgressValueText, wxEmptyString); UpdateStaticText(&m_StatusValueText, GetStatusString(NULL)); } } } m_oldWorkCount = workCount; #ifndef __WXMAC__ Thaw(); #endif }
// called from CSimpleFrame::OnRefreshView() void CSimpleGUIPanel::OnFrameRender() { CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); int workCount = pDoc->GetSimpleGUIWorkCount(); CC_STATUS status; bool isSuspended; // OnFrameRender() may be called while SimpleGUI initialization is // in progress due to completion of a periodic get_messages RPC, // causing unintended recursion in CMainDocument::RequestRPC(). // Check for that situation here. if (pDoc->WaitingForRPC()) return; // Workaround for Linux refresh problem if (m_irefreshCount < REFRESH_WAIT) { ++m_irefreshCount; m_taskPanel->UpdatePanel(true); return; } if (workCount != m_oldWorkCount) { if (workCount < 0) { m_projPanel->Hide(); } else if (m_oldWorkCount == 0) { m_projPanel->Show(); } this->Layout(); ReskinInterface(); } if (IsShown()) { if ( pDoc->IsConnected() ) { // Show Resume or Suspend as appropriate pDoc->GetCoreClientStatus(status); isSuspended = (RUN_MODE_NEVER == status.task_mode); if ((isSuspended != m_bIsSuspended) || (!m_SuspendResumeButton->IsEnabled())) { m_bIsSuspended = isSuspended; m_SuspendResumeButton->SetLabel(m_bIsSuspended ? m_sResumeString : m_sSuspendString); m_SuspendResumeButton->SetToolTip(m_bIsSuspended ? m_sResumeButtonToolTip : m_sSuspendButtonToolTip); } m_SuspendResumeButton->Enable(); } else { m_SuspendResumeButton->SetToolTip(wxEmptyString); m_SuspendResumeButton->Disable(); } UpdateProjectView(); if (m_bNewNoticeAlert) { wxRect r = m_NoticesButton->GetRect(); r.Inflate(4, 4); RefreshRect(r, m_bNoticesButtonIsRed); m_bNoticesButtonIsRed = !m_bNoticesButtonIsRed; } // State changes can cause the BSG to crash if a dialogue is open. // Defer state change until after the dialogue is closed if ( dlgOpen ) { return; } m_oldWorkCount = workCount; m_taskPanel->UpdatePanel(false); } }