OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [platformsdlg.cpp] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// platformsdlg.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians
28
// Contact(s):  julians
29
// Date:        2000/09/06
30
// Version:     $Id: platformsdlg.cpp,v 1.2 2001/03/23 13:38:04 julians Exp $
31
// Purpose:
32
// Description: Implementation file for the ecPlatformsDialog
33
// Requires:
34
// Provides:
35
// See also:
36
// Known bugs:
37
// Usage:
38
//
39
//####DESCRIPTIONEND####
40
//
41
//===========================================================================
42
 
43
// ============================================================================
44
// declarations
45
// ============================================================================
46
 
47
// ----------------------------------------------------------------------------
48
// headers
49
// ----------------------------------------------------------------------------
50
#ifdef __GNUG__
51
#pragma implementation "platformsdlg.h"
52
#endif
53
 
54
// Includes other headers for precompiled compilation
55
#include "ecpch.h"
56
 
57
#ifdef __BORLANDC__
58
#pragma hdrstop
59
#endif
60
 
61
#include "wx/cshelp.h"
62
 
63
#include "configtool.h"
64
#include "platformsdlg.h"
65
#include "platformeditordlg.h"
66
 
67
#ifdef __WXMSW__
68
#include "wx/msw/winundef.h"
69
#endif
70
 
71
BEGIN_EVENT_TABLE(ecPlatformsDialog, ecDialog)
72
    EVT_BUTTON(ecID_PLATFORMS_MODIFY, ecPlatformsDialog::OnModify)
73
    EVT_BUTTON(ecID_PLATFORMS_ADD, ecPlatformsDialog::OnAdd)
74
    EVT_BUTTON(ecID_PLATFORMS_DELETE, ecPlatformsDialog::OnDelete)
75
    EVT_BUTTON(wxID_OK, ecPlatformsDialog::OnOK)
76
    EVT_BUTTON(wxID_CANCEL, ecPlatformsDialog::OnCancel)
77
    EVT_UPDATE_UI(ecID_PLATFORMS_MODIFY, ecPlatformsDialog::OnUpdateAny)
78
    EVT_UPDATE_UI(ecID_PLATFORMS_DELETE, ecPlatformsDialog::OnUpdateAny)
79
END_EVENT_TABLE()
80
 
81
const wxChar* ecPlatformsDialog::sm_arpszTypes[]={
82
  wxT("Hardware with breakpoint support"),
83
  wxT("Simulator"),
84
  wxT("Synthetic target"),
85
  wxT("Hardware without breakpoint support"),
86
  wxT("Remote simulator")
87
};
88
 
89
 
