1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
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)
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
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.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 //=================================================================
27 // RegionGeneralPage.cpp
29 // Memory Layout Tool region general property page class
31 //=================================================================
32 //#####DESCRIPTIONBEGIN####
34 // Author(s): John Dallaway
36 // Date: 1998/07/29 $RcsDate$ {or whatever}
37 // Version: 0.00+ $RcsVersion$ {or whatever}
38 // Purpose: Provides a derivation of the MFC CeCosPropertyPage class for
39 // general region property selection
40 // See also: RegionGeneralPage.h
41 // Known bugs: <UPDATE_ME_AT_RELEASE_TIME>
43 //####DESCRIPTIONEND####
46 #include "RegionGeneralPage.h"
47 #include "ConfigTool.h"
53 static char THIS_FILE[] = __FILE__;
56 /////////////////////////////////////////////////////////////////////////////
57 // CRegionGeneralPage property page
59 IMPLEMENT_DYNCREATE(CRegionGeneralPage, CeCosPropertyPage)
61 CRegionGeneralPage::CRegionGeneralPage() : CeCosPropertyPage(CRegionGeneralPage::IDD)
63 //{{AFX_DATA_INIT(CRegionGeneralPage)
64 m_strRegionName = _T("");
65 m_bRegionReadOnly = FALSE;
66 m_strRegionStartAddress = _T("");
67 m_strRegionSize = _T("");
71 CRegionGeneralPage::~CRegionGeneralPage()
75 void CRegionGeneralPage::DoDataExchange(CDataExchange* pDX)
77 CeCosPropertyPage::DoDataExchange(pDX);
78 //{{AFX_DATA_MAP(CRegionGeneralPage)
79 DDX_Control(pDX, IDC_REGION_GENERAL_SIZE, m_edtRegionSize);
80 DDX_Control(pDX, IDC_REGION_GENERAL_START_ADDRESS, m_edtRegionStartAddress);
81 DDX_Control(pDX, IDC_REGION_GENERAL_NAME, m_edtRegionName);
82 DDX_Text(pDX, IDC_REGION_GENERAL_NAME, m_strRegionName);
83 DDX_Check(pDX, IDC_REGION_GENERAL_READ_ONLY, m_bRegionReadOnly);
84 DDX_Text(pDX, IDC_REGION_GENERAL_START_ADDRESS, m_strRegionStartAddress);
85 DDX_Text(pDX, IDC_REGION_GENERAL_SIZE, m_strRegionSize);
90 BEGIN_MESSAGE_MAP(CRegionGeneralPage, CeCosPropertyPage)
91 //{{AFX_MSG_MAP(CRegionGeneralPage)
92 // NOTE: the ClassWizard will add message map macros here
96 /////////////////////////////////////////////////////////////////////////////
97 // CRegionGeneralPage message handlers
99 BOOL CRegionGeneralPage::OnKillActive()
101 if (! UpdateData (TRUE))
104 if ((m_strRegionName == _T("")) || (m_strRegionName.FindOneOf (LD_ILLEGAL_CHARS) != -1))
106 AfxMessageBox (IDS_VALIDATE_REGION_NAME);
107 m_edtRegionName.SetFocus ();
111 // convert address and size information to a DWORD representation
113 TCHAR strDummy [2]; // holds any stray character following a hex value
115 if (_stscanf (m_strRegionStartAddress, _T("%lx%1s"), &m_dwRegionStartAddress, strDummy) != 1)
117 AfxMessageBox (IDS_VALIDATE_REGION_START_ADDRESS);
118 m_edtRegionStartAddress.SetFocus ();
119 m_edtRegionStartAddress.SetSel (0, -1); // select all text
123 if ((_stscanf (m_strRegionSize, _T("%lx%1s"), &m_dwRegionSize, strDummy) != 1) || (m_dwRegionSize < 1))
125 AfxMessageBox (IDS_VALIDATE_REGION_SIZE);
126 m_edtRegionSize.SetFocus ();
127 m_edtRegionSize.SetSel (0, -1); // select all text
131 return CeCosPropertyPage::OnKillActive();
134 BOOL CRegionGeneralPage::OnSetActive()
136 // generate hex strings for display
138 if (m_dwRegionSize == 0) // a new region
140 m_strRegionStartAddress = _T("");
141 m_strRegionSize = _T("");
143 else // modify an existing region
145 m_strRegionStartAddress.Format (_T("%08lX"), m_dwRegionStartAddress);
146 m_strRegionSize.Format (_T("%lX"), m_dwRegionSize);
149 if (! UpdateData (FALSE))
152 return CeCosPropertyPage::OnSetActive();