summaryrefslogtreecommitdiffstats
path: root/kpercentage/kpercentage/kanimation.h
blob: 6b16883beb0bef3d5eddba3574891d1a87a2fd51 (plain)
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
#ifndef KANIMATION_H
#define KANIMATION_H

#include <tqcanvas.h>
#include <tqdict.h>

class TQString;

/**
 * This class contains information about one frame.
 */
class KFrame
{
    public:
    /**
     * The constructor gets:
     * @param nx the position x coordinate
     * @param ny the position  coordinate
     * @param nf the frame number 
     */
    KFrame( double nx, double ny, int nf );
    /**
     * The destructor is empty yet
     */
    ~KFrame();

    double x, y; // position
    int f; // frame number
};

/**
 * This class handles a list of frames, called "scene".
 * Also a list of possibly following scene names is maintained.
 */
class KScene: public TQPtrList<KFrame>
{
    public:
        /**
         * The constructor initiates the list of following scene names.
         * Attention: this list uses the autoDelete functionality as the KScene itself do.
         */
        KScene();
        /**
         * The destructor deletes the list of following scene names.
         */
        ~KScene();

        /**
         * @return a pointer to the current frame or 0, if the list is empty.
         */
        KFrame *currentFrame();
        /**
         * increases the current frame. Resets the scene, if the laste frame was reached.
         * @return a pointer to the next frame or 0, if there is no frame left or the list is empty
         */
        KFrame *nextFrame();

        /**
         * adds a scene name
         */
        void addFollowingScene( const TQString scene_name );
        /**
         * selects a scene out of the list of possibly following scenes.
         */
        void followingSceneName( TQString& scene_name);
        
        void setToStart();

    private:
        TQStrList *following;
        unsigned int current_frame_number;
};

/**
 * KStoryBoard
 */
class KStoryBoard: public TQDict<KScene>
{
    public:
        KStoryBoard( const TQString filename );
        ~KStoryBoard();

        KFrame *nextFrame();
        KFrame *currentFrame();
        void setToStart();

    private:
        KScene *current_scene;
};

class KAnimation: public TQCanvasSprite
{
    public:
        KAnimation( const TQString stroy_filename, TQCanvasPixmapArray *a, TQCanvas *canvas );
        ~KAnimation();

        virtual void advance( int phase );

        void setToStart();

        KStoryBoard *story;
};

#endif