///////////////////////////////////////////////////////////////////////////////
-// Name: notebook.cpp
+// Name: src/mac/classic/notebmac.cpp
// Purpose: implementation of wxNotebook
// Author: Stefan Csomor
// Modified by:
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "notebook.h"
-#endif
+#include "wx/wxprec.h"
// ============================================================================
// declarations
// ----------------------------------------------------------------------------
// 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
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)
}
// 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;
}
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);
}
// ----------------------------------------------------------------------------
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 ;
tabstyle , (long) this ) ;
MacPostControlCreate() ;
- return TRUE ;
+ return true ;
}
// dtor
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;
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 )
{
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] )
MacSetupTabs() ;
}
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
MacSetupTabs();
m_nSelection = -1 ;
InvalidateBestSize();
- return TRUE;
+ return true;
}
// 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;
// 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 ;
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 ) ;
}
// 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
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
// 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 ) ;
}
ProcessEvent(event);
#endif
}
-