Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

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