OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [testtool/] [win32/] [ExecutionPage.cpp] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// ExecutionPage.cpp : implementation file
23
//
24
#include "stdafx.h"
25
#include "ExecutionPage.h"
26
#include "shlobj.h"
27
#include "RunTestsSheet.h"
28
#include <afxpriv.h> // for WM_KICKIDLE
29
#ifdef _DEBUG
30
#define new DEBUG_NEW
31
#undef THIS_FILE
32
static char THIS_FILE[] = __FILE__;
33
#endif
34
 
35
/////////////////////////////////////////////////////////////////////////////
36
// CExecutionPage property page
37
 
38
const UINT arIds []={IDC_TT_SELECT_ALL,IDC_TT_UNSELECT_ALL,IDC_TT_ADD, IDC_TT_FOLDER, IDC_TT_REMOVE};
39
 
40
IMPLEMENT_DYNCREATE(CExecutionPage, CeCosPropertyPage)
41
 
42
CExecutionPage::CExecutionPage() :
43
  CeCosPropertyPage(IDD_TT_EXECUTION_PAGE),
44
  m_strExtension(_T("*.exe"))
45
{
46
  GetCurrentDirectory(MAX_PATH,m_strFolder.GetBuffer(MAX_PATH));
47
  m_strFolder.ReleaseBuffer();
48
  //{{AFX_DATA_INIT(CExecutionPage)
49
                // NOTE: the ClassWizard will add member initialization here
50
  //}}AFX_DATA_INIT
51
}
52
 
53
CExecutionPage::~CExecutionPage()
54
{
55
}
56
 
57
void CExecutionPage::DoDataExchange(CDataExchange* pDX)
58
{
59
  CeCosPropertyPage::DoDataExchange(pDX);
60
  //{{AFX_DATA_MAP(CExecutionPage)
61
  DDX_Control(pDX, IDC_TT_RUNTESTS_LIST, m_List);
62
  //}}AFX_DATA_MAP
63
}
64
 
65
 
66
BEGIN_MESSAGE_MAP(CExecutionPage, CeCosPropertyPage)
67
//{{AFX_MSG_MAP(CExecutionPage)
68
ON_BN_CLICKED(IDC_TT_FOLDER, OnFolder)
69
ON_BN_CLICKED(IDC_TT_SELECT_ALL, OnSelectAll)
70
ON_BN_CLICKED(IDC_TT_UNSELECT_ALL, OnUnselectAll)
71
ON_BN_CLICKED(IDC_TT_ADD, OnAdd)
72
ON_BN_CLICKED(IDC_TT_REMOVE, OnRemove)
73
ON_WM_SIZE()
74
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
75
ON_WM_CHAR()
76
//}}AFX_MSG_MAP
77
END_MESSAGE_MAP()
78
 
79
/////////////////////////////////////////////////////////////////////////////
80
// CExecutionPage message handlers
81
CExecutionPage *CExecutionPage::pDlg=NULL;
82
LRESULT CALLBACK CExecutionPage::WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam)
83
{
84
  if (message ==  WM_COMMAND) {
85
    switch(wParam){
86
    case MAKEWPARAM(IDC_TT_RECURSE,BN_CLICKED):
87
      pDlg->m_bRecurse ^= 1;
88
      pDlg->m_Button.SetCheck(pDlg->m_bRecurse);
89
      return 0;
90
    case MAKEWPARAM(IDC_TT_EXTENSION,EN_CHANGE):
91
      {
92
        CString str;
93
        pDlg->m_Combo.GetWindowText(str);
94
        pDlg->m_strExtension=(LPCTSTR)str;
95
      }
96
      return 0;
97
    default:
98
      break;
99
    }
100
  }
101
  return CallWindowProc(pDlg->m_wndProc, hwnd, message, wParam, lParam);
102
}
103
 
104
int CALLBACK CExecutionPage::CBBrowseCallbackProc( HWND hwnd,
105
                                                  UINT uMsg,
106
                                                  LPARAM lParam,
107
                                                  LPARAM lpData
108
                                                  )
109
{
110
  pDlg=(CExecutionPage *)lpData;
111
  switch(uMsg){
112
  case BFFM_INITIALIZED:
113
    {
114
      ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)(LPCTSTR)pDlg->m_strFolder);
115
      CWnd *pWnd=CWnd::FromHandle(hwnd);
116
      pWnd->SetWindowText(_T("Add Files from Folder"));
117
 
118
      // Get rect of IDCANCEL button to the right
119
      CRect rect,rect1,rect2;
120
      pWnd->GetDlgItem(IDCANCEL)->GetWindowRect(&rect1);
121
      pWnd->GetWindowRect(&rect2);
122
      int nDlgMargin=rect2.right-rect1.right;
123
      int nButtonHeight=rect1.Height();
124
      rect.left=rect.top=nDlgMargin;
125
      rect.right=rect.left+6*nButtonHeight;
126
      rect.bottom=rect.top+(10*nButtonHeight)/14;
127
      WPARAM wFont=(WPARAM)GetStockObject(DEFAULT_GUI_FONT);
128
      pDlg->m_Button.CreateEx(0,_T("BUTTON"),NULL, WS_VISIBLE|WS_CHILD|BS_CHECKBOX, rect, pWnd, IDC_TT_RECURSE);
129
      pDlg->m_Button.SetWindowText(_T("&Add from subfolders"));
130
      pDlg->m_Button.SendMessage(WM_SETFONT, wFont, 0);
131
      pDlg->m_Button.SetCheck(pDlg->m_bRecurse);
132
 
133
      rect.left=rect.right+(4*nButtonHeight)/14;
134
      rect.right=rect.left+3*nButtonHeight;
135
      rect.bottom+=2*GetSystemMetrics(SM_CYBORDER)+4;
136
      pDlg->m_Static.Create(_T("Files of type:"),WS_VISIBLE|WS_CHILD|SS_LEFT, rect, pWnd);
137
      pDlg->m_Static.SendMessage(WM_SETFONT, wFont, 0);
138
      rect.bottom-=2*GetSystemMetrics(SM_CYBORDER)+4;
139
 
140
      rect.left=rect.right+(4*nButtonHeight)/14;
141
      rect.right=rect.left+3*nButtonHeight;
142
      //rect.bottom=rect.top+2*nButtonHeight;
143
      rect.top=rect.bottom-(12*nButtonHeight)/14;
144
      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);
145
      //pDlg->m_Combo.AddString(pDlg->m_strExtension);
146
      //pDlg->m_Combo.SetCurSel(0);
147
      pDlg->m_Combo.SetWindowText(pDlg->m_strExtension);
148
      pDlg->m_Combo.SendMessage(WM_SETFONT, wFont, 0);
149
 
150
      pDlg->m_wndProc = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (long)WindowProcNew);
151
 
152
    }
153
  case BFFM_SELCHANGED:
154
    {
155
      // Change the cwd such that if the New button is used, we know where we are to start from
156
      ITEMIDLIST *iil=(ITEMIDLIST *)lParam;
157
      CString strFolder;
158
      SHGetPathFromIDList(iil,strFolder.GetBuffer(MAX_PATH));
159
      strFolder.ReleaseBuffer();
160
      SetCurrentDirectory(strFolder);
161
    }
162
    break;
163
  default:
164
    ;
165
  }
166
 
167
  return 0;
168
}
169
 
170
void CExecutionPage::OnFolder()
171
{
172
 
173
  BROWSEINFO bi;
174
  bi.hwndOwner = GetSafeHwnd();
175
  bi.pidlRoot = NULL;
176
  bi.pszDisplayName = m_strFolder.GetBuffer(MAX_PATH);
177
  bi.lpszTitle = _T("");
178
  bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT/*|0x0010 BIF_EDITBOX*/;
179
  bi.lpfn = (BFFCALLBACK)CBBrowseCallbackProc;
180
  bi.lParam = (LPARAM)this;
181
 
182
  bool bSaveRecurse=m_bRecurse;
183
  LPITEMIDLIST iil = SHBrowseForFolder(&bi);
184
  m_strFolder.ReleaseBuffer();
185
  if(iil){
186
    SHGetPathFromIDList(iil,m_strFolder.GetBuffer(MAX_PATH));
187
    m_strFolder.ReleaseBuffer();
188
    SetModified();
189
    FillListBox(m_strFolder);
190
  } else {
191
    m_bRecurse=bSaveRecurse;
192
  }
193
 
194
}
195
 
196
/*
197
void CExecutionPage::OnRefresh()
198
{
199
FillListBox(m_strFolder);
200
}
201
*/
202
 
