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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [testtool/] [win32/] [ExecutionPage.cpp] - Blame information for rev 321

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

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

powered by: WebSVN 2.1.0

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