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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [win32/] [MainFrm.cpp] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//                                                                          
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it 
9
// under the terms of the GNU General Public License as published by the Free 
10
// Software Foundation; either version 2 of the License, or (at your option) 
11
// any later version.
12
// 
13
// This program is distributed in the hope that it will be useful, but WITHOUT 
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16
// more details.
17
// 
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc., 
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//                                                                          
24
//####COPYRIGHTEND####
25
// MainFrm.cpp : implementation of the CMainFrame class:
26
//
27
//===========================================================================
28
//#####DESCRIPTIONBEGIN####
29
//
30
// Author(s):   sdf
31
// Contact(s):  sdf
32
// Date:                1998/08/11
33
// Version:             0.01
34
// Purpose:     
35
// Description: This is the implementation of the main frame class
36
// Requires:    
37
// Provides:    
38
// See also:    
39
// Known bugs:  
40
// Usage:       
41
//
42
//####DESCRIPTIONEND####
43
//
44
//===========================================================================
45
 
46
#include "stdafx.h"
47
 
48
#define WM_SUBPROCESS (WM_USER+42)
49
 
50
#include "BinDirDialog.h"
51
#include "BuildOptionsDialog.h"
52
#include "CTOptionsDialog.h"
53
#include "CTUtils.h"
54
#include "CellView.h"
55
#include "ConfigItem.h"
56
#include "ConfigTool.h"
57
#include "ConfigToolDoc.h"
58
#include "ControlView.h"
59
#include "DescView.h"
60
#include "FindDialog.h"
61
#include "FolderDialog.h"
62
#include "MLTFrame.h"
63
#include "MainFrm.h"
64
#include "MessageBox.h"
65
#include "PlatformsDialog.h"
66
#include "NotePage.h"
67
#include "OutputView.h"
68
#include "PropertiesView.h"
69
#include "RegionGeneralPage.h"
70
#include "RulesView.h"
71
#include "SectionGeneralPage.h"
72
#include "SectionRelocationPage.h"
73
#include "Splash.h"
74
#include "SplitterWndEx.h"
75
#include "Subprocess.h"
76
#include "TestResource.h"
77
#include "ThinSplitter.h"
78
#include "ViewOptions.h"
79
 
80
#define INCLUDEFILE "build.hxx"
81
#include "IncludeSTL.h"
82
 
83
#include <afxpriv.h>
84
#include <htmlhelp.h>
85
#include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
86
 
87
#ifdef _DEBUG
88
#define new DEBUG_NEW
89
#undef THIS_FILE
90
static char THIS_FILE[] = __FILE__;
91
#endif
92
 
93
 
94
/////////////////////////////////////////////////////////////////////////////
95
// CMainFrame
96
 
97
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
98
//UINT WM_FINDREPLACE = RegisterWindowMessage(FINDMSGSTRING);
99
 
100
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
101
  //{{AFX_MSG_MAP(CMainFrame)
102
  ON_WM_CREATE()
103
  ON_COMMAND(ID_VIEW_PROPERTIES, OnViewProperties)
104
  ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTIES, OnUpdateViewProperties)
105
  ON_COMMAND(ID_VIEW_MLT, OnViewMLT)
106
  ON_COMMAND(ID_VIEW_SHORTDESC, OnViewShortdesc)
107
  ON_UPDATE_COMMAND_UI(ID_VIEW_SHORTDESC, OnUpdateViewShortdesc)
108
  ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput)
109
  ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput)
110
  ON_UPDATE_COMMAND_UI(ID_BUILD_CONFIGURE, OnUpdateBuildConfigure)
111
  ON_COMMAND(ID_BUILD_STOP, OnBuildStop)
112
  ON_UPDATE_COMMAND_UI(ID_BUILD_STOP, OnUpdateBuildStop)
113
  ON_COMMAND(ID_BUILD_CONFIGURE, OnConfigurationBuild)
114
  ON_WM_DESTROY()
115
  ON_COMMAND(ID_BUILD_TESTS, OnBuildTests)
116
  ON_UPDATE_COMMAND_UI(ID_BUILD_TESTS, OnUpdateBuildTests)
117
  ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
118
  ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnUpdateFileSaveAs)
119
  ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen)
120
  ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew)
121
  ON_UPDATE_COMMAND_UI(ID_APP_EXIT, OnUpdateAppExit)
122
  ON_UPDATE_COMMAND_UI(ID_VIEW_MLT, OnUpdateViewMLT)
123
  ON_WM_SYSCOMMAND()
124
  ON_UPDATE_COMMAND_UI(ID_CONFIGURATION_REFRESH, OnUpdateConfigurationRefresh)
125
  ON_COMMAND(ID_CONFIGURATION_REFRESH, OnConfigurationRefresh)
126
  ON_COMMAND(ID_MENU_VIEW_SETTINGS, OnViewSettings)
127
  ON_COMMAND(ID_TOOLS_PATHS, OnToolsPaths)
128
  ON_WM_SIZE()
129
  ON_UPDATE_COMMAND_UI(ID_CONFIGURATION_REPOSITORY, OnUpdateConfigurationRepository)
130
  ON_COMMAND(ID_WINDOW_NEXT, OnWindowNext)
131
  ON_COMMAND(ID_WINDOW_PREV, OnWindowPrev)
132
  ON_COMMAND(ID_HELP_SUBMIT_PR, OnHelpSubmitPr)
133
  ON_COMMAND(ID_HELP_ECOS, OnHelpEcos)
134
  ON_COMMAND(ID_HELP_RED_HATONTHEWEB, OnHelpRedHatHome)
135
  ON_COMMAND(ID_HELP_UITRON, OnHelpUitron)
136
  ON_COMMAND(ID_HELP_ECOSHOME, OnHelpEcoshome)
137
  ON_COMMAND(ID_RUN_SIM, OnRunSim)
138
  ON_COMMAND(ID_BUILD_CLEAN, OnBuildClean)
139
  ON_UPDATE_COMMAND_UI(ID_BUILD_CLEAN, OnUpdateBuildClean)
140
  ON_COMMAND(ID_TOOLS_SHELL, OnToolsShell)
141
  ON_WM_CLOSE()
142
  ON_COMMAND(ID_BUILD_OPTIONS, OnBuildOptions)
143
  ON_COMMAND(ID_TOOLS_OPTIONS, OnToolsOptions)
144
  ON_COMMAND(ID_USERTOOLS_PATHS, OnUsertoolsPaths)
145
  ON_MESSAGE(WM_SETMESSAGESTRING, OnSetMessageString)
146
  ON_UPDATE_COMMAND_UI(ID_RUN_SIM, OnUpdateRunSim)
147
  ON_COMMAND(ID_VIEW_CONFLICTS, OnViewConflicts)
148
  ON_UPDATE_COMMAND_UI(ID_VIEW_CONFLICTS, OnUpdateViewConflicts)
149
  ON_COMMAND(ID_VIEW_MLTBAR, OnViewMltbar)
