changed ShowWithEffects() to use directional wxSHOW_EFFECT_XXX flags instead of additional wxDirection argument that doesn't always make sense; this also means the direction is never implicit
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53499 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -61,16 +61,14 @@ public:
|
||||
|
||||
virtual bool Show(bool show = true);
|
||||
virtual bool ShowWithEffect(wxShowEffect effect,
|
||||
unsigned timeout = 0,
|
||||
wxDirection dir = wxBOTTOM)
|
||||
unsigned timeout = 0)
|
||||
{
|
||||
return MSWShowWithEffect(true, effect, timeout, dir);
|
||||
return MSWShowWithEffect(true, effect, timeout);
|
||||
}
|
||||
virtual bool HideWithEffect(wxShowEffect effect,
|
||||
unsigned timeout = 0,
|
||||
wxDirection dir = wxBOTTOM)
|
||||
unsigned timeout = 0)
|
||||
{
|
||||
return MSWShowWithEffect(false, effect, timeout, dir);
|
||||
return MSWShowWithEffect(false, effect, timeout);
|
||||
}
|
||||
|
||||
virtual void SetFocus();
|
||||
@@ -431,8 +429,7 @@ public:
|
||||
// common part of Show/HideWithEffect()
|
||||
bool MSWShowWithEffect(bool show,
|
||||
wxShowEffect effect,
|
||||
unsigned timeout,
|
||||
wxDirection dir);
|
||||
unsigned timeout);
|
||||
|
||||
// Responds to colour changes: passes event on to children.
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
@@ -118,8 +118,14 @@ enum wxWindowVariant
|
||||
// valid values for Show/HideWithEffect()
|
||||
enum wxShowEffect
|
||||
{
|
||||
wxSHOW_EFFECT_ROLL,
|
||||
wxSHOW_EFFECT_SLIDE,
|
||||
wxSHOW_EFFECT_ROLL_TO_LEFT,
|
||||
wxSHOW_EFFECT_ROLL_TO_RIGHT,
|
||||
wxSHOW_EFFECT_ROLL_TO_TOP,
|
||||
wxSHOW_EFFECT_ROLL_TO_BOTTOM,
|
||||
wxSHOW_EFFECT_SLIDE_TO_LEFT,
|
||||
wxSHOW_EFFECT_SLIDE_TO_RIGHT,
|
||||
wxSHOW_EFFECT_SLIDE_TO_TOP,
|
||||
wxSHOW_EFFECT_SLIDE_TO_BOTTOM,
|
||||
wxSHOW_EFFECT_BLEND,
|
||||
wxSHOW_EFFECT_EXPAND,
|
||||
wxSHOW_EFFECT_MAX
|
||||
@@ -538,27 +544,15 @@ public:
|
||||
//
|
||||
// timeout specifies how long the animation should take, in ms, the
|
||||
// default value of 0 means to use the default (system-dependent) value
|
||||
//
|
||||
// direction is only used with wxSHOW_EFFECT_ROLL and SLIDE values
|
||||
virtual bool ShowWithEffect(wxShowEffect effect,
|
||||
unsigned timeout = 0,
|
||||
wxDirection dir = wxBOTTOM)
|
||||
virtual bool ShowWithEffect(wxShowEffect WXUNUSED(effect),
|
||||
unsigned WXUNUSED(timeout) = 0)
|
||||
{
|
||||
wxUnusedVar(effect);
|
||||
wxUnusedVar(timeout);
|
||||
wxUnusedVar(dir);
|
||||
|
||||
return Show();
|
||||
}
|
||||
|
||||
virtual bool HideWithEffect(wxShowEffect effect,
|
||||
unsigned timeout = 0,
|
||||
wxDirection dir = wxBOTTOM)
|
||||
virtual bool HideWithEffect(wxShowEffect WXUNUSED(effect),
|
||||
unsigned WXUNUSED(timeout) = 0)
|
||||
{
|
||||
wxUnusedVar(effect);
|
||||
wxUnusedVar(timeout);
|
||||
wxUnusedVar(dir);
|
||||
|
||||
return Hide();
|
||||
}
|
||||
|
||||
|
@@ -1255,17 +1255,16 @@ public:
|
||||
bool Hide();
|
||||
|
||||
/**
|
||||
This function hides a window, like Hide(), but using a
|
||||
special visual effect if possible.
|
||||
The parameters of this function are the same as for
|
||||
ShowWithEffect(), please see their
|
||||
description there.
|
||||
This function hides a window, like Hide(), but using a special visual
|
||||
effect if possible.
|
||||
|
||||
The parameters of this function are the same as for ShowWithEffect(),
|
||||
please see their description there.
|
||||
|
||||
@since 2.9.0
|
||||
*/
|
||||
virtual bool HideWithEffect(wxShowEffect effect,
|
||||
unsigned timeout = 0,
|
||||
wxDirection dir = wxBOTTOM);
|
||||
unsigned timeout = 0);
|
||||
|
||||
/**
|
||||
This function is (or should be, in case of custom controls) called during
|
||||
@@ -2455,42 +2454,26 @@ public:
|
||||
virtual bool Show(bool show = true);
|
||||
|
||||
/**
|
||||
This function shows a window, like Show(), but using a
|
||||
special visual effect if possible.
|
||||
Possible values for @a effect are:
|
||||
This function shows a window, like Show(), but using a special visual
|
||||
effect if possible.
|
||||
|
||||
wxSHOW_EFFECT_ROLL
|
||||
@param effect
|
||||
The effect to use.
|
||||
|
||||
Roll window effect
|
||||
|
||||
wxSHOW_EFFECT_SLIDE
|
||||
|
||||
Sliding window effect
|
||||
|
||||
wxSHOW_EFFECT_BLEND
|
||||
|
||||
Fade in or out effect
|
||||
|
||||
wxSHOW_EFFECT_EXPAND
|
||||
|
||||
Expanding or collapsing effect
|
||||
|
||||
For the roll and slide effects the @a dir parameter specifies the animation
|
||||
direction: it can be one of @c wxTOP, @c wxBOTTOM, @c wxLEFT
|
||||
or @c wxRIGHT. For the other effects, this parameter is unused.
|
||||
@param timeout
|
||||
The @a timeout parameter specifies the time of the animation, in
|
||||
milliseconds. If the default value of 0 is used, the default animation time
|
||||
for the current platform is used.
|
||||
Currently this function is only implemented in wxMSW and does the same thing as
|
||||
Show() in the other ports.
|
||||
milliseconds. If the default value of 0 is used, the default
|
||||
animation time for the current platform is used.
|
||||
|
||||
@note Currently this function is only implemented in wxMSW and does the
|
||||
same thing as Show() in the other ports.
|
||||
|
||||
@since 2.9.0
|
||||
|
||||
@see HideWithEffect()
|
||||
*/
|
||||
virtual bool ShowWithEffect(wxShowEffect effect,
|
||||
unsigned timeout = 0,
|
||||
wxDirection dir = wxBOTTOM);
|
||||
unsigned timeout = 0);
|
||||
|
||||
/**
|
||||
Reenables window updating after a previous call to Freeze().
|
||||
@@ -2634,6 +2617,32 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/// Valid values for wxWindow::ShowWithEffect() and wxWindow::HideWithEffect().
|
||||
enum wxShowEffect
|
||||
{
|
||||
/// Roll window to the left
|
||||
wxSHOW_EFFECT_ROLL_TO_LEFT,
|
||||
/// Roll window to the right
|
||||
wxSHOW_EFFECT_ROLL_TO_RIGHT,
|
||||
/// Roll window to the top
|
||||
wxSHOW_EFFECT_ROLL_TO_TOP,
|
||||
/// Roll window to the bottom
|
||||
wxSHOW_EFFECT_ROLL_TO_BOTTOM,
|
||||
/// Slide window to the left
|
||||
wxSHOW_EFFECT_SLIDE_TO_LEFT,
|
||||
/// Slide window to the right
|
||||
wxSHOW_EFFECT_SLIDE_TO_RIGHT,
|
||||
/// Slide window to the top
|
||||
wxSHOW_EFFECT_SLIDE_TO_TOP,
|
||||
/// Slide window to the bottom
|
||||
wxSHOW_EFFECT_SLIDE_TO_BOTTOM,
|
||||
/// Fade in or out effect
|
||||
wxSHOW_EFFECT_BLEND,
|
||||
/// Expanding or collapsing effect
|
||||
wxSHOW_EFFECT_EXPAND
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// Global functions/macros
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/image.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -152,15 +153,13 @@ public:
|
||||
wxShowEffect effect,
|
||||
// TODO: add menu command to the main frame to allow changing
|
||||
// these parameters
|
||||
unsigned timeout = 1000,
|
||||
wxDirection dir = wxBOTTOM)
|
||||
unsigned timeout = 1000)
|
||||
: wxFrame(parent, wxID_ANY,
|
||||
wxString::Format("Frame shown with %s effect",
|
||||
GetEffectName(effect)),
|
||||
wxDefaultPosition, wxSize(450, 300)),
|
||||
m_effect(effect),
|
||||
m_timeout(timeout),
|
||||
m_dir(dir)
|
||||
m_timeout(timeout)
|
||||
{
|
||||
new wxStaticText(this, wxID_ANY,
|
||||
wxString::Format("Effect: %s", GetEffectName(effect)),
|
||||
@@ -169,7 +168,7 @@ public:
|
||||
wxString::Format("Timeout: %ums", m_timeout),
|
||||
wxPoint(20, 60));
|
||||
|
||||
ShowWithEffect(m_effect, m_timeout, m_dir);
|
||||
ShowWithEffect(m_effect, m_timeout);
|
||||
|
||||
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(EffectFrame::OnClose));
|
||||
}
|
||||
@@ -179,7 +178,16 @@ private:
|
||||
{
|
||||
static const char *names[] =
|
||||
{
|
||||
"roll", "slide", "fade", "expand",
|
||||
"roll to left",
|
||||
"roll to right",
|
||||
"roll to top",
|
||||
"roll to bottom",
|
||||
"slide to left",
|
||||
"slide to right",
|
||||
"slide to top",
|
||||
"slide to bottom",
|
||||
"fade",
|
||||
"expand",
|
||||
};
|
||||
wxCOMPILE_TIME_ASSERT( WXSIZEOF(names) == wxSHOW_EFFECT_MAX,
|
||||
EffectNamesMismatch );
|
||||
@@ -189,14 +197,13 @@ private:
|
||||
|
||||
void OnClose(wxCloseEvent& event)
|
||||
{
|
||||
HideWithEffect(m_effect, m_timeout, m_dir);
|
||||
HideWithEffect(m_effect, m_timeout);
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
wxShowEffect m_effect;
|
||||
unsigned m_timeout;
|
||||
wxDirection m_dir;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
@@ -271,12 +278,70 @@ void MainFrame::OnShowTransparent(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MainFrame::OnShowEffect(wxCommandEvent& event)
|
||||
{
|
||||
int effect = wxSHOW_EFFECT_ROLL + event.GetId() - Show_Effect_Roll;
|
||||
int effect = event.GetId();
|
||||
static wxDirection direction = wxLEFT;
|
||||
direction = (wxDirection)(((int)direction)<< 1);
|
||||
if ( direction > wxDOWN )
|
||||
direction = wxLEFT ;
|
||||
new EffectFrame(this, wx_static_cast(wxShowEffect, effect),1000,direction);
|
||||
|
||||
wxShowEffect eff;
|
||||
switch ( effect )
|
||||
{
|
||||
case Show_Effect_Roll:
|
||||
switch ( direction )
|
||||
{
|
||||
case wxLEFT:
|
||||
eff = wxSHOW_EFFECT_ROLL_TO_LEFT;
|
||||
break;
|
||||
case wxRIGHT:
|
||||
eff = wxSHOW_EFFECT_ROLL_TO_RIGHT;
|
||||
break;
|
||||
case wxTOP:
|
||||
eff = wxSHOW_EFFECT_ROLL_TO_TOP;
|
||||
break;
|
||||
case wxBOTTOM:
|
||||
eff = wxSHOW_EFFECT_ROLL_TO_BOTTOM;
|
||||
break;
|
||||
default:
|
||||
wxFAIL_MSG( "invalid direction" );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case Show_Effect_Slide:
|
||||
switch ( direction )
|
||||
{
|
||||
case wxLEFT:
|
||||
eff = wxSHOW_EFFECT_SLIDE_TO_LEFT;
|
||||
break;
|
||||
case wxRIGHT:
|
||||
eff = wxSHOW_EFFECT_SLIDE_TO_RIGHT;
|
||||
break;
|
||||
case wxTOP:
|
||||
eff = wxSHOW_EFFECT_SLIDE_TO_TOP;
|
||||
break;
|
||||
case wxBOTTOM:
|
||||
eff = wxSHOW_EFFECT_SLIDE_TO_BOTTOM;
|
||||
break;
|
||||
default:
|
||||
wxFAIL_MSG( "invalid direction" );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case Show_Effect_Blend:
|
||||
eff = wxSHOW_EFFECT_BLEND;
|
||||
break;
|
||||
|
||||
case Show_Effect_Expand:
|
||||
eff = wxSHOW_EFFECT_EXPAND;
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( "invalid effect" );
|
||||
return;
|
||||
}
|
||||
|
||||
new EffectFrame(this, eff,1000);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -732,8 +732,7 @@ bool wxWindowMSW::Show(bool show)
|
||||
bool
|
||||
wxWindowMSW::MSWShowWithEffect(bool show,
|
||||
wxShowEffect effect,
|
||||
unsigned timeout,
|
||||
wxDirection dir)
|
||||
unsigned timeout)
|
||||
{
|
||||
if ( !wxWindowBase::Show(show) )
|
||||
return false;
|
||||
@@ -762,16 +761,39 @@ wxWindowMSW::MSWShowWithEffect(bool show,
|
||||
timeout = 200; // this is the default animation timeout, per MSDN
|
||||
|
||||
DWORD dwFlags = show ? 0 : AW_HIDE;
|
||||
bool needsDir = false;
|
||||
|
||||
switch ( effect )
|
||||
{
|
||||
case wxSHOW_EFFECT_ROLL:
|
||||
needsDir = true;
|
||||
case wxSHOW_EFFECT_ROLL_TO_LEFT:
|
||||
dwFlags |= AW_HOR_NEGATIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_SLIDE:
|
||||
needsDir = true;
|
||||
dwFlags |= AW_SLIDE;
|
||||
case wxSHOW_EFFECT_ROLL_TO_RIGHT:
|
||||
dwFlags |= AW_HOR_POSITIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_ROLL_TO_TOP:
|
||||
dwFlags |= AW_VER_NEGATIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_ROLL_TO_BOTTOM:
|
||||
dwFlags |= AW_VER_POSITIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_SLIDE_TO_LEFT:
|
||||
dwFlags |= AW_SLIDE | AW_HOR_NEGATIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_SLIDE_TO_RIGHT:
|
||||
dwFlags |= AW_SLIDE | AW_HOR_POSITIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_SLIDE_TO_TOP:
|
||||
dwFlags |= AW_SLIDE | AW_VER_NEGATIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_SLIDE_TO_BOTTOM:
|
||||
dwFlags |= AW_SLIDE | AW_VER_POSITIVE;
|
||||
break;
|
||||
|
||||
case wxSHOW_EFFECT_BLEND:
|
||||
@@ -792,38 +814,6 @@ wxWindowMSW::MSWShowWithEffect(bool show,
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( needsDir )
|
||||
{
|
||||
switch ( dir )
|
||||
{
|
||||
case wxTOP:
|
||||
dwFlags |= AW_VER_NEGATIVE;
|
||||
break;
|
||||
|
||||
case wxBOTTOM:
|
||||
dwFlags |= AW_VER_POSITIVE;
|
||||
break;
|
||||
|
||||
case wxLEFT:
|
||||
dwFlags |= AW_HOR_NEGATIVE;
|
||||
break;
|
||||
|
||||
case wxRIGHT:
|
||||
dwFlags |= AW_HOR_POSITIVE;
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( _T("unknown window effect direction") );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // animation effect which doesn't need the direction
|
||||
{
|
||||
wxASSERT_MSG( dir == wxBOTTOM,
|
||||
_T("non-default direction used unnecessarily") );
|
||||
}
|
||||
|
||||
|
||||
if ( !(*s_pfnAnimateWindow)(GetHwnd(), timeout, dwFlags) )
|
||||
{
|
||||
wxLogLastError(_T("AnimateWindow"));
|
||||
|
Reference in New Issue
Block a user