X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/15ea6e205bc11e2348b8f33097c4d92abb762fb5..0738b901b17340f09766524b8d9d79e9ed1268e7:/src/generic/infobar.cpp?ds=inline diff --git a/src/generic/infobar.cpp b/src/generic/infobar.cpp index a85ead0f40..5f6c948bb0 100644 --- a/src/generic/infobar.cpp +++ b/src/generic/infobar.cpp @@ -28,6 +28,7 @@ #ifndef WX_PRECOMP #include "wx/bmpbuttn.h" #include "wx/button.h" + #include "wx/dcmemory.h" #include "wx/settings.h" #include "wx/statbmp.h" #include "wx/stattext.h" @@ -82,8 +83,8 @@ void wxInfoBarGeneric::Init() m_text = NULL; m_button = NULL; - m_showEffect = wxSHOW_EFFECT_SLIDE_TO_BOTTOM; - m_hideEffect = wxSHOW_EFFECT_SLIDE_TO_TOP; + m_showEffect = + m_hideEffect = wxSHOW_EFFECT_MAX; // use default effect duration m_effectDuration = 0; @@ -164,6 +165,68 @@ bool wxInfoBarGeneric::SetFont(const wxFont& font) return true; } +wxInfoBarGeneric::BarPlacement wxInfoBarGeneric::GetBarPlacement() const +{ + wxSizer * const sizer = GetContainingSizer(); + if ( !sizer ) + return BarPlacement_Unknown; + + // FIXME-VC6: can't compare "const wxInfoBarGeneric *" and "wxWindow *", + // so need this workaround + wxWindow * const self = const_cast(this); + const wxSizerItemList& siblings = sizer->GetChildren(); + if ( siblings.GetFirst()->GetData()->GetWindow() == self ) + return BarPlacement_Top; + else if ( siblings.GetLast()->GetData()->GetWindow() == self ) + return BarPlacement_Bottom; + else + return BarPlacement_Unknown; +} + +wxShowEffect wxInfoBarGeneric::GetShowEffect() const +{ + if ( m_showEffect != wxSHOW_EFFECT_MAX ) + return m_showEffect; + + switch ( GetBarPlacement() ) + { + case BarPlacement_Top: + return wxSHOW_EFFECT_SLIDE_TO_BOTTOM; + + case BarPlacement_Bottom: + return wxSHOW_EFFECT_SLIDE_TO_TOP; + + default: + wxFAIL_MSG( "unknown info bar placement" ); + // fall through + + case BarPlacement_Unknown: + return wxSHOW_EFFECT_NONE; + } +} + +wxShowEffect wxInfoBarGeneric::GetHideEffect() const +{ + if ( m_hideEffect != wxSHOW_EFFECT_MAX ) + return m_hideEffect; + + switch ( GetBarPlacement() ) + { + case BarPlacement_Top: + return wxSHOW_EFFECT_SLIDE_TO_TOP; + + case BarPlacement_Bottom: + return wxSHOW_EFFECT_SLIDE_TO_BOTTOM; + + default: + wxFAIL_MSG( "unknown info bar placement" ); + // fall through + + case BarPlacement_Unknown: + return wxSHOW_EFFECT_NONE; + } +} + void wxInfoBarGeneric::UpdateParent() { wxWindow * const parent = wxGetTopLevelParent(GetParent()); @@ -172,7 +235,7 @@ void wxInfoBarGeneric::UpdateParent() void wxInfoBarGeneric::DoHide() { - HideWithEffect(m_hideEffect, m_effectDuration); + HideWithEffect(GetHideEffect(), GetEffectDuration()); UpdateParent(); } @@ -198,7 +261,7 @@ void wxInfoBarGeneric::DoShow() // finally do really show the window. - ShowWithEffect(m_showEffect, m_effectDuration); + ShowWithEffect(GetShowEffect(), GetEffectDuration()); } void wxInfoBarGeneric::ShowMessage(const wxString& msg, int flags)