summaryrefslogtreecommitdiff
path: root/textscroller.h
blob: 53ffbff735c16ebd1688ffa2d02fdd13608ced22 (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
#pragma once

#include <list>
#include "flat.h"
#include <string.h>
#include <vdr/thread.h>

#define WAITDELAY 1000 // in ms

class cTextScroll
{
private:
    cRect Position;

    tColor ColorFg, ColorExtraTextFg, ColorBg;
    std::string Text;
    cFont *Font;
    cPixmap *Pixmap;
    cOsd *Osd;
    int Layer;
    int PixelsPerStep;
    int WAITSTEPS, waitSteps;
    bool isReserveStep;
    bool ResetX;
    int ScrollType;
public:
    cTextScroll(cOsd *osd, int type, int pixels, int waitsteps, int layer) {
        Font = NULL;
        Pixmap = NULL;
        Osd = osd;
        Layer = layer;
        PixelsPerStep = pixels;
        ScrollType = type;
        isReserveStep = false;
        WAITSTEPS = waitsteps;
        ResetX = false;
    }
    cTextScroll(cOsd *osd, int type, int pixels, int waitsteps) {
        Font = NULL;
        Pixmap = NULL;
        Osd = osd;
        Layer = 2;
        PixelsPerStep = pixels;
        ScrollType = type;
        isReserveStep = false;
        WAITSTEPS = waitsteps;
        ResetX = false;
    }

    ~cTextScroll() {
        if( Pixmap ) {
            Osd->DestroyPixmap(Pixmap);
            Pixmap = NULL;
        }
    }

    void Reset(void);
    void SetText(const char *text, cRect position, tColor colorFg, tColor colorBg, cFont *font, tColor ColorExtraTextFg = 0);
    void DoStep(void);
    void Draw(void);

};

class cTextScrollers : public cThread
{
private:
    std::vector<cTextScroll *> Scrollers;

    cOsd *Osd;
    int scrollStep, scrollDelay;
    int scrollType;
    int Layer;
    virtual void Action(void);
    void StartScrolling(void);
public:
    cTextScrollers();
    ~cTextScrollers();

    void Clear(void);
    void SetOsd(cOsd *osd) { Osd = osd;}
    void SetPixmapLayer(int layer) { Layer = layer; }
    void SetScrollStep(int step) { scrollStep = step; }
    void SetScrollDelay(int delay) { scrollDelay = delay; }
    void SetScrollType(int type) { scrollType = type; }
    void AddScroller(const char *text, cRect position, tColor colorFg, tColor colorBg, cFont *font, tColor ColorExtraTextFg = 0);
    bool isActive(void) { return Active(); }
};