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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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