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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [testtool/] [win32/] [SummaryPage.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
// SummaryPage.cpp : implementation file
23
//
24
 
25
#include "stdafx.h"
26
#include "SummaryPage.h"
27
#include "eCosTest.h"
28
#include "RunTestsSheet.h"
29
#include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
30
 
31
#ifdef _DEBUG
32
#define new DEBUG_NEW
33
#undef THIS_FILE
34
static char THIS_FILE[] = __FILE__;
35
#endif
36
 
37
LPCTSTR CSummaryPage::arpszCols[]={_T("Time"), _T("Host"), _T( "Platform"), _T("Executable"), _T("Status"), _T("Size"), _T("Download"), _T("Elapsed"), _T("Execution")};
38
const int CSummaryPage::nCols=sizeof CSummaryPage::arpszCols/sizeof CSummaryPage::arpszCols[0];
39
 
40
/////////////////////////////////////////////////////////////////////////////
41
// CSummaryPage property page
42
 
43
IMPLEMENT_DYNCREATE(CSummaryPage, CeCosPropertyPage)
44
 
45
CSummaryPage::CSummaryPage() : CeCosPropertyPage(IDD_TT_SUMMARY_PAGE)
46
{
47
        //{{AFX_DATA_INIT(CSummaryPage)
48
                // NOTE: the ClassWizard will add member initialization here
49
        //}}AFX_DATA_INIT
50
}
51
 
52
CSummaryPage::~CSummaryPage()
53
{
54
}
55
 
56
void CSummaryPage::DoDataExchange(CDataExchange* pDX)
57
{
58
        CeCosPropertyPage::DoDataExchange(pDX);
59
        //{{AFX_DATA_MAP(CSummaryPage)
60
        DDX_Control(pDX, IDC_TT_LIST, m_List);
61
        //}}AFX_DATA_MAP
62
}
63
 
64
 
65
BEGIN_MESSAGE_MAP(CSummaryPage, CeCosPropertyPage)
66
        //{{AFX_MSG_MAP(CSummaryPage)
67
        ON_NOTIFY(NM_RCLICK, IDC_TT_LIST, OnRclickList)
68
        ON_COMMAND(IDC_TT_CLEAR, OnClear)
69
        ON_NOTIFY(LVN_COLUMNCLICK, IDC_TT_LIST, OnColumnclickList)
70
        ON_WM_SIZE()
71
        ON_COMMAND(ID_TT_EDIT_SAVE, OnEditSave)
72
        //}}AFX_MSG_MAP
73
END_MESSAGE_MAP()
74
 
75
/////////////////////////////////////////////////////////////////////////////
76
// CSummaryPage message handlers
77
 
78
void CSummaryPage::AddResult(CeCosTest *pTest)
79
{
80
  const CString strResult((LPCTSTR)pTest->ResultString(false));
81
  int nLength=strResult.GetLength();
82
  CString arstr[8];
83
  CString strTime,strDate;
84
  TRACE(_T("%s\n"),strResult);
85
  // 1999-05-28 10:29:28 nan:0 TX39-jmr3904-sim tx39-jmr3904sim-libc10-signal2.exe Fail 0k/1108k D=0.0/0.0 Total=9.3 E=0.6/300.0 
86
  _stscanf(strResult,_T("%s %s %s %s %s %s %s %s %s %s"),strDate.GetBuffer(1+nLength),strTime.GetBuffer(1+nLength),arstr[0].GetBuffer(1+nLength),arstr[1].GetBuffer(1+nLength),arstr[2].GetBuffer(1+nLength),arstr[3].GetBuffer(1+nLength),arstr[4].GetBuffer(1+nLength),arstr[5].GetBuffer(1+nLength),arstr[6].GetBuffer(1+nLength),arstr[7].GetBuffer(1+nLength));
87
  // Remove before '=' in time fields
88
  for(int i=5;i<8;i++){
89
      TCHAR *pch=_tcschr(arstr[i],_TCHAR('='));
90
      if(pch){
91
          arstr[i]=pch+1;
92
      }
93
  }
94
 
95
  strDate.ReleaseBuffer();
96
  strTime.ReleaseBuffer();
97
  strDate+=_TCHAR(' ');
98
  strDate+=strTime;
99
  int nItem=m_List.GetItemCount();
100
  m_List.InsertItem(nItem,strDate);
101
  m_List.SetItemData(nItem,nItem);// to support sorting
102
  for(i=0;i<8;i++){
103
      m_List.SetItemText(nItem,1+i,arstr[i]);
104
      arstr[i].ReleaseBuffer();
105
  }
106
}
107
 
108
BOOL CSummaryPage::OnInitDialog()
109
{
110
    m_nLastCol=0x7fffffff;
111
        CeCosPropertyPage::OnInitDialog();
112
 
113
    CRect rect;
114
    m_List.GetClientRect(rect);
115
    for(int i=0;i<nCols;i++){
116
        m_List.InsertColumn(i,arpszCols[i]);
117
    }
118
        ListView_SetExtendedListViewStyle(m_List.GetSafeHwnd(),LVS_EX_FULLROWSELECT);
119
    for(i=0;i<nCols;i++){
120
            m_List.SetColumnWidth(i,rect.Width()/nCols);
121
    }
122
 
123
        return TRUE;  // return TRUE unless you set the focus to a control
124
                      // EXCEPTION: OCX Property Pages should return FALSE
125
}
126
 
127
void CSummaryPage::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
128
{
129
    UNUSED_ALWAYS(pNMHDR);
130
    if(m_List.GetItemCount()>0){
131
            CMenu menu;
132
            menu.LoadMenu(IDR_TT_CONTEXTMENU1);
133
        DWORD dwPos=GetMessagePos();
134
 
135
            CMenu *pPopup=menu.GetSubMenu(0);
136
            pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, MAKEPOINTS(dwPos).x,MAKEPOINTS(dwPos).y,this);
137
    }
138
        *pResult = 0;
139
}
140
 
