diff options
author | John Ankarström <john@ankarstrom.se> | 2022-09-03 01:15:01 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-09-03 01:15:01 +0200 |
commit | 2cd22c671c67deaf2c1fcb659e3262bf57552557 (patch) | |
tree | 825342c317a39022cd60d0aad6569e5f8ef11c0d /c | |
parent | d02e63924c92a6f0f2f88881a75680cb9a538962 (diff) | |
download | EpisodeBrowser-2cd22c671c67deaf2c1fcb659e3262bf57552557.tar.gz |
Add Preferences dialog (WIP).
Diffstat (limited to 'c')
-rw-r--r-- | c/CMakeLists.txt | 4 | ||||
-rw-r--r-- | c/data.cpp | 2 | ||||
-rw-r--r-- | c/datalistview.cpp | 2 | ||||
-rw-r--r-- | c/episodelistview.cpp | 2 | ||||
-rw-r--r-- | c/main.cpp | 32 | ||||
-rw-r--r-- | c/res.h (renamed from c/resource.h) | 25 | ||||
-rw-r--r-- | c/res.rc (renamed from c/resource.rc) | 22 | ||||
-rw-r--r-- | c/window.h | 2 |
8 files changed, 72 insertions, 19 deletions
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index cd86f08..0c8bb83 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -29,8 +29,8 @@ target_sources(EpisodeBrowser PRIVATE listview.cpp listview.h main.cpp - resource.h - resource.rc + res.h + res.rc test.cpp test.h util.h @@ -7,7 +7,7 @@ #include "data.h" #include "episodelistview.h" -#include "resource.h" +#include "res.h" #include "util.h" #include "win32.h" #include "window.h" diff --git a/c/datalistview.cpp b/c/datalistview.cpp index 4ed3d41..2e31d25 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -7,7 +7,7 @@ #include "datalistview.h" #include "episodelistview.h" #include "listview.h" -#include "resource.h" +#include "res.h" #include "window.h" DataListView::DataListView(Window& parent) diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index 29c015b..b683114 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -8,7 +8,7 @@ #include "episodelistview.h" #include "ext.h" #include "listview.h" -#include "resource.h" +#include "res.h" #include "util.h" #include "win32.h" #include "window.h" @@ -8,7 +8,7 @@ #include "debug.h" #include "drag.h" #include "episodelistview.h" -#include "resource.h" +#include "res.h" #include "test.h" #include "util.h" #include "window.h" @@ -45,6 +45,8 @@ static void InitializeMainWindow(HWND) noexcept; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); /* Handle messages to Help > About dialog. */ static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); +/* Handle messages to File > Preferences... dialog. */ +static INT_PTR CALLBACK PreferencesDlgProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain( _In_ const HINSTANCE hInstance, @@ -200,6 +202,23 @@ INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wPa } } +INT_PTR CALLBACK PreferencesDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM) +{ + switch (uMsg) { + case WM_CLOSE: + EndDialog(hWnd, IDOK); + return TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK) + EndDialog(hWnd, IDOK); + return TRUE; + + default: + return FALSE; + } +} + LRESULT CALLBACK Window::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM lParam) { switch (uMsg) { @@ -296,11 +315,12 @@ LRESULT CALLBACK Window::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM { /* Look up status bar tip for menu command. The tip * strings are stored in arrays, whose indices - * correspond to the IDM_ values (see resource.h). */ + * correspond to the IDM_ values (see res.h). */ const wchar_t* vTipMenu[] = { /*IDM_FILE_EXIT*/L"Close Episode Browser.", /*IDM_FILE_REFRESH*/L"Quickly refresh episode list.", + /*IDM_FILE_PREFERENCES*/L"Configure Episode Browser.", /*IDM_FILE_FETCH_DATA*/L"Fetch episode data from the web (may take a few seconds).", /*IDM_FILE_FETCH_SCREENWRITERS*/L"Fetch screenwriters from the web (may take a minute).", /*IDM_FILE_FETCH_CANCEL*/L"Stop fetching data from the web.", @@ -375,6 +395,14 @@ void Window::HandleMainMenu(const HWND hWnd, const WORD command) elv.Update(); break; + case IDM_FILE_PREFERENCES: + DialogBox( + GetModuleHandle(nullptr), + MAKEINTRESOURCE(IDD_PREFERENCES), + hWnd, + PreferencesDlgProc); + break; + case IDM_FILE_FETCH_DATA: { WaitFor(*this, FetchData); @@ -1,5 +1,5 @@ -#ifndef RESOURCE_H -#define RESOURCE_H +#ifndef RES_H +#define RES_H /* Resource groups. */ #define ID_GROUP(i) ((i) & 0x0f00) @@ -25,17 +25,24 @@ #define IDC_ABOUTTEXT 0x0201 #define IDC_EPISODELISTVIEW 0x0202 #define IDC_DATALISTVIEW 0x0203 +#define IDD_PREFERENCES 0x0204 +#define IDC_STATIC 0x0205 +#define IDC_BROWSE 0x0206 +#define IDC_EDIT_ROOT 0x0207 +#define IDC_EDIT_URL 0x0208 +#define IDC_EDIT_PREFIX 0x0209 /* Main menu items. */ #define IDM_FILE_EXIT 0x0300 #define IDM_FILE_REFRESH 0x0301 -#define IDM_FILE_FETCH_DATA 0x0302 -#define IDM_FILE_FETCH_SCREENWRITERS 0x0303 -#define IDM_FILE_FETCH_CANCEL 0x0304 -#define IDM_FILE_ABOUT 0x0305 -#define IDM_VIEW_WATCHED 0x0306 -#define IDM_VIEW_TV_ORIGINAL 0x0307 -#define IDM_VIEW_OTHERS 0x0308 +#define IDM_FILE_PREFERENCES 0x0302 +#define IDM_FILE_FETCH_DATA 0x0303 +#define IDM_FILE_FETCH_SCREENWRITERS 0x0304 +#define IDM_FILE_FETCH_CANCEL 0x0305 +#define IDM_FILE_ABOUT 0x0306 +#define IDM_VIEW_WATCHED 0x0307 +#define IDM_VIEW_TV_ORIGINAL 0x0308 +#define IDM_VIEW_OTHERS 0x0309 /* Context menu items. */ #define IDM_WATCH_LOCALLY 0x0400 @@ -1,5 +1,5 @@ #include <windows.h> -#include "resource.h" +#include "res.h" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "application.manifest" @@ -14,6 +14,7 @@ BEGIN MENUITEM "&Cancel", IDM_FILE_FETCH_CANCEL, GRAYED END MENUITEM "&Refresh", IDM_FILE_REFRESH + MENUITEM "&Preferences...", IDM_FILE_PREFERENCES MENUITEM "E&xit", IDM_FILE_EXIT END POPUP "&View" @@ -68,4 +69,21 @@ BEGIN DEFPUSHBUTTON "&OK", IDOK, ABOUTW-OKW-HPAD, ABOUTH-OKH-VPAD, OKW, OKH LTEXT "Episode Browser\r\nCopyright 2021 John Ankarström", IDC_ABOUTTEXT, HPAD, VPAD, ABOUTW-OKW-HPAD-HPAD, ABOUTH-VPAD -END
\ No newline at end of file +END + +IDD_PREFERENCES DIALOGEX 20, 20, 256, 137 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTEXTHELP +CAPTION "Preferences" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,145,116,50,14 + PUSHBUTTON "Cancel",IDCANCEL,199,116,50,14 + EDITTEXT IDC_EDIT_ROOT,14,18,172,14,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES + PUSHBUTTON "Browse...",IDC_BROWSE,191,18,50,14 + GROUPBOX "Root directory for local episode lookup",IDC_STATIC,7,7,242,32 + EDITTEXT IDC_EDIT_URL,14,54,227,14,ES_AUTOHSCROLL + GROUPBOX "URL for online episode lookup",IDC_STATIC,7,42,242,32 + EDITTEXT IDC_EDIT_PREFIX,14,90,227,14,ES_AUTOHSCROLL + GROUPBOX "Prefix for internal internet requests (for Windows XP compatibility)",IDC_STATIC,7,79,242,32 +END @@ -7,7 +7,7 @@ #include "datalistview.h" #include "drag.h" #include "episodelistview.h" -#include "resource.h" +#include "res.h" #include "win32.h" struct Window |