150
  ON_UPDATE_COMMAND_UI(ID_VIEW_MLTBAR, OnUpdateViewMltbar)
151
  ON_COMMAND(ID_RESOLVE_CONFLICTS, OnResolveConflicts)
152
  ON_UPDATE_COMMAND_UI(ID_RESOLVE_CONFLICTS, OnUpdateResolveConflicts)
153
  ON_COMMAND(ID_GO_HOME, OnGoHome)
154
  ON_WM_MEASUREITEM()
155
  ON_WM_INITMENUPOPUP()
156
  ON_UPDATE_COMMAND_UI(ID_BUILD_OPTIONS, OnUpdateBuildOptions)
157
  ON_MESSAGE(WM_SUBPROCESS,OnSubprocess)
158
        ON_UPDATE_COMMAND_UI(ID_TOOLS_ADMINISTRATION, OnUpdateToolsAdministration)
159
        ON_WM_HELPINFO()
160
        ON_COMMAND(ID_EDIT_PLATFORMS, OnEditPlatforms)
161
  ON_WM_MENUCHAR()
162
  ON_COMMAND(ID_HELP, OnHelp)
163
        ON_WM_TIMER()
164
        //}}AFX_MSG_MAP
165
  ON_NOTIFY(HHN_NAVCOMPLETE,  ID_HHNOTIFICATION, OnNavComplete)
166
  ON_NOTIFY(HHN_TRACK,        ID_HHNOTIFICATION, OnNavComplete)
167
  ON_NOTIFY(HHN_WINDOW_CREATE,ID_HHNOTIFICATION, OnNavComplete)
168
END_MESSAGE_MAP()
169
 
170
UINT CMainFrame::indicators[] =
171
{
172
  ID_SEPARATOR,           // status line indicator
173
    ID_THERMOMETER,
174
    ID_SEPARATOR,           // status line indicator
175
    ID_SEPARATOR
176
};
177
 
178
bool CMainFrame::m_arMounted[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
179
 
180
/////////////////////////////////////////////////////////////////////////////
181
// CMainFrame construction/destruction
182
 
183
CMainFrame::CMainFrame():
184
  m_pFindReplaceDialog(NULL),
185
    m_strIdleMessage(),
186
    m_nThermometerMax(0),
187
    m_bFindInProgress(false),
188
    m_bStatusBarCreated(false)
189
{
190
}
191
 
192
CMainFrame::~CMainFrame()
193
{
194
}
195
 
196
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
197
{
198
  DragAcceptFiles();
199
 
200
  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
201
    return -1;
202
 
203
  if (!m_wndToolBar.Create(this,WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,AFX_IDW_TOOLBAR) ||
204
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
205
  {
206
    TRACE0("Failed to create toolbar\n");
207
    return -1;      // fail to create
208
  }
209
 
210
  if (!m_wndMLTToolBar.Create(this,WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,AFX_IDW_TOOLBAR+1) ||
211
    !m_wndMLTToolBar.LoadToolBar(IDR_MLTBAR))
212
  {
213
    TRACE0("Failed to create MLT toolbar\n");
214
    return -1;      // fail to create
215
  }
216
  m_bMLTToolbarVisible=true;
217
 
218
  if (!m_wndStatusBar.Create(this) ||
219
    !m_wndStatusBar.SetIndicators(indicators,
220
    sizeof(indicators)/sizeof(UINT)))
221
  {
222
    TRACE0("Failed to create status bar\n");
223
    return -1;      // fail to create
224
  }
225
  m_bStatusBarCreated=true;
226
  CDC *pDC=GetDC();
227
  CFont *pOldFont=pDC->SelectObject(m_wndStatusBar.GetFont());
228
  m_nThermometerPaneSize=100;
229
  m_nPercentagePaneSize=pDC->GetTextExtent(_T("100%")).cx;
230
  m_nFailRulePaneSize=pDC->GetTextExtent(_T("333 conflicts")).cx;
231
  pDC->SelectObject(pOldFont);
232
  ReleaseDC(pDC);
233
 
234
  CRect rect;
235
  m_wndStatusBar.GetItemRect(ThermometerPane, rect);
236
 
237
  m_Progress.Create(WS_VISIBLE|WS_CHILD|PBS_SMOOTH, rect,&m_wndStatusBar, ID_THERMOMETER);
238
  m_Progress.SetRange(0,100);
239
  m_Progress.SetPos(0);
240
 
241
  //CConfigTool::GetConfigToolDoc()->UpdateFailingRuleCount();
242
  // TODO: Delete these three lines if you don't want the toolbar to
243
  //  be dockable
244
  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
245
  m_wndMLTToolBar.EnableDocking(CBRS_ALIGN_ANY);
246
 
247
  EnableDocking(CBRS_ALIGN_ANY);
248
  DockControlBar(&m_wndToolBar);
249
  DockControlBar(&m_wndMLTToolBar);
250
 
251
  CSplashWnd::ShowSplashScreen(this);
252
 
253
  return 0;
254
}
255
 
256
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
257
{
258
  //cs.style|=~FWS_ADDTOTITLE;
259
  return CFrameWnd::PreCreateWindow(cs);
260
}
261
 
262
/////////////////////////////////////////////////////////////////////////////
263
// CMainFrame diagnostics
264
 
265
#ifdef _DEBUG
266
void CMainFrame::AssertValid() const
267
{
268
  CFrameWnd::AssertValid();
269
}
270
 
271
void CMainFrame::Dump(CDumpContext& dc) const
272
{
273
  CFrameWnd::Dump(dc);
274
}
275
 
276
#endif //_DEBUG
277
 
278
/////////////////////////////////////////////////////////////////////////////
279
// CMainFrame message handlers
280
CMainFrame::ViewStruct CMainFrame::arView[PaneTypeMax]={
281
  CMainFrame::ViewStruct(_T("Cell"),              true,RUNTIME_CLASS(CCellView)),
282
  CMainFrame::ViewStruct(_T("Configuration"),     true,RUNTIME_CLASS(CControlView)),
283
  CMainFrame::ViewStruct(_T("Short Description"), true,RUNTIME_CLASS(CDescView)),
284
  CMainFrame::ViewStruct(_T("Output"),            true,RUNTIME_CLASS(COutputView)),
285
  CMainFrame::ViewStruct(_T("Properties"),        true,RUNTIME_CLASS(CPropertiesView)),
286
  CMainFrame::ViewStruct(_T("Rules"),             false,RUNTIME_CLASS(CRulesView)),
287
  CMainFrame::ViewStruct(_T("Memory Layout"),     false,RUNTIME_CLASS(CMLTView))
288
};
289
 
290
// This data defines the layout of the nested splitters
291
CMainFrame::Split CMainFrame::arSplit[]={
292
  CMainFrame::Split(Horz,1,0.8),
293
    CMainFrame::Split(Horz,2,0.7),
294
      CMainFrame::Split(Vert,3,0.5),
295
        CMainFrame::Split(Thin,4,0.4),
296
          CMainFrame::Split(Control,5),
297
          CMainFrame::Split(Cell,5),
298
        CMainFrame::Split(Horz,4,0.6),
299
          CMainFrame::Split(Rules,5),
300
          CMainFrame::Split(Horz,5,0.5),
301
            CMainFrame::Split(Properties,6),
302
            CMainFrame::Split(ShortDesc,6),
303
      CMainFrame::Split(MLT,3),
304
    CMainFrame::Split(Output,2)
305
};
306
 
307
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
308
{
309
  for(int i=0;i<sizeof arView/sizeof arView[0];i++){
310
    ViewStruct &v=arView[(PaneType)i];
311
    v.bVisible=GetApp()->GetProfileInt(_T("Windows"),v.pszName,v.bVisible);
312
  }
313
  CRect rcClient;
314
  GetClientRect(rcClient);
315
 
316
  BOOL rc=TRUE;
317
 
318
  //    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
319
  //    x         |         |                           x
320
  //    x Tree (T)| Cell(T) |                           x
321
  //    x ^^^^^^^^^^^^^^^^^^|           Rules (2)       x
322
  //    x         1         |                           x
323
  //    x         |         |---------------------------x
324
  //    x         |         |                           x
325
  //    x         |         |           Properties (2)  x
326
  //    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
327
  //    x           MLT                                 x
328
  //    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
329
  //    x                                               x
330
  //    x           Output (0)                          x
331
  //    x                                               x
332
  //    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
333
 
334
  for(i=0;i<sizeof arSplit/sizeof arSplit[0];i++){
335
    const CSize szDefault(50,50);
336
    Split &s=arSplit[i];
337
    CSplitterWndEx *pParent=NULL;
338
    bool bSecond=false;
339
    int nRowParent=0;
340
    int nColParent=0;
341
    // Search backwards for our parent.  This is the first entry back of level one higher.
342
    for(int j=i-1;j>=0;--j){
343
      Split &sp=arSplit[j];
344
      if(sp.nLevel==s.nLevel-1){
345
        pParent=sp.pSplit;
346
        nRowParent=(bSecond && Horz==sp.type);
347
        nColParent=(bSecond && Horz!=sp.type);
348
        break;
349
      } else if(sp.nLevel==s.nLevel){
350
        bSecond=true;
351
      }
352
    }
353
    if(s.type>=0 /* a view */){
354
      TRACE(_T("Create view index=%d [%s]\n"),i,arView[s.type].pszName);
355
      VERIFY(pParent->CreateView (nRowParent, nColParent, arView[s.type].pClass, szDefault, pContext));
356
      arView[s.type].pView=(CView *)pParent->GetPane(nRowParent,nColParent);
357
      arView[s.type].pParent=pParent;
358
    } else {
359
      int nRows=1+(Horz==s.type);
360
      int nCols=1+(Horz!=s.type);
361
      UINT id;
362
      CWnd *pwndParent;
363
      if(NULL==pParent){
364
        pwndParent=this;
365
        id=AFX_IDW_PANE_FIRST;
366
      } else {
367
        id=pParent->IdFromRowCol(nRowParent,nColParent);
368
        pwndParent=pParent;
369
      }
370
      if(Thin==s.type){
371
        TRACE(_T("Create thin splitter index=%d\n"),i);
372
        s.pSplit=new CThinSplitter;
373
        VERIFY(s.pSplit->CreateStatic (pParent, 1, 2, WS_CHILD|WS_VISIBLE|WS_BORDER, id));
374
        s.pSplit->SetScrollStyle(WS_VSCROLL);
375
      } else {
376
        TRACE(_T("Create splitter index=%d\n"),i);
377
        s.pSplit=new CSplitterWndEx;
378
        VERIFY(s.pSplit->CreateStatic (pwndParent, nRows, nCols, WS_CHILD|WS_VISIBLE|WS_BORDER, id));
379
      }
380
    }
381
  };
382
 
383
  for(i=0;i<PaneTypeMax;i++){
384
    LOGFONT lf;
385
    ViewStruct &v=arView[(PaneType)i];
386
    GetApp()->LoadFont(v.pszName,lf);
387
    if(!arView[(PaneType)i].font.CreateFontIndirect(&lf)){
388
      CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT))->GetLogFont(&lf);
389
    }
390
    SetPaneFont((PaneType)i,lf);
391
    //v.pParent->ShowPane(v.pView,v.bVisible);
392
  }
393
 
394
  for(i=0;i<sizeof arSplit/sizeof arSplit[0];i++){
395
    Split &s=arSplit[i];
396
    if(s.pSplit){
397
      s.pSplit->RecalcLayout();
398
    }
399
  }
400
 
401
  UNUSED_ALWAYS(lpcs); // avoid compiler warning
402
  return rc;
403
}
404
 
