summaryrefslogtreecommitdiff
path: root/textscroller.h
blob: 5303cf87ccff80780f04be14695cc56f4157e0ab (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 WAITSTEPS 50

class cTextScroll
{
private:
    cRect Position;

    tColor ColorFg, ColorBg;
    std::string Text;
    cFont *Font;
    cPixmap *Pixmap;
    cOsd *Osd;

    int waitSteps;
    bool isReserveStep;
    bool ResetX;
    int ScrollType;

public:
    cTextScroll(cOsd *osd, int type) {
        Font = NULL;
        Pixmap = NULL;
        Osd = osd;

        ScrollType = type;
        isReserveStep = false;
        waitSteps = WAITSTEPS;
        ResetX = false;
    }

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

/*
    cTextScroll& operator=(const cTextScroll& other) {
        if( this != &other ) {
            this->Position = other.Position;
            this->Text = other.Text;
            this->ColorFg = other.ColorFg;
            this->ColorBg = other.ColorBg;
            this->Font = other.Font;
            this->Pixmap = other.Pixmap;
            this->Osd = other.Osd;
            dsyslog("operator= pointer: %x", this->Pixmap);
        }
        return *this;
    }
*/
    void Reset(void);
    void SetText(const char *text, cRect position, tColor colorFg, tColor colorBg, cFont *font);
    void DoStep(int Step);
    void Draw(void);

};

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

    cOsd *Osd;
    int scrollStep, scrollDelay;
    int scrollType;

    virtual void Action(void);
public:
    cTextScrollers();
    ~cTextScrollers();

    void Clear(void);
    void SetOsd(cOsd *osd) { Osd = osd;}
    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);
};