OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [testtool/] [win32/] [OutputEdit.cpp] - Blame information for rev 268

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
// OutputEdit.cpp : implementation file
26
//
27
 
28
#include "stdafx.h"
29
#include "OutputEdit.h"
30
#include "TestToolRes.h"                // main symbols
31
 
32
#ifdef _DEBUG
33
#define new DEBUG_NEW
34
#undef THIS_FILE
35
static char THIS_FILE[] = __FILE__;
36
#endif
37
 
38
/////////////////////////////////////////////////////////////////////////////
39
// COutputEdit
40
 
41
COutputEdit::COutputEdit()
42
{
43
}
44
 
45
COutputEdit::~COutputEdit()
46
{
47
}
48
 
49
 
50
BEGIN_MESSAGE_MAP(COutputEdit, CEdit)
51
        //{{AFX_MSG_MAP(COutputEdit)
52
        ON_WM_CONTEXTMENU()
53
        ON_COMMAND(ID_EDIT_SELECT_ALL, OnEditSelectAll)
54
        ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
55
        ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)
56
        ON_WM_CHAR()
57
        ON_WM_SETFOCUS()
58
        ON_WM_KILLFOCUS()
59
        ON_COMMAND(ID_TT_EDIT_SAVE, OnEditSave)
60
        //}}AFX_MSG_MAP
61
END_MESSAGE_MAP()
62
 
63
/////////////////////////////////////////////////////////////////////////////
64
// COutputEdit message handlers
65
 
66
void COutputEdit::OnContextMenu(CWnd* pWnd, CPoint point)
67
{
68
    UNUSED_ALWAYS(pWnd);
69
    if(GetWindowTextLength()>0){
70
            CMenu menu;
71
            menu.LoadMenu(IDR_TT_CONTEXTMENU2);
72
 
73
            CMenu *pPopup=menu.GetSubMenu(0);
74
 
75
        int nBeg, nEnd;
76
 
77
        GetSel( nBeg, nEnd );
78
 
79
        if(nBeg==nEnd ){
80
            pPopup->EnableMenuItem(ID_EDIT_COPY,MF_BYCOMMAND|MF_GRAYED);
81
        }
82
        pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this);
83
    }
84
}
85
 
86
void COutputEdit::OnEditSelectAll()
87
{
88
        SetSel(0,-1);
89
}
90
 
91
void COutputEdit::OnEditCopy()
92
{
93
        Copy();
94
}
95
 
96
void COutputEdit::OnEditClear()
97
{
98
        SetWindowText(_T(""));
99
}
100
 
101
void COutputEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
102
{
103
    switch(nChar){
104
        case 1: // ctrl+A
105
            OnEditSelectAll();
106
            break;
107
        case 3: // ctrl+C
108
            OnEditCopy();
109
            break;
110
        default:
111
            CEdit::OnChar(nChar, nRepCnt, nFlags);
112
            break;
113
    }
114
}
115
 
116
// Control gets sent WM_SETSEL (0,0xffffffff) when property page is selected
117
// I don't know why, but this works around it:
118
void COutputEdit::OnSetFocus(CWnd* pOldWnd)
119
{
120
        CEdit::OnSetFocus(pOldWnd);
121
    SetSel(m_dwSel);
122
 
123
}
124
 
125
void COutputEdit::OnKillFocus(CWnd* pNewWnd)
126
{
127
    m_dwSel=GetSel();
128
        CEdit::OnKillFocus(pNewWnd);
129
}
130
 
131
void COutputEdit::OnEditSave()
132
{
133
        CFileDialog dlg( FALSE, _T("log"), _T("Output"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
134
                _T("Log Files (*.log)|*.log|All Files (*.*)|*.*||"));
135
        if(IDOK==dlg.DoModal()){
136
            TRY
137
            {
138
                    CStdioFile f( dlg.GetPathName(), CFile::modeCreate | CFile::modeWrite );
139
                    CString str;
140
                    GetWindowText(str);
141
                    f.WriteString(str);
142
                    f.Close();
143
            }
144
            CATCH( CFileException, e )
145
            {
146
                    MessageBox(_T("Failed to write file"));
147
            }
148
            END_CATCH
149
        }
150
 
151
}

powered by: WebSVN 2.1.0

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