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 // OutputPage.cpp : implementation file
30 #include "OutputPage.h"
32 #include "RunTestsSheet.h"
36 static char THIS_FILE[] = __FILE__;
39 /////////////////////////////////////////////////////////////////////////////
40 // COutputPage property page
42 IMPLEMENT_DYNCREATE(COutputPage, CeCosPropertyPage)
44 COutputPage::COutputPage() : CeCosPropertyPage(IDD_TT_OUTPUT_PAGE,0)
46 //{{AFX_DATA_INIT(COutputPage)
47 // NOTE: the ClassWizard will add member initialization here
51 COutputPage::~COutputPage()
55 void COutputPage::DoDataExchange(CDataExchange* pDX)
57 CeCosPropertyPage::DoDataExchange(pDX);
58 //{{AFX_DATA_MAP(COutputPage)
59 DDX_Control(pDX, IDC_TT_EDIT, m_Edit);
64 BEGIN_MESSAGE_MAP(COutputPage, CeCosPropertyPage)
65 //{{AFX_MSG_MAP(COutputPage)
70 /////////////////////////////////////////////////////////////////////////////
71 // COutputPage message handlers
73 BOOL COutputPage::OnInitDialog()
75 CeCosPropertyPage::OnInitDialog();
77 m_Font.CreatePointFont(90,_T("Courier New"));
78 m_Edit.SetFont(&m_Font);
80 return TRUE; // return TRUE unless you set the focus to a control
81 // EXCEPTION: OCX Property Pages should return FALSE
84 void COutputPage::AddText(LPCTSTR psz)
86 const CString str(psz);
88 // Change \n into \r\n
90 for(int nIndex=0;nIndex<str.GetLength();nIndex++){
91 if(str[nIndex]==_TCHAR('\n')){
92 if(nIndex==0||str[nIndex-1]!=_TCHAR('\r')){
93 strText+=str.Mid(nStart,nIndex-nStart);
94 strText+=_TCHAR('\r');
100 strText+=str.Mid(nStart,nIndex-nStart);
104 m_Edit.GetWindowText(strWText);
106 m_Edit.SetWindowText(strWText);
111 int nLength=m_Edit.GetWindowTextLength();
112 m_Edit.GetSel(nStart,nEnd);
114 m_Edit.SetSel(nLength,nLength,TRUE);
115 m_Edit.ReplaceSel(strText);
116 if(m_Edit.GetWindowTextLength()!=nLength+strText.GetLength()){
117 // Try again by removing equivalent length from start of buffer.
118 // For neatness, remove whole lines
119 int nLine=m_Edit.LineFromChar(strText.GetLength()-1);
120 int nIndex=m_Edit.LineIndex(nLine+1);
121 m_Edit.SetSel(0,nIndex-1,TRUE);
122 m_Edit.ReplaceSel(_T(""));
123 nLength=m_Edit.GetWindowTextLength();
124 m_Edit.SetSel(nLength,nLength,TRUE);
125 m_Edit.ReplaceSel(strText);
126 } else if(nStart!=nEnd) {
127 m_Edit.SetSel(nStart,nEnd,TRUE);
136 BOOL COutputPage::OnSetActive()
138 BOOL rc=CeCosPropertyPage::OnSetActive();
141 m_Edit.GetSel(nStart,nEnd);
142 TRACE(_T("Before: Start=%d end=%d\n"),nStart,nEnd);
143 m_Edit.GetSel(nStart,nEnd);
144 TRACE(_T("After: Start=%d end=%d\n"),nStart,nEnd);
145 //m_Edit.SetSel(nStart,nEnd);
150 void COutputPage::OnSize(UINT nType, int cx, int cy)
152 CeCosPropertyPage::OnSize(nType, cx, cy);
153 CWnd *pWnd=GetDlgItem(IDC_TT_EDIT);
155 ((CRunTestsSheet*)GetParent())->MoveWindow(pWnd,CRunTestsSheet::Stretch);
159 void COutputPage::AddLogMsg(LPCTSTR psz)
164 _tcsftime(str.GetBuffer(80),80,_T("*** %H:%M:%S "),localtime(<ime));