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

Subversion Repositories openrisc

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

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, 2003, 2004, 2005, 2006, 2008, 2009, 2011 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
// mainwin.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians, jld
28
// Contact(s):  julians, jld
29
// Date:        2000/08/24
30
// Version:     $Id: mainwin.cpp,v 1.57 2002/02/28 18:30:35 julians Exp $
31
// Purpose:
32
// Description: Implementation file for the ConfigTool main window
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 "mainwin.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
#include "wx/wxhtml.h"
63
#include "wx/filedlg.h"
64
#include "wx/wfstream.h"
65
 
66
#include "mainwin.h"
67
#include "configtool.h"
68
#include "configtree.h"
69
#include "propertywin.h"
70
#include "conflictwin.h"
71
#include "mltwin.h"
72
#include "outputwin.h"
73
#include "shortdescrwin.h"
74
#include "conflictsdlg.h"
75
#include "aboutdlg.h"
76
#include "finddlg.h"
77
#include "settingsdlg.h"
78
#include "platformsdlg.h"
79
#include "buildoptionsdlg.h"
80
#include "templatesdlg.h"
81
#include "admindlg.h"
82
#include "packagesdlg.h"
83
#include "configtooldoc.h"
84
#include "configtoolview.h"
85
#include "folderdlg.h"
86
#include "reposdlg.h"
87
#include "docsystem.h"
88
#include "symbols.h"
89
 
90
#ifdef __WXMSW__
91
#include "wx/msw/winundef.h"
92
#if wxCHECK_VERSION(2, 6, 0)
93
#include "wx/msw/wrapcctl.h" /* for TVS_NOHSCROLL */
94
#else
95
#define _WIN32_IE 0x0600 /* assume maximal feature set */
96
#include <commctrl.h> /* for TVS_NOHSCROLL */
97
#endif
98
#endif
99
 
100
// ----------------------------------------------------------------------------
101
// resources
102
// ----------------------------------------------------------------------------
103
// the application icon
104
#if defined(__WXGTK__) || defined(__WXMOTIF__)
105
#include "bitmaps/configtool.xpm"
106
#include "bitmaps/new.xpm"
107
#include "bitmaps/open.xpm"
108
#include "bitmaps/save.xpm"
109
#include "bitmaps/copy.xpm"
110
#include "bitmaps/paste.xpm"
111
#include "bitmaps/cut.xpm"
112
#include "bitmaps/delete.xpm"
113
#include "bitmaps/help.xpm"
114
#include "bitmaps/cshelp.xpm"
115
#include "bitmaps/search.xpm"
116
#include "bitmaps/stopbuild.xpm"
117
#include "bitmaps/buildlibrary.xpm"
118
#include "bitmaps/newregion.xpm"
119
#include "bitmaps/newsection.xpm"
120
#include "bitmaps/properties.xpm"
121
#endif
122
 
123
// ----------------------------------------------------------------------------
124
// event tables and other macros for wxWindows
125
// ----------------------------------------------------------------------------
126
 
127
BEGIN_EVENT_TABLE(ecMainFrame, wxDocParentFrame)
128
    EVT_MENU(wxID_EXIT,  ecMainFrame::OnQuit)
129
    EVT_MENU(wxID_ABOUT, ecMainFrame::OnAbout)
130
    EVT_MENU(ecID_REPOSITORY_INFO, ecMainFrame::OnRepositoryInfo)
131
    EVT_MENU(wxID_FIND, ecMainFrame::OnFind)
132
    EVT_MENU(ecID_FIND_NEXT, ecMainFrame::OnFindNext)
133
    EVT_SASH_DRAGGED_RANGE(ecID_CONFIG_SASH_WINDOW, ecID_OUTPUT_SASH_WINDOW, ecMainFrame::OnSashDrag)
134
    EVT_SIZE(ecMainFrame::OnSize)
135
    EVT_IDLE(ecMainFrame::OnIdle)
136
    EVT_CLOSE(ecMainFrame::OnCloseWindow)
137
    EVT_MENU(ecID_TOGGLE_CONFLICTS, ecMainFrame::OnToggleWindow)
138
    EVT_MENU(ecID_TOGGLE_PROPERTIES, ecMainFrame::OnToggleWindow)
139
    EVT_MENU(ecID_TOGGLE_MEMORY, ecMainFrame::OnToggleWindow)
140
    EVT_MENU(ecID_TOGGLE_SHORT_DESCR, ecMainFrame::OnToggleWindow)
141
    EVT_MENU(ecID_TOGGLE_OUTPUT, ecMainFrame::OnToggleWindow)
142
    EVT_MENU(ecID_TOOLBARS, ecMainFrame::OnToggleToolbar)
143
    EVT_MENU(ecID_CONFIGTOOL_HELP, ecMainFrame::OnHelpConfigtool)
144
    EVT_MENU(ecID_ECOS_HELP, ecMainFrame::OnHelpEcos)
145
    EVT_MENU(ecID_CONTEXT_HELP, ecMainFrame::OnHelpContext)
146
    EVT_MENU(ecID_RESOLVE_CONFLICTS, ecMainFrame::OnResolveConflicts)
147
    EVT_UPDATE_UI(ecID_RESOLVE_CONFLICTS, ecMainFrame::OnUpdateResolveConflicts)
148
    EVT_MENU(ecID_SETTINGS, ecMainFrame::OnSettings)
149
    EVT_MENU(ecID_PLATFORMS, ecMainFrame::OnPlatforms)
150
    EVT_MENU(ecID_BUILD_OPTIONS, ecMainFrame::OnBuildOptions)
151
    EVT_MENU(ecID_PATHS_BUILD_TOOLS, ecMainFrame::OnBuildToolsPath)
152
    EVT_MENU(ecID_PATHS_USER_TOOLS, ecMainFrame::OnUserToolsPath)
153
    EVT_MENU(ecID_BUILD_TEMPLATES, ecMainFrame::OnTemplates)
154
    EVT_MENU(ecID_ADMINISTRATION, ecMainFrame::OnAdmin)
155
    EVT_MENU(ecID_BUILD_PACKAGES, ecMainFrame::OnPackages)
156
    EVT_MENU(ecID_RUN_TESTS, ecMainFrame::OnRunTests)
157
    EVT_MENU(ecID_BUILD_REPOSITORY, ecMainFrame::OnChooseRepository)
158
    EVT_MENU(ecID_WHATS_THIS, ecMainFrame::OnWhatsThis)
159
    EVT_MENU(ecID_SAVE_OUTPUT, ecMainFrame::OnSaveOutput)
160
    EVT_MENU(ecID_IMPORT, ecMainFrame::OnImport)
161
    EVT_MENU(ecID_EXPORT, ecMainFrame::OnExport)
162
    EVT_MENU(ecID_REDHAT_WEB_HOME, ecMainFrame::OnWebRedHatHome)
163
    EVT_MENU(ecID_REDHAT_WEB_ECOS, ecMainFrame::OnWebEcos)
164
    EVT_MENU(ecID_REDHAT_WEB_NET_RELEASE, ecMainFrame::OnWebNetRelease)
165
    EVT_MENU(ecID_REDHAT_WEB_UITRON, ecMainFrame::OnWebUitron)
166
    EVT_MENU(ecID_STOP_BUILD, ecMainFrame::OnStopBuild)
167
    EVT_MENU(ecID_BUILD_LIBRARY, ecMainFrame::OnBuildLibrary)
168
    EVT_MENU(ecID_BUILD_TESTS, ecMainFrame::OnBuildTests)
169
    EVT_MENU(ecID_CLEAN, ecMainFrame::OnClean)
170
    EVT_MENU(ecID_SHELL, ecMainFrame::OnShell)
171
    EVT_MENU(ecID_INDEX_DOCS, ecMainFrame::OnIndexDocs)
172
    EVT_MENU(ecID_GENERATE_BUILD_TREE, ecMainFrame::OnGenerateBuildTree)
173
 
174
    EVT_UPDATE_UI(ecID_PLATFORMS, ecMainFrame::OnUpdatePlatforms)
175
    EVT_UPDATE_UI(ecID_BUILD_OPTIONS, ecMainFrame::OnUpdateBuildOptions)
176
    EVT_UPDATE_UI(ecID_PATHS_BUILD_TOOLS, ecMainFrame::OnUpdateBuildToolsPath)
177
    EVT_UPDATE_UI(ecID_PATHS_USER_TOOLS, ecMainFrame::OnUpdateUserToolsPath)
178
    EVT_UPDATE_UI(ecID_BUILD_TEMPLATES, ecMainFrame::OnUpdateTemplates)
179
    EVT_UPDATE_UI(ecID_ADMINISTRATION, ecMainFrame::OnUpdateAdmin)
180
    EVT_UPDATE_UI(ecID_BUILD_PACKAGES, ecMainFrame::OnUpdatePackages)
181
    EVT_UPDATE_UI(ecID_RUN_TESTS, ecMainFrame::OnUpdateRunTests)
182
    EVT_UPDATE_UI(ecID_BUILD_REPOSITORY, ecMainFrame::OnUpdateChooseRepository)
183
    EVT_UPDATE_UI(ecID_CLEAN, ecMainFrame::OnUpdateClean)
184
    EVT_UPDATE_UI(ecID_REPOSITORY_INFO, ecMainFrame::OnUpdateRepositoryInfo)
185
    EVT_UPDATE_UI(ecID_INDEX_DOCS, ecMainFrame::OnUpdateIndexDocs)
186
 
187
    EVT_UPDATE_UI(ecID_TOGGLE_CONFLICTS, ecMainFrame::OnUpdateToggleWindow)
188
    EVT_UPDATE_UI(ecID_TOGGLE_PROPERTIES, ecMainFrame::OnUpdateToggleWindow)
189
    EVT_UPDATE_UI(ecID_TOGGLE_MEMORY, ecMainFrame::OnUpdateToggleWindow)
190
    EVT_UPDATE_UI(ecID_TOGGLE_SHORT_DESCR, ecMainFrame::OnUpdateToggleWindow)
191
    EVT_UPDATE_UI(ecID_TOGGLE_OUTPUT, ecMainFrame::OnUpdateToggleWindow)
192
    EVT_UPDATE_UI(ecID_TOOLBARS, ecMainFrame::OnUpdateToggleToolbar)
193
 
194
    // Disable commands that don't make sense immediately or are not yet implemented.
195
    // Also, for text controls, disable if they are not being enabled by currently-focussed controls.
196
    EVT_UPDATE_UI(wxID_COPY, ecMainFrame::OnUpdateDisable)
197
    EVT_UPDATE_UI(wxID_CUT, ecMainFrame::OnUpdateDisable)
198
    EVT_UPDATE_UI(wxID_PASTE, ecMainFrame::OnUpdateDisable)
199
    EVT_UPDATE_UI(wxID_SELECTALL, ecMainFrame::OnUpdateSelectAll)
200
    EVT_UPDATE_UI(wxID_CLEAR, ecMainFrame::OnUpdateClear)
201
 
202
    EVT_UPDATE_UI(wxID_FIND, ecMainFrame::OnUpdateFind)
203
    EVT_UPDATE_UI(ecID_FIND_NEXT, ecMainFrame::OnUpdateFindNext)
204
 
205
    EVT_MENU(ecID_NEW_REGION, ecMainFrame::OnNewRegion)
206
    EVT_MENU(ecID_NEW_SECTION, ecMainFrame::OnNewSection)
207
    EVT_MENU(ecID_DELETE, ecMainFrame::OnDeleteRegionOrSection)
208
    EVT_MENU(ecID_PROPERTIES, ecMainFrame::OnRegionOrSectionProperties)
209
 
210
    EVT_UPDATE_UI(ecID_STOP_BUILD, ecMainFrame::OnUpdateStopBuild)
211
    EVT_UPDATE_UI(ecID_BUILD_LIBRARY, ecMainFrame::OnUpdateBuildLibrary)
212
    EVT_UPDATE_UI(ecID_BUILD_TESTS, ecMainFrame::OnUpdateBuildTests)
213
    EVT_UPDATE_UI(ecID_GENERATE_BUILD_TREE, ecMainFrame::OnUpdateGenerateBuildTree)
214
 
215
    EVT_UPDATE_UI(ecID_SHELL, ecMainFrame::OnUpdateShell)
216
 
217
    EVT_UPDATE_UI(ecID_NEW_REGION, ecMainFrame::OnUpdateNewRegion)
218
    EVT_UPDATE_UI(ecID_NEW_SECTION, ecMainFrame::OnUpdateNewSection)
219
    EVT_UPDATE_UI(ecID_DELETE, ecMainFrame::OnUpdateDeleteRegionOrSection)
220
    EVT_UPDATE_UI(ecID_PROPERTIES, ecMainFrame::OnUpdateRegionOrSectionProperties)
221
 
222
    EVT_UPDATE_UI(ecID_IMPORT, ecMainFrame::OnUpdateImport)
223
    EVT_UPDATE_UI(ecID_EXPORT, ecMainFrame::OnUpdateExport)
224
END_EVENT_TABLE()
225
 
226
// ----------------------------------------------------------------------------
227
// main frame
228
// ----------------------------------------------------------------------------
229
 
230
// Frame constructor
231
ecMainFrame::ecMainFrame(wxDocManager *manager, const wxString& title, const wxPoint& pos, const wxSize& size):
232
    wxDocParentFrame(manager, (wxFrame *)NULL, ecID_MAIN_FRAME, title, pos, size, wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE )
233
{
234
    m_splitter = NULL;
235
    m_scrolledWindow = NULL;
236
    m_tree = NULL;
237
    m_configSashWindow = NULL;
238
    m_valueWindow = NULL;
239
    m_outputWindow = NULL;
240
    m_shortDescrWindow = NULL;
241
    m_conflictsSashWindow = NULL;
242
    m_propertiesSashWindow = NULL;
243
    m_memorySashWindow = NULL;
244
    m_shortDescrSashWindow = NULL;
245
    m_outputSashWindow = NULL;
246
    m_propertyListWindow = NULL;
247
    m_findDialog = NULL;
248
    m_mltWindow = NULL;
249
 
250
#ifdef __WXMAC__
251
    // we need this in order to allow the about menu relocation, since ABOUT is
252
    // not the default id of the about menu
253
    wxApp::s_macAboutMenuItemId = wxID_EXIT;
254
#endif
255
 
256
    CreateWindows();
257
 
258
    wxIcon mainIcon(wxICON(configtool));
259
    wxGetApp().SetMainIcon(mainIcon);
260
 
261
    // set the frame icon
262
    SetIcon(mainIcon);
263
 
264
    // create a menu bar
265
 
266
    // File menu
267
    wxMenu *fileMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
268
 
269
    fileMenu->Append(wxID_NEW, _("&New\tCtrl+N"), _("Creates a new document"));
270
#if 0
271
    wxMenuItem* menuItem = new wxMenuItem(fileMenu, wxID_NEW, _("&New\tCtrl+N"), _("Creates a new document"));
272
    menuItem->SetBitmaps(wxBITMAP(new));
273
    fileMenu->Append(menuItem);
274
#endif
275
 
276
    fileMenu->Append(wxID_OPEN, _("&Open\tCtrl+O"), _("Opens an existing document"));
277
    fileMenu->Append(wxID_SAVE, _("&Save\tCtrl+S"), _("Saves the active document"));
278
    fileMenu->Append(wxID_SAVEAS, _("Save &As..."), _("Saves the active document with a new name"));
279
    fileMenu->AppendSeparator();
280
    fileMenu->Append(ecID_IMPORT, _("&Import..."), _("Imports a minimal configuration exported from another configuration"));
281
    fileMenu->Append(ecID_EXPORT, _("&Export..."), _("Exports a minimal configuration for importing into another configuration"));
282
    fileMenu->AppendSeparator();
283
    fileMenu->Append(wxID_EXIT, _("E&xit\tAlt+X"), _("Quits the application"));
284
 
285
    // A history of files visited. Use this menu.
286
    wxGetApp().GetDocManager()->FileHistoryUseMenu(fileMenu);
287
    // Load file history
288
    {
289
        wxConfig config(wxGetApp().GetSettings().GetConfigAppName());
290
        config.SetPath(wxT("FileHistory/"));
291
        wxGetApp().GetDocManager()->FileHistoryLoad(config);
292
    }
293
 
294
    // Edit menu
295
    wxMenu* editMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
296
 
297
    editMenu->Append(wxID_CUT, _("Cu&t\tCtrl+X"), _("Cuts the output pane selection and moves it to the Clipboard"));
298
    editMenu->Append(wxID_COPY, _("&Copy\tCtrl+C"), _("Copies the output pane selection to the clipboard"));
299
    editMenu->Append(wxID_PASTE, _("&Paste\tCtrl+V"), _("Inserts Clipboard contents"));
300
    editMenu->Append(wxID_CLEAR, _("&Clear"), _("Erases everything in the output pane"));
301
    editMenu->AppendSeparator();
302
    editMenu->Append(wxID_SELECTALL, _("&Select All\tCtrl+A"), _("Selects the entire output pane"));
303
    editMenu->AppendSeparator();
304
    editMenu->Append(wxID_FIND, _("&Find...\tCtrl+F"), _("Finds the specified text"));
305
    editMenu->Append(ecID_FIND_NEXT, _("Find &Next\tF3"), _("Finds the next item matching the Find text"));
306
    editMenu->AppendSeparator();
307
    editMenu->Append(ecID_SAVE_OUTPUT, _("Sa&ve Output..."), _("Saves the contents of the output pane"));
308
 
309
    // View menu
310
    wxMenu* viewMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
311
 
312
    viewMenu->Append(ecID_SETTINGS, _("&Settings...\tCtrl+T"), _("Shows the application settings dialog"));
313
    viewMenu->AppendSeparator();
314
    viewMenu->Append(ecID_TOOLBARS, _("&Toolbar"), _("Shows or hides the toolbar"), TRUE);
315
    viewMenu->Append(ecID_TOGGLE_PROPERTIES, _("&Properties\tAlt+1"), _("Shows or hides the properties window"), TRUE);
316
    viewMenu->Append(ecID_TOGGLE_OUTPUT, _("&Output\tAlt+2"), _("Shows the output window"), TRUE);
317
    viewMenu->Append(ecID_TOGGLE_SHORT_DESCR, _("&Short Description\tAlt+3"), _("Shows or hides the short description window"), TRUE);
318
 
319
    viewMenu->Append(ecID_TOGGLE_CONFLICTS, _("&Conflicts\tAlt+4"), _("Shows or hides the conflicts window"), TRUE);
320
#if ecUSE_MLT
321
    viewMenu->Append(ecID_TOGGLE_MEMORY, _("&Memory Layout\tAlt+5"), _("Shows or hides the memory layout window"), TRUE);
322
    //viewMenu->Enable(ecID_TOGGLE_MEMORY, FALSE);
323
#endif
324
 
325
    // Not clear what these do, so let's not have them.
326
    //viewMenu->Append(ecID_VIEW_NEXT, _("&Next\tAlt+F6"), _("Selects the next visible pane"));
327
    //viewMenu->Append(ecID_VIEW_PREVIOUS, _("&Previous\tShift+Alt+F6"), _("Selects the previous visible pane"));
328
 
329
    // Build menu
330
    wxMenu* buildMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
331
 
332
    buildMenu->Append(ecID_BUILD_LIBRARY, _("&Library\tF7"), _("Builds the library"));
333
    buildMenu->Append(ecID_BUILD_TESTS, _("&Tests\tShift+F7"), _("Builds the tests"));
334
    buildMenu->Append(ecID_CLEAN, _("&Clean"), _("Deletes intermediate and output files"));
335
    buildMenu->Append(ecID_STOP_BUILD, _("&Stop"), _("Stops the build"));
336
    buildMenu->AppendSeparator();
337
    buildMenu->Append(ecID_GENERATE_BUILD_TREE, _("&Generate Build Tree"), _("Explicitly recreates the build tree"));
338
    buildMenu->AppendSeparator();
339
    buildMenu->Append(ecID_BUILD_OPTIONS, _("&Options..."), _("Changes build options"));
340
    buildMenu->Append(ecID_BUILD_REPOSITORY, _("&Repository..."), _("Selects repository"));
341
    buildMenu->Append(ecID_BUILD_TEMPLATES, _("Te&mplates..."), _("Selects the package templates"));
342
    buildMenu->Append(ecID_BUILD_PACKAGES, _("&Packages..."), _("Selects individual packages"));
343
 
344
    // Tools menu
345
    wxMenu* toolsMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
346
 
347
    wxMenu* pathMenu = new wxMenu;
348
    pathMenu->Append(ecID_PATHS_BUILD_TOOLS, _("&Build Tools..."), _("Specifies the folder containing the build tools"));
349
    pathMenu->Append(ecID_PATHS_USER_TOOLS, _("&User Tools..."), _("Specifies the folder containing the user tools"));
350
    toolsMenu->Append(ecID_PATHS, _("&Paths"), pathMenu);
351
 
352
    toolsMenu->Append(ecID_SHELL, _("&Shell..."), _("Invokes a command shell"));
353
    toolsMenu->Append(ecID_RUN_TESTS, _("&Run Tests...\tCtrl+F5"), _("Runs the configuration tests"));
354
    toolsMenu->Append(ecID_PLATFORMS, _("Plat&forms..."), _("Edits the platforms list"));
355
    toolsMenu->Append(ecID_RESOLVE_CONFLICTS, _("Resolve &Conflicts..."), _("Resolves conflicts"));
356
    toolsMenu->Append(ecID_ADMINISTRATION, _("&Administration..."), _("Performs repository administration tasks"));
357
#if 0
358
    toolsMenu->AppendSeparator();
359
    toolsMenu->Append(ecID_TOOLS_OPTIONS, _("&Options..."), _("Changes configuration options"));
360
#endif
361
    toolsMenu->Append(ecID_INDEX_DOCS, _("Regenerate Help &Index"), _("Regenerates the online help contents"));
362
 
363
    // Help menu
364
    wxMenu* helpMenu = new wxMenu;
365
    helpMenu->Append(ecID_CONFIGTOOL_HELP, _("&Configuration Tool Help\tShift+F1"), _("Displays help"));
366
    helpMenu->Append(ecID_ECOS_HELP, _("&eCos Documentation"), _("Displays the documentation home page"));
367
    helpMenu->Append(ecID_CONTEXT_HELP, _("&Help On..."), _("Displays help for clicked-on windows"));
368
    helpMenu->AppendSeparator();
369
 
370
    wxMenu* webMenu = new wxMenu;
371
    webMenu->Append(ecID_REDHAT_WEB_HOME, _("&Red Hat Home Page"), _("Opens the Red Hat home page"));
372
    webMenu->Append(ecID_REDHAT_WEB_ECOS, _("&eCos Product Page"), _("Opens the eCos product page"));
373
    webMenu->Append(ecID_REDHAT_WEB_NET_RELEASE, _("eCos &Net Release Page"), _("Opens the eCos net release page"));
374
    webMenu->AppendSeparator();
375
    webMenu->Append(ecID_REDHAT_WEB_UITRON, _("&ITRON"), _("Opens the ITRON specification page"));
376
 
377
//    helpMenu->Append(ecID_REDHAT_WEB, _("&Red Hat on the Web"), webMenu);
378
//    helpMenu->AppendSeparator();
379
    helpMenu->Append(ecID_REPOSITORY_INFO, _("Repository &Information...\tCtrl+I"), _("Displays information about the current repository"));
380
    helpMenu->Append(wxID_ABOUT, _("&About the Configuration Tool..."), _("Displays program information, version and copyright"));
381
 
382
    wxMenuBar *menuBar = new wxMenuBar();
383
    menuBar->Append(fileMenu, _("&File"));
384
    menuBar->Append(editMenu, _("&Edit"));
385
    menuBar->Append(viewMenu, _("&View"));
386
    menuBar->Append(buildMenu, _("&Build"));
387
    menuBar->Append(toolsMenu, _("&Tools"));
388
    menuBar->Append(helpMenu, _("&Help"));
389
 
390
    // ... and attach this menu bar to the frame
391
    SetMenuBar(menuBar);
392
 
393
    // Create the toolbar
394
    RecreateToolbar();
395
 
396
    if (!wxGetApp().GetSettings().m_showToolBar)
397
        GetToolBar()->Show( FALSE );
398
 
399
    // Create the status bar
400
#ifdef __WXMSW__
401
    CreateStatusBar(4, wxST_SIZEGRIP);
402
#else
403
    CreateStatusBar(4, 0);
404
#endif
405
 
406
    int* widths = new int[4];
407
    widths[0] = -1; widths[1] = 100; widths[2] = 40; widths[3] = 100;
408
    SetStatusWidths(4, widths);
409
    delete[] widths;
410
 
411
    SetStatusText(_("No conflicts"), ecFailRulePane);
412
    SetStatusText(_("Ready"), ecStatusPane);
413
}
414
 
