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