diff options
author | John Ankarström <john@ankarstrom.se> | 2022-02-15 17:17:50 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-02-15 17:17:50 +0100 |
commit | c1eee2b46cd5643ba8efb98b2cd598ef47c4daf6 (patch) | |
tree | cd23129ac6476d5be4814687248e3e71c0d959c9 /c | |
parent | c605ea0545ac22dc328c83d78011e3d18346eb63 (diff) | |
download | EpisodeBrowser-c1eee2b46cd5643ba8efb98b2cd598ef47c4daf6.tar.gz |
Show data in data list view.
Diffstat (limited to 'c')
-rw-r--r-- | c/common.c | 2 | ||||
-rw-r--r-- | c/datalistview.c | 35 | ||||
-rw-r--r-- | c/defs.h | 2 | ||||
-rw-r--r-- | c/episodelistview.c | 4 | ||||
-rw-r--r-- | c/main.c | 7 |
5 files changed, 40 insertions, 10 deletions
@@ -6,7 +6,7 @@ /* Convert zero-terminated non-wide (multi-byte) string to * zero-terminated wide/non-wide string depending on UNICODE. */ TCHAR * -TSZFromSZ(char *sz, int iCp) +TSZFromSZ(const char *sz, int iCp) { TCHAR *tsz; diff --git a/c/datalistview.c b/c/datalistview.c index 873befc..4a0208d 100644 --- a/c/datalistview.c +++ b/c/datalistview.c @@ -34,9 +34,17 @@ DlvCreate(HWND hWnd) void DlvShowEpisode(int iEpisode) { + HWND hListView; int r; + LVITEM lviKey, lviValue; term_t t; + hListView = GetDlgItem(gDlv_hWnd, IDC_DATALISTVIEW); + ListView_DeleteAllItems(hListView); + + lviKey.mask = LVIF_TEXT; + lviValue.mask = LVIF_TEXT; + t = PL_new_term_refs(3); if(!PL_put_integer(t+0, iEpisode)) return; @@ -56,23 +64,46 @@ DlvShowEpisode(int iEpisode) tHead = PL_new_term_ref(); tList = PL_copy_term_ref(t+2); - while (PL_get_list(tList, tHead, tList)) { + for (int i = 0; PL_get_list(tList, tHead, tList); i++) { atom_t aKey; const char *szKey; char *szValue; + TCHAR *tszKey, *tszValue; term_t tValue; size_t iArity; if (!PL_get_name_arity(tHead, &aKey, &iArity)) continue; szKey = PL_atom_chars(aKey); + if (!szKey) + continue; if (!PL_get_arg(1, tHead, tValue)) continue; if (!PL_get_atom_chars(tValue, &szValue)) continue; - //printf("%s/%d: %s\n", szKey, iArity, szValue); + tszKey = TSZFromSZ(szKey, CP_UTF8); + if (!tszKey) + continue; + tszValue = TSZFromSZ(szValue, CP_UTF8); + if (!tszValue) + continue; + + lviKey.mask = LVIF_TEXT; + lviKey.iItem = i; + lviKey.iSubItem = 0; + lviKey.pszText = tszKey; + lviKey.lParam = iEpisode; + ListView_InsertItem(hListView, &lviKey); + + lviValue.iItem = i; + lviValue.iSubItem = 1; + lviValue.pszText = tszValue; + ListView_SetItem(hListView, &lviValue); + + free(tszKey); + free(tszValue); } } } @@ -5,7 +5,7 @@ #include <commctrl.h> /* common.c */ -TCHAR *TSZFromSZ(char *, int); +TCHAR *TSZFromSZ(const char *, int); int Watched(int); /* main.c */ diff --git a/c/episodelistview.c b/c/episodelistview.c index ab54f81..0b9e855 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -51,7 +51,7 @@ ElvHandleNotify(LPARAM lParam) && (pNmLv->uNewState & LVIS_FOCUSED)) { g_SelectedItem = pNmLv->iItem; ElvUpdateName(pNmLv); - //DlvShowEpisode(pNmLv->lParam); + DlvShowEpisode(pNmLv->lParam); } break; case NM_CUSTOMDRAW: @@ -87,7 +87,6 @@ ElvUpdate() term_t t; hListView = GetDlgItem(gElv_hWnd, IDC_EPISODELISTVIEW); - ListView_DeleteAllItems(hListView); lviEpisode.mask = LVIF_TEXT|LVIF_PARAM; @@ -139,7 +138,6 @@ ElvUpdate() /* Insert item. */ - lviEpisode.mask = LVIF_TEXT|LVIF_STATE|LVIF_PARAM; lviEpisode.iItem = i; lviEpisode.iSubItem = 0; lviEpisode.pszText = tszEpisode; @@ -207,7 +207,7 @@ void UpdateLayout(HWND hWnd) { HWND hElv, hDlv; - int cxColumn; + int cxColumn, cyDlv; RECT rc; static int cxVScroll = 0; extern int g_SelectedItem; @@ -222,7 +222,8 @@ UpdateLayout(HWND hWnd) /* Resize data list view. */ hDlv = GetDlgItem(hWnd, IDC_DATALISTVIEW); - MoveWindow(hDlv, 0, rc.bottom-100, + cyDlv = rc.bottom-100; + MoveWindow(hDlv, 0, cyDlv, rc.right, rc.bottom, TRUE); @@ -234,7 +235,7 @@ UpdateLayout(HWND hWnd) hElv = GetDlgItem(hWnd, IDC_EPISODELISTVIEW); MoveWindow(hElv, 0, 0, - rc.right, rc.bottom-100+1, + rc.right, cyDlv+1, TRUE); cxColumn = ListView_GetColumnWidth(hElv, 0); |