1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 // Copyright (C) 2003 John Dallaway
7 // This program is part of the eCos host tools.
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)
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
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.
23 // ----------------------------------------------------------------------------
25 //####COPYRIGHTEND####
28 //===========================================================================
29 //#####DESCRIPTIONBEGIN####
31 // Author(s): julians, jld
32 // Contact(s): julians, jld
36 // Description: Implementation file for the ConfigTool main window
43 //####DESCRIPTIONEND####
45 //===========================================================================
47 // ============================================================================
49 // ============================================================================
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 #pragma implementation "mainwin.h"
58 // Includes other headers for precompiled compilation
65 #include "wx/cshelp.h"
66 #include "wx/wxhtml.h"
67 #include "wx/filedlg.h"
68 #include "wx/wfstream.h"
71 #include "configtool.h"
72 #include "configtree.h"
73 #include "propertywin.h"
74 #include "conflictwin.h"
76 #include "outputwin.h"
77 #include "shortdescrwin.h"
78 #include "conflictsdlg.h"
81 #include "settingsdlg.h"
82 #include "platformsdlg.h"
83 #include "buildoptionsdlg.h"
84 #include "templatesdlg.h"
86 #include "packagesdlg.h"
87 #include "configtooldoc.h"
88 #include "configtoolview.h"
89 #include "folderdlg.h"
91 #include "docsystem.h"
94 #include "wx/msw/winundef.h"
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
100 // the application icon
101 #if defined(__WXGTK__) || defined(__WXMOTIF__)
102 #include "bitmaps/configtool.xpm"
103 #include "bitmaps/new.xpm"
104 #include "bitmaps/open.xpm"
105 #include "bitmaps/save.xpm"
106 #include "bitmaps/copy.xpm"
107 #include "bitmaps/paste.xpm"
108 #include "bitmaps/cut.xpm"
109 #include "bitmaps/delete.xpm"
110 #include "bitmaps/help.xpm"
111 #include "bitmaps/cshelp.xpm"
112 #include "bitmaps/search.xpm"
113 #include "bitmaps/stopbuild.xpm"
114 #include "bitmaps/buildlibrary.xpm"
115 #include "bitmaps/newregion.xpm"
116 #include "bitmaps/newsection.xpm"
117 #include "bitmaps/properties.xpm"
120 // ----------------------------------------------------------------------------
121 // event tables and other macros for wxWindows
122 // ----------------------------------------------------------------------------
124 BEGIN_EVENT_TABLE(ecMainFrame, wxDocParentFrame)
125 EVT_MENU(wxID_EXIT, ecMainFrame::OnQuit)
126 EVT_MENU(wxID_ABOUT, ecMainFrame::OnAbout)
127 EVT_MENU(ecID_REPOSITORY_INFO, ecMainFrame::OnRepositoryInfo)
128 EVT_MENU(wxID_FIND, ecMainFrame::OnFind)
129 EVT_MENU(ecID_FIND_NEXT, ecMainFrame::OnFindNext)
130 EVT_SASH_DRAGGED_RANGE(ecID_CONFIG_SASH_WINDOW, ecID_OUTPUT_SASH_WINDOW, ecMainFrame::OnSashDrag)
131 EVT_SIZE(ecMainFrame::OnSize)
132 EVT_IDLE(ecMainFrame::OnIdle)
133 EVT_CLOSE(ecMainFrame::OnCloseWindow)
134 EVT_MENU(ecID_TOGGLE_CONFLICTS, ecMainFrame::OnToggleWindow)
135 EVT_MENU(ecID_TOGGLE_PROPERTIES, ecMainFrame::OnToggleWindow)
136 EVT_MENU(ecID_TOGGLE_MEMORY, ecMainFrame::OnToggleWindow)
137 EVT_MENU(ecID_TOGGLE_SHORT_DESCR, ecMainFrame::OnToggleWindow)
138 EVT_MENU(ecID_TOGGLE_OUTPUT, ecMainFrame::OnToggleWindow)
139 EVT_MENU(ecID_TOOLBARS, ecMainFrame::OnToggleToolbar)
140 EVT_MENU(ecID_CONFIGTOOL_HELP, ecMainFrame::OnHelpConfigtool)
141 EVT_MENU(ecID_ECOS_HELP, ecMainFrame::OnHelpEcos)
142 EVT_MENU(ecID_CONTEXT_HELP, ecMainFrame::OnHelpContext)
143 EVT_MENU(ecID_RESOLVE_CONFLICTS, ecMainFrame::OnResolveConflicts)
144 EVT_UPDATE_UI(ecID_RESOLVE_CONFLICTS, ecMainFrame::OnUpdateResolveConflicts)
145 EVT_MENU(ecID_SETTINGS, ecMainFrame::OnSettings)
146 EVT_MENU(ecID_PLATFORMS, ecMainFrame::OnPlatforms)
147 EVT_MENU(ecID_BUILD_OPTIONS, ecMainFrame::OnBuildOptions)
148 EVT_MENU(ecID_PATHS_BUILD_TOOLS, ecMainFrame::OnBuildToolsPath)
149 EVT_MENU(ecID_PATHS_USER_TOOLS, ecMainFrame::OnUserToolsPath)
150 EVT_MENU(ecID_BUILD_TEMPLATES, ecMainFrame::OnTemplates)
151 EVT_MENU(ecID_ADMINISTRATION, ecMainFrame::OnAdmin)
152 EVT_MENU(ecID_BUILD_PACKAGES, ecMainFrame::OnPackages)
153 EVT_MENU(ecID_RUN_TESTS, ecMainFrame::OnRunTests)
154 EVT_MENU(ecID_BUILD_REPOSITORY, ecMainFrame::OnChooseRepository)
155 EVT_MENU(ecID_WHATS_THIS, ecMainFrame::OnWhatsThis)
156 EVT_MENU(ecID_SAVE_OUTPUT, ecMainFrame::OnSaveOutput)
157 EVT_MENU(ecID_IMPORT, ecMainFrame::OnImport)
158 EVT_MENU(ecID_EXPORT, ecMainFrame::OnExport)
159 EVT_MENU(ecID_REDHAT_WEB_HOME, ecMainFrame::OnWebRedHatHome)
160 EVT_MENU(ecID_REDHAT_WEB_ECOS, ecMainFrame::OnWebEcos)
161 EVT_MENU(ecID_REDHAT_WEB_NET_RELEASE, ecMainFrame::OnWebNetRelease)
162 EVT_MENU(ecID_REDHAT_WEB_UITRON, ecMainFrame::OnWebUitron)
163 EVT_MENU(ecID_STOP_BUILD, ecMainFrame::OnStopBuild)
164 EVT_MENU(ecID_BUILD_LIBRARY, ecMainFrame::OnBuildLibrary)
165 EVT_MENU(ecID_BUILD_TESTS, ecMainFrame::OnBuildTests)
166 EVT_MENU(ecID_CLEAN, ecMainFrame::OnClean)
167 EVT_MENU(ecID_SHELL, ecMainFrame::OnShell)
168 EVT_MENU(ecID_INDEX_DOCS, ecMainFrame::OnIndexDocs)
169 EVT_MENU(ecID_GENERATE_BUILD_TREE, ecMainFrame::OnGenerateBuildTree)
171 EVT_UPDATE_UI(ecID_PLATFORMS, ecMainFrame::OnUpdatePlatforms)
172 EVT_UPDATE_UI(ecID_BUILD_OPTIONS, ecMainFrame::OnUpdateBuildOptions)
173 EVT_UPDATE_UI(ecID_PATHS_BUILD_TOOLS, ecMainFrame::OnUpdateBuildToolsPath)
174 EVT_UPDATE_UI(ecID_PATHS_USER_TOOLS, ecMainFrame::OnUpdateUserToolsPath)
175 EVT_UPDATE_UI(ecID_BUILD_TEMPLATES, ecMainFrame::OnUpdateTemplates)
176 EVT_UPDATE_UI(ecID_ADMINISTRATION, ecMainFrame::OnUpdateAdmin)
177 EVT_UPDATE_UI(ecID_BUILD_PACKAGES, ecMainFrame::OnUpdatePackages)
178 EVT_UPDATE_UI(ecID_RUN_TESTS, ecMainFrame::OnUpdateRunTests)
179 EVT_UPDATE_UI(ecID_BUILD_REPOSITORY, ecMainFrame::OnUpdateChooseRepository)
180 EVT_UPDATE_UI(ecID_CLEAN, ecMainFrame::OnUpdateClean)
181 EVT_UPDATE_UI(ecID_REPOSITORY_INFO, ecMainFrame::OnUpdateRepositoryInfo)
182 EVT_UPDATE_UI(ecID_INDEX_DOCS, ecMainFrame::OnUpdateIndexDocs)
184 EVT_UPDATE_UI(ecID_TOGGLE_CONFLICTS, ecMainFrame::OnUpdateToggleWindow)
185 EVT_UPDATE_UI(ecID_TOGGLE_PROPERTIES, ecMainFrame::OnUpdateToggleWindow)
186 EVT_UPDATE_UI(ecID_TOGGLE_MEMORY, ecMainFrame::OnUpdateToggleWindow)
187 EVT_UPDATE_UI(ecID_TOGGLE_SHORT_DESCR, ecMainFrame::OnUpdateToggleWindow)
188 EVT_UPDATE_UI(ecID_TOGGLE_OUTPUT, ecMainFrame::OnUpdateToggleWindow)
189 EVT_UPDATE_UI(ecID_TOOLBARS, ecMainFrame::OnUpdateToggleToolbar)
191 // Disable commands that don't make sense immediately or are not yet implemented.
192 // Also, for text controls, disable if they are not being enabled by currently-focussed controls.
193 EVT_UPDATE_UI(wxID_COPY, ecMainFrame::OnUpdateDisable)
194 EVT_UPDATE_UI(wxID_CUT, ecMainFrame::OnUpdateDisable)
195 EVT_UPDATE_UI(wxID_PASTE, ecMainFrame::OnUpdateDisable)
196 EVT_UPDATE_UI(wxID_SELECTALL, ecMainFrame::OnUpdateSelectAll)
197 EVT_UPDATE_UI(wxID_CLEAR, ecMainFrame::OnUpdateClear)
199 EVT_UPDATE_UI(wxID_FIND, ecMainFrame::OnUpdateFind)
200 EVT_UPDATE_UI(ecID_FIND_NEXT, ecMainFrame::OnUpdateFindNext)
202 EVT_MENU(ecID_NEW_REGION, ecMainFrame::OnNewRegion)
203 EVT_MENU(ecID_NEW_SECTION, ecMainFrame::OnNewSection)
204 EVT_MENU(ecID_DELETE, ecMainFrame::OnDeleteRegionOrSection)
205 EVT_MENU(ecID_PROPERTIES, ecMainFrame::OnRegionOrSectionProperties)
207 EVT_UPDATE_UI(ecID_STOP_BUILD, ecMainFrame::OnUpdateStopBuild)
208 EVT_UPDATE_UI(ecID_BUILD_LIBRARY, ecMainFrame::OnUpdateBuildLibrary)
209 EVT_UPDATE_UI(ecID_BUILD_TESTS, ecMainFrame::OnUpdateBuildTests)
210 EVT_UPDATE_UI(ecID_GENERATE_BUILD_TREE, ecMainFrame::OnUpdateGenerateBuildTree)
212 EVT_UPDATE_UI(ecID_SHELL, ecMainFrame::OnUpdateShell)
214 EVT_UPDATE_UI(ecID_NEW_REGION, ecMainFrame::OnUpdateNewRegion)
215 EVT_UPDATE_UI(ecID_NEW_SECTION, ecMainFrame::OnUpdateNewSection)
216 EVT_UPDATE_UI(ecID_DELETE, ecMainFrame::OnUpdateDeleteRegionOrSection)
217 EVT_UPDATE_UI(ecID_PROPERTIES, ecMainFrame::OnUpdateRegionOrSectionProperties)
219 EVT_UPDATE_UI(ecID_IMPORT, ecMainFrame::OnUpdateImport)
220 EVT_UPDATE_UI(ecID_EXPORT, ecMainFrame::OnUpdateExport)
223 // ----------------------------------------------------------------------------
225 // ----------------------------------------------------------------------------
228 ecMainFrame::ecMainFrame(wxDocManager *manager, const wxString& title, const wxPoint& pos, const wxSize& size):
229 wxDocParentFrame(manager, (wxFrame *)NULL, ecID_MAIN_FRAME, title, pos, size, wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE )
232 m_scrolledWindow = NULL;
234 m_configSashWindow = NULL;
235 m_valueWindow = NULL;
236 m_outputWindow = NULL;
237 m_shortDescrWindow = NULL;
238 m_conflictsSashWindow = NULL;
239 m_propertiesSashWindow = NULL;
240 m_memorySashWindow = NULL;
241 m_shortDescrSashWindow = NULL;
242 m_outputSashWindow = NULL;
243 m_propertyListWindow = NULL;
248 // we need this in order to allow the about menu relocation, since ABOUT is
249 // not the default id of the about menu
250 wxApp::s_macAboutMenuItemId = wxID_EXIT;
255 wxIcon mainIcon(wxICON(configtool));
256 wxGetApp().SetMainIcon(mainIcon);
258 // set the frame icon
264 wxMenu *fileMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
266 fileMenu->Append(wxID_NEW, _("&New\tCtrl+N"), _("Creates a new document"));
268 wxMenuItem* menuItem = new wxMenuItem(fileMenu, wxID_NEW, _("&New\tCtrl+N"), _("Creates a new document"));
269 menuItem->SetBitmaps(wxBITMAP(new));
270 fileMenu->Append(menuItem);
273 fileMenu->Append(wxID_OPEN, _("&Open\tCtrl+O"), _("Opens an existing document"));
274 fileMenu->Append(wxID_SAVE, _("&Save\tCtrl+S"), _("Saves the active document"));
275 fileMenu->Append(wxID_SAVEAS, _("Save &As..."), _("Saves the active document with a new name"));
276 fileMenu->AppendSeparator();
277 fileMenu->Append(ecID_IMPORT, _("&Import..."), _("Imports a minimal configuration exported from another configuration"));
278 fileMenu->Append(ecID_EXPORT, _("&Export..."), _("Exports a minimal configuration for importing into another configuration"));
279 fileMenu->AppendSeparator();
280 fileMenu->Append(wxID_EXIT, _("E&xit\tAlt+X"), _("Quits the application"));
282 // A history of files visited. Use this menu.
283 wxGetApp().GetDocManager()->FileHistoryUseMenu(fileMenu);
286 wxConfig config(wxGetApp().GetSettings().GetConfigAppName());
287 config.SetPath(wxT("FileHistory/"));
288 wxGetApp().GetDocManager()->FileHistoryLoad(config);
292 wxMenu* editMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
294 editMenu->Append(wxID_CUT, _("Cu&t\tCtrl+X"), _("Cuts the output pane selection and moves it to the Clipboard"));
295 editMenu->Append(wxID_COPY, _("&Copy\tCtrl+C"), _("Copies the output pane selection to the clipboard"));
296 editMenu->Append(wxID_PASTE, _("&Paste\tCtrl+V"), _("Inserts Clipboard contents"));
297 editMenu->Append(wxID_CLEAR, _("&Clear"), _("Erases everything in the output pane"));
298 editMenu->AppendSeparator();
299 editMenu->Append(wxID_SELECTALL, _("&Select All\tCtrl+A"), _("Selects the entire output pane"));
300 editMenu->AppendSeparator();
301 editMenu->Append(wxID_FIND, _("&Find...\tCtrl+F"), _("Finds the specified text"));
302 editMenu->Append(ecID_FIND_NEXT, _("Find &Next\tF3"), _("Finds the next item matching the Find text"));
303 editMenu->AppendSeparator();
304 editMenu->Append(ecID_SAVE_OUTPUT, _("Sa&ve Output..."), _("Saves the contents of the output pane"));
307 wxMenu* viewMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
309 viewMenu->Append(ecID_SETTINGS, _("&Settings...\tCtrl+T"), _("Shows the application settings dialog"));
310 viewMenu->AppendSeparator();
311 viewMenu->Append(ecID_TOOLBARS, _("&Toolbar"), _("Shows or hides the toolbar"), TRUE);
312 viewMenu->Append(ecID_TOGGLE_PROPERTIES, _("&Properties\tAlt+1"), _("Shows or hides the properties window"), TRUE);
313 viewMenu->Append(ecID_TOGGLE_OUTPUT, _("&Output\tAlt+2"), _("Shows the output window"), TRUE);
314 viewMenu->Append(ecID_TOGGLE_SHORT_DESCR, _("&Short Description\tAlt+3"), _("Shows or hides the short description window"), TRUE);
316 viewMenu->Append(ecID_TOGGLE_CONFLICTS, _("&Conflicts\tAlt+4"), _("Shows or hides the conflicts window"), TRUE);
318 viewMenu->Append(ecID_TOGGLE_MEMORY, _("&Memory Layout\tAlt+5"), _("Shows or hides the memory layout window"), TRUE);
319 //viewMenu->Enable(ecID_TOGGLE_MEMORY, FALSE);
322 // Not clear what these do, so let's not have them.
323 //viewMenu->Append(ecID_VIEW_NEXT, _("&Next\tAlt+F6"), _("Selects the next visible pane"));
324 //viewMenu->Append(ecID_VIEW_PREVIOUS, _("&Previous\tShift+Alt+F6"), _("Selects the previous visible pane"));
327 wxMenu* buildMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
329 buildMenu->Append(ecID_BUILD_LIBRARY, _("&Library\tF7"), _("Builds the library"));
330 buildMenu->Append(ecID_BUILD_TESTS, _("&Tests\tShift+F7"), _("Builds the tests"));
331 buildMenu->Append(ecID_CLEAN, _("&Clean"), _("Deletes intermediate and output files"));
332 buildMenu->Append(ecID_STOP_BUILD, _("&Stop"), _("Stops the build"));
333 buildMenu->AppendSeparator();
334 buildMenu->Append(ecID_GENERATE_BUILD_TREE, _("&Generate Build Tree"), _("Explicitly recreates the build tree"));
335 buildMenu->AppendSeparator();
336 buildMenu->Append(ecID_BUILD_OPTIONS, _("&Options..."), _("Changes build options"));
337 buildMenu->Append(ecID_BUILD_REPOSITORY, _("&Repository..."), _("Selects repository"));
338 buildMenu->Append(ecID_BUILD_TEMPLATES, _("&Templates..."), _("Selects the package templates"));
339 buildMenu->Append(ecID_BUILD_PACKAGES, _("&Packages..."), _("Selects individual packages"));
342 wxMenu* toolsMenu = new wxMenu(wxT(""), wxMENU_TEAROFF);
344 wxMenu* pathMenu = new wxMenu;
345 pathMenu->Append(ecID_PATHS_BUILD_TOOLS, _("&Build Tools..."), _("Specifies the folder containing the build tools"));
346 pathMenu->Append(ecID_PATHS_USER_TOOLS, _("&User Tools..."), _("Specifies the folder containing the user tools"));
347 toolsMenu->Append(ecID_PATHS, _("&Paths"), pathMenu);
349 toolsMenu->Append(ecID_SHELL, _("&Shell..."), _("Invokes a command shell"));
350 toolsMenu->Append(ecID_RUN_TESTS, _("&Run Tests...\tCtrl+F5"), _("Runs the configuration tests"));
351 toolsMenu->Append(ecID_PLATFORMS, _("&Platforms..."), _("Edits the platforms list"));
352 toolsMenu->Append(ecID_RESOLVE_CONFLICTS, _("Resolve &Conflicts..."), _("Resolves conflicts"));
353 toolsMenu->Append(ecID_ADMINISTRATION, _("&Administration..."), _("Performs repository administration tasks"));
355 toolsMenu->AppendSeparator();
356 toolsMenu->Append(ecID_TOOLS_OPTIONS, _("&Options..."), _("Changes configuration options"));
358 toolsMenu->Append(ecID_INDEX_DOCS, _("Regenerate Help &Index"), _("Regenerates the online help contents"));
361 wxMenu* helpMenu = new wxMenu;
362 helpMenu->Append(ecID_CONFIGTOOL_HELP, _("&Configuration Tool Help\tShift+F1"), _("Displays help"));
363 helpMenu->Append(ecID_ECOS_HELP, _("&eCos Documentation"), _("Displays the documentation home page"));
364 helpMenu->Append(ecID_CONTEXT_HELP, _("&Help On..."), _("Displays help for clicked-on windows"));
365 helpMenu->AppendSeparator();
367 wxMenu* webMenu = new wxMenu;
368 webMenu->Append(ecID_REDHAT_WEB_HOME, _("&Red Hat Home Page"), _("Opens the Red Hat home page"));
369 webMenu->Append(ecID_REDHAT_WEB_ECOS, _("&eCos Product Page"), _("Opens the eCos product page"));
370 webMenu->Append(ecID_REDHAT_WEB_NET_RELEASE, _("eCos &Net Release Page"), _("Opens the eCos net release page"));
371 webMenu->AppendSeparator();
372 webMenu->Append(ecID_REDHAT_WEB_UITRON, _("&ITRON"), _("Opens the ITRON specification page"));
374 // helpMenu->Append(ecID_REDHAT_WEB, _("&Red Hat on the Web"), webMenu);
375 // helpMenu->AppendSeparator();
376 helpMenu->Append(ecID_REPOSITORY_INFO, _("Repository &Information...\tCtrl+I"), _("Displays information about the current repository"));
377 helpMenu->Append(wxID_ABOUT, _("&About the Configuration Tool..."), _("Displays program information, version and copyright"));
379 wxMenuBar *menuBar = new wxMenuBar();
380 menuBar->Append(fileMenu, _("&File"));
381 menuBar->Append(editMenu, _("&Edit"));
382 menuBar->Append(viewMenu, _("&View"));
383 menuBar->Append(buildMenu, _("&Build"));
384 menuBar->Append(toolsMenu, _("&Tools"));
385 menuBar->Append(helpMenu, _("&Help"));
387 // ... and attach this menu bar to the frame
390 // Create the toolbar
393 if (!wxGetApp().GetSettings().m_showToolBar)
394 GetToolBar()->Show( FALSE );
396 // Create the status bar
397 CreateStatusBar(4, wxST_SIZEGRIP);
399 int* widths = new int[4];
400 widths[0] = -1; widths[1] = 100; widths[2] = 40; widths[3] = 80;
401 SetStatusWidths(4, widths);
404 SetStatusText(_("No conflicts"), ecFailRulePane);
405 SetStatusText(_("Ready"), ecStatusPane);
408 // Create the windows
409 void ecMainFrame::CreateWindows()
411 ecSettings& stg = wxGetApp().GetSettings();
413 // Create the sash layout windows first
415 // Sash window for the output window
416 m_outputSashWindow = new wxSashLayoutWindow(this, ecID_OUTPUT_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
417 m_outputSashWindow->SetDefaultSize(stg.m_outputSashSize);
418 m_outputSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
419 m_outputSashWindow->SetAlignment(wxLAYOUT_BOTTOM);
420 m_outputSashWindow->SetSashVisible(wxSASH_TOP, TRUE);
421 m_outputWindow = new ecOutputWindow(m_outputSashWindow, ecID_OUTPUT_WINDOW, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxCLIP_CHILDREN|wxTE_READONLY|wxTE_RICH);
422 m_outputWindow->SetHelpText(_("The output window displays various warning and informational messages."));
424 // Sash window for the memory window
425 m_memorySashWindow = new wxSashLayoutWindow(this, ecID_MEMORY_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxSW_3D|wxCLIP_SIBLINGS);
426 m_memorySashWindow->SetDefaultSize(stg.m_memorySashSize);
427 m_memorySashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
428 m_memorySashWindow->SetAlignment(wxLAYOUT_BOTTOM);
429 m_memorySashWindow->SetSashVisible(wxSASH_TOP, TRUE);
430 //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);
431 m_mltWindow = new ecMemoryLayoutWindow(m_memorySashWindow, ecID_MEMORY_WINDOW, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN|wxSUNKEN_BORDER);
432 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 // Sash window for the config tree
435 m_configSashWindow = new wxSashLayoutWindow(this, ecID_CONFIG_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_CHILDREN/*|wxCLIP_SIBLINGS*/);
436 m_configSashWindow->SetDefaultSize(stg.m_treeSashSize);
437 m_configSashWindow->SetOrientation(wxLAYOUT_VERTICAL);
438 m_configSashWindow->SetAlignment(wxLAYOUT_LEFT);
439 m_configSashWindow->SetSashVisible(wxSASH_RIGHT, TRUE);
441 // Sash window for the conflicts window
442 m_conflictsSashWindow = new wxSashLayoutWindow(this, ecID_CONFLICTS_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
443 m_conflictsSashWindow->SetDefaultSize(stg.m_conflictsSashSize);
444 m_conflictsSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
445 m_conflictsSashWindow->SetAlignment(wxLAYOUT_TOP);
446 m_conflictsSashWindow->SetSashVisible(wxSASH_BOTTOM, TRUE);
447 m_conflictsWindow = new ecConflictListCtrl(m_conflictsSashWindow, ecID_CONFLICTS_WINDOW, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxCLIP_CHILDREN|wxSUNKEN_BORDER);
448 m_conflictsWindow->SetHelpText(_("The conflicts window lists any outstanding conflicts in the configuration."));
450 // Sash window for the properties window
451 m_propertiesSashWindow = new wxSashLayoutWindow(this, ecID_PROPERTIES_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
452 m_propertiesSashWindow->SetDefaultSize(stg.m_propertiesSashSize);
453 m_propertiesSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
454 m_propertiesSashWindow->SetAlignment(wxLAYOUT_TOP);
455 m_propertiesSashWindow->SetSashVisible(wxSASH_BOTTOM, TRUE);
456 // 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);
457 m_propertyListWindow = new ecPropertyListCtrl(m_propertiesSashWindow, ecID_PROPERTIES_WINDOW, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxCLIP_CHILDREN|wxLC_VRULES|wxLC_HRULES|wxSUNKEN_BORDER);
458 m_propertyListWindow->SetHelpText(_("The properties window shows the properties of the selected configuration item."));
460 // Sash window for the short description window
461 m_shortDescrSashWindow = new wxSashLayoutWindow(this, ecID_SHORT_DESCR_SASH_WINDOW, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxCLIP_SIBLINGS);
462 m_shortDescrSashWindow->SetDefaultSize(stg.m_shortDescrSashSize);
463 m_shortDescrSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
464 m_shortDescrSashWindow->SetAlignment(wxLAYOUT_TOP);
465 //m_shortDescrSashWindow->SetSashVisible(wxSASH_TOP, TRUE);
466 m_shortDescrWindow = new ecShortDescriptionWindow(m_shortDescrSashWindow, ecID_SHORT_DESCR_WINDOW, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxCLIP_CHILDREN/*|wxTE_NO_VSCROLL*/|wxTE_READONLY);
467 m_shortDescrWindow->SetBackgroundColour(wxColour(255, 255, 225));
468 m_shortDescrWindow->SetHelpText(_("The short description window displays brief help on a selected configuration item."));
470 // Create a composite widget to represent the scrolling config window
471 m_scrolledWindow = new ecSplitterScrolledWindow(m_configSashWindow, ecID_SCROLLED_WINDOW, wxDefaultPosition,
472 wxSize(400, 100), wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL);
473 m_splitter = new wxThinSplitterWindow(m_scrolledWindow, ecID_SPLITTER_WINDOW, wxDefaultPosition,
474 wxSize(400, 100), wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
475 m_splitter->SetSashSize(2);
476 m_tree = new ecConfigTreeCtrl(m_splitter, ecID_TREE_CTRL, wxDefaultPosition,
477 wxSize(200, 100), wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER );
478 m_valueWindow = new ecValueWindow(m_splitter, ecID_VALUE_WINDOW, wxDefaultPosition,
479 wxSize(200, 100), wxNO_BORDER);
480 m_splitter->SplitVertically(m_tree, m_valueWindow);
481 m_splitter->SetMinimumPaneSize(100);
482 //m_splitter->AdjustScrollbars();
483 m_splitter->SetSashPosition(wxGetApp().GetSettings().m_configPaneWidth);
484 m_scrolledWindow->SetTargetWindow(m_tree);
485 m_scrolledWindow->EnableScrolling(FALSE, FALSE);
486 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."));
487 m_valueWindow->SetHelpText(m_tree->GetHelpText());
489 // Let the two controls know about each other
490 m_valueWindow->SetTreeCtrl(m_tree);
491 m_tree->SetCompanionWindow(m_valueWindow);
493 // Set visibility according to config settings
494 if (!wxGetApp().GetSettings().m_showConflictsWindow)
495 m_conflictsSashWindow->Show(FALSE);
496 if (!wxGetApp().GetSettings().m_showPropertiesWindow)
497 m_propertiesSashWindow->Show(FALSE);
498 if (!wxGetApp().GetSettings().m_showShortDescrWindow)
499 m_shortDescrSashWindow->Show(FALSE);
500 if (!wxGetApp().GetSettings().m_showOutputWindow)
501 m_outputSashWindow->Show(FALSE);
502 if (!wxGetApp().GetSettings().m_showMemoryWindow)
503 m_memorySashWindow->Show(FALSE);
507 void ecMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
512 void ecMainFrame::OnFind(wxCommandEvent& event)
516 m_findDialog->Raise();
520 m_findDialog = new ecFindDialog (this, ecID_FIND_DIALOG, _("Find in configuration"));
521 m_findDialog->Show(TRUE);
523 // For some reason, under Windows, the text control doesn't get the focus if we set the focus
524 // and then call Show. We have to set the focus afterwards instead.
525 m_findDialog->FindWindow(ecID_FIND_DIALOG_WHAT)->SetFocus();
528 void ecMainFrame::OnFindNext(wxCommandEvent& event)
530 if (wxGetApp().GetConfigToolDoc())
532 ecConfigToolView* view = (ecConfigToolView*) wxGetApp().GetConfigToolDoc()->GetFirstView() ;
534 view->DoFind(wxGetApp().GetSettings().m_findText, this);
538 void ecMainFrame::OnUpdateFind(wxUpdateUIEvent& event)
540 event.Enable( wxGetApp().GetConfigToolDoc() != NULL );
543 void ecMainFrame::OnUpdateFindNext(wxUpdateUIEvent& event)
545 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && !wxGetApp().GetSettings().m_findText.IsEmpty() );
548 void ecMainFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
550 // ecAboutDialog dialog(this, ecID_ABOUT_DIALOG, _("About eCos Configuration Tool"));
551 // dialog.ShowModal();
552 wxMessageBox(_("eCos Configuration Tool 2.12.net (eCos 2.0b1)\n\nCopyright (c) Red Hat, Inc. 1998-2002\nCopyright (c) John Dallaway 2003"), _("About eCos Configuration Tool"), wxICON_INFORMATION | wxOK);
555 void ecMainFrame::OnSize(wxSizeEvent& WXUNUSED(event))
557 // First, we need to resize the sash windows proportionately,
558 // or we may end up with negative sizes, etc.
559 wxRect rect = GetRect();
560 if (rect != wxGetApp().GetSettings().m_frameSize)
562 double factorX = ((double) rect.GetWidth() / (double) wxGetApp().GetSettings().m_frameSize.GetWidth());
563 double factorY = ((double) rect.GetHeight() / (double) wxGetApp().GetSettings().m_frameSize.GetHeight());
565 wxNode* node = GetChildren().First();
568 wxWindow* win = (wxWindow*) node->Data();
569 if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)))
571 wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) win;
572 wxSize sz = sashWin->GetSize();
573 sashWin->SetDefaultSize(wxSize((int) ((double) sz.x * factorX), (int) ((double) sz.y * factorY)));
579 wxLayoutAlgorithm layout;
580 layout.LayoutFrame(this);
582 wxGetApp().GetSettings().m_frameSize = rect;
585 void ecMainFrame::RecreateToolbar()
587 // delete and recreate the toolbar
588 wxToolBarBase *toolBar = GetToolBar();
595 long style = wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL | wxTB_DOCKABLE;
597 toolBar = CreateToolBar(style, ecID_TOOLBAR);
599 toolBar->SetMargins( 4, 4 );
602 wxBitmap toolBarBitmaps[20];
604 toolBarBitmaps[0] = wxBITMAP(new);
605 toolBarBitmaps[1] = wxBITMAP(open);
606 toolBarBitmaps[2] = wxBITMAP(save);
607 toolBarBitmaps[3] = wxBITMAP(copy);
608 toolBarBitmaps[4] = wxBITMAP(cut);
609 toolBarBitmaps[5] = wxBITMAP(paste);
610 toolBarBitmaps[6] = wxBITMAP(search);
611 toolBarBitmaps[7] = wxBITMAP(stopbuild);
612 toolBarBitmaps[8] = wxBITMAP(buildlibrary);
613 toolBarBitmaps[9] = wxBITMAP(help);
614 toolBarBitmaps[10] = wxBITMAP(newregion);
615 toolBarBitmaps[11] = wxBITMAP(newsection);
616 toolBarBitmaps[12] = wxBITMAP(delete);
617 toolBarBitmaps[13] = wxBITMAP(properties);
618 toolBarBitmaps[14] = wxBITMAP(cshelp);
620 toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("New file"));
621 toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Open file"));
622 toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Save file"));
624 toolBar->AddSeparator();
626 toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Cut");
627 toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Copy");
628 toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Paste");
629 toolBar->AddTool(wxID_FIND, toolBarBitmaps[6], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Search");
631 toolBar->AddSeparator();
633 toolBar->AddTool(ecID_STOP_BUILD, toolBarBitmaps[7], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Stop build");
634 toolBar->AddTool(ecID_BUILD_LIBRARY, toolBarBitmaps[8], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Build library");
636 toolBar->AddSeparator();
637 toolBar->AddTool(ecID_NEW_REGION, toolBarBitmaps[10], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "New region");
638 toolBar->AddTool(ecID_NEW_SECTION, toolBarBitmaps[11], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "New section");
639 toolBar->AddTool(ecID_DELETE, toolBarBitmaps[12], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Delete");
640 toolBar->AddTool(ecID_PROPERTIES, toolBarBitmaps[13], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Properties");
642 toolBar->AddSeparator();
643 toolBar->AddTool(ecID_CONTEXT_HELP, toolBarBitmaps[14], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Show help for clicked-on windows");
644 toolBar->AddTool(ecID_ECOS_HELP, toolBarBitmaps[9], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Show help");
646 // after adding the buttons to the toolbar, must call Realize() to reflect
650 toolBar->SetHelpText(_("The toolbar allows quick access to commonly-used commands."));
653 // Toggle one of the windows
654 void ecMainFrame::OnToggleWindow(wxCommandEvent& event)
656 ToggleWindow(event.GetId());
659 // Toggle the given window on or off
660 void ecMainFrame::ToggleWindow(int windowId)
662 wxWindow* win = NULL;
663 bool *configSetting = NULL;
666 case ecID_TOGGLE_CONFLICTS:
667 win = m_conflictsSashWindow;
668 configSetting = & wxGetApp().GetSettings().m_showConflictsWindow;
670 case ecID_TOGGLE_PROPERTIES:
671 win = m_propertiesSashWindow;
672 configSetting = & wxGetApp().GetSettings().m_showPropertiesWindow;
674 case ecID_TOGGLE_MEMORY:
675 win = m_memorySashWindow;
676 configSetting = & wxGetApp().GetSettings().m_showMemoryWindow;
678 case ecID_TOGGLE_SHORT_DESCR:
679 win = m_shortDescrSashWindow;
680 configSetting = & wxGetApp().GetSettings().m_showShortDescrWindow;
682 case ecID_TOGGLE_OUTPUT:
683 win = m_outputSashWindow;
684 configSetting = & wxGetApp().GetSettings().m_showOutputWindow;
689 bool showing = !win->IsShown();
692 * configSetting = showing;
694 // Make sure we don't have ridiculous sizes
695 if (showing && (windowId == ecID_TOGGLE_CONFLICTS || windowId == ecID_TOGGLE_PROPERTIES || windowId == ecID_TOGGLE_SHORT_DESCR))
697 m_conflictsSashWindow->SetDefaultSize(wxSize(2000, 50));
698 m_propertiesSashWindow->SetDefaultSize(wxSize(2000, 50));
699 m_shortDescrSashWindow->SetDefaultSize(wxSize(2000, 50));
701 wxSize frameSize = GetClientSize();
702 wxSize configSize = m_configSashWindow->GetSize();
704 if ((frameSize.x - configSize.x) < 5)
706 // We must resize the config window
707 m_configSashWindow->SetDefaultSize(wxSize(frameSize.x/2, configSize.y));
711 wxLayoutAlgorithm layout;
712 layout.LayoutFrame(this);
716 void ecMainFrame::OnUpdateToggleWindow(wxUpdateUIEvent& event)
718 wxWindow* win = NULL;
719 switch (event.GetId())
721 case ecID_TOGGLE_CONFLICTS:
722 win = m_conflictsSashWindow;
724 case ecID_TOGGLE_PROPERTIES:
725 win = m_propertiesSashWindow;
727 case ecID_TOGGLE_MEMORY:
728 win = m_memorySashWindow;
730 case ecID_TOGGLE_SHORT_DESCR:
731 win = m_shortDescrSashWindow;
733 case ecID_TOGGLE_OUTPUT:
734 win = m_outputSashWindow;
739 event.Enable( TRUE );
740 event.Check( win->IsShown() );
744 if (event.GetId() == ecID_TOGGLE_MEMORY)
745 event.Enable( FALSE );
750 void ecMainFrame::OnUpdateDisable(wxUpdateUIEvent& event)
752 event.Enable( FALSE );
755 void ecMainFrame::OnToggleToolbar(wxCommandEvent& event)
757 GetToolBar()->Show( ! GetToolBar()->IsShown() );
759 wxSizeEvent sizeEvent(GetSize(), GetId());
760 GetEventHandler()->ProcessEvent(sizeEvent);
762 GtkOnSize( GetPosition().x, GetPosition().y, GetSize().x, GetSize().y);
766 void ecMainFrame::OnUpdateToggleToolbar(wxUpdateUIEvent& event)
768 event.Check( GetToolBar()->IsShown() );
771 // Respond to a sash drag operation, by setting the new size
772 // for this window and then recalculating the layout.
773 void ecMainFrame::OnSashDrag(wxSashEvent& event)
775 if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
778 switch (event.GetId())
780 case ecID_CONFIG_SASH_WINDOW:
782 m_configSashWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 2000));
785 case ecID_CONFLICTS_SASH_WINDOW:
787 // Change the height of the properties window so we don't affect the
788 // short description window
789 int deltaY = event.GetDragRect().height - m_conflictsSashWindow->GetSize().y;
790 int propertiesHeight = 0;
791 if (m_propertiesSashWindow->IsShown())
793 propertiesHeight = m_propertiesSashWindow->GetSize().y - deltaY ;
794 if (propertiesHeight <= 0)
797 m_propertiesSashWindow->SetDefaultSize(wxSize(2000, propertiesHeight));
799 m_conflictsSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
802 case ecID_PROPERTIES_SASH_WINDOW:
804 m_propertiesSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
807 case ecID_SHORT_DESCR_SASH_WINDOW:
809 m_shortDescrSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
812 case ecID_MEMORY_SASH_WINDOW:
814 m_memorySashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
817 case ecID_OUTPUT_SASH_WINDOW:
819 m_outputSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height));
824 wxFAIL_MSG( _("Shouldn't get here.") );
829 if (event.GetId() == ecID_MEMORY_SASH_WINDOW || event.GetId() == ecID_OUTPUT_SASH_WINDOW)
831 // Special processing so we don't spoil the layout of the
832 // conflicts/properties/short description windows
834 GetMinorWindows(minorWindows);
836 int memoryLayoutHeight = m_memorySashWindow->IsShown() ? m_memorySashWindow->GetSize().y : 0;
837 int outputHeight = m_memorySashWindow->IsShown() ? m_outputSashWindow->GetSize().y : 0;
839 GetClientSize(& cx, & cy);
841 // Calculate how much space will be left after this drag operation.
843 if (event.GetId() == ecID_MEMORY_SASH_WINDOW)
844 heightLeft = cy - outputHeight - event.GetDragRect().height;
846 heightLeft = cy - memoryLayoutHeight - event.GetDragRect().height;
848 DivideSpaceEvenly(minorWindows, wxSize(0, heightLeft), wxVERTICAL);
849 RestoreDefaultWindowSizes(minorWindows);
852 wxLayoutAlgorithm layout;
853 if (!layout.LayoutFrame(this))
855 // If layout failed, restored default sizes.
856 wxNode* node = GetChildren().First();
859 wxWindow* win = (wxWindow*) node->Data();
860 if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)))
862 wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) win;
863 wxSize sz = sashWin->GetSize();
864 sashWin->SetDefaultSize(sz);
872 void ecMainFrame::OnIdle(wxIdleEvent& event)
874 // Normal idle processing
875 wxFrame::OnIdle(event);
879 text = GetStatusBar()->GetStatusText(0);
881 // Set the title if we have no document
882 if (!wxGetApp().GetConfigToolDoc() && GetTitle() != wxGetApp().GetSettings().GetAppName())
883 SetTitle(wxGetApp().GetSettings().GetAppName());
885 if ( wxGetApp().m_pipedProcess && wxGetApp().m_pipedProcess->HasInput() )
890 if ( wxGetApp().m_pipedProcess )
892 if (text != _("Building..."))
893 SetStatusText(_("Building..."), 0);
895 else if (text != _("Ready"))
896 SetStatusText(_("Ready"), 0);
899 void ecMainFrame::OnCloseWindow(wxCloseEvent& event)
903 if (!wxGetApp().GetDocManager()->Clear(FALSE) && event.CanVeto())
908 if (wxGetApp().m_pipedProcess)
909 wxGetApp().m_pipedProcess->Detach();
912 m_findDialog->Close(TRUE);
914 wxGetApp().DestroyHelpController();
917 wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_MAXIMIZED ;
918 else if (IsIconized())
919 wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_MINIMIZED ;
921 wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_NORMAL ;
923 if (!IsMaximized() && !IsIconized())
924 wxGetApp().GetSettings().m_frameSize = GetRect();
926 wxGetApp().GetSettings().m_showToolBar = GetToolBar()->IsShown();
928 wxGetApp().GetSettings().m_treeSashSize = m_configSashWindow->GetSize();
929 wxGetApp().GetSettings().m_propertiesSashSize = m_propertiesSashWindow->GetSize();
930 wxGetApp().GetSettings().m_conflictsSashSize = m_conflictsSashWindow->GetSize();
931 wxGetApp().GetSettings().m_shortDescrSashSize = m_shortDescrSashWindow->GetSize();
932 wxGetApp().GetSettings().m_memorySashSize = m_memorySashWindow->GetSize();
933 wxGetApp().GetSettings().m_outputSashSize = m_outputSashWindow->GetSize();
934 wxGetApp().GetSettings().m_configPaneWidth = m_splitter->GetSashPosition();
939 // Enumerate the visible 'minor' sash windows,
940 // i.e. those in the top-right segment of the frame
941 void ecMainFrame::GetMinorWindows(wxList& list)
943 if (m_conflictsSashWindow->IsShown())
944 list.Append(m_conflictsSashWindow);
945 if (m_propertiesSashWindow->IsShown())
946 list.Append(m_propertiesSashWindow);
947 if (m_shortDescrSashWindow->IsShown())
948 list.Append(m_shortDescrSashWindow);
951 // Get all visible sash windows
952 void ecMainFrame::GetSashWindows(wxList& list)
954 wxNode* node = GetChildren().First();
957 wxWindow* win = (wxWindow*) node->Data();
958 if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)) && win->IsShown())
966 // Divide the given space evenly amongst some windows
967 void ecMainFrame::DivideSpaceEvenly(wxList& list, const wxSize& space, int orient)
969 if (list.Number() == 0)
972 // Find total size first
974 double proportion = 0.0;
975 wxNode* node = list.First();
978 wxWindow* win = (wxWindow*) node->Data();
979 wxSize sz = win->GetSize();
980 if (orient == wxHORIZONTAL)
986 if (orient == wxHORIZONTAL)
991 proportion = ((double) space.x / (double) totalSize);
998 proportion = ((double) space.y / (double) totalSize);
1000 node = list.First();
1003 wxWindow* win = (wxWindow*) node->Data();
1004 wxSize sz = win->GetSize();
1005 if (orient == wxHORIZONTAL)
1006 sz.x = (int) (sz.x * proportion);
1008 sz.y = (int) (sz.y * proportion);
1010 node = node->Next();
1014 // Restore the sash window default size from the actual window size
1015 void ecMainFrame::RestoreDefaultWindowSizes(wxList& list)
1017 wxNode* node = list.First();
1020 wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) node->Data();
1021 wxSize sz = sashWin->GetSize();
1022 sashWin->SetDefaultSize(sz);
1023 node = node->Next();
1027 void ecMainFrame::OnHelpEcos(wxCommandEvent& event)
1029 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1032 wxString strURL(wxT("index.html"));
1033 doc->QualifyDocURL(strURL, FALSE);
1034 switch (wxGetApp().GetSettings().m_eUseCustomBrowser)
1038 if (wxGetApp().HasHelpController())
1039 wxGetApp().GetHelpController().DisplayContents();
1044 doc->ShowURL(strURL);
1050 void ecMainFrame::OnHelpConfigtool(wxCommandEvent& event)
1052 //wxString strURL(wxT("redirect/the-ecos-configuration-tool.html"));
1053 wxString strURL(wxGetApp().GetFullAppPath(wxT("manual/user-guides.2.html")));
1054 if (!wxFileExists(strURL))
1055 strURL = wxT("user-guide/the-ecos-configuration-tool.html");
1057 if (wxGetApp().GetConfigToolDoc())
1059 wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1063 void ecMainFrame::OnHelpContext(wxCommandEvent& event)
1065 wxContextHelp contextHelp;
1068 void ecMainFrame::OnResolveConflicts(wxCommandEvent& event)
1071 ecResolveConflictsDialog dialog(this);
1074 if ( ecConfigToolDoc::NotDone == wxGetApp().GetConfigToolDoc()->ResolveGlobalConflicts() )
1076 // Global inference handler was never invoked. Say something
1078 msg.Printf(_("No solutions can be automatically determined for the current set of conflicts."));
1079 wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);
1083 void ecMainFrame::OnUpdateResolveConflicts(wxUpdateUIEvent& event)
1085 if (!wxGetApp().GetConfigToolDoc() || !wxGetApp().GetConfigToolDoc()->GetCdlInterpreter())
1087 event.Enable(FALSE);
1091 event.Enable(wxGetApp().GetConfigToolDoc()->GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0);
1094 void ecMainFrame::OnSettings(wxCommandEvent& event)
1096 ecSettingsDialog dialog(this);
1100 void ecMainFrame::OnPlatforms(wxCommandEvent& event)
1102 ecPlatformsDialog dialog(this);
1103 if (dialog.ShowModal() == wxID_OK)
1105 CeCosTestPlatform::RemoveAllPlatforms();
1107 for(i=0; i < dialog.PlatformCount();i++){
1108 CeCosTestPlatform::Add(*dialog.Platform(i));
1110 CeCosTestPlatform::Save();
1114 void ecMainFrame::OnBuildOptions(wxCommandEvent& event)
1116 ecBuildOptionsDialog dialog(this);
1120 void ecMainFrame::OnTemplates(wxCommandEvent& event)
1122 ecTemplatesDialog dialog(this);
1123 if (dialog.ShowModal() == wxID_OK)
1126 // Ensure display gets updated
1127 ::UpdateWindow((HWND) GetHWND());
1130 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1132 doc->SelectHardware(dialog.GetSelectedHardware());
1133 doc->SelectTemplate(dialog.GetSelectedTemplate(), dialog.GetSelectedTemplateVersion());
1137 void ecMainFrame::OnAdmin(wxCommandEvent& event)
1139 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1143 if (wxYES == wxMessageBox(_("This command will close the current document.\n\nDo you wish to continue?"),
1144 wxGetApp().GetAppName(), wxYES_NO, this))
1146 wxString shellCommands;
1147 // ensure that the user tools are on the path for use by ecosadmin.tcl
1148 // TODO: need to something else for Linux (since it returns settings in shellCommands)
1149 if (wxGetApp().PrepareEnvironment(FALSE, & shellCommands))
1151 // make sure we use doc data before the doc is destroyed
1153 ecAdminDialog dlg(this, doc->GetPackagesDir(), wxGetApp().GetSettings().GetUserToolsDir());
1155 if (dlg.ShowModal() == wxID_OK)
1157 // Create new document
1158 wxGetApp().GetDocManager()->CreateDocument(wxEmptyString, wxDOC_NEW);
1164 void ecMainFrame::OnPackages(wxCommandEvent& event)
1166 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1168 doc->SelectPackages();
1171 void ecMainFrame::OnRunTests(wxCommandEvent& event)
1173 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1178 void ecMainFrame::OnChooseRepository(wxCommandEvent& event)
1180 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1181 if (doc && !doc->OnSaveModified())
1186 doc = (ecConfigToolDoc*) wxGetApp().GetDocManager()->CreateDocument(wxString(""), wxDOC_NEW|ecDOC_PROMPT_FOR_REPOSITORY);
1191 doc->m_bRepositoryOpen = FALSE;
1193 if (wxGetApp().GetConfigToolDoc()->OpenRepository(wxEmptyString, TRUE))
1197 // reset the document title as shown in the frame window
1198 GetDocTemplate ()->SetDefaultTitle (this);
1200 // load the memory layout for the default target-platform-startup from the new repository
1201 NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf")));
1204 doc->UpdateAllViews(NULL);
1205 doc->UpdateFailingRuleCount();
1210 doc->m_bRepositoryOpen = TRUE;
1214 void ecMainFrame::OnBuildToolsPath(wxCommandEvent& event)
1216 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1220 // Add all the paths from the bin dirs to the path array,
1221 // making the default path the appropriate target prefix
1222 wxString defaultPath;
1223 const wxString strPrefix(doc->GetCurrentTargetPrefix());
1224 wxArrayString arstrPaths;
1226 wxStringToStringMap& map = wxGetApp().GetSettings().GetBinDirs();
1228 wxString key, value;
1229 bool hasDefaultDir = FALSE;
1230 while (map.Next(key, value))
1232 arstrPaths.Add(value);
1233 if (key == strPrefix)
1234 defaultPath = value;
1235 if (value == wxGetApp().GetSettings().m_buildToolsDir)
1236 hasDefaultDir = TRUE;
1238 if (!wxGetApp().GetSettings().m_buildToolsDir.IsEmpty() && !hasDefaultDir)
1240 arstrPaths.Add(wxGetApp().GetSettings().m_buildToolsDir);
1244 msg.Printf(_("Enter the location of the %s build tools\n"
1245 "folder, which should contain %sgcc. You can\n"
1246 "type in a path or use the Browse button to\n"
1247 "navigate to a folder."),
1248 (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("native")) : strPrefix),
1249 (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("")) : strPrefix + wxT("-"))
1251 wxString caption(_("Build Tools Path"));
1253 ecFolderDialog dialog(defaultPath, arstrPaths, msg, this, ecID_BUILD_TOOLS_DIALOG, caption);
1254 if (dialog.ShowModal() == wxID_OK)
1259 wxString exeSuffix(wxT(".exe"));
1261 wxString exeSuffix(wxEmptyString);
1263 wxString path(dialog.GetPath());
1264 strExe.Printf(wxT("%s%c%s%sgcc%s"), (const wxChar*) path, wxFILE_SEP_PATH, (const wxChar*) strPrefix,
1265 (const wxChar*) strPrefix.IsEmpty() ? wxT("") : wxT("-"), (const wxChar*) exeSuffix);
1268 msg.Printf(wxT("%s does not appear to contain the build tools - use this folder anyway?"), (const wxChar*) path);
1270 if(strExe.Exists() ||
1271 (wxID_YES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO)))
1273 map.Set(strPrefix, path);
1275 wxGetApp().GetSettings().m_buildToolsDir = path;
1280 void ecMainFrame::OnUserToolsPath(wxCommandEvent& event)
1282 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1286 wxArrayString paths = wxGetApp().GetSettings().m_userToolPaths;
1287 if (!wxGetApp().GetSettings().m_userToolsDir.IsEmpty())
1288 paths.Add(wxGetApp().GetSettings().m_userToolsDir);
1290 wxString msg(_("Enter the location of the user tools folder,\n"
1291 "which should contain cat and ls. You can type in\n"
1292 "a path or use the Browse button to navigate to a\n"
1295 wxString caption(_("User Tools Path"));
1296 wxString defaultPath(wxGetApp().GetSettings().m_userToolsDir);
1298 ecFolderDialog dialog(defaultPath, paths, msg, this, ecID_USER_TOOLS_DIALOG, caption);
1299 if (dialog.ShowModal() == wxID_OK)
1301 wxString path(dialog.GetPath());
1302 ecFileName strFile(path);
1305 wxString exeSuffix(wxT(".exe"));
1307 wxString exeSuffix(wxEmptyString);
1309 wxString prog(wxString(wxT("ls")) + exeSuffix);
1311 strFile += (const wxChar*) prog;
1314 msg.Printf(wxT("%s does not appear to contain the user tools - use this folder anyway?"), (const wxChar*) path);
1316 if(strFile.Exists() ||
1317 (wxID_YES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO)))
1319 wxGetApp().GetSettings().m_userToolsDir = path;
1324 // Process events for the window with the focus first.
1325 bool ecMainFrame::ProcessEvent(wxEvent& event)
1327 static wxEvent* s_lastEvent = NULL;
1329 if (& event == s_lastEvent)
1332 if (event.IsCommandEvent())
1334 s_lastEvent = & event;
1336 wxWindow* focusWin = wxFindFocusDescendant(this);
1337 bool success = FALSE;
1340 //long windowId = focusWin->GetId();
1341 //wxLogDebug("Found focus window %d", windowId);
1342 success = focusWin->GetEventHandler()->ProcessEvent(event);
1345 success = wxDocParentFrame::ProcessEvent(event);
1352 return wxDocParentFrame::ProcessEvent(event);
1356 void ecMainFrame::SetFailRulePane(int nCount)
1362 strCount = wxT("No conflicts");
1365 strCount = wxT("1 conflict");
1368 strCount.Printf (_("%d conflicts"), nCount);
1373 GetStatusBar()->SetStatusText(strCount, ecFailRulePane);
1377 // Update the title, either via the document's view or explicitly if no doc
1378 void ecMainFrame::UpdateFrameTitle()
1380 if (wxGetApp().GetConfigToolDoc())
1381 wxGetApp().GetConfigToolDoc()->GetFirstView()->OnChangeFilename();
1383 SetTitle(wxGetApp().GetSettings().GetAppName());
1386 void ecMainFrame::OnUpdatePlatforms(wxUpdateUIEvent& event)
1391 void ecMainFrame::OnUpdateBuildOptions(wxUpdateUIEvent& event)
1393 event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1396 void ecMainFrame::OnUpdateBuildToolsPath(wxUpdateUIEvent& event)
1398 event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1401 void ecMainFrame::OnUpdateUserToolsPath(wxUpdateUIEvent& event)
1403 event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1406 void ecMainFrame::OnUpdateTemplates(wxUpdateUIEvent& event)
1408 event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1411 void ecMainFrame::OnUpdateAdmin(wxUpdateUIEvent& event)
1413 event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1416 void ecMainFrame::OnUpdatePackages(wxUpdateUIEvent& event)
1418 event.Enable(wxGetApp().GetConfigToolDoc() != NULL);
1421 void ecMainFrame::OnUpdateRunTests(wxUpdateUIEvent& event)
1423 event.Enable(wxGetApp().GetConfigToolDoc() != NULL && !wxGetApp().GetConfigToolDoc()->GetInstallTree().IsEmpty() && (wxGetApp().m_pipedProcess == NULL));
1426 void ecMainFrame::OnUpdateChooseRepository(wxUpdateUIEvent& event)
1431 void ecMainFrame::OnWhatsThis(wxCommandEvent& event)
1433 wxGetApp().OnWhatsThis(event);
1436 void ecMainFrame::OnSaveOutput(wxCommandEvent& event)
1438 ecOutputWindow* win = GetOutputWindow();
1442 wxFileDialog dialog(this, _("Choose a file for saving the output window contents"),
1443 wxT(""), wxT("output.txt"), wxT("*.txt"), wxSAVE|wxOVERWRITE_PROMPT);
1444 if (dialog.ShowModal() == wxID_OK)
1446 if (!win->SaveFile(dialog.GetPath()))
1448 wxMessageBox(_("Sorry, there was a problem saving the file."), wxGetApp().GetSettings().GetAppName(),
1449 wxICON_EXCLAMATION|wxID_OK);
1454 void ecMainFrame::OnUpdateSelectAll(wxUpdateUIEvent& event)
1456 wxWindow* win = wxWindow::FindFocus();
1457 event.Enable (win && win->IsKindOf(CLASSINFO(wxTextCtrl)) );
1460 void ecMainFrame::OnUpdateClear(wxUpdateUIEvent& event)
1462 wxWindow* win = wxWindow::FindFocus();
1463 event.Enable (win && win->IsKindOf(CLASSINFO(wxTextCtrl)) );
1466 void ecMainFrame::OnImport(wxCommandEvent& event)
1468 if (wxGetApp().GetConfigToolDoc())
1470 wxGetApp().GetConfigToolDoc()->ImportFile();
1474 void ecMainFrame::OnExport(wxCommandEvent& event)
1476 if (wxGetApp().GetConfigToolDoc())
1478 wxGetApp().GetConfigToolDoc()->ExportFile();
1482 void ecMainFrame::OnUpdateImport(wxUpdateUIEvent& event)
1484 event.Enable ( wxGetApp().GetConfigToolDoc() != NULL );
1487 void ecMainFrame::OnUpdateExport(wxUpdateUIEvent& event)
1489 event.Enable ( wxGetApp().GetConfigToolDoc() != NULL );
1492 void ecMainFrame::OnWebRedHatHome(wxCommandEvent& event)
1494 wxString strURL(wxT("http://www.redhat.com"));
1495 if (wxGetApp().GetConfigToolDoc())
1496 wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1499 void ecMainFrame::OnWebEcos(wxCommandEvent& event)
1501 wxString strURL(wxT("http://www.redhat.com/products/ecos"));
1502 if (wxGetApp().GetConfigToolDoc())
1503 wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1506 void ecMainFrame::OnWebNetRelease(wxCommandEvent& event)
1508 wxString strURL(wxT("http://sources.redhat.com/ecos"));
1509 if (wxGetApp().GetConfigToolDoc())
1510 wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1513 void ecMainFrame::OnWebUitron(wxCommandEvent& event)
1515 wxString strURL(wxT("http://www.itron.gr.jp/"));
1516 if (wxGetApp().GetConfigToolDoc())
1517 wxGetApp().GetConfigToolDoc()->ShowURL(strURL);
1520 void ecMainFrame::OnBuildLibrary(wxCommandEvent& event)
1522 // TODO: possibly add wxT("clean build") to ensure library is
1523 // cleanly built. No, can't do that because it would clean
1524 // out any user code too :-(
1526 bool regenerateBuildTree = FALSE;
1528 if (wxGetApp().GetSettings().m_editSaveFileOnly)
1530 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);
1534 regenerateBuildTree = TRUE;
1536 else if (ans == wxCANCEL)
1540 if (regenerateBuildTree)
1542 ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
1546 if (!pDoc->GenerateBuildTree())
1553 void ecMainFrame::OnBuildTests(wxCommandEvent& event)
1555 bool regenerateBuildTree = FALSE;
1557 if (wxGetApp().GetSettings().m_editSaveFileOnly)
1559 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);
1563 regenerateBuildTree = TRUE;
1565 else if (ans == wxCANCEL)
1569 if (regenerateBuildTree)
1571 ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
1575 if (!pDoc->GenerateBuildTree())
1579 wxGetApp().Build(wxT("tests"));
1582 void ecMainFrame::OnStopBuild(wxCommandEvent& event)
1584 if (wxGetApp().m_pipedProcess)
1586 long pid = wxGetApp().m_pipedProcess->GetPid();
1587 wxGetApp().m_pipedProcess->Detach();
1589 wxProcessKiller pKiller(pid);
1594 void ecMainFrame::OnClean(wxCommandEvent& event)
1596 wxGetApp().Build(wxT("clean"));
1599 void ecMainFrame::OnShell(wxCommandEvent& event)
1601 ecConfigToolDoc *pDoc=wxGetApp().GetConfigToolDoc();
1605 wxString variableSettings;
1606 if (wxGetApp().PrepareEnvironment(TRUE, & variableSettings))
1609 wxString currentDir = wxGetCwd();
1610 wxSetWorkingDirectory(pDoc->GetBuildTree());
1612 wxExecute("bash.exe");
1614 if (!currentDir.IsEmpty()) // if the current directory was changed
1616 wxSetWorkingDirectory(currentDir); // restore the previous current directory
1619 wxString cmdLine = wxString(wxT("xterm"));
1621 // TODO: query an appropriate variable, and/or have a setting for this
1627 void ecMainFrame::OnUpdateBuildLibrary(wxUpdateUIEvent& event)
1629 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess == NULL ));
1632 void ecMainFrame::OnUpdateBuildTests(wxUpdateUIEvent& event)
1634 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess == NULL ));
1637 void ecMainFrame::OnUpdateStopBuild(wxUpdateUIEvent& event)
1639 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess != NULL ));
1642 void ecMainFrame::OnUpdateClean(wxUpdateUIEvent& event)
1644 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && (wxGetApp().m_pipedProcess == NULL ));
1647 void ecMainFrame::OnRepositoryInfo(wxCommandEvent& event)
1649 ecRepositoryInfoDialog dialog(this, ecID_REPOSITORY_INFO, _("Repository Information"));
1653 void ecMainFrame::OnUpdateShell(wxUpdateUIEvent& event)
1655 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) );
1658 void ecMainFrame::OnUpdateRepositoryInfo(wxUpdateUIEvent& event)
1660 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) );
1663 void ecMainFrame::OnNewRegion(wxCommandEvent& event)
1669 void ecMainFrame::OnNewSection(wxCommandEvent& event)
1675 void ecMainFrame::OnDeleteRegionOrSection(wxCommandEvent& event)
1681 void ecMainFrame::OnRegionOrSectionProperties(wxCommandEvent& event)
1687 void ecMainFrame::OnUpdateNewRegion(wxUpdateUIEvent& event)
1691 event.Enable( FALSE );
1695 void ecMainFrame::OnUpdateNewSection(wxUpdateUIEvent& event)
1699 event.Enable( FALSE );
1703 void ecMainFrame::OnUpdateDeleteRegionOrSection(wxUpdateUIEvent& event)
1707 event.Enable( FALSE );
1711 void ecMainFrame::OnUpdateRegionOrSectionProperties(wxUpdateUIEvent& event)
1715 event.Enable( FALSE );
1719 void ecMainFrame::OnIndexDocs(wxCommandEvent& event)
1721 ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
1724 doc->RebuildHelpIndex(TRUE) ;
1728 void ecMainFrame::OnUpdateIndexDocs(wxUpdateUIEvent& event)
1730 event.Enable( wxGetApp().GetConfigToolDoc() != NULL );
1733 void ecMainFrame::OnGenerateBuildTree(wxCommandEvent& event)
1735 if (wxGetApp().GetConfigToolDoc() && wxGetApp().GetConfigToolDoc()->CanGenerateBuildTree())
1737 if (!wxGetApp().GetConfigToolDoc()->GenerateBuildTree())
1739 // Error probably already reported
1744 void ecMainFrame::OnUpdateGenerateBuildTree(wxUpdateUIEvent& event)
1746 event.Enable( (wxGetApp().GetConfigToolDoc() != NULL) && wxGetApp().GetConfigToolDoc()->CanGenerateBuildTree());