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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [Utils/] [win32/] [IntegerEdit.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
// IntegerEdit.cpp : implementation file
23
//
24
//
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   sdf
28
// Contact(s):  sdf
29
// Date:                1998/08/11
30
// Version:             0.01
31
// Purpose:     
32
// Description: This is the implementation of the masked edit control as used 
33
//                              in integer in-cell edits by the control view.
34
// Requires:    
35
// Provides:    
36
// See also:    
37
// Known bugs:  
38
// Usage:       
39
//
40
//####DESCRIPTIONEND####
41
//
42
//===========================================================================
43
 
44
#include "stdafx.h"
45
#include "IntegerEdit.h"
46
#include "CTUtils.h"
47
 
48
#ifdef _DEBUG
49
#define new DEBUG_NEW
50
#undef THIS_FILE
51
static char THIS_FILE[] = __FILE__;
52
#endif
53
 
54
/////////////////////////////////////////////////////////////////////////////
55
// CIntegerEdit
56
 
57
CIntegerEdit::CIntegerEdit(__int64 nInitialValue):
58
  CCellEdit(CUtils::IntToStr(nInitialValue,false/*bool bHex*/)),
59
  m_bInSize(false)
60
{
61
}
62
 
63
CIntegerEdit::~CIntegerEdit()
64
{
65
}
66
 
67
 
68
BEGIN_MESSAGE_MAP(CIntegerEdit, CCellEdit)
69
        //{{AFX_MSG_MAP(CIntegerEdit)
70
        ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
71
        ON_WM_CREATE()
72
        ON_WM_SIZE()
73
        ON_WM_CHAR()
74
        //}}AFX_MSG_MAP
75
END_MESSAGE_MAP()
76
 
77
/////////////////////////////////////////////////////////////////////////////
78
// CIntegerEdit message handlers
79
 
80
void CIntegerEdit::OnUpdate()
81
{
82
    CString str;
83
    GetWindowText(str);
84
    __int64 d;
85
    if(CUtils::StrToItemIntegerType(str,d)||0==str.CompareNoCase(_T("0X"))||_T("-")==str){
86
        // reject all illegal strings except [partially] correct ones
87
        m_strPrevText=str;
88
    } else {
89
        MessageBeep(0xFFFFFFFF);
90
        const CPoint pt(GetCaretPos());
91
        SetWindowText(m_strPrevText);
92
        SetCaretPos(pt);
93
    }
94
}
95
 
96
 
97
BOOL CIntegerEdit::PreCreateWindow(CREATESTRUCT& cs)
98
{
99
        return CCellEdit::PreCreateWindow(cs);
100
}
101
 
102
int CIntegerEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
103
{
104
        if (CCellEdit::OnCreate(lpCreateStruct) == -1)
105
                return -1;
106
  m_wndSpin.Create(WS_CHILD|UDS_NOTHOUSANDS|UDS_ARROWKEYS|UDS_SETBUDDYINT,CRect(0,0,1,1),GetParent(),1);
107
  m_wndSpin.SetBuddy(this);
108
  m_wndSpin.SetRange32(0,0x7fffffff);
109
  m_wndSpin.SetWindowPos(this,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
110
        return 0;
111
}
112
 
113
void CIntegerEdit::OnSize(UINT /*nType*/, int cx, int cy)
114
{
115
  int cxSpin=::GetSystemMetrics(SM_CXVSCROLL);
116
  int cySpin=::GetSystemMetrics(SM_CYVSCROLL);
117
  int cxEdge=::GetSystemMetrics(SM_CXEDGE);
118
  int cyEdge=::GetSystemMetrics(SM_CYEDGE);
119
  bool bSpin=(cx>3*cxSpin);
120
  if(bSpin){
121
    if(m_bInSize){
122
      Default();
123
    } else {
124
      cx-=(cxSpin+4);
125
      CRect rect(cx+4,-cyEdge,cx+4+cxSpin,min(cySpin,cy+2*cyEdge));
126
      ClientToScreen(rect);
127
      GetParent()->ScreenToClient(rect);
128
      m_wndSpin.MoveWindow(rect,true);
129
      m_wndSpin.ShowWindow(SW_SHOW);
130
      rect=CRect(0,0,cx,cy);
131
      ClientToScreen(rect);
132
      GetParent()->ScreenToClient(rect);
133
      m_bInSize=true;
134
      rect.InflateRect(cxEdge,cyEdge);
135
      MoveWindow(rect);
136
      m_bInSize=false;
137
    }
138
  } else {
139
    m_wndSpin.ShowWindow(SW_HIDE);
140
    Default();
141
  }
142
}

powered by: WebSVN 2.1.0

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