aboutsummaryrefslogtreecommitdiff
path: root/c/defs.h
blob: c83dd8ce6b9876d436e1186336d83cd71f64c1b3 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef DEFS_H
#define DEFS_H

#include <memory>
#include <windows.h>
#include <commctrl.h>
#include <SWI-Prolog.h>

/* common.cpp */
TCHAR *TszFromSz(const char *, int);
class Library {
private:
	HMODULE m_hModule;
public:
	static std::unique_ptr<Library> Load(const TCHAR *);
	Library(const TCHAR *);
	~Library();
	FARPROC GetProcAddress(const char *);
};

/* main.cpp */
void UpdateLayout();

/* listview.cpp */
class ListView {
protected:
	int m_bHeader = 1;
	WNDPROC m_prevProc;
	HWND m_hWnd;
public:
	ListView(HMENU, DWORD);
	int Height(int = -1);
	HWND HWnd(void) const;
	virtual void UpdateTheme(BOOL);
	virtual LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
};

/* episodelistview.cpp */
class EpisodeListView : public ListView {
private:
	int m_iSort;
	LVITEM m_lviFocus;
	friend int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
public:
	EpisodeListView(void);
	void DoSort(void);
	void EnsureFocusVisible(void);
	LRESULT HandleNotify(LPARAM);
	int ISort(void) const;
	void Redraw(void);
	void SaveFocus(void);
	void SetTop(int);
	void RestoreFocus(void);
	void SelectUnwatched(int);
	void ShowFocus(void);
	void Update(void);
	void UpdateItem(LPLVITEM);
	LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) override;
};

/* datalistview.cpp */
class DataListView : public ListView {
public:
	DataListView(void);
	void ShowEpisode(int);
};

/* pl.cpp */
int Pl(const char *, const char *, const char *, ...);
int Plp(term_t, const char *, ...);
int Plg(term_t, const char *, ...);

/* defs.h */
#ifdef UNICODE
#define WA "W"
#else
#define WA "A"
#endif

#define DLVSIKEY 0
#define DLVSIVALUE 1
#define ELVSIEPISODE 0
#define ELVSITITLE 1
#define ELVSIRATING 2

inline int
Cmp(int a, int b)
{
	if (a == b)
		return 0;
	if (a > b)
		return 1;
	return -1;
}

inline int
Dpi(int i)
{
	extern int g_iDPI;
	return MulDiv(i, g_iDPI, 96);
}

#endif