aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/common.cpp3
-rw-r--r--c/common.h59
-rw-r--r--c/datalistview.cpp6
-rw-r--r--c/datalistview.h15
-rw-r--r--c/episodelistview.cpp6
-rw-r--r--c/episodelistview.h35
-rw-r--r--c/listview.cpp5
-rw-r--r--c/listview.h19
-rw-r--r--c/main.cpp7
-rw-r--r--c/main.h6
-rw-r--r--c/pl.cpp3
-rw-r--r--c/pl.h (renamed from c/defs.h)118
12 files changed, 161 insertions, 121 deletions
diff --git a/c/common.cpp b/c/common.cpp
index 3a99769..1fcff31 100644
--- a/c/common.cpp
+++ b/c/common.cpp
@@ -3,8 +3,7 @@
#include <windows.h>
#include <SWI-Prolog.h>
-#include "resource.h"
-#include "defs.h"
+#include "common.h"
/* Convert normal string to TSTR using given codepage. */
TCHAR *TszFromSz(const char *sz, int iCp)
diff --git a/c/common.h b/c/common.h
new file mode 100644
index 0000000..a6bba23
--- /dev/null
+++ b/c/common.h
@@ -0,0 +1,59 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <memory>
+#include <optional>
+#include <stdexcept>
+#include <windows.h>
+
+TCHAR *TszFromSz(const char *, int);
+struct Win32Error : public std::exception
+{
+ Win32Error(DWORD);
+ ~Win32Error(void);
+ virtual const char *what(void) const noexcept override;
+private:
+ DWORD m_dwErr;
+ char *m_szMsg = NULL;
+};
+struct Library
+{
+ Library(const TCHAR *);
+ ~Library(void);
+ FARPROC GetProcAddress(const char *);
+private:
+ HMODULE m_hModule;
+};
+
+#ifdef UNICODE
+#define WA "W"
+#else
+#define WA "A"
+#endif
+
+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);
+}
+
+template <class T, typename ...A>
+std::optional<T> try_make(A ...args)
+{
+ try {
+ return T(args...);
+ } catch (...) {
+ return {};
+ }
+}
+
+#endif
diff --git a/c/datalistview.cpp b/c/datalistview.cpp
index 9c13ae8..b730993 100644
--- a/c/datalistview.cpp
+++ b/c/datalistview.cpp
@@ -4,7 +4,11 @@
#include <SWI-Prolog.h>
#include "resource.h"
-#include "defs.h"
+#include "common.h"
+#include "datalistview.h"
+#include "episodelistview.h"
+#include "listview.h"
+#include "main.h"
extern EpisodeListView *g_lpElv;
diff --git a/c/datalistview.h b/c/datalistview.h
new file mode 100644
index 0000000..011f067
--- /dev/null
+++ b/c/datalistview.h
@@ -0,0 +1,15 @@
+#ifndef DATALISTVIEW_H
+#define DATALISTVIEW_H
+
+#include "listview.h"
+
+struct DataListView : public ListView
+{
+ DataListView(void);
+ void ShowEpisode(int);
+};
+
+#define DLVSIKEY 0
+#define DLVSIVALUE 1
+
+#endif
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index 6430b17..a126649 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -4,7 +4,11 @@
#include <SWI-Prolog.h>
#include "resource.h"
-#include "defs.h"
+#include "common.h"
+#include "datalistview.h"
+#include "episodelistview.h"
+#include "listview.h"
+#include "pl.h"
extern DataListView *g_lpDlv;
int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
diff --git a/c/episodelistview.h b/c/episodelistview.h
new file mode 100644
index 0000000..8befc14
--- /dev/null
+++ b/c/episodelistview.h
@@ -0,0 +1,35 @@
+#ifndef EPISODELISTVIEW_H
+#define EPISODELISTVIEW_H
+
+#include <windows.h>
+#include <commctrl.h>
+
+#include "listview.h"
+
+struct EpisodeListView : public ListView
+{
+ 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;
+private:
+ int m_iSort;
+ LVITEM m_lviFocus;
+ friend int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
+};
+
+#define ELVSIEPISODE 0
+#define ELVSITITLE 1
+#define ELVSIRATING 2
+
+#endif
diff --git a/c/listview.cpp b/c/listview.cpp
index 1a06e55..4e9d754 100644
--- a/c/listview.cpp
+++ b/c/listview.cpp
@@ -2,8 +2,9 @@
#include <commctrl.h>
#include <uxtheme.h>
-#include "resource.h"
-#include "defs.h"
+#include "common.h"
+#include "listview.h"
+#include "main.h"
extern HFONT g_hfNormal;
extern HWND g_hWnd;
diff --git a/c/listview.h b/c/listview.h
new file mode 100644
index 0000000..369c4ec
--- /dev/null
+++ b/c/listview.h
@@ -0,0 +1,19 @@
+#ifndef LISTVIEW_H
+#define LISTVIEW_H
+
+#include <windows.h>
+
+struct ListView
+{
+ ListView(HMENU, DWORD);
+ int Height(int = -1);
+ HWND HWnd(void) const;
+ virtual void UpdateTheme(BOOL);
+ virtual LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+protected:
+ int m_bHeader = 1;
+ WNDPROC m_prevProc;
+ HWND m_hWnd;
+};
+
+#endif
diff --git a/c/main.cpp b/c/main.cpp
index 82c95ba..cbfb8f1 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -1,10 +1,15 @@
+#include <exception>
#include <windows.h>
#include <commctrl.h>
#include <uxtheme.h>
#include <SWI-Prolog.h>
#include "resource.h"
-#include "defs.h"
+#include "common.h"
+#include "datalistview.h"
+#include "episodelistview.h"
+#include "main.h"
+#include "pl.h"
DataListView *g_lpDlv = nullptr;
EpisodeListView *g_lpElv = nullptr;
diff --git a/c/main.h b/c/main.h
new file mode 100644
index 0000000..0b899e6
--- /dev/null
+++ b/c/main.h
@@ -0,0 +1,6 @@
+#ifndef MAIN_H
+#define MAIN_H
+
+void UpdateLayout();
+
+#endif
diff --git a/c/pl.cpp b/c/pl.cpp
index 1fbc4e7..ace83e7 100644
--- a/c/pl.cpp
+++ b/c/pl.cpp
@@ -1,5 +1,6 @@
#include <SWI-Prolog.h>
-#include "defs.h"
+
+#include "pl.h"
Query::Query(module_t ctx, predicate_t p, term_t t0)
{
diff --git a/c/defs.h b/c/pl.h
index 102dce2..f0edfb8 100644
--- a/c/defs.h
+++ b/c/pl.h
@@ -1,81 +1,8 @@
-#ifndef DEFS_H
-#define DEFS_H
+#ifndef PL_H
+#define PL_H
-#include <memory>
-#include <optional>
-#include <stdexcept>
-#include <windows.h>
-#include <commctrl.h>
#include <SWI-Prolog.h>
-/* common.cpp */
-TCHAR *TszFromSz(const char *, int);
-struct Win32Error : public std::exception
-{
- Win32Error(DWORD);
- ~Win32Error(void);
- virtual const char *what(void) const noexcept override;
-private:
- DWORD m_dwErr;
- char *m_szMsg = NULL;
-};
-struct Library
-{
- Library(const TCHAR *);
- ~Library(void);
- FARPROC GetProcAddress(const char *);
-private:
- HMODULE m_hModule;
-};
-
-/* main.cpp */
-void UpdateLayout();
-
-/* listview.cpp */
-struct ListView
-{
- ListView(HMENU, DWORD);
- int Height(int = -1);
- HWND HWnd(void) const;
- virtual void UpdateTheme(BOOL);
- virtual LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
-protected:
- int m_bHeader = 1;
- WNDPROC m_prevProc;
- HWND m_hWnd;
-};
-
-/* episodelistview.cpp */
-struct EpisodeListView : public ListView
-{
- 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;
-private:
- int m_iSort;
- LVITEM m_lviFocus;
- friend int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
-};
-
-/* datalistview.cpp */
-struct DataListView : public ListView
-{
- DataListView(void);
- void ShowEpisode(int);
-};
-
-/* pl.cpp */
int Plx(const char *, const char *);
struct Query
{
@@ -88,6 +15,9 @@ private:
qid_t m_q;
};
+#define DLVSIKEY 0
+#define DLVSIVALUE 1
+
/* Polymorphic aliases for PL_put_*, PL_get_*. */
inline int PlPut(term_t t, int x) { return PL_put_integer(t, x); }
inline int PlPut(term_t t, long x) { return PL_put_integer(t, x); }
@@ -159,42 +89,4 @@ int Pl(const char *szMod, const char *szPred, T... args)
}
}
-/* 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);
-}
-
-template <class T, typename ...A>
-std::optional<T> try_make(A ...args)
-{
- try {
- return T(args...);
- } catch (...) {
- return {};
- }
-}
-
#endif