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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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