aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c/defs.h6
-rw-r--r--c/episodelistview.cpp31
-rw-r--r--c/listview.cpp14
-rw-r--r--c/main.cpp2
4 files changed, 25 insertions, 28 deletions
diff --git a/c/defs.h b/c/defs.h
index 14066a9..c557320 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -14,11 +14,12 @@ void UpdateLayout();
/* listview.cpp */
class ListView {
protected:
+ int m_bHeader = 1;
WNDPROC m_prevProc;
HWND m_hWnd;
public:
ListView(HMENU, DWORD);
- int Height(int);
+ int Height(int = -1);
HWND HWnd(void) const;
virtual void UpdateTheme(BOOL);
virtual LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
@@ -29,6 +30,7 @@ class EpisodeListView : public ListView {
private:
int m_iSort;
LVITEM m_lviFocus;
+ friend int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
public:
EpisodeListView(void);
void DoSort(void);
@@ -43,7 +45,7 @@ public:
void ShowFocus(void);
void Update(void);
void UpdateItem(LPLVITEM);
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+ LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) override;
};
/* datalistview.cpp */
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index e34fb34..15d7ba4 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -7,7 +7,7 @@
#include "defs.h"
extern DataListView *g_lpDlv;
-static int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
+int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
EpisodeListView::EpisodeListView() : ListView((HMENU)IDC_EPISODELISTVIEW, 0)
{
@@ -141,12 +141,6 @@ EpisodeListView::HandleNotify(LPARAM lParam)
return 0;
}
-int
-EpisodeListView::ISort() const
-{
- return m_iSort;
-}
-
void
EpisodeListView::Redraw()
{
@@ -419,36 +413,34 @@ EpisodeListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return ListView::WndProc(hWnd, uMsg, wParam, lParam);
}
-/* Sort list view items, iSort being the 1-based index of the column
- * to sort by. If iSort is negative, the order is descending. */
int CALLBACK
-ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM lpLv)
+ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM lExtra)
{
- EpisodeListView *lpThis = (EpisodeListView *)lpLv;
+ EpisodeListView *lpElv = (EpisodeListView *)lExtra;
LVITEM lvi1, lvi2;
lvi1.mask = lvi2.mask = LVIF_PARAM;
lvi1.iItem = iItem1; lvi2.iItem = iItem2;
- if (!ListView_GetItem(lpThis->HWnd(), &lvi1)) return 0;
- if (!ListView_GetItem(lpThis->HWnd(), &lvi2)) return 0;
+ if (!ListView_GetItem(lpElv->HWnd(), &lvi1)) return 0;
+ if (!ListView_GetItem(lpElv->HWnd(), &lvi2)) return 0;
- int iOrder = Cmp(lpThis->ISort(), 0);
+ /* abs(m_iSort) is the 1-based index of the column to sort by.
+ * If m_iSort is negative, the order is descending. */
+ int iOrder = Cmp(lpElv->m_iSort, 0);
- switch (abs(lpThis->ISort())-1) {
+ switch (abs(lpElv->m_iSort)-1) {
case ELVSIEPISODE:
return iOrder*Cmp(lvi1.lParam, lvi2.lParam);
- break;
case ELVSIRATING:
{
int iRating1, iRating2;
- iRating1 = lpThis->ISort() > 0? 99: -1;
- iRating2 = lpThis->ISort() > 0? 99: -1;
+ iRating1 = lpElv->m_iSort > 0? 99: -1;
+ iRating2 = lpElv->m_iSort > 0? 99: -1;
Pl("episode_data","episode_rating","Ii",lvi1.lParam,&iRating1);
Pl("episode_data","episode_rating","Ii",lvi2.lParam,&iRating2);
if (iRating1 == iRating2)
return Cmp(lvi1.lParam, lvi2.lParam);
return iOrder*Cmp(iRating1, iRating2);
- break;
}
case ELVSITITLE:
{
@@ -462,7 +454,6 @@ ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM lpLv)
cch2 = strlen(sz2);
cch = cch1 > cch2? cch2: cch1;
return iOrder*_strnicmp(sz1, sz2, cch);
- break;
}
default:
return 0;
diff --git a/c/listview.cpp b/c/listview.cpp
index 8e92ea1..b375454 100644
--- a/c/listview.cpp
+++ b/c/listview.cpp
@@ -11,12 +11,14 @@ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
ListView::ListView(HMENU hMenu, DWORD dwStyle)
{
+ if (dwStyle & LVS_NOCOLUMNHEADER)
+ m_bHeader = 0;
+
m_hWnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
WC_LISTVIEW,
TEXT(""),
- dwStyle
- |WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LVS_REPORT|LVS_SHOWSELALWAYS,
+ dwStyle|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LVS_REPORT|LVS_SHOWSELALWAYS,
0, 0, 0, 0,
g_hWnd, hMenu, GetModuleHandle(NULL), this
);
@@ -34,6 +36,8 @@ ListView::ListView(HMENU hMenu, DWORD dwStyle)
int
ListView::Height(int bHeader)
{
+ if (bHeader == -1)
+ bHeader = m_bHeader;
int iCount = ListView_GetItemCount(m_hWnd);
return iCount? Dpi(bHeader? 27: 4)+iCount*Dpi(19): 0;
}
@@ -89,7 +93,7 @@ ListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return CallWindowProc(m_prevProc, hWnd, uMsg, wParam, lParam);
}
-static LRESULT CALLBACK
+LRESULT CALLBACK
WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
@@ -98,6 +102,6 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
- ListView *lpThis = (ListView *)GetProp(hWnd, TEXT("this"));
- return lpThis? lpThis->WndProc(hWnd, uMsg, wParam, lParam): FALSE;
+ ListView *lpLv = (ListView *)GetProp(hWnd, TEXT("this"));
+ return lpLv? lpLv->WndProc(hWnd, uMsg, wParam, lParam): FALSE;
}
diff --git a/c/main.cpp b/c/main.cpp
index 43fe5f0..3cfe2d6 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -522,7 +522,7 @@ UpdateLayout()
/* Resize data list view. */
SendMessage(g_lpDlv->HWnd(), WM_SETREDRAW, FALSE, 0);
SendMessage(g_lpElv->HWnd(), WM_SETREDRAW, FALSE, 0);
- cyDlv = rc.bottom-yStatus-g_lpDlv->Height(DLVSIKEY);
+ cyDlv = rc.bottom-yStatus-g_lpDlv->Height();
MoveWindow(g_lpDlv->HWnd(), 0, cyDlv, rc.right, rc.bottom-yStatus-cyDlv, TRUE);
ListView_SetColumnWidth(g_lpDlv->HWnd(), DLVSIKEY, LVSCW_AUTOSIZE);
cxColumn = ListView_GetColumnWidth(g_lpDlv->HWnd(), 0)+4;