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;
417 andreas 27
class QResizeEvent;
28
class QHideEvent;
29
class QShowEvent;
390 andreas 30
class QStaticText;
391 andreas 31
class QPixmap;
390 andreas 32
class QFont;
394 andreas 33
class QRawFont;
390 andreas 34
 
422 andreas 35
#define BASE_SPEED  25
36
 
391 andreas 37
class TQMarquee : public QLabel
390 andreas 38
{
39
    Q_OBJECT
40
    Q_PROPERTY(QString text READ text WRITE setText)
41
 
42
    public:
391 andreas 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
 
390 andreas 53
        TQMarquee(QWidget *parent=0);
391 andreas 54
        TQMarquee(QWidget *parent, int msec, MQ_TYPES type=MQ_LEFT, bool enable=true);
390 andreas 55
        ~TQMarquee();
56
 
391 andreas 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
 
390 andreas 63
    public slots:
391 andreas 64
        QString text() const { return mText; }
390 andreas 65
        void setText(const QString& text);
437 andreas 66
        void setFont(const QFont& f);
390 andreas 67
        QColor backgroundColor();
68
        void setBackgroundColor(QColor& color);
391 andreas 69
        QPixmap background();
70
        void setBackground(QPixmap& bitmap);
71
        void setDirection(MQ_TYPES type);
390 andreas 72
 
73
    protected:
74
        virtual void paintEvent(QPaintEvent *);
75
        virtual void resizeEvent(QResizeEvent *);
417 andreas 76
        virtual void hideEvent(QHideEvent *);
77
        virtual void showEvent(QShowEvent *);
391 andreas 78
        void updateCoordinates();
390 andreas 79
 
80
    private slots:
391 andreas 81
        void refreshLabel();
390 andreas 82
 
83
    private:
84
        void init();
421 andreas 85
        bool testVisibility(const QRegion& region);
390 andreas 86
 
87
        QWidget *mParent{nullptr};
88
        QString mText;
391 andreas 89
        bool mScrollEnabled{true};
90
        MQ_TYPES mType{MQ_NONE};
91
        QPixmap mBackgroundImage;
390 andreas 92
        QColor mBgColor{Qt::transparent};
391 andreas 93
        int mFrameLeft{0};
94
        int mFrameTop{0};
95
        int mFrameRight{0};
96
        int mFrameBottom{0};
417 andreas 97
        bool mPaused{false};
391 andreas 98
 
99
        int px{0};
100
        int py{0};
421 andreas 101
        QTimer *mTimer{nullptr};
422 andreas 102
        int mInterval{BASE_SPEED};
419 andreas 103
        Qt::Alignment mAlign{Qt::AlignCenter};
422 andreas 104
        int mSpeed{1};
391 andreas 105
        Qt::LayoutDirection mDirection{Qt::LeftToRight};
106
        int mFontPointSize{8};
107
        int mTextLength{0};
393 andreas 108
        int mTextHeight{0};
390 andreas 109
};
110
 
111
#endif