How to activate a view
a2dView is most of the time activated via events from wxWidgets when a wxWidgets gets the focus or the wxWidgets containing the a2dView (also nested as a child of a wxFrame) is activated. One can force a view to be active by calling:
a2dView::Activate( true )
this leads to one of these depending if you are using only docview module or also the canvas module:
See a2dView::Activate() for how the wxEVT_ACTIVATE_VIEW is distributed via a2dObject::DistributeEvent(). And also notice that there is yet another one set direct up the m_display window chain, called wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD. This last one make the window containing the view, know what is the their current view.
1 a2dDocumentCommandProcessor::SetActiveView( a2dView* )
So when is a2dView::Activate() itself called? The a2dView::ProcessEvent() takes the following events to do that:
The above event or coming from the m_display of the a2dView, being a a2dDocumentFrame or a2dViewWindow derived class, which have m_view pointer them selfs, and event processing to redirect above event to the a2dView before treating the event themselfs. Notice also a2dDocumentFrame::OnActivateViewSentFromChild() which sets this pointer.
There or several reasons to activate a a2dView without an event doing it, search for Activate() in docviewref.cpp for knowing when. The main reason for calling it so often, is to let the the commandprocessor have the current active view set correctly or as expected.
A related topic DetectActivateView.