405
void CMainFrame::OnViewProperties()
406
{
407
  arView[Properties].bVisible^=1;
408
  arView[Properties].pParent->ShowPane(arView[Properties].pView,arView[Properties].bVisible);
409
}
410
 
411
void CMainFrame::OnUpdateViewProperties(CCmdUI* pCmdUI)
412
{
413
  pCmdUI->SetCheck(arView[Properties].bVisible);
414
}
415
 
416
void CMainFrame::OnViewMLT()
417
{
418
  arView[MLT].bVisible^=1;
419
  arView[MLT].pParent->ShowPane(arView[MLT].pView,arView[MLT].bVisible);
420
  ShowControlBar(&m_wndMLTToolBar,arView[MLT].bVisible&m_bMLTToolbarVisible,false);
421
}
422
 
423
void CMainFrame::OnViewShortdesc()
424
{
425
  arView[ShortDesc].bVisible^=1;
426
  arView[ShortDesc].pParent->ShowPane(arView[ShortDesc].pView,arView[ShortDesc].bVisible);
427
}
428
 
429
void CMainFrame::OnUpdateViewShortdesc(CCmdUI* pCmdUI)
430
{
431
  pCmdUI->SetCheck(arView[ShortDesc].bVisible);
432
}
433
 
434
void CMainFrame::OnViewOutput()
435
{
436
  arView[Output].bVisible^=1;
437
  arView[Output].pParent->ShowPane(arView[Output].pView,arView[Output].bVisible);
438
}
439
 
440
void CMainFrame::OnUpdateViewOutput(CCmdUI* pCmdUI)
441
{
442
  pCmdUI->SetCheck(arView[Output].bVisible);
443
}
444
 
445
void CMainFrame::OnUpdateBuildConfigure(CCmdUI* pCmdUI)
446
{
447
  pCmdUI->Enable(!m_sp.ProcessAlive());
448
}
449
 
450
void CMainFrame::OnBuildStop()
451
{
452
  m_sp.Kill(); // leave the rest to OnSubprocessComplete()
453
}
454
 
455
void CMainFrame::OnUpdateBuildStop(CCmdUI* pCmdUI)
456
{
457
  pCmdUI->Enable(m_sp.ProcessAlive());
458
}
459
 
460
void CMainFrame::OnConfigurationBuild()
461
{
462
  Build();
463
}
464
 