415
// Create the windows
416
void ecMainFrame::CreateWindows()
417
{
418
    ecSettings& stg = wxGetApp().GetSettings();
419
 
420
    // Create the sash layout windows first
421
 
422
    // Sash window for the output window
423
    m_outputSashWindow = new wxSashLayoutWindow(this, ecID_OUTPUT_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
424
    m_outputSashWindow->SetDefaultSize(stg.m_outputSashSize);
425
    m_outputSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
426
    m_outputSashWindow->SetAlignment(wxLAYOUT_BOTTOM);
427
    m_outputSashWindow->SetSashVisible(wxSASH_TOP, TRUE);
428
    m_outputWindow = new ecOutputWindow(m_outputSashWindow, ecID_OUTPUT_WINDOW, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxCLIP_CHILDREN|wxTE_READONLY|wxTE_RICH|wxSUNKEN_BORDER);
429
    m_outputWindow->SetHelpText(_("The output window displays various warning and informational messages."));
430
 
431
    // Sash window for the memory window
432
    m_memorySashWindow = new wxSashLayoutWindow(this, ecID_MEMORY_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxSW_3D|wxCLIP_SIBLINGS);
433
    m_memorySashWindow->SetDefaultSize(stg.m_memorySashSize);
434
    m_memorySashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
435
    m_memorySashWindow->SetAlignment(wxLAYOUT_BOTTOM);
436
    m_memorySashWindow->SetSashVisible(wxSASH_TOP, TRUE);
437
    //wxTextCtrl* memoryWindow = new wxTextCtrl(m_memorySashWindow, ecID_MEMORY_WINDOW, wxT("This will be the memory layout window."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxCLIP_CHILDREN|wxTE_NO_VSCROLL|wxTE_READONLY);
438
    m_mltWindow = new ecMemoryLayoutWindow(m_memorySashWindow, ecID_MEMORY_WINDOW, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN|wxSUNKEN_BORDER);
439
    m_mltWindow->SetHelpText(_("The memory layout window presents a graphical view of the memory layout of the currently selected\ncombination of target architecture, platform and start-up type."));
440
 
441
    // Sash window for the config tree
442
    m_configSashWindow = new wxSashLayoutWindow(this, ecID_CONFIG_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_CHILDREN/*|wxCLIP_SIBLINGS*/);
443
    m_configSashWindow->SetDefaultSize(stg.m_treeSashSize);
444
    m_configSashWindow->SetOrientation(wxLAYOUT_VERTICAL);
445
    m_configSashWindow->SetAlignment(wxLAYOUT_LEFT);
446
    m_configSashWindow->SetSashVisible(wxSASH_RIGHT, TRUE);
447
 
448
    // Sash window for the conflicts window
449
    m_conflictsSashWindow = new wxSashLayoutWindow(this, ecID_CONFLICTS_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
450
    m_conflictsSashWindow->SetDefaultSize(stg.m_conflictsSashSize);
451
    m_conflictsSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
452
    m_conflictsSashWindow->SetAlignment(wxLAYOUT_TOP);
453
    m_conflictsSashWindow->SetSashVisible(wxSASH_BOTTOM, TRUE);
454
    m_conflictsWindow = new ecConflictListCtrl(m_conflictsSashWindow, ecID_CONFLICTS_WINDOW, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxCLIP_CHILDREN|wxSUNKEN_BORDER);
455
    m_conflictsWindow->SetHelpText(_("The conflicts window lists any outstanding conflicts in the configuration."));
456
 
457
    // Sash window for the properties window
458
    m_propertiesSashWindow = new wxSashLayoutWindow(this, ecID_PROPERTIES_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
459
    m_propertiesSashWindow->SetDefaultSize(stg.m_propertiesSashSize);
460
    m_propertiesSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
461
    m_propertiesSashWindow->SetAlignment(wxLAYOUT_TOP);
462
    m_propertiesSashWindow->SetSashVisible(wxSASH_BOTTOM, TRUE);
463
//    wxTextCtrl* propertiesWindow = new wxTextCtrl(m_propertiesSashWindow, ecID_PROPERTIES_WINDOW, wxT("This will be the properties window."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxCLIP_CHILDREN|wxTE_NO_VSCROLL|wxTE_READONLY);
464
    m_propertyListWindow = new ecPropertyListCtrl(m_propertiesSashWindow, ecID_PROPERTIES_WINDOW, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxCLIP_CHILDREN|wxLC_VRULES|wxLC_HRULES|wxSUNKEN_BORDER);
465
    m_propertyListWindow->SetHelpText(_("The properties window shows the properties of the selected configuration item."));
466
 
467
    // Sash window for the short description window
468
    m_shortDescrSashWindow = new wxSashLayoutWindow(this, ecID_SHORT_DESCR_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
469
    m_shortDescrSashWindow->SetDefaultSize(stg.m_shortDescrSashSize);
470
    m_shortDescrSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
471
    m_shortDescrSashWindow->SetAlignment(wxLAYOUT_TOP);
472
    //m_shortDescrSashWindow->SetSashVisible(wxSASH_TOP, TRUE);
473
    m_shortDescrWindow = new ecShortDescriptionWindow(m_shortDescrSashWindow, ecID_SHORT_DESCR_WINDOW, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxCLIP_CHILDREN/*|wxTE_NO_VSCROLL*/|wxTE_READONLY);
474
    m_shortDescrWindow->SetBackgroundColour(wxColour(255, 255, 225));
475
    m_shortDescrWindow->SetHelpText(_("The short description window displays brief help on a selected configuration item."));
476
 
477
    // Create a composite widget to represent the scrolling config window
478
    m_scrolledWindow = new ecSplitterScrolledWindow(m_configSashWindow, ecID_SCROLLED_WINDOW, wxDefaultPosition,
479
        wxSize(400, 100), wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL);
480
    m_splitter = new wxThinSplitterWindow(m_scrolledWindow, ecID_SPLITTER_WINDOW, wxDefaultPosition,
481
        wxSize(400, 100),
482
#ifdef __WXMSW__
483
        wxSP_3DBORDER |
484
#else
485
        wxSUNKEN_BORDER |
486
#endif
487
        wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
488
    m_splitter->SetSashSize(2);
489
    m_tree = new ecConfigTreeCtrl(m_splitter, ecID_TREE_CTRL, wxDefaultPosition,
490
        wxSize(200, 100), wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER | wxTR_ROW_LINES /* | wxALWAYS_SHOW_SB */);
491
#ifdef __WXMSW__
492
    // disable horizontal scrolling of the config tree control
493
    HWND hTree = (HWND) m_tree->GetHandle();
494
    SetWindowLong (hTree, GWL_STYLE, GetWindowLong (hTree, GWL_STYLE) | TVS_NOHSCROLL);
495
#endif        
496
    m_valueWindow = new ecValueWindow(m_splitter, ecID_VALUE_WINDOW, wxDefaultPosition,
497
        wxSize(200, 100), wxNO_BORDER);
498
    m_splitter->SplitVertically(m_tree, m_valueWindow);
499
    m_splitter->SetMinimumPaneSize(100);
500
    //m_splitter->AdjustScrollbars();
501
    m_splitter->SetSashPosition(wxGetApp().GetSettings().m_configPaneWidth);
502
    m_scrolledWindow->SetTargetWindow(m_tree);
503
    m_scrolledWindow->EnableScrolling(FALSE, FALSE);
504
    m_tree->SetHelpText(_("The configuration window is the principal window used to configure eCos.\nIt takes the form of a tree-based representation of the configuration items within the currently loaded eCos packages."));
505
    m_valueWindow->SetHelpText(m_tree->GetHelpText());
506
 
507
    // Let the two controls know about each other
508
    m_valueWindow->SetTreeCtrl(m_tree);
509
    m_tree->SetCompanionWindow(m_valueWindow);
510
 
511
    // Set visibility according to config settings
512
    if (!wxGetApp().GetSettings().m_showConflictsWindow)
513
        m_conflictsSashWindow->Show(FALSE);
514
    if (!wxGetApp().GetSettings().m_showPropertiesWindow)
515
        m_propertiesSashWindow->Show(FALSE);
516
    if (!wxGetApp().GetSettings().m_showShortDescrWindow)
517
        m_shortDescrSashWindow->Show(FALSE);
518
    if (!wxGetApp().GetSettings().m_showOutputWindow)
519
        m_outputSashWindow->Show(FALSE);
520
    if (!wxGetApp().GetSettings().m_showMemoryWindow)
521
        m_memorySashWindow->Show(FALSE);
522
}
523
// event handlers
524
 
525
void ecMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
526
{
527
    Close();
528
}
529
 
530
void ecMainFrame::OnFind(wxCommandEvent& event)
531
{
532
    if (m_findDialog)
533
    {
534
        m_findDialog->Raise();
535
        return;
536
    }
537
 
538
    m_findDialog = new ecFindDialog (this, ecID_FIND_DIALOG, _("Find in configuration"));
539
    m_findDialog->Show(TRUE);
540
 
541
    // For some reason, under Windows, the text control doesn't get the focus if we set the focus
542
    // and then call Show. We have to set the focus afterwards instead.
543
    m_findDialog->FindWindow(ecID_FIND_DIALOG_WHAT)->SetFocus();
544
}
545
 
546
void ecMainFrame::OnFindNext(wxCommandEvent& event)
547
{
548
    if (wxGetApp().GetConfigToolDoc())
549
    {
550
        ecConfigToolView* view = (ecConfigToolView*) wxGetApp().GetConfigToolDoc()->GetFirstView() ;
551
 
552
        view->DoFind(wxGetApp().GetSettings().m_findText, this);
553
    }
554
}
555
 
556
void ecMainFrame::OnUpdateFind(wxUpdateUIEvent& event)
557
{
558
    event.Enable( wxGetApp().GetConfigToolDoc() != NULL );
559
}
560
 
561
void ecMainFrame::OnUpdateFindNext(wxUpdateUIEvent& event)
562
{
563
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && !wxGetApp().GetSettings().m_findText.IsEmpty() );
564
}
565
 
566
void ecMainFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
567
{
568
//    ecAboutDialog dialog(this, ecID_ABOUT_DIALOG, _("About eCos Configuration Tool"));
569
//    dialog.ShowModal();
570
        wxString msg;
571
        int iTclVerMajor, iTclVerMinor, iTclVerPatchLevel;
572
        Tcl_GetVersion (&iTclVerMajor, &iTclVerMinor, &iTclVerPatchLevel, NULL);
573
        msg.Printf("eCos Configuration Tool %s (%s %s)\n\n"
574
                "Copyright (c) Free Software Foundation, Inc. 1998-2011\n\n"
575
                "Using %s %s and Tcl %d.%d.%d",
576
                ecCONFIGURATION_TOOL_VERSION, __DATE__, __TIME__,
577
                wxPlatformInfo::Get().GetPortIdName().c_str(), wxVERSION_NUM_DOT_STRING,
578
                iTclVerMajor, iTclVerMinor, iTclVerPatchLevel);
579
    wxMessageBox(msg, _("About eCos Configuration Tool"), wxICON_INFORMATION | wxOK);
580
}
581
 
582
void ecMainFrame::OnSize(wxSizeEvent& WXUNUSED(event))
583
{
584
    // First, we need to resize the sash windows proportionately,
585
    // or we may end up with negative sizes, etc.
586
    wxRect rect = GetRect();
587
    if (rect != wxGetApp().GetSettings().m_frameSize)
588
    {
589
        double factorX = ((double) rect.GetWidth() / (double) wxGetApp().GetSettings().m_frameSize.GetWidth());
590
        double factorY = ((double) rect.GetHeight() / (double) wxGetApp().GetSettings().m_frameSize.GetHeight());
591
 
592
#if wxCHECK_VERSION(2, 6, 0)
593
                wxNode* node = (wxNode *) GetChildren().GetFirst();
594
        while (node)
595
        {
596
            wxWindow* win = (wxWindow*) node->GetData();
597
#else
598
        wxNode* node = GetChildren().First();
599
        while (node)
600
        {
601
            wxWindow* win = (wxWindow*) node->Data();
602
#endif
603
            if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)))
604
            {
605
                wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) win;
606
                wxSize sz = sashWin->GetSize();
607
                sashWin->SetDefaultSize(wxSize((int) ((double) sz.x * factorX), (int) ((double) sz.y * factorY)));
608
            }
609
#if wxCHECK_VERSION(2, 6, 0)
610
            node = node->GetNext();
611
#else
612
            node = node->Next();
613
#endif
614
        }
615
    }
616
 
617
    wxLayoutAlgorithm layout;
618
    layout.LayoutFrame(this);
619
 
620
    wxGetApp().GetSettings().m_frameSize = rect;
621
}
622
 
623
void ecMainFrame::RecreateToolbar()
624
{
625
    // delete and recreate the toolbar
626
    wxToolBarBase *toolBar = GetToolBar();
627
    if (toolBar)
628
    {
629
        delete toolBar;
630
        SetToolBar(NULL);
631
    }
632
 
633
    long style = wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL | wxTB_DOCKABLE;
634
 
635
    toolBar = CreateToolBar(style, ecID_TOOLBAR);
636
 
637
    toolBar->SetMargins( 4, 4 );
638
 
639
    // Set up toolbar
640
    wxBitmap toolBarBitmaps[20];
641
 
642
    toolBarBitmaps[0] = wxBITMAP(new);
643
    toolBarBitmaps[1] = wxBITMAP(open);
644
    toolBarBitmaps[2] = wxBITMAP(save);
645
    toolBarBitmaps[3] = wxBITMAP(copy);
646
    toolBarBitmaps[4] = wxBITMAP(cut);
647
    toolBarBitmaps[5] = wxBITMAP(paste);
648
    toolBarBitmaps[6] = wxBITMAP(search);
649
    toolBarBitmaps[7] = wxBITMAP(stopbuild);
650
    toolBarBitmaps[8] = wxBITMAP(buildlibrary);
651
    toolBarBitmaps[9] = wxBITMAP(help);
652
    toolBarBitmaps[10] = wxBITMAP(newregion);
653
    toolBarBitmaps[11] = wxBITMAP(newsection);
654
    toolBarBitmaps[12] = wxBITMAP(delete);
655
    toolBarBitmaps[13] = wxBITMAP(properties);
656
    toolBarBitmaps[14] = wxBITMAP(cshelp);
657
 
658
    toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("New file"));
659
    toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Open file"));
660
    toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Save file"));
661
 
662
    toolBar->AddSeparator();
663
 
664
    toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Cut");
665
    toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Copy");
666
    toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Paste");
667
    toolBar->AddTool(wxID_FIND, toolBarBitmaps[6], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Search");
668
 
669
    toolBar->AddSeparator();
670
 
671
    toolBar->AddTool(ecID_STOP_BUILD, toolBarBitmaps[7], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Stop build");
672
    toolBar->AddTool(ecID_BUILD_LIBRARY, toolBarBitmaps[8], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Build library");
673
#if ecUSE_MLT
674
    toolBar->AddSeparator();
675
    toolBar->AddTool(ecID_NEW_REGION, toolBarBitmaps[10], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "New region");
676
    toolBar->AddTool(ecID_NEW_SECTION, toolBarBitmaps[11], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "New section");
677
    toolBar->AddTool(ecID_DELETE, toolBarBitmaps[12], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Delete");
678
    toolBar->AddTool(ecID_PROPERTIES, toolBarBitmaps[13], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Properties");
679
#endif
680
    toolBar->AddSeparator();
681
    toolBar->AddTool(ecID_CONTEXT_HELP, toolBarBitmaps[14], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Show help for clicked-on windows");
682
    toolBar->AddTool(ecID_ECOS_HELP, toolBarBitmaps[9], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Show help");
683
 
684
    // after adding the buttons to the toolbar, must call Realize() to reflect
685
    // the changes
686
    toolBar->Realize();
687
 
688
    toolBar->SetHelpText(_("The toolbar allows quick access to commonly-used commands."));
689
}
690
 
691
// Toggle one of the windows
692
void ecMainFrame::OnToggleWindow(wxCommandEvent& event)
693
{
694
    ToggleWindow(event.GetId());
695
}
696
 
697
// Toggle the given window on or off
698
void ecMainFrame::ToggleWindow(int windowId)
699
{
700
    wxWindow* win = NULL;
701
    bool *configSetting = NULL;
702
    switch (windowId)
703
    {
704
    case ecID_TOGGLE_CONFLICTS:
705
        win = m_conflictsSashWindow;
706
        configSetting = & wxGetApp().GetSettings().m_showConflictsWindow;
707
        break;
708
    case ecID_TOGGLE_PROPERTIES:
709
        win = m_propertiesSashWindow;
710
        configSetting = & wxGetApp().GetSettings().m_showPropertiesWindow;
711
        break;
712
    case ecID_TOGGLE_MEMORY:
713
        win = m_memorySashWindow;
714
        configSetting = & wxGetApp().GetSettings().m_showMemoryWindow;
715
        break;
716
    case ecID_TOGGLE_SHORT_DESCR:
717
        win = m_shortDescrSashWindow;
718
        configSetting = & wxGetApp().GetSettings().m_showShortDescrWindow;
719
        break;
720
    case ecID_TOGGLE_OUTPUT:
721
        win = m_outputSashWindow;
722
        configSetting = & wxGetApp().GetSettings().m_showOutputWindow;
723
        break;
724
    }
725
    if (win)
726
    {
727
        bool showing = !win->IsShown();
728
 
729
        win->Show(showing);
730
        * configSetting = showing;
731
 
732
        // Make sure we don't have ridiculous sizes
733
        if (showing && (windowId == ecID_TOGGLE_CONFLICTS || windowId == ecID_TOGGLE_PROPERTIES || windowId == ecID_TOGGLE_SHORT_DESCR))
734
        {
735
            m_conflictsSashWindow->SetDefaultSize(wxSize(2000, 50));
736
            m_propertiesSashWindow->SetDefaultSize(wxSize(2000, 50));
737
            m_shortDescrSashWindow->SetDefaultSize(wxSize(2000, 50));
738
 
739
            wxSize frameSize = GetClientSize();
740
            wxSize configSize = m_configSashWindow->GetSize();
741
 
742
            if ((frameSize.x - configSize.x) < 5)
743
            {
744
                // We must resize the config window
745
                m_configSashWindow->SetDefaultSize(wxSize(frameSize.x/2, configSize.y));
746
            }
747
        }
748
 
749
        wxLayoutAlgorithm layout;
750
        layout.LayoutFrame(this);
751
    }
752
}
753
 
754
void ecMainFrame::OnUpdateToggleWindow(wxUpdateUIEvent& event)
755
{
756
    wxWindow* win = NULL;
757
    switch (event.GetId())
758
    {
759
    case ecID_TOGGLE_CONFLICTS:
760
        win = m_conflictsSashWindow;
761
        break;
762
    case ecID_TOGGLE_PROPERTIES:
763
        win = m_propertiesSashWindow;
764
        break;
765
    case ecID_TOGGLE_MEMORY:
766
        win = m_memorySashWindow;
767
        break;
768
    case ecID_TOGGLE_SHORT_DESCR:
769
        win = m_shortDescrSashWindow;
770
        break;
771
    case ecID_TOGGLE_OUTPUT:
772
        win = m_outputSashWindow;
773
        break;
774
    }
775
    if (win)
776
    {
777
        event.Enable( TRUE );
778
        event.Check( win->IsShown() );
779
 
780
        // Not implemented
781
#if !ecUSE_MLT
782
        if (event.GetId() == ecID_TOGGLE_MEMORY)
783
            event.Enable( FALSE );
784
#endif
785
    }
786
}
787
 
788
void ecMainFrame::OnUpdateDisable(wxUpdateUIEvent& event)
789
{
790
    event.Enable( FALSE );
791
}
792
 
793
void ecMainFrame::OnToggleToolbar(wxCommandEvent& event)
794
{
795
    GetToolBar()->Show( ! GetToolBar()->IsShown() );
796
 
797
    wxSizeEvent sizeEvent(GetSize(), GetId());
798
    GetEventHandler()->ProcessEvent(sizeEvent);
799
#ifdef __WXGTK__
800
    GtkOnSize();
801
#endif
802
}
803
 
804
void ecMainFrame::OnUpdateToggleToolbar(wxUpdateUIEvent& event)
805
{
806
    event.Check( GetToolBar()->IsShown() );
807
}
808
 
809
// Respond to a sash drag operation, by setting the new size
810
// for this window and then recalculating the layout.
811
void ecMainFrame::OnSashDrag(wxSashEvent& event)
812
{
813
    if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
814
        return;
815
 
816
    switch (event.GetId())
817
    {
818
    case ecID_CONFIG_SASH_WINDOW:
819
        {
820
            m_configSashWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 2000));
821
            break;
822
        }
823
    case ecID_CONFLICTS_SASH_WINDOW:
824
        {
825
            // Change the height of the properties window so we don't affect the
826
            // short description window
827
            int deltaY = event.GetDragRect().height - m_conflictsSashWindow->GetSize().y;
828
            int propertiesHeight = 0;
829
            if (m_propertiesSashWindow->IsShown())
830
            {
831
                propertiesHeight = m_propertiesSashWindow->GetSize().y - deltaY ;
832
                if (propertiesHeight <= 0)
833
                    return;
834
                else
835
                    m_propertiesSashWindow->SetDefaultSize(wxSize(2000, propertiesHeight));
836
            }
837
            m_conflictsSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
838
            break;
839
        }
840
    case ecID_PROPERTIES_SASH_WINDOW:
841
        {
842
            m_propertiesSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
843
            break;
844
        }
845
    case ecID_SHORT_DESCR_SASH_WINDOW:
846
        {
847
            m_shortDescrSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
848
            break;
849
        }
850
    case ecID_MEMORY_SASH_WINDOW:
851
        {
852
            m_memorySashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
853
            break;
854
        }
855
    case ecID_OUTPUT_SASH_WINDOW:
856
        {
857
            m_outputSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
858
            break;
859
        }
860
    default:
861
        {
862
            wxFAIL_MSG( _("Shouldn't get here.") );
863
            break;
864
        }
865
    }
866
 
867
    if (event.GetId() == ecID_MEMORY_SASH_WINDOW || event.GetId() == ecID_OUTPUT_SASH_WINDOW)
868
    {
869
        // Special processing so we don't spoil the layout of the
870
        // conflicts/properties/short description windows
871
        wxList minorWindows;
872
        GetMinorWindows(minorWindows);
873
 
874
        int memoryLayoutHeight = m_memorySashWindow->IsShown() ? m_memorySashWindow->GetSize().y : 0;
875
        int outputHeight = m_memorySashWindow->IsShown() ? m_outputSashWindow->GetSize().y : 0;
876
        int cx, cy;
877
        GetClientSize(& cx, & cy);
878
 
879
        // Calculate how much space will be left after this drag operation.
880
        int heightLeft;
881
        if (event.GetId() == ecID_MEMORY_SASH_WINDOW)
882
            heightLeft = cy - outputHeight - event.GetDragRect().height;
883
        else
884
            heightLeft = cy - memoryLayoutHeight - event.GetDragRect().height;
885
 
886
        DivideSpaceEvenly(minorWindows, wxSize(0, heightLeft), wxVERTICAL);
887
        RestoreDefaultWindowSizes(minorWindows);
888
    }
889
 
890
    wxLayoutAlgorithm layout;
891
    if (!layout.LayoutFrame(this))
892
    {
893
        // If layout failed, restored default sizes.
894
#if wxCHECK_VERSION(2, 6, 0)
895
        wxNode* node = (wxNode *) GetChildren().GetFirst();
896
        while (node)
897
        {
898
            wxWindow* win = (wxWindow*) node->GetData();
899
#else
900
        wxNode* node = GetChildren().First();
901
        while (node)
902
        {
903
            wxWindow* win = (wxWindow*) node->Data();
904
#endif
905
            if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)))
906
            {
907
                wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) win;
908
                wxSize sz = sashWin->GetSize();
909
                sashWin->SetDefaultSize(sz);
910
            }
911
#if wxCHECK_VERSION(2, 6, 0)
912
            node = node->GetNext();
913
#else
914
            node = node->Next();
915
#endif
916
        }
917
    }
918
 
919
}
920
 
921
void ecMainFrame::OnIdle(wxIdleEvent& event)
922
{
923
#if wxCHECK_VERSION(2, 6, 0)
924
        // Doesn't event handlling happen anyway?
925
#else
926
    // Normal idle processing
927
    wxFrame::OnIdle(event);
928
#endif
929
 
930
    wxString text;
931
    if (GetStatusBar())
932
        text = GetStatusBar()->GetStatusText(0);
933
 
934
    // Set the title if we have no document
935
    if (!wxGetApp().GetConfigToolDoc() && GetTitle() != wxGetApp().GetSettings().GetAppName())
936
        SetTitle(wxGetApp().GetSettings().GetAppName());
937
 
938
    if ( wxGetApp().m_pipedProcess && wxGetApp().m_pipedProcess->HasInput() )
939
    {
940
        event.RequestMore();
941
    }
942
 
943
    if ( wxGetApp().m_pipedProcess )
944
    {
945
        if (text != _("Building..."))
946
            SetStatusText(_("Building..."), 0);
947
    }
948
    else if (text != _("Ready"))
949
        SetStatusText(_("Ready"), 0);
950
}
951
 
952
void ecMainFrame::OnCloseWindow(wxCloseEvent& event)
953
{
954
    wxBusyCursor busy;
955
 
956
    if (!wxGetApp().GetDocManager()->Clear(FALSE) && event.CanVeto())
957
    {
958
        event.Veto();
959
        return;
960
    }
961
    if (wxGetApp().m_pipedProcess)
962
        wxGetApp().m_pipedProcess->Detach();
963
 
964
    if (m_findDialog)
965
        m_findDialog->Close(TRUE);
966
 
967
    wxGetApp().DestroyHelpController();
968
 
969
    if (IsMaximized())
970
        wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_MAXIMIZED ;
971
    else if (IsIconized())
972
        wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_MINIMIZED ;
973
    else
974
        wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_NORMAL ;
975
 
976
    if (!IsMaximized() && !IsIconized())
977
        wxGetApp().GetSettings().m_frameSize = GetRect();
978
 
979
    wxGetApp().GetSettings().m_showToolBar = GetToolBar()->IsShown();
980
 
981
    wxGetApp().GetSettings().m_treeSashSize = m_configSashWindow->GetSize();
982
    wxGetApp().GetSettings().m_propertiesSashSize = m_propertiesSashWindow->GetSize();
983
    wxGetApp().GetSettings().m_conflictsSashSize = m_conflictsSashWindow->GetSize();
984
    wxGetApp().GetSettings().m_shortDescrSashSize = m_shortDescrSashWindow->GetSize();
985
    wxGetApp().GetSettings().m_memorySashSize = m_memorySashWindow->GetSize();
986
    wxGetApp().GetSettings().m_outputSashSize = m_outputSashWindow->GetSize();
987
    wxGetApp().GetSettings().m_configPaneWidth = m_splitter->GetSashPosition();
988
 
989
    event.Skip();
990
}
991
 
992
// Enumerate the visible 'minor' sash windows,
993
// i.e. those in the top-right segment of the frame
994
void ecMainFrame::GetMinorWindows(wxList& list)
995
{
996
    if (m_conflictsSashWindow->IsShown())
997
        list.Append(m_conflictsSashWindow);
998
    if (m_propertiesSashWindow->IsShown())
999
        list.Append(m_propertiesSashWindow);
1000
    if (m_shortDescrSashWindow->IsShown())
1001
        list.Append(m_shortDescrSashWindow);
1002
}
1003
 
1004
// Get all visible sash windows
1005
void ecMainFrame::GetSashWindows(wxList& list)
1006
{
1007
#if wxCHECK_VERSION(2, 6, 0)
1008
    wxNode* node = (wxNode *) GetChildren().GetFirst();
1009
    while (node)
1010
    {
1011
        wxWindow* win = (wxWindow*) node->GetData();
1012
#else
1013
    wxNode* node = GetChildren().First();
1014
    while (node)
1015
    {
1016
        wxWindow* win = (wxWindow*) node->Data();
1017
#endif
1018
        if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)) && win->IsShown())
1019
        {
1020
            list.Append(win);
1021
        }
1022
#if wxCHECK_VERSION(2, 6, 0)
1023
        node = node->GetNext();
1024
#else
1025
        node = node->Next();
1026
#endif
1027
    }
1028
}
1029
 
