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