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

Subversion Repositories openrisc

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

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
// OutputPage.cpp : implementation file
23
//
24
 
25
#include "stdafx.h"
26
#include <time.h>
27
#include "OutputPage.h"
28
#include "eCosTest.h"
29
#include "RunTestsSheet.h"
30
#ifdef _DEBUG
31
#define new DEBUG_NEW
32
#undef THIS_FILE
33
static char THIS_FILE[] = __FILE__;
34
#endif
35
 
36
/////////////////////////////////////////////////////////////////////////////
37
// COutputPage property page
38
 
39
IMPLEMENT_DYNCREATE(COutputPage, CeCosPropertyPage)
40
 
41
COutputPage::COutputPage() : CeCosPropertyPage(IDD_TT_OUTPUT_PAGE,0)
42
{
43
        //{{AFX_DATA_INIT(COutputPage)
44
                // NOTE: the ClassWizard will add member initialization here
45
        //}}AFX_DATA_INIT
46
}
47
 
48
COutputPage::~COutputPage()
49
{
50
}
51
 
52
void COutputPage::DoDataExchange(CDataExchange* pDX)
53
{
54
        CeCosPropertyPage::DoDataExchange(pDX);
55
        //{{AFX_DATA_MAP(COutputPage)
56
        DDX_Control(pDX, IDC_TT_EDIT, m_Edit);
57
        //}}AFX_DATA_MAP
58
}
59
 
60
 
61
BEGIN_MESSAGE_MAP(COutputPage, CeCosPropertyPage)
62
        //{{AFX_MSG_MAP(COutputPage)
63
        ON_WM_SIZE()
64
        //}}AFX_MSG_MAP
65
END_MESSAGE_MAP()
66
 
67
/////////////////////////////////////////////////////////////////////////////
68
// COutputPage message handlers
69
 
70
BOOL COutputPage::OnInitDialog()
71
{
72
        CeCosPropertyPage::OnInitDialog();
73
 
74
    m_Font.CreatePointFont(90,_T("Courier New"));
75
    m_Edit.SetFont(&m_Font);
76
 
77
    return TRUE;  // return TRUE unless you set the focus to a control
78
                      // EXCEPTION: OCX Property Pages should return FALSE
79
}
80
 
81
void COutputPage::AddText(LPCTSTR psz)
82
{
83
    const CString str(psz);
84
        CString strText;
85
        // Change \n into \r\n
86
        int nStart=0;
87
        for(int nIndex=0;nIndex<str.GetLength();nIndex++){
88
                if(str[nIndex]==_TCHAR('\n')){
89
                        if(nIndex==0||str[nIndex-1]!=_TCHAR('\r')){
90
                                strText+=str.Mid(nStart,nIndex-nStart);
91
                                strText+=_TCHAR('\r');
92
                                nStart=nIndex;
93
                        }
94
                }
95
        }
96
 
97
        strText+=str.Mid(nStart,nIndex-nStart);
98
 
99
    /*
100
    CString strWText;
101
    m_Edit.GetWindowText(strWText);
102
    strWText+=strText;
103
    m_Edit.SetWindowText(strWText);
104
    */
105
 
106
        {
107
                int nStart,nEnd;
108
                int nLength=m_Edit.GetWindowTextLength();
109
                m_Edit.GetSel(nStart,nEnd);
110
                // Replace selection
111
                m_Edit.SetSel(nLength,nLength,TRUE);
112
                m_Edit.ReplaceSel(strText);
113
                if(m_Edit.GetWindowTextLength()!=nLength+strText.GetLength()){
114
                        // Try again by removing equivalent length from start of buffer.
115
                        // For neatness, remove whole lines
116
                        int nLine=m_Edit.LineFromChar(strText.GetLength()-1);
117
                        int nIndex=m_Edit.LineIndex(nLine+1);
118
                        m_Edit.SetSel(0,nIndex-1,TRUE);
119
                        m_Edit.ReplaceSel(_T(""));
120
                        nLength=m_Edit.GetWindowTextLength();
121
                        m_Edit.SetSel(nLength,nLength,TRUE);
122
                        m_Edit.ReplaceSel(strText);
123
                } else if(nStart!=nEnd) {
124
                        m_Edit.SetSel(nStart,nEnd,TRUE);
125
                }
126
        }
127
}
128
 
129
 
130
 
131
 
132
 
133
BOOL COutputPage::OnSetActive()
134
{
135
        BOOL rc=CeCosPropertyPage::OnSetActive();
136
        /*
137
        int nStart,nEnd;
138
    m_Edit.GetSel(nStart,nEnd);
139
TRACE(_T("Before: Start=%d end=%d\n"),nStart,nEnd);
140
        m_Edit.GetSel(nStart,nEnd);
141
TRACE(_T("After: Start=%d end=%d\n"),nStart,nEnd);
142
    //m_Edit.SetSel(nStart,nEnd);
143
    */
144
    return rc;
145
}
146
 
147
void COutputPage::OnSize(UINT nType, int cx, int cy)
148
{
149
        CeCosPropertyPage::OnSize(nType, cx, cy);
150
    CWnd *pWnd=GetDlgItem(IDC_TT_EDIT);
151
    if(pWnd){
152
        ((CRunTestsSheet*)GetParent())->MoveWindow(pWnd,CRunTestsSheet::Stretch);
153
    }
154
}
155
 
156
void COutputPage::AddLogMsg(LPCTSTR psz)
157
{
158
    CString str;
159
    time_t ltime;
160
    time(&ltime);
161
    _tcsftime(str.GetBuffer(80),80,_T("*** %H:%M:%S "),localtime(&ltime));
162
    str.ReleaseBuffer();
163
    str+=psz;
164
    str+=_T("\r\n");
165
    AddText(str);
166
}

powered by: WebSVN 2.1.0

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