aboutsummaryrefslogtreecommitdiff
path: root/c/listview.h
blob: ba3a1155355f2407f889b88c30610f957bdda2b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef LISTVIEW_H
#define LISTVIEW_H

#include <windows.h>
#include <commctrl.h>

struct Window;

struct ListView
{
	HWND hWnd;
	Window& parent;

	ListView(Window& parent, HMENU hMenu, DWORD dwStyle);
	/* Retrieve next matching list view item. */
	bool FindNextItem(LVITEM* lvi, LPARAM lParam) noexcept;
	/* Naively calculate height appropriate for number of items. */
	virtual int Height() noexcept;
	/* Update column widths on window size change (unimplemented
	 * by default). */
	virtual void ResizeColumns(int w);
	/* Enable/disable "modern" theme. */
	virtual void UpdateTheme(bool bThemeActive);
	virtual LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
protected:
	WNDPROC m_proc0;
};

inline bool ListView::FindNextItem(LVITEM* const lvi, const LPARAM lParam) noexcept
{
	if ((lvi->iItem = ListView_GetNextItem(hWnd, lvi->iItem, lParam)) == -1)
		return false;
	return ListView_GetItem(hWnd, lvi);
}

#endif