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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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