+ int iNumUnits = event.GetInt();
+ const char* const pszTaskName = event.GetString().c_str();
+ BackgroundSupervisor* pTask = reinterpret_cast<BackgroundSupervisor*>(event.GetClientData());
+ if (pTask == NULL) {
+ sys_error (ERR_SEVERE, "Received NULL task [BackgroundManager::OnAddTask]");
+ return;
+ }
+
+ wxCriticalSectionLocker locker (m_criticalSection);
+ int iNumTasks = m_vecpBackgroundTasks.size();
+ std::vector<bool> vecPositionUsed (iNumTasks);
+ int i;
+ for (i = 0; i < iNumTasks; i++)
+ vecPositionUsed[i] = false;
+
+ for (i = 0; i < iNumTasks; i++) {
+ int iPosUsed = m_vecpPositions[i];
+ if (iPosUsed < iNumTasks)
+ vecPositionUsed[iPosUsed] = true;
+ }
+
+ int iFirstUnusedPos = iNumTasks; // default is just past current number of tasks
+ for (i = 0; i < iNumTasks; i++)
+ if (! vecPositionUsed[i]) {
+ iFirstUnusedPos = i;
+ break;
+ }
+
+ wxPoint posGauge (m_sizeBorder.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y);
+ wxPoint posLabel (m_sizeBorder.x + m_sizeGauge.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y);
+ wxGauge* pGauge = new wxGauge (m_pCanvas, -1, iNumUnits, posGauge, m_sizeGauge);
+ wxStaticText* pLabel = new wxStaticText (m_pCanvas, -1, pszTaskName, posLabel, m_sizeLabel);
+ // wxPoint posButton (m_sizeBorder.x + m_sizeGauge.x + m_sizeLabel.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y);
+// wxButton* pCancelButton = new wxButton (m_pCanvas, iFirstUnusedPos, _T("Cancel"), posButton, m_sizeButton, wxBU_LEFT);