Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 andreas 1
/*
21 andreas 2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
5 andreas 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 __TOBJECT_H__
20
#define __TOBJECT_H__
21
 
22
#include <string>
23
#include <QtGlobal>
24
 
25
QT_BEGIN_NAMESPACE
26
class QLabel;
27
class QWidget;
28
class QTextObject;
21 andreas 29
class QMediaPlayer;
30
class QVideoWidget;
5 andreas 31
QT_END_NAMESPACE
32
 
33
class TObject
34
{
35
    public:
36
        typedef enum OBJECT_TYPE
37
        {
38
            OBJ_NONE,
39
            OBJ_PAGE,
40
            OBJ_SUBPAGE,
41
            OBJ_BUTTON,
42
            OBJ_TEXT,
21 andreas 43
            OBJ_INPUT,
44
            OBJ_VIDEO
5 andreas 45
        }OBJECT_TYPE;
46
 
47
        typedef union _OBJ
48
        {
21 andreas 49
            QVideoWidget *vwidget{nullptr}; // A video window
50
            QLabel *label;                  // For buttons
51
            QWidget *widget;                // For subpage
52
            QTextObject *text;              // For text line optional with input
5 andreas 53
        }_OBJ;
54
 
55
        typedef struct OBJECT_t
56
        {
57
            OBJECT_TYPE type{OBJ_NONE};
58
            ulong handle{0};
59
            _OBJ object;
21 andreas 60
            QMediaPlayer *player{nullptr};  // Pointer to video player if this is a video button
5 andreas 61
            int left{0};
62
            int top{0};
63
            int width{0};
64
            int height{0};
65
            OBJECT_t *next{nullptr};
66
        }OBJECT_t;
67
 
68
        TObject();
69
        ~TObject();
70
 
71
        OBJECT_t *addObject();
72
        OBJECT_t *findObject(ulong handle);
11 andreas 73
        OBJECT_t *findFirstChild(ulong handle);
74
        OBJECT_t *findNextChild(ulong handle);
75
        void removeAllChilds(ulong handle);
5 andreas 76
        void removeObject(ulong handle);
77
 
78
        static std::string handleToString(ulong handle)
79
        {
80
            ulong part1 = (handle >> 16) & 0x0000ffff;
81
            ulong part2 = handle & 0x0000ffff;
82
            return std::to_string(part1)+":"+std::to_string(part2);
83
        }
84
 
14 andreas 85
        static std::string objectToString(OBJECT_TYPE o);
86
 
87
    protected:
88
        void dropContent(OBJECT_t *obj);
89
 
5 andreas 90
    private:
91
        OBJECT_t *mObject{nullptr};
92
};
93
 
94
#endif