diff --git a/include/wx/generic/infobar.h b/include/wx/generic/infobar.h index aef0e8c9fb..16cf5d4ab0 100644 --- a/include/wx/generic/infobar.h +++ b/include/wx/generic/infobar.h @@ -97,12 +97,6 @@ private: // handler for the close button void OnButton(wxCommandEvent& event); - // change the parent background colour to match that of our sibling - void ChangeParentBackground(); - - // restore the parent background changed by the above function - void RestoreParentBackground(); - // show/hide the bar void DoShow(); void DoHide(); @@ -118,9 +112,6 @@ private: m_hideEffect; int m_effectDuration; - // the original parent background colour, before we changed it - wxColour m_origParentBgCol; - DECLARE_EVENT_TABLE() wxDECLARE_NO_COPY_CLASS(wxInfoBarGeneric); }; diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 0319bb4541..72a1b58ccc 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -561,6 +561,12 @@ MyFrame::MyFrame(const wxString& title) sizer->Add(m_canvas, wxSizerFlags(1).Expand()); sizer->Add(m_infoBarAdvanced, wxSizerFlags().Expand()); SetSizer(sizer); + + // final touch: under MSW the info bars are shown progressively and parts + // of the parent window can be seen during the process, so use the same + // background colour for our background as for the canvas window which + // covers our entire client area to avoid jarring colour jumps + SetOwnBackgroundColour(m_canvas->GetBackgroundColour()); #endif // wxUSE_INFOBAR } diff --git a/src/generic/infobar.cpp b/src/generic/infobar.cpp index f0af9c9b8b..a85ead0f40 100644 --- a/src/generic/infobar.cpp +++ b/src/generic/infobar.cpp @@ -170,55 +170,10 @@ void wxInfoBarGeneric::UpdateParent() parent->Layout(); } -void wxInfoBarGeneric::ChangeParentBackground() -{ - wxWindow * const parent = GetParent(); - m_origParentBgCol = parent->GetBackgroundColour(); - - wxSizer * const sizer = GetContainingSizer(); - if ( !sizer ) - return; - - wxWindow *sibling = NULL; - for ( wxSizerItemList::compatibility_iterator - node = sizer->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - if ( node->GetData()->GetWindow() == this ) - { - // find the next window following us - for ( node = node->GetNext(); - node; - node = node->GetNext() ) - { - wxSizerItem * const item = node->GetData(); - if ( item->IsWindow() ) - { - sibling = item->GetWindow(); - break; - } - } - - break; - } - } - - if ( sibling ) - parent->SetOwnBackgroundColour(sibling->GetBackgroundColour()); -} - -void wxInfoBarGeneric::RestoreParentBackground() -{ - GetParent()->SetOwnBackgroundColour(m_origParentBgCol); -} - void wxInfoBarGeneric::DoHide() { - ChangeParentBackground(); - wxON_BLOCK_EXIT_THIS0( wxInfoBarGeneric::RestoreParentBackground ); - HideWithEffect(m_hideEffect, m_effectDuration); + UpdateParent(); } @@ -234,12 +189,6 @@ void wxInfoBarGeneric::DoShow() // without really showing it wxWindowBase::Show(); - // an extra hack: we want the temporarily uncovered area in which we're - // going to expand to look like part of this sibling for a better effect so - // temporarily change the background of our parent to the same colour - ChangeParentBackground(); - wxON_BLOCK_EXIT_THIS0( wxInfoBarGeneric::RestoreParentBackground ); - // adjust the parent layout to account for us UpdateParent();