90
// Frame constructor
91
ecPlatformsDialog::ecPlatformsDialog(wxWindow* parent)
92
{
93
    m_listCtrl = NULL;
94
 
95
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
96
 
97
    ecDialog::Create(parent, ecID_PLATFORMS_DIALOG, _("Platforms"),
98
        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
99
 
100
    CreateControls(this);
101
 
102
    Centre(wxBOTH);
103
 
104
    unsigned int i;
105
    for(i=0; i < CeCosTestPlatform::Count(); i++)
106
    {
107
        Add(*CeCosTestPlatform::Get(i));
108
    }
109
}
110
 
111
ecPlatformsDialog::~ecPlatformsDialog()
112
{
113
    Clear();
114
}
115
 
116
void ecPlatformsDialog::Clear()
117
{
118
#if wxCHECK_VERSION(2, 6, 0)
119
    wxNode* node = m_arTargetInfo.GetFirst();
120
    while (node)
121
    {
122
        CeCosTestPlatform* platform = (CeCosTestPlatform*) node->GetData();
123
        delete platform;
124
        node = node->GetNext();
125
#else
126
    wxNode* node = m_arTargetInfo.First();
127
    while (node)
128
    {
129
        CeCosTestPlatform* platform = (CeCosTestPlatform*) node->Data();
130
        delete platform;
131
        node = node->Next();
132
#endif
133
    }
134
    m_arTargetInfo.Clear();
135
}
136
 
137
void ecPlatformsDialog::CreateControls(wxWindow* parent)
138
{
139
    // Create custom windows first
140
    m_listCtrl = new ecPlatformsListCtrl(parent, ecID_PLATFORMS_LIST, wxDefaultPosition, wxSize(450, 300), wxLC_REPORT|wxCLIP_CHILDREN|wxSUNKEN_BORDER);
141
    m_listCtrl->InsertColumn(0, _("Target"), wxLIST_FORMAT_LEFT, 70);
142
    m_listCtrl->InsertColumn(1, _("Prefix"), wxLIST_FORMAT_LEFT, 70);
143
    m_listCtrl->InsertColumn(2, _("Commands"), wxLIST_FORMAT_LEFT, 70);
144
    m_listCtrl->InsertColumn(3, _("Inferior"), wxLIST_FORMAT_LEFT, 70);
145
    m_listCtrl->InsertColumn(4, _("Prompt"), wxLIST_FORMAT_LEFT, 70);
146
    m_listCtrl->InsertColumn(5, _("ServerSideGdb"), wxLIST_FORMAT_LEFT, 80);
147
 
148
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
149
 
150
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
151
 
152
    wxButton *item2 = new wxButton( parent, ecID_PLATFORMS_MODIFY, _("&Modify..."), wxDefaultPosition, wxDefaultSize, 0 );
153
    item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
154
 
155
    wxButton *item3 = new wxButton( parent, ecID_PLATFORMS_ADD, _("&Add..."), wxDefaultPosition, wxDefaultSize, 0 );
156
    item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
157
 
158
    wxButton *item4 = new wxButton( parent, ecID_PLATFORMS_DELETE, _("&Delete..."), wxDefaultPosition, wxDefaultSize, 0 );
159
    item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
160
 
161
    wxButton *item5 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
162
    item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
163
 
164
    wxButton *item6 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
165
    item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
166
 
167
#ifdef __WXGTK__
168
    wxButton *contextButton = new wxContextHelpButton( parent );
169
    item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
170
#endif
171
 
172
    item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
173
 
174
    wxWindow *item7 = parent->FindWindow( ecID_PLATFORMS_LIST );
175
    wxASSERT( item7 );
176
    item0->Add( item7, 2, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
177
 
178
#if 0
179
    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
180
 
181
    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
182
 
183
    wxButton *item2 = new wxButton( parent, ecID_PLATFORMS_MODIFY, "&Modify...", wxDefaultPosition, wxDefaultSize, 0 );
184
    item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
185
 
186
    wxButton *item3 = new wxButton( parent, ecID_PLATFORMS_ADD, "&Add...", wxDefaultPosition, wxDefaultSize, 0 );
187
    item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );
188
 
189
    wxButton *item4 = new wxButton( parent, ecID_PLATFORMS_DELETE, "&Delete...", wxDefaultPosition, wxDefaultSize, 0 );
190
    item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );
191
 
192
    wxButton *item5 = new wxButton( parent, wxID_OK, "&OK", wxDefaultPosition, wxDefaultSize, 0 );
193
    item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
194
 
195
    wxButton *item6 = new wxButton( parent, wxID_CANCEL, "&Cancel", wxDefaultPosition, wxDefaultSize, 0 );
196
    item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
197
 
198
#ifdef __WXGTK__
199
    wxButton *contextButton = new wxContextHelpButton( parent );
200
    item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
201
#endif
202
 
203
    item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 0 );
204
 
205
    wxWindow *item7 = parent->FindWindow( ecID_PLATFORMS_LIST );
206
    wxASSERT( item7 );
207
    item0->Add( item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
208
#endif
209
 
210
    parent->SetAutoLayout( TRUE );
211
    parent->SetSizer( item0 );
212
    parent->Layout();
213
    item0->Fit( parent );
214
    item0->SetSizeHints( parent );
215
 
216
    ((wxButton*) FindWindow(wxID_OK))->SetDefault();
217
 
218
    // Add context-sensitive help text
219
    parent->FindWindow( ecID_PLATFORMS_LIST )->SetHelpText(_("Displays the list of platforms."));
220
    parent->FindWindow( ecID_PLATFORMS_MODIFY )->SetHelpText(_("Changes the characteristics of the currently selected platform."));
221
    parent->FindWindow( ecID_PLATFORMS_ADD )->SetHelpText(_("Adds a new platform."));
222
    parent->FindWindow( ecID_PLATFORMS_DELETE )->SetHelpText(_("Removes the currently selected platform."));
223
    parent->FindWindow( wxID_OK )->SetHelpText(_("Closes the dialog and saves any changes you have made."));
224
    parent->FindWindow( wxID_CANCEL )->SetHelpText(_("Closes the dialog without saving any changes you have made."));
225
 
226
#if __WXGTK__
227
    parent->FindWindow( wxID_CONTEXT_HELP )->SetHelpText(_("Invokes context-sensitive help for the clicked-on window."));
228
#endif
229
}
230
 
231
void ecPlatformsDialog::OnModify(wxCommandEvent& event)
232
{
233
    long n = m_listCtrl->GetItemCount();
234
    long i;
235
    for (i = 0; i < n; i++)
236
    {
237
        if (m_listCtrl->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED)
238
        {
239
            CeCosTestPlatform *pti=Platform(i);
240
 
241
            ecPlatformEditorDialog dlg(this);
242
 
243
            dlg.m_strPlatform = pti->Name();
244
            dlg.m_strPrefix = pti->Prefix();
245
            dlg.m_strGDB = pti->GdbCmds();
246
            dlg.m_strCaption = wxT("Modify Platform");
247
            dlg.m_strPrompt = pti->Prompt();
248
            dlg.m_bServerSideGdb = pti->ServerSideGdb();
249
            dlg.m_strInferior = pti->Inferior();
250
 
251
            if ( wxID_CANCEL != dlg.ShowModal() )
252
            {
253
                *pti = CeCosTestPlatform(dlg.m_strPlatform,dlg.m_strPrefix,dlg.m_strPrompt,dlg.m_strGDB,dlg.m_bServerSideGdb,dlg.m_strInferior);
254
                m_listCtrl->SetItem(i, 1, pti->Prefix());
255
                m_listCtrl->SetItem(i, 2, pti->GdbCmds());
256
                m_listCtrl->SetItem(i, 3, pti->Inferior());
257
                m_listCtrl->SetItem(i, 4, pti->Prompt());
258
                m_listCtrl->SetItem(i, 5, pti->ServerSideGdb() ? wxT("Y") : wxT("N"));
259
            }
260
        }
261
    }
262
}
263
 
264
static long ecFindListCtrlSelection(long& whereFrom, wxListCtrl* listCtrl)
265
{
266
    long n = listCtrl->GetItemCount();
267
    long i;
268
    for (i = whereFrom; i < n; i++)
269
    {
270
        if (listCtrl->GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED)
271
        {
272
            whereFrom = i+1;
273
            return i;
274
        }
275
    }
276
    return -1;
277
}
278
 
279
void ecPlatformsDialog::OnDelete(wxCommandEvent& event)
280
{
281
    long sel = -1;
282
    long whereFrom = 0;
283
    do
284
    {
285
        sel = ecFindListCtrlSelection(whereFrom, m_listCtrl);
286
        if (sel > -1)
287
        {
288
            if (wxYES == wxMessageBox(wxT("Are you sure you wish to delete this platform?"), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxYES_NO, this))
289
            {
290
                delete Platform(sel);
291
                m_listCtrl->DeleteItem(sel);
292
#if wxCHECK_VERSION(2, 6, 0)
293
                delete m_arTargetInfo.Item(sel);
294
#else
295
                delete m_arTargetInfo.Nth(sel);
296
#endif
297
                whereFrom = 0;
298
            }
299
        }
300
    } while (sel > -1) ;
301
}
302
 
303
void ecPlatformsDialog::OnAdd(wxCommandEvent& event)
304
{
305
    ecPlatformEditorDialog dlg(this);
306
    dlg.m_strCaption = wxT("New Platform");
307
    if (wxID_OK == dlg.ShowModal())
308
    {
309
        if( -1 == m_listCtrl->FindItem(-1, dlg.m_strPlatform) )
310
        {
311
            Add(CeCosTestPlatform(dlg.m_strPlatform,dlg.m_strPrefix,dlg.m_strPrompt,dlg.m_strGDB,dlg.m_bServerSideGdb,dlg.m_strInferior));
312
        } else {
313
            wxMessageBox(wxT("That platform name is already in use."), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
314
        }
315
    }
316
}
317
 
318
void ecPlatformsDialog::OnCancel(wxCommandEvent& event)
319
{
320
    event.Skip();
321
}
322
 
323
void ecPlatformsDialog::OnOK(wxCommandEvent& event)
324
{
325
    event.Skip();
326
}
327
 
328
void ecPlatformsDialog::Add(const CeCosTestPlatform &ti)
329
{
330
    wxListCtrl* listCtrl = (wxListCtrl*) FindWindow( ecID_PLATFORMS_LIST );
331
    int i = listCtrl->GetItemCount();
332
 
333
    listCtrl->InsertItem(i,ti.Name());
334
    listCtrl->SetItem(i,1,ti.Prefix());
335
    listCtrl->SetItem(i,2,ti.GdbCmds());
336
    listCtrl->SetItem(i,3,ti.Inferior());
337
    listCtrl->SetItem(i,4,ti.Prompt());
338
    listCtrl->SetItem(i,5,ti.ServerSideGdb() ? wxT("Y"):wxT("N"));
339
 
340
    m_arTargetInfo.Append((wxObject*) new CeCosTestPlatform(ti));
341
}
342
 
343
void ecPlatformsDialog::OnUpdateAny(wxUpdateUIEvent& event)
344
{
345
    event.Enable( m_listCtrl->GetSelectedItemCount() > 0 );
346
}
347
 
348
void ecPlatformsDialog::OnDoubleLClick()
349
{
350
    wxCommandEvent event;
351
    OnModify(event);
352
}
353
 
354
void ecPlatformsDialog::OnDeleteKey()
355
{
356
    wxCommandEvent event;
357
    OnDelete(event);
358
}
359
 
360
/*
361
 * ecPlatformsListCtrl
362
 */
363
 
364
IMPLEMENT_CLASS(ecPlatformsListCtrl, wxListCtrl)
365
 
366
BEGIN_EVENT_TABLE(ecPlatformsListCtrl, wxListCtrl)
367
    EVT_LEFT_DCLICK(ecPlatformsListCtrl::OnDoubleLClick)
368
    EVT_CHAR(ecPlatformsListCtrl::OnChar)
369
END_EVENT_TABLE()
370
 
371
ecPlatformsListCtrl::ecPlatformsListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt,
372
        const wxSize& sz, long style):
373
        wxListCtrl(parent, id, pt, sz, style)
374
{
375
}
376
 
377
void ecPlatformsListCtrl::OnDoubleLClick(wxMouseEvent& event)
378
{
379
    ecPlatformsDialog* parent = (ecPlatformsDialog*) GetParent();
380
    parent->OnDoubleLClick();
381
}
382
 
383
void ecPlatformsListCtrl::OnChar(wxKeyEvent& event)
384
{
385
    if (event.GetKeyCode() == WXK_DELETE)
386
    {
387
        ecPlatformsDialog* parent = (ecPlatformsDialog*) GetParent();
388
        parent->OnDeleteKey();
389
    }
390
    else
391
        event.Skip();
392
}

powered by: WebSVN 2.1.0

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