Mercurial > flash_v2
comparison host/tools/testtool/win32/PropertiesDialog.cpp @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children | 6736c52df507 |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 //####COPYRIGHTBEGIN#### | |
| 2 // | |
| 3 // ---------------------------------------------------------------------------- | |
| 4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 5 // | |
| 6 // This program is part of the eCos host tools. | |
| 7 // | |
| 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) | |
| 11 // any later version. | |
| 12 // | |
| 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 | |
| 16 // more details. | |
| 17 // | |
| 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. | |
| 21 // | |
| 22 // ---------------------------------------------------------------------------- | |
| 23 // | |
| 24 //####COPYRIGHTEND#### | |
| 25 // ConnectionPage.cpp : implementation file | |
| 26 // | |
| 27 | |
| 28 #include "stdafx.h" | |
| 29 #include "eCosTest.h" | |
| 30 #include "eCosTestSocket.h" | |
| 31 #include "PropertiesDialog.h" | |
| 32 #include "LocalPropertiesDialog.h" | |
| 33 #include "RemotePropertiesDialog.h" | |
| 34 | |
| 35 #ifdef _DEBUG | |
| 36 #define new DEBUG_NEW | |
| 37 #undef THIS_FILE | |
| 38 static char THIS_FILE[] = __FILE__; | |
| 39 #endif | |
| 40 | |
| 41 ///////////////////////////////////////////////////////////////////////////// | |
| 42 // CPropertiesDialog property page | |
| 43 | |
| 44 //IMPLEMENT_DYNCREATE(CPropertiesDialog, CeCosDialog) | |
| 45 | |
| 46 CPropertiesDialog::CPropertiesDialog(bool bHideTarget,bool bHideRemoteControls) : | |
| 47 CeCosDialog(IDD_TT_PROPERTIES), | |
| 48 m_bConnectionModified(false), | |
| 49 m_bHideRemoteControls(bHideRemoteControls), | |
| 50 m_bHideTarget(bHideTarget) | |
| 51 { | |
| 52 //{{AFX_DATA_INIT(CPropertiesDialog) | |
| 53 //}}AFX_DATA_INIT | |
| 54 } | |
| 55 | |
| 56 CPropertiesDialog::~CPropertiesDialog() | |
| 57 { | |
| 58 } | |
| 59 | |
| 60 void CPropertiesDialog::DoDataExchange(CDataExchange* pDX) | |
| 61 { | |
| 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()); | |
| 69 } else { | |
| 70 if(pCombo->GetCount()>0){ | |
| 71 int nSel=0; | |
| 72 for(int i=0;i<pCombo->GetCount();i++){ | |
| 73 CString str; | |
| 74 pCombo->GetLBText(i, str.GetBuffer(pCombo->GetLBTextLen(i))); | |
| 75 str.ReleaseBuffer(); | |
| 76 if(0==str.Compare(m_strTarget)){ | |
| 77 nSel=i; | |
| 78 break; | |
| 79 } | |
| 80 } | |
| 81 pCombo->SetCurSel(nSel); | |
| 82 } | |
| 83 GetDlgItem(IDC_TT_STATIC_PLATFORM)->SetWindowText(m_strTarget); | |
| 84 | |
| 85 SetButtons(); | |
| 86 ((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->SetCheck(m_bRemote); | |
| 87 ((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->SetCheck(!m_bRemote); | |
| 88 } | |
| 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); | |
| 96 //}}AFX_DATA_MAP | |
| 97 } | |
| 98 | |
| 99 | |
| 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) | |
| 108 //}}AFX_MSG_MAP | |
| 109 END_MESSAGE_MAP() | |
| 110 | |
| 111 ///////////////////////////////////////////////////////////////////////////// | |
| 112 // CPropertiesDialog message handlers | |
| 113 | |
| 114 void CPropertiesDialog::OnRadioLocal() | |
| 115 { | |
| 116 ((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->SetCheck(FALSE); | |
| 117 SetButtons(); | |
| 118 } | |
| 119 | |
| 120 void CPropertiesDialog::OnRadioRemote() | |
| 121 { | |
| 122 ((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->SetCheck(FALSE); | |
| 123 SetButtons(); | |
| 124 } | |
| 125 | |
| 126 | |
| 127 BOOL CPropertiesDialog::OnInitDialog() | |
| 128 { | |
| 129 GetParent()->BringWindowToTop(); | |
| 130 | |
| 131 if(m_bHideRemoteControls){ | |
| 132 | |
| 133 m_bRemote=false; | |
| 134 | |
| 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); | |
| 139 } | |
| 140 | |
| 141 // Move the bottom three buttons up | |
| 142 CRect rect; | |
| 143 GetDlgItem(IDC_STATIC_EXECUTION)->GetWindowRect(rect); | |
| 144 ScreenToClient(rect); | |
| 145 int nTop=rect.top; | |
| 146 static const arIDs2[]={IDC_TT_SETTINGS, IDOK, IDCANCEL}; | |
| 147 int nDelta=0; | |
| 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; | |
| 154 rect.top=nTop; | |
| 155 rect.bottom=rect.top+nHeight; | |
| 156 pWnd->MoveWindow(rect); | |
| 157 } | |
| 158 GetWindowRect(rect); | |
| 159 rect.bottom-=nDelta; | |
| 160 MoveWindow(rect); | |
| 161 } | |
| 162 | |
| 163 CeCosDialog::OnInitDialog(); | |
| 164 | |
| 165 CComboBox *pCombo=(CComboBox *)GetDlgItem(IDC_TT_PLATFORM); | |
| 166 for(unsigned int i=0;i<CeCosTest::TargetTypeMax();i++){ | |
| 167 pCombo->AddString(CeCosTest::Image(i)); | |
| 168 } | |
| 169 | |
| 170 UpdateData(false); | |
| 171 | |
| 172 ((CSpinButtonCtrl *)GetDlgItem(IDC_TT_SPIN3))->SetRange(1,999); | |
| 173 ((CSpinButtonCtrl *)GetDlgItem(IDC_TT_SPIN4))->SetRange(1,999); | |
| 174 | |
| 175 if(m_bHideTarget){ | |
| 176 GetDlgItem(IDC_TT_STATIC_PLATFORM)->ShowWindow(SW_SHOW); | |
| 177 GetDlgItem(IDC_TT_PLATFORM)->ShowWindow(SW_HIDE); | |
| 178 } | |
| 179 | |
| 180 SetButtons(); | |
| 181 return TRUE; // return TRUE unless you set the focus to a control | |
| 182 // EXCEPTION: OCX Property Pages should return FALSE | |
| 183 } | |
| 184 | |
| 185 void CPropertiesDialog::OnSelchangePlatform() | |
| 186 { | |
| 187 SetButtons(); | |
| 188 } | |
| 189 | |
| 190 void CPropertiesDialog::SetButtons() | |
| 191 { | |
| 192 CString strTarget; | |
| 193 GetDlgItemText(IDC_TT_PLATFORM,strTarget); | |
| 194 bool bSim=CeCosTest::IsSim(strTarget); | |
| 195 static const int arIDs[]={IDC_TT_DOWNLOADTIMEOUT,IDC_TT_SPIN4,IDC_TT_DOWNLOADTIMEOUT_COMBO}; | |
| 196 for(int i=0;i<sizeof arIDs/sizeof arIDs[0];i++){ | |
| 197 GetDlgItem(arIDs[i]) ->EnableWindow(!bSim); | |
| 198 } | |
| 199 GetDlgItem(IDC_TT_SETTINGS)->EnableWindow(!bSim || !((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->GetCheck()); | |
| 200 | |
| 201 bool b=(TIMEOUT_SPECIFIED==((CComboBox*)GetDlgItem(IDC_TT_TIMEOUT_COMBO))->GetCurSel()); | |
| 202 GetDlgItem(IDC_TT_TESTTIMEOUT)->EnableWindow(b); | |
| 203 GetDlgItem(IDC_TT_SPIN3)->EnableWindow(b); | |
| 204 | |
| 205 b=(TIMEOUT_SPECIFIED==((CComboBox*)GetDlgItem(IDC_TT_DOWNLOADTIMEOUT_COMBO))->GetCurSel()); | |
| 206 GetDlgItem(IDC_TT_DOWNLOADTIMEOUT)->EnableWindow(!bSim && b); | |
| 207 GetDlgItem(IDC_TT_SPIN4)->EnableWindow(!bSim && b); | |
| 208 } | |
| 209 | |
| 210 void CPropertiesDialog::OnSettings() | |
| 211 { | |
| 212 if(((CButton *)GetDlgItem(IDC_TT_RADIO_REMOTE))->GetCheck()){ | |
| 213 CRemotePropertiesDialog dlg; | |
| 214 dlg.m_strResourceHost=m_strResourceHost; | |
| 215 dlg.m_nResourcePort=m_nResourcePort; | |
| 216 dlg.m_strRemoteHost=m_strRemoteHost; | |
| 217 dlg.m_nRemotePort=m_nRemotePort; | |
| 218 dlg.m_bFarmed=m_bFarmed; | |
| 219 if(IDOK==dlg.DoModal()){ | |
| 220 m_bConnectionModified=true; | |
| 221 | |
| 222 m_strResourceHost=dlg.m_strResourceHost; | |
| 223 m_nResourcePort=dlg.m_nResourcePort; | |
| 224 m_strRemoteHost=dlg.m_strRemoteHost; | |
| 225 m_nRemotePort=dlg.m_nRemotePort; | |
| 226 m_bFarmed=dlg.m_bFarmed; | |
| 227 } | |
| 228 } else { | |
| 229 CLocalPropertiesDialog dlg(m_bHideRemoteControls); | |
| 230 dlg.m_bSerial=m_bSerial; | |
| 231 dlg.m_strPort=m_strPort; | |
| 232 dlg.m_nBaud=m_nBaud; | |
| 233 dlg.m_strLocalTCPIPHost=m_strLocalTCPIPHost; | |
| 234 dlg.m_nLocalTCPIPPort=m_nLocalTCPIPPort; | |
| 235 dlg.m_nReset=m_nReset; | |
| 236 dlg.m_strPort=m_strPort; | |
| 237 if(IDOK==dlg.DoModal()){ | |
| 238 m_bConnectionModified=true; | |
| 239 | |
| 240 m_bSerial=dlg.m_bSerial; | |
| 241 m_strPort=dlg.m_strPort; | |
| 242 m_nBaud=dlg.m_nBaud; | |
| 243 m_strPort=dlg.m_strPort; | |
| 244 m_strLocalTCPIPHost=dlg.m_strLocalTCPIPHost; | |
| 245 m_nLocalTCPIPPort=dlg.m_nLocalTCPIPPort; | |
| 246 m_nReset=dlg.m_nReset; | |
| 247 m_strReset=dlg.m_strReset; | |
| 248 } | |
| 249 } | |
| 250 } | |
| 251 | |
| 252 void CPropertiesDialog::OnCancel() | |
| 253 { | |
| 254 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)){ | |
| 255 CeCosDialog::OnCancel(); | |
| 256 } | |
| 257 } | |
| 258 | |
| 259 void CPropertiesDialog::OnSelchangeDownloadtimeoutCombo() | |
| 260 { | |
| 261 SetButtons(); | |
| 262 } | |
| 263 | |
| 264 void CPropertiesDialog::OnSelchangeTimeoutCombo() | |
| 265 { | |
| 266 SetButtons(); | |
| 267 } | |
| 268 |
