1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
2 // dlgeditsetting.cpp
\r
7 #include "windowstool.h"
\r
8 #include "dlgeditsetting.h"
\r
9 #include "layoutmanager.h"
\r
10 #include <windowsx.h>
\r
14 class DlgEditSetting : public LayoutManager
\r
16 HWND m_hwndMayuPathName; ///
\r
17 HWND m_hwndMayuPath; ///
\r
18 HWND m_hwndSymbols; ///
\r
20 DlgEditSettingData *m_data; ///
\r
24 DlgEditSetting(HWND i_hwnd)
\r
25 : LayoutManager(i_hwnd),
\r
26 m_hwndMayuPathName(NULL),
\r
27 m_hwndMayuPath(NULL),
\r
28 m_hwndSymbols(NULL),
\r
33 BOOL wmInitDialog(HWND /* focus */, LPARAM i_lParam) {
\r
34 m_data = reinterpret_cast<DlgEditSettingData *>(i_lParam);
\r
36 setSmallIcon(m_hwnd, IDI_ICON_mayu);
\r
37 setBigIcon(m_hwnd, IDI_ICON_mayu);
\r
39 CHECK_TRUE( m_hwndMayuPathName
\r
40 = GetDlgItem(m_hwnd, IDC_EDIT_mayuPathName) );
\r
41 CHECK_TRUE( m_hwndMayuPath = GetDlgItem(m_hwnd, IDC_EDIT_mayuPath) );
\r
42 CHECK_TRUE( m_hwndSymbols = GetDlgItem(m_hwnd, IDC_EDIT_symbols) );
\r
44 SetWindowText(m_hwndMayuPathName, m_data->m_name.c_str());
\r
45 SetWindowText(m_hwndMayuPath, m_data->m_filename.c_str());
\r
46 SetWindowText(m_hwndSymbols, m_data->m_symbols.c_str());
\r
48 restrictSmallestSize();
\r
50 // set layout manager
\r
51 typedef LayoutManager LM;
\r
53 addItem(GetDlgItem(m_hwnd, IDC_STATIC_mayuPathName));
\r
54 addItem(GetDlgItem(m_hwnd, IDC_EDIT_mayuPathName),
\r
55 LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE,
\r
56 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE);
\r
57 addItem(GetDlgItem(m_hwnd, IDC_STATIC_mayuPathNameComment),
\r
58 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE,
\r
59 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE);
\r
61 addItem(GetDlgItem(m_hwnd, IDC_STATIC_mayuPath));
\r
62 addItem(GetDlgItem(m_hwnd, IDC_EDIT_mayuPath),
\r
63 LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE,
\r
64 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE);
\r
65 addItem(GetDlgItem(m_hwnd, IDC_BUTTON_browse),
\r
66 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE,
\r
67 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE);
\r
69 addItem(GetDlgItem(m_hwnd, IDC_STATIC_symbols));
\r
70 addItem(GetDlgItem(m_hwnd, IDC_EDIT_symbols),
\r
71 LM::ORIGIN_LEFT_EDGE, LM::ORIGIN_TOP_EDGE,
\r
72 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE);
\r
73 addItem(GetDlgItem(m_hwnd, IDC_STATIC_symbolsComment),
\r
74 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE,
\r
75 LM::ORIGIN_RIGHT_EDGE, LM::ORIGIN_TOP_EDGE);
\r
77 addItem(GetDlgItem(m_hwnd, IDOK),
\r
78 LM::ORIGIN_CENTER, LM::ORIGIN_TOP_EDGE,
\r
79 LM::ORIGIN_CENTER, LM::ORIGIN_TOP_EDGE);
\r
80 addItem(GetDlgItem(m_hwnd, IDCANCEL),
\r
81 LM::ORIGIN_CENTER, LM::ORIGIN_TOP_EDGE,
\r
82 LM::ORIGIN_CENTER, LM::ORIGIN_TOP_EDGE);
\r
84 restrictSmallestSize(LM::RESTRICT_BOTH);
\r
85 restrictLargestSize(LM::RESTRICT_VERTICALLY);
\r
92 CHECK_TRUE( EndDialog(m_hwnd, 0) );
\r
97 BOOL wmCommand(int /* i_notify_code */, int i_id, HWND /* i_hwnd_control */) {
\r
98 _TCHAR buf[GANA_MAX_PATH];
\r
100 case IDC_BUTTON_browse: {
\r
101 tstring title = loadString(IDS_openMayu);
\r
102 tstring filter = loadString(IDS_openMayuFilter);
\r
103 for (size_t i = 0; i < filter.size(); ++ i)
\r
104 if (filter[i] == _T('|'))
\r
105 filter[i] = _T('\0');
\r
107 _tcscpy(buf, _T(".mayu"));
\r
109 memset(&of, 0, sizeof(of));
\r
110 of.lStructSize = sizeof(of);
\r
111 of.hwndOwner = m_hwnd;
\r
112 of.lpstrFilter = filter.c_str();
\r
113 of.nFilterIndex = 1;
\r
114 of.lpstrFile = buf;
\r
115 of.nMaxFile = NUMBER_OF(buf);
\r
116 of.lpstrTitle = title.c_str();
\r
117 of.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
\r
118 OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
\r
119 if (GetOpenFileName(&of))
\r
120 SetWindowText(m_hwndMayuPath, buf);
\r
125 GetWindowText(m_hwndMayuPathName, buf, NUMBER_OF(buf));
\r
126 m_data->m_name = buf;
\r
127 GetWindowText(m_hwndMayuPath, buf, NUMBER_OF(buf));
\r
128 m_data->m_filename = buf;
\r
129 GetWindowText(m_hwndSymbols, buf, NUMBER_OF(buf));
\r
130 m_data->m_symbols = buf;
\r
131 CHECK_TRUE( EndDialog(m_hwnd, 1) );
\r
136 CHECK_TRUE( EndDialog(m_hwnd, 0) );
\r
147 INT_PTR CALLBACK dlgEditSetting_dlgProc(HWND i_hwnd, UINT i_message,
\r
149 BOOL CALLBACK dlgEditSetting_dlgProc(HWND i_hwnd, UINT i_message,
\r
151 WPARAM i_wParam, LPARAM i_lParam)
\r
153 DlgEditSetting *wc;
\r
154 getUserData(i_hwnd, &wc);
\r
156 switch (i_message) {
\r
157 case WM_INITDIALOG:
\r
158 wc = setUserData(i_hwnd, new DlgEditSetting(i_hwnd));
\r
159 return wc->wmInitDialog(
\r
160 reinterpret_cast<HWND>(i_wParam), i_lParam);
\r
163 switch (i_message) {
\r
165 return wc->wmCommand(HIWORD(i_wParam), LOWORD(i_wParam),
\r
166 reinterpret_cast<HWND>(i_lParam));
\r
168 return wc->wmClose();
\r
173 return wc->defaultWMHandler(i_message, i_wParam, i_lParam);
\r