X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/23645bfa01b6450257f140a30c87565225b1ef4a..b5a49d4c5267d4eb933d45ec615ac2ed374750dc:/src/univ/notebook.cpp diff --git a/src/univ/notebook.cpp b/src/univ/notebook.cpp index e1e2ff47ef..c90d042c39 100644 --- a/src/univ/notebook.cpp +++ b/src/univ/notebook.cpp @@ -212,15 +212,21 @@ int wxNotebook::SetSelection(int nPage) return m_sel; } - if ( m_sel != INVALID_PAGE ) + // we need to change m_sel 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; + + m_sel = nPage; + + if ( selOld != INVALID_PAGE ) { - RefreshTab(m_sel); + RefreshTab(selOld, TRUE /* this tab was selected */); - m_pages[m_sel]->Hide(); + m_pages[selOld]->Hide(); } - m_sel = nPage; - if ( m_sel != INVALID_PAGE ) // this is impossible - but test nevertheless { if ( HasSpinBtn() ) @@ -421,12 +427,12 @@ void wxNotebook::RefreshCurrent() } } -void wxNotebook::RefreshTab(int page) +void wxNotebook::RefreshTab(int page, bool forceSelected) { wxCHECK_RET( IS_VALID_PAGE(page), _T("invalid notebook page") ); wxRect rect = GetTabRect(page); - if ( (size_t)page == m_sel ) + if ( forceSelected || ((size_t)page == m_sel) ) { const wxSize indent = GetRenderer()->GetTabIndent(); rect.Inflate(indent.x, indent.y); @@ -460,6 +466,7 @@ void wxNotebook::DoDrawTab(wxDC& dc, const wxRect& rect, size_t n) dc.SelectObject(bmp); dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); m_imageList->Draw(image, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL, TRUE); + dc.SelectObject(wxNullBitmap); #else bmp = *m_imageList->GetBitmap(image); #endif @@ -1247,9 +1254,14 @@ void wxNotebook::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - wxControl::DoSetSize(x, y, width, height, sizeFlags); + wxSize old_client_size = GetClientSize(); - Relayout(); + wxControl::DoSetSize(x, y, width, height, sizeFlags); + + wxSize new_client_size = GetClientSize(); + + if (old_client_size != new_client_size) + Relayout(); } // ----------------------------------------------------------------------------