#include "GameListManager.hpp" GameListManager::GameListManager(wxListCtrl *game_list): game_list(game_list), game_counter(0) { game_list->InsertColumn(0, L"Id", wxLIST_FORMAT_LEFT, 50); game_list->InsertColumn(1, L"White", wxLIST_FORMAT_LEFT, 200); game_list->InsertColumn(2, L"Black", wxLIST_FORMAT_LEFT, 200); game_list->InsertColumn(3, L"Event", wxLIST_FORMAT_LEFT, 150); game_list->InsertColumn(4, L"Round", wxLIST_FORMAT_LEFT, 100); game_list->InsertColumn(5, L"Result", wxLIST_FORMAT_LEFT, 200); game_list->InsertColumn(6, L"ECO", wxLIST_FORMAT_LEFT, 200); } void GameListManager::AddGame(CType White,CType Black,CType Event,CType Round, CType Result, CType Eco){ // Update rows elements rows.push_back({White,Black,Event,Round,Result,Eco}); // Display the row DisplayRow(game_counter); game_counter++; } void GameListManager::DisplayRow(long id){ RType row=rows[id]; long index = game_list->InsertItem(game_counter, std::to_string(id)); // want this for col. 1 game_list->SetItem(index, 1, row.White); game_list->SetItem(index, 2, row.Black); game_list->SetItem(index, 3, row.Event); game_list->SetItem(index, 4, row.Round); game_list->SetItem(index, 5, row.Result); game_list->SetItem(index, 6, row.Eco); } void GameListManager::Clear(){ game_list->DeleteAllItems(); rows.clear(); } void GameListManager::ClearDisplayedRow(){ game_list->DeleteAllItems(); } void GameListManager::MarkItemAsOpen(long item){ game_list->SetItemBackgroundColour(item, *wxGREEN); } void GameListManager::MarkItemAsDeleted(long item){ game_list->SetItemBackgroundColour(item, *wxRED); } std::vector GameListManager::GetSelectedItems(){ std::vector items; long selected = -1; while ((selected = game_list->GetNextItem(selected, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != wxNOT_FOUND) { items.push_back(selected); } return(items); } long GameListManager::GetItemGameId(long item){ wxListItem listItem; listItem.m_itemId = item; // sets row listItem.m_col = 0; // sets column to Id (column 0) game_list->GetItem(listItem); // gets item return std::stol(listItem.GetText().ToStdString()); }