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 // PlatformsDialog.cpp : implementation file
30 #include "PLatformsDialog.h"
31 #include "PlatformDialog.h"
36 static char THIS_FILE[] = __FILE__;
39 /////////////////////////////////////////////////////////////////////////////
40 // CPlatformsDialog dialog
43 CPlatformsDialog::CPlatformsDialog(CWnd* pParent /*=NULL*/)
44 : CeCosDialog(CPlatformsDialog::IDD, pParent)
46 //{{AFX_DATA_INIT(CPlatformsDialog)
47 // NOTE: the ClassWizard will add member initialization here
52 void CPlatformsDialog::DoDataExchange(CDataExchange* pDX)
54 CeCosDialog::DoDataExchange(pDX);
55 //{{AFX_DATA_MAP(CPlatformsDialog)
56 DDX_Control(pDX, IDC_TT_PLATFORM_LIST, m_List);
61 BEGIN_MESSAGE_MAP(CPlatformsDialog, CeCosDialog)
62 //{{AFX_MSG_MAP(CPlatformsDialog)
63 ON_BN_CLICKED(IDC_TT_ADD_PLATFORM, OnAddPlatform)
64 ON_BN_CLICKED(IDC_TT_DELETE_PLATFORM, OnDeletePlatform)
65 ON_NOTIFY(NM_DBLCLK, IDC_TT_PLATFORM_LIST, OnDblclkPlatformList)
66 ON_BN_CLICKED(IDC_TT_MODIFY_PLATFORM, OnModifyPlatform)
67 ON_NOTIFY(LVN_KEYDOWN, IDC_TT_PLATFORM_LIST, OnKeydownPlatformList)
68 ON_NOTIFY(LVN_ITEMCHANGED, IDC_TT_PLATFORM_LIST, OnItemchangedPlatformList)
72 /////////////////////////////////////////////////////////////////////////////
73 // CPlatformsDialog message handlers
74 const LPCTSTR CPlatformsDialog::arpszTypes[]={
75 _T("Hardware with breakpoint support"),
77 _T("Synthetic target"),
78 _T("Hardware without breakpoint support"),
79 _T("Remote simulator")
82 BOOL CPlatformsDialog::OnInitDialog()
84 CeCosDialog::OnInitDialog();
86 ListView_SetExtendedListViewStyle(m_List.GetSafeHwnd(),LVS_EX_FULLROWSELECT);
88 m_List.InsertColumn(0,_T("Target"));
89 m_List.InsertColumn(1,_T("Prefix"));
90 m_List.InsertColumn(2,_T("Commands"));
91 m_List.InsertColumn(3,_T("Inferior"));
92 m_List.InsertColumn(4,_T("Prompt"));
93 m_List.InsertColumn(5,_T("ServerSideGdb"));
94 for(unsigned int i=0;i<CeCosTestPlatform::Count();i++){
95 Add(*CeCosTestPlatform::Get(i));
98 m_List.GetClientRect(rect);
99 m_List.SetColumnWidth(0,rect.Width()/6);
100 m_List.SetColumnWidth(1,rect.Width()/6);
101 m_List.SetColumnWidth(2,rect.Width()/6);
102 m_List.SetColumnWidth(3,rect.Width()/6);
103 m_List.SetColumnWidth(4,rect.Width()/6);
104 m_List.SetColumnWidth(5,rect.Width()/6);
106 bool bSel=(NULL!=m_List.GetFirstSelectedItemPosition());
107 GetDlgItem(IDC_TT_MODIFY_PLATFORM)->EnableWindow(bSel);
108 GetDlgItem(IDC_TT_DELETE_PLATFORM)->EnableWindow(bSel);
110 return TRUE; // return TRUE unless you set the focus to a control
111 // EXCEPTION: OCX Property Pages should return FALSE
114 void CPlatformsDialog::OnAddPlatform()
117 if(IDOK==dlg.DoModal()){
119 fi.flags=LVFI_STRING;
120 fi.psz=dlg.m_strPlatform;
121 if(-1==m_List.FindItem(&fi)){
122 Add(CeCosTestPlatform(dlg.m_strPlatform,dlg.m_strPrefix,dlg.m_strPrompt,dlg.m_strGDB,dlg.m_bServerSideGdb,dlg.m_strInferior));
124 MessageBox(_T("That platform name is already in use."));
129 void CPlatformsDialog::OnDeletePlatform()
131 POSITION pos = m_List.GetFirstSelectedItemPosition();
133 int nIndex= m_List.GetNextSelectedItem(pos);
135 if(IDYES==MessageBox(_T("Are you sure you wish to delete this platform?"),_T("Delete"),MB_YESNO)){
136 delete Platform(nIndex);
137 m_List.DeleteItem(nIndex);
138 m_arTargetInfo.RemoveAt(nIndex);
143 void CPlatformsDialog::Add(const CeCosTestPlatform &ti)
145 int i=m_List.GetItemCount();
146 m_List.InsertItem(i,ti.Name());
147 m_List.SetItemText(i,1,ti.Prefix());
148 m_List.SetItemText(i,2,ti.GdbCmds());
149 m_List.SetItemText(i,3,ti.Inferior());
150 m_List.SetItemText(i,4,ti.Prompt());
151 m_List.SetItemText(i,5,ti.ServerSideGdb()?_T("y"):_T("n"));
152 m_arTargetInfo.Add(new CeCosTestPlatform(ti));
155 void CPlatformsDialog::OnDblclkPlatformList(NMHDR*, LRESULT* pResult)
161 void CPlatformsDialog::OnModifyPlatform()
163 POSITION pos = m_List.GetFirstSelectedItemPosition();
165 int nIndex= m_List.GetNextSelectedItem(pos);
166 CeCosTestPlatform *pti=Platform(nIndex);
168 dlg.m_strPlatform=pti->Name();
169 dlg.m_strPrefix=pti->Prefix();
170 dlg.m_strGDB=pti->GdbCmds();
171 dlg.m_strCaption=_T("Modify");
172 dlg.m_strPrompt=pti->Prompt();
173 dlg.m_bServerSideGdb=pti->ServerSideGdb();
174 dlg.m_strInferior=pti->Inferior();
175 if(IDCANCEL!=dlg.DoModal()){
176 *pti=CeCosTestPlatform(dlg.m_strPlatform,dlg.m_strPrefix,dlg.m_strPrompt,dlg.m_strGDB,dlg.m_bServerSideGdb,dlg.m_strInferior);
177 m_List.SetItemText(nIndex,1,pti->Prefix());
178 m_List.SetItemText(nIndex,2,pti->GdbCmds());
179 m_List.SetItemText(nIndex,3,pti->Inferior());
180 m_List.SetItemText(nIndex,4,pti->Prompt());
181 m_List.SetItemText(nIndex,5,pti->ServerSideGdb()?_T("Y"):_T("N"));
186 void CPlatformsDialog::OnKeydownPlatformList(NMHDR* pNMHDR, LRESULT* pResult)
188 LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
189 if(VK_DELETE==pLVKeyDow->wVKey){
195 void CPlatformsDialog::OnItemchangedPlatformList(NMHDR* pNMHDR, LRESULT* pResult)
197 //NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
198 bool bSel=(NULL!=m_List.GetFirstSelectedItemPosition());
199 GetDlgItem(IDC_TT_MODIFY_PLATFORM)->EnableWindow(bSel);
200 GetDlgItem(IDC_TT_DELETE_PLATFORM)->EnableWindow(bSel);