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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [Utils/] [win32/] [DoubleEdit.cpp] - Blame information for rev 810

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
// DoubleEdit.cpp: implementation of the CDoubleEdit class.
26
//
27
//////////////////////////////////////////////////////////////////////
28
 
29
#include "stdafx.h"
30
#include "DoubleEdit.h"
31
#include "CTUtils.h"
32
 
33
#ifdef _DEBUG
34
#define new DEBUG_NEW
35
#undef THIS_FILE
36
static char THIS_FILE[] = __FILE__;
37
#endif
38
 
39
//////////////////////////////////////////////////////////////////////
40
// Construction/Destruction
41
//////////////////////////////////////////////////////////////////////
42
 
43
CDoubleEdit::CDoubleEdit(double dInitialValue):
44
  CCellEdit(CUtils::DoubleToStr (dInitialValue))
45
{
46
}
47
 
48
CDoubleEdit::~CDoubleEdit()
49
{
50
 
51
}
52
 
53
BEGIN_MESSAGE_MAP(CDoubleEdit, CCellEdit)
54
        //{{AFX_MSG_MAP(CDoubleEdit)
55
        ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
56
        //}}AFX_MSG_MAP
57
END_MESSAGE_MAP()
58
 
59
/////////////////////////////////////////////////////////////////////////////
60
// CDoubleEdit message handlers
61
 
62
void CDoubleEdit::OnUpdate()
63
{
64
    CString strValue;
65
    GetWindowText (strValue);
66
    double dValue;
67
    if (strValue.IsEmpty () || CUtils::StrToDouble (strValue, dValue) || _T("-")==strValue ||
68
                CUtils::StrToDouble (TrimRightNoCase (strValue, _T("e")), dValue) ||
69
                CUtils::StrToDouble (TrimRightNoCase (strValue, _T("e+")), dValue) ||
70
                CUtils::StrToDouble (TrimRightNoCase (strValue, _T("e-")), dValue)) // cell text is legal
71
        {
72
        m_strPrevText = strValue;
73
    }
74
        else // cell text is not legal so revert to previous text
75
        {
76
        MessageBeep (0xFFFFFFFF);
77
        const CPoint pt (GetCaretPos ());
78
        SetWindowText (m_strPrevText);
79
        SetCaretPos (pt);
80
    }
81
}
82
 
83
CString CDoubleEdit::TrimRightNoCase (const CString & strInput, LPCTSTR lpszTrimChars)
84
{
85
        const CString strTrim = lpszTrimChars;
86
        if (0 == strInput.Right (strTrim.GetLength ()).CompareNoCase (strTrim))
87
                return strInput.Left (strInput.GetLength () - strTrim.GetLength ());
88
        else
89
                return strInput;
90
}
91
 
92
BOOL CDoubleEdit::PreCreateWindow(CREATESTRUCT& cs)
93
{
94
    /*
95
    if(!m_bHex){
96
        cs.style|=ES_NUMBER;
97
    }
98
    */
99
        return CCellEdit::PreCreateWindow(cs);
100
}

powered by: WebSVN 2.1.0

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