File: animdecod.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (111 lines) | stat: -rw-r--r-- 3,367 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/animdecod.h
// Purpose:     wxAnimationDecoder
// Author:      Francesco Montorsi
// Copyright:   (c) 2006 Francesco Montorsi
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

enum wxAnimationDisposal
{
    /// No disposal specified. The decoder is not required to take any action.
    wxANIM_UNSPECIFIED = -1,

    /// Do not dispose. The graphic is to be left in place.
    wxANIM_DONOTREMOVE = 0,

    /// Restore to background color. The area used by the graphic must be
    /// restored to the background color.
    wxANIM_TOBACKGROUND = 1,

    /// Restore to previous. The decoder is required to restore the area
    /// overwritten by the graphic with what was there prior to rendering the graphic.
    wxANIM_TOPREVIOUS = 2
};



/**
   @class wxAnimationDecoder

   wxAnimationDecoder is used by @c wxAnimation for loading frames and other
   information for the animation from the animation image file.

 */
class wxAnimationDecoder : public wxObjectRefData
{
public:
    wxAnimationDecoder();

    /**
       Load the animation image frames from the given stream.
    */
    virtual bool Load( wxInputStream& stream ) = 0;

    /**
       Returns @true if this decoder supports loading from the given stream.
    */
    bool CanRead( wxInputStream& stream ) const;

    /**
       Create a copy of this decoder.
    */
    virtual wxAnimationDecoder *Clone() const = 0;

    /**
       Return the animation type this decoder implements.
    */
    virtual wxAnimationType GetType() const = 0;

    /**
       Convert given frame to @c wxImage.
    */
    virtual bool ConvertToImage(unsigned int frame, wxImage *image) const = 0;


    /*
      Get the size of the given animation frame.

      It's possible that not all frames are of the same size; e.g. GIF allows
      to specify that between two frames only a smaller portion of the entire
      animation has changed.
    */
    virtual wxSize GetFrameSize(unsigned int frame) const = 0;

    /*
      Returns the position of the frame, in case it's not as big as the animation size,
      or @c wxPoint(0,0) otherwise.
    */
    virtual wxPoint GetFramePosition(unsigned int frame) const = 0;

    /**
      What should be done after displaying this frame.
    */
    virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const = 0;

    /**
       Return the number of milliseconds this frame should be displayed.
       If -1 is returned then the frame must be displayed forever.
    */
    virtual long GetDelay(unsigned int frame) const = 0;

    /**
       The transparent colour for this frame, if any, or @c wxNullColour.
    */
    virtual wxColour GetTransparentColour(unsigned int frame) const = 0;

    wxSize GetAnimationSize() const;
    wxColour GetBackgroundColour() const;
    unsigned int GetFrameCount() const;

protected:
    /**
       Checks the signature of the data in the given stream and returns true if it
       appears to be a valid animation format recognized by the animation decoder;
       this function should modify the stream current position without taking care
       of restoring it since @c CanRead() will do it.
    */
    virtual bool DoCanRead(wxInputStream& stream) const = 0;
};