1030
// Divide the given space evenly amongst some windows
1031
void ecMainFrame::DivideSpaceEvenly(wxList& list, const wxSize& space, int orient)
1032
{
1033
#if wxCHECK_VERSION(2, 6, 0)
1034
    if (list.GetCount() == 0)
1035
#else
1036
    if (list.Number() == 0)
1037
#endif
1038
        return;
1039
 
1040
    // Find total size first
1041
    int totalSize = 0;
1042
    double proportion = 0.0;
1043
#if wxCHECK_VERSION(2, 6, 0)
1044
    wxNode* node = list.GetFirst();
1045
    while (node)
1046
    {
1047
        wxWindow* win = (wxWindow*) node->GetData();
1048
#else
1049
    wxNode* node = list.First();
1050
    while (node)
1051
    {
1052
        wxWindow* win = (wxWindow*) node->Data();
1053
#endif
1054
        wxSize sz = win->GetSize();
1055
        if (orient == wxHORIZONTAL)
1056
            totalSize += sz.x;
1057
        else
1058
            totalSize += sz.y;
1059
#if wxCHECK_VERSION(2, 6, 0)
1060
        node = node->GetNext();
1061
#else
1062
        node = node->Next();
1063
#endif
1064
    }
1065
    if (orient == wxHORIZONTAL)
1066
    {
1067
        if (totalSize == 0)
1068
            return;
1069
 
1070
        proportion = ((double) space.x / (double) totalSize);
1071
    }
1072
    else
1073
    {
1074
        if (totalSize == 0)
1075
            return;
1076
 
1077
        proportion = ((double) space.y / (double) totalSize);
1078
    }
1079
 
1080
#if wxCHECK_VERSION(2, 6, 0)
1081
    node = list.GetFirst();
1082
    while (node)
1083
    {
1084
        wxWindow* win = (wxWindow*) node->GetData();
1085
#else
1086
    node = list.First();
1087
    while (node)
1088
    {
1089
        wxWindow* win = (wxWindow*) node->Data();
1090
#endif
1091
        wxSize sz = win->GetSize();
1092
        if (orient == wxHORIZONTAL)
1093
            sz.x = (int) (sz.x * proportion);
1094
        else
1095
            sz.y = (int) (sz.y * proportion);
1096
        win->SetSize(sz);
1097
#if wxCHECK_VERSION(2, 6, 0)
1098
        node = node->GetNext();
1099
#else
1100
        node = node->Next();
1101
#endif
1102
    }
1103
}
1104
 
1105
// Restore the sash window default size from the actual window size
1106
void ecMainFrame::RestoreDefaultWindowSizes(wxList& list)
1107
{
1108
#if wxCHECK_VERSION(2, 6, 0)
1109
    wxNode* node = list.GetFirst();
1110
    while (node)
1111
    {
1112
        wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) node->GetData();
1113
#else
1114
    wxNode* node = list.First();
1115
    while (node)
1116
    {
1117
        wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) node->Data();
1118
#endif
1119
        wxSize sz = sashWin->GetSize();
1120
        sashWin->SetDefaultSize(sz);
1121
#if wxCHECK_VERSION(2, 6, 0)
1122
        node = node->GetNext();
1123
#else
1124
        node = node->Next();
1125
#endif
1126
    }
1127
}
1128
 
1129
void ecMainFrame::OnHelpEcos(wxCommandEvent& event)
1130
{
1131
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1132
    if (doc)
1133
    {
1134
        wxString strURL(wxT("index.html"));
1135
        doc->QualifyDocURL(strURL, FALSE);
1136
        switch (wxGetApp().GetSettings().m_eUseCustomBrowser)
1137
        {
1138
        case ecInternal:
1139
            {
1140
                if (wxGetApp().HasHelpController())
1141
                    wxGetApp().GetHelpController().DisplayContents();
1142
                break;
1143
            }
1144
        default:
1145
            {
1146
                doc->ShowURL(strURL);
1147
            }
1148
        }
1149
    }
1150
}
1151
 
1152
void ecMainFrame::OnHelpConfigtool(wxCommandEvent& event)
1153
{
1154
    //wxString strURL(wxT("redirect/the-ecos-configuration-tool.html"));
1155
    wxString strURL(wxGetApp().GetFullAppPath(wxT("manual/user-guides.2.html")));
1156
    if (!wxFileExists(strURL))
1157
        strURL = wxT("user-guide/the-ecos-configuration-tool.html");
1158
 
1159
    if (wxGetApp().GetConfigToolDoc())
1160
    {
1161
        wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1162
    }
1163
}
1164
 
1165
void ecMainFrame::OnHelpContext(wxCommandEvent& event)
1166
{
1167
    wxContextHelp contextHelp;
1168
}
1169
 
1170
void ecMainFrame::OnResolveConflicts(wxCommandEvent& event)
1171
{
1172
/*
1173
    ecResolveConflictsDialog dialog(this);
1174
    dialog.ShowModal();
1175
*/
1176
    if ( ecConfigToolDoc::NotDone == wxGetApp().GetConfigToolDoc()->ResolveGlobalConflicts() )
1177
    {
1178
        // Global inference handler was never invoked.  Say something
1179
        wxString msg;
1180
        msg.Printf(_("No solutions can be automatically determined for the current set of conflicts."));
1181
        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
1182
    }
1183
}
1184
 
1185
void ecMainFrame::OnUpdateResolveConflicts(wxUpdateUIEvent& event)
1186
{
1187
    if (!wxGetApp().GetConfigToolDoc() || !wxGetApp().GetConfigToolDoc()->GetCdlInterpreter())
1188
    {
1189
        event.Enable(FALSE);
1190
        return;
1191
    }
1192
 
1193
    event.Enable(wxGetApp().GetConfigToolDoc()->GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0);
1194
}
1195
 
1196
void ecMainFrame::OnSettings(wxCommandEvent& event)
1197
{
1198
    ecSettingsDialog dialog(this);
1199
    dialog.ShowModal();
1200
}
1201
 
1202
void ecMainFrame::OnPlatforms(wxCommandEvent& event)
1203
{
1204
    ecPlatformsDialog dialog(this);
1205
    if (dialog.ShowModal() == wxID_OK)
1206
    {
1207
        CeCosTestPlatform::RemoveAllPlatforms();
1208
        unsigned int i ;
1209
        for(i=0; i < dialog.PlatformCount();i++){
1210
            CeCosTestPlatform::Add(*dialog.Platform(i));
1211
        }
1212
        CeCosTestPlatform::Save();
1213
    }
1214
}
1215
 
1216
void ecMainFrame::OnBuildOptions(wxCommandEvent& event)
1217
{
1218
    ecBuildOptionsDialog dialog(this);
1219
    dialog.ShowModal();
1220
}
1221
 
1222
void ecMainFrame::OnTemplates(wxCommandEvent& event)
1223
{
1224
    ecTemplatesDialog dialog(this);
1225
    if (dialog.ShowModal() == wxID_OK)
1226
        {
1227
#ifdef __WXMSW__
1228
        // Ensure display gets updated
1229
        ::UpdateWindow((HWND) GetHWND());
1230
        //wxYield();
1231
#endif
1232
        ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1233
 
1234
                doc->SelectHardware(dialog.GetSelectedHardware());
1235
                doc->SelectTemplate(dialog.GetSelectedTemplate(), dialog.GetSelectedTemplateVersion());
1236
        }
1237
}
1238
 
1239
void ecMainFrame::OnAdmin(wxCommandEvent& event)
1240
{
1241
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1242
 
1243
    wxASSERT (doc) ;
1244
 
1245
    if (wxYES == wxMessageBox(_("This command will close the current document.\n\nDo you wish to continue?"),
1246
        wxGetApp().GetAppName(), wxYES_NO, this))
1247
    {
1248
        wxString shellCommands;
1249
        // ensure that the user tools are on the path for use by ecosadmin.tcl
1250
        // TODO: need to something else for Linux (since it returns settings in shellCommands)
1251
        if (wxGetApp().PrepareEnvironment(FALSE, & shellCommands))
1252
        {
1253
            // make sure we use doc data before the doc is destroyed
1254
 
1255
            ecAdminDialog dlg(this, doc->GetPackagesDir(), wxGetApp().GetSettings().GetUserToolsDir());
1256
 
1257
            if (dlg.ShowModal() == wxID_OK)
1258
            {
1259
                // Create new document
1260
                wxGetApp().GetDocManager()->CreateDocument(wxEmptyString, wxDOC_NEW);
1261
            }
1262
        }
1263
    }
1264
}
1265
 
1266
void ecMainFrame::OnPackages(wxCommandEvent& event)
1267
{
1268
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1269
    if (doc)
1270
        doc->SelectPackages();
1271
}
1272
 
1273
void ecMainFrame::OnRunTests(wxCommandEvent& event)
1274
{
1275
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1276
    if (doc)
1277
        doc->RunTests();
1278
}
1279
 
1280
void ecMainFrame::OnChooseRepository(wxCommandEvent& event)
1281
{
1282
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1283
    if (doc && !doc->OnSaveModified())
1284
        return;
1285
 
1286
    if (!doc)
1287
    {
1288
        doc = (ecConfigToolDoc*) wxGetApp().GetDocManager()->CreateDocument(wxString(""), wxDOC_NEW|ecDOC_PROMPT_FOR_REPOSITORY);
1289
        return;
1290
    }
1291
 
1292
    if (doc)
1293
        doc->m_bRepositoryOpen = FALSE;
1294
 
1295
    if (wxGetApp().GetConfigToolDoc()->OpenRepository(wxEmptyString, TRUE))
1296
    {
1297
        // TODO
1298
#if 0
1299
        // reset the document title as shown in the frame window
1300
        GetDocTemplate ()->SetDefaultTitle (this);
1301
 
1302
        // load the memory layout for the default target-platform-startup from the new repository
1303
        NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf")));
1304
#endif
1305
 
1306
        doc->UpdateAllViews(NULL);
1307
        doc->UpdateFailingRuleCount();
1308
    }
1309
    else
1310
    {
1311
        if (doc)
1312
            doc->m_bRepositoryOpen = TRUE;
1313
    }
1314
}
1315
 
1316
void ecMainFrame::OnBuildToolsPath(wxCommandEvent& event)
1317
{
1318
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1319
    if (!doc)
1320
        return;
1321
 
1322
    // add the current build tools dir to the drop-down list box
1323
    wxArrayString arstrPaths;
1324
    if (!wxGetApp().GetSettings().m_buildToolsDir.IsEmpty())
1325
        arstrPaths.Add(wxGetApp().GetSettings().m_buildToolsDir);
1326
 
1327
    // also add the sub-directory containing tools for the current command prefix
1328
    wxString value;
1329
    wxStringToStringMap& map = wxGetApp().GetSettings().GetBinDirs();
1330
    const wxString strPrefix(doc->GetCurrentTargetPrefix());
1331
    if (map.Find(strPrefix, value) && (wxNOT_FOUND == arstrPaths.Index(value)))
1332
        arstrPaths.Add(value);
1333
 
1334
    wxString msg;
1335
    msg.Printf(_("Enter the location of the %s build tools\n"
1336
          "folder. You can type in a path or use the\n"
1337
          "Browse button to navigate to a folder."),
1338
          (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("native")) : strPrefix));
1339
    wxString caption(_("Build Tools Path"));
1340
 
1341
    ecFolderDialog dialog(wxGetApp().GetSettings().m_buildToolsDir, arstrPaths, msg, this, ecID_BUILD_TOOLS_DIALOG, caption);
1342
    if (dialog.ShowModal() == wxID_OK)
1343
    {
1344
        wxString path (dialog.GetPath());
1345
 
1346
        // look for *objcopy under the user-specified build tools directory
1347
        wxArrayString objcopyFiles;
1348
        wxString objcopyFileSpec(wxT("objcopy"));
1349
#ifdef __WXMSW__
1350
        objcopyFileSpec += wxT(".exe");
1351
#endif
1352
        size_t objcopyCount = wxDir::GetAllFiles(path, &objcopyFiles, wxT("*") + objcopyFileSpec, wxDIR_FILES | wxDIR_DIRS);
1353
        bool bPrefixFound = false;
1354
        for (int count=0; count < objcopyCount; count++)
1355
        {
1356
            wxFileName file (objcopyFiles [count]);
1357
            wxString new_prefix (file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec)));
1358
            if ((! new_prefix.IsEmpty()) && ('-' == new_prefix.Last()))
1359
                new_prefix = new_prefix.Left (new_prefix.Len() - 1); // strip off trailing hyphen 
1360
            if (new_prefix == strPrefix)
1361
                bPrefixFound = true;
1362
        }
