// 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();
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);
};
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
}
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();
}
// 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();