203
void CExecutionPage::FillListBox(LPCTSTR pszFolder)
204
{
205
  CWaitCursor wait;
206
  CString strOldFolder;
207
  ::GetCurrentDirectory(MAX_PATH,strOldFolder.GetBuffer(MAX_PATH));
208
  strOldFolder.ReleaseBuffer();
209
 
210
  if(::SetCurrentDirectory(pszFolder)){
211
    int nCount=m_List.GetCount();
212
    m_List.Dir(DDL_READWRITE,m_strExtension);
213
    for(int i=nCount;i<m_List.GetCount();i++){
214
      TCHAR strFull[1+MAX_PATH];
215
      CString str;
216
      m_List.GetText(i,str);
217
      TCHAR *pFile;
218
      ::GetFullPathName(str,MAX_PATH,strFull,&pFile);
219
      m_List.DeleteString(i);
220
      if(LB_ERR==m_List.FindStringExact(-1,strFull)){
221
        m_List.InsertString(i,strFull);
222
        m_List.SetCheck(i,TRUE);
223
      } else {
224
        --i;
225
      }
226
    }
227
    if(m_bRecurse){
228
                    CFileFind finder;
229
        BOOL bMore=finder.FindFile();
230
        while (bMore)    {
231
          bMore = finder.FindNextFile();
232
          if(finder.IsDirectory() && !finder.IsDots()){
233
            FillListBox(finder.GetFileName());
234
          }
235
        }
236
    }
237
    ::SetCurrentDirectory(strOldFolder);
238
  }
239
  GetDlgItem(IDC_TT_SELECT_ALL)->EnableWindow(m_List.GetCount()>0);
240
  GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(m_List.GetCount()>0);
241
}
242
 
243
void CExecutionPage::OnSelectAll()
244
{
245
  for(int i=0;i<m_List.GetCount();i++){
246
    m_List.SetCheck(i,TRUE);
247
  }
248
}
249
 
250
void CExecutionPage::OnUnselectAll()
251
{
252
  for(int i=0;i<m_List.GetCount();i++){
253
    m_List.SetCheck(i,FALSE);
254
  }
255
}
256
 
257
bool CExecutionPage::IsSelected(int i)
258
{
259
  return TRUE==m_List.GetCheck(i);
260
}
261
 
