static const size_t INVALID_PAGE = (size_t)-1;
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// implementation
// ============================================================================
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
// ----------------------------------------------------------------------------
// wxNotebook creation
m_sizePad = GetRenderer()->GetTabPadding();
- SetBestSize(size);
+ SetInitialSize(size);
CreateInputHandler(wxINP_HANDLER_NOTEBOOK);
wxString wxNotebook::GetPageText(size_t nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("invalid notebook page") );
return m_titles[nPage];
}
bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), false, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("invalid notebook page") );
if ( strText != m_titles[nPage] )
{
int wxNotebook::GetPageImage(size_t nPage) const
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("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, wxT("invalid notebook page") );
wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false,
- _T("invalid image index in SetPageImage()") );
+ wxT("invalid image index in SetPageImage()") );
if ( nImage != m_images[nPage] )
{
int wxNotebook::DoSetSelection(size_t nPage, int flags)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("invalid notebook page") );
if ( (size_t)nPage == m_sel )
{
return m_sel;
}
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
- if (flags & SetSelection_SendEvent)
+ if ( flags & SetSelection_SendEvent )
{
- // event handling
- event.SetSelection(nPage);
- event.SetOldSelection(m_sel);
- event.SetEventObject(this);
- if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
+ if ( !SendPageChangingEvent(nPage) )
{
// program doesn't allow the page change
return m_sel;
m_pages[m_sel]->Show();
}
- if (flags & SetSelection_SendEvent)
+ if ( flags & SetSelection_SendEvent )
{
// event handling
- event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
- GetEventHandler()->ProcessEvent(event);
+ SendPageChangedEvent(selOld);
}
return selOld;
{
size_t nPages = GetPageCount();
wxCHECK_MSG( nPage == nPages || IS_VALID_PAGE(nPage), false,
- _T("invalid notebook page in InsertPage()") );
+ wxT("invalid notebook page in InsertPage()") );
// modify the data
m_pages.Insert(pPage, nPage);
wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL, wxT("invalid notebook page") );
wxNotebookPage *page = m_pages[nPage];
m_pages.RemoveAt(nPage);
void wxNotebook::RefreshTab(int page, bool forceSelected)
{
- wxCHECK_RET( IS_VALID_PAGE(page), _T("invalid notebook page") );
+ wxCHECK_RET( IS_VALID_PAGE(page), wxT("invalid notebook page") );
wxRect rect = GetTabRect(page);
if ( forceSelected || ((size_t)page == m_sel) )
switch ( GetTabOrientation() )
{
default:
- wxFAIL_MSG(_T("unknown tab orientation"));
+ wxFAIL_MSG(wxT("unknown tab orientation"));
// fall through
case wxTOP:
wxRect wxNotebook::GetTabRect(int page) const
{
wxRect rect;
- wxCHECK_MSG( IS_VALID_PAGE(page), rect, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(page), rect, wxT("invalid notebook page") );
// calc the size of this tab and of the preceding ones
wxCoord widthThis, widthBefore;
void wxNotebook::GetTabSize(int page, wxCoord *w, wxCoord *h) const
{
- wxCHECK_RET( w && h, _T("NULL pointer in GetTabSize") );
+ wxCHECK_RET( w && h, wxT("NULL pointer in GetTabSize") );
if ( IsVertical() )
{
void wxNotebook::SetTabSize(const wxSize& sz)
{
- wxCHECK_RET( FixedSizeTabs(), _T("SetTabSize() ignored") );
+ wxCHECK_RET( FixedSizeTabs(), wxT("SetTabSize() ignored") );
if ( IsVertical() )
{
wxSize size;
- wxCHECK_MSG( IS_VALID_PAGE(page), size, _T("invalid notebook page") );
+ wxCHECK_MSG( IS_VALID_PAGE(page), size, wxT("invalid notebook page") );
GetTextExtent(m_titles[page], &size.x, &size.y);
switch ( GetTabOrientation() )
{
default:
- wxFAIL_MSG(_T("unknown tab orientation"));
+ wxFAIL_MSG(wxT("unknown tab orientation"));
// fall through
case wxTOP:
void wxNotebook::ScrollTo(int page)
{
- wxCHECK_RET( IS_VALID_PAGE(page), _T("invalid notebook page") );
+ wxCHECK_RET( IS_VALID_PAGE(page), wxT("invalid notebook page") );
// set the first visible tab and offset (easy)
m_firstVisible = (size_t)page;
void wxNotebook::ScrollLastTo(int page)
{
- wxCHECK_RET( IS_VALID_PAGE(page), _T("invalid notebook page") );
+ wxCHECK_RET( IS_VALID_PAGE(page), wxT("invalid notebook page") );
// go backwards until we find the first tab which can be made visible
// without hiding the given one
ScrollTo(m_firstVisible);
// consitency check: the page we were asked to show should be shown
- wxASSERT_MSG( (size_t)page < m_lastVisible, _T("bug in ScrollLastTo") );
+ wxASSERT_MSG( (size_t)page < m_lastVisible, wxT("bug in ScrollLastTo") );
}
// ----------------------------------------------------------------------------