aboutsummaryrefslogtreecommitdiff
path: root/c/datalistview.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/datalistview.c')
-rw-r--r--c/datalistview.c62
1 files changed, 25 insertions, 37 deletions
diff --git a/c/datalistview.c b/c/datalistview.c
index e37375d..d859e24 100644
--- a/c/datalistview.c
+++ b/c/datalistview.c
@@ -1,33 +1,33 @@
#include <windows.h>
+#include <commctrl.h>
#include <SWI-Prolog.h>
#include "resource.h"
#include "defs.h"
-HWND gDlv_hWnd;
+HWND Dlv_hWnd;
HWND
DlvCreate(HWND hWnd)
{
- HWND hListView;
+ HWND hDlv;
LVCOLUMN lvc;
- gDlv_hWnd = hWnd;
- hListView = LvCreate(hWnd, (HMENU)IDC_DATALISTVIEW);
+ Dlv_hWnd = hWnd;
+ hDlv = LvCreate(hWnd, (HMENU)IDC_DATALISTVIEW);
lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
-
lvc.iSubItem = 0;
lvc.pszText = TEXT("Key");
lvc.cx = 42;
- ListView_InsertColumn(hListView, 0, &lvc);
+ ListView_InsertColumn(hDlv, 0, &lvc);
lvc.iSubItem = 1;
lvc.pszText = TEXT("Value");
lvc.cx = 500;
- ListView_InsertColumn(hListView, 1, &lvc);
+ ListView_InsertColumn(hDlv, 1, &lvc);
- return hListView;
+ return hDlv;
}
/* Show episode data. */
@@ -35,26 +35,20 @@ void
DlvShowEpisode(int iEpisode)
{
fid_t f;
- HWND hListView;
+ HWND hDlv;
LVITEM lviKey, lviValue;
term_t t;
- hListView = GetDlgItem(gDlv_hWnd, IDC_DATALISTVIEW);
- ListView_DeleteAllItems(hListView);
+ hDlv = GetDlgItem(Dlv_hWnd, IDC_DATALISTVIEW);
+ ListView_DeleteAllItems(hDlv);
lviKey.mask = LVIF_TEXT;
lviValue.mask = LVIF_TEXT;
- f = PL_open_foreign_frame();
- t = PL_new_term_refs(3);
-
- if(!PL_put_integer(t+0, iEpisode))
- return;
-
- if (!PL_call_predicate(NULL, PL_Q_NORMAL,
- PL_predicate("lookup_episode_local", 3, "episode_data"),
- t))
- return;
+ F(f);
+ t = T(3);
+ PI(t,iEpisode) goto e;
+ P("episode_data","lookup_episode_local",3,t) goto e;
/* The episode data is a list of unary compounds,
* whose functor is the key and whose argument is the value. */
@@ -73,40 +67,34 @@ DlvShowEpisode(int iEpisode)
term_t tValue;
size_t iArity;
- if (!PL_get_name_arity(tHead, &aKey, &iArity))
- continue;
+ if (!PL_get_name_arity(tHead,&aKey,&iArity)) continue;
szKey = PL_atom_chars(aKey);
- if (!szKey)
- continue;
+ if (!szKey) continue;
tValue = PL_new_term_ref();
- if (!PL_get_arg(1, tHead, tValue))
- continue;
- if (!PL_get_atom_chars(tValue, &szValue))
- continue;
+ if (!PL_get_arg(1, tHead, tValue)) continue;
+ GAC(tValue,&szValue) continue;
tszKey = TSZFromSZ(szKey, CP_UTF8);
- if (!tszKey)
- continue;
+ if (!tszKey) continue;
tszValue = TSZFromSZ(szValue, CP_UTF8);
- if (!tszValue)
- continue;
+ if (!tszValue) goto e1;
lviKey.mask = LVIF_TEXT;
lviKey.iItem = i;
lviKey.iSubItem = 0;
lviKey.pszText = tszKey;
- ListView_InsertItem(hListView, &lviKey);
+ ListView_InsertItem(hDlv, &lviKey);
lviValue.iItem = i;
lviValue.iSubItem = 1;
lviValue.pszText = tszValue;
- ListView_SetItem(hListView, &lviValue);
+ ListView_SetItem(hDlv, &lviValue);
- free(tszKey);
free(tszValue);
+e1: free(tszKey);
}
}
- PL_close_foreign_frame(f);
+e: Fd(f);
}