465
DWORD CMainFrame::ThreadFunc(LPVOID param)
466
{
467
  CMainFrame *pMain=(CMainFrame *)param;
468
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
469
  CString strCmd(_T("make -n "));
470
  strCmd+=pMain->m_strBuildTarget;
471
  SetCurrentDirectory(pDoc->BuildTree());
472
  String strOut;
473
  CSubprocess sp;
474
  sp.Run(strOut,strCmd);
475
  // Don't attempt to change the thermometer itself - not safe from a separate thread
476
  pMain->m_nThermometerMax=pDoc->GetCompilationCount(strOut);
477
 
478
  return 0;
479
}
480
 
481
void CMainFrame::Build(const CString &strWhat/*=_T("")*/)
482
{
483
  ASSERT(!m_sp.ProcessAlive());
484
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
485
 
486
  if(!arView[Output].bVisible){
487
    SendMessage(WM_COMMAND,ID_VIEW_OUTPUT,0);
488
  }
489
 
490
  if(pDoc->IsModified()||pDoc->BuildTree().IsEmpty()){
491
    SendMessage (WM_COMMAND, ID_FILE_SAVE);
492
  }
493
 
494
  if(!(pDoc->IsModified()||pDoc->BuildTree().IsEmpty())){ // verify the save worked
495
    CString strCmd (_T("make"));
496
    if(!strWhat.IsEmpty()){
497
      strCmd+=_TCHAR(' ');
498
      strCmd+=strWhat;
499
    }
500
    if(!GetApp()->m_strMakeOptions.IsEmpty()){
501
      strCmd+=_TCHAR(' ');
502
      strCmd+=GetApp()->m_strMakeOptions;
503
    }
504
 
505
    strCmd += _T(" --directory ");
506
 
507
    // Quoting the name may not mix with the 'sh' command on Unix, so only do it
508
    // under Windows where it's more likely there will be spaces needing quoting.
509
#ifdef _WINDOWS
510
    CString buildDir(pDoc->BuildTree());
511
 
512
#if 1 // ecUSE_ECOS_X_NOTATION
513
    std::string cPath = cygpath(std::string(pDoc->BuildTree()));
514
    buildDir = cPath.c_str();
515
#endif
516
    strCmd += CString(_T("\"")) + buildDir + CString(_T("\""));
517
#else
518
    strCmd += CString(pDoc->BuildTree()) ;
519
#endif
520
 
521
    if(PrepareEnvironment()){
522
      m_strBuildTarget=strWhat;
523
      SetThermometerMax(250); // This is just a guess.  The thread we are about to spawn will work out the correct answer
524
      m_nLogicalLines=0;
525
      UpdateThermometer(0);
526
      CloseHandle(CreateThread(NULL, 0, ThreadFunc, this, 0 ,&m_dwThreadId));
527
      CString strMsg;
528
      strMsg.Format(_T("Building %s"),strWhat);
529
      SetIdleMessage(strMsg);
530
 
531
      SetTimer(42,1000,0); // This timer checks for process completion
532
      SetCurrentDirectory(pDoc->BuildTree());
533
      m_sp.Run(SubprocessOutputFunc, this, strCmd, false);
534
      SetIdleMessage();
535
    }
536
  }
537
}
538
 
539
 
540
CConfigToolApp * CMainFrame::GetApp()
541
{
542
  return (CConfigToolApp *)AfxGetApp();
543
}
544
 
545
void CMainFrame::ActivateFrame(int nCmdShow)
546
{
547
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
548
  CRect rcDefault;
549
  SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)(RECT *)rcDefault, 0);
550
  // Insist on nothing more than 1000 width, with the golden ratio
551
  rcDefault.DeflateRect(max(0,(rcDefault.Width()-1000)/2),max(0,(rcDefault.Height()-618)/2));
552
 
553
  GetApp()->RestoreWindowPlacement (this, _T("Window size"),rcDefault);
554
  LoadBarState(_T("DockState"));
555
 
556
  ShowControlBar(&m_wndMLTToolBar,arView[MLT].bVisible,false);
557
  CFrameWnd::ActivateFrame(nCmdShow); // must be before we muck about with the splitters
558
 
559
  CRect rcClient;
560
  GetClientRect(rcClient);
561
  for(int j=0;j<sizeof arSplit/sizeof arSplit[0];j++){
562
    Split &s=arSplit[j];
563
    if(s.pSplit){
564
      CString strKey;
565
      strKey.Format(_T("Split %d"),j);
566
      const CString strSplit(GetApp()->GetProfileString(_T("Split"),strKey));
567
      double fSplit=s.fFrac;
568
      _tscanf(_T("%f"),&fSplit);
569
      s.pSplit->SetSplitPoint(fSplit);
570
      s.pSplit->RecalcLayout();
571
    }
572
  }
573
 
574
  for(int i=0;i<PaneTypeMax;i++){
575
    ViewStruct &v=arView[(PaneType)i];
576
    v.pParent->ShowPane(v.pView,v.bVisible);
577
  }
578
 
579
  RecalcLayout();
580
  pDoc->UpdateFailingRuleCount();
581
 
582
}
583
 
584
void CMainFrame::OnDestroy()
585
{
586
 
587
  GetApp()->SaveWindowPlacement (this, _T("Window size"));
588
 
589
  for(int i=0;i<PaneTypeMax;i++){
590
    LOGFONT lf;
591
    ViewStruct &v=arView[(PaneType)i];
592
    v.font.GetLogFont(&lf);
593
    GetApp()->SaveFont(v.pszName,lf);
594
  }
595
  for(int j=0;j<sizeof arSplit/sizeof arSplit[0];j++){
596
    Split &s=arSplit[j];
597
    if(s.pSplit){
598
      CString strSplit;
599
      strSplit.Format(_T("%f"),s.pSplit->GetSplitPoint());
600
      CString strKey;
601
      strKey.Format(_T("%d"),j);
602
      GetApp()->WriteProfileString(_T("Split"),strKey,strSplit);
603
    }
604
  }
605
  for(j=0;j<sizeof arSplit/sizeof arSplit[0];j++){
606
    Split &s=arSplit[j];
607
    if(s.pSplit){
608
      deleteZ(s.pSplit);
609
    }
610
  }
611
 
612
  if(m_sp.ProcessAlive()){
613
    m_sp.Kill();
614
  }
615
 
616
  for(i=0;i<sizeof arView/sizeof arView[0];i++){
617
    GetApp()->WriteProfileInt(_T("Windows"), arView[i].pszName, arView[i].bVisible);
618
  }
619
 
620
  CFrameWnd::OnDestroy();
621
}
622
 
623
void CMainFrame::OnBuildTests()
624
{
625
  Build("tests");
626
}
627
 
628
void CMainFrame::OnUpdateBuildTests(CCmdUI* pCmdUI)
629
{
630
  pCmdUI->Enable(!m_sp.ProcessAlive());
631
}
632
 
633
void CMainFrame::OnUpdateFileSave(CCmdUI* pCmdUI)
634
{
635
  pCmdUI->Enable(!m_sp.ProcessAlive());
636
}
637
 
638
void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
639
{
640
  pCmdUI->Enable(!m_sp.ProcessAlive());
641
}
642
 
643
void CMainFrame::OnUpdateFileOpen(CCmdUI* pCmdUI)
644
{
645
  pCmdUI->Enable(!m_sp.ProcessAlive());
646
}
647
 
648
void CMainFrame::OnUpdateFileNew(CCmdUI* pCmdUI)
649
{
650
  pCmdUI->Enable(!m_sp.ProcessAlive());
651
}
652
 
653
void CMainFrame::OnUpdateAppExit(CCmdUI* pCmdUI)
654
{
655
  pCmdUI->Enable(!m_sp.ProcessAlive());
656
}
657
 
658
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
659
{
660
  CFrameWnd::OnSysCommand(nID, lParam);
661
}
662
 
663
 
664
void CMainFrame::OnUpdateConfigurationRefresh(CCmdUI* pCmdUI)
665
{
666
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
667
  pCmdUI->Enable(!m_sp.ProcessAlive() && !pDoc->BuildTree().IsEmpty());
668
}
669
 
670
void CMainFrame::OnConfigurationRefresh()
671
{
672
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
673
  pDoc->Reload();
674
}
675
 
676
void CMainFrame::OnViewSettings()
677
{
678
  CViewOptions dlg;
679
  dlg.DoModal();
680
}
681
 
682
void CMainFrame::OnHelp() // Help->Configuration Tool Help
683
{
684
  CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_CONFIGTOOL_HELP));
685
}
686
 
687
void CMainFrame::OnSize(UINT nType, int cx, int cy)
688
{
689
  CFrameWnd::OnSize(nType, cx, cy);
690
  if(m_wndStatusBar){
691
    cx=max(0,cx-m_nFailRulePaneSize-m_nThermometerPaneSize-m_nPercentagePaneSize);
692
    m_wndStatusBar.SetPaneInfo(StatusPane, 0, SBPS_STRETCH   , 0);
693
    m_wndStatusBar.SetPaneInfo(ThermometerPane, 0, SBPS_NORMAL, m_nThermometerPaneSize);
694
    m_wndStatusBar.SetPaneInfo(PercentagePane, 0, SBPS_NORMAL, m_nPercentagePaneSize);
695
    m_wndStatusBar.SetPaneInfo(FailRulePane, 0, SBPS_NORMAL, m_nFailRulePaneSize);
696
    CRect rc;
697
    m_wndStatusBar.GetItemRect(ThermometerPane, rc);
698
    // Reposition the progress control correctly!
699
    m_Progress.SetWindowPos(&wndTop, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0);
700
  }
701
}
702
 
703
void CMainFrame::OnUpdateConfigurationRepository(CCmdUI* pCmdUI)
704
{
705
  pCmdUI->Enable(!m_sp.ProcessAlive());
706
}
707
 
708
void CMainFrame::OnWindowNext()
709
{
710
  BumpWindow(+1);
711
}
712
 
713
void CMainFrame::OnWindowPrev()
714
{
715
  BumpWindow(-1);
716
}
717
 
718
void CMainFrame::BumpWindow(int nInc)
719
{
720
  CWnd *pWnd=CWnd::GetFocus();
721
  if(pWnd){
722
    int nWindows=sizeof arView/sizeof arView[0];
723
    for(int i=0;i<nWindows;i++){
724
      CWnd *pThisWnd=arView[i].pView;
725
      if(pWnd->m_hWnd==pThisWnd->m_hWnd){
726
        for(int j=((i+nInc+nWindows)%nWindows);j!=i;j=((j+nInc+nWindows)%nWindows)){
727
          if(arView[j].bVisible){
728
            arView[j].pView->SetFocus();
729
            return;
730
          }
731
        }
732
      }
733
    }
734
  }
735
}
736
 
737
void CMainFrame::OnHelpSubmitPr()
738
{
739
  CString strURL;
740
  if(strURL.LoadString(IDS_ECOS_PR_URL)){
741
    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);
742
  }
743
}
744
 
745
void CMainFrame::OnHelpEcos()
746
{
747
  CString strURL;
748
  if(strURL.LoadString(IDS_ECOS_SOURCEWARE_URL)){
749
    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);
750
  }
751
}
752
 
753
void CMainFrame::OnHelpEcoshome()
754
{
755
  CString strURL;
756
  if(strURL.LoadString(IDS_ECOS_HOME_URL)){
757
    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);
758
  }
759
}
760
 
761
void CMainFrame::OnHelpRedHatHome()
762
{
763
  CString strURL;
764
  if(strURL.LoadString(IDS_RED_HAT_HOME_URL)){
765
    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);
766
  }
767
}
768
 
769
void CMainFrame::OnHelpUitron()
770
{
771
  CString strURL;
772
  if(strURL.LoadString(IDS_UITRON_HOME_URL)){
773
    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);
774
  }
775
}
776
 
777
void CMainFrame::OnBuildClean()
778
{
779
  Build("clean");
780
}
781
 
782
void CMainFrame::OnUpdateBuildClean(CCmdUI* pCmdUI)
783
{
784
  pCmdUI->Enable(!m_sp.ProcessAlive());
785
}
786
 
787
void CMainFrame::OnToolsShell()
788
{
789
  if(PrepareEnvironment()){
790
 
791
    CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
792
    const CFileName strOldFolder(CFileName::SetCurrentDirectory(pDoc->BuildTree()));
793
    CUtils::Launch(_T(""),CUtils::LoadString(IDS_SHELL_NAME));
794
    if(!strOldFolder.IsEmpty()){ // if the current directory was changed
795
      SetCurrentDirectory(strOldFolder); // restore the previous current directory
796
    }
797
  }
798
}
799
 
800
bool CMainFrame::PrepareEnvironment(bool bWithBuildTools /* = true */)
801
{
802
 
803
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
804
  CConfigToolApp *pApp=(CConfigToolApp *)GetApp();
805
  ::SetEnvironmentVariable(_T("PATH"),pApp->m_strOriginalPath);
806
 
807
  const CString strPrefix(pDoc->CurrentTargetPrefix());
808
  CFileName strBinDir;
809
 
810
  bool rc=(! bWithBuildTools) || pApp->m_arstrBinDirs.Lookup(strPrefix,strBinDir);
811
  if(!rc){
812
    SendMessage(WM_COMMAND,ID_TOOLS_PATHS,0);
813
    rc=pApp->m_arstrBinDirs.Lookup(strPrefix,strBinDir);
814
  }
815
 
816
  if(rc){
817
 
818
    CFileName strUserBinDir(pApp->m_strUserToolsDir);
819
    if(strUserBinDir.IsEmpty()){
820
      if(1==pDoc->m_arstrUserToolPaths.GetSize()){
821
        pApp->m_strUserToolsDir=pDoc->m_arstrUserToolPaths[0];
822
      } else {
823
        SendMessage(WM_COMMAND,ID_USERTOOLS_PATHS,0);
824
      }
825
      strUserBinDir=pApp->m_strUserToolsDir;
826
    }
827
    if(!strUserBinDir.IsEmpty()){
828
 
829
      // calculate the directory of the host tools from this application's module name
830
      CFileName strHostToolsBinDir;
831
      ::GetModuleFileName (::GetModuleHandle (NULL), strHostToolsBinDir.GetBuffer (1 + MAX_PATH), MAX_PATH);
832
      strHostToolsBinDir.ReleaseBuffer ();
833
      strHostToolsBinDir = strHostToolsBinDir.Head ();
834
#ifdef _DEBUG
835
      strHostToolsBinDir = _T("C:\\Progra~1\\Redhat~1\\eCos");
836
#endif
837
 
838
      // tools directories are in the order host-tools, user-tools, comp-tools, install/bin (if present), contrib-tools (if present) on the path
839
      const CFileName strContribBinDir(strUserBinDir,_T("..\\contrib\\bin"));
840
      CFileName strUsrBinDir(strUserBinDir,_T("..\\usr\\bin"));
841
      const CFileName strInstallBinDir(pDoc->InstallTree (),_T("bin"));
842
 
843
      // In case strUserBinDir is e.g. c:\program files\red hat\cygwin-00r1\usertools\h-i686-pc-cygwin\bin
844
      if (!strUsrBinDir.IsDir ())
845
          strUsrBinDir = CFileName(strUserBinDir + _T("..\\..\\..\\H-i686-pc-cygwin\\bin"));
846
 
847
      if (
848
        (strUsrBinDir.IsDir ()     && ! CUtils::AddToPath (strUsrBinDir)) ||
849
        (strContribBinDir.IsDir () && ! CUtils::AddToPath (strContribBinDir)) ||
850
        (strInstallBinDir.IsDir () && ! CUtils::AddToPath (strInstallBinDir)) ||
851
        (bWithBuildTools && ! CUtils::AddToPath (strBinDir)) ||
852
        ! CUtils::AddToPath (strUserBinDir) ||
853
        ! CUtils::AddToPath (strHostToolsBinDir)) {
854
        CUtils::MessageBoxF(_T("Failed to set PATH environment variable - rc=%d"),GetLastError());
855
        rc=false;
856
      } else {
857
        if(!SetEnvironmentVariable(_T("MAKE_MODE"),_T("unix"))){
858
          CUtils::MessageBoxF(_T("Failed to set MAKE_MODE environment variable - rc=%d"),GetLastError());
859
          rc=false;
860
        } else {
861
          SetEnvironmentVariable(_T("GDBTK_LIBRARY"),NULL);
862
          SetEnvironmentVariable(_T("GCC_EXEC_PREFIX"),NULL);
863
          SetEnvironmentVariable(_T("ECOS_REPOSITORY"),pDoc->PackagesDir()); // useful for ecosconfig
864
 
865
          if (! pDoc->BuildTree().IsEmpty())
866
            CygMount(pDoc->BuildTree()[0]);
867
          if (! pDoc->InstallTree().IsEmpty())
868
            CygMount(pDoc->InstallTree()[0]);
869
          if (! pDoc->Repository().IsEmpty())
870
            CygMount(pDoc->Repository()[0]);
871
 
872
#ifdef _DEBUG
873
          TCHAR buf[512];
874
          ::GetEnvironmentVariable(_T("PATH"), buf, 512);
875
          CConfigTool::Log(buf);
876
#endif
877
 
878
        }
879
      }
880
    }
881
  }
882
  return rc;
883
}
884
 
885
 
886
void CMainFrame::OnClose()
887
{
888
  if(m_sp.ProcessAlive()){
889
    if(IDNO==CUtils::MessageBoxFT(MB_YESNO|MB_DEFBUTTON2,_T("A build is in progress: exit anyway?"))){
890
      return;
891
    }
892
    m_sp.Kill();
893
  }
894
  SaveBarState(_T("DockState"));
895
  CFrameWnd::OnClose();
896
}
897
 
898
void CMainFrame::OnBuildOptions()
899
{
900
  CBuildOptionsDialog dlg;
901
  dlg.DoModal();
902
}
903
 
904
void CMainFrame::OnUpdateBuildOptions(CCmdUI* pCmdUI)
905
{
906
  pCmdUI->Enable(TRUE);
907
}
908
 
909
void CMainFrame::OnToolsOptions()
910
{
911
  CToolsOptionsDialog dlg;
912
  dlg.DoModal();
913
}
914
 
915
void CMainFrame::OnUpdateViewMLT(CCmdUI* pCmdUI)
916
{
917
  pCmdUI->SetCheck(arView[MLT].bVisible);
918
}
919
 
920
void CMainFrame::OnViewConflicts()
921
{
922
  arView[Rules].bVisible^=1;
923
  arView[Rules].pParent->ShowPane(arView[Rules].pView,arView[Rules].bVisible);
924
}
925
 
926
void CMainFrame::OnUpdateViewConflicts(CCmdUI* pCmdUI)
927
{
928
  pCmdUI->SetCheck(arView[Rules].bVisible);
929
}
930
 
931
void CMainFrame::OnToolsPaths()
932
{
933
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
934
  CConfigToolApp *pApp=(CConfigToolApp *)GetApp();
935
 
936
  CString strDefault;
937
  const CString strPrefix(pDoc->CurrentTargetPrefix());
938
 
939
  CStringArray arstrPaths;
940
  for(POSITION pos = pApp->m_arstrBinDirs.GetStartPosition(); pos != NULL; ){
941
    CString strP,strB;
942
    pApp->m_arstrBinDirs.GetNextAssoc(pos, strP, strB);
943
 
944
    arstrPaths.Add(strB);
945
    if(strP==strPrefix){
946
      strDefault=strB;
947
    }
948
  }
949
 
950
  CBinDirDialog dlg(arstrPaths,strDefault);
951
 
952
  dlg.m_strDesc.Format(CUtils::LoadString(IDS_COMPTOOLS_DLG_DESC),strPrefix.IsEmpty()?_T("native"):strPrefix,strPrefix.IsEmpty()?_T(""):strPrefix+_T("-"));
953
  dlg.m_strTitle=_T("Build Tools");
954
 
955
  if(IDOK==dlg.DoModal()){
956
    CFileName strExe;
957
    strExe.Format(_T("%s\\%s%sgcc.exe"),dlg.m_strFolder,strPrefix,strPrefix.IsEmpty()?_T(""):_T("-"));
958
    if(strExe.Exists()||
959
      IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("%s does not appear to contain the build tools - use this folder anyway?"),dlg.m_strFolder)){
960
      pApp->m_arstrBinDirs.SetAt(strPrefix,dlg.m_strFolder);
961
    }
962
  }
963
}
964
 
965
void CMainFrame::OnUsertoolsPaths()
966
{
967
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
968
  CConfigToolApp * pApp = (CConfigToolApp *) GetApp ();
969
 
970
  CStringArray arstrPaths;
971
  arstrPaths.Copy(pDoc->m_arstrUserToolPaths);
972
  if(!pApp->m_strUserToolsDir.IsEmpty()){
973
    arstrPaths.Add(pApp->m_strUserToolsDir);
974
  }
975
  CBinDirDialog dlg(arstrPaths, pApp->m_strUserToolsDir);
976
 
977
  dlg.m_strDesc.LoadString(IDS_USERTOOLS_DLG_DESC);
978
  dlg.m_strTitle=_T("User Tools");
979
 
980
  if(IDOK==dlg.DoModal()){
981
    CFileName strFile(dlg.m_strFolder);
982
    strFile+=_T("ls.exe");
983
    if(strFile.Exists()||
984
      IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("%s does not appear to contain the user tools - use this folder anyway?"),dlg.m_strFolder)){
985
      pApp->m_strUserToolsDir=dlg.m_strFolder;
986
    }
987
  }
988
}
989
 
990
void CMainFrame::UpdateThermometer(int nLines)
991
{
992
  if(nLines>=0 && 0!=m_nThermometerMax){
993
    int nPercentage=min(100,(100*nLines)/m_nThermometerMax);
994
    m_Progress.SetPos(nPercentage);
995
    CString str;
996
    if(nLines>0){
997
      str.Format(_T("%d%%"),nPercentage);
998
    }
999
    m_wndStatusBar.SetPaneText(PercentagePane,str);
1000
  }
1001
}
1002
 
1003
void CMainFrame::SetThermometerMax (int nMax)
1004
{
1005
  if(0==nMax){
1006
    UpdateThermometer(0);
1007
  }
1008
  m_nThermometerMax=nMax;
1009
}
1010
 
1011
LRESULT CMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam)
1012
{
1013
  if (AFX_IDS_IDLEMESSAGE==wParam){
1014
    wParam=0;
1015
    lParam=(LPARAM)(LPCTSTR )m_strIdleMessage;
1016
  }
1017
  return CFrameWnd::OnSetMessageString(wParam, lParam);
1018
}
1019
 
1020
void CMainFrame::SetIdleMessage (LPCTSTR pszIdleMessage)
1021
{
1022
  if(NULL==pszIdleMessage){
1023
    m_strIdleMessage.LoadString(AFX_IDS_IDLEMESSAGE);
1024
  } else {
1025
    m_strIdleMessage=pszIdleMessage;
1026
  }
1027
  SendMessage(WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE, 0);
1028
}
1029
 
1030
void CMainFrame::OnRunSim()
1031
{
1032
  CConfigTool::GetConfigToolDoc()->RunTests();
1033
}
1034
 
1035
bool CMainFrame::SetPaneFont(PaneType pane,const LOGFONT &lf)
1036
{
1037
  CFont &font=arView[pane].font;
1038
  font.Detach();
1039
  font.CreateFontIndirect(&lf);
1040
  switch(pane){
1041
                case Output:
1042
      CConfigTool::GetOutputView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1043
      break;
1044
    case ShortDesc:
1045
      CConfigTool::GetDescView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1046
      CConfigTool::GetDescView()->Invalidate();
1047
      break;
1048
    case Control:
1049
    case Cell:
1050
      CConfigTool::GetControlView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1051
      CConfigTool::GetCellView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1052
      CConfigTool::GetControlView()->Invalidate();
1053
      CConfigTool::GetCellView()->Invalidate();
1054
      break;
1055
    case Properties:
1056
      CConfigTool::GetPropertiesView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1057
      CConfigTool::GetPropertiesView()->Invalidate();
1058
      break;
1059
    case Rules:
1060
      CConfigTool::GetRulesView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1061
      CConfigTool::GetRulesView()->Invalidate();
1062
      break;
1063
    case MLT:
1064
      CConfigTool::GetRulesView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0);
1065
      CConfigTool::GetRulesView()->Invalidate();
1066
      break;
1067
    default:
1068
      ASSERT(FALSE);
1069
      break;
1070
  }
1071
  return true;
1072
}
1073
 
1074
CFont &CMainFrame::GetPaneFont(PaneType pane)
1075
{
1076
  return arView[pane].font;
1077
}
1078
 
1079
void CMainFrame::OnUpdateRunSim(CCmdUI* pCmdUI)
1080
{
1081
  pCmdUI->Enable(!CConfigTool::GetConfigToolDoc()->InstallTree().IsEmpty() && !m_sp.ProcessAlive());
1082
}
1083
 
1084
void CMainFrame::SetFailRulePane(int nCount)
1085
{
1086
  CString strCount;
1087
  switch (nCount)
1088
  {
1089
                case 0:
1090
      strCount = _T("No conflicts");
1091
      break;
1092
    case 1:
1093
      strCount = _T("1 conflict");
1094
      break;
1095
    default:
1096
      strCount.Format (_T("%d conflicts"), nCount);
1097
      break;
1098
  }
1099
  if(m_bStatusBarCreated){
1100
    m_wndStatusBar.SetPaneText (FailRulePane, strCount);
1101
  }
1102
}
1103
 
1104
void CMainFrame::OnUpdateFrameTitle (BOOL bAddToTitle)
1105
{
1106
  if ((GetStyle() & FWS_ADDTOTITLE) == 0)
1107
    return;     // leave it alone!
1108
                /*
1109
                #ifndef _AFX_NO_OLE_SUPPORT
1110
                // allow hook to set the title (used for OLE support)
1111
                if (m_pNotifyHook != NULL && m_pNotifyHook->OnUpdateFrameTitle())
1112
                return;
1113
                #endif
1114
  */
1115
  CDocument* pDoc=CConfigTool::GetConfigToolDoc();
1116
  if (bAddToTitle && pDoc != NULL)
1117
    UpdateFrameTitleForDocument(pDoc->GetTitle() + (pDoc->IsModified () ? "*" : ""));
1118
  else
1119
    UpdateFrameTitleForDocument(NULL);
1120
}
1121
 
1122
void CMainFrame::OnViewMltbar()
1123
{
1124
  m_bMLTToolbarVisible^=1;
1125
  ShowControlBar(&m_wndMLTToolBar,m_bMLTToolbarVisible,false);
1126
}
1127
 
1128
void CMainFrame::OnUpdateViewMltbar(CCmdUI* pCmdUI)
1129
{
1130
  pCmdUI->Enable(arView[MLT].bVisible);
1131
  pCmdUI->SetCheck(m_bMLTToolbarVisible);
1132
}
1133
 
1134
void CMainFrame::OnResolveConflicts()
1135
{
1136
  if(CConfigToolDoc::NotDone==CConfigTool::GetConfigToolDoc()->ResolveGlobalConflicts()){
1137
    // Global inference handler was never invoked.  Say something
1138
    CUtils::MessageBoxF(_T("No solutions can be automatically determined for the current set of conflicts."));
1139
  }
1140
}
1141
 
