X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/62e1ba759a61210a7facf7b9de39fc8bf0f4b479..a7cfad3ad6bc8080b33a0878a14b1c02ca33fe3e:/src/univ/notebook.cpp?ds=inline diff --git a/src/univ/notebook.cpp b/src/univ/notebook.cpp index 252723acd7..5a1d6c87df 100644 --- a/src/univ/notebook.cpp +++ b/src/univ/notebook.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: univ/notebook.cpp +// Name: src/univ/notebook.cpp // Purpose: wxNotebook implementation // Author: Vadim Zeitlin // Modified by: @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "univnotebook.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ @@ -29,27 +25,50 @@ #if wxUSE_NOTEBOOK -#include "wx/imaglist.h" #include "wx/notebook.h" + +#ifndef WX_PRECOMP + #include "wx/dcmemory.h" +#endif + +#include "wx/imaglist.h" #include "wx/spinbutt.h" -#include "wx/dcmemory.h" #include "wx/univ/renderer.h" // ---------------------------------------------------------------------------- -// macros +// wxStdNotebookInputHandler: translates SPACE and ENTER keys and the left mouse +// click into button press/release actions // ---------------------------------------------------------------------------- -#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount())) +class WXDLLEXPORT wxStdNotebookInputHandler : public wxStdInputHandler +{ +public: + wxStdNotebookInputHandler(wxInputHandler *inphand); + + virtual bool HandleKey(wxInputConsumer *consumer, + const wxKeyEvent& event, + bool pressed); + virtual bool HandleMouse(wxInputConsumer *consumer, + const wxMouseEvent& event); + virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event); + virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event); + virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); + +protected: + void HandleFocusChange(wxInputConsumer *consumer); +}; // ---------------------------------------------------------------------------- -// constants +// macros // ---------------------------------------------------------------------------- -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) +#if 0 +// due to unsigned type nPage is always >= 0 +#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((size_t(nPage)) < GetPageCount())) +#else +#define IS_VALID_PAGE(nPage) (((size_t)nPage) < GetPageCount()) +#endif // ---------------------------------------------------------------------------- // private classes @@ -59,7 +78,7 @@ class wxNotebookSpinBtn : public wxSpinButton { public: wxNotebookSpinBtn(wxNotebook *nb) - : wxSpinButton(nb, -1, + : wxSpinButton(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize, nb->IsVertical() ? wxSP_VERTICAL : wxSP_HORIZONTAL) { @@ -79,15 +98,14 @@ private: }; BEGIN_EVENT_TABLE(wxNotebookSpinBtn, wxSpinButton) - EVT_SPIN(-1, wxNotebookSpinBtn::OnSpin) + EVT_SPIN(wxID_ANY, wxNotebookSpinBtn::OnSpin) END_EVENT_TABLE() // ============================================================================ // implementation // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) -IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase) // ---------------------------------------------------------------------------- // wxNotebook creation @@ -95,8 +113,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) void wxNotebook::Init() { - m_sel = INVALID_PAGE; - m_heightTab = m_widthMax = 0; @@ -116,33 +132,36 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { + if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) + style |= wxBK_TOP; + if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) - return FALSE; + return false; m_sizePad = GetRenderer()->GetTabPadding(); - SetBestSize(size); + SetInitialSize(size); CreateInputHandler(wxINP_HANDLER_NOTEBOOK); - return TRUE; + return true; } // ---------------------------------------------------------------------------- // wxNotebook page titles and images // ---------------------------------------------------------------------------- -wxString wxNotebook::GetPageText(int nPage) const +wxString wxNotebook::GetPageText(size_t nPage) const { - wxCHECK_MSG( IS_VALID_PAGE(nPage), _T(""), _T("invalid notebook page") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("invalid notebook page") ); return m_titles[nPage]; } -bool wxNotebook::SetPageText(int nPage, const wxString& strText) +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] ) { @@ -160,22 +179,22 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText) } } - return TRUE; + return true; } -int wxNotebook::GetPageImage(int 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, wxT("invalid notebook page") ); return m_images[nPage]; } -bool wxNotebook::SetPageImage(int nPage, int nImage) +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()") ); + wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false, + wxT("invalid image index in SetPageImage()") ); if ( nImage != m_images[nPage] ) { @@ -191,7 +210,7 @@ bool wxNotebook::SetPageImage(int nPage, int nImage) RefreshTab(nPage); } - return TRUE; + return true; } wxNotebook::~wxNotebook() @@ -202,101 +221,90 @@ wxNotebook::~wxNotebook() // wxNotebook page switching // ---------------------------------------------------------------------------- -int wxNotebook::SetSelection(int nPage) +int wxNotebook::DoSetSelection(size_t nPage, int flags) { - wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("invalid notebook page") ); - if ( (size_t)nPage == m_sel ) + if ( (int)nPage == m_selection ) { // don't do anything if there is nothing to do - return m_sel; + return m_selection; } - // we need to change m_sel first, before calling RefreshTab() below as + if ( flags & SetSelection_SendEvent ) + { + if ( !SendPageChangingEvent(nPage) ) + { + // program doesn't allow the page change + return m_selection; + } + } + + // we need to change m_selection first, before calling RefreshTab() below as // otherwise the previously selected tab wouldn't be redrawn properly under // wxGTK which calls Refresh() immediately and not during the next event // loop iteration as wxMSW does and as it should - size_t selOld = m_sel; + int selOld = m_selection; - m_sel = nPage; + m_selection = nPage; - if ( selOld != INVALID_PAGE ) + if ( selOld != wxNOT_FOUND ) { - RefreshTab(selOld, TRUE /* this tab was selected */); + RefreshTab(selOld, true /* this tab was selected */); m_pages[selOld]->Hide(); } - if ( m_sel != INVALID_PAGE ) // this is impossible - but test nevertheless + if ( m_selection != wxNOT_FOUND ) // this is impossible - but test nevertheless { if ( HasSpinBtn() ) { // keep it in sync - m_spinbtn->SetValue(m_sel); + m_spinbtn->SetValue(m_selection); } - if ( m_sel < m_firstVisible ) + if ( nPage < m_firstVisible ) { // selection is to the left of visible part of tabs - ScrollTo(m_sel); + ScrollTo(nPage); } - else if ( m_sel > m_lastFullyVisible ) + else if ( nPage > m_lastFullyVisible ) { // selection is to the right of visible part of tabs - ScrollLastTo(m_sel); + ScrollLastTo(nPage); } else // we already see this tab { // no need to scroll - RefreshTab(m_sel); + RefreshTab(nPage); } - m_pages[m_sel]->SetSize(GetPageRect()); - m_pages[m_sel]->Show(); + m_pages[nPage]->SetSize(GetPageRect()); + m_pages[nPage]->Show(); } - return m_sel; -} - -void wxNotebook::ChangePage(int nPage) -{ - wxCHECK_RET( IS_VALID_PAGE(nPage), _T("invalid notebook page") ); - - if ( (size_t)nPage == m_sel ) - { - // nothing to do - return; - } - - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId); - event.SetSelection(nPage); - event.SetOldSelection(m_sel); - event.SetEventObject(this); - if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() ) + if ( flags & SetSelection_SendEvent ) { - // program doesn't allow the page change - return; + // event handling + SendPageChangedEvent(selOld); } - SetSelection(nPage); - - event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); - GetEventHandler()->ProcessEvent(event); + return selOld; } // ---------------------------------------------------------------------------- // wxNotebook pages adding/deleting // ---------------------------------------------------------------------------- -bool wxNotebook::InsertPage(int nPage, +bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, int imageId) { - int nPages = GetPageCount(); - wxCHECK_MSG( nPage == nPages || IS_VALID_PAGE(nPage), FALSE, - _T("invalid notebook page in InsertPage()") ); + size_t nPages = GetPageCount(); + wxCHECK_MSG( nPage == nPages || IS_VALID_PAGE(nPage), false, + wxT("invalid notebook page in InsertPage()") ); // modify the data m_pages.Insert(pPage, nPage); @@ -327,9 +335,10 @@ bool wxNotebook::InsertPage(int nPage, if ( nPages == 0 ) { // always select the first tab to have at least some selection - bSelect = TRUE; + bSelect = true; Relayout(); + Refresh(); } else // not the first tab { @@ -345,13 +354,13 @@ bool wxNotebook::InsertPage(int nPage, pPage->Hide(); } - return TRUE; + return true; } bool wxNotebook::DeleteAllPages() { if ( !wxNotebookBase::DeleteAllPages() ) - return FALSE; + return false; // clear the other arrays as well m_titles.Clear(); @@ -359,20 +368,17 @@ bool wxNotebook::DeleteAllPages() m_accels.Clear(); m_widths.Clear(); - // it is not valid any longer - m_sel = INVALID_PAGE; - // spin button is not needed any more UpdateSpinBtn(); Relayout(); - return TRUE; + return true; } -wxNotebookPage *wxNotebook::DoRemovePage(int 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); @@ -382,31 +388,37 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage) m_images.RemoveAt(nPage); // the spin button might not be needed any more - if ( HasSpinBtn() ) + // 2002-08-12 'if' commented out by JACS on behalf + // of Hans Van Leemputten who + // points out that UpdateSpinBtn should always be called, + // to ensure m_lastVisible is up to date. + // if ( HasSpinBtn() ) { UpdateSpinBtn(); } - int count = GetPageCount(); + size_t count = GetPageCount(); if ( count ) { - if ( m_sel == (size_t)nPage ) + wxASSERT_MSG( m_selection != wxNOT_FOUND, "should have selection" ); + + if ( (size_t)m_selection == nPage ) { // avoid sending event to this page which doesn't exist in the // notebook any more - m_sel = INVALID_PAGE; + m_selection = wxNOT_FOUND; SetSelection(nPage == count ? nPage - 1 : nPage); } - else if ( m_sel > (size_t)nPage ) + else if ( (size_t)m_selection > nPage ) { // no need to change selection, just adjust the index - m_sel--; + m_selection--; } } else // no more tabs left { - m_sel = INVALID_PAGE; + m_selection = wxNOT_FOUND; } // have to refresh everything @@ -421,18 +433,18 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage) void wxNotebook::RefreshCurrent() { - if ( m_sel != INVALID_PAGE ) + if ( m_selection != wxNOT_FOUND ) { - RefreshTab(m_sel); + RefreshTab(m_selection); } } 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) ) + if ( forceSelected || (page == m_selection) ) { const wxSize indent = GetRenderer()->GetTabIndent(); rect.Inflate(indent.x, indent.y); @@ -458,22 +470,24 @@ void wxNotebook::DoDrawTab(wxDC& dc, const wxRect& rect, size_t n) { int image = m_images[n]; -#ifdef __WXMSW__ // FIXME + // Not needed now that wxGenericImageList is being + // used for wxUniversal under MSW +#if 0 // def __WXMSW__ // FIXME int w, h; m_imageList->GetSize(n, w, h); bmp.Create(w, h); wxMemoryDC dc; dc.SelectObject(bmp); dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); - m_imageList->Draw(image, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL, TRUE); + m_imageList->Draw(image, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL, true); dc.SelectObject(wxNullBitmap); #else - bmp = *m_imageList->GetBitmap(image); + bmp = m_imageList->GetBitmap(image); #endif } int flags = 0; - if ( n == m_sel ) + if ( (int)n == m_selection ) { flags |= wxCONTROL_SELECTED; @@ -512,10 +526,20 @@ void wxNotebook::DoDraw(wxControlRenderer *renderer) wxSize sizeSpinBtn = m_spinbtn->GetSize(); if ( IsVertical() ) + { rectTabs.height -= sizeSpinBtn.y; + + // Allow for erasing the line under selected tab + rectTabs.width += 2; + } else + { rectTabs.width -= sizeSpinBtn.x; + // Allow for erasing the line under selected tab + rectTabs.height += 2; + } + dc.SetClippingRegion(rectTabs); } @@ -527,7 +551,7 @@ void wxNotebook::DoDraw(wxControlRenderer *renderer) { GetTabSize(n, &rect.width, &rect.height); - if ( n == m_sel ) + if ( (int)n == m_selection ) { // don't redraw it now as this tab has to be drawn over the other // ones as it takes more place and spills over to them @@ -558,18 +582,23 @@ void wxNotebook::DoDraw(wxControlRenderer *renderer) // now redraw the selected tab if ( rectSel.width ) { - DoDrawTab(dc, rectSel, m_sel); + DoDrawTab(dc, rectSel, m_selection); } + + dc.DestroyClippingRegion(); } // ---------------------------------------------------------------------------- // wxNotebook geometry // ---------------------------------------------------------------------------- -int wxNotebook::HitTest(const wxPoint& pt) const +int wxNotebook::HitTest(const wxPoint& pt, long *flags) const { + if ( flags ) + *flags = wxBK_HITTEST_NOWHERE; + // first check that it is in this window at all - if ( !GetClientRect().Inside(pt) ) + if ( !GetClientRect().Contains(pt) ) { return -1; } @@ -579,7 +608,7 @@ int wxNotebook::HitTest(const wxPoint& pt) const switch ( GetTabOrientation() ) { default: - wxFAIL_MSG(_T("unknown tab orientation")); + wxFAIL_MSG(wxT("unknown tab orientation")); // fall through case wxTOP: @@ -607,8 +636,16 @@ int wxNotebook::HitTest(const wxPoint& pt) const { GetTabSize(n, &rectTabs.width, &rectTabs.height); - if ( rectTabs.Inside(pt) ) + if ( rectTabs.Contains(pt) ) + { + if ( flags ) + { + // TODO: be more precise + *flags = wxBK_HITTEST_ONITEM; + } + return n; + } // move the rectTabs to the next tab if ( IsVertical() ) @@ -630,21 +667,21 @@ bool wxNotebook::IsVertical() const wxDirection wxNotebook::GetTabOrientation() const { long style = GetWindowStyle(); - if ( style & wxNB_BOTTOM ) + if ( style & wxBK_BOTTOM ) return wxBOTTOM; - else if ( style & wxNB_RIGHT ) + else if ( style & wxBK_RIGHT ) return wxRIGHT; - else if ( style & wxNB_LEFT ) + else if ( style & wxBK_LEFT ) return wxLEFT; - // wxNB_TOP == 0 so we don't have to test for it + // wxBK_TOP == 0 so we don't have to test for it return 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; @@ -717,8 +754,16 @@ wxRect wxNotebook::GetTabsPart() const const wxSize indent = GetRenderer()->GetTabIndent(); if ( IsVertical() ) { - rect.x += indent.y; rect.y += indent.x; + if ( dir == wxLEFT ) + { + rect.x += indent.y; + rect.width -= indent.y; + } + else // wxRIGHT + { + rect.width -= indent.y; + } } else // horz { @@ -739,7 +784,7 @@ wxRect wxNotebook::GetTabsPart() const 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() ) { @@ -758,7 +803,7 @@ void wxNotebook::GetTabSize(int page, wxCoord *w, wxCoord *h) const void wxNotebook::SetTabSize(const wxSize& sz) { - wxCHECK_RET( FixedSizeTabs(), _T("SetTabSize() ignored") ); + wxCHECK_RET( FixedSizeTabs(), wxT("SetTabSize() ignored") ); if ( IsVertical() ) { @@ -779,7 +824,7 @@ wxSize wxNotebook::CalcTabSize(int page) const 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); @@ -805,7 +850,7 @@ void wxNotebook::ResizeTab(int page) wxSize sizeTab = CalcTabSize(page); // we only need full relayout if the page size changes - bool needsRelayout = FALSE; + bool needsRelayout = false; if ( IsVertical() ) { @@ -817,7 +862,7 @@ void wxNotebook::ResizeTab(int page) if ( sizeTab.y > m_heightTab ) { - needsRelayout = TRUE; + needsRelayout = true; m_heightTab = sizeTab.y; } @@ -854,27 +899,28 @@ void wxNotebook::Relayout() UpdateSpinBtn(); - if ( m_sel != INVALID_PAGE ) + if ( m_selection != wxNOT_FOUND ) { // resize the currently shown page wxRect rectPage = GetPageRect(); - m_pages[m_sel]->SetSize(rectPage); + m_pages[m_selection]->SetSize(rectPage); // also scroll it into view if needed (note that m_lastVisible // was updated by the call to UpdateSpinBtn() above, this is why it // is needed here) if ( HasSpinBtn() ) { - if ( m_sel < m_firstVisible ) + const size_t selection = m_selection; + if ( selection < m_firstVisible ) { // selection is to the left of visible part of tabs - ScrollTo(m_sel); + ScrollTo(selection); } - else if ( m_sel > m_lastFullyVisible ) + else if ( selection > m_lastFullyVisible ) { // selection is to the right of visible part of tabs - ScrollLastTo(m_sel); + ScrollLastTo(selection); } } } @@ -943,7 +989,7 @@ void wxNotebook::SetPageSize(const wxSize& size) SetClientSize(GetSizeForPage(size)); } -wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) +wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const { return AdjustSize(GetSizeForPage(sizePage)); } @@ -1043,7 +1089,7 @@ void wxNotebook::UpdateSpinBtn() { // this case is special, get rid of it immediately: everything is // visible and we don't need any spin buttons - allTabsShown = TRUE; + allTabsShown = true; // have to reset them manually as we don't call CalcLastVisibleTab() m_firstVisible = @@ -1079,7 +1125,7 @@ void wxNotebook::UpdateSpinBtn() m_spinbtn = new wxNotebookSpinBtn(this); // set the correct value to keep it in sync - m_spinbtn->SetValue(m_sel); + m_spinbtn->SetValue(m_selection); } // position it correctly @@ -1099,7 +1145,7 @@ void wxNotebook::UpdateSpinBtn() } else // all tabs are visible, we don't need spin button { - if ( m_spinbtn ) + if ( m_spinbtn && m_spinbtn -> IsShown() ) { m_spinbtn->Hide(); } @@ -1120,7 +1166,7 @@ void wxNotebook::PositionSpinBtn() switch ( GetTabOrientation() ) { default: - wxFAIL_MSG(_T("unknown tab orientation")); + wxFAIL_MSG(wxT("unknown tab orientation")); // fall through case wxTOP: @@ -1151,12 +1197,12 @@ void wxNotebook::PositionSpinBtn() // wxNotebook scrolling // ---------------------------------------------------------------------------- -void wxNotebook::ScrollTo(int page) +void wxNotebook::ScrollTo(size_t 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; + m_firstVisible = page; m_offset = 0; for ( size_t n = 0; n < m_firstVisible; n++ ) { @@ -1169,9 +1215,9 @@ void wxNotebook::ScrollTo(int page) RefreshAllTabs(); } -void wxNotebook::ScrollLastTo(int page) +void wxNotebook::ScrollLastTo(size_t 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 @@ -1207,7 +1253,7 @@ void wxNotebook::ScrollLastTo(int page) 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") ); } // ---------------------------------------------------------------------------- @@ -1217,7 +1263,7 @@ void wxNotebook::ScrollLastTo(int page) wxSize wxNotebook::DoGetBestClientSize() const { // calculate the max page size - wxSize size(0, 0); + wxSize size; size_t count = GetPageCount(); if ( count ) @@ -1254,9 +1300,14 @@ void wxNotebook::DoSetSize(int x, int y, int width, int height, int sizeFlags) { + wxSize old_client_size = GetClientSize(); + wxControl::DoSetSize(x, y, width, height, sizeFlags); - Relayout(); + wxSize new_client_size = GetClientSize(); + + if (old_client_size != new_client_size) + Relayout(); } // ---------------------------------------------------------------------------- @@ -1268,15 +1319,23 @@ bool wxNotebook::PerformAction(const wxControlAction& action, const wxString& strArg) { if ( action == wxACTION_NOTEBOOK_NEXT ) - ChangePage(GetNextPage(TRUE)); + SetSelection(GetNextPage(true)); else if ( action == wxACTION_NOTEBOOK_PREV ) - ChangePage(GetNextPage(FALSE)); + SetSelection(GetNextPage(false)); else if ( action == wxACTION_NOTEBOOK_GOTO ) - ChangePage((int)numArg); + SetSelection((int)numArg); else return wxControl::PerformAction(action, numArg, strArg); - return TRUE; + return true; +} + +/* static */ +wxInputHandler *wxNotebook::GetStdInputHandler(wxInputHandler *handlerDef) +{ + static wxStdNotebookInputHandler s_handler(handlerDef); + + return &s_handler; } // ---------------------------------------------------------------------------- @@ -1332,7 +1391,7 @@ bool wxStdNotebookInputHandler::HandleKey(wxInputConsumer *consumer, break; } - if ( !!action ) + if ( !action.IsEmpty() ) { return consumer->PerformAction(action, page); } @@ -1352,7 +1411,7 @@ bool wxStdNotebookInputHandler::HandleMouse(wxInputConsumer *consumer, { consumer->PerformAction(wxACTION_NOTEBOOK_GOTO, page); - return FALSE; + return false; } } @@ -1365,12 +1424,13 @@ bool wxStdNotebookInputHandler::HandleMouseMove(wxInputConsumer *consumer, return wxStdInputHandler::HandleMouseMove(consumer, event); } -bool wxStdNotebookInputHandler::HandleFocus(wxInputConsumer *consumer, - const wxFocusEvent& event) +bool +wxStdNotebookInputHandler::HandleFocus(wxInputConsumer *consumer, + const wxFocusEvent& WXUNUSED(event)) { HandleFocusChange(consumer); - return FALSE; + return false; } bool wxStdNotebookInputHandler::HandleActivation(wxInputConsumer *consumer, @@ -1379,7 +1439,7 @@ bool wxStdNotebookInputHandler::HandleActivation(wxInputConsumer *consumer, // we react to the focus change in the same way as to the [de]activation HandleFocusChange(consumer); - return FALSE; + return false; } void wxStdNotebookInputHandler::HandleFocusChange(wxInputConsumer *consumer) @@ -1389,4 +1449,3 @@ void wxStdNotebookInputHandler::HandleFocusChange(wxInputConsumer *consumer) } #endif // wxUSE_NOTEBOOK -