X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fbackgroundmgr.cpp;h=7c6ef63fdd87343ebde024af4129c1c655435bc5;hb=ad846952429412dd9b090cbb4500f179ca460b12;hp=6d4a50cafd2ff13479b45be2c7432ee1bab600a9;hpb=841cd96a9faa03494c7841877a7f008c019fed9e;p=ctsim.git diff --git a/src/backgroundmgr.cpp b/src/backgroundmgr.cpp index 6d4a50c..7c6ef63 100644 --- a/src/backgroundmgr.cpp +++ b/src/backgroundmgr.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2001 Kevin Rosenberg ** -** $Id: backgroundmgr.cpp,v 1.15 2001/03/09 21:31:51 kevin Exp $ +** $Id$ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -67,6 +67,7 @@ BackgroundManager::BackgroundManager () m_sizeCell.Set (m_sizeGauge.x + m_sizeLabel.x + m_sizeCellSpacing.x + m_sizeButton.x, 25); + theApp->getMainFrame()->SetFocus(); Show(false); } @@ -88,7 +89,7 @@ void BackgroundManager::OnUnitTick (wxCommandEvent& event) { int iUnits = event.GetInt(); - + BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); if (pSupervisor == NULL) { sys_error (ERR_SEVERE, "Received NULL task [BackgroundManager::OnUnitTick]"); @@ -97,8 +98,8 @@ BackgroundManager::OnUnitTick (wxCommandEvent& event) BackgroundManagerTask* pTask = lookupTask (pSupervisor); if (pTask == NULL) { - sys_error (ERR_SEVERE, "Error looking up task [BackgroundManager::OnUnitTick]"); - return; + sys_error (ERR_SEVERE, "Error looking up task [BackgroundManager::OnUnitTick]"); + return; } pTask->gauge()->SetValue (iUnits); } @@ -117,7 +118,7 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) wxCriticalSectionLocker locker (m_criticalSection); int iNumTasks = m_vecpTasks.size(); - std::vector vecPositionUsed (iNumTasks); //vector of used table positions + std::vector vecPositionUsed (iNumTasks); //vector of used table positions for (int iP = 0; iP < iNumTasks; iP++) vecPositionUsed[iP] = false; @@ -133,7 +134,7 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) 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); wxPoint posButton (m_sizeBorder.x + m_sizeGauge.x + m_sizeLabel.x, m_sizeBorder.y + iFirstUnusedPos * m_sizeCell.y); @@ -141,7 +142,7 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) wxStaticText* pLabel = new wxStaticText (m_pCanvas, -1, pszTaskName, posLabel, m_sizeLabel); wxButton* pButton = new wxButton (m_pCanvas, s_iNextButtonID, _T("Cancel"), posButton, m_sizeButton, wxBU_LEFT); - BackgroundManagerTask* pTask = new BackgroundManagerTask (pSupervisor, pszTaskName, + BackgroundManagerTask* pTask = new BackgroundManagerTask (pSupervisor, pszTaskName, iFirstUnusedPos, pGauge, pLabel, pButton, s_iNextButtonID); m_vecpTasks.push_back (pTask); @@ -150,9 +151,8 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) resizeWindow(); if (m_iNumTasks == 1) { - SetFocus(); - Show(true); - theApp->getMainFrame()->SetFocus(); // necessary to keep wxWindows from crashing + m_pCanvas->SetFocus(); + Show(true); } } @@ -170,24 +170,26 @@ BackgroundManager::OnRemoveTask (wxCommandEvent& event) bool bFound = false; for (TaskContainer::iterator iTask = m_vecpTasks.begin(); iTask != m_vecpTasks.end(); iTask++) { if ((*iTask)->supervisor() == pSupervisor) { - delete (*iTask)->gauge(); - delete (*iTask)->label(); - delete (*iTask)->button(); + delete (*iTask)->gauge(); + delete (*iTask)->label(); + delete (*iTask)->button(); delete *iTask; m_vecpTasks.erase (iTask); m_iNumTasks--; - bFound = true; + bFound = true; break; } } if (! bFound) { - sys_error (ERR_SEVERE, "Unable to find supervisor [BackgroundManager::OnRemoveTask]"); + sys_error (ERR_SEVERE, "Unable to find supervisor [BackgroundManager::OnRemoveTask]"); return; } pSupervisor->ackRemoveBackgroundManager(); resizeWindow(); - if (m_iNumTasks <= 0) + if (m_iNumTasks <= 0) { + m_pCanvas->SetFocus(); Show(false); + } } void