3 |
andreas |
1 |
/*
|
21 |
andreas |
2 |
* Copyright (C) 2020, 2021 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"
|
7 |
andreas |
27 |
#include "tfont.h"
|
3 |
andreas |
28 |
|
|
|
29 |
enum SHOWEFFECT
|
|
|
30 |
{
|
|
|
31 |
SE_NONE,
|
|
|
32 |
SE_FADE,
|
|
|
33 |
SE_SLIDE_LEFT,
|
|
|
34 |
SE_SLIDE_RIGHT,
|
|
|
35 |
SE_SLIDE_TOP,
|
|
|
36 |
SE_SLIDE_BOTTOM,
|
|
|
37 |
SE_SLIDE_LEFT_FADE,
|
|
|
38 |
SE_SLIDE_RIGHT_FADE,
|
|
|
39 |
SE_SLIDE_TOP_FADE,
|
|
|
40 |
SE_SLIDE_BOTTOM_FADE
|
|
|
41 |
};
|
|
|
42 |
|
|
|
43 |
typedef struct SUBPAGE_T
|
|
|
44 |
{
|
|
|
45 |
std::string popupType; // The type of the popup
|
|
|
46 |
int pageID{0}; // Unique ID of popup/page
|
|
|
47 |
std::string name; // The name of the popup/page
|
|
|
48 |
int left{0}; // Left position of popup
|
|
|
49 |
int top{0}; // Top position of popup
|
|
|
50 |
int width{0}; // Width of popup
|
|
|
51 |
int height{0}; // Height of popup
|
|
|
52 |
int modal{0}; // 0 = Popup/Page = non modal
|
|
|
53 |
std::string group; // Name of the group the popup belongs
|
|
|
54 |
int timeout{0}; // Time after the popup hides in 1/10 seconds
|
|
|
55 |
SHOWEFFECT showEffect{SE_NONE}; // The effect when the popup is shown
|
|
|
56 |
int showTime{0}; // The time reserved for the show effect
|
15 |
andreas |
57 |
int showX{0}; // End of show effect position (by default "left+width");
|
|
|
58 |
int showY{0}; // End of show effect position (by default "top+height");
|
3 |
andreas |
59 |
SHOWEFFECT hideEffect{SE_NONE}; // The effect when the popup hides
|
|
|
60 |
int hideTime{0}; // The time reserved for the hide effect
|
15 |
andreas |
61 |
int hideX{0}; // End of hide effect position (by default "left");
|
|
|
62 |
int hideY{0}; // End of hide effect position (by default "top");
|
3 |
andreas |
63 |
std::vector<Button::SR_T> sr; // Page/Popup description
|
|
|
64 |
}SUBPAGE_T;
|
|
|
65 |
|
11 |
andreas |
66 |
typedef struct RECT_T
|
|
|
67 |
{
|
|
|
68 |
int left{0};
|
|
|
69 |
int top{0};
|
|
|
70 |
int width{0};
|
|
|
71 |
int height{0};
|
|
|
72 |
}RECT_T;
|
|
|
73 |
|
3 |
andreas |
74 |
class TSubPage : public TValidateFile
|
|
|
75 |
{
|
|
|
76 |
public:
|
|
|
77 |
TSubPage(const std::string& name);
|
|
|
78 |
~TSubPage();
|
|
|
79 |
|
4 |
andreas |
80 |
void setPalette(TPalette *pal) { mPalette = pal; }
|
7 |
andreas |
81 |
void setFonts(TFont *ft) { mFonts = ft; }
|
4 |
andreas |
82 |
|
3 |
andreas |
83 |
int getNumber() { return mSubpage.pageID; }
|
|
|
84 |
std::string& getName() { return mSubpage.name; }
|
|
|
85 |
SUBPAGE_T& getSubPage() { return mSubpage; }
|
11 |
andreas |
86 |
std::string& getGroupName() { return mSubpage.group; }
|
5 |
andreas |
87 |
int getLeft() { return mSubpage.left; }
|
15 |
andreas |
88 |
void setLeft(int l) { mSubpage.left = l; }
|
5 |
andreas |
89 |
int getTop() { return mSubpage.top; }
|
15 |
andreas |
90 |
void setTop(int t) { mSubpage.top = t; }
|
5 |
andreas |
91 |
int getWidth() { return mSubpage.width; }
|
15 |
andreas |
92 |
void setWidth(int w) { mSubpage.width = w; }
|
5 |
andreas |
93 |
int getHeight() { return mSubpage.height; }
|
15 |
andreas |
94 |
void setHeight(int h) { mSubpage.height = h; }
|
|
|
95 |
RECT_T getRegion();
|
14 |
andreas |
96 |
int getZOrder() { if (mVisible) return mZOrder; else return -1; }
|
|
|
97 |
void setZOrder(int z) { mZOrder = z; }
|
11 |
andreas |
98 |
void setGroup(const std::string& group) { mSubpage.group = group; }
|
12 |
andreas |
99 |
void setModal(int m) { mSubpage.modal = m; }
|
5 |
andreas |
100 |
bool isModal() { return (mSubpage.modal != 0); }
|
15 |
andreas |
101 |
SHOWEFFECT getShowEffect() { return mSubpage.showEffect; }
|
|
|
102 |
void setShowEffect(SHOWEFFECT se) { mSubpage.showEffect = se; }
|
|
|
103 |
int getShowTime() { return mSubpage.showTime; }
|
|
|
104 |
void setShowTime(int t) { mSubpage.showTime = t; }
|
|
|
105 |
void setShowEndPosition(int x, int y) { mSubpage.showX = x; mSubpage.showY = y; }
|
|
|
106 |
SHOWEFFECT getHideEffect() { return mSubpage.hideEffect; }
|
|
|
107 |
void setHideEffect(SHOWEFFECT he) { mSubpage.hideEffect = he; }
|
|
|
108 |
void setHideEndPosition(int x, int y) { mSubpage.hideX = x; mSubpage.hideY = y; }
|
|
|
109 |
int getHideTime() { return mSubpage.hideTime; }
|
|
|
110 |
void setHideTime(int t) { mSubpage.hideTime = t; }
|
|
|
111 |
int getTimeout() { return mSubpage.timeout; }
|
|
|
112 |
void setTimeout(int t) { mSubpage.timeout = t; }
|
11 |
andreas |
113 |
bool isVisible() { return mVisible; }
|
14 |
andreas |
114 |
bool hasButton(int id);
|
|
|
115 |
Button::TButton *getButton(int id);
|
16 |
andreas |
116 |
std::vector<Button::TButton *> getButtons(int ap, int ad);
|
6 |
andreas |
117 |
void show();
|
11 |
andreas |
118 |
void drop();
|
|
|
119 |
void doClick(int x, int y, bool pressed);
|
6 |
andreas |
120 |
void registerCallback(std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)> setBackground) { _setBackground = setBackground; }
|
|
|
121 |
void registerCallbackDB(std::function<void(ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> displayButton) { _displayButton = displayButton; }
|
7 |
andreas |
122 |
void registerCallbackFT(std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)> setText)
|
|
|
123 |
{ _setText = setText; }
|
11 |
andreas |
124 |
void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
|
21 |
andreas |
125 |
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 |
126 |
|
|
|
127 |
protected:
|
|
|
128 |
void initialize();
|
|
|
129 |
Button::BUTTONS_T *addButton(Button::TButton* button);
|
|
|
130 |
bool sortButtons();
|
|
|
131 |
|
|
|
132 |
private:
|
6 |
andreas |
133 |
std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)> _setBackground{nullptr};
|
|
|
134 |
std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
|
7 |
andreas |
135 |
std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)> _setText{nullptr};
|
11 |
andreas |
136 |
std::function<void (ulong handle)> _callDropSubPage{nullptr};
|
21 |
andreas |
137 |
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 |
138 |
|
14 |
andreas |
139 |
bool mVisible{false}; // TRUE = subpage is visible
|
|
|
140 |
std::string mFName; // The file name of the page
|
|
|
141 |
std::string mFile; // The path and file name of the page
|
|
|
142 |
TPalette *mPalette{nullptr}; // The color palette
|
|
|
143 |
SUBPAGE_T mSubpage; // Parameters of the subpage
|
|
|
144 |
Button::BUTTONS_T *mButtons{nullptr}; // The elements of the subpage
|
|
|
145 |
TFont *mFonts{nullptr}; // The font management
|
|
|
146 |
int mZOrder{-1}; // The Z-Order of the subpage if it is visible
|
3 |
andreas |
147 |
};
|
|
|
148 |
|
|
|
149 |
#endif
|