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
This commit is contained in:
Vadim Zeitlin 2009-10-05 22:57:39 +00:00
parent ec20a753b9
commit 15ea6e205b
3 changed files with 7 additions and 61 deletions

View File

@ -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);
};

View File

@ -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
}

View File

@ -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();