aboutsummaryrefslogtreecommitdiff
path: root/c/datalistview.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-10 23:23:09 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-10 23:25:09 +0200
commit295d423cc47f9ee8a72134dc544892a03b279311 (patch)
tree3e89b0bbcf42b3053225eb0dff88b887dd16df48 /c/datalistview.c
parent85a4ad2c184ed915915a2fb630415a80ed9a286f (diff)
downloadEpisodeBrowser-295d423cc47f9ee8a72134dc544892a03b279311.tar.gz
Convert to C++.
I already hit upon some object-oriented programming patterns in *listview.c, so I felt that it would be natural to use this as an opportunity to learn C++.
Diffstat (limited to 'c/datalistview.c')
-rw-r--r--c/datalistview.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/c/datalistview.c b/c/datalistview.c
deleted file mode 100644
index fbb46d0..0000000
--- a/c/datalistview.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <stdio.h>
-#include <windows.h>
-#include <commctrl.h>
-#include <SWI-Prolog.h>
-
-#include "resource.h"
-#include "defs.h"
-
-HWND HDlv;
-
-HWND
-DlvCreate()
-{
- LVCOLUMN lvc;
-
- HDlv = LvCreate((HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEADER);
-
- lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
- lvc.iSubItem = DLVSIKEY;
- lvc.pszText = TEXT("Key");
-
- lvc.cx = Dpi(42);
- ListView_InsertColumn(HDlv, DLVSIKEY, &lvc);
-
- lvc.iSubItem = DLVSIVALUE;
- lvc.pszText = TEXT("Value");
- lvc.cx = 500;
- ListView_InsertColumn(HDlv, DLVSIVALUE, &lvc);
-
- return HDlv;
-}
-
-/* Show episode data. */
-void
-DlvShowEpisode(int iEpisode)
-{
- int i, iItem;
- LVFINDINFO lvfi;
- LVITEM lviKey, lviValue;
- term_t t;
- qid_t q;
- extern HWND HElv;
-
- ListView_DeleteAllItems(HDlv);
-
- lviKey.mask = LVIF_TEXT;
- lviValue.mask = LVIF_TEXT;
-
- t = PL_new_term_refs(3);
- if (!Plp(t,"I",iEpisode)) return;
- q = PL_open_query(NULL, PL_Q_NORMAL,
- PL_predicate("episode_datum", 3, "episode_data"), t);
-
- for (i = 0; PL_next_solution(q); i++) {
- char *szKey;
- char *szValue;
- TCHAR *tszKey, *tszValue;
-
- if (!Plg(t+1,"ss",&szKey,&szValue)) continue;
-
- tszKey = TszFromSz(szKey, CP_UTF8);
- if (!tszKey) continue;
- tszValue = TszFromSz(szValue, CP_UTF8);
- if (!tszValue) goto c;
-
- lviKey.mask = LVIF_TEXT;
- lviKey.iItem = i;
- lviKey.iSubItem = 0;
- lviKey.pszText = tszKey;
- ListView_InsertItem(HDlv, &lviKey);
-
- lviValue.iItem = i;
- lviValue.iSubItem = 1;
- lviValue.pszText = tszValue;
- ListView_SetItem(HDlv, &lviValue);
-
- free(tszValue);
- c: free(tszKey);
- }
-
- PL_cut_query(q);
- UpdateLayout();
-
- lvfi.flags = LVFI_PARAM;
- lvfi.lParam = iEpisode;
- iItem = ListView_FindItem(HElv, -1, &lvfi);
- if (iItem != -1)
- ListView_EnsureVisible(HElv, iItem, TRUE);
-}