📄 mainframe.cpp
字号:
{ int w; int h; m_outputSashWindow = new wxSashLayoutWindow(this, ID_OUTPUT_SASH_WINDOW); m_outputSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL); m_outputSashWindow->SetAlignment(wxLAYOUT_BOTTOM); m_outputSashWindow->SetSashVisible(wxSASH_TOP, true); m_outputWindow = new wxTextCtrl(m_outputSashWindow, ID_OUTPUT_WINDOW, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxCLIP_CHILDREN | wxTE_READONLY | wxTE_RICH); wxLog *old_log = wxLog::SetActiveTarget(new wxLogTextCtrl(m_outputWindow)); delete old_log; wxLogMessage(wxT("Nut/OS Configurator Version %s"), wxT(VERSION)); wxLogMessage(wxT("Linked to %s"), wxVERSION_STRING); wxLogMessage(wxT("Running on %s"), wxGetOsDescription().c_str()); wxLogVerbose(wxT("Create ConfigSash")); m_configSashWindow = new wxSashLayoutWindow(this, ID_CONFIG_SASH_WINDOW); m_configSashWindow->SetOrientation(wxLAYOUT_VERTICAL); m_configSashWindow->SetAlignment(wxLAYOUT_LEFT); m_configSashWindow->SetSashVisible(wxSASH_RIGHT, true); wxLogVerbose(wxT("Create PropertySash")); m_propertiesSashWindow = new wxSashLayoutWindow(this, ID_PROPERTIES_SASH_WINDOW); m_propertiesSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL); m_propertiesSashWindow->SetAlignment(wxLAYOUT_TOP); m_propertiesSashWindow->SetSashVisible(wxSASH_BOTTOM, true); wxLogVerbose(wxT("Create InfoSash")); m_infoSashWindow = new wxSashLayoutWindow(this, ID_SHORT_DESCR_SASH_WINDOW); m_infoSashWindow->SetOrientation(wxLAYOUT_HORIZONTAL); m_infoSashWindow->SetAlignment(wxLAYOUT_TOP); wxLogVerbose(wxT("Create CPropertyList")); m_propertyListWindow = new CPropertyList(m_propertiesSashWindow, ID_PROPERTIES_WINDOW, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxCLIP_CHILDREN | wxLC_VRULES | wxLC_HRULES | wxSUNKEN_BORDER); wxLogVerbose(wxT("Create CInfoWindow")); m_infoWindow = new CInfoWindow(m_infoSashWindow, ID_SHORT_DESCR_WINDOW, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxCLIP_CHILDREN | wxTE_READONLY); /* * Component tree control. * * Window relationship: * CSplitScroll - wxScrolledWindow * wxSplitterWindow * CConfigTree - CScrolledTreeCtrl - wxTreeCtrl * CValueWindow - CTreeCompWindow - wxWindow */ wxLogVerbose(wxT("Create CSplitScroll")); m_scrolledWindow = new CSplitScroll(m_configSashWindow, ID_SCROLLED_WINDOW, wxDefaultPosition, wxSize(250, 150), wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); wxLogVerbose(wxT("Create wxSplitterWindow")); m_splitter = new wxSplitterWindow(m_scrolledWindow, ID_SPLITTER_WINDOW, wxDefaultPosition, wxSize(240, 130), wxSP_3DBORDER | wxCLIP_CHILDREN); wxLogVerbose(wxT("Create CConfigTree")); m_treeWindow = new CConfigTree(m_splitter, ID_TREE_CTRL, wxDefaultPosition, wxSize(120, 120), wxTR_HAS_BUTTONS | /* wxTR_NO_LINES | */ wxTR_ROW_LINES | wxNO_BORDER); wxLogVerbose(wxT("Create CValueWindow")); m_valueWindow = new CValueWindow(m_splitter, ID_VALUE_WINDOW, wxDefaultPosition, wxSize(120, 120), wxNO_BORDER); m_splitter->SplitVertically(m_treeWindow, m_valueWindow); m_splitter->SetMinimumPaneSize(100); /* Scrolling is done on the tree. */ //m_scrolledWindow->SetTargetWindow(m_treeWindow); m_scrolledWindow->EnableScrolling(false, false); // Let the two controls know about each other m_valueWindow->SetTreeCtrl(m_treeWindow); m_treeWindow->SetCompanionWindow(m_valueWindow); wxConfigBase *pConfig = wxConfigBase::Get(); wxString lastPath = pConfig->GetPath(); pConfig->SetPath(wxT("/MainFrame")); wxLogVerbose(wxT("Size ConfigSash")); w = pConfig->Read(wxT("tree_w"), 270); h = pConfig->Read(wxT("tree_h"), 190); m_configSashWindow->SetDefaultSize(wxSize(w > 50 ? w : 50, h > 50 ? h : 50)); m_splitter->SetSashSize(5); int x = pConfig->Read(wxT("split_x"), 10); m_splitter->SetSashPosition(x < 10 ? 10 : x); wxLogVerbose(wxT("Size PropertySash")); w = pConfig->Read(wxT("prop_w"), 300); h = pConfig->Read(wxT("prop_h"), 115); m_propertiesSashWindow->SetDefaultSize(wxSize(w > 50 ? w : 50, h > 50 ? h : 50)); wxLogVerbose(wxT("Size InfoSash")); w = pConfig->Read(wxT("desc_w"), 300); h = pConfig->Read(wxT("desc_h"), 75); m_infoSashWindow->SetDefaultSize(wxSize(w > 50 ? w : 50, h > 50 ? h : 50)); wxLogVerbose(wxT("Size OutputSash")); w = pConfig->Read(wxT("outp_w"), 560); h = pConfig->Read(wxT("outp_h"), 90); m_outputSashWindow->SetDefaultSize(wxSize(w > 50 ? w : 50, h > 50 ? h : 50)); pConfig->SetPath(lastPath); wxLogVerbose(wxT("+++++++++++++++ Windows created +++++++++++++++++"));}wxTextCtrl *CMainFrame::GetOutputWindow() const{ return m_outputWindow;}CConfigTree *CMainFrame::GetTreeCtrl() const{ return m_treeWindow;}CValueWindow *CMainFrame::GetValueWindow() const{ return m_valueWindow;}CInfoWindow *CMainFrame::GetInfoWindow() const{ return m_infoWindow;}CPropertyList *CMainFrame::GetPropertyListWindow() const{ return m_propertyListWindow;}void CMainFrame::OnSize(wxSizeEvent & WXUNUSED(event)){ wxLayoutAlgorithm layout; layout.LayoutFrame(this);}void CMainFrame::OnSashDrag(wxSashEvent & event){ if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) return; switch (event.GetId()) { case ID_CONFIG_SASH_WINDOW: m_configSashWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 2000)); break; case ID_PROPERTIES_SASH_WINDOW: m_propertiesSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; case ID_SHORT_DESCR_SASH_WINDOW: m_infoSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; case ID_OUTPUT_SASH_WINDOW: m_outputSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; } wxLayoutAlgorithm layout; if (!layout.LayoutFrame(this)) { wxNode *node = (wxNode *) GetChildren().GetFirst(); while (node) { wxWindow *win = (wxWindow *) node->GetData(); if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow))) { wxSashLayoutWindow *sashWin = (wxSashLayoutWindow *) win; wxSize sz = sashWin->GetSize(); sashWin->SetDefaultSize(sz); } node = node->GetNext(); } }}/* ------------------------- Menu Events ------------------------- */void CMainFrame::OnQuit(wxCommandEvent & WXUNUSED(event)){ Close();}void CMainFrame::OnSettings(wxCommandEvent& WXUNUSED(event)){ CSettingsDialog dialog(this); dialog.ShowModal();}void CMainFrame::OnGenerateBuildTree(wxCommandEvent & WXUNUSED(event)){ CNutConfDoc *doc = wxGetApp().GetNutConfDoc(); CSettings *cfg = wxGetApp().GetSettings(); wxString str; str += wxT("\nSource directory: "); str += cfg->m_source_dir; str += wxT("\nBuild directory: "); str += cfg->m_buildpath; str += wxT("\nTarget platform: "); str += cfg->m_platform; str += wxT("\n\nDo you like to generate this build tree?\n"); if(wxMessageBox(str, wxT("Generate Build"), wxOK | wxCANCEL | wxICON_QUESTION, this) == wxOK) { if (doc) { doc->GenerateBuildTree(); } }}void CMainFrame::OnBuildNutOS(wxCommandEvent & WXUNUSED(event)){ CSettings *cfg = wxGetApp().GetSettings(); wxString str; str += wxT("\nSource directory: "); str += cfg->m_source_dir; str += wxT("\nBuild directory: "); str += cfg->m_buildpath; str += wxT("\nTarget platform: "); str += cfg->m_platform; if(!cfg->m_lib_dir.IsEmpty()) { str += wxT("\nInstall directory: "); str += cfg->m_lib_dir; } str += wxT("\n\nDo you like to build the Nut/OS libraries?\n"); if(wxMessageBox(str, wxT("Build Nut/OS"), wxOK | wxCANCEL | wxICON_QUESTION, this) == wxOK) { if(!wxGetApp().Build(wxT("clean"))) { if(wxMessageBox(wxT("Cleaning build tree failed! Continue?"), wxT("Build"), wxYES_NO | wxICON_HAND) != wxYES) { return; } } if(!wxGetApp().Build()) { if(wxMessageBox(wxT("Building Nut/OS failed! Continue?"), wxT("Build"), wxYES_NO | wxICON_HAND) != wxYES) { return; } } if(!cfg->m_lib_dir.IsEmpty()) { if(!wxGetApp().Build(wxT("install"))) { wxMessageBox(wxT("Installing Nut/OS failed!"), wxT("Build"), wxYES_NO | wxICON_HAND); } } }}void CMainFrame::OnBuildLibraries(wxCommandEvent &event){ OnGenerateBuildTree(event); OnBuildNutOS(event);}void CMainFrame::OnCreateSampleDir(wxCommandEvent & WXUNUSED(event)){ CNutConfDoc *doc = wxGetApp().GetNutConfDoc(); CSettings *cfg = wxGetApp().GetSettings(); wxString app_source = cfg->m_source_dir + wxT("/app"); wxString str; str += wxT("\nSource directory: "); str += app_source; str += wxT("\nTarget directory: "); str += cfg->m_app_dir; str += wxT("\nProgrammer "); str += cfg->m_programmer; str += wxT("\n\nDo you like to create the sample directory?\n"); if(wxMessageBox(str, wxT("Creating samples"), wxOK | wxCANCEL | wxICON_QUESTION, this) == wxOK) { if (doc) { doc->GenerateApplicationTree(); } }}void CMainFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event)){ wxToolBar *tbar = GetToolBar(); if (tbar == NULL) { CreateNutToolBar(); } else { delete tbar; SetToolBar(NULL); }}void CMainFrame::OnToggleToolbarSize(wxCommandEvent& WXUNUSED(event)){ wxToolBar *tbar = GetToolBar(); if (tbar) { delete tbar; SetToolBar(NULL); } m_smallToolbar = !m_smallToolbar; CreateNutToolBar();}void CMainFrame::OnHelp(wxCommandEvent& event){ m_help.DisplayContents();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -