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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [RegionGeneralPage.cpp] - Blame information for rev 786

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
//=================================================================
23
//
24
//        RegionGeneralPage.cpp
25
//
26
//        Memory Layout Tool region general property page class
27
//
28
//=================================================================
29
//#####DESCRIPTIONBEGIN####
30
//
31
// Author(s):     John Dallaway
32
// Contact(s):    jld
33
// Date:          1998/07/29 $RcsDate$ {or whatever}
34
// Version:       0.00+  $RcsVersion$ {or whatever}
35
// Purpose:       Provides a derivation of the MFC CeCosPropertyPage class for
36
//                general region property selection
37
// See also:      RegionGeneralPage.h
38
// Known bugs:    <UPDATE_ME_AT_RELEASE_TIME>
39
//
40
//####DESCRIPTIONEND####
41
 
42
#include "stdafx.h"
43
#include "RegionGeneralPage.h"
44
#include "ConfigTool.h"
45
#include "memmap.h"
46
 
47
#ifdef _DEBUG
48
#define new DEBUG_NEW
49
#undef THIS_FILE
50
static char THIS_FILE[] = __FILE__;
51
#endif
52
 
53
/////////////////////////////////////////////////////////////////////////////
54
// CRegionGeneralPage property page
55
 
56
IMPLEMENT_DYNCREATE(CRegionGeneralPage, CeCosPropertyPage)
57
 
58
CRegionGeneralPage::CRegionGeneralPage() : CeCosPropertyPage(CRegionGeneralPage::IDD)
59
{
60
        //{{AFX_DATA_INIT(CRegionGeneralPage)
61
        m_strRegionName = _T("");
62
        m_bRegionReadOnly = FALSE;
63
        m_strRegionStartAddress = _T("");
64
        m_strRegionSize = _T("");
65
        //}}AFX_DATA_INIT
66
}
67
 
68
CRegionGeneralPage::~CRegionGeneralPage()
69
{
70
}
71
 
72
void CRegionGeneralPage::DoDataExchange(CDataExchange* pDX)
73
{
74
        CeCosPropertyPage::DoDataExchange(pDX);
75
        //{{AFX_DATA_MAP(CRegionGeneralPage)
76
        DDX_Control(pDX, IDC_REGION_GENERAL_SIZE, m_edtRegionSize);
77
        DDX_Control(pDX, IDC_REGION_GENERAL_START_ADDRESS, m_edtRegionStartAddress);
78
        DDX_Control(pDX, IDC_REGION_GENERAL_NAME, m_edtRegionName);
79
        DDX_Text(pDX, IDC_REGION_GENERAL_NAME, m_strRegionName);
80
        DDX_Check(pDX, IDC_REGION_GENERAL_READ_ONLY, m_bRegionReadOnly);
81
        DDX_Text(pDX, IDC_REGION_GENERAL_START_ADDRESS, m_strRegionStartAddress);
82
        DDX_Text(pDX, IDC_REGION_GENERAL_SIZE, m_strRegionSize);
83
        //}}AFX_DATA_MAP
84
}
85
 
86
 
87
BEGIN_MESSAGE_MAP(CRegionGeneralPage, CeCosPropertyPage)
88
        //{{AFX_MSG_MAP(CRegionGeneralPage)
89
                // NOTE: the ClassWizard will add message map macros here
90
        //}}AFX_MSG_MAP
91
END_MESSAGE_MAP()
92
 
93
/////////////////////////////////////////////////////////////////////////////
94
// CRegionGeneralPage message handlers
95
 
96
BOOL CRegionGeneralPage::OnKillActive()
97
{
98
    if (! UpdateData (TRUE))
99
        return FALSE;
100
 
101
    if ((m_strRegionName == _T("")) || (m_strRegionName.FindOneOf (LD_ILLEGAL_CHARS) != -1))
102
    {
103
        AfxMessageBox (IDS_VALIDATE_REGION_NAME);
104
        m_edtRegionName.SetFocus ();
105
        return FALSE;
106
    }
107
 
108
    // convert address and size information to a DWORD representation
109
 
110
    TCHAR strDummy [2]; // holds any stray character following a hex value
111
 
112
    if (_stscanf (m_strRegionStartAddress, _T("%lx%1s"), &m_dwRegionStartAddress, strDummy) != 1)
113
    {
114
        AfxMessageBox (IDS_VALIDATE_REGION_START_ADDRESS);
115
        m_edtRegionStartAddress.SetFocus ();
116
        m_edtRegionStartAddress.SetSel (0, -1); // select all text
117
        return FALSE;
118
    }
119
 
120
    if ((_stscanf (m_strRegionSize, _T("%lx%1s"), &m_dwRegionSize, strDummy) != 1) || (m_dwRegionSize < 1))
121
    {
122
        AfxMessageBox (IDS_VALIDATE_REGION_SIZE);
123
        m_edtRegionSize.SetFocus ();
124
        m_edtRegionSize.SetSel (0, -1); // select all text
125
        return FALSE;
126
    }
127
 
128
    return CeCosPropertyPage::OnKillActive();
129
}
130
 
131
BOOL CRegionGeneralPage::OnSetActive()
132
{
133
    // generate hex strings for display
134
 
135
    if (m_dwRegionSize == 0) // a new region
136
    {
137
        m_strRegionStartAddress = _T("");
138
        m_strRegionSize = _T("");
139
    }
140
    else // modify an existing region
141
    {
142
        m_strRegionStartAddress.Format (_T("%08lX"), m_dwRegionStartAddress);
143
        m_strRegionSize.Format (_T("%lX"), m_dwRegionSize);
144
    }
145
 
146
    if (! UpdateData (FALSE))
147
        return FALSE;
148
 
149
        return CeCosPropertyPage::OnSetActive();
150
}
151
 

powered by: WebSVN 2.1.0

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