Determine the appropriate show effect automatically in wxInfoBar.
Slide the info bar from top or bottom of the parent window depending on its location. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62302 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,8 +63,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get effect used when showing/hiding the window
|
// get effect used when showing/hiding the window
|
||||||
wxShowEffect GetShowEffect() const { return m_showEffect; }
|
wxShowEffect GetShowEffect() const;
|
||||||
wxShowEffect GetHideEffect() const { return m_hideEffect; }
|
wxShowEffect GetHideEffect() const;
|
||||||
|
|
||||||
// set the duration of animation used when showing/hiding the bar, in ms
|
// set the duration of animation used when showing/hiding the bar, in ms
|
||||||
void SetEffectDuration(int duration) { m_effectDuration = duration; }
|
void SetEffectDuration(int duration) { m_effectDuration = duration; }
|
||||||
@@ -101,13 +101,26 @@ private:
|
|||||||
void DoShow();
|
void DoShow();
|
||||||
void DoHide();
|
void DoHide();
|
||||||
|
|
||||||
|
// determine the placement of the bar from its position in the containing
|
||||||
|
// sizer
|
||||||
|
enum BarPlacement
|
||||||
|
{
|
||||||
|
BarPlacement_Top,
|
||||||
|
BarPlacement_Bottom,
|
||||||
|
BarPlacement_Unknown
|
||||||
|
};
|
||||||
|
|
||||||
|
BarPlacement GetBarPlacement() const;
|
||||||
|
|
||||||
|
|
||||||
// different controls making up the bar
|
// different controls making up the bar
|
||||||
wxStaticBitmap *m_icon;
|
wxStaticBitmap *m_icon;
|
||||||
wxStaticText *m_text;
|
wxStaticText *m_text;
|
||||||
wxBitmapButton *m_button;
|
wxBitmapButton *m_button;
|
||||||
|
|
||||||
// the effects to use when showing/hiding and duration for them
|
// the effects to use when showing/hiding and duration for them: by default
|
||||||
|
// the effect is determined by the info bar automatically depending on its
|
||||||
|
// position and the default duration is used
|
||||||
wxShowEffect m_showEffect,
|
wxShowEffect m_showEffect,
|
||||||
m_hideEffect;
|
m_hideEffect;
|
||||||
int m_effectDuration;
|
int m_effectDuration;
|
||||||
|
@@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
@since 2.9.1
|
@since 2.9.1
|
||||||
*/
|
*/
|
||||||
class wxInfoBar : public wxWindow
|
class wxInfoBar : public wxControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -200,17 +200,17 @@ public:
|
|||||||
Either or both of the parameters can be set to wxSHOW_EFFECT_NONE to
|
Either or both of the parameters can be set to wxSHOW_EFFECT_NONE to
|
||||||
disable using effects entirely.
|
disable using effects entirely.
|
||||||
|
|
||||||
Notice that if you place the bar at the bottom of the window you should
|
By default, the info bar uses wxSHOW_EFFECT_SLIDE_TO_BOTTOM effect for
|
||||||
reverse the effects used for showing and hiding for better appearance.
|
showing itself and wxSHOW_EFFECT_SLIDE_TO_TOP for hiding if it is the
|
||||||
|
first element of the containing sizer and reverse effects if it's the
|
||||||
|
last one. If it is neither the first nor the last element, no effect is
|
||||||
|
used to avoid the use of an inappropriate one and this function must be
|
||||||
|
called if an effect is desired.
|
||||||
|
|
||||||
@param showEffect
|
@param showEffect
|
||||||
The effect to use when showing the bar. By default,
|
The effect to use when showing the bar.
|
||||||
wxSHOW_EFFECT_SLIDE_TO_BOTTOM which is appropriate for the bars
|
|
||||||
placed at the top of the window.
|
|
||||||
@param hideEffect
|
@param hideEffect
|
||||||
The effect to use when hiding the bar. By default,
|
The effect to use when hiding the bar.
|
||||||
wxSHOW_EFFECT_SLIDE_TO_TOP which is appropriate for the bars placed
|
|
||||||
at the top of the window.
|
|
||||||
*/
|
*/
|
||||||
void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect);
|
void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect);
|
||||||
|
|
||||||
|
@@ -82,8 +82,8 @@ void wxInfoBarGeneric::Init()
|
|||||||
m_text = NULL;
|
m_text = NULL;
|
||||||
m_button = NULL;
|
m_button = NULL;
|
||||||
|
|
||||||
m_showEffect = wxSHOW_EFFECT_SLIDE_TO_BOTTOM;
|
m_showEffect =
|
||||||
m_hideEffect = wxSHOW_EFFECT_SLIDE_TO_TOP;
|
m_hideEffect = wxSHOW_EFFECT_MAX;
|
||||||
|
|
||||||
// use default effect duration
|
// use default effect duration
|
||||||
m_effectDuration = 0;
|
m_effectDuration = 0;
|
||||||
@@ -164,6 +164,65 @@ bool wxInfoBarGeneric::SetFont(const wxFont& font)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxInfoBarGeneric::BarPlacement wxInfoBarGeneric::GetBarPlacement() const
|
||||||
|
{
|
||||||
|
wxSizer * const sizer = GetContainingSizer();
|
||||||
|
if ( !sizer )
|
||||||
|
return BarPlacement_Unknown;
|
||||||
|
|
||||||
|
const wxSizerItemList& siblings = sizer->GetChildren();
|
||||||
|
if ( siblings.GetFirst()->GetData()->GetWindow() == this )
|
||||||
|
return BarPlacement_Top;
|
||||||
|
else if ( siblings.GetLast()->GetData()->GetWindow() == this )
|
||||||
|
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()
|
void wxInfoBarGeneric::UpdateParent()
|
||||||
{
|
{
|
||||||
wxWindow * const parent = wxGetTopLevelParent(GetParent());
|
wxWindow * const parent = wxGetTopLevelParent(GetParent());
|
||||||
@@ -172,7 +231,7 @@ void wxInfoBarGeneric::UpdateParent()
|
|||||||
|
|
||||||
void wxInfoBarGeneric::DoHide()
|
void wxInfoBarGeneric::DoHide()
|
||||||
{
|
{
|
||||||
HideWithEffect(m_hideEffect, m_effectDuration);
|
HideWithEffect(GetHideEffect(), GetEffectDuration());
|
||||||
|
|
||||||
UpdateParent();
|
UpdateParent();
|
||||||
}
|
}
|
||||||
@@ -198,7 +257,7 @@ void wxInfoBarGeneric::DoShow()
|
|||||||
|
|
||||||
|
|
||||||
// finally do really show the window.
|
// finally do really show the window.
|
||||||
ShowWithEffect(m_showEffect, m_effectDuration);
|
ShowWithEffect(GetShowEffect(), GetEffectDuration());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxInfoBarGeneric::ShowMessage(const wxString& msg, int flags)
|
void wxInfoBarGeneric::ShowMessage(const wxString& msg, int flags)
|
||||||
|
Reference in New Issue
Block a user