Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2023 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TQMARQUEE_H__
20
#define __TQMARQUEE_H__
21
 
22
#include <QLabel>
23
#include <QTimer>
24
 
25
class QString;
26
class QPaintEvent;
27
class QResizeEvent;
28
class QHideEvent;
29
class QShowEvent;
30
class QStaticText;
31
class QPixmap;
32
class QFont;
33
class QRawFont;
34
 
35
#define BASE_SPEED  25
36
 
37
class TQMarquee : public QLabel
38
{
39
    Q_OBJECT
40
    Q_PROPERTY(QString text READ text WRITE setText)
41
 
42
    public:
43
        typedef enum MQ_TYPES
44
        {
45
            MQ_NONE,    // 0
46
            MQ_LEFT,    // 1
47
            MQ_RIGHT,   // 2
48
            MQ_PONG,    // 3
49
            MQ_UP,      // 4
50
            MQ_DOWN     // 5
51
        }MQ_TYPES;
52
 
53
        TQMarquee(QWidget *parent=0);
54
        TQMarquee(QWidget *parent, int msec, MQ_TYPES type=MQ_LEFT, bool enable=true);
55
        ~TQMarquee();
56
 
57
        void setAlignment(Qt::Alignment al);
58
        void setFrame(int left, int top, int right, int bottom);
59
        void setSpeed(int msec);
60
        void pause();
61
        void resume();
62
 
63
    public slots:
64
        QString text() const { return mText; }
65
        void setText(const QString& text);
66
        void setFont(const QFont& f);
67
        QColor backgroundColor();
68
        void setBackgroundColor(QColor& color);
69
        QPixmap background();
70
        void setBackground(QPixmap& bitmap);
71
        void setDirection(MQ_TYPES type);
72
 
73
    protected:
74
        virtual void paintEvent(QPaintEvent *);
75
        virtual void resizeEvent(QResizeEvent *);
76
        virtual void hideEvent(QHideEvent *);
77
        virtual void showEvent(QShowEvent *);
78
        void updateCoordinates();
79
 
80
    private slots:
81
        void refreshLabel();
82
 
83
    private:
84
        void init();
85
        bool testVisibility(const QRegion& region);
86
 
87
        QWidget *mParent{nullptr};
88
        QString mText;
89
        bool mScrollEnabled{true};
90
        MQ_TYPES mType{MQ_NONE};
91
        QPixmap mBackgroundImage;
92
        QColor mBgColor{Qt::transparent};
93
        int mFrameLeft{0};
94
        int mFrameTop{0};
95
        int mFrameRight{0};
96
        int mFrameBottom{0};
97
        bool mPaused{false};
98
 
99
        int px{0};
100
        int py{0};
101
        QTimer *mTimer{nullptr};
102
        int mInterval{BASE_SPEED};
103
        Qt::Alignment mAlign{Qt::AlignCenter};
104
        int mSpeed{1};
105
        Qt::LayoutDirection mDirection{Qt::LeftToRight};
106
        int mFontPointSize{8};
107
        int mTextLength{0};
108
        int mTextHeight{0};
109
};
110
 
111
#endif