3 |
andreas |
1 |
/*
|
289 |
andreas |
2 |
* Copyright (C) 2020 to 2023 by Andreas Theofilu <andreas@theosys.at>
|
3 |
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 __TSUBPAGE_H__
|
|
|
20 |
#define __TSUBPAGE_H__
|
|
|
21 |
|
|
|
22 |
#include <string>
|
|
|
23 |
#include <vector>
|
|
|
24 |
#include "tbutton.h"
|
|
|
25 |
#include "tvalidatefile.h"
|
4 |
andreas |
26 |
#include "tpalette.h"
|
201 |
andreas |
27 |
#include "tpageinterface.h"
|
306 |
andreas |
28 |
#include "tintborder.h"
|
3 |
andreas |
29 |
|
289 |
andreas |
30 |
class TBitmap;
|
|
|
31 |
|
11 |
andreas |
32 |
typedef struct RECT_T
|
|
|
33 |
{
|
|
|
34 |
int left{0};
|
|
|
35 |
int top{0};
|
|
|
36 |
int width{0};
|
|
|
37 |
int height{0};
|
|
|
38 |
}RECT_T;
|
|
|
39 |
|
306 |
andreas |
40 |
class TSubPage : public TValidateFile, public TPageInterface, public Border::TIntBorder
|
3 |
andreas |
41 |
{
|
|
|
42 |
public:
|
|
|
43 |
TSubPage(const std::string& name);
|
|
|
44 |
~TSubPage();
|
|
|
45 |
|
4 |
andreas |
46 |
void setPalette(TPalette *pal) { mPalette = pal; }
|
|
|
47 |
|
3 |
andreas |
48 |
int getNumber() { return mSubpage.pageID; }
|
286 |
andreas |
49 |
std::string& getPopupType() { return mSubpage.popupType; }
|
3 |
andreas |
50 |
std::string& getName() { return mSubpage.name; }
|
201 |
andreas |
51 |
PAGE_T& getSubPage() { return mSubpage; }
|
11 |
andreas |
52 |
std::string& getGroupName() { return mSubpage.group; }
|
5 |
andreas |
53 |
int getLeft() { return mSubpage.left; }
|
408 |
andreas |
54 |
int getLeftOrig() { return mSubpage.leftOrig; }
|
15 |
andreas |
55 |
void setLeft(int l) { mSubpage.left = l; }
|
5 |
andreas |
56 |
int getTop() { return mSubpage.top; }
|
408 |
andreas |
57 |
int getTopOrig() { return mSubpage.topOrig; }
|
15 |
andreas |
58 |
void setTop(int t) { mSubpage.top = t; }
|
5 |
andreas |
59 |
int getWidth() { return mSubpage.width; }
|
15 |
andreas |
60 |
void setWidth(int w) { mSubpage.width = w; }
|
5 |
andreas |
61 |
int getHeight() { return mSubpage.height; }
|
15 |
andreas |
62 |
void setHeight(int h) { mSubpage.height = h; }
|
|
|
63 |
RECT_T getRegion();
|
14 |
andreas |
64 |
int getZOrder() { if (mVisible) return mZOrder; else return -1; }
|
|
|
65 |
void setZOrder(int z) { mZOrder = z; }
|
11 |
andreas |
66 |
void setGroup(const std::string& group) { mSubpage.group = group; }
|
12 |
andreas |
67 |
void setModal(int m) { mSubpage.modal = m; }
|
5 |
andreas |
68 |
bool isModal() { return (mSubpage.modal != 0); }
|
15 |
andreas |
69 |
SHOWEFFECT getShowEffect() { return mSubpage.showEffect; }
|
|
|
70 |
void setShowEffect(SHOWEFFECT se) { mSubpage.showEffect = se; }
|
|
|
71 |
int getShowTime() { return mSubpage.showTime; }
|
|
|
72 |
void setShowTime(int t) { mSubpage.showTime = t; }
|
|
|
73 |
void setShowEndPosition(int x, int y) { mSubpage.showX = x; mSubpage.showY = y; }
|
351 |
andreas |
74 |
void getShowEndPosition(int *x, int *y) { if (x) *x = mSubpage.showX; if (y) *y = mSubpage.showY; }
|
15 |
andreas |
75 |
SHOWEFFECT getHideEffect() { return mSubpage.hideEffect; }
|
|
|
76 |
void setHideEffect(SHOWEFFECT he) { mSubpage.hideEffect = he; }
|
|
|
77 |
void setHideEndPosition(int x, int y) { mSubpage.hideX = x; mSubpage.hideY = y; }
|
348 |
andreas |
78 |
void getHideEndPosition(int *x, int *y) { if (x) *x = mSubpage.hideX; if (y) *y = mSubpage.hideY; }
|
15 |
andreas |
79 |
int getHideTime() { return mSubpage.hideTime; }
|
|
|
80 |
void setHideTime(int t) { mSubpage.hideTime = t; }
|
|
|
81 |
int getTimeout() { return mSubpage.timeout; }
|
|
|
82 |
void setTimeout(int t) { mSubpage.timeout = t; }
|
11 |
andreas |
83 |
bool isVisible() { return mVisible; }
|
154 |
andreas |
84 |
ulong getHandle() { return ((mSubpage.pageID << 16) & 0xffff0000); }
|
306 |
andreas |
85 |
ulong getParent() { return mParent; }
|
|
|
86 |
void setParent(ulong handle) { mParent = handle; }
|
281 |
andreas |
87 |
std::string getFillColor() { return mSubpage.sr[0].cf; }
|
|
|
88 |
std::string getTextColor() { return mSubpage.sr[0].ct; }
|
289 |
andreas |
89 |
SkBitmap& getBgImage();
|
281 |
andreas |
90 |
|
6 |
andreas |
91 |
void show();
|
11 |
andreas |
92 |
void drop();
|
|
|
93 |
void doClick(int x, int y, bool pressed);
|
409 |
andreas |
94 |
void moveMouse(int x, int y);
|
54 |
andreas |
95 |
void startTimer();
|
|
|
96 |
void stopTimer() { mTimerRunning = false; }
|
262 |
andreas |
97 |
#ifdef _OPAQUE_SKIA_
|
289 |
andreas |
98 |
void registerCallback(std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> setBackground) { _setBackground = setBackground; }
|
262 |
andreas |
99 |
#else
|
289 |
andreas |
100 |
void registerCallback(std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> setBackground) { _setBackground = setBackground; }
|
262 |
andreas |
101 |
#endif
|
391 |
andreas |
102 |
void registerCallbackDB(std::function<void(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> displayButton) { _displayButton = displayButton; }
|
350 |
andreas |
103 |
void regCallDropSubPage(std::function<void (ulong handle, ulong parent)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
|
21 |
andreas |
104 |
void regCallPlayVideo(std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> playVideo) { _playVideo = playVideo; };
|
3 |
andreas |
105 |
|
|
|
106 |
protected:
|
|
|
107 |
void initialize();
|
53 |
andreas |
108 |
void runTimer();
|
43 |
andreas |
109 |
#ifdef _SCALE_SKIA_
|
31 |
andreas |
110 |
void calcPosition(int im_width, int im_height, int *left, int *top, bool scale = false);
|
43 |
andreas |
111 |
#else
|
|
|
112 |
void calcPosition(int im_width, int im_height, int *left, int *top);
|
|
|
113 |
#endif
|
3 |
andreas |
114 |
private:
|
262 |
andreas |
115 |
#ifdef _OPAQUE_SKIA_
|
289 |
andreas |
116 |
std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> _setBackground{nullptr};
|
262 |
andreas |
117 |
#else
|
289 |
andreas |
118 |
std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> _setBackground{nullptr};
|
262 |
andreas |
119 |
#endif
|
391 |
andreas |
120 |
std::function<void (ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> _displayButton{nullptr};
|
350 |
andreas |
121 |
std::function<void (ulong handle, ulong parent)> _callDropSubPage{nullptr};
|
21 |
andreas |
122 |
std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> _playVideo{nullptr};
|
6 |
andreas |
123 |
|
14 |
andreas |
124 |
bool mVisible{false}; // TRUE = subpage is visible
|
|
|
125 |
std::string mFName; // The file name of the page
|
|
|
126 |
std::string mFile; // The path and file name of the page
|
|
|
127 |
TPalette *mPalette{nullptr}; // The color palette
|
201 |
andreas |
128 |
PAGE_T mSubpage; // Parameters of the subpage
|
306 |
andreas |
129 |
ulong mParent{0}; // The handle of the parent page or view button
|
14 |
andreas |
130 |
int mZOrder{-1}; // The Z-Order of the subpage if it is visible
|
289 |
andreas |
131 |
SkBitmap mBgImage; // The background image (cache).
|
53 |
andreas |
132 |
std::atomic<bool>mTimerRunning{false}; // TRUE= timer is running
|
|
|
133 |
std::thread mThreadTimer; // The thread started if a timeout is defined.
|
199 |
andreas |
134 |
std::vector<LIST_t> mLists; // Lists of subpage
|
3 |
andreas |
135 |
};
|
|
|
136 |
|
|
|
137 |
#endif
|