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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [mainwin.cpp] - Blame information for rev 574

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

powered by: WebSVN 2.1.0

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