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>
190 andreas 23
 
42 andreas 24
#include "tsubpage.h"
190 andreas 25
#include "tqeditline.h"
42 andreas 26
 
5 andreas 27
QT_BEGIN_NAMESPACE
28
class QLabel;
29
class QWidget;
51 andreas 30
class QTextEdit;
31
class QLineEdit;
21 andreas 32
class QMediaPlayer;
33
class QVideoWidget;
41 andreas 34
class QPropertyAnimation;
200 andreas 35
class QListWidget;
5 andreas 36
QT_END_NAMESPACE
37
 
38
class TObject
39
{
40
    public:
41
        typedef enum OBJECT_TYPE
42
        {
43
            OBJ_NONE,
44
            OBJ_PAGE,
45
            OBJ_SUBPAGE,
46
            OBJ_BUTTON,
47
            OBJ_TEXT,
21 andreas 48
            OBJ_INPUT,
200 andreas 49
            OBJ_LIST,
21 andreas 50
            OBJ_VIDEO
5 andreas 51
        }OBJECT_TYPE;
52
 
53
        typedef union _OBJ
54
        {
21 andreas 55
            QVideoWidget *vwidget{nullptr}; // A video window
56
            QLabel *label;                  // For buttons
57
            QWidget *widget;                // For subpage
200 andreas 58
            TQEditLine *plaintext;          // For text input
59
            QListWidget *list;              // For lists
5 andreas 60
        }_OBJ;
61
 
62
        typedef struct OBJECT_t
63
        {
64
            OBJECT_TYPE type{OBJ_NONE};
65
            ulong handle{0};
66
            _OBJ object;
21 andreas 67
            QMediaPlayer *player{nullptr};  // Pointer to video player if this is a video button
5 andreas 68
            int left{0};
69
            int top{0};
70
            int width{0};
71
            int height{0};
200 andreas 72
            int rows{0};
73
            int cols{0};
41 andreas 74
            QPropertyAnimation *animation{nullptr};
42 andreas 75
            ANIMATION_t animate;
107 andreas 76
            bool aniDirection{false};
51 andreas 77
            WId wid{0};                     // Used to identify a QTextEdit or QLineEdit
107 andreas 78
            std::atomic<bool> remove{false};// Object is marked for remove. Used with animation.
5 andreas 79
            OBJECT_t *next{nullptr};
80
        }OBJECT_t;
81
 
82
        TObject();
83
        ~TObject();
84
 
89 andreas 85
        void clear(bool force=false);
5 andreas 86
        OBJECT_t *addObject();
87
        OBJECT_t *findObject(ulong handle);
51 andreas 88
        OBJECT_t *findObject(WId id);
11 andreas 89
        OBJECT_t *findFirstChild(ulong handle);
90
        OBJECT_t *findNextChild(ulong handle);
42 andreas 91
        OBJECT_t *getMarkedRemove();
92
        OBJECT_t *getNextMarkedRemove(OBJECT_t *obj);
142 andreas 93
        OBJECT_t *findFirstWindow();
94
        OBJECT_t *findNextWindow(OBJECT_t *obj);
107 andreas 95
        void cleanMarked();
198 andreas 96
        void removeAllChilds(ulong handle, bool drop=true);
97
        void removeObject(ulong handle, bool drop=true);
217 andreas 98
        void invalidateAllObjects();
99
        void invalidateAllSubObjects(ulong handle);
5 andreas 100
 
101
        static std::string handleToString(ulong handle)
102
        {
103
            ulong part1 = (handle >> 16) & 0x0000ffff;
104
            ulong part2 = handle & 0x0000ffff;
105
            return std::to_string(part1)+":"+std::to_string(part2);
106
        }
107
 
14 andreas 108
        static std::string objectToString(OBJECT_TYPE o);
198 andreas 109
        void dropContent(OBJECT_t *obj, bool lock=true);
14 andreas 110
 
5 andreas 111
    private:
112
        OBJECT_t *mObject{nullptr};
113
};
114
 
115
#endif