diff options
author | John Ankarström <john@ankarstrom.se> | 2022-04-07 10:25:50 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-04-07 10:25:50 +0200 |
commit | 85add87933a1cb5a47049b87fbb224448385afae (patch) | |
tree | e014c897e9e2d783b9ff2e20598c2d356591c98e /c/main.c | |
parent | aa967ecb490fea1e298b7cb7bf8d425539f45043 (diff) | |
download | EpisodeBrowser-85add87933a1cb5a47049b87fbb224448385afae.tar.gz |
Add status bar.
Diffstat (limited to 'c/main.c')
-rw-r--r-- | c/main.c | 105 |
1 files changed, 67 insertions, 38 deletions
@@ -11,6 +11,7 @@ HFONT HfBold; HMENU HPopupMenu; HWND HFocus; HWND HWnd; +HWND HWndStatus; int BViewTVOriginal = 1; int BViewWatched = 1; int IDPI = -1; @@ -18,6 +19,7 @@ static int BThemes; static int CxVScroll; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); +static HWND CreateStatusBar(HWND, HINSTANCE); static int Attach(void); static void SetupFonts(void); static void UpdateTheme(void); @@ -82,6 +84,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, ); tszErr = TEXT("Could not create main window."); if (!hWnd) goto f; + HWndStatus = CreateStatusBar(hWnd, hInstance); ShowWindow(hWnd, nCmdShow); /* Populate episode list view. */ @@ -125,18 +128,18 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) t = T(1); P("cfg","get_view_watched",1,t) goto s; GI(t,&BViewWatched); - CheckMenuItem(GetMenu(hWnd), ID_VIEW_WATCHED, + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, BViewWatched? MF_CHECKED: MF_UNCHECKED); } - { + s: { term_t t; t = T(1); - P("cfg","get_view_tv_original",1,t) goto s; + P("cfg","get_view_tv_original",1,t) goto t; GI(t,&BViewTVOriginal); - CheckMenuItem(GetMenu(hWnd), ID_VIEW_TV_ORIGINAL, + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, BViewTVOriginal? MF_CHECKED: MF_UNCHECKED); } - s: SetupFonts(); + t: SetupFonts(); DlvCreate(); ElvCreate(); UpdateTheme(); @@ -150,6 +153,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PostQuitMessage(0); break; case WM_SIZE: + SendMessage(HWndStatus, WM_SIZE, wParam, lParam); UpdateLayout(); break; case WM_GETMINMAXINFO: @@ -199,16 +203,16 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_COMMAND: switch (LOWORD(wParam)) { - case ID_FILE_EXIT: + case IDM_FILE_EXIT: PostMessage(hWnd, WM_CLOSE, 0, 0); break; - case ID_FILE_REFRESH: + case IDM_FILE_REFRESH: ElvUpdate(); break; - case ID_FILE_RESET: + case IDM_FILE_RESET: ElvSelectRecent(); break; - case ID_FILE_ABOUT: + case IDM_FILE_ABOUT: DialogBox( GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), @@ -216,10 +220,10 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) AboutDlgProc ); break; - case ID_VIEW_WATCHED: + case IDM_VIEW_WATCHED: { term_t t; - CheckMenuItem(GetMenu(hWnd), ID_VIEW_WATCHED, + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_WATCHED, BViewWatched? MF_UNCHECKED: MF_CHECKED); BViewWatched = !BViewWatched; ElvUpdate(); @@ -228,10 +232,10 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) P("cfg","set_view_watched",1,t); break; } - case ID_VIEW_TV_ORIGINAL: + case IDM_VIEW_TV_ORIGINAL: { term_t t; - CheckMenuItem(GetMenu(hWnd), ID_VIEW_TV_ORIGINAL, + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_TV_ORIGINAL, BViewTVOriginal? MF_UNCHECKED: MF_CHECKED); BViewTVOriginal = !BViewTVOriginal; ElvUpdate(); @@ -240,16 +244,16 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) P("cfg","set_view_tv_original",1,t); break; } - case ID_WATCH: - case ID_TOGGLE: - case ID_FORGET: - case ID_LOOKUP: - case ID_RATE5: - case ID_RATE4: - case ID_RATE3: - case ID_RATE2: - case ID_RATE1: - case ID_RATE0: + case IDM_WATCH: + case IDM_TOGGLE: + case IDM_FORGET: + case IDM_LOOKUP: + case IDM_RATE5: + case IDM_RATE4: + case IDM_RATE3: + case IDM_RATE2: + case IDM_RATE1: + case IDM_RATE0: { LVITEM lvi; term_t t; @@ -267,40 +271,40 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PI(t,lvi.lParam) goto b; switch (LOWORD(wParam)) { - case ID_WATCH: + case IDM_WATCH: P("local_episode","open_episode",1,t); break; - case ID_TOGGLE: + case IDM_TOGGLE: P("track_episodes","toggle_episode",1,t); ElvRedraw(); break; - case ID_FORGET: + case IDM_FORGET: P("track_episodes","forget_episode",1,t); P("track_episodes","update_tracked_episodes",0,t); ElvRedraw(); break; - case ID_LOOKUP: + case IDM_LOOKUP: P("episode_data","retract_episode",1,t); ElvUpdateItem(&lvi); ElvRedraw(); DlvShowEpisode(lvi.lParam); break; - case ID_RATE5: + case IDM_RATE5: PI(t+1,5) break; goto r; - case ID_RATE4: + case IDM_RATE4: PI(t+1,4) break; goto r; - case ID_RATE3: + case IDM_RATE3: PI(t+1,3) break; goto r; - case ID_RATE2: + case IDM_RATE2: PI(t+1,2) break; goto r; - case ID_RATE1: + case IDM_RATE1: PI(t+1,1) break; goto r; - case ID_RATE0: + case IDM_RATE0: PI(t+1,0) break; r: P("episode_data","rate_episode",2,t); ElvUpdateItem(&lvi); @@ -340,6 +344,24 @@ AboutDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; } +HWND +CreateStatusBar(HWND hWndParent, HINSTANCE hInstance) +{ + HWND hWnd; + hWnd = CreateWindowEx( + 0, + STATUSCLASSNAME, + (LPCTSTR) NULL, + WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, + 0, 0, 0, 0, + hWndParent, + (HMENU)ID_STATUS, + hInstance, + NULL + ); + return hWnd; +} + /***/ /* Attach persistent databases. */ @@ -380,16 +402,18 @@ SetupFonts() void UpdateLayout() { - int cxColumn, cyDlv; - RECT rc; + int cxColumn, cyDlv, yStatus; + RECT rc, rcStatus; extern HWND HDlv, HElv; GetClientRect(HWnd, &rc); + GetClientRect(HWndStatus, &rcStatus); + yStatus = rcStatus.bottom-rcStatus.top; /* Resize data list view. */ SendMessage(HDlv, WM_SETREDRAW, FALSE, 0); - cyDlv = rc.bottom - LvHeight(HDlv, 0); - MoveWindow(HDlv, 0, cyDlv, rc.right, rc.bottom, TRUE); + cyDlv = rc.bottom-yStatus-LvHeight(HDlv, 0); + MoveWindow(HDlv, 0, cyDlv, rc.right, rc.bottom-yStatus-cyDlv, TRUE); ListView_SetColumnWidth(HDlv, 0, LVSCW_AUTOSIZE); cxColumn = ListView_GetColumnWidth(HDlv, 0)+4; ListView_SetColumnWidth(HDlv, 0, cxColumn); @@ -406,7 +430,12 @@ UpdateLayout() ListView_SetColumnWidth(HElv, 2, rc.right-cxColumn-CxVScroll-4); SendMessage(HElv, WM_SETREDRAW, TRUE, 0); -#undef SETCOLW + /* Resize status bar parts. */ + { + int aParts[] = {rc.right-Dpi(100), rc.right-Dpi(50), rc.right}; + SendMessage(HWndStatus, SB_SETPARTS, + (WPARAM)sizeof(aParts), (LPARAM)aParts); + } } /* Try to style application according to current Windows theme. */ |