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/] [OutputPage.cpp] - Blame information for rev 307

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

powered by: WebSVN 2.1.0

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