-
- // Processing continues to next OnSize
- event.Skip();
-}
-
-void wxNotebook::OnSelChange(wxBookCtrlEvent& event)
-{
- // is it our tab control?
- if ( event.GetEventObject() == this )
- ChangePage(event.GetOldSelection(), event.GetSelection());
-
- // we want to give others a chance to process this message as well
- event.Skip();
-}
-
-void wxNotebook::OnSetFocus(wxFocusEvent& event)
-{
- // set focus to the currently selected page if any
- if ( m_nSelection != -1 )
- m_pages[m_nSelection]->SetFocus();
-
- event.Skip();
-}
-
-void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
-{
- if ( event.IsWindowChange() )
- {
- // change pages
- AdvanceSelection( event.GetDirection() );
- }
- else
- {
- // we get this event in 2 cases
- //
- // a) one of our pages might have generated it because the user TABbed
- // out from it in which case we should propagate the event upwards and
- // our parent will take care of setting the focus to prev/next sibling
- //
- // or
- //
- // b) the parent panel wants to give the focus to us so that we
- // forward it to our selected page. We can't deal with this in
- // OnSetFocus() because we don't know which direction the focus came
- // from in this case and so can't choose between setting the focus to
- // first or last panel child
- wxWindow *parent = GetParent();
-
- // the cast is here to fix a GCC ICE
- if ( ((wxWindow*)event.GetEventObject()) == parent )
- {
- // no, it doesn't come from child, case (b): forward to a page
- if ( m_nSelection != -1 )
- {
- // so that the page knows that the event comes from it's parent
- // and is being propagated downwards
- event.SetEventObject( this );
-
- wxWindow *page = m_pages[m_nSelection];
- if ( !page->HandleWindowEvent( event ) )
- {
- page->SetFocus();
- }
- //else: page manages focus inside it itself
- }
- else
- {
- // we have no pages - still have to give focus to _something_
- SetFocus();
- }
- }
- else
- {
- // it comes from our child, case (a), pass to the parent
- if ( parent )
- {
- event.SetCurrentFocus( this );
- parent->HandleWindowEvent( event );
- }
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook base class virtuals
-// ----------------------------------------------------------------------------
-
-#if wxUSE_CONSTRAINTS
-
-// override these 2 functions to do nothing: everything is done in OnSize
-
-void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
-{
- // don't set the sizes of the pages - their correct size is not yet known
- wxControl::SetConstraintSizes( false );
-}
-
-bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
-{
- return true;
-}
-
-#endif // wxUSE_CONSTRAINTS
-
-void wxNotebook::Command(wxCommandEvent& WXUNUSED(event))
-{
- wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook helper functions
-// ----------------------------------------------------------------------------
-
-// hide the currently active panel and show the new one
-void wxNotebook::ChangePage(int nOldSel, int nSel)
-{
- if (nOldSel == nSel)
- return;
-
- if ( nOldSel != -1 )
- m_pages[nOldSel]->Show( false );
-
- if ( nSel != -1 )
- {
- wxNotebookPage *pPage = m_pages[nSel];
- pPage->Show( true );
- pPage->SetFocus();
- }
-
- m_nSelection = nSel;
- m_peer->SetValue( m_nSelection + 1 ) ;
-}
-
-wxInt32 wxNotebook::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
-{
- OSStatus status = eventNotHandledErr ;
-
- SInt32 newSel = m_peer->GetValue() - 1 ;
- if ( newSel != m_nSelection )
- {
- wxBookCtrlEvent changing(
- wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
- newSel , m_nSelection );
- changing.SetEventObject( this );
- HandleWindowEvent( changing );
-
- if ( changing.IsAllowed() )
- {
- wxBookCtrlEvent event(
- wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
- newSel, m_nSelection );
- event.SetEventObject( this );
- HandleWindowEvent( event );
- }
- else
- {
- m_peer->SetValue( m_nSelection + 1 ) ;
- }
-
- status = noErr ;
- }
-
- return (wxInt32)status ;