comparison host/tools/testtool/win32/ExecutionPage.cpp @ 82:6736c52df507 ecos-sw-2000-04-14

Merge from eCos master repository on 2000-04-14-13:35:46-BST
author jlarmour
date Tue, 18 Apr 2000 21:51:55 +0000
parents 435cced73e2f
children 74dbf4c3f2e1
comparison
equal deleted inserted replaced
81:89fef2181d7d 82:6736c52df507
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 // 21 //
22 // ---------------------------------------------------------------------------- 22 // ----------------------------------------------------------------------------
23 // 23 //
24 //####COPYRIGHTEND#### 24 //####COPYRIGHTEND####
25 // ExecutionPage.cpp : implementation file 25 // ExecutionPage.cpp : implementation file
26 // 26 //
27 #include "stdafx.h" 27 #include "stdafx.h"
28 #include "ExecutionPage.h" 28 #include "ExecutionPage.h"
29 #include "shlobj.h" 29 #include "shlobj.h"
30 #include "RunTestsSheet.h" 30 #include "RunTestsSheet.h"
41 const UINT arIds []={IDC_TT_SELECT_ALL,IDC_TT_UNSELECT_ALL,IDC_TT_ADD, IDC_TT_FOLDER, IDC_TT_REMOVE}; 41 const UINT arIds []={IDC_TT_SELECT_ALL,IDC_TT_UNSELECT_ALL,IDC_TT_ADD, IDC_TT_FOLDER, IDC_TT_REMOVE};
42 42
43 IMPLEMENT_DYNCREATE(CExecutionPage, CeCosPropertyPage) 43 IMPLEMENT_DYNCREATE(CExecutionPage, CeCosPropertyPage)
44 44
45 CExecutionPage::CExecutionPage() : 45 CExecutionPage::CExecutionPage() :
46 CeCosPropertyPage(IDD_TT_EXECUTION_PAGE) 46 CeCosPropertyPage(IDD_TT_EXECUTION_PAGE),
47 { 47 m_strExtension(_T("*.exe"))
48 GetCurrentDirectory(MAX_PATH,m_strFolder.GetBuffer(MAX_PATH)); 48 {
49 m_strFolder.ReleaseBuffer(); 49 GetCurrentDirectory(MAX_PATH,m_strFolder.GetBuffer(MAX_PATH));
50 //{{AFX_DATA_INIT(CExecutionPage) 50 m_strFolder.ReleaseBuffer();
51 //{{AFX_DATA_INIT(CExecutionPage)
51 // NOTE: the ClassWizard will add member initialization here 52 // NOTE: the ClassWizard will add member initialization here
52 //}}AFX_DATA_INIT 53 //}}AFX_DATA_INIT
53 } 54 }
54 55
55 CExecutionPage::~CExecutionPage() 56 CExecutionPage::~CExecutionPage()
56 { 57 {
57 } 58 }
58 59
59 void CExecutionPage::DoDataExchange(CDataExchange* pDX) 60 void CExecutionPage::DoDataExchange(CDataExchange* pDX)
60 { 61 {
61 CeCosPropertyPage::DoDataExchange(pDX); 62 CeCosPropertyPage::DoDataExchange(pDX);
62 //{{AFX_DATA_MAP(CExecutionPage) 63 //{{AFX_DATA_MAP(CExecutionPage)
63 DDX_Control(pDX, IDC_TT_RUNTESTS_LIST, m_List); 64 DDX_Control(pDX, IDC_TT_RUNTESTS_LIST, m_List);
64 //}}AFX_DATA_MAP 65 //}}AFX_DATA_MAP
65 } 66 }
66 67
67 68
68 BEGIN_MESSAGE_MAP(CExecutionPage, CeCosPropertyPage) 69 BEGIN_MESSAGE_MAP(CExecutionPage, CeCosPropertyPage)
69 //{{AFX_MSG_MAP(CExecutionPage) 70 //{{AFX_MSG_MAP(CExecutionPage)
70 ON_BN_CLICKED(IDC_TT_FOLDER, OnFolder) 71 ON_BN_CLICKED(IDC_TT_FOLDER, OnFolder)
71 ON_BN_CLICKED(IDC_TT_SELECT_ALL, OnSelectAll) 72 ON_BN_CLICKED(IDC_TT_SELECT_ALL, OnSelectAll)
72 ON_BN_CLICKED(IDC_TT_UNSELECT_ALL, OnUnselectAll) 73 ON_BN_CLICKED(IDC_TT_UNSELECT_ALL, OnUnselectAll)
73 ON_BN_CLICKED(IDC_TT_ADD, OnAdd) 74 ON_BN_CLICKED(IDC_TT_ADD, OnAdd)
74 ON_BN_CLICKED(IDC_TT_REMOVE, OnRemove) 75 ON_BN_CLICKED(IDC_TT_REMOVE, OnRemove)
75 ON_WM_SIZE() 76 ON_WM_SIZE()
76 ON_MESSAGE(WM_KICKIDLE, OnKickIdle) 77 ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
77 ON_WM_CHAR() 78 ON_WM_CHAR()
78 //}}AFX_MSG_MAP 79 //}}AFX_MSG_MAP
79 END_MESSAGE_MAP() 80 END_MESSAGE_MAP()
80 81
81 ///////////////////////////////////////////////////////////////////////////// 82 /////////////////////////////////////////////////////////////////////////////
82 // CExecutionPage message handlers 83 // CExecutionPage message handlers
83 CExecutionPage *CExecutionPage::pDlg=NULL; 84 CExecutionPage *CExecutionPage::pDlg=NULL;
84 LRESULT CALLBACK CExecutionPage::WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam) 85 LRESULT CALLBACK CExecutionPage::WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam)
85 { 86 {
86 if (message == WM_COMMAND) { 87 if (message == WM_COMMAND) {
87 switch(wParam){ 88 switch(wParam){
88 case MAKEWPARAM(IDC_TT_RECURSE,BN_CLICKED): 89 case MAKEWPARAM(IDC_TT_RECURSE,BN_CLICKED):
89 pDlg->m_bRecurse ^= 1; 90 pDlg->m_bRecurse ^= 1;
90 pDlg->m_Button.SetCheck(pDlg->m_bRecurse); 91 pDlg->m_Button.SetCheck(pDlg->m_bRecurse);
91 return 0; 92 return 0;
92 case MAKEWPARAM(IDC_TT_EXTENSION,EN_CHANGE): 93 case MAKEWPARAM(IDC_TT_EXTENSION,EN_CHANGE):
93 pDlg->m_Combo.GetWindowText(pDlg->m_strExtension); 94 {
94 return 0; 95 CString str;
95 default: 96 pDlg->m_Combo.GetWindowText(str);
96 break; 97 pDlg->m_strExtension=(LPCTSTR)str;
97 } 98 }
98 } 99 return 0;
99 return CallWindowProc(pDlg->m_wndProc, hwnd, message, wParam, lParam); 100 default:
100 } 101 break;
101 102 }
103 }
104 return CallWindowProc(pDlg->m_wndProc, hwnd, message, wParam, lParam);
105 }
106
102 int CALLBACK CExecutionPage::CBBrowseCallbackProc( HWND hwnd, 107 int CALLBACK CExecutionPage::CBBrowseCallbackProc( HWND hwnd,
103 UINT uMsg, 108 UINT uMsg,
104 LPARAM lParam, 109 LPARAM lParam,
105 LPARAM lpData 110 LPARAM lpData
106 ) 111 )
107 { 112 {
108 pDlg=(CExecutionPage *)lpData; 113 pDlg=(CExecutionPage *)lpData;
109 switch(uMsg){ 114 switch(uMsg){
110 case BFFM_INITIALIZED: 115 case BFFM_INITIALIZED:
111 { 116 {
112 ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)(LPCTSTR)pDlg->m_strFolder); 117 ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)(LPCTSTR)pDlg->m_strFolder);
113 CWnd *pWnd=CWnd::FromHandle(hwnd); 118 CWnd *pWnd=CWnd::FromHandle(hwnd);
114 pWnd->SetWindowText(_T("Add Files from Folder")); 119 pWnd->SetWindowText(_T("Add Files from Folder"));
115 120
116 // Get rect of IDCANCEL button to the right 121 // Get rect of IDCANCEL button to the right
117 CRect rect,rect1,rect2; 122 CRect rect,rect1,rect2;
118 pWnd->GetDlgItem(IDCANCEL)->GetWindowRect(&rect1); 123 pWnd->GetDlgItem(IDCANCEL)->GetWindowRect(&rect1);
119 pWnd->GetWindowRect(&rect2); 124 pWnd->GetWindowRect(&rect2);
120 int nDlgMargin=rect2.right-rect1.right; 125 int nDlgMargin=rect2.right-rect1.right;
121 int nButtonHeight=rect1.Height(); 126 int nButtonHeight=rect1.Height();
122 rect.left=rect.top=nDlgMargin; 127 rect.left=rect.top=nDlgMargin;
123 rect.right=rect.left+6*nButtonHeight; 128 rect.right=rect.left+6*nButtonHeight;
124 rect.bottom=rect.top+(10*nButtonHeight)/14; 129 rect.bottom=rect.top+(10*nButtonHeight)/14;
125 WPARAM wFont=(WPARAM)GetStockObject(DEFAULT_GUI_FONT); 130 WPARAM wFont=(WPARAM)GetStockObject(DEFAULT_GUI_FONT);
126 pDlg->m_Button.CreateEx(0,_T("BUTTON"),NULL, WS_VISIBLE|WS_CHILD|BS_CHECKBOX, rect, pWnd, IDC_TT_RECURSE); 131 pDlg->m_Button.CreateEx(0,_T("BUTTON"),NULL, WS_VISIBLE|WS_CHILD|BS_CHECKBOX, rect, pWnd, IDC_TT_RECURSE);
127 pDlg->m_Button.SetWindowText(_T("&Add from subfolders")); 132 pDlg->m_Button.SetWindowText(_T("&Add from subfolders"));
128 pDlg->m_Button.SendMessage(WM_SETFONT, wFont, 0); 133 pDlg->m_Button.SendMessage(WM_SETFONT, wFont, 0);
129 pDlg->m_Button.SetCheck(pDlg->m_bRecurse); 134 pDlg->m_Button.SetCheck(pDlg->m_bRecurse);
130 135
131 rect.left=rect.right+(4*nButtonHeight)/14; 136 rect.left=rect.right+(4*nButtonHeight)/14;
132 rect.right=rect.left+3*nButtonHeight; 137 rect.right=rect.left+3*nButtonHeight;
133 rect.bottom+=2*GetSystemMetrics(SM_CYBORDER)+4; 138 rect.bottom+=2*GetSystemMetrics(SM_CYBORDER)+4;
134 pDlg->m_Static.Create(_T("Files of type:"),WS_VISIBLE|WS_CHILD|SS_LEFT, rect, pWnd); 139 pDlg->m_Static.Create(_T("Files of type:"),WS_VISIBLE|WS_CHILD|SS_LEFT, rect, pWnd);
135 pDlg->m_Static.SendMessage(WM_SETFONT, wFont, 0); 140 pDlg->m_Static.SendMessage(WM_SETFONT, wFont, 0);
136 rect.bottom-=2*GetSystemMetrics(SM_CYBORDER)+4; 141 rect.bottom-=2*GetSystemMetrics(SM_CYBORDER)+4;
137 142
138 rect.left=rect.right+(4*nButtonHeight)/14; 143 rect.left=rect.right+(4*nButtonHeight)/14;
139 rect.right=rect.left+3*nButtonHeight; 144 rect.right=rect.left+3*nButtonHeight;
140 //rect.bottom=rect.top+2*nButtonHeight; 145 //rect.bottom=rect.top+2*nButtonHeight;
141 rect.top=rect.bottom-(12*nButtonHeight)/14; 146 rect.top=rect.bottom-(12*nButtonHeight)/14;
142 pDlg->m_Combo.CreateEx(WS_EX_CLIENTEDGE,_T("Edit"),NULL,WS_VISIBLE|WS_CHILD|WS_BORDER|ES_LEFT/*|CBS_DROPDOWN*/, rect, pWnd, IDC_TT_EXTENSION); 147 pDlg->m_Combo.CreateEx(WS_EX_CLIENTEDGE,_T("Edit"),NULL,WS_VISIBLE|WS_CHILD|WS_BORDER|ES_LEFT/*|CBS_DROPDOWN*/, rect, pWnd, IDC_TT_EXTENSION);
143 //pDlg->m_Combo.AddString(pDlg->m_strExtension); 148 //pDlg->m_Combo.AddString(pDlg->m_strExtension);
144 //pDlg->m_Combo.SetCurSel(0); 149 //pDlg->m_Combo.SetCurSel(0);
145 pDlg->m_Combo.SetWindowText(pDlg->m_strExtension); 150 pDlg->m_Combo.SetWindowText(pDlg->m_strExtension);
146 pDlg->m_Combo.SendMessage(WM_SETFONT, wFont, 0); 151 pDlg->m_Combo.SendMessage(WM_SETFONT, wFont, 0);
147 152
148 pDlg->m_wndProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (long)WindowProcNew); 153 pDlg->m_wndProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (long)WindowProcNew);
149 154
150 } 155 }
151 case BFFM_SELCHANGED: 156 case BFFM_SELCHANGED:
152 { 157 {
153 // Change the cwd such that if the New button is used, we know where we are to start from 158 // Change the cwd such that if the New button is used, we know where we are to start from
154 ITEMIDLIST *iil=(ITEMIDLIST *)lParam; 159 ITEMIDLIST *iil=(ITEMIDLIST *)lParam;
155 CString strFolder; 160 CString strFolder;
156 SHGetPathFromIDList(iil,strFolder.GetBuffer(MAX_PATH)); 161 SHGetPathFromIDList(iil,strFolder.GetBuffer(MAX_PATH));
157 strFolder.ReleaseBuffer(); 162 strFolder.ReleaseBuffer();
158 SetCurrentDirectory(strFolder); 163 SetCurrentDirectory(strFolder);
159 } 164 }
160 break; 165 break;
161 default: 166 default:
162 ; 167 ;
163 } 168 }
164 169
165 return 0; 170 return 0;
166 } 171 }
167 172
168 void CExecutionPage::OnFolder() 173 void CExecutionPage::OnFolder()
169 { 174 {
170 175
171 BROWSEINFO bi; 176 BROWSEINFO bi;
172 bi.hwndOwner = GetSafeHwnd(); 177 bi.hwndOwner = GetSafeHwnd();
173 bi.pidlRoot = NULL; 178 bi.pidlRoot = NULL;
174 bi.pszDisplayName = m_strFolder.GetBuffer(MAX_PATH); 179 bi.pszDisplayName = m_strFolder.GetBuffer(MAX_PATH);
175 bi.lpszTitle = _T(""); 180 bi.lpszTitle = _T("");
176 bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT/*|0x0010 BIF_EDITBOX*/; 181 bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT/*|0x0010 BIF_EDITBOX*/;
177 bi.lpfn = (BFFCALLBACK)CBBrowseCallbackProc; 182 bi.lpfn = (BFFCALLBACK)CBBrowseCallbackProc;
178 bi.lParam = (LPARAM)this; 183 bi.lParam = (LPARAM)this;
179 184
180 bool bSaveRecurse=m_bRecurse; 185 bool bSaveRecurse=m_bRecurse;
181 LPITEMIDLIST iil = SHBrowseForFolder(&bi); 186 LPITEMIDLIST iil = SHBrowseForFolder(&bi);
182 m_strFolder.ReleaseBuffer(); 187 m_strFolder.ReleaseBuffer();
183 if(iil){ 188 if(iil){
184 SHGetPathFromIDList(iil,m_strFolder.GetBuffer(MAX_PATH)); 189 SHGetPathFromIDList(iil,m_strFolder.GetBuffer(MAX_PATH));
185 m_strFolder.ReleaseBuffer(); 190 m_strFolder.ReleaseBuffer();
186 SetModified(); 191 SetModified();
187 FillListBox(m_strFolder); 192 FillListBox(m_strFolder);
188 } else { 193 } else {
189 m_bRecurse=bSaveRecurse; 194 m_bRecurse=bSaveRecurse;
190 } 195 }
191 196
192 } 197 }
193 198
194 /* 199 /*
195 void CExecutionPage::OnRefresh() 200 void CExecutionPage::OnRefresh()
196 { 201 {
197 FillListBox(m_strFolder); 202 FillListBox(m_strFolder);
198 } 203 }
199 */ 204 */
200 205
201 void CExecutionPage::FillListBox(LPCTSTR pszFolder) 206 void CExecutionPage::FillListBox(LPCTSTR pszFolder)
202 { 207 {
238 GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(m_List.GetCount()>0); 243 GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(m_List.GetCount()>0);
239 } 244 }
240 245
241 void CExecutionPage::OnSelectAll() 246 void CExecutionPage::OnSelectAll()
242 { 247 {
243 for(int i=0;i<m_List.GetCount();i++){ 248 for(int i=0;i<m_List.GetCount();i++){
244 m_List.SetCheck(i,TRUE); 249 m_List.SetCheck(i,TRUE);
245 } 250 }
246 } 251 }
247 252
248 void CExecutionPage::OnUnselectAll() 253 void CExecutionPage::OnUnselectAll()
249 { 254 {
250 for(int i=0;i<m_List.GetCount();i++){ 255 for(int i=0;i<m_List.GetCount();i++){
251 m_List.SetCheck(i,FALSE); 256 m_List.SetCheck(i,FALSE);
252 } 257 }
253 } 258 }
254 259
255 bool CExecutionPage::IsSelected(int i) 260 bool CExecutionPage::IsSelected(int i)
256 { 261 {
257 return TRUE==m_List.GetCheck(i); 262 return TRUE==m_List.GetCheck(i);
258 } 263 }
259 264
260 void CExecutionPage::OnAdd() 265 void CExecutionPage::OnAdd()
261 { 266 {
262 CFileDialog dlg(TRUE, _T("exe"), _T("*.exe"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST, 267 CFileDialog dlg(TRUE, _T("exe"), _T("*.exe"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,
295 } 300 }
296 301
297 302
298 int CExecutionPage::SelectedTestCount() 303 int CExecutionPage::SelectedTestCount()
299 { 304 {
300 int n=0; 305 int n=0;
301 if(IsWindow(m_List.m_hWnd)){ 306 if(IsWindow(m_List.m_hWnd)){
302 for(int i=0;i<m_List.GetCount();i++){ 307 for(int i=0;i<m_List.GetCount();i++){
303 n+=m_List.GetCheck(i); 308 n+=m_List.GetCheck(i);
304 } 309 }
305 } 310 }
306 return n; 311 return n;
307 } 312 }
308 313
309 CString CExecutionPage::SelectedTest(int nIndex) 314 CString CExecutionPage::SelectedTest(int nIndex)
310 { 315 {
311 CString str; 316 CString str;
312 for(int i=0;i<m_List.GetCount();i++){ 317 for(int i=0;i<m_List.GetCount();i++){
313 if(m_List.GetCheck(i)){ 318 if(m_List.GetCheck(i)){
314 if(0==nIndex--){ 319 if(0==nIndex--){
315 m_List.GetText(i,str); 320 m_List.GetText(i,str);
316 break; 321 break;
317 } 322 }
318 } 323 }
319 } 324 }
320 return str; 325 return str;
321 326
322 } 327 }
323 328
324 BOOL CExecutionPage::OnInitDialog() 329 BOOL CExecutionPage::OnInitDialog()
325 { 330 {
326 CeCosPropertyPage::OnInitDialog(); 331 CeCosPropertyPage::OnInitDialog();
327 for(POSITION pos = m_arstrPreLoad.GetStartPosition(); pos != NULL; ){ 332 for(POSITION pos = m_arstrPreLoad.GetStartPosition(); pos != NULL; ){
328 CString strFile; 333 CString strFile;
329 void *p; 334 void *p;
330 m_arstrPreLoad.GetNextAssoc( pos, strFile,p); 335 m_arstrPreLoad.GetNextAssoc( pos, strFile,p);
331 m_List.SetCheck(m_List.AddString(strFile),0!=p); 336 m_List.SetCheck(m_List.AddString(strFile),0!=p);
380 } 385 }
381 } 386 }
382 387
383 LRESULT CExecutionPage::OnKickIdle(WPARAM, LPARAM) 388 LRESULT CExecutionPage::OnKickIdle(WPARAM, LPARAM)
384 { 389 {
385 if(IsWindow(m_List.m_hWnd)){ 390 if(IsWindow(m_List.m_hWnd)){
386 int n=m_List.GetCount(); 391 int n=m_List.GetCount();
387 bool bSelectAll=false; 392 bool bSelectAll=false;
388 bool bUnSelectAll=false; 393 bool bUnSelectAll=false;
389 if(n>0){ 394 if(n>0){
390 bool bPrev=false; 395 bool bPrev=false;
391 for(int i=0;i<n;i++){ 396 for(int i=0;i<n;i++){
392 bool bCheck=(TRUE==m_List.GetCheck(i)); 397 bool bCheck=(TRUE==m_List.GetCheck(i));
393 if(bCheck){ 398 if(bCheck){
394 bUnSelectAll=true; 399 bUnSelectAll=true;
395 } else { 400 } else {
396 bSelectAll=true; 401 bSelectAll=true;
397 }
398 if(i>0 && bCheck!=bPrev){
399 break;
400 }
401 bPrev=bCheck;
402 }
403 } 402 }
404 GetDlgItem(IDC_TT_SELECT_ALL)->EnableWindow(bSelectAll); 403 if(i>0 && bCheck!=bPrev){
405 GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(bUnSelectAll); 404 break;
406 } 405 }
407 return 0; 406 bPrev=bCheck;
407 }
408 }
409 GetDlgItem(IDC_TT_SELECT_ALL)->EnableWindow(bSelectAll);
410 GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(bUnSelectAll);
411 }
412 return 0;
408 } 413 }
409 414
410 bool CExecutionPage::SomeTestsSelected() 415 bool CExecutionPage::SomeTestsSelected()
411 { 416 {
412 bool b=0; 417 bool b=0;
413 if(IsWindow(m_List.m_hWnd)){ 418 if(IsWindow(m_List.m_hWnd)){
414 for(int i=0;i<m_List.GetCount();i++){ 419 for(int i=0;i<m_List.GetCount();i++){
415 if(m_List.GetCheck(i)){ 420 if(m_List.GetCheck(i)){
416 b=true; 421 b=true;
417 break; 422 break;
418 } 423 }
419 } 424 }
420 } 425 }
421 return b; 426 return b;
422 427
423 } 428 }
424 429
425 void CExecutionPage::OnRemove() 430 void CExecutionPage::OnRemove()
426 { 431 {
427 m_List.SendMessage(WM_COMMAND,IDC_TT_REMOVE,0); 432 m_List.SendMessage(WM_COMMAND,IDC_TT_REMOVE,0);