141
void CSummaryPage::OnClear()
142
{
143
    m_List.DeleteAllItems();
144
}
145
 
146
int CSummaryPage::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
147
{
148
    CSummaryPage *pPage=(CSummaryPage *)lParamSort;
149
        CString str1,str2;
150
    int nCol=pPage->m_nLastCol&0x7fffffff;
151
    str1=pPage->m_List.GetItemText(lParam1,nCol);
152
    str2=pPage->m_List.GetItemText(lParam2,nCol);
153
    int rc=str1.Compare(str2);
154
    if(rc && (pPage->m_nLastCol&0x80000000)){
155
        rc^=0x80000000;
156
    }
157
    return rc;
158
}
159
 
160
void CSummaryPage::OnColumnclickList(NMHDR* pNMHDR, LRESULT* pResult)
161
{
162
        NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
163
        LPARAM nCol=pNMListView->iSubItem;
164
        if((nCol&0x7fffffff)==(0x7fffffff&m_nLastCol)){
165
                m_nLastCol=m_nLastCol^0x80000000;
166
    } else {
167
        m_nLastCol=nCol;
168
    }
169
    m_List.SortItems(CompareFunc,(LPARAM)this);
170
    for(int i=m_List.GetItemCount()-1;i>=0;--i){
171
        m_List.SetItemData(i,i);
172
    }
173
        *pResult = 0;
174
}
175
 
176
void CSummaryPage::OnSize(UINT nType, int cx, int cy)
177
{
178
        CeCosPropertyPage::OnSize(nType, cx, cy);
179
    float arProp[nCols]; // to preserve column propertions
180
    if(m_List){
181
        CRect rect;
182
        m_List.GetClientRect(rect);
183
        float fWidth=(float)rect.Width();
184
        for(int i=0;i<nCols;i++){
185
            arProp[i]=float(m_List.GetColumnWidth(i))/fWidth;
186
        }
187
        ((CRunTestsSheet*)GetParent())->MoveWindow(GetDlgItem(IDC_TT_LIST),CRunTestsSheet::Stretch);
188
        m_List.GetClientRect(rect);
189
        fWidth=(float)rect.Width();
190
        for(i=0;i<nCols;i++){
191
                m_List.SetColumnWidth(i,(int)(0.5+fWidth*arProp[i]));
192
        }
193
    }
194
}
195
 
196
void CSummaryPage::OnEditSave()
197
{
198
        CFileDialog dlg( FALSE, _T("log"), _T("Output"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
199
                _T("Log Files (*.log)|*.log|All Files (*.*)|*.*||"));
200
        if(IDOK==dlg.DoModal()){
201
            TRY
202
            {
203
                    CStdioFile f( dlg.GetPathName(), CFile::modeCreate | CFile::modeWrite );
204
            CString str;
205
            int arColWidth[nCols];
206
            for(int nCol=0;nCol<nCols;nCol++){
207
                    int &w=arColWidth[nCol];
208
                w=_tcslen(arpszCols[nCol]);
209
                for(int nItem=0;nItem<m_List.GetItemCount();nItem++){
210
                    w=max(w,m_List.GetItemText(nItem,nCol).GetLength());
211
                }
212
                TRACE(_T("max[%d]=%d\n"),nCol,w);
213
            }
214
 
215
            for(nCol=0;nCol<nCols;nCol++){
216
                const CString &strItem=arpszCols[nCol];
217
                str+=strItem;
218
                if(nCol<nCols-1){
219
                    CString strTab(_TCHAR(' '),1+arColWidth[nCol]-strItem.GetLength());
220
                    str+=strTab;
221
                }
222
            }
223
            str+=_TCHAR('\n');
224
            f.WriteString(str);
225
            for(int nItem=0;nItem<m_List.GetItemCount();nItem++){
226
                        CString str;
227
                for(int nCol=0;nCol<nCols;nCol++){
228
                    const CString strItem=m_List.GetItemText(nItem,nCol);
229
                    str+=strItem;
230
                    if(nCol<nCols-1){
231
                        CString strTab(_TCHAR(' '),1+arColWidth[nCol]-strItem.GetLength());
232
                        str+=strTab;
233
                    }
234
                }
235
                str+=_TCHAR('\n');
236
                        f.WriteString(str);
237
            }
238
                    f.Close();
239
            }
240
            CATCH( CFileException, e )
241
            {
242
                    MessageBox(_T("Failed to write file"));
243
            }
244
            END_CATCH
245
        }
246
 
247
}

powered by: WebSVN 2.1.0

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