aboutsummaryrefslogtreecommitdiff
path: root/c/listview.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/listview.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/listview.c')
-rw-r--r--c/listview.c78
1 files changed, 0 insertions, 78 deletions
diff --git a/c/listview.c b/c/listview.c
deleted file mode 100644
index 91838da..0000000
--- a/c/listview.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include <windows.h>
-#include <commctrl.h>
-#include <uxtheme.h>
-
-#include "resource.h"
-#include "defs.h"
-
-extern HFONT HfNormal;
-extern HWND HWnd;
-WNDPROC LvPrevProc;
-static LRESULT CALLBACK LvProc(HWND, UINT, WPARAM, LPARAM);
-
-HWND
-LvCreate(HMENU hMenu, DWORD dwStyle)
-{
- HWND hLv;
-
- hLv = CreateWindowEx(
- WS_EX_CLIENTEDGE,
- WC_LISTVIEW,
- TEXT(""),
- dwStyle|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP
- |LVS_REPORT|LVS_SHOWSELALWAYS,
- 0, 0, 0, 0,
- HWnd, hMenu, GetModuleHandle(NULL), NULL
- );
-
- LvPrevProc = (WNDPROC)SetWindowLongPtr(hLv,
- GWLP_WNDPROC, (LONG_PTR)LvProc);
-
- ListView_SetExtendedListViewStyle(hLv, LVS_EX_FULLROWSELECT);
-
- SendMessage(hLv, WM_SETFONT, (WPARAM)HfNormal, MAKELPARAM(FALSE, 0));
-
- return hLv;
-}
-
-LRESULT CALLBACK
-LvProc(HWND hLv, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case HDN_ENDTRACK:
- UpdateLayout();
- return TRUE;
- }
- break;
- case WM_GETDLGCODE:
- {
- LRESULT lResult;
- extern HWND HElv;
-
- /* For the episode list view, the Enter key should not
- * be handled by the dialog manager, but instead be sent
- * along to the main window procedure, so that it may be
- * handled by the NM_RETURN case in ElvHandleNotify. */
-
- if (hLv != HElv) break;
- lResult = CallWindowProc(LvPrevProc, hLv, uMsg, wParam, lParam);
- if (lParam && ((MSG *)lParam)->message == WM_KEYDOWN
- && ((MSG *)lParam)->wParam == VK_RETURN)
- return DLGC_WANTMESSAGE;
- return lResult;
- }
- }
-
- return CallWindowProc(LvPrevProc, hLv, uMsg, wParam, lParam);
-}
-
-/* Naively calculate height of list view. */
-int
-LvHeight(HWND hLv, int bHeader)
-{
- int iCount;
- iCount = ListView_GetItemCount(hLv);
- return iCount? Dpi(bHeader? 27: 4)+iCount*Dpi(19): 0;
-}