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