X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..66b6b04535cf261b7bae7da77332835b242abd04:/src/mac/notebook.cpp?ds=sidebyside diff --git a/src/mac/notebook.cpp b/src/mac/notebook.cpp index 312dd0f3d3..3cb269c3cc 100644 --- a/src/mac/notebook.cpp +++ b/src/mac/notebook.cpp @@ -24,7 +24,7 @@ #include #include #include - +#include // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -32,11 +32,15 @@ // check that the page index is valid #define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount())) +const short kwxMacTabLeftMargin = 16 ; +const short kwxMacTabTopMargin = 30 ; +const short kwxMacTabRightMargin = 16 ; +const short kwxMacTabBottomMargin = 16 ; + // ---------------------------------------------------------------------------- // event table // ---------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARIES BEGIN_EVENT_TABLE(wxNotebook, wxControl) EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) @@ -47,7 +51,6 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) -#endif // ============================================================================ // implementation @@ -91,21 +94,16 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { - // base init - SetName(name); - SetParent(parent); - - m_windowId = id == -1 ? NewControlId() : id; - - // style - m_windowStyle = style; - - if ( parent != NULL ) - parent->AddChild(this); - - // TODO - - return FALSE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } // dtor @@ -123,8 +121,7 @@ int wxNotebook::GetPageCount() const int wxNotebook::GetRowCount() const { - // TODO - return 0; + return 1; } int wxNotebook::SetSelection(int nPage) @@ -132,9 +129,11 @@ int wxNotebook::SetSelection(int nPage) wxASSERT( IS_VALID_PAGE(nPage) ); ChangePage(m_nSelection, nPage); - - // TODO - return 0; + SetControlValue( m_macControl , m_nSelection + 1 ) ; +// Boolean enabled = true ; + +// SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled ); + return m_nSelection; } void wxNotebook::AdvanceSelection(bool bForward) @@ -246,7 +245,19 @@ bool wxNotebook::InsertPage(int nPage, wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); - // TODO: insert native widget page + ControlTabInfoRec tie ; + Boolean enabled = true ; + if ( nPage + 1 > GetControlMaximum( m_macControl ) ) + { + SetControlMaximum( m_macControl , nPage + 1 ) ; + } + + tie.version = 0 ; + tie.iconSuiteID = 0 ; + strcpy( (char*) tie.name , strText ) ; + c2pstr( (char*) tie.name ) ; + SetControlData( m_macControl, nPage + 1, kControlTabInfoTag , sizeof( ControlTabInfoRec) , (char*) &tie ) ; + SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled ); // save the pointer to the page m_aPages.Insert(pPage, nPage); @@ -258,6 +269,9 @@ bool wxNotebook::InsertPage(int nPage, else if ( m_nSelection == -1 ) m_nSelection = 0; + // don't show pages by default (we'll need to adjust their size first) + pPage->Show( FALSE ) ; + return TRUE; } @@ -290,7 +304,9 @@ void wxNotebook::OnSize(wxSizeEvent& event) unsigned int nCount = m_aPages.Count(); for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_aPages[nPage]; - pPage->SetSize(0, 0, w, h); + pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); +// pPage->SetSize(0, 0, w, h); if ( pPage->GetAutoLayout() ) pPage->Layout(); } @@ -362,7 +378,16 @@ void wxNotebook::Command(wxCommandEvent& event) // hide the currently active panel and show the new one void wxNotebook::ChangePage(int nOldSel, int nSel) { - wxASSERT( nOldSel != nSel ); // impossible + // it's not an error (the message may be generated by the tab control itself) + // and it may happen - just do nothing + if ( nSel == nOldSel ) + { + wxNotebookPage *pPage = m_aPages[nSel]; + pPage->Show(FALSE); + pPage->Show(TRUE); + pPage->SetFocus(); + return; + } if ( nOldSel != -1 ) { m_aPages[nOldSel]->Show(FALSE); @@ -375,3 +400,11 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) m_nSelection = nSel; } +void wxNotebook::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControlValue(m_macControl) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); +} +