Add public wxDocManager::GetAnyUsableView().

This method tries to find the current view harder than GetCurrentView() and
always returns a non-NULL view if there are any open documents at all.

This is used by wxDocManager internally to find the view to apply the user
commands to and will also be needed in the upcoming changes outside of
wxDocManager, so just make this method public, as it seems that it could be
useful in user code too, especially if we could use some better fallback than
the first opened document (e.g. the last document the user interacted with
would be better).

This also clarifies the confusion between GetCurrentView() and GetActiveView(),
see #13296.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-05-04 23:59:43 +00:00
parent 9fe942190d
commit de28042337
3 changed files with 28 additions and 11 deletions

View File

@@ -1185,7 +1185,7 @@ void wxDocManager::OnMRUFileNotExist(unsigned n, const wxString& filename)
void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
{
wxView *view = GetActiveView();
wxView *view = GetAnyUsableView();
if (!view)
return;
@@ -1219,7 +1219,7 @@ wxPreviewFrame* wxDocManager::CreatePreviewFrame(wxPrintPreviewBase* preview,
void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
{
wxBusyCursor busy;
wxView *view = GetActiveView();
wxView *view = GetAnyUsableView();
if (!view)
return;
@@ -1348,7 +1348,7 @@ void wxDocManager::OnUpdateRedo(wxUpdateUIEvent& event)
cmdproc->SetMenuStrings();
}
wxView *wxDocManager::GetActiveView() const
wxView *wxDocManager::GetAnyUsableView() const
{
wxView *view = GetCurrentView();
@@ -1374,7 +1374,7 @@ wxView *wxDocManager::GetActiveView() const
bool wxDocManager::TryBefore(wxEvent& event)
{
wxView * const view = GetActiveView();
wxView * const view = GetAnyUsableView();
return view && view->ProcessEventLocally(event);
}
@@ -1570,7 +1570,7 @@ bool wxDocManager::FlushDoc(wxDocument *WXUNUSED(doc))
wxDocument *wxDocManager::GetCurrentDocument() const
{
wxView * const view = GetActiveView();
wxView * const view = GetAnyUsableView();
return view ? view->GetDocument() : NULL;
}