1363
 
1364
        wxString msg;
1365
        msg.Printf(wxT("%s does not appear to contain the build tools - use this folder anyway?"), (const wxChar*) path);
1366
 
1367
        if(bPrefixFound ||
1368
            (wxYES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO)))
1369
        {
1370
            for (int count=0; count < objcopyCount; count++)
1371
            {
1372
                wxFileName file (objcopyFiles [count]);
1373
                wxString new_prefix (file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec)));
1374
                if ((! new_prefix.IsEmpty()) && ('-' == new_prefix.Last()))
1375
                    new_prefix = new_prefix.Left (new_prefix.Len() - 1); // strip off trailing hyphen
1376
                map.Set(new_prefix, file.GetPath(wxPATH_GET_VOLUME));
1377
            }
1378
            wxGetApp().GetSettings().m_buildToolsDir = path;
1379
        }
1380
    }
1381
}
1382
 
1383
void ecMainFrame::OnUserToolsPath(wxCommandEvent& event)
1384
{
1385
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1386
    if (!doc)
1387
        return;
1388
 
1389
    wxArrayString paths = wxGetApp().GetSettings().m_userToolPaths;
1390
    if (!wxGetApp().GetSettings().m_userToolsDir.IsEmpty())
1391
        paths.Add(wxGetApp().GetSettings().m_userToolsDir);
1392
 
1393
    wxString msg(_("Enter the location of the user tools folder,\n"
1394
          "which should contain cat and ls. You can type in\n"
1395
          "a path or use the Browse button to navigate to a\n"
1396
          "folder."));
1397
 
1398
    wxString caption(_("User Tools Path"));
1399
    wxString defaultPath(wxGetApp().GetSettings().m_userToolsDir);
1400
 
1401
    ecFolderDialog dialog(defaultPath, paths, msg, this, ecID_USER_TOOLS_DIALOG, caption);
1402
    if (dialog.ShowModal() == wxID_OK)
1403
    {
1404
        wxString path(dialog.GetPath());
1405
        ecFileName strFile(path);
1406
 
1407
#ifdef __WXMSW__
1408
        wxString exeSuffix(wxT(".exe"));
1409
#else
1410
        wxString exeSuffix(wxEmptyString);
1411
#endif
1412
        wxString prog(wxString(wxT("ls")) + exeSuffix);
1413
 
1414
        strFile += (const wxChar*) prog;
1415
 
1416
        wxString msg;
1417
        msg.Printf(wxT("%s does not appear to contain the user tools - use this folder anyway?"), (const wxChar*) path);
1418
 
1419
        if(strFile.Exists() ||
1420
            (wxYES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO)))
1421
        {
1422
            wxGetApp().GetSettings().m_userToolsDir = path;
1423
        }
1424
    }
1425
}
1426
 
1427
// Process events for the window with the focus first.
1428
bool ecMainFrame::ProcessEvent(wxEvent& event)
1429
{
1430
    static wxEvent* s_lastEvent = NULL;
1431
 
1432
    if (& event == s_lastEvent)
1433
        return FALSE;
1434
 
1435
    if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxChildFocusEvent)))
1436
    {
1437
        s_lastEvent = & event;
1438
 
1439
        wxWindow* focusWin = wxFindFocusDescendant(this);
1440
        bool success = FALSE;
1441
        if (focusWin)
1442
        {
1443
            //long windowId = focusWin->GetId();
1444
            //wxLogDebug("Found focus window %d", windowId);
1445
            success = focusWin->GetEventHandler()->ProcessEvent(event);
1446
        }
1447
        if (!success)
1448
            success = wxDocParentFrame::ProcessEvent(event);
1449
 
1450
        s_lastEvent = NULL;
1451
        return success;
1452
    }
1453
    else
1454
    {
1455
        return wxDocParentFrame::ProcessEvent(event);
1456
    }
1457
}
1458
 
1459
void ecMainFrame::SetFailRulePane(int nCount)
1460
{
1461
    wxString strCount;
1462
    switch (nCount)
1463
    {
1464
    case 0:
1465
        strCount = wxT("No conflicts");
1466
        break;
1467
    case 1:
1468
        strCount = wxT("1 conflict");
1469
        break;
1470
    default:
1471
        strCount.Printf (_("%d conflicts"), nCount);
1472
        break;
1473
    }
1474
    if (GetStatusBar())
1475
    {
1476
        GetStatusBar()->SetStatusText(strCount, ecFailRulePane);
1477
    }
1478
}
1479
 
1480
// Update the title, either via the document's view or explicitly if no doc
1481
void ecMainFrame::UpdateFrameTitle()
1482
{
1483
    if (wxGetApp().GetConfigToolDoc())
1484
        wxGetApp().GetConfigToolDoc()->GetFirstView()->OnChangeFilename();
1485
    else
1486
        SetTitle(wxGetApp().GetSettings().GetAppName());
1487
}
1488
 
1489
void ecMainFrame::OnUpdatePlatforms(wxUpdateUIEvent& event)
1490
{
1491
    event.Enable(TRUE);
1492
}
1493
 
1494
void ecMainFrame::OnUpdateBuildOptions(wxUpdateUIEvent& event)
1495
{
1496
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1497
}
1498
 
1499
void ecMainFrame::OnUpdateBuildToolsPath(wxUpdateUIEvent& event)
1500
{
1501
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1502
}
1503
 
1504
void ecMainFrame::OnUpdateUserToolsPath(wxUpdateUIEvent& event)
1505
{
1506
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1507
}
1508
 
1509
void ecMainFrame::OnUpdateTemplates(wxUpdateUIEvent& event)
1510
{
1511
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1512
}
1513
 
1514
void ecMainFrame::OnUpdateAdmin(wxUpdateUIEvent& event)
1515
{
1516
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1517
}
1518
 
1519
void ecMainFrame::OnUpdatePackages(wxUpdateUIEvent& event)
1520
{
1521
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1522
}
1523
 
1524
void ecMainFrame::OnUpdateRunTests(wxUpdateUIEvent& event)
1525
{
1526
    event.Enable(wxGetApp().GetConfigToolDoc() != NULL && !wxGetApp().GetConfigToolDoc()->GetInstallTree().IsEmpty() && (wxGetApp().m_pipedProcess == NULL));
1527
}
1528
 
1529
void ecMainFrame::OnUpdateChooseRepository(wxUpdateUIEvent& event)
1530
{
1531
    event.Enable(TRUE);
1532
}
1533
 
1534
void ecMainFrame::OnWhatsThis(wxCommandEvent& event)
1535
{
1536
    wxGetApp().OnWhatsThis(event);
1537
}
1538
 
1539
void ecMainFrame::OnSaveOutput(wxCommandEvent& event)
1540
{
1541
    ecOutputWindow* win = GetOutputWindow();
1542
    if (!win)
1543
        return;
1544
    win->OnSave(event);
1545
}
1546
 
