Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
390 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
 
391 andreas 22
#include <QLabel>
390 andreas 23
#include <QTimer>
24
 
25
class QString;
26
class QPaintEvent;
27
class QStaticText;
391 andreas 28
class QPixmap;
390 andreas 29
class QFont;
30
 
391 andreas 31
class TQMarquee : public QLabel
390 andreas 32
{
33
    Q_OBJECT
34
    Q_PROPERTY(QString text READ text WRITE setText)
35
 
36
    public:
391 andreas 37
        typedef enum MQ_TYPES
38
        {
39
            MQ_NONE,    // 0
40
            MQ_LEFT,    // 1
41
            MQ_RIGHT,   // 2
42
            MQ_PONG,    // 3
43
            MQ_UP,      // 4
44
            MQ_DOWN     // 5
45
        }MQ_TYPES;
46
 
390 andreas 47
        TQMarquee(QWidget *parent=0);
391 andreas 48
        TQMarquee(QWidget *parent, int msec, MQ_TYPES type=MQ_LEFT, bool enable=true);
390 andreas 49
        ~TQMarquee();
50
 
391 andreas 51
        void setAlignment(Qt::Alignment al);
52
        void setFrame(int left, int top, int right, int bottom);
53
        void setSpeed(int msec);
54
        void pause();
55
        void resume();
56
 
390 andreas 57
    public slots:
391 andreas 58
        QString text() const { return mText; }
390 andreas 59
        void setText(const QString& text);
60
        QColor backgroundColor();
61
        void setBackgroundColor(QColor& color);
391 andreas 62
        QPixmap background();
63
        void setBackground(QPixmap& bitmap);
64
        void setDirection(MQ_TYPES type);
390 andreas 65
 
66
    protected:
67
        virtual void paintEvent(QPaintEvent *);
68
        virtual void resizeEvent(QResizeEvent *);
391 andreas 69
        void updateCoordinates();
390 andreas 70
 
71
    private slots:
391 andreas 72
        void refreshLabel();
390 andreas 73
 
74
    private:
75
        void init();
76
 
77
        QWidget *mParent{nullptr};
78
        QString mText;
391 andreas 79
        bool mScrollEnabled{true};
80
        MQ_TYPES mType{MQ_NONE};
81
        QPixmap mBackgroundImage;
390 andreas 82
        QColor mBgColor{Qt::transparent};
391 andreas 83
        int mFrameLeft{0};
84
        int mFrameTop{0};
85
        int mFrameRight{0};
86
        int mFrameBottom{0};
87
 
88
        int px{0};
89
        int py{0};
390 andreas 90
        QTimer mTimer;
391 andreas 91
        Qt::Alignment mAlign{Qt::AlignVCenter};
92
        int mSpeed{200};
93
        Qt::LayoutDirection mDirection{Qt::LeftToRight};
94
        int mFontPointSize{8};
95
        int mTextLength{0};
390 andreas 96
};
97
 
98
#endif