From 15ea6e205bc11e2348b8f33097c4d92abb762fb5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Oct 2009 22:57:39 +0000 Subject: [PATCH] Remove the hack with changing the parent background colour in wxInfoBar. Finding the closest info bar to copy the background colour from only worked for very simple layouts and failed for more complicated ones with nested sizers so don't try to change the colour automatically, it's easy enough to do it manually as shown in the updated dialogs sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/infobar.h | 9 ------ samples/dialogs/dialogs.cpp | 6 ++++ src/generic/infobar.cpp | 53 +----------------------------------- 3 files changed, 7 insertions(+), 61 deletions(-) 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();