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
 
279 andreas 24
#include "tpageinterface.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;
285 andreas 36
class TQScrollArea;
296 andreas 37
class MainWindow;
5 andreas 38
QT_END_NAMESPACE
39
 
40
class TObject
41
{
42
    public:
43
        typedef enum OBJECT_TYPE
44
        {
45
            OBJ_NONE,
46
            OBJ_PAGE,
47
            OBJ_SUBPAGE,
48
            OBJ_BUTTON,
49
            OBJ_TEXT,
21 andreas 50
            OBJ_INPUT,
200 andreas 51
            OBJ_LIST,
279 andreas 52
            OBJ_VIDEO,
53
            OBJ_SUBVIEW
5 andreas 54
        }OBJECT_TYPE;
55
 
56
        typedef union _OBJ
57
        {
21 andreas 58
            QVideoWidget *vwidget{nullptr}; // A video window
59
            QLabel *label;                  // For buttons
60
            QWidget *widget;                // For subpage
200 andreas 61
            TQEditLine *plaintext;          // For text input
285 andreas 62
            QListWidget *list;              // For lists
63
            TQScrollArea *area;             // For scroll area
5 andreas 64
        }_OBJ;
65
 
66
        typedef struct OBJECT_t
67
        {
68
            OBJECT_TYPE type{OBJ_NONE};
69
            ulong handle{0};
70
            _OBJ object;
21 andreas 71
            QMediaPlayer *player{nullptr};  // Pointer to video player if this is a video button
5 andreas 72
            int left{0};
73
            int top{0};
74
            int width{0};
75
            int height{0};
200 andreas 76
            int rows{0};
77
            int cols{0};
271 andreas 78
            bool invalid{true};
41 andreas 79
            QPropertyAnimation *animation{nullptr};
42 andreas 80
            ANIMATION_t animate;
107 andreas 81
            bool aniDirection{false};
51 andreas 82
            WId wid{0};                     // Used to identify a QTextEdit or QLineEdit
296 andreas 83
            bool remove{false};             // Object is marked for remove. Used with animation.
321 andreas 84
            bool connected{false};          // TRUE = there is a connection.
5 andreas 85
        }OBJECT_t;
86
 
87
        TObject();
88
        ~TObject();
89
 
296 andreas 90
        void setParent(MainWindow *mw) { mMainWindow = mw; }
89 andreas 91
        void clear(bool force=false);
296 andreas 92
        bool addObject(OBJECT_t& obj);
5 andreas 93
        OBJECT_t *findObject(ulong handle);
51 andreas 94
        OBJECT_t *findObject(WId id);
11 andreas 95
        OBJECT_t *findFirstChild(ulong handle);
96
        OBJECT_t *findNextChild(ulong handle);
42 andreas 97
        OBJECT_t *getMarkedRemove();
98
        OBJECT_t *getNextMarkedRemove(OBJECT_t *obj);
142 andreas 99
        OBJECT_t *findFirstWindow();
100
        OBJECT_t *findNextWindow(OBJECT_t *obj);
107 andreas 101
        void cleanMarked();
198 andreas 102
        void removeAllChilds(ulong handle, bool drop=true);
103
        void removeObject(ulong handle, bool drop=true);
217 andreas 104
        void invalidateAllObjects();
296 andreas 105
        void invalidateObject(ulong handle);
217 andreas 106
        void invalidateAllSubObjects(ulong handle);
296 andreas 107
        bool enableObject(ulong handle);
108
        bool enableAllSubObjects(ulong handle);
5 andreas 109
 
14 andreas 110
        static std::string objectToString(OBJECT_TYPE o);
198 andreas 111
        void dropContent(OBJECT_t *obj, bool lock=true);
14 andreas 112
 
5 andreas 113
    private:
293 andreas 114
        std::mutex mutex_obj;
115
 
296 andreas 116
        std::map<ulong, OBJECT_t> mObjects;
117
        MainWindow *mMainWindow;
5 andreas 118
};
119
 
120
#endif