1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
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)
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
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.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 // SummaryPage.cpp : implementation file
29 #include "SummaryPage.h"
31 #include "RunTestsSheet.h"
32 #include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
37 static char THIS_FILE[] = __FILE__;
40 LPCTSTR CSummaryPage::arpszCols[]={_T("Time"), _T("Host"), _T( "Platform"), _T("Executable"), _T("Status"), _T("Size"), _T("Download"), _T("Elapsed"), _T("Execution")};
41 const int CSummaryPage::nCols=sizeof CSummaryPage::arpszCols/sizeof CSummaryPage::arpszCols[0];
43 /////////////////////////////////////////////////////////////////////////////
44 // CSummaryPage property page
46 IMPLEMENT_DYNCREATE(CSummaryPage, CeCosPropertyPage)
48 CSummaryPage::CSummaryPage() : CeCosPropertyPage(IDD_TT_SUMMARY_PAGE)
50 //{{AFX_DATA_INIT(CSummaryPage)
51 // NOTE: the ClassWizard will add member initialization here
55 CSummaryPage::~CSummaryPage()
59 void CSummaryPage::DoDataExchange(CDataExchange* pDX)
61 CeCosPropertyPage::DoDataExchange(pDX);
62 //{{AFX_DATA_MAP(CSummaryPage)
63 DDX_Control(pDX, IDC_TT_LIST, m_List);
68 BEGIN_MESSAGE_MAP(CSummaryPage, CeCosPropertyPage)
69 //{{AFX_MSG_MAP(CSummaryPage)
70 ON_NOTIFY(NM_RCLICK, IDC_TT_LIST, OnRclickList)
71 ON_COMMAND(IDC_TT_CLEAR, OnClear)
72 ON_NOTIFY(LVN_COLUMNCLICK, IDC_TT_LIST, OnColumnclickList)
74 ON_COMMAND(ID_TT_EDIT_SAVE, OnEditSave)
78 /////////////////////////////////////////////////////////////////////////////
79 // CSummaryPage message handlers
81 void CSummaryPage::AddResult(CeCosTest *pTest)
83 const CString strResult((LPCTSTR)pTest->ResultString(false));
84 int nLength=strResult.GetLength();
86 CString strTime,strDate;
87 TRACE(_T("%s\n"),strResult);
88 // 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
89 _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));
90 // Remove before '=' in time fields
92 TCHAR *pch=_tcschr(arstr[i],_TCHAR('='));
98 strDate.ReleaseBuffer();
99 strTime.ReleaseBuffer();
100 strDate+=_TCHAR(' ');
102 int nItem=m_List.GetItemCount();
103 m_List.InsertItem(nItem,strDate);
104 m_List.SetItemData(nItem,nItem);// to support sorting
106 m_List.SetItemText(nItem,1+i,arstr[i]);
107 arstr[i].ReleaseBuffer();
111 BOOL CSummaryPage::OnInitDialog()
113 m_nLastCol=0x7fffffff;
114 CeCosPropertyPage::OnInitDialog();
117 m_List.GetClientRect(rect);
118 for(int i=0;i<nCols;i++){
119 m_List.InsertColumn(i,arpszCols[i]);
121 ListView_SetExtendedListViewStyle(m_List.GetSafeHwnd(),LVS_EX_FULLROWSELECT);
122 for(i=0;i<nCols;i++){
123 m_List.SetColumnWidth(i,rect.Width()/nCols);
126 return TRUE; // return TRUE unless you set the focus to a control
127 // EXCEPTION: OCX Property Pages should return FALSE
130 void CSummaryPage::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
132 UNUSED_ALWAYS(pNMHDR);
133 if(m_List.GetItemCount()>0){
135 menu.LoadMenu(IDR_TT_CONTEXTMENU1);
136 DWORD dwPos=GetMessagePos();
138 CMenu *pPopup=menu.GetSubMenu(0);
139 pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, MAKEPOINTS(dwPos).x,MAKEPOINTS(dwPos).y,this);
144 void CSummaryPage::OnClear()
146 m_List.DeleteAllItems();
149 int CSummaryPage::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
151 CSummaryPage *pPage=(CSummaryPage *)lParamSort;
153 int nCol=pPage->m_nLastCol&0x7fffffff;
154 str1=pPage->m_List.GetItemText(lParam1,nCol);
155 str2=pPage->m_List.GetItemText(lParam2,nCol);
156 int rc=str1.Compare(str2);
157 if(rc && (pPage->m_nLastCol&0x80000000)){
163 void CSummaryPage::OnColumnclickList(NMHDR* pNMHDR, LRESULT* pResult)
165 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
166 LPARAM nCol=pNMListView->iSubItem;
167 if((nCol&0x7fffffff)==(0x7fffffff&m_nLastCol)){
168 m_nLastCol=m_nLastCol^0x80000000;
172 m_List.SortItems(CompareFunc,(LPARAM)this);
173 for(int i=m_List.GetItemCount()-1;i>=0;--i){
174 m_List.SetItemData(i,i);
179 void CSummaryPage::OnSize(UINT nType, int cx, int cy)
181 CeCosPropertyPage::OnSize(nType, cx, cy);
182 float arProp[nCols]; // to preserve column propertions
185 m_List.GetClientRect(rect);
186 float fWidth=(float)rect.Width();
187 for(int i=0;i<nCols;i++){
188 arProp[i]=float(m_List.GetColumnWidth(i))/fWidth;
190 ((CRunTestsSheet*)GetParent())->MoveWindow(GetDlgItem(IDC_TT_LIST),CRunTestsSheet::Stretch);
191 m_List.GetClientRect(rect);
192 fWidth=(float)rect.Width();
193 for(i=0;i<nCols;i++){
194 m_List.SetColumnWidth(i,(int)(0.5+fWidth*arProp[i]));
199 void CSummaryPage::OnEditSave()
201 CFileDialog dlg( FALSE, _T("log"), _T("Output"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
202 _T("Log Files (*.log)|*.log|All Files (*.*)|*.*||"));
203 if(IDOK==dlg.DoModal()){
206 CStdioFile f( dlg.GetPathName(), CFile::modeCreate | CFile::modeWrite );
208 int arColWidth[nCols];
209 for(int nCol=0;nCol<nCols;nCol++){
210 int &w=arColWidth[nCol];
211 w=_tcslen(arpszCols[nCol]);
212 for(int nItem=0;nItem<m_List.GetItemCount();nItem++){
213 w=max(w,m_List.GetItemText(nItem,nCol).GetLength());
215 TRACE(_T("max[%d]=%d\n"),nCol,w);
218 for(nCol=0;nCol<nCols;nCol++){
219 const CString &strItem=arpszCols[nCol];
222 CString strTab(_TCHAR(' '),1+arColWidth[nCol]-strItem.GetLength());
228 for(int nItem=0;nItem<m_List.GetItemCount();nItem++){
230 for(int nCol=0;nCol<nCols;nCol++){
231 const CString strItem=m_List.GetItemText(nItem,nCol);
234 CString strTab(_TCHAR(' '),1+arColWidth[nCol]-strItem.GetLength());
243 CATCH( CFileException, e )
245 MessageBox(_T("Failed to write file"));