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
virtual void ActivateView(wxView *view, bool activate = true);
virtual wxView *GetCurrentView() const { return m_currentView; }
+ // This method tries to find an active view harder than GetCurrentView():
+ // if the latter is NULL, it also checks if we don't have just a single
+ // view and returns it then.
+ wxView *GetAnyUsableView() const;
+
+
#ifndef __VISUALC6__
wxDocVector GetDocumentsVector() const;
wxDocTemplateVector GetTemplatesVector() const;
// return the command processor for the current document, if any
wxCommandProcessor *GetCurrentCommandProcessor() const;
- // this method tries to find an active view harder than GetCurrentView():
- // if the latter is NULL, it also checks if we don't have just a single
- // view and returns it then
- wxView *GetActiveView() const;
-
int m_defaultDocumentNameCounter;
int m_maxDocsOpen;
wxList m_docs;
*/
virtual wxDocTemplate* FindTemplateForPath(const wxString& path);
+ /**
+ Returns the view to apply a user command to.
+
+ This method tries to find the view that the user wants to interact
+ with. It returns the same view as GetCurrentDocument() if there is any
+ currently active view but falls back to the first view of the first
+ document if there is no active view.
+
+ @since 2.9.5
+ */
+ wxView* GetAnyUsableView() const;
+
/**
Returns the document associated with the currently active view (if
any).
wxDocument* GetCurrentDocument() const;
/**
- Returns the currently active view
+ Returns the currently active view.
+
+ This method can return @NULL if no view is currently active.
+
+ @see GetAnyUsableView()
*/
virtual wxView* GetCurrentView() const;
void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
{
- wxView *view = GetActiveView();
+ wxView *view = GetAnyUsableView();
if (!view)
return;
void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
{
wxBusyCursor busy;
- wxView *view = GetActiveView();
+ wxView *view = GetAnyUsableView();
if (!view)
return;
cmdproc->SetMenuStrings();
}
-wxView *wxDocManager::GetActiveView() const
+wxView *wxDocManager::GetAnyUsableView() const
{
wxView *view = GetCurrentView();
bool wxDocManager::TryBefore(wxEvent& event)
{
- wxView * const view = GetActiveView();
+ wxView * const view = GetAnyUsableView();
return view && view->ProcessEventLocally(event);
}
wxDocument *wxDocManager::GetCurrentDocument() const
{
- wxView * const view = GetActiveView();
+ wxView * const view = GetAnyUsableView();
return view ? view->GetDocument() : NULL;
}