1142
void CMainFrame::OnUpdateResolveConflicts(CCmdUI* pCmdUI)
1143
{
1144
  pCmdUI->Enable(CConfigTool::GetConfigToolDoc()->GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0);
1145
}
1146
 
1147
void CMainFrame::OnGoHome() // Help->eCos Documentation
1148
{
1149
  CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_ECOS_HELP));
1150
}
1151
 
1152
HMENU CMainFrame::NewMenu()
1153
{
1154
  // Load the menu from the resources
1155
  m_menu.LoadMenu(IDR_MAINFRAME);
1156
 
1157
  m_menu.LoadToolbar(IDR_MAINFRAME);
1158
  m_menu.LoadToolbar(IDR_MISCBAR);
1159
 
1160
  m_menu.ModifyODMenu(NULL,ID_HELP,IDB_HELP);
1161
  m_menu.ModifyODMenu(NULL,ID_GO_HOME,IDB_HELP);
1162
  m_menu.ModifyODMenu(NULL,ID_HELP_RED_HATONTHEWEB,IDB_HTML);
1163
  m_menu.ModifyODMenu(NULL,ID_HELP_ECOSHOME,IDB_HTML);
1164
  m_menu.ModifyODMenu(NULL,ID_HELP_ECOS,IDB_HTML);
1165
  m_menu.ModifyODMenu(NULL,ID_HELP_UITRON,IDB_HTML);
1166
 
1167
  return(m_menu.Detach());
1168
 
1169
}
1170
 
1171
//This handler ensure that the popup menu items are drawn correctly
1172
void CMainFrame::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
1173
{
1174
  BOOL setflag=FALSE;
1175
  if(lpMeasureItemStruct->CtlType==ODT_MENU){
1176
    if(IsMenu((HMENU)lpMeasureItemStruct->itemID)){
1177
      CMenu* cmenu=CMenu::FromHandle((HMENU)lpMeasureItemStruct->itemID);
1178
      if(BCMenu::IsMenu(cmenu)){
1179
        m_menu.MeasureItem(lpMeasureItemStruct);
1180
        setflag=TRUE;
1181
      }
1182
    }
1183
  }
1184
  if(!setflag)CFrameWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
1185
}
1186
 
1187
//This handler ensures that keyboard shortcuts work
1188
LRESULT CMainFrame::OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu)
1189
{
1190
  LRESULT lresult;
1191
  if(BCMenu::IsMenu(pMenu))
1192
    lresult=BCMenu::FindKeyboardShortcut(nChar, nFlags, pMenu);
1193
  else
1194
    lresult=CFrameWnd::OnMenuChar(nChar, nFlags, pMenu);
1195
  return(lresult);
1196
}
1197
 
1198
//This handler updates the menus from time to time
1199
void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
1200
{
1201
  CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
1202
  if(!bSysMenu){
1203
    if(BCMenu::IsMenu(pPopupMenu))BCMenu::UpdateMenu(pPopupMenu);
1204
  }
1205
}
1206
 
1207
void CALLBACK CMainFrame::SubprocessOutputFunc(void *pParam,LPCTSTR psz)
1208
{
1209
  LPTSTR pszCopy=new TCHAR[1+_tcslen(psz)];
1210
  _tcscpy(pszCopy,psz);
1211
  // Post a message to the mainframe because it wouldn't be safe to manipulate controls from a different thread
1212
  ((CMainFrame *)pParam)->PostMessage(WM_SUBPROCESS,(WPARAM)pszCopy);
1213
}
1214
 
1215
LRESULT CMainFrame::OnSubprocess(WPARAM wParam, LPARAM)
1216
{
1217
  LPTSTR psz=(LPTSTR)wParam;
1218
  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();
1219
  m_nLogicalLines+=pDoc->GetCompilationCount(psz);
1220
  UpdateThermometer (m_nLogicalLines);
1221
  CConfigTool::GetOutputView()->AddText(psz);
1222
  deleteZA(psz);
1223
  return 0;
1224
}
1225
 
1226
void CMainFrame::OnUpdateToolsAdministration(CCmdUI* pCmdUI)
1227
{
1228
  pCmdUI->Enable(!m_sp.ProcessAlive());
1229
}
1230
 
1231
void CMainFrame::CygMount(TCHAR c)
1232
{
1233
  // May not be alpha if it's e.g. a UNC network path
1234
  if (!_istalpha(c))
1235
      return;
1236
 
1237
  c=towlower(c);
1238
  if(!m_arMounted[c-_TCHAR('a')]){
1239
    m_arMounted[c-_TCHAR('a')]=true;
1240
    CString strCmd;
1241
    String strOutput;
1242
 
1243
    strCmd.Format(_T("mount %c: /ecos-%c"),c,c);
1244
    CSubprocess sub;
1245
    sub.Run(strOutput,strCmd);
1246
  }
1247
}
1248
 
1249
BOOL CMainFrame::OnHelpInfo(HELPINFO* pHelpInfo)
1250
{
1251
        // TODO: Add your message handler code here and/or call default
1252
 
1253
        return CFrameWnd::OnHelpInfo(pHelpInfo);
1254
}
1255
 
1256
void CMainFrame::OnNavComplete(NMHDR* pHdr, LRESULT*)
1257
{
1258
  TRACE(_T("HH Notify\n"));
1259
}
1260
 
1261
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
1262
{
1263
  if(WM_NOTIFY==pMsg->message){
1264
    LPNMHDR pHdr=(LPNMHDR)pMsg->lParam;
1265
    TRACE(_T("WM_NOTIFY id=%d idFrom=%d code=%d\n"),pMsg->wParam,pHdr->idFrom,pHdr->code);
1266
  }
1267
 
1268
        return CFrameWnd::PreTranslateMessage(pMsg);
1269
}
1270
 
1271
void CMainFrame::OnEditPlatforms()
1272
{
1273
  CPlatformsDialog dlg;
1274
  if(IDOK==dlg.DoModal()){
1275
    CeCosTestPlatform::RemoveAllPlatforms();
1276
    for(unsigned int i=0;i<dlg.PlatformCount();i++){
1277
      CeCosTestPlatform::Add(*dlg.Platform(i));
1278
    }
1279
    CeCosTestPlatform::Save();
1280
  }
1281
}
1282
 
1283
void CMainFrame::OnTimer(UINT nIDEvent)
1284
{
1285
  if(!m_sp.ProcessAlive()){
1286
    KillTimer(nIDEvent);
1287
 
1288
    TRACE(_T("m_nThermometerMax=%d m_nLogicalLines=%d\n"),m_nThermometerMax,m_nLogicalLines);
1289
    if(0==m_sp.GetExitCode){
1290
      UpdateThermometer(m_nThermometerMax);
1291
      Sleep(250); // Allow user to see it
1292
    }
1293
    UpdateThermometer(0);
1294
    SetThermometerMax(0);
1295
  }
1296
        CFrameWnd::OnTimer(nIDEvent);
1297
}

powered by: WebSVN 2.1.0

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