262
void CExecutionPage::OnAdd()
263
{
264
  CFileDialog dlg(TRUE, _T("exe"), _T("*.exe"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,
265
    _T("Executables(*.exe)\0*.exe\0"));
266
  dlg.m_ofn.lpstrTitle=_T("Add");
267
  if(IDOK==dlg.DoModal()){
268
    LPCTSTR pszDir=dlg.m_ofn.lpstrFile;
269
    DWORD dwAttr=GetFileAttributes(pszDir);
270
    if(0xFFFFFFFF!=dwAttr){
271
      bool bErr=false;
272
      if(dwAttr&FILE_ATTRIBUTE_DIRECTORY){
273
        for(LPCTSTR c=pszDir+_tcslen(pszDir)+1;_TCHAR('\0')!=*c;c+=_tcslen(c)+1){
274
          CString str(pszDir);
275
          str+=_TCHAR('\\');
276
          str+=c;
277
          if(LB_ERR==m_List.FindStringExact(-1,str)){
278
            m_List.SetCheck(m_List.AddString(str),TRUE);
279
          } else {
280
            bErr=true;
281
          }
282
        }
283
      } else {
284
        if(LB_ERR==m_List.FindStringExact(-1,pszDir)){
285
          m_List.SetCheck(m_List.AddString(pszDir),TRUE);
286
        } else {
287
          bErr=true;
288
        }
289
      }
290
      if(bErr){
291
        MessageBox(_T("One or more of the files was already present"));
292
      }
293
    }
294
  }
295
  GetDlgItem(IDC_TT_SELECT_ALL)->EnableWindow(m_List.GetCount()>0);
296
  GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(m_List.GetCount()>0);
297
}
298
 
299
 
300
int CExecutionPage::SelectedTestCount()
301
{
302
  int n=0;
303
  if(IsWindow(m_List.m_hWnd)){
304
    for(int i=0;i<m_List.GetCount();i++){
305
      n+=m_List.GetCheck(i);
306
    }
307
  }
308
  return n;
309
}
310
 
311
CString CExecutionPage::SelectedTest(int nIndex)
312
{
313
  CString str;
314
  for(int i=0;i<m_List.GetCount();i++){
315
    if(m_List.GetCheck(i)){
316
      if(0==nIndex--){
317
        m_List.GetText(i,str);
318
        break;
319
      }
320
    }
321
  }
322
  return str;
323
 
324
}
325
 
326
BOOL CExecutionPage::OnInitDialog()
327
{
328
  CeCosPropertyPage::OnInitDialog();
329
  for(POSITION pos = m_arstrPreLoad.GetStartPosition(); pos != NULL; ){
330
    CString strFile;
331
    void *p;
332
    m_arstrPreLoad.GetNextAssoc( pos, strFile,p);
333
    m_List.SetCheck(m_List.AddString(strFile),0!=p);
334
  }
335
  return TRUE;  // return TRUE unless you set the focus to a control
336
  // EXCEPTION: OCX Property Pages should return FALSE
337
}
338
 
339
void CExecutionPage::OnSize(UINT nType, int cx, int cy)
340
{
341
  CRect rect;
342
  GetClientRect(rect);
343
  CeCosPropertyPage::OnSize(nType, cx, cy);
344
 
345
  CWnd *pWnd=GetDlgItem(IDC_TT_RUNTESTS_LIST);
346
  if(pWnd){
347
    ((CRunTestsSheet*)GetParent())->MoveWindow(pWnd,CRunTestsSheet::Stretch);
348
    const int nWnds=sizeof(arIds)/sizeof(arIds[0]);
349
    CRect rc[nWnds];
350
 
351
    CWnd *pWnd0=GetDlgItem(arIds[0]);
352
    ((CRunTestsSheet*)GetParent())->MoveWindow(pWnd0,CRunTestsSheet::TopLeft);
353
    CWnd *pWndn=GetDlgItem(arIds[nWnds-1]);
354
    ((CRunTestsSheet*)GetParent())->MoveWindow(pWndn,CRunTestsSheet::TopRight);
355
 
356
    CRect rect0;
357
    pWnd0->GetWindowRect(rect0);
358
    ScreenToClient(rect0);
359
 
360
    CRect rectn;
361
    pWndn->GetWindowRect(rectn);
362
    ScreenToClient(rectn);
363
 
364
    int nSpacing=(rectn.left-rect0.left)/(nWnds-1);
365
    for(int i=1;i<nWnds-1;i++){
366
      CRect rect;
367
      rect.left=rect0.left+i*nSpacing;
368
      rect.right=rect.left+rect0.Width();
369
      rect.top=rect0.top;
370
      rect.bottom=rect0.bottom;
371
      pWnd=GetDlgItem(arIds[i]);
372
      pWnd->GetWindowRect(rc[i]);
373
      ScreenToClient(rc[i]);
374
      pWnd->MoveWindow(rect);
375
    }
376
 
377
    for(i=0;i<sizeof(arIds)/sizeof(arIds[0]);i++){
378
      InvalidateRect(rc[i]);
379
      GetDlgItem(arIds[i])->Invalidate();
380
    }
381
 
382
  }
383
}
384
 
385
LRESULT CExecutionPage::OnKickIdle(WPARAM, LPARAM)
386
{
387
  if(IsWindow(m_List.m_hWnd)){
388
    int n=m_List.GetCount();
389
    bool bSelectAll=false;
390
    bool bUnSelectAll=false;
391
    if(n>0){
392
      bool bPrev=false;
393
      for(int i=0;i<n;i++){
394
        bool bCheck=(TRUE==m_List.GetCheck(i));
395
        if(bCheck){
396
          bUnSelectAll=true;
397
        } else {
398
          bSelectAll=true;
399
        }
400
        if(i>0 && bCheck!=bPrev){
401
          break;
402
        }
403
        bPrev=bCheck;
404
      }
405
    }
406
    GetDlgItem(IDC_TT_SELECT_ALL)->EnableWindow(bSelectAll);
407
    GetDlgItem(IDC_TT_UNSELECT_ALL)->EnableWindow(bUnSelectAll);
408
  }
409
  return 0;
410
}
411
 
412
bool CExecutionPage::SomeTestsSelected()
413
{
414
  bool b=0;
415
  if(IsWindow(m_List.m_hWnd)){
416
    for(int i=0;i<m_List.GetCount();i++){
417
      if(m_List.GetCheck(i)){
418
        b=true;
419
        break;
420
      }
421
    }
422
  }
423
  return b;
424
 
425
}
426
 
427
void CExecutionPage::OnRemove()
428
{
429
  m_List.SendMessage(WM_COMMAND,IDC_TT_REMOVE,0);
430
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.