1 // folder_name_dlg.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "studiox.h"
6 #include "studiox_includes.h"
7 #include "folder_name_dlg.h"
8
9
10 enum folder_name_test_commands{
11 TEST_SET_FOLDER_NAME = 1,
12 TEST_SAVE_FOLDER_NAME_EDIT,
13 TEST_CHECK_SPECIFY_OUTPUT_FILE,
14 TEST_SET_FOLDER_OUTPUT_FILE_NAME
15 };
16 // folder_name_dlg dialog
17
18 enum ItemType {
19 TYPE_RESOURCE_FOLDER = 1,
20 TYPE_PROJECT_VIEW_FOLDER,
21 };
22
BEGIN_MESSAGE_MAP(folder_name_dlg,express_dialog)23 BEGIN_MESSAGE_MAP(folder_name_dlg, express_dialog)
24 ON_EN_CHANGE(IDC_FOLDER_NAME, &folder_name_dlg::OnEnChangeFolderName)
25 ON_BN_CLICKED(IDC_CUSTOM_FOLDER_OUTPUT, &folder_name_dlg::OnBnClickedCustomOutput)
26 ON_MESSAGE(STUDIO_TEST, &folder_name_dlg::OnTestMessage)
27 ON_BN_CLICKED(IDOK, OnOK)
28 END_MESSAGE_MAP()
29
30
31 IMPLEMENT_DYNAMIC(folder_name_dlg, express_dialog)
32
33 folder_name_dlg::folder_name_dlg(res_info *info, CWnd* pParent /*=NULL*/)
34 : express_dialog(folder_name_dlg::IDD, pParent)
35 {
36 folder_name = info->name;
37 output_filename.Empty();
38 input_item_type = TYPE_RESOURCE_FOLDER;
39 IconId = IDB_FOLDER_RENAME;
40 SetTitleText("Edit Folder Name");
41 }
42
folder_name_dlg(folder_info * info,CWnd * pParent)43 folder_name_dlg::folder_name_dlg(folder_info *info, CWnd* pParent /*=NULL*/)
44 : express_dialog(folder_name_dlg::IDD, pParent)
45 {
46 folder_name = info->folder_name;
47 output_filename = info->output_filename;
48 input_item_type = TYPE_PROJECT_VIEW_FOLDER;
49 IconId = IDB_FOLDER_RENAME;
50 SetTitleText("Edit Folder Name");
51 }
52
~folder_name_dlg()53 folder_name_dlg::~folder_name_dlg()
54 {
55 }
56
DoDataExchange(CDataExchange * pDX)57 void folder_name_dlg::DoDataExchange(CDataExchange* pDX)
58 {
59 express_dialog::DoDataExchange(pDX);
60 DDX_Text(pDX, IDC_FOLDER_NAME, folder_name);
61 DDX_Text(pDX, IDC_FOLDER_OUTPUT_FILENAME, output_filename);
62 }
63
OnEnChangeFolderName()64 void folder_name_dlg::OnEnChangeFolderName()
65 {
66 // TODO: If this is a RICHEDIT control, the control will not
67 // send this notification unless you override the CDialog::OnInitDialog()
68 // function and call CRichEditCtrl().SetEventMask()
69 // with the ENM_CHANGE flag ORed into the mask.
70
71 // TODO: Add your control notification handler code here
72 }
73
74
OnInitDialog()75 BOOL folder_name_dlg::OnInitDialog()
76 {
77 express_dialog::OnInitDialog();
78
79 if (output_filename.IsEmpty())
80 {
81 /* output filename is empty means it hasn't been specified. So disable checkbox and edit control. */
82 ((CButton *)GetDlgItem(IDC_CUSTOM_FOLDER_OUTPUT))->SetCheck(FALSE);
83 GetDlgItem(IDC_FOLDER_OUTPUT_FILENAME)->EnableWindow(FALSE);
84 }
85 else
86 {
87 ((CButton *)GetDlgItem(IDC_CUSTOM_FOLDER_OUTPUT))->SetCheck(TRUE);
88 GetDlgItem(IDC_FOLDER_OUTPUT_FILENAME)->EnableWindow(TRUE);
89 }
90
91 /* Hide ouput file name edit Item and resize current window. */
92 if (input_item_type == TYPE_RESOURCE_FOLDER)
93 {
94 /* Hide item. */
95 GetDlgItem(IDC_CUSTOM_FOLDER_OUTPUT)->ShowWindow(FALSE);
96 GetDlgItem(IDC_FOLDER_OUTPUT_FILENAME)->ShowWindow(FALSE);
97
98 /* Resize window */
99 CRect window_size;
100 GetWindowRect(window_size);
101
102 /* Hard coded window size here. */
103 window_size.bottom -= 50;
104 MoveWindow(window_size);
105 }
106
107 SetControlAccessibleName(GetDlgItem(IDC_FOLDER_OUTPUT_FILENAME)->GetSafeHwnd(), _T("folder_output_filename"));
108
109 AddCancelButton();
110 AddSaveButton();
111
112 // TODO: Add extra initialization here
113
114 return TRUE; // return TRUE unless you set the focus to a control
115 // EXCEPTION: OCX Property Pages should return FALSE
116 }
117
GetEditFolderName(CString & new_folder_name) const118 void folder_name_dlg::GetEditFolderName(CString &new_folder_name) const
119 {
120 new_folder_name = folder_name;
121 }
122
GetSpecifiedOutputFileName(CString & output) const123 void folder_name_dlg::GetSpecifiedOutputFileName(CString &output) const
124 {
125 output = output_filename;
126 }
127
OnBnClickedCustomOutput()128 void folder_name_dlg::OnBnClickedCustomOutput()
129 {
130 // TODO: Add your control notification handler code here
131 CButton *pb = (CButton *)GetDlgItem(IDC_CUSTOM_FOLDER_OUTPUT);
132
133 if (pb->GetCheck())
134 {
135 GetDlgItem(IDC_FOLDER_OUTPUT_FILENAME)->EnableWindow(TRUE);
136 }
137 else
138 {
139 SetDlgItemText(IDC_FOLDER_OUTPUT_FILENAME, _T(""));
140 output_filename.Empty();
141 GetDlgItem(IDC_FOLDER_OUTPUT_FILENAME)->EnableWindow(FALSE);
142 }
143 }
144
OnOK()145 void folder_name_dlg::OnOK()
146 {
147 CString name;
148 GetDlgItemText(IDC_FOLDER_NAME, name);
149
150 if (name.IsEmpty())
151 {
152 Notify("Folder name could not be empty.", this);
153 return;
154 }
155
156 GetDlgItemText(IDC_FOLDER_OUTPUT_FILENAME, name);
157
158 if (IsFileNameFormat(name))
159 {
160 express_dialog::OnOK();
161 }
162 }
163
OnTestMessage(WPARAM wParam,LPARAM lParam)164 LRESULT folder_name_dlg::OnTestMessage(WPARAM wParam, LPARAM lParam)
165 {
166 CWnd *pWnd;
167
168 switch (wParam)
169 {
170 case TEST_SET_FOLDER_NAME:
171 SetDlgItemText(IDC_FOLDER_NAME, GetTestingParam(0));
172 break;
173
174 case TEST_SAVE_FOLDER_NAME_EDIT:
175 OnOK();
176 break;
177
178 case TEST_CHECK_SPECIFY_OUTPUT_FILE:
179 pWnd = GetDlgItem(IDC_CUSTOM_FOLDER_OUTPUT);
180 ((CButton *)pWnd)->SetCheck(lParam);
181 SendMessage(WM_COMMAND, MAKEWPARAM(IDC_CUSTOM_FOLDER_OUTPUT, BN_CLICKED), (LPARAM)pWnd->m_hWnd);
182 break;
183
184 case TEST_SET_FOLDER_OUTPUT_FILE_NAME:
185 SetDlgItemText(IDC_FOLDER_OUTPUT_FILENAME, GetTestingParam(0));
186 break;
187 }
188
189 return 0;
190 }