+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)
+ : wxFrame(parent, wxID_ANY,
+ wxString::Format("Frame shown with %s effect",
+ GetEffectName(effect)),
+ wxDefaultPosition, wxSize(450, 300)),
+ m_effect(effect),
+ m_timeout(timeout)
+ {
+ 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);
+
+ Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(EffectFrame::OnClose));
+ }
+
+private:
+ static const char *GetEffectName(wxShowEffect effect)
+ {
+ static const char *names[] =
+ {
+ "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 );
+
+ return names[effect];
+ }
+
+ void OnClose(wxCloseEvent& event)
+ {
+ HideWithEffect(m_effect, m_timeout);
+
+ event.Skip();
+ }
+
+ wxShowEffect m_effect;
+ unsigned m_timeout;
+};
+