]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/generic/animate.h
Simplify and correct MSW selection of background brush for children painting.
[wxWidgets.git] / include / wx / generic / animate.h
index 2b84863e40a6dd0663f615952b4aeed2a448dcd0..dee5f283646c1b2250f8508c64c3898127d75caf 100644 (file)
 #ifndef _WX_GENERIC_ANIMATEH__
 #define _WX_GENERIC_ANIMATEH__
 
+#include "wx/bitmap.h"
+
 // ----------------------------------------------------------------------------
 // wxAnimation
 // ----------------------------------------------------------------------------
 
-WX_DECLARE_LIST(wxAnimationDecoder, wxAnimationDecoderList);
+WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
 
 class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
 {
 public:
-    bool operator == (const wxAnimation& anim) const
-        { return m_refData == anim.m_refData; }
-    bool operator != (const wxAnimation& anim) const
-        { return m_refData != anim.m_refData; }
+    wxAnimation() {}
+    wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
+        { LoadFile(name, type); }
 
-    bool IsOk() const
+    virtual bool IsOk() const
         { return m_refData != NULL; }
 
-    size_t GetFrameCount() const;
-    int GetDelay(size_t i) const;
-    wxImage GetFrame(size_t i) const;
-    wxSize GetSize() const;
-
-    bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
-    bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
-
-public:     // extended interface used by the generic implementation of wxAnimationCtrl
-
-    wxPoint GetFramePosition(size_t frame) const;
-    wxAnimationDisposal GetDisposalMethod(size_t frame) const;
+    virtual unsigned int GetFrameCount() const;
+    virtual int GetDelay(unsigned int i) const;
+    virtual wxImage GetFrame(unsigned int i) const;
+    virtual wxSize GetSize() const;
+
+    virtual bool LoadFile(const wxString& filename,
+                          wxAnimationType type = wxANIMATION_TYPE_ANY);
+    virtual bool Load(wxInputStream& stream,
+                      wxAnimationType type = wxANIMATION_TYPE_ANY);
+
+    // extended interface used by the generic implementation of wxAnimationCtrl
+    wxPoint GetFramePosition(unsigned int frame) const;
+    wxSize GetFrameSize(unsigned int frame) const;
+    wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
+    wxColour GetTransparentColour(unsigned int frame) const;
     wxColour GetBackgroundColour() const;
 
 protected:
@@ -66,18 +70,22 @@ public:
 class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
 {
 public:
-    wxAnimationCtrl();
+    wxAnimationCtrl() { Init(); }
     wxAnimationCtrl(wxWindow *parent,
-            wxWindowID id,
-            const wxAnimation& anim = wxNullAnimation,
-            const wxPoint& pos = wxDefaultPosition,
-            const wxSize& size = wxDefaultSize,
-            long style = wxAC_DEFAULT_STYLE,
-            const wxString& name = wxAnimationCtrlNameStr)
+                    wxWindowID id,
+                    const wxAnimation& anim = wxNullAnimation,
+                    const wxPoint& pos = wxDefaultPosition,
+                    const wxSize& size = wxDefaultSize,
+                    long style = wxAC_DEFAULT_STYLE,
+                    const wxString& name = wxAnimationCtrlNameStr)
     {
+        Init();
+
         Create(parent, id, anim, pos, size, style, name);
     }
 
+    void Init();
+
     bool Create(wxWindow *parent, wxWindowID id,
                 const wxAnimation& anim = wxNullAnimation,
                 const wxPoint& pos = wxDefaultPosition,
@@ -89,6 +97,7 @@ public:
 
 public:
     virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
+    virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
 
     virtual void Stop();
     virtual bool Play()
@@ -100,6 +109,11 @@ public:
     wxAnimation GetAnimation() const
         { return m_animation; }
 
+    virtual void SetInactiveBitmap(const wxBitmap &bmp);
+
+    // override base class method
+    virtual bool SetBackgroundColour(const wxColour& col);
+
 public:     // event handlers
 
     void OnPaint(wxPaintEvent& event);
@@ -132,16 +146,19 @@ protected:      // internal utilities
     void FitToAnimation();
 
     // Draw the background; use this when e.g. previous frame had wxANIM_TOBACKGROUND disposal.
+    void DisposeToBackground();
     void DisposeToBackground(wxDC& dc);
+    void DisposeToBackground(wxDC& dc, const wxPoint &pos, const wxSize &sz);
 
     void IncrementalUpdateBackingStore();
-    void RebuildBackingStoreUpToFrame(size_t);
-    void DrawFrame(wxDC &dc, size_t);
+    bool RebuildBackingStoreUpToFrame(unsigned int);
+    void DrawFrame(wxDC &dc, unsigned int);
 
+    virtual void DisplayStaticImage();
     virtual wxSize DoGetBestSize() const;
 
 protected:
-    size_t        m_currentFrame;     // Current frame
+    unsigned int  m_currentFrame;     // Current frame
     bool          m_looped;           // Looped, or not
     wxTimer       m_timer;            // The timer
     wxAnimation   m_animation;        // The animation