📄 mainwin.cpp
字号:
wxSize frameSize = GetClientSize(); wxSize configSize = m_configSashWindow->GetSize(); if ((frameSize.x - configSize.x) < 5) { // We must resize the config window m_configSashWindow->SetDefaultSize(wxSize(frameSize.x/2, configSize.y)); } } wxLayoutAlgorithm layout; layout.LayoutFrame(this); }}void ecMainFrame::OnUpdateToggleWindow(wxUpdateUIEvent& event){ wxWindow* win = NULL; switch (event.GetId()) { case ecID_TOGGLE_CONFLICTS: win = m_conflictsSashWindow; break; case ecID_TOGGLE_PROPERTIES: win = m_propertiesSashWindow; break; case ecID_TOGGLE_MEMORY: win = m_memorySashWindow; break; case ecID_TOGGLE_SHORT_DESCR: win = m_shortDescrSashWindow; break; case ecID_TOGGLE_OUTPUT: win = m_outputSashWindow; break; } if (win) { event.Enable( TRUE ); event.Check( win->IsShown() ); // Not implemented#if !ecUSE_MLT if (event.GetId() == ecID_TOGGLE_MEMORY) event.Enable( FALSE );#endif }}void ecMainFrame::OnUpdateDisable(wxUpdateUIEvent& event){ event.Enable( FALSE );}void ecMainFrame::OnToggleToolbar(wxCommandEvent& event){ GetToolBar()->Show( ! GetToolBar()->IsShown() ); wxSizeEvent sizeEvent(GetSize(), GetId()); GetEventHandler()->ProcessEvent(sizeEvent);#ifdef __WXGTK__ GtkOnSize( GetPosition().x, GetPosition().y, GetSize().x, GetSize().y);#endif}void ecMainFrame::OnUpdateToggleToolbar(wxUpdateUIEvent& event){ event.Check( GetToolBar()->IsShown() );}// Respond to a sash drag operation, by setting the new size// for this window and then recalculating the layout.void ecMainFrame::OnSashDrag(wxSashEvent& event){ if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) return; switch (event.GetId()) { case ecID_CONFIG_SASH_WINDOW: { m_configSashWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 2000)); break; } case ecID_CONFLICTS_SASH_WINDOW: { // Change the height of the properties window so we don't affect the // short description window int deltaY = event.GetDragRect().height - m_conflictsSashWindow->GetSize().y; int propertiesHeight = 0; if (m_propertiesSashWindow->IsShown()) { propertiesHeight = m_propertiesSashWindow->GetSize().y - deltaY ; if (propertiesHeight <= 0) return; else m_propertiesSashWindow->SetDefaultSize(wxSize(2000, propertiesHeight)); } m_conflictsSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; } case ecID_PROPERTIES_SASH_WINDOW: { m_propertiesSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; } case ecID_SHORT_DESCR_SASH_WINDOW: { m_shortDescrSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; } case ecID_MEMORY_SASH_WINDOW: { m_memorySashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; } case ecID_OUTPUT_SASH_WINDOW: { m_outputSashWindow->SetDefaultSize(wxSize(2000, event.GetDragRect().height)); break; } default: { wxFAIL_MSG( _("Shouldn't get here.") ); break; } } if (event.GetId() == ecID_MEMORY_SASH_WINDOW || event.GetId() == ecID_OUTPUT_SASH_WINDOW) { // Special processing so we don't spoil the layout of the // conflicts/properties/short description windows wxList minorWindows; GetMinorWindows(minorWindows); int memoryLayoutHeight = m_memorySashWindow->IsShown() ? m_memorySashWindow->GetSize().y : 0; int outputHeight = m_memorySashWindow->IsShown() ? m_outputSashWindow->GetSize().y : 0; int cx, cy; GetClientSize(& cx, & cy); // Calculate how much space will be left after this drag operation. int heightLeft; if (event.GetId() == ecID_MEMORY_SASH_WINDOW) heightLeft = cy - outputHeight - event.GetDragRect().height; else heightLeft = cy - memoryLayoutHeight - event.GetDragRect().height; DivideSpaceEvenly(minorWindows, wxSize(0, heightLeft), wxVERTICAL); RestoreDefaultWindowSizes(minorWindows); } wxLayoutAlgorithm layout; if (!layout.LayoutFrame(this)) { // If layout failed, restored default sizes. wxNode* node = GetChildren().First(); while (node) { wxWindow* win = (wxWindow*) node->Data(); if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow))) { wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) win; wxSize sz = sashWin->GetSize(); sashWin->SetDefaultSize(sz); } node = node->Next(); } } }void ecMainFrame::OnIdle(wxIdleEvent& event){ // Normal idle processing wxFrame::OnIdle(event); wxString text; if (GetStatusBar()) text = GetStatusBar()->GetStatusText(0); // Set the title if we have no document if (!wxGetApp().GetConfigToolDoc() && GetTitle() != wxGetApp().GetSettings().GetAppName()) SetTitle(wxGetApp().GetSettings().GetAppName()); if ( wxGetApp().m_pipedProcess && wxGetApp().m_pipedProcess->HasInput() ) { event.RequestMore(); } if ( wxGetApp().m_pipedProcess ) { if (text != _("Building...")) SetStatusText(_("Building..."), 0); } else if (text != _("Ready")) SetStatusText(_("Ready"), 0);}void ecMainFrame::OnCloseWindow(wxCloseEvent& event){ wxBusyCursor busy; if (!wxGetApp().GetDocManager()->Clear(FALSE) && event.CanVeto()) { event.Veto(); return; } if (wxGetApp().m_pipedProcess) wxGetApp().m_pipedProcess->Detach(); if (m_findDialog) m_findDialog->Close(TRUE); wxGetApp().DestroyHelpController(); if (IsMaximized()) wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_MAXIMIZED ; else if (IsIconized()) wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_MINIMIZED ; else wxGetApp().GetSettings().m_frameStatus = ecSHOW_STATUS_NORMAL ; if (!IsMaximized() && !IsIconized()) wxGetApp().GetSettings().m_frameSize = GetRect(); wxGetApp().GetSettings().m_showToolBar = GetToolBar()->IsShown(); wxGetApp().GetSettings().m_treeSashSize = m_configSashWindow->GetSize(); wxGetApp().GetSettings().m_propertiesSashSize = m_propertiesSashWindow->GetSize(); wxGetApp().GetSettings().m_conflictsSashSize = m_conflictsSashWindow->GetSize(); wxGetApp().GetSettings().m_shortDescrSashSize = m_shortDescrSashWindow->GetSize(); wxGetApp().GetSettings().m_memorySashSize = m_memorySashWindow->GetSize(); wxGetApp().GetSettings().m_outputSashSize = m_outputSashWindow->GetSize(); wxGetApp().GetSettings().m_configPaneWidth = m_splitter->GetSashPosition(); event.Skip();}// Enumerate the visible 'minor' sash windows,// i.e. those in the top-right segment of the framevoid ecMainFrame::GetMinorWindows(wxList& list){ if (m_conflictsSashWindow->IsShown()) list.Append(m_conflictsSashWindow); if (m_propertiesSashWindow->IsShown()) list.Append(m_propertiesSashWindow); if (m_shortDescrSashWindow->IsShown()) list.Append(m_shortDescrSashWindow);}// Get all visible sash windowsvoid ecMainFrame::GetSashWindows(wxList& list){ wxNode* node = GetChildren().First(); while (node) { wxWindow* win = (wxWindow*) node->Data(); if (win->IsKindOf(CLASSINFO(wxSashLayoutWindow)) && win->IsShown()) { list.Append(win); } node = node->Next(); }}// Divide the given space evenly amongst some windowsvoid ecMainFrame::DivideSpaceEvenly(wxList& list, const wxSize& space, int orient){ if (list.Number() == 0) return; // Find total size first int totalSize = 0; double proportion = 0.0; wxNode* node = list.First(); while (node) { wxWindow* win = (wxWindow*) node->Data(); wxSize sz = win->GetSize(); if (orient == wxHORIZONTAL) totalSize += sz.x; else totalSize += sz.y; node = node->Next(); } if (orient == wxHORIZONTAL) { if (totalSize == 0) return; proportion = ((double) space.x / (double) totalSize); } else { if (totalSize == 0) return; proportion = ((double) space.y / (double) totalSize); } node = list.First(); while (node) { wxWindow* win = (wxWindow*) node->Data(); wxSize sz = win->GetSize(); if (orient == wxHORIZONTAL) sz.x = (int) (sz.x * proportion); else sz.y = (int) (sz.y * proportion); win->SetSize(sz); node = node->Next(); }}// Restore the sash window default size from the actual window sizevoid ecMainFrame::RestoreDefaultWindowSizes(wxList& list){ wxNode* node = list.First(); while (node) { wxSashLayoutWindow* sashWin = (wxSashLayoutWindow*) node->Data(); wxSize sz = sashWin->GetSize(); sashWin->SetDefaultSize(sz); node = node->Next(); }}void ecMainFrame::OnHelpEcos(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); if (doc) { wxString strURL(wxT("index.html")); doc->QualifyDocURL(strURL, FALSE); switch (wxGetApp().GetSettings().m_eUseCustomBrowser) { case ecInternal: { if (wxGetApp().HasHelpController()) wxGetApp().GetHelpController().DisplayContents(); break; } default: { doc->ShowURL(strURL); } } }}void ecMainFrame::OnHelpConfigtool(wxCommandEvent& event)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -