diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-15 00:50:32 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-15 00:50:32 +0200 |
commit | 095954fe8c0d1a64d8696d0ad0cd0ed395dd6c54 (patch) | |
tree | cc1543954c5208dfa56adfa82853239a6504ba18 /c | |
parent | 0e22414d042207269f916298b236f1be341ddeea (diff) | |
download | EpisodeBrowser-095954fe8c0d1a64d8696d0ad0cd0ed395dd6c54.tar.gz |
Change declaration style.
Diffstat (limited to 'c')
-rw-r--r-- | c/common.cpp | 9 | ||||
-rw-r--r-- | c/datalistview.cpp | 3 | ||||
-rw-r--r-- | c/defs.h | 44 | ||||
-rw-r--r-- | c/episodelistview.cpp | 39 | ||||
-rw-r--r-- | c/listview.cpp | 15 | ||||
-rw-r--r-- | c/main.cpp | 24 | ||||
-rw-r--r-- | c/pl.cpp | 15 |
7 files changed, 56 insertions, 93 deletions
diff --git a/c/common.cpp b/c/common.cpp index 93f97eb..bcc5fd0 100644 --- a/c/common.cpp +++ b/c/common.cpp @@ -6,8 +6,7 @@ #include "defs.h" /* Convert normal string to TSTR using given codepage. */ -TCHAR * -TszFromSz(const char *sz, int iCp) +TCHAR *TszFromSz(const char *sz, int iCp) { TCHAR *tsz; @@ -40,14 +39,12 @@ Library::~Library() FreeLibrary(m_hModule); } -FARPROC -Library::GetProcAddress(const char *szProc) +FARPROC Library::GetProcAddress(const char *szProc) { return m_hModule? ::GetProcAddress(m_hModule, szProc): NULL; } -std::unique_ptr<Library> -Library::Load(const TCHAR *tszLibrary) +std::unique_ptr<Library> Library::Load(const TCHAR *tszLibrary) { auto upLib = std::make_unique<Library>(tszLibrary); if (!upLib->m_hModule) upLib = nullptr; diff --git a/c/datalistview.cpp b/c/datalistview.cpp index bd9b317..661a68e 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -25,8 +25,7 @@ DataListView::DataListView() : ListView((HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEA ListView_InsertColumn(m_hWnd, DLVSIVALUE, &lvc); } -void -DataListView::ShowEpisode(int iEpisode) +void DataListView::ShowEpisode(int iEpisode) { ListView_DeleteAllItems(m_hWnd); @@ -8,40 +8,36 @@ /* common.cpp */ TCHAR *TszFromSz(const char *, int); -class Library { -private: - HMODULE m_hModule; -public: - static std::unique_ptr<Library> Load(const TCHAR *); +struct Library +{ Library(const TCHAR *); ~Library(); FARPROC GetProcAddress(const char *); + static std::unique_ptr<Library> Load(const TCHAR *); +private: + HMODULE m_hModule; }; /* main.cpp */ void UpdateLayout(); /* listview.cpp */ -class ListView { -protected: - int m_bHeader = 1; - WNDPROC m_prevProc; - HWND m_hWnd; -public: +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 */ -class EpisodeListView : public ListView { -private: - int m_iSort; - LVITEM m_lviFocus; - friend int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM); -public: +struct EpisodeListView : public ListView +{ EpisodeListView(void); void DoSort(void); void EnsureFocusVisible(void); @@ -56,11 +52,15 @@ public: 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 */ -class DataListView : public ListView { -public: +struct DataListView : public ListView +{ DataListView(void); void ShowEpisode(int); }; @@ -83,8 +83,7 @@ int Plg(term_t, const char *, ...); #define ELVSITITLE 1 #define ELVSIRATING 2 -inline int -Cmp(int a, int b) +inline int Cmp(int a, int b) { if (a == b) return 0; @@ -93,8 +92,7 @@ Cmp(int a, int b) return -1; } -inline int -Dpi(int i) +inline int Dpi(int i) { extern int g_iDPI; return MulDiv(i, g_iDPI, 96); diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index 15d7ba4..8273e08 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -33,22 +33,19 @@ EpisodeListView::EpisodeListView() : ListView((HMENU)IDC_EPISODELISTVIEW, 0) m_iSort = 1; } -void -EpisodeListView::DoSort() +void EpisodeListView::DoSort() { ListView_SortItemsEx(m_hWnd, ElvSort, (LPARAM)this); } -void -EpisodeListView::EnsureFocusVisible() +void EpisodeListView::EnsureFocusVisible() { int iEpFocus = ListView_GetNextItem(m_hWnd, -1, LVNI_FOCUSED); if (iEpFocus == -1) return; ListView_EnsureVisible(m_hWnd, iEpFocus, TRUE); } -LRESULT -EpisodeListView::HandleNotify(LPARAM lParam) +LRESULT EpisodeListView::HandleNotify(LPARAM lParam) { LPNMLISTVIEW lpNmLv = (LPNMLISTVIEW)lParam; @@ -141,15 +138,13 @@ EpisodeListView::HandleNotify(LPARAM lParam) return 0; } -void -EpisodeListView::Redraw() +void EpisodeListView::Redraw() { RedrawWindow(m_hWnd, NULL, NULL, RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN); } -void -EpisodeListView::SaveFocus() +void EpisodeListView::SaveFocus() { LVITEM lvi; lvi.mask = LVIF_PARAM; @@ -158,8 +153,7 @@ EpisodeListView::SaveFocus() Pl("cfg","set_focus","I",lvi.lParam); } -void -EpisodeListView::SetTop(int iItem) +void EpisodeListView::SetTop(int iItem) { int iLast = ListView_GetItemCount(m_hWnd)-1; ListView_EnsureVisible(m_hWnd, iLast, TRUE); @@ -167,8 +161,7 @@ EpisodeListView::SetTop(int iItem) } /* Select previously focused episode. */ -void -EpisodeListView::RestoreFocus() +void EpisodeListView::RestoreFocus() { int i, iEpisode, iItem; LVFINDINFO lvfi; @@ -202,8 +195,7 @@ s: ListView_SetItemState(m_hWnd, -1, LVIF_STATE, LVIS_SELECTED); } /* Select next/previous unwatched episode. */ -void -EpisodeListView::SelectUnwatched(int iDir) +void EpisodeListView::SelectUnwatched(int iDir) { /* Get focused episode. */ LVITEM lviFocus; @@ -239,8 +231,7 @@ EpisodeListView::SelectUnwatched(int iDir) } while (i++ < 1000); } -void -EpisodeListView::ShowFocus() +void EpisodeListView::ShowFocus() { int iEpFocus = ListView_GetNextItem(m_hWnd, -1, LVNI_FOCUSED); if (iEpFocus == -1) return; @@ -248,8 +239,7 @@ EpisodeListView::ShowFocus() } /* Update episode list. */ -void -EpisodeListView::Update() +void EpisodeListView::Update() { int cEp, i, iEp, iEpFocus, iItem, iItemMark, iItemTopNew; LVITEM lvi, lviEpisode, lviTop; @@ -360,8 +350,7 @@ EpisodeListView::Update() } /* Update episode name and rating. */ -void -EpisodeListView::UpdateItem(LPLVITEM lpLvi) +void EpisodeListView::UpdateItem(LPLVITEM lpLvi) { char *szName; int iRating; @@ -389,8 +378,7 @@ r: if (!Pl("episode_data","episode_rating","Ii",lpLvi->lParam,&iRating)) { f: if (tszName) free(tszName); } -LRESULT CALLBACK -EpisodeListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK EpisodeListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_GETDLGCODE: @@ -413,8 +401,7 @@ EpisodeListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return ListView::WndProc(hWnd, uMsg, wParam, lParam); } -int CALLBACK -ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM lExtra) +int CALLBACK ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM lExtra) { EpisodeListView *lpElv = (EpisodeListView *)lExtra; diff --git a/c/listview.cpp b/c/listview.cpp index cce1461..1a06e55 100644 --- a/c/listview.cpp +++ b/c/listview.cpp @@ -32,8 +32,7 @@ ListView::ListView(HMENU hMenu, DWORD dwStyle) } /* Naively calculate height of list view. */ -int -ListView::Height(int bHeader) +int ListView::Height(int bHeader) { if (bHeader == -1) bHeader = m_bHeader; @@ -41,14 +40,12 @@ ListView::Height(int bHeader) return iCount? Dpi(bHeader? 27: 4)+iCount*Dpi(19): 0; } -HWND -ListView::HWnd() const +HWND ListView::HWnd() const { return m_hWnd; } -void -ListView::UpdateTheme(BOOL bThemeActive) +void ListView::UpdateTheme(BOOL bThemeActive) { DWORD dwStyle; LPTSTR tszTheme; @@ -76,8 +73,7 @@ ListView::UpdateTheme(BOOL bThemeActive) SendMessage(m_hWnd, WM_UPDATEUISTATE, MAKEWPARAM(wAction, UISF_HIDEFOCUS), 0); } -LRESULT CALLBACK -ListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK ListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_NOTIFY: @@ -92,8 +88,7 @@ ListView::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return CallWindowProc(m_prevProc, hWnd, uMsg, wParam, lParam); } -LRESULT CALLBACK -WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ListView *lpLv = (ListView *)GetProp(hWnd, TEXT("this")); @@ -30,8 +30,7 @@ static HWND CreateStatusBar(HWND, HINSTANCE); static int Attach(void); static void UpdateTheme(void); -int WINAPI -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) { LPTSTR tszErr; @@ -129,8 +128,7 @@ f: MessageBox(NULL, tszErr, TEXT("Error"), MB_ICONERROR); return 1; } -static LRESULT CALLBACK -CBTProc(int nCode, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode != HCBT_CREATEWND) return 0; if (g_hWnd) return 0; @@ -159,8 +157,7 @@ CBTProc(int nCode, WPARAM wParam, LPARAM lParam) return 0; } -LRESULT CALLBACK -WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: @@ -451,8 +448,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR CALLBACK -AboutDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: @@ -472,8 +468,7 @@ AboutDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; } -HWND -CreateStatusBar(HWND hWndParent, HINSTANCE hInstance) +HWND CreateStatusBar(HWND hWndParent, HINSTANCE hInstance) { HWND hWnd = CreateWindowEx( 0, @@ -492,8 +487,7 @@ CreateStatusBar(HWND hWndParent, HINSTANCE hInstance) /***/ /* Attach persistent databases. */ -int -Attach() +int Attach() { if (!Pl("track_episodes","attach","")) return 0; if (!Pl("episode_data","attach","")) return 0; @@ -502,8 +496,7 @@ Attach() /***/ -void -UpdateLayout() +void UpdateLayout() { int cxColumn, cyDlv, yStatus; RECT rc, rcStatus; @@ -538,8 +531,7 @@ UpdateLayout() } /* Try to style application according to current Windows theme. */ -void -UpdateTheme() +void UpdateTheme() { if (!g_bThemes) return; BOOL bThemeActive = IsThemeActive(); @@ -7,8 +7,7 @@ static int Plpv(term_t, const char *, va_list); static int Plgv(term_t, const char *, va_list); /* Call Prolog predicate once. */ -int -Pl(const char *szMod, const char *szPred, const char *szFmt, ...) +int Pl(const char *szMod, const char *szPred, const char *szFmt, ...) { int iArity; term_t t; @@ -35,8 +34,7 @@ f: va_end(vl); } /* Put known values in term. */ -int -Plp(term_t t, const char *szFmt, ...) +int Plp(term_t t, const char *szFmt, ...) { int r; va_list vl; @@ -45,8 +43,7 @@ Plp(term_t t, const char *szFmt, ...) va_end(vl); return r; } -int -Plpv(term_t t, const char *szFmt, va_list vl) +int Plpv(term_t t, const char *szFmt, va_list vl) { int i; for (i = 0; szFmt[i]; i++) { @@ -89,8 +86,7 @@ Plpv(term_t t, const char *szFmt, va_list vl) } /* Get unknown values from term. */ -int -Plg(term_t t, const char *szFmt, ...) +int Plg(term_t t, const char *szFmt, ...) { int r; va_list vl; @@ -99,8 +95,7 @@ Plg(term_t t, const char *szFmt, ...) va_end(vl); return r; } -int -Plgv(term_t t, const char *szFmt, va_list vl) +int Plgv(term_t t, const char *szFmt, va_list vl) { int i; for (i = 0; szFmt[i]; i++) { |