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 // ConnectionPage.cpp : implementation file
29 #include "eCosTestPlatform.h"
30 #include "eCosSocket.h"
31 #include "PropertiesDialog.h"
32 #include "LocalPropertiesDialog.h"
33 #include "RemotePropertiesDialog.h"
38 static char THIS_FILE[] = __FILE__;
41 /////////////////////////////////////////////////////////////////////////////
42 // CPropertiesDialog property page
44 //IMPLEMENT_DYNCREATE(CPropertiesDialog, CeCosDialog)
46 CPropertiesDialog::CPropertiesDialog(bool bHideTarget,bool bHideRemoteControls) :
47 CeCosDialog(IDD_TT_PROPERTIES),
48 m_bConnectionModified(false),
49 m_bHideRemoteControls(bHideRemoteControls),
50 m_bHideTarget(bHideTarget)
52 //{{AFX_DATA_INIT(CPropertiesDialog)
56 CPropertiesDialog::~CPropertiesDialog()
60 void CPropertiesDialog::DoDataExchange(CDataExchange* pDX)
62 CeCosDialog::DoDataExchange(pDX);
63 CComboBox *pCombo=((CComboBox *)GetDlgItem(IDC_TT_PLATFORM));
64 if(pDX->m_bSaveAndValidate){
65 int i=pCombo->GetCurSel();
66 pCombo->GetLBText(i, m_strTarget.GetBuffer(pCombo->GetLBTextLen(i)));
67 m_strTarget.ReleaseBuffer();
68 m_bRemote=(TRUE==((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->GetCheck());
70 if(pCombo->GetCount()>0){
72 for(int i=0;i<pCombo->GetCount();i++){
74 pCombo->GetLBText(i, str.GetBuffer(pCombo->GetLBTextLen(i)));
76 if(0==str.Compare(m_strTarget)){
81 pCombo->SetCurSel(nSel);
83 GetDlgItem(IDC_TT_STATIC_PLATFORM)->SetWindowText(m_strTarget);
86 ((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->SetCheck(m_bRemote);
87 ((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->SetCheck(!m_bRemote);
89 //{{AFX_DATA_MAP(CPropertiesDialog)
90 DDX_Text(pDX, IDC_TT_DOWNLOADTIMEOUT, m_nDownloadTimeout);
91 DDV_MinMaxUInt(pDX, m_nDownloadTimeout, 1, 3600);
92 DDX_Text(pDX, IDC_TT_TESTTIMEOUT, m_nTimeout);
93 DDV_MinMaxUInt(pDX, m_nTimeout, 1, 3600);
94 DDX_CBIndex(pDX, IDC_TT_DOWNLOADTIMEOUT_COMBO, m_nDownloadTimeoutType);
95 DDX_CBIndex(pDX, IDC_TT_TIMEOUT_COMBO, m_nTimeoutType);
100 BEGIN_MESSAGE_MAP(CPropertiesDialog, CeCosDialog)
101 //{{AFX_MSG_MAP(CPropertiesDialog)
102 ON_BN_CLICKED(IDC_TT_RADIO_LOCAL, OnRadioLocal)
103 ON_BN_CLICKED(IDC_TT_RADIO_REMOTE, OnRadioRemote)
104 ON_CBN_SELCHANGE(IDC_TT_PLATFORM, OnSelchangePlatform)
105 ON_BN_CLICKED(IDC_TT_SETTINGS, OnSettings)
106 ON_CBN_SELCHANGE(IDC_TT_DOWNLOADTIMEOUT_COMBO, OnSelchangeDownloadtimeoutCombo)
107 ON_CBN_SELCHANGE(IDC_TT_TIMEOUT_COMBO, OnSelchangeTimeoutCombo)
111 /////////////////////////////////////////////////////////////////////////////
112 // CPropertiesDialog message handlers
114 void CPropertiesDialog::OnRadioLocal()
116 ((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->SetCheck(FALSE);
120 void CPropertiesDialog::OnRadioRemote()
122 ((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->SetCheck(FALSE);
127 BOOL CPropertiesDialog::OnInitDialog()
129 GetParent()->BringWindowToTop();
131 if(m_bHideRemoteControls){
135 // Hide these controls:
136 static const arIDs1[]={IDC_STATIC_EXECUTION, IDC_TT_RADIO_LOCAL, IDC_TT_RADIO_REMOTE};
137 for(int i=0;i<sizeof arIDs1/sizeof arIDs1[0];i++){
138 GetDlgItem(arIDs1[i])->ShowWindow(SW_HIDE);
141 // Move the bottom three buttons up
143 GetDlgItem(IDC_STATIC_EXECUTION)->GetWindowRect(rect);
144 ScreenToClient(rect);
146 static const arIDs2[]={IDC_TT_SETTINGS, IDOK, IDCANCEL};
148 for(i=0;i<sizeof arIDs2/sizeof arIDs2[0];i++){
149 CWnd *pWnd=GetDlgItem(arIDs2[i]);
150 pWnd->GetWindowRect(rect);
151 ScreenToClient(rect);
152 int nHeight=rect.Height();
153 nDelta=rect.top-nTop;
155 rect.bottom=rect.top+nHeight;
156 pWnd->MoveWindow(rect);
163 CeCosDialog::OnInitDialog();
165 CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_TT_PLATFORM);
166 for(unsigned int i=0;i<CeCosTestPlatform::Count();i++){
167 pCombo->AddString(CeCosTestPlatform::Get(i)->Name());
172 ((CSpinButtonCtrl *)GetDlgItem(IDC_TT_SPIN3))->SetRange(1,999);
173 ((CSpinButtonCtrl *)GetDlgItem(IDC_TT_SPIN4))->SetRange(1,999);
176 GetDlgItem(IDC_TT_STATIC_PLATFORM)->ShowWindow(SW_SHOW);
177 GetDlgItem(IDC_TT_PLATFORM)->ShowWindow(SW_HIDE);
181 return TRUE; // return TRUE unless you set the focus to a control
182 // EXCEPTION: OCX Property Pages should return FALSE
185 void CPropertiesDialog::OnSelchangePlatform()
190 void CPropertiesDialog::SetButtons()
193 GetDlgItemText(IDC_TT_PLATFORM,strTarget);
194 static const int arIDs[]={IDC_TT_DOWNLOADTIMEOUT,IDC_TT_SPIN4,IDC_TT_DOWNLOADTIMEOUT_COMBO};
195 for(int i=0;i<sizeof arIDs/sizeof arIDs[0];i++){
196 GetDlgItem(arIDs[i]) ->EnableWindow(true);
198 //GetDlgItem(IDC_TT_SETTINGS)->EnableWindow(!bSim || !((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->GetCheck());
200 bool b=(TIMEOUT_SPECIFIED==((CComboBox*)GetDlgItem(IDC_TT_TIMEOUT_COMBO))->GetCurSel());
201 GetDlgItem(IDC_TT_TESTTIMEOUT)->EnableWindow(b);
202 GetDlgItem(IDC_TT_SPIN3)->EnableWindow(b);
204 b=(TIMEOUT_SPECIFIED==((CComboBox*)GetDlgItem(IDC_TT_DOWNLOADTIMEOUT_COMBO))->GetCurSel());
205 GetDlgItem(IDC_TT_DOWNLOADTIMEOUT)->EnableWindow(b);
206 GetDlgItem(IDC_TT_SPIN4)->EnableWindow(b);
209 void CPropertiesDialog::OnSettings()
211 if(((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->GetCheck()){
212 CRemotePropertiesDialog dlg;
213 dlg.m_strResourceHost=m_strResourceHost;
214 dlg.m_nResourcePort=m_nResourcePort;
215 dlg.m_strRemoteHost=m_strRemoteHost;
216 dlg.m_nRemotePort=m_nRemotePort;
217 dlg.m_bFarmed=m_bFarmed;
218 if(IDOK==dlg.DoModal()){
219 m_bConnectionModified=true;
221 m_strResourceHost=dlg.m_strResourceHost;
222 m_nResourcePort=dlg.m_nResourcePort;
223 m_strRemoteHost=dlg.m_strRemoteHost;
224 m_nRemotePort=dlg.m_nRemotePort;
225 m_bFarmed=dlg.m_bFarmed;
228 CLocalPropertiesDialog dlg(m_bHideRemoteControls);
229 dlg.m_bSerial=m_bSerial;
230 dlg.m_strPort=m_strPort;
232 dlg.m_strLocalTCPIPHost=m_strLocalTCPIPHost;
233 dlg.m_nLocalTCPIPPort=m_nLocalTCPIPPort;
234 dlg.m_nReset=m_nReset;
235 dlg.m_strPort=m_strPort;
236 if(IDOK==dlg.DoModal()){
237 m_bConnectionModified=true;
239 m_bSerial=dlg.m_bSerial;
240 m_strPort=dlg.m_strPort;
242 m_strPort=dlg.m_strPort;
243 m_strLocalTCPIPHost=dlg.m_strLocalTCPIPHost;
244 m_nLocalTCPIPPort=dlg.m_nLocalTCPIPPort;
245 m_nReset=dlg.m_nReset;
246 m_strReset=dlg.m_strReset;
251 void CPropertiesDialog::OnCancel()
253 if(!m_bConnectionModified || IDYES==MessageBox(_T("This will discard any changes that may have been made to connection settings. Do you still wish to cancel?"),NULL,MB_YESNO|MB_DEFBUTTON2)){
254 CeCosDialog::OnCancel();
258 void CPropertiesDialog::OnSelchangeDownloadtimeoutCombo()
263 void CPropertiesDialog::OnSelchangeTimeoutCombo()