OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [testtool/] [win32/] [PropertiesDialog.cpp] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####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 "eCosTestPlatform.h"
30
#include "eCosSocket.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<CeCosTestPlatform::Count();i++){
167
        pCombo->AddString(CeCosTestPlatform::Get(i)->Name());
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
  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);
197
  }
198
  //GetDlgItem(IDC_TT_SETTINGS)->EnableWindow(!bSim || !((CButton *)GetDlgItem(IDC_TT_RADIO_LOCAL))->GetCheck());
199
 
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);
203
 
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);
207
}
208
 
209
void CPropertiesDialog::OnSettings()
210
{
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;
220
 
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;
226
        }
227
    } else {
228
        CLocalPropertiesDialog dlg(m_bHideRemoteControls);
229
        dlg.m_bSerial=m_bSerial;
230
        dlg.m_strPort=m_strPort;
231
        dlg.m_nBaud=m_nBaud;
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;
238
 
239
            m_bSerial=dlg.m_bSerial;
240
            m_strPort=dlg.m_strPort;
241
            m_nBaud=dlg.m_nBaud;
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;
247
        }
248
    }
249
}
250
 
251
void CPropertiesDialog::OnCancel()
252
{
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();
255
    }
256
}
257
 
258
void CPropertiesDialog::OnSelchangeDownloadtimeoutCombo()
259
{
260
    SetButtons();
261
}
262
 
263
void CPropertiesDialog::OnSelchangeTimeoutCombo()
264
{
265
    SetButtons();
266
}
267
 

powered by: WebSVN 2.1.0

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