1547
void ecMainFrame::OnUpdateSelectAll(wxUpdateUIEvent& event)
1548
{
1549
    wxWindow* win = wxWindow::FindFocus();
1550
    event.Enable (win && win->IsKindOf(CLASSINFO(wxTextCtrl)) );
1551
}
1552
 
1553
void ecMainFrame::OnUpdateClear(wxUpdateUIEvent& event)
1554
{
1555
    wxWindow* win = wxWindow::FindFocus();
1556
    event.Enable (win && win->IsKindOf(CLASSINFO(wxTextCtrl)) );
1557
}
1558
 
1559
void ecMainFrame::OnImport(wxCommandEvent& event)
1560
{
1561
    if (wxGetApp().GetConfigToolDoc())
1562
    {
1563
        wxGetApp().GetConfigToolDoc()->ImportFile();
1564
    }
1565
}
1566
 
1567
void ecMainFrame::OnExport(wxCommandEvent& event)
1568
{
1569
    if (wxGetApp().GetConfigToolDoc())
1570
    {
1571
        wxGetApp().GetConfigToolDoc()->ExportFile();
1572
    }
1573
}
1574
 
1575
void ecMainFrame::OnUpdateImport(wxUpdateUIEvent& event)
1576
{
1577
    event.Enable ( wxGetApp().GetConfigToolDoc() != NULL );
1578
}
1579
 
1580
void ecMainFrame::OnUpdateExport(wxUpdateUIEvent& event)
1581
{
1582
    event.Enable ( wxGetApp().GetConfigToolDoc() != NULL );
1583
}
1584
 
1585
void ecMainFrame::OnWebRedHatHome(wxCommandEvent& event)
1586
{
1587
    wxString strURL(wxT("http://www.redhat.com"));
1588
    if (wxGetApp().GetConfigToolDoc())
1589
        wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1590
}
1591
 
1592
void ecMainFrame::OnWebEcos(wxCommandEvent& event)
1593
{
1594
    wxString strURL(wxT("http://www.redhat.com/products/ecos"));
1595
    if (wxGetApp().GetConfigToolDoc())
1596
        wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1597
}
1598
 
1599
void ecMainFrame::OnWebNetRelease(wxCommandEvent& event)
1600
{
1601
    wxString strURL(wxT("http://sources.redhat.com/ecos"));
1602
    if (wxGetApp().GetConfigToolDoc())
1603
        wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1604
}
1605
 
1606
void ecMainFrame::OnWebUitron(wxCommandEvent& event)
1607
{
1608
    wxString strURL(wxT("http://www.itron.gr.jp/"));
1609
    if (wxGetApp().GetConfigToolDoc())
1610
        wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1611
}
1612
 
1613
void ecMainFrame::OnBuildLibrary(wxCommandEvent& event)
1614
{
1615
    // TODO: possibly add wxT("clean build") to ensure library is
1616
    // cleanly built. No, can't do that because it would clean
1617
    // out any user code too :-(
1618
 
1619
    bool regenerateBuildTree = FALSE;
1620
 
1621
    if (wxGetApp().GetSettings().m_editSaveFileOnly)
1622
    {
1623
        int ans = wxMessageBox(wxT("Running in --edit-only mode so there may not be an up-to-date build tree.\nBuild the tree now?"), wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO|wxCANCEL);
1624
 
1625
        if (ans == wxYES)
1626
        {
1627
            regenerateBuildTree = TRUE;
1628
        }
1629
        else if (ans == wxCANCEL)
1630
            return;
1631
    }
1632
 
1633
    if (regenerateBuildTree)
1634
    {
1635
        ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
1636
        if (!pDoc)
1637
            return;
1638
 
1639
        if (!pDoc->GenerateBuildTree())
1640
            return ;
1641
    }
1642
 
1643
    wxGetApp().Build();
1644
}
1645
 
1646
void ecMainFrame::OnBuildTests(wxCommandEvent& event)
1647
{
1648
    bool regenerateBuildTree = FALSE;
1649
 
1650
    if (wxGetApp().GetSettings().m_editSaveFileOnly)
1651
    {
1652
        int ans = wxMessageBox(wxT("Running in --edit-only mode so there may not be an up-to-date build tree.\nBuild the tree now?"), wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO|wxCANCEL);
1653
 
1654
        if (ans == wxYES)
1655
        {
1656
            regenerateBuildTree = TRUE;
1657
        }
1658
        else if (ans == wxCANCEL)
1659
            return;
1660
    }
1661
 
1662
    if (regenerateBuildTree)
1663
    {
1664
        ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
1665
        if (!pDoc)
1666
            return;
1667
 
1668
        if (!pDoc->GenerateBuildTree())
1669
            return ;
1670
    }
1671
 
1672
    wxGetApp().Build(wxT("tests"));
1673
}
1674
 
1675
void ecMainFrame::OnStopBuild(wxCommandEvent& event)
1676
{
1677
    if (wxGetApp().m_pipedProcess)
1678
    {
1679
        long pid = wxGetApp().m_pipedProcess->GetPid();
1680
        wxGetApp().m_pipedProcess->Detach();
1681
 
1682
        wxProcessKiller pKiller(pid);
1683
        pKiller.Kill(TRUE);
1684
    }
1685
}
1686
 
1687
void ecMainFrame::OnClean(wxCommandEvent& event)
1688
{
1689
    wxGetApp().Build(wxT("clean"));
1690
}
1691
 
1692
void ecMainFrame::OnShell(wxCommandEvent& event)
1693
{
1694
    ecConfigToolDoc *pDoc=wxGetApp().GetConfigToolDoc();
1695
    if (!pDoc)
1696
        return;
1697
 
1698
    wxString variableSettings;
1699
    if (wxGetApp().PrepareEnvironment(TRUE, & variableSettings))
1700
    {
1701
#ifdef __WXMSW__
1702
        wxString currentDir = wxGetCwd();
1703
        wxSetWorkingDirectory(pDoc->GetBuildTree());
1704
 
1705
        wxExecute("bash.exe");
1706
 
1707
        if (!currentDir.IsEmpty()) // if the current directory was changed
1708
        {
1709
            wxSetWorkingDirectory(currentDir); // restore the previous current directory
1710
        }
1711
#else
1712
        wxString cmdLine = wxString(wxT("xterm"));
1713
 
1714
        // TODO: query an appropriate variable, and/or have a setting for this
1715
        wxExecute(cmdLine);
1716
#endif
1717
    }
1718
}
1719
 
1720
void ecMainFrame::OnUpdateBuildLibrary(wxUpdateUIEvent& event)
1721
{
1722
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess == NULL ));
1723
}
1724
 
1725
void ecMainFrame::OnUpdateBuildTests(wxUpdateUIEvent& event)
1726
{
1727
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess == NULL ));
1728
}
1729
 
1730
void ecMainFrame::OnUpdateStopBuild(wxUpdateUIEvent& event)
1731
{
1732
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess != NULL ));
1733
}
1734
 
1735
void ecMainFrame::OnUpdateClean(wxUpdateUIEvent& event)
1736
{
1737
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess == NULL ));
1738
}
1739
 
1740
void ecMainFrame::OnRepositoryInfo(wxCommandEvent& event)
1741
{
1742
    ecRepositoryInfoDialog dialog(this, ecID_REPOSITORY_INFO, _("Repository Information"));
1743
    dialog.ShowModal();
1744
}
1745
 
1746
void ecMainFrame::OnUpdateShell(wxUpdateUIEvent& event)
1747
{
1748
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) );
1749
}
1750
 
1751
void ecMainFrame::OnUpdateRepositoryInfo(wxUpdateUIEvent& event)
1752
{
1753
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) );
1754
}
1755
 
1756
void ecMainFrame::OnNewRegion(wxCommandEvent& event)
1757
{
1758
#if ecUSE_MLT
1759
#endif
1760
}
1761
 
1762
void ecMainFrame::OnNewSection(wxCommandEvent& event)
1763
{
1764
#if ecUSE_MLT
1765
#endif
1766
}
1767
 
1768
void ecMainFrame::OnDeleteRegionOrSection(wxCommandEvent& event)
1769
{
1770
#if ecUSE_MLT
1771
#endif
1772
}
1773
 
1774
void ecMainFrame::OnRegionOrSectionProperties(wxCommandEvent& event)
1775
{
1776
#if ecUSE_MLT
1777
#endif
1778
}
1779
 
1780
void ecMainFrame::OnUpdateNewRegion(wxUpdateUIEvent& event)
1781
{
1782
#if ecUSE_MLT
1783
#else
1784
    event.Enable( FALSE );
1785
#endif
1786
}
1787
 
1788
void ecMainFrame::OnUpdateNewSection(wxUpdateUIEvent& event)
1789
{
1790
#if ecUSE_MLT
1791
#else
1792
    event.Enable( FALSE );
1793
#endif
1794
}
1795
 
1796
void ecMainFrame::OnUpdateDeleteRegionOrSection(wxUpdateUIEvent& event)
1797
{
1798
#if ecUSE_MLT
1799
#else
1800
    event.Enable( FALSE );
1801
#endif
1802
}
1803
 
1804
void ecMainFrame::OnUpdateRegionOrSectionProperties(wxUpdateUIEvent& event)
1805
{
1806
#if ecUSE_MLT
1807
#else
1808
    event.Enable( FALSE );
1809
#endif
1810
}
1811
 
1812
void ecMainFrame::OnIndexDocs(wxCommandEvent& event)
1813
{
1814
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1815
    if (doc)
1816
    {
1817
        doc->RebuildHelpIndex(TRUE) ;
1818
    }
1819
}
1820
 
1821
void ecMainFrame::OnUpdateIndexDocs(wxUpdateUIEvent& event)
1822
{
1823
    event.Enable( wxGetApp().GetConfigToolDoc() != NULL );
1824
}
1825
 
1826
void ecMainFrame::OnGenerateBuildTree(wxCommandEvent& event)
1827
{
1828
    if (wxGetApp().GetConfigToolDoc() && wxGetApp().GetConfigToolDoc()->CanGenerateBuildTree())
1829
    {
1830
        if (!wxGetApp().GetConfigToolDoc()->GenerateBuildTree())
1831
        {
1832
            // Error probably already reported
1833
        }
1834
    }
1835
}
1836
 
1837
void ecMainFrame::OnUpdateGenerateBuildTree(wxUpdateUIEvent& event)
1838
{
1839
    event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && wxGetApp().GetConfigToolDoc()->CanGenerateBuildTree());
1840
}

powered by: WebSVN 2.1.0

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