X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/37144cf0f155bb7cea1972e934a4d083bca1b8ca..f5590243955d800aaeee4e2c3b8c4aec14919181:/src/mac/classic/notebmac.cpp?ds=inline diff --git a/src/mac/classic/notebmac.cpp b/src/mac/classic/notebmac.cpp index fbc6c4a092..9bd1c41477 100644 --- a/src/mac/classic/notebmac.cpp +++ b/src/mac/classic/notebmac.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: notebook.cpp +// Name: src/mac/classic/notebmac.cpp // Purpose: implementation of wxNotebook // Author: Stefan Csomor // Modified by: @@ -9,9 +9,7 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "notebook.h" -#endif +#include "wx/wxprec.h" // ============================================================================ // declarations @@ -20,12 +18,17 @@ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- -#include "wx/app.h" -#include "wx/string.h" -#include "wx/log.h" + +#include "wx/notebook.h" + +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/log.h" + #include "wx/app.h" +#endif + #include "wx/imaglist.h" #include "wx/image.h" -#include "wx/notebook.h" #include "wx/mac/uma.h" // ---------------------------------------------------------------------------- // macros @@ -43,7 +46,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING) BEGIN_EVENT_TABLE(wxNotebook, wxControl) - EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) + EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange) EVT_MOUSE_EVENTS(wxNotebook::OnMouse) EVT_SIZE(wxNotebook::OnSize) @@ -96,10 +99,10 @@ static inline int wxMacTabMargin(long nbStyle, long side) } // If the style matches the side asked for then return the tab margin, - // but we have to special case wxNB_TOP since it is zero... - if ( side == wxNB_TOP) + // but we have to special case wxBK_TOP since it is zero... + if ( side == wxBK_TOP) { - if ( nbStyle != 0 && nbStyle & (wxNB_LEFT|wxNB_RIGHT|wxNB_BOTTOM)) + if ( nbStyle != 0 && nbStyle & (wxBK_LEFT|wxBK_RIGHT|wxBK_BOTTOM)) { return otherMargin; } @@ -116,22 +119,22 @@ static inline int wxMacTabMargin(long nbStyle, long side) static inline int wxMacTabLeftMargin(long style) { - return wxMacTabMargin(style, wxNB_LEFT); + return wxMacTabMargin(style, wxBK_LEFT); } static inline int wxMacTabTopMargin(long style) { - return wxMacTabMargin(style, wxNB_TOP); + return wxMacTabMargin(style, wxBK_TOP); } static inline int wxMacTabRightMargin(long style) { - return wxMacTabMargin(style, wxNB_RIGHT); + return wxMacTabMargin(style, wxBK_RIGHT); } static inline int wxMacTabBottomMargin(long style) { - return wxMacTabMargin(style, wxNB_BOTTOM); + return wxMacTabMargin(style, wxBK_BOTTOM); } // ---------------------------------------------------------------------------- @@ -187,19 +190,19 @@ bool wxNotebook::Create(wxWindow *parent, MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; int tabstyle = kControlTabSmallNorthProc ; - if ( HasFlag(wxNB_LEFT) ) + if ( HasFlag(wxBK_LEFT) ) tabstyle = kControlTabSmallWestProc ; - else if ( HasFlag( wxNB_RIGHT ) ) + else if ( HasFlag( wxBK_RIGHT ) ) tabstyle = kControlTabSmallEastProc ; - else if ( HasFlag( wxNB_BOTTOM ) ) + else if ( HasFlag( wxBK_BOTTOM ) ) tabstyle = kControlTabSmallSouthProc ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, tabstyle , (long) this ) ; MacPostControlCreate() ; - return TRUE ; + return true ; } // dtor @@ -229,9 +232,9 @@ void wxNotebook::SetPageSize(const wxSize& size) wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const { wxSize sizeTotal = sizePage; - sizeTotal.x += 2 * m_macHorizontalBorder + wxMacTabLeftMargin(GetWindowStyle()) + + sizeTotal.x += 2 * m_macHorizontalBorder + wxMacTabLeftMargin(GetWindowStyle()) + wxMacTabRightMargin(GetWindowStyle()) ; - sizeTotal.y += 2 * m_macVerticalBorder + wxMacTabTopMargin(GetWindowStyle()) + + sizeTotal.y += 2 * m_macVerticalBorder + wxMacTabTopMargin(GetWindowStyle()) + wxMacTabBottomMargin(GetWindowStyle()) ; return sizeTotal; @@ -267,7 +270,7 @@ wxSize wxNotebook::DoGetBestSize() const int wxNotebook::SetSelection(size_t nPage) { - wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); if ( int(nPage) != m_nSelection ) { @@ -309,16 +312,16 @@ wxString wxNotebook::GetPageText(size_t nPage) const int wxNotebook::GetPageImage(size_t nPage) const { - wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") ); return m_images[nPage]; } bool wxNotebook::SetPageImage(size_t nPage, int nImage) { - wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), false, _T("invalid notebook page") ); - wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), FALSE, + wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false, _T("invalid image index in SetPageImage()") ); if ( nImage != m_images[nPage] ) @@ -331,7 +334,7 @@ bool wxNotebook::SetPageImage(size_t nPage, int nImage) MacSetupTabs() ; } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -364,7 +367,7 @@ bool wxNotebook::DeleteAllPages() MacSetupTabs(); m_nSelection = -1 ; InvalidateBestSize(); - return TRUE; + return true; } @@ -403,13 +406,13 @@ bool wxNotebook::InsertPage(size_t nPage, // if the inserted page is before the selected one, we must update the // index of the selected page - if ( int(nPage) <= m_nSelection ) + if ( int(nPage) <= m_nSelection ) { m_nSelection++; // while this still is the same page showing, we need to update the tabs SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; } - + // some page should be selected: either this one or the first one if there // is still no selection int selNew = -1; @@ -457,7 +460,7 @@ void wxNotebook::MacSetupTabs() // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we // unregister it) in case this will ever lead to having the same icon everywhere add some kind // of static counter - const wxBitmap* bmap = GetImageList()->GetBitmap( GetPageImage(ii ) ) ; + const wxBitmap* bmap = GetImageList()->GetBitmapPtr( GetPageImage(ii ) ) ; if ( bmap ) { wxBitmap scaledBitmap ; @@ -480,10 +483,10 @@ void wxNotebook::MacSetupTabs() sizeof( info ), (Ptr)&info ); wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ; if ( UMAGetSystemVersion() < 0x1030 ) - { - UnregisterIconRef( 'WXNG' , (OSType) 1 ) ; + { + UnregisterIconRef( 'WXNG' , (OSType) 1 ) ; } - + ReleaseIconRef( iconRef ) ; DisposeHandle( (Handle) iconFamily ) ; } @@ -500,12 +503,12 @@ wxRect wxNotebook::GetPageRect() const // fit the notebook page to the tab control's display area int w, h; GetSize(&w, &h); - - return wxRect( - wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder, + + return wxRect( + wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder, wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder, w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder, - h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder); + h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder); } // ---------------------------------------------------------------------------- // wxNotebook callbacks @@ -614,13 +617,13 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse)) { - // don't set the sizes of the pages - their correct size is not yet known - wxControl::SetConstraintSizes(FALSE); + // 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; + return true; } #endif // wxUSE_CONSTRAINTS @@ -637,18 +640,18 @@ void wxNotebook::Command(wxCommandEvent& event) // hide the currently active panel and show the new one void wxNotebook::ChangePage(int nOldSel, int nSel) { - if ( nOldSel != -1 ) + if ( nOldSel != -1 ) { - m_pages[nOldSel]->Show(FALSE); + m_pages[nOldSel]->Show(false); } if ( nSel != -1 ) { wxNotebookPage *pPage = m_pages[nSel]; - pPage->Show(TRUE); + pPage->Show(true); pPage->SetFocus(); } - + m_nSelection = nSel; SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; } @@ -729,4 +732,3 @@ void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , ProcessEvent(event); #endif } -