-
Notifications
You must be signed in to change notification settings - Fork 9
/
VExtension.Page.cpp
109 lines (93 loc) · 3.57 KB
/
VExtension.Page.cpp
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
104
105
106
107
108
109
#include <vu>
#include <fstream>
#include <windowsx.h>
#include "VExtension.Page.h"
#include "types.h"
#include "resource.h"
extern std::string get_prefs_file_path();
VExtensionPage::VExtensionPage(json& prefs)
: m_prefs(prefs)
, m_option_resolve_ordinal(nullptr)
, m_option_undecorate_symbol(nullptr)
, m_option_shorten_undecorated_symbol(nullptr)
, m_option_auto_fit_width_column_name(nullptr)
{
}
VExtensionPage::~VExtensionPage()
{
}
LRESULT VExtensionPage::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
m_option_resolve_ordinal = GetDlgItem(hWnd, IDC_OPTION_RESOLVE_ORDINAL);
m_option_undecorate_symbol = GetDlgItem(hWnd, IDC_OPTION_UNDECORATE_SYMBOL);
m_option_shorten_undecorated_symbol = GetDlgItem(hWnd, IDC_OPTION_SHORTEN_UNDECORATED_SYMBOL);
m_option_auto_fit_width_column_name = GetDlgItem(hWnd, IDC_OPTION_AUTO_FIT_LAST_COLUMN);
bool resolve_ordinal = json_get_option(m_prefs, "resolve_ordinal", true);
Button_SetCheck(m_option_resolve_ordinal, resolve_ordinal ? BST_CHECKED : BST_UNCHECKED);
bool undecorate_symbol = json_get_option(m_prefs, "undecorate_symbol", true);
Button_SetCheck(m_option_undecorate_symbol, undecorate_symbol ? BST_CHECKED : BST_UNCHECKED);
bool shorten_undecorated_symbol = json_get_option(m_prefs, "shorten_undecorated_symbol", true);
Button_SetCheck(m_option_shorten_undecorated_symbol, shorten_undecorated_symbol ? BST_CHECKED : BST_UNCHECKED);
Button_Enable(m_option_shorten_undecorated_symbol, undecorate_symbol ? TRUE : FALSE);
bool auto_fit_width_column_name = json_get_option(m_prefs, "auto_fit_width_column_name", true);
Button_SetCheck(m_option_auto_fit_width_column_name, auto_fit_width_column_name ? BST_CHECKED : BST_UNCHECKED);
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_OPTION_RESOLVE_ORDINAL:
{
bool resolve_ordinal = Button_GetCheck(m_option_resolve_ordinal) == BST_CHECKED;
json_set_option(m_prefs, "resolve_ordinal", resolve_ordinal);
}
break;
case IDC_OPTION_UNDECORATE_SYMBOL:
{
bool undecorate_symbol = Button_GetCheck(m_option_undecorate_symbol) == BST_CHECKED;
json_set_option(m_prefs, "undecorate_symbol", undecorate_symbol);
Button_Enable(m_option_shorten_undecorated_symbol, undecorate_symbol ? TRUE : FALSE);
}
break;
case IDC_OPTION_SHORTEN_UNDECORATED_SYMBOL:
{
bool shorten_undecorated_symbol = Button_GetCheck(m_option_shorten_undecorated_symbol) == BST_CHECKED;
json_set_option(m_prefs, "shorten_undecorated_symbol", shorten_undecorated_symbol);
}
break;
case IDC_OPTION_AUTO_FIT_LAST_COLUMN:
{
bool auto_fit_width_column_name = Button_GetCheck(m_option_auto_fit_width_column_name) == BST_CHECKED;
json_set_option(m_prefs, "auto_fit_width_column_name", auto_fit_width_column_name);
}
break;
case IDC_OPTION_SAVE:
{
try
{
auto prefs_file_path = get_prefs_file_path();
std::ofstream f;
f.open(prefs_file_path);
f << m_prefs.dump(2, ' ');
f.close();
}
catch (...)
{
auto error = vu::get_last_error_A();
vu::msg_box_A(hWnd, MB_OK | MB_ICONERROR, "VExtension", "Save failed (%s).", error.c_str());
}
}
break;
}
}
break;
default:
break;
}
return FALSE;
}