X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fbackgroundmgr.cpp;h=f40cc916340d55b9975ffbcc86fad45171da38af;hp=340d7d4c73b13163f0af1b257e49f08680f1cd52;hb=f13a8c004b8f182b42d9e4df2bcd7c7f030bf1ad;hpb=8a7697ce57b56cdc43698cd1241ad98d49f9b5ac diff --git a/src/backgroundmgr.cpp b/src/backgroundmgr.cpp index 340d7d4..f40cc91 100644 --- a/src/backgroundmgr.cpp +++ b/src/backgroundmgr.cpp @@ -7,9 +7,7 @@ ** Date Started: February 2001 ** ** This is part of the CTSim program -** Copyright (C) 1983-2001 Kevin Rosenberg -** -** $Id$ +** Copyright (C) 1983-2009 Kevin Rosenberg ** ** 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 @@ -89,7 +87,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]"); @@ -98,8 +96,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); } @@ -108,7 +106,7 @@ void BackgroundManager::OnAddTask (wxCommandEvent& event) { int iNumUnits = event.GetInt(); - const char* const pszTaskName = event.GetString().c_str(); + const char* const pszTaskName = event.GetString().mb_str(wxConvUTF8); BackgroundSupervisor* pSupervisor = reinterpret_cast(event.GetClientData()); if (pSupervisor == NULL) { sys_error (ERR_SEVERE, "Received NULL supervisor [BackgroundManager::OnAddTask]"); @@ -118,7 +116,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; @@ -134,15 +132,15 @@ 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); wxGauge* pGauge = new wxGauge (m_pCanvas, -1, iNumUnits, posGauge, m_sizeGauge); - wxStaticText* pLabel = new wxStaticText (m_pCanvas, -1, pszTaskName, posLabel, m_sizeLabel); + wxStaticText* pLabel = new wxStaticText (m_pCanvas, -1, wxConvUTF8.cMB2WX(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); @@ -152,7 +150,7 @@ BackgroundManager::OnAddTask (wxCommandEvent& event) resizeWindow(); if (m_iNumTasks == 1) { m_pCanvas->SetFocus(); - Show(true); + Show(true); } } @@ -170,18 +168,18 @@ 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();