#include #include #include #include #include "resource.h" #include "common.h" #include "datalistview.h" #include "episodelistview.h" #include "listview.h" #include "main.h" #include "pl.h" DataListView::DataListView(const HWND hWndParent) : ListView(hWndParent, (HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEADER) { LVCOLUMN lvc; lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM; lvc.iSubItem = DLVSIKEY; lvc.pszText = (TCHAR*)TEXT("Key"); lvc.cx = Dpi(42); ListView_InsertColumn(hWnd, DLVSIKEY, &lvc); lvc.iSubItem = DLVSIVALUE; lvc.pszText = (TCHAR*)TEXT("Value"); lvc.cx = 500; ListView_InsertColumn(hWnd, DLVSIVALUE, &lvc); } void DataListView::ResizeColumns() { RECT rc; require(GetClientRect(hWnd, &rc)); ListView_SetColumnWidth(hWnd, DLVSIKEY, LVSCW_AUTOSIZE); const int cxColumn = ListView_GetColumnWidth(hWnd, 0)+4; ListView_SetColumnWidth(hWnd, DLVSIKEY, cxColumn); ListView_SetColumnWidth(hWnd, DLVSIVALUE, rc.right-cxColumn); } void DataListView::ShowEpisode(const int iEpisode) { extern EpisodeListView* const g_pElv; ListView_DeleteAllItems(hWnd); LVITEM lviKey, lviValue; lviKey.mask = LVIF_TEXT; lviValue.mask = LVIF_TEXT; Frame f; const term_t t = PL_new_term_refs(3); if (!PL_put_integer(t,iEpisode)) return; const qid_t q = PL_open_query(NULL, PL_Q_NORMAL, PL_predicate("episode_datum", 3, "episode_data"), t); for (int i = 0; PL_next_solution(q); i++) { std::basic_string tstrKey; std::basic_string tstrValue; if (!(PlGet(t+1, &tstrKey) && PlGet(t+2, &tstrValue))) continue; lviKey.mask = LVIF_TEXT; lviKey.iItem = i; lviKey.iSubItem = 0; lviKey.pszText = tstrKey.data(); ListView_InsertItem(hWnd, &lviKey); lviValue.iItem = i; lviValue.iSubItem = 1; lviValue.pszText = tstrValue.data(); ListView_SetItem(hWnd, &lviValue); } PL_cut_query(q); UpdateLayout(); LVFINDINFO lvfi; lvfi.flags = LVFI_PARAM; lvfi.lParam = iEpisode; int iItem = ListView_FindItem(g_pElv->hWnd, -1, &lvfi); if (iItem != -1) ListView_EnsureVisible(g_pElv->hWnd, iItem, TRUE); }