- Added {wxTextCtrl,wxComboBox}::AutoComplete() and AutoCompleteFileNames()
- Added wxH[V]ScrolledWindow (Brad Anderson, Bryan Petty).
- Added wxNotificationMessage class for non-intrusive notifications
+- Added wxWindow::Show/HideWithEffect()
- Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron).
- Added support for drop down toolbar buttons (Tim Kosse).
- Added support for labels for toolbar controls (Vince Harron).
\helpref{wxRadioBox::Show}{wxradioboxshow}
+\membersection{wxWindow::ShowWithEffect}\label{wxwindowshowwitheffect}
+
+\func{virtual bool}{ShowWithEffect}{\param{wxShowEffect }{effect}, \param{unsigned }{timeout = $0$}, \param{wxDirection }{dir = wxBOTTOM}}
+
+This function shows a window, like \helpref{Show()}{wxwindowshow}, but using a
+special visual effect if possible.
+
+Possible values for \arg{effect} are:
+\begin{twocollist}\itemsep=0pt
+\twocolitem{wxSHOW\_EFFECT\_ROLL}{Roll window effect}
+\twocolitem{wxSHOW\_EFFECT\_SLIDE}{Sliding window effect}
+\twocolitem{wxSHOW\_EFFECT\_BLEND}{Fade in or out effect}
+\twocolitem{wxSHOW\_EFFECT\_EXPAND}{Expanding or collapsing effect}
+\end{twocollist}
+
+For the roll and slide effects the \arg{dir} parameter specifies the animation
+direction: it can be one of \texttt{wxTOP}, \texttt{wxBOTTOM}, \texttt{wxLEFT}
+or \texttt{wxRIGHT}. For the other effects, this parameter is unused.
+
+The \arg{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.
+
+\newsince{2.9.0}
+
+\wxheading{See also}
+
+\helpref{HideWithEffect}{wxwindowhidewitheffect}
+
+
\membersection{wxWindow::Thaw}\label{wxwindowthaw}
\func{virtual void}{Thaw}{\void}
virtual void Raise();
virtual void Lower();
- virtual bool Show( bool show = true );
+ virtual bool Show(bool show = true);
+ virtual bool ShowWithEffect(wxShowEffect effect,
+ unsigned timeout = 0,
+ wxDirection dir = wxBOTTOM)
+ {
+ return MSWShowWithEffect(true, effect, timeout, dir);
+ }
+ virtual bool HideWithEffect(wxShowEffect effect,
+ unsigned timeout = 0,
+ wxDirection dir = wxBOTTOM)
+ {
+ return MSWShowWithEffect(false, effect, timeout, dir);
+ }
virtual void SetFocus();
virtual void SetFocusFromKbd();
return true;
}
+ // common part of Show/HideWithEffect()
+ bool MSWShowWithEffect(bool show,
+ wxShowEffect effect,
+ unsigned timeout,
+ wxDirection dir);
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
#define wxWINDOW_DEFAULT_VARIANT wxT("window-default-variant")
#endif
+// valid values for Show/HideWithEffect()
+enum wxShowEffect
+{
+ wxSHOW_EFFECT_ROLL,
+ wxSHOW_EFFECT_SLIDE,
+ wxSHOW_EFFECT_BLEND,
+ wxSHOW_EFFECT_EXPAND,
+ wxSHOW_EFFECT_MAX
+};
+
// ----------------------------------------------------------------------------
// (pseudo)template list classes
// ----------------------------------------------------------------------------
virtual bool Show( bool show = true );
bool Hide() { return Show(false); }
+ // show or hide the window with a special effect, not implemented on
+ // most platforms (where it is the same as Show()/Hide() respectively)
+ //
+ // 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)
+ {
+ wxUnusedVar(effect);
+ wxUnusedVar(timeout);
+ wxUnusedVar(dir);
+
+ return Show();
+ }
+
+ virtual bool HideWithEffect(wxShowEffect effect,
+ unsigned timeout = 0,
+ wxDirection dir = wxBOTTOM)
+ {
+ wxUnusedVar(effect);
+ wxUnusedVar(timeout);
+ wxUnusedVar(dir);
+
+ return Hide();
+ }
+
// returns true if window was enabled/disabled, false if nothing done
virtual bool Enable( bool enable = true );
bool Disable() { return Enable(false); }
enum
{
Show_Shaped,
- Show_Transparent
+ Show_Transparent,
+
+ // must be consecutive and in the same order as wxShowEffect enum elements
+ Show_Effect_First,
+ Show_Effect_Roll = Show_Effect_First,
+ Show_Effect_Slide,
+ Show_Effect_Blend,
+ Show_Effect_Expand,
+ Show_Effect_Last = Show_Effect_Expand
};
// ----------------------------------------------------------------------------
private:
void OnShowShaped(wxCommandEvent& event);
void OnShowTransparent(wxCommandEvent& event);
+ void OnShowEffect(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
DECLARE_EVENT_TABLE()
};
+class EffectFrame : public wxFrame
+{
+public:
+ EffectFrame(wxWindow *parent,
+ wxShowEffect effect,
+ // TODO: add menu command to the main frame to allow changing
+ // these parameters
+ unsigned timeout = 1000,
+ wxDirection dir = wxBOTTOM)
+ : 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)
+ {
+ new wxStaticText(this, wxID_ANY,
+ wxString::Format("Effect: %s", GetEffectName(effect)),
+ wxPoint(20, 20));
+ new wxStaticText(this, wxID_ANY,
+ wxString::Format("Timeout: %ums", m_timeout),
+ wxPoint(20, 60));
+
+ ShowWithEffect(m_effect, m_timeout, m_dir);
+
+ Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(EffectFrame::OnClose));
+ }
+
+private:
+ static const char *GetEffectName(wxShowEffect effect)
+ {
+ static const char *names[] =
+ {
+ "roll", "slide", "fade", "expand",
+ };
+ wxCOMPILE_TIME_ASSERT( WXSIZEOF(names) == wxSHOW_EFFECT_MAX,
+ EffectNamesMismatch );
+
+ return names[effect];
+ }
+
+ void OnClose(wxCloseEvent& event)
+ {
+ HideWithEffect(m_effect, m_timeout, m_dir);
+
+ event.Skip();
+ }
+
+ wxShowEffect m_effect;
+ unsigned m_timeout;
+ wxDirection m_dir;
+};
+
// ============================================================================
// implementation
// ============================================================================
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_MENU(Show_Shaped, MainFrame::OnShowShaped)
EVT_MENU(Show_Transparent, MainFrame::OnShowTransparent)
+ EVT_MENU_RANGE(Show_Effect_First, Show_Effect_Last, MainFrame::OnShowEffect)
END_EVENT_TABLE()
MainFrame::MainFrame()
menuFrames->Append(Show_Shaped, "Show &shaped window\tCtrl-S");
menuFrames->Append(Show_Transparent, "Show &transparent window\tCtrl-T");
menuFrames->AppendSeparator();
+ menuFrames->Append(Show_Effect_Roll, "Show &rolled effect\tCtrl-R");
+ menuFrames->Append(Show_Effect_Slide, "Show s&lide effect\tCtrl-L");
+ menuFrames->Append(Show_Effect_Blend, "Show &fade effect\tCtrl-F");
+ menuFrames->Append(Show_Effect_Expand, "Show &expand effect\tCtrl-E");
+ menuFrames->AppendSeparator();
menuFrames->Append(wxID_EXIT, "E&xit");
mbar->Append(menuFrames, "&Show");
seeThroughFrame->Show(true);
}
+void MainFrame::OnShowEffect(wxCommandEvent& event)
+{
+ int effect = wxSHOW_EFFECT_ROLL + event.GetId() - Show_Effect_Roll;
+ new EffectFrame(this, wx_static_cast(wxShowEffect, effect));
+}
+
// ----------------------------------------------------------------------------
// shaped frame
// ----------------------------------------------------------------------------
return true;
}
+bool
+wxWindowMSW::MSWShowWithEffect(bool show,
+ wxShowEffect effect,
+ unsigned timeout,
+ wxDirection dir)
+{
+ typedef BOOL (WINAPI *AnimateWindow_t)(HWND, DWORD, DWORD);
+
+ static AnimateWindow_t s_pfnAnimateWindow = NULL;
+ static bool s_initDone = false;
+ if ( !s_initDone )
+ {
+ wxLogNull noLog;
+
+ wxDynamicLibrary dllUser32(_T("user32.dll"), wxDL_VERBATIM);
+ wxDL_INIT_FUNC(s_pfn, AnimateWindow, dllUser32);
+
+ s_initDone = true;
+
+ // notice that it's ok to unload user32.dll here as it won't be really
+ // unloaded, being still in use because we link to it statically too
+ }
+
+ if ( !s_pfnAnimateWindow )
+ return Show(show);
+
+ // prepare to use AnimateWindow()
+
+ if ( !timeout )
+ 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;
+ break;
+
+ case wxSHOW_EFFECT_SLIDE:
+ needsDir = true;
+ dwFlags |= AW_SLIDE;
+ break;
+
+ case wxSHOW_EFFECT_BLEND:
+ dwFlags |= AW_BLEND;
+ break;
+
+ case wxSHOW_EFFECT_EXPAND:
+ dwFlags |= AW_CENTER;
+ break;
+
+
+ case wxSHOW_EFFECT_MAX:
+ wxFAIL_MSG( _T("invalid window show effect") );
+ return false;
+
+ default:
+ wxFAIL_MSG( _T("unknown window show effect") );
+ 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"));
+
+ return false;
+ }
+
+ return true;
+}
+
// Raise the window to the top of the Z order
void wxWindowMSW::Raise()
{