📄 mainfrm.cpp
字号:
//####COPYRIGHTBEGIN####// // ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or (at your option) // any later version.// // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details.// // You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// ----------------------------------------------------------------------------// //####COPYRIGHTEND####// MainFrm.cpp : implementation of the CMainFrame class:////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): sdf// Contact(s): sdf// Date: 1998/08/11// Version: 0.01// Purpose: // Description: This is the implementation of the main frame class// Requires: // Provides: // See also: // Known bugs: // Usage: ////####DESCRIPTIONEND####////===========================================================================#include "stdafx.h"#include "BinDirDialog.h"#include "BuildOptionsDialog.h"#include "CTOptionsDialog.h"#include "CTUtils.h"#include "CellView.h"#include "ConfigItem.h"#include "ConfigTool.h"#include "ConfigToolDoc.h"#include "ControlView.h"#include "DescView.h"#include "FindDialog.h"#include "FolderDialog.h"#include "MLTFrame.h"#include "MainFrm.h"#include "MessageBox.h"#include "PlatformsDialog.h"#include "NotePage.h"#include "OutputView.h"#include "PropertiesView.h"#include "RegionGeneralPage.h"#include "RulesView.h"#include "SectionGeneralPage.h"#include "SectionRelocationPage.h"#include "Splash.h"#include "SplitterWndEx.h"#include "Subprocess.h"#include "TestResource.h"#include "ThinSplitter.h"#include "ViewOptions.h"#define INCLUDEFILE "build.hxx"#include "IncludeSTL.h"#include <afxpriv.h>#include <htmlhelp.h>#include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CMainFrameIMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)//UINT WM_FINDREPLACE = RegisterWindowMessage(FINDMSGSTRING);BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_COMMAND(ID_VIEW_PROPERTIES, OnViewProperties) ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTIES, OnUpdateViewProperties) ON_COMMAND(ID_VIEW_MLT, OnViewMLT) ON_COMMAND(ID_VIEW_SHORTDESC, OnViewShortdesc) ON_UPDATE_COMMAND_UI(ID_VIEW_SHORTDESC, OnUpdateViewShortdesc) ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput) ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput) ON_UPDATE_COMMAND_UI(ID_BUILD_CONFIGURE, OnUpdateBuildConfigure) ON_COMMAND(ID_BUILD_STOP, OnBuildStop) ON_UPDATE_COMMAND_UI(ID_BUILD_STOP, OnUpdateBuildStop) ON_COMMAND(ID_BUILD_CONFIGURE, OnConfigurationBuild) ON_WM_DESTROY() ON_COMMAND(ID_BUILD_TESTS, OnBuildTests) ON_UPDATE_COMMAND_UI(ID_BUILD_TESTS, OnUpdateBuildTests) ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave) ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnUpdateFileSaveAs) ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen) ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew) ON_UPDATE_COMMAND_UI(ID_APP_EXIT, OnUpdateAppExit) ON_UPDATE_COMMAND_UI(ID_VIEW_MLT, OnUpdateViewMLT) ON_WM_SYSCOMMAND() ON_UPDATE_COMMAND_UI(ID_CONFIGURATION_REFRESH, OnUpdateConfigurationRefresh) ON_COMMAND(ID_CONFIGURATION_REFRESH, OnConfigurationRefresh) ON_COMMAND(ID_MENU_VIEW_SETTINGS, OnViewSettings) ON_COMMAND(ID_TOOLS_PATHS, OnToolsPaths) ON_WM_SIZE() ON_UPDATE_COMMAND_UI(ID_CONFIGURATION_REPOSITORY, OnUpdateConfigurationRepository) ON_COMMAND(ID_WINDOW_NEXT, OnWindowNext) ON_COMMAND(ID_WINDOW_PREV, OnWindowPrev) ON_COMMAND(ID_HELP_SUBMIT_PR, OnHelpSubmitPr) ON_COMMAND(ID_HELP_ECOS, OnHelpEcos) ON_COMMAND(ID_HELP_RED_HATONTHEWEB, OnHelpRedHatHome) ON_COMMAND(ID_HELP_UITRON, OnHelpUitron) ON_COMMAND(ID_HELP_ECOSHOME, OnHelpEcoshome) ON_COMMAND(ID_RUN_SIM, OnRunSim) ON_COMMAND(ID_BUILD_CLEAN, OnBuildClean) ON_UPDATE_COMMAND_UI(ID_BUILD_CLEAN, OnUpdateBuildClean) ON_COMMAND(ID_TOOLS_SHELL, OnToolsShell) ON_WM_CLOSE() ON_COMMAND(ID_BUILD_OPTIONS, OnBuildOptions) ON_COMMAND(ID_TOOLS_OPTIONS, OnToolsOptions) ON_COMMAND(ID_USERTOOLS_PATHS, OnUsertoolsPaths) ON_MESSAGE(WM_SETMESSAGESTRING, OnSetMessageString) ON_UPDATE_COMMAND_UI(ID_RUN_SIM, OnUpdateRunSim) ON_COMMAND(ID_VIEW_CONFLICTS, OnViewConflicts) ON_UPDATE_COMMAND_UI(ID_VIEW_CONFLICTS, OnUpdateViewConflicts) ON_COMMAND(ID_VIEW_MLTBAR, OnViewMltbar) ON_UPDATE_COMMAND_UI(ID_VIEW_MLTBAR, OnUpdateViewMltbar) ON_COMMAND(ID_RESOLVE_CONFLICTS, OnResolveConflicts) ON_UPDATE_COMMAND_UI(ID_RESOLVE_CONFLICTS, OnUpdateResolveConflicts) ON_COMMAND(ID_GO_HOME, OnGoHome) ON_WM_MEASUREITEM() ON_WM_INITMENUPOPUP() ON_UPDATE_COMMAND_UI(ID_BUILD_OPTIONS, OnUpdateBuildOptions) ON_MESSAGE(WM_SUBPROCESS,OnSubprocess) ON_UPDATE_COMMAND_UI(ID_TOOLS_ADMINISTRATION, OnUpdateToolsAdministration) ON_WM_HELPINFO() ON_WM_MENUCHAR() ON_WM_TIMER() ON_COMMAND(ID_HELP, OnHelp) ON_COMMAND(ID_EDIT_PLATFORMS, OnEditPlatforms) //}}AFX_MSG_MAP ON_NOTIFY(HHN_NAVCOMPLETE, ID_HHNOTIFICATION, OnNavComplete) ON_NOTIFY(HHN_TRACK, ID_HHNOTIFICATION, OnNavComplete) ON_NOTIFY(HHN_WINDOW_CREATE,ID_HHNOTIFICATION, OnNavComplete)END_MESSAGE_MAP()UINT CMainFrame::indicators[] ={ ID_SEPARATOR, // status line indicator ID_THERMOMETER, ID_SEPARATOR, // status line indicator ID_SEPARATOR};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};/////////////////////////////////////////////////////////////////////////////// CMainFrame construction/destructionCMainFrame::CMainFrame(): m_pFindReplaceDialog(NULL), m_strIdleMessage(), m_nThermometerMax(0), m_bFindInProgress(false), m_bStatusBarCreated(false), m_psp(NULL){}CMainFrame::~CMainFrame(){}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){ DragAcceptFiles(); if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.Create(this,WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,AFX_IDW_TOOLBAR) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndMLTToolBar.Create(this,WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,AFX_IDW_TOOLBAR+1) || !m_wndMLTToolBar.LoadToolBar(IDR_MLTBAR)) { TRACE0("Failed to create MLT toolbar\n"); return -1; // fail to create } m_bMLTToolbarVisible=true; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_bStatusBarCreated=true; CDC *pDC=GetDC(); CFont *pOldFont=pDC->SelectObject(m_wndStatusBar.GetFont()); m_nThermometerPaneSize=100; m_nPercentagePaneSize=pDC->GetTextExtent(_T("100%")).cx; m_nFailRulePaneSize=pDC->GetTextExtent(_T("333 conflicts")).cx; pDC->SelectObject(pOldFont); ReleaseDC(pDC); CRect rect; m_wndStatusBar.GetItemRect(ThermometerPane, rect); m_Progress.Create(WS_VISIBLE|WS_CHILD|PBS_SMOOTH, rect,&m_wndStatusBar, ID_THERMOMETER); m_Progress.SetRange(0,100); m_Progress.SetPos(0); //CConfigTool::GetConfigToolDoc()->UpdateFailingRuleCount(); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndMLTToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); DockControlBar(&m_wndMLTToolBar); CSplashWnd::ShowSplashScreen(this); return 0;}BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs){ //cs.style|=~FWS_ADDTOTITLE; return CFrameWnd::PreCreateWindow(cs);}/////////////////////////////////////////////////////////////////////////////// CMainFrame diagnostics#ifdef _DEBUGvoid CMainFrame::AssertValid() const{ CFrameWnd::AssertValid();}void CMainFrame::Dump(CDumpContext& dc) const{ CFrameWnd::Dump(dc);}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CMainFrame message handlersCMainFrame::ViewStruct CMainFrame::arView[PaneTypeMax]={ CMainFrame::ViewStruct(_T("Cell"), true,RUNTIME_CLASS(CCellView)), CMainFrame::ViewStruct(_T("Configuration"), true,RUNTIME_CLASS(CControlView)), CMainFrame::ViewStruct(_T("Short Description"), true,RUNTIME_CLASS(CDescView)), CMainFrame::ViewStruct(_T("Output"), true,RUNTIME_CLASS(COutputView)), CMainFrame::ViewStruct(_T("Properties"), true,RUNTIME_CLASS(CPropertiesView)), CMainFrame::ViewStruct(_T("Rules"), false,RUNTIME_CLASS(CRulesView)), CMainFrame::ViewStruct(_T("Memory Layout"), false,RUNTIME_CLASS(CMLTView))};// This data defines the layout of the nested splittersCMainFrame::Split CMainFrame::arSplit[]={ CMainFrame::Split(Horz,1,0.8), CMainFrame::Split(Horz,2,0.7), CMainFrame::Split(Vert,3,0.5), CMainFrame::Split(Thin,4,0.4), CMainFrame::Split(Control,5), CMainFrame::Split(Cell,5), CMainFrame::Split(Horz,4,0.6), CMainFrame::Split(Rules,5), CMainFrame::Split(Horz,5,0.5), CMainFrame::Split(Properties,6), CMainFrame::Split(ShortDesc,6), CMainFrame::Split(MLT,3), CMainFrame::Split(Output,2)};BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { for(int i=0;i<sizeof arView/sizeof arView[0];i++){ ViewStruct &v=arView[(PaneType)i]; v.bVisible=GetApp()->GetProfileInt(_T("Windows"),v.pszName,v.bVisible); } CRect rcClient; GetClientRect(rcClient); BOOL rc=TRUE; // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // x | | x // x Tree (T)| Cell(T) | x // x ^^^^^^^^^^^^^^^^^^| Rules (2) x // x 1 | x // x | |---------------------------x // x | | x // x | | Properties (2) x // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // x MLT x // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // x x // x Output (0) x // x x // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx for(i=0;i<sizeof arSplit/sizeof arSplit[0];i++){ const CSize szDefault(50,50); Split &s=arSplit[i]; CSplitterWndEx *pParent=NULL; bool bSecond=false; int nRowParent=0; int nColParent=0; // Search backwards for our parent. This is the first entry back of level one higher. for(int j=i-1;j>=0;--j){ Split &sp=arSplit[j]; if(sp.nLevel==s.nLevel-1){ pParent=sp.pSplit; nRowParent=(bSecond && Horz==sp.type); nColParent=(bSecond && Horz!=sp.type); break; } else if(sp.nLevel==s.nLevel){ bSecond=true; } } if(s.type>=0 /* a view */){ TRACE(_T("Create view index=%d [%s]\n"),i,arView[s.type].pszName); VERIFY(pParent->CreateView (nRowParent, nColParent, arView[s.type].pClass, szDefault, pContext)); arView[s.type].pView=(CView *)pParent->GetPane(nRowParent,nColParent); arView[s.type].pParent=pParent; } else { int nRows=1+(Horz==s.type); int nCols=1+(Horz!=s.type); UINT id; CWnd *pwndParent; if(NULL==pParent){ pwndParent=this; id=AFX_IDW_PANE_FIRST; } else { id=pParent->IdFromRowCol(nRowParent,nColParent); pwndParent=pParent; } if(Thin==s.type){ TRACE(_T("Create thin splitter index=%d\n"),i); s.pSplit=new CThinSplitter; VERIFY(s.pSplit->CreateStatic (pParent, 1, 2, WS_CHILD|WS_VISIBLE|WS_BORDER, id)); s.pSplit->SetScrollStyle(WS_VSCROLL); } else { TRACE(_T("Create splitter index=%d\n"),i); s.pSplit=new CSplitterWndEx; VERIFY(s.pSplit->CreateStatic (pwndParent, nRows, nCols, WS_CHILD|WS_VISIBLE|WS_BORDER, id)); } } }; for(i=0;i<PaneTypeMax;i++){ LOGFONT lf; ViewStruct &v=arView[(PaneType)i]; GetApp()->LoadFont(v.pszName,lf); if(!arView[(PaneType)i].font.CreateFontIndirect(&lf)){ CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT))->GetLogFont(&lf); } SetPaneFont((PaneType)i,lf); //v.pParent->ShowPane(v.pView,v.bVisible); } for(i=0;i<sizeof arSplit/sizeof arSplit[0];i++){ Split &s=arSplit[i]; if(s.pSplit){ s.pSplit->RecalcLayout(); } } UNUSED_ALWAYS(lpcs); // avoid compiler warning return rc;}void CMainFrame::OnViewProperties() { arView[Properties].bVisible^=1; arView[Properties].pParent->ShowPane(arView[Properties].pView,arView[Properties].bVisible);}void CMainFrame::OnUpdateViewProperties(CCmdUI* pCmdUI) { pCmdUI->SetCheck(arView[Properties].bVisible);}void CMainFrame::OnViewMLT() { arView[MLT].bVisible^=1; arView[MLT].pParent->ShowPane(arView[MLT].pView,arView[MLT].bVisible); ShowControlBar(&m_wndMLTToolBar,arView[MLT].bVisible&m_bMLTToolbarVisible,false);}void CMainFrame::OnViewShortdesc() { arView[ShortDesc].bVisible^=1; arView[ShortDesc].pParent->ShowPane(arView[ShortDesc].pView,arView[ShortDesc].bVisible);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -