aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-25 14:10:02 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-25 14:10:02 +0200
commitc884c09ac88c0d22a21f839593d77c7173c41b60 (patch)
tree5aa03981fcc2196443993d691f792c14d0435872
parent45133f2f99dc2e6f0e786909a68f1cfd93b7f01d (diff)
downloadEpisodeBrowser-c884c09ac88c0d22a21f839593d77c7173c41b60.tar.gz
Flip title and rating columns.
-rw-r--r--c/datalistview.c8
-rw-r--r--c/defs.h27
-rw-r--r--c/episodelistview.c34
-rw-r--r--c/main.c18
4 files changed, 47 insertions, 40 deletions
diff --git a/c/datalistview.c b/c/datalistview.c
index e9ad2ac..5335b27 100644
--- a/c/datalistview.c
+++ b/c/datalistview.c
@@ -16,16 +16,16 @@ DlvCreate()
HDlv = LvCreate((HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEADER);
lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
- lvc.iSubItem = 0;
+ lvc.iSubItem = DLVSIKEY;
lvc.pszText = TEXT("Key");
lvc.cx = Dpi(42);
- ListView_InsertColumn(HDlv, 0, &lvc);
+ ListView_InsertColumn(HDlv, DLVSIKEY, &lvc);
- lvc.iSubItem = 1;
+ lvc.iSubItem = DLVSIVALUE;
lvc.pszText = TEXT("Value");
lvc.cx = 500;
- ListView_InsertColumn(HDlv, 1, &lvc);
+ ListView_InsertColumn(HDlv, DLVSIVALUE, &lvc);
return HDlv;
}
diff --git a/c/defs.h b/c/defs.h
index c5e80c2..afc742f 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -27,6 +27,23 @@ void ElvUpdateItem(LPLVITEM);
HWND DlvCreate();
void DlvShowEpisode(int);
+/* defs.h */
+#define DLVSIKEY 0
+#define DLVSIVALUE 1
+#define ELVSIEPISODE 0
+#define ELVSITITLE 1
+#define ELVSIRATING 2
+
+#define P(m,p,a,t) if (!PL_call_predicate(NULL, PL_Q_NORMAL, \
+ PL_predicate(p,a,m), t))
+#define Q(m,p,a,t) PL_open_query(NULL, PL_Q_NORMAL, PL_predicate(p,a,m), t)
+#define Qn(q) PL_next_solution(q)
+#define Qc(q) PL_cut_query(q)
+#define T(a) PL_new_term_refs(a)
+#define PI(t,x) if (!PL_put_integer(t,x))
+#define GI(t,x) if (!PL_get_integer(t,x))
+#define GAC(t,x) if (!PL_get_atom_chars(t,x))
+
inline int
Cmp(int a, int b)
{
@@ -44,14 +61,4 @@ Dpi(int i)
return MulDiv(i, IDPI, 96);
}
-#define P(m,p,a,t) if (!PL_call_predicate(NULL, PL_Q_NORMAL, \
- PL_predicate(p,a,m), t))
-#define Q(m,p,a,t) PL_open_query(NULL, PL_Q_NORMAL, PL_predicate(p,a,m), t)
-#define Qn(q) PL_next_solution(q)
-#define Qc(q) PL_cut_query(q)
-#define T(a) PL_new_term_refs(a)
-#define PI(t,x) if (!PL_put_integer(t,x))
-#define GI(t,x) if (!PL_get_integer(t,x))
-#define GAC(t,x) if (!PL_get_atom_chars(t,x))
-
#endif
diff --git a/c/episodelistview.c b/c/episodelistview.c
index 601f2b7..eaa7e1b 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -20,20 +20,20 @@ ElvCreate()
HElv = LvCreate((HMENU)IDC_EPISODELISTVIEW, 0);
lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
- lvc.iSubItem = 0;
+ lvc.iSubItem = ELVSIEPISODE;
lvc.pszText = TEXT("#");
lvc.cx = Dpi(42);
- ListView_InsertColumn(HElv, 0, &lvc);
+ ListView_InsertColumn(HElv, ELVSIEPISODE, &lvc);
- lvc.iSubItem = 1;
- lvc.pszText = TEXT("/");
- lvc.cx = Dpi(30);
- ListView_InsertColumn(HElv, 1, &lvc);
-
- lvc.iSubItem = 2;
+ lvc.iSubItem = ELVSITITLE;
lvc.pszText = TEXT("Title");
lvc.cx = 500;
- ListView_InsertColumn(HElv, 2, &lvc);
+ ListView_InsertColumn(HElv, ELVSITITLE, &lvc);
+
+ lvc.iSubItem = ELVSIRATING;
+ lvc.pszText = TEXT("/");
+ lvc.cx = Dpi(30);
+ ListView_InsertColumn(HElv, ELVSIRATING, &lvc);
t = T(1);
P("cfg","get_sort",1,t);
@@ -201,11 +201,11 @@ ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM iSort)
if (!ListView_GetItem(HElv, &lvi1)) return 0;
if (!ListView_GetItem(HElv, &lvi2)) return 0;
iOrder = Cmp(iSort, 0);
- switch (abs(iSort)) {
- case 1: /* Sort by episode number. */
+ switch (abs(iSort)-1) {
+ case ELVSIEPISODE:
return iOrder*Cmp(lvi1.lParam, lvi2.lParam);
break;
- case 2: /* Sort by rating. */
+ case ELVSIRATING:
{
int iRating1, iRating2;
term_t t, t2;
@@ -224,7 +224,7 @@ ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM iSort)
return iOrder*Cmp(iRating1, iRating2);
break;
}
- case 3: /* Sort by title. */
+ case ELVSITITLE:
{
char *sz1, *sz2;
int cch, cch1, cch2;
@@ -319,7 +319,7 @@ ElvUpdate()
/* Insert item. */
lviEpisode.iItem = iItem++;
- lviEpisode.iSubItem = 0;
+ lviEpisode.iSubItem = ELVSIEPISODE;
lviEpisode.pszText = tszEpisode;
lviEpisode.lParam = iEp;
ListView_InsertItem(HElv, &lviEpisode);
@@ -389,18 +389,18 @@ ElvUpdateItem(LPLVITEM lpLvi)
GAC(t+1,&szName) goto r;
tszName = TszFromSz(szName, CP_UTF8);
if (tszName)
- ListView_SetItemText(HElv, lpLvi->iItem, 2, tszName);
+ ListView_SetItemText(HElv, lpLvi->iItem, ELVSITITLE, tszName);
r: t2 = T(2);
PI(t2,lpLvi->lParam) goto f;
P("episode_data","episode_rating",2,t2) {
- ListView_SetItemText(HElv, lpLvi->iItem, 1, TEXT(""));
+ ListView_SetItemText(HElv, lpLvi->iItem, ELVSIRATING, TEXT(""));
goto f;
}
GI(t2+1,&iRating) goto f;
_stprintf_s(tszRating, sizeof(tszRating), TEXT("%d"), iRating);
- ListView_SetItemText(HElv, lpLvi->iItem, 1, tszRating);
+ ListView_SetItemText(HElv, lpLvi->iItem, ELVSIRATING, tszRating);
f: if (tszName) free(tszName);
}
diff --git a/c/main.c b/c/main.c
index 2676e01..25d90d2 100644
--- a/c/main.c
+++ b/c/main.c
@@ -450,22 +450,22 @@ UpdateLayout()
/* Resize data list view. */
SendMessage(HDlv, WM_SETREDRAW, FALSE, 0);
- cyDlv = rc.bottom-yStatus-LvHeight(HDlv, 0);
+ cyDlv = rc.bottom-yStatus-LvHeight(HDlv, DLVSIKEY);
MoveWindow(HDlv, 0, cyDlv, rc.right, rc.bottom-yStatus-cyDlv, TRUE);
- ListView_SetColumnWidth(HDlv, 0, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(HDlv, DLVSIKEY, LVSCW_AUTOSIZE);
cxColumn = ListView_GetColumnWidth(HDlv, 0)+4;
- ListView_SetColumnWidth(HDlv, 0, cxColumn);
- ListView_SetColumnWidth(HDlv, 1, rc.right-cxColumn-CxVScroll-4);
+ ListView_SetColumnWidth(HDlv, DLVSIKEY, cxColumn);
+ ListView_SetColumnWidth(HDlv, DLVSIVALUE, rc.right-cxColumn-CxVScroll-4);
SendMessage(HDlv, WM_SETREDRAW, TRUE, 0);
/* Resize episode list view. */
SendMessage(HElv, WM_SETREDRAW, FALSE, 0);
MoveWindow(HElv, 0, 0, rc.right, cyDlv+1, TRUE);
- ListView_SetColumnWidth(HElv, 0, LVSCW_AUTOSIZE);
- cxColumn = ListView_GetColumnWidth(HElv, 0)+4;
- ListView_SetColumnWidth(HElv, 0, cxColumn);
- cxColumn += ListView_GetColumnWidth(HElv, 1);
- ListView_SetColumnWidth(HElv, 2, rc.right-cxColumn-CxVScroll-4);
+ ListView_SetColumnWidth(HElv, ELVSIEPISODE, LVSCW_AUTOSIZE);
+ cxColumn = ListView_GetColumnWidth(HElv, ELVSIEPISODE)+4;
+ ListView_SetColumnWidth(HElv, ELVSIEPISODE, cxColumn);
+ cxColumn += ListView_GetColumnWidth(HElv, ELVSIRATING);
+ ListView_SetColumnWidth(HElv, ELVSITITLE, rc.right-cxColumn-CxVScroll-4);
SendMessage(HElv, WM_SETREDRAW, TRUE, 0);
/* Resize status bar parts. */