446 |
andreas |
1 |
/*
|
|
|
2 |
* Copyright (C) 2022, 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 __TPAGEINTERFACE_H__
|
|
|
20 |
#define __TPAGEINTERFACE_H__
|
|
|
21 |
|
|
|
22 |
#include <functional>
|
|
|
23 |
|
|
|
24 |
#include "tfont.h"
|
|
|
25 |
#include "tbutton.h"
|
|
|
26 |
#include "tsystembutton.h"
|
|
|
27 |
|
|
|
28 |
#define REGULAR_PAGE_START 0
|
|
|
29 |
#define REGULAR_SUBPAGE_START 500
|
|
|
30 |
|
|
|
31 |
#define SYSTEM_PAGE_START 5000
|
|
|
32 |
#define SYSTEM_SUBPAGE_START 5500
|
|
|
33 |
|
|
|
34 |
#define SYSTEM_PAGE_LOGGING 5001
|
|
|
35 |
#define SYSTEM_PAGE_LOG_TXLOGFILE 22
|
|
|
36 |
#define SYSTEM_PAGE_LOG_BTRESET 23
|
|
|
37 |
#define SYSTEM_PAGE_LOG_BTFILE 24
|
|
|
38 |
|
|
|
39 |
#define SYSTEM_PAGE_CONTROLLER 5002
|
|
|
40 |
#define SYSTEM_PAGE_CTRL_SURFACE 23
|
|
|
41 |
#define SYSTEM_PAGE_CTRL_DOWNLOAD 27
|
|
|
42 |
#define SYSTEM_SUBPAGE_SURFACE 5502
|
|
|
43 |
|
|
|
44 |
#define SYSTEM_PAGE_SOUND 5005
|
|
|
45 |
#define SYSTEM_PAGE_SOUND_TXSYSSOUND 10
|
|
|
46 |
#define SYSTEM_PAGE_SOUND_TXSINGLEBEEP 12
|
|
|
47 |
#define SYSTEM_PAGE_SOUND_TXDOUBLEBEEP 14
|
|
|
48 |
#define SYSTEM_SUBPAGE_SYSTEMSOUND 5503
|
|
|
49 |
#define SYSTEM_SUBPAGE_SINGLEBEEP 5504
|
|
|
50 |
#define SYSTEM_SUBPAGE_DOUBLEBEEP 5505
|
|
|
51 |
|
|
|
52 |
#define SYSTEM_LIST_SURFACE 2023
|
|
|
53 |
#define SYSTEM_LIST_SYSTEMSOUND 2024
|
|
|
54 |
#define SYSTEM_LIST_SINGLEBEEP 2025
|
|
|
55 |
#define SYSTEM_LIST_DOUBLEBEEP 2026
|
|
|
56 |
|
|
|
57 |
#define SYSTEM_ITEM_SYSGAIN 6
|
|
|
58 |
#define SYSTEM_ITEM_CONNSTATE 8
|
|
|
59 |
#define SYSTEM_ITEM_SYSVOLUME 9
|
|
|
60 |
#define SYSTEM_ITEM_SOUNDSWITCH 17
|
|
|
61 |
#define SYSTEM_ITEM_FTPSURFACE 25
|
|
|
62 |
#define SYSTEM_ITEM_SETUPPAGE 73
|
|
|
63 |
#define SYSTEM_ITEM_SHUTDOWN 80
|
|
|
64 |
#define SYSTEM_ITEM_CONNSTRENGTH 81
|
|
|
65 |
#define SYSTEM_ITEM_NETLINX_IP 122
|
|
|
66 |
#define SYSTEM_ITEM_NETLINX_CHANNEL 123
|
|
|
67 |
#define SYSTEM_ITEM_NETLINX_PORT 124
|
|
|
68 |
|
|
|
69 |
#define SYSTEM_ITEM_STANDARDTIME 141
|
|
|
70 |
#define SYSTEM_ITEM_TIMEAMPM 142
|
|
|
71 |
#define SYSTEM_ITEM_TIME24 143
|
|
|
72 |
#define SYSTEM_ITEM_NETLINXPORT 144
|
|
|
73 |
#define SYSTEM_ITEM_DATEWEEKDAY 151
|
|
|
74 |
#define SYSTEM_ITEM_DATEMMDD 152
|
|
|
75 |
#define SYSTEM_ITEM_DATEDDMM 153
|
|
|
76 |
#define SYSTEM_ITEM_DATEMMDDYYYY 154
|
|
|
77 |
#define SYSTEM_ITEM_DATEDDMMYYYY 155
|
|
|
78 |
#define SYSTEM_ITEM_DATEMONDDYYYY 156
|
|
|
79 |
#define SYSTEM_ITEM_DATEDDMONYYYY 157
|
|
|
80 |
#define SYSTEM_ITEM_DATEYYYYMMDD 158
|
|
|
81 |
#define SYSTEM_ITEM_SOUNDPLAYTESTSOUND 159
|
|
|
82 |
#define SYSTEM_ITEM_VOLUMEUP 171
|
|
|
83 |
#define SYSTEM_ITEM_VOLUMEDOWN 172
|
|
|
84 |
#define SYSTEM_ITEM_VOLUMEMUTE 173
|
|
|
85 |
|
|
|
86 |
#define SYSTEM_ITEM_NETLINX_PTYPE 199
|
|
|
87 |
|
|
|
88 |
#define SYSTEM_ITEM_BATTERYCHARGING 234
|
|
|
89 |
#define SYSTEM_ITEM_BATTERYLEVEL 242
|
|
|
90 |
|
|
|
91 |
#define SYSTEM_ITEM_SINGLEBEEP 404
|
|
|
92 |
#define SYSTEM_ITEM_DOUBLEBEEP 405
|
|
|
93 |
|
|
|
94 |
#define SYSTEM_ITEM_BTSAVESETTINGS 412
|
|
|
95 |
#define SYSTEM_ITEM_BTCANCELSETTINGS 413
|
|
|
96 |
#define SYSTEM_ITEM_SIPENABLE 416
|
|
|
97 |
#define SYSTEM_ITEM_SIPPROXY 418
|
|
|
98 |
#define SYSTEM_ITEM_SIPPORT 419
|
|
|
99 |
#define SYSTEM_ITEM_SIPSTUN 420
|
|
|
100 |
#define SYSTEM_ITEM_SIPDOMAIN 421
|
|
|
101 |
#define SYSTEM_ITEM_SIPUSER 422
|
|
|
102 |
#define SYSTEM_ITEM_SIPPASSWORD 423
|
|
|
103 |
|
|
|
104 |
#define SYSTEM_ITEM_SYSTEMSOUND 1143
|
|
|
105 |
|
|
|
106 |
#define SYSTEM_ITEM_DEBUGINFO 2000
|
|
|
107 |
#define SYSTEM_ITEM_DEBUGWARNING 2001
|
|
|
108 |
#define SYSTEM_ITEM_DEBUGERROR 2002
|
|
|
109 |
#define SYSTEM_ITEM_DEBUGTRACE 2003
|
|
|
110 |
#define SYSTEM_ITEM_DEBUGDEBUG 2004
|
|
|
111 |
#define SYSTEM_ITEM_DEBUGPROTOCOL 2005
|
|
|
112 |
#define SYSTEM_ITEM_DEBUGALL 2006
|
|
|
113 |
#define SYSTEM_ITEM_DEBUGPROFILE 2007
|
|
|
114 |
#define SYSTEM_ITEM_DEBUGLONG 2008
|
|
|
115 |
#define SYSTEM_ITEM_LOGLOGFILE 2009
|
|
|
116 |
#define SYSTEM_ITEM_LOGRESET 2010
|
|
|
117 |
#define SYSTEM_ITEM_LOGFILEOPEN 2011
|
|
|
118 |
|
|
|
119 |
#define SYSTEM_ITEM_FTPUSER 2020
|
|
|
120 |
#define SYSTEM_ITEM_FTPPASSWORD 2021
|
|
|
121 |
#define SYSTEM_ITEM_FTPDOWNLOAD 2030
|
|
|
122 |
#define SYSTEM_ITEM_FTPPASSIVE 2031
|
|
|
123 |
|
|
|
124 |
#define SYSTEM_ITEM_SOUNDPLAYSYSSOUND 2050
|
|
|
125 |
#define SYSTEM_ITEM_SOUNDPLAYBEEP 2051
|
|
|
126 |
#define SYSTEM_ITEM_SOUNDPLAYDBEEP 2052
|
|
|
127 |
#define SYSTEM_ITEM_SIPIPV4 2060
|
|
|
128 |
#define SYSTEM_ITEM_SIPIPV6 2061
|
|
|
129 |
#define SYSTEM_ITEM_SIPIPHONE 2062
|
|
|
130 |
#define SYSTEM_ITEM_VIEWSCALEFIT 2070
|
|
|
131 |
#define SYSTEM_ITEM_VIEWBANNER 2071
|
|
|
132 |
#define SYSTEM_ITEM_VIEWNOTOOLBAR 2072
|
|
|
133 |
#define SYSTEM_ITEM_VIEWTOOLBAR 2073
|
|
|
134 |
#define SYSTEM_ITEM_VIEWROTATE 2074
|
|
|
135 |
|
|
|
136 |
class TSubPage;
|
|
|
137 |
|
|
|
138 |
enum SHOWEFFECT
|
|
|
139 |
{
|
|
|
140 |
SE_NONE,
|
|
|
141 |
SE_FADE,
|
|
|
142 |
SE_SLIDE_LEFT,
|
|
|
143 |
SE_SLIDE_RIGHT,
|
|
|
144 |
SE_SLIDE_TOP,
|
|
|
145 |
SE_SLIDE_BOTTOM,
|
|
|
146 |
SE_SLIDE_LEFT_FADE,
|
|
|
147 |
SE_SLIDE_RIGHT_FADE,
|
|
|
148 |
SE_SLIDE_TOP_FADE,
|
|
|
149 |
SE_SLIDE_BOTTOM_FADE
|
|
|
150 |
};
|
|
|
151 |
|
|
|
152 |
typedef SHOWEFFECT SHOWEFFECT_t;
|
|
|
153 |
|
|
|
154 |
typedef struct ANIMATION_t
|
|
|
155 |
{
|
|
|
156 |
SHOWEFFECT_t showEffect{SE_NONE};
|
|
|
157 |
int showTime{0};
|
|
|
158 |
SHOWEFFECT_t hideEffect{SE_NONE};
|
|
|
159 |
int hideTime{0};
|
|
|
160 |
}ANIMATION_t;
|
|
|
161 |
|
|
|
162 |
typedef struct PAGE_T
|
|
|
163 |
{
|
|
|
164 |
std::string popupType; // The type of the popup (popup only)
|
|
|
165 |
int pageID{0}; // Unique ID of popup/page
|
|
|
166 |
std::string name; // The name of the popup/page
|
|
|
167 |
int left{0}; // Left position of popup (always 0 for pages)
|
|
|
168 |
int leftOrig{0}; // Original left position; Not used for pages
|
|
|
169 |
int top{0}; // Top position of popup (always 0 for pages)
|
|
|
170 |
int topOrig{0}; // Original top position; (not used for pages)
|
|
|
171 |
int width{0}; // Width of popup
|
|
|
172 |
int widthOrig{0}; // The original width of the popup
|
|
|
173 |
int height{0}; // Height of popup
|
|
|
174 |
int heightOrig{0}; // The original height of the popup
|
|
|
175 |
int modal{0}; // 0 = Popup/Page = non modal
|
|
|
176 |
std::string group; // Name of the group the popup belongs (popup only)
|
|
|
177 |
int timeout{0}; // Time after the popup hides in 1/10 seconds (popup only)
|
|
|
178 |
SHOWEFFECT showEffect{SE_NONE}; // The effect when the popup is shown (popup only)
|
|
|
179 |
int showTime{0}; // The time reserved for the show effect (popup only)
|
|
|
180 |
int showX{0}; // End of show effect position (by default "left+width"); (popup only)
|
|
|
181 |
int showY{0}; // End of show effect position (by default "top+height"); (popup only)
|
|
|
182 |
SHOWEFFECT hideEffect{SE_NONE}; // The effect when the popup hides (popup only)
|
|
|
183 |
int hideTime{0}; // The time reserved for the hide effect (popup only)
|
|
|
184 |
int hideX{0}; // End of hide effect position (by default "left"); (popup only)
|
|
|
185 |
int hideY{0}; // End of hide effect position (by default "top"); (popup only)
|
|
|
186 |
int resetPos{0}; // If this is 1 the popup is reset to it's original position and size on open
|
|
|
187 |
std::vector<Button::SR_T> sr; // Page/Popup description
|
|
|
188 |
}PAGE_T;
|
|
|
189 |
|
|
|
190 |
/**
|
|
|
191 |
* This class in an interface to manage pages and subpages. Both classes of
|
|
|
192 |
* TPage and TSubpage have a lot of identical functions. This functions are
|
|
|
193 |
* in this class.
|
|
|
194 |
*/
|
|
|
195 |
class TPageInterface : public TSystemButton
|
|
|
196 |
{
|
|
|
197 |
public:
|
|
|
198 |
virtual ~TPageInterface() {}
|
|
|
199 |
|
|
|
200 |
bool drawText(PAGE_T& pinfo, SkBitmap *img);
|
|
|
201 |
bool drawFrame(PAGE_T& pinfo, SkBitmap* bm);
|
|
|
202 |
#ifdef _OPAQUE_SKIA_
|
|
|
203 |
bool setOpacity(SkBitmap *bm, int oo);
|
|
|
204 |
#endif
|
|
|
205 |
virtual int getNumber() = 0;
|
|
|
206 |
virtual std::string& getName() = 0;
|
|
|
207 |
virtual void show() = 0;
|
|
|
208 |
virtual void drop() = 0;
|
|
|
209 |
virtual SkBitmap& getBgImage() = 0;
|
|
|
210 |
virtual std::string getFillColor() = 0;
|
|
|
211 |
|
|
|
212 |
void setButtons(Button::BUTTONS_T *bt) { mButtons = bt; }
|
|
|
213 |
Button::BUTTONS_T *getButtons() { return mButtons; }
|
|
|
214 |
Button::BUTTONS_T *addButton(Button::TButton* button);
|
|
|
215 |
Button::TButton *getButton(int id);
|
|
|
216 |
std::vector<Button::TButton *> getButtons(int ap, int ad);
|
|
|
217 |
std::vector<Button::TButton *> getAllButtons();
|
|
|
218 |
bool hasButton(int id);
|
|
|
219 |
bool sortButtons();
|
|
|
220 |
Button::TButton *getFirstButton();
|
|
|
221 |
Button::TButton *getNextButton();
|
|
|
222 |
Button::TButton *getLastButton();
|
|
|
223 |
Button::TButton *getPreviousButton();
|
|
|
224 |
|
|
|
225 |
void setSR(std::vector<Button::SR_T>& s) { sr = s; }
|
|
|
226 |
std::vector<Button::SR_T>& getSR() { return sr; }
|
|
|
227 |
|
|
|
228 |
void setFonts(TFont *f);
|
|
|
229 |
TFont *getFonts() { return mFonts; }
|
|
|
230 |
|
|
|
231 |
void setSelectedRow(ulong handle, int row);
|
|
|
232 |
int getSelectedRow(ulong handle);
|
|
|
233 |
std::string getSelectedItem(ulong handle);
|
|
|
234 |
|
|
|
235 |
template<typename T>
|
|
|
236 |
inline void registerListCallback(Button::TButton *button, T *pg)
|
|
|
237 |
{
|
|
|
238 |
if (!button || !pg)
|
|
|
239 |
return;
|
|
|
240 |
|
|
|
241 |
button->regCallListContent(std::bind(&TPageInterface::getListContent, pg, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6));
|
|
|
242 |
button->regCallListRow(std::bind(&TPageInterface::getListRow, pg, std::placeholders::_1, std::placeholders::_2));
|
|
|
243 |
button->regCallGlobalSettings(std::bind(&TPageInterface::setGlobalSettings, pg, std::placeholders::_1));
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
static bool isSystemPage(int ID) { return ID >= SYSTEM_PAGE_START && ID < SYSTEM_SUBPAGE_START; }
|
|
|
247 |
static bool isSystemSubPage(int ID) { return ID >= SYSTEM_SUBPAGE_START; }
|
|
|
248 |
static bool isRegularPage(int ID) { return ID > REGULAR_PAGE_START && ID < REGULAR_SUBPAGE_START; }
|
|
|
249 |
static bool isRegularSubPage(int ID) { return ID >= REGULAR_SUBPAGE_START && ID < SYSTEM_PAGE_START; }
|
|
|
250 |
|
|
|
251 |
protected:
|
|
|
252 |
typedef struct LIST_t
|
|
|
253 |
{
|
|
|
254 |
ulong handle{0};
|
|
|
255 |
int ap{0};
|
|
|
256 |
int ta{0};
|
|
|
257 |
int ti{0};
|
|
|
258 |
int rows{0};
|
|
|
259 |
int columns{0};
|
|
|
260 |
int selected{-1};
|
|
|
261 |
std::vector<std::string> list;
|
|
|
262 |
}LIST_t;
|
|
|
263 |
|
|
|
264 |
std::vector<std::string> getListContent(ulong handle, int ap, int ta, int ti, int rows, int columns);
|
|
|
265 |
std::string getListRow(int ti, int row);
|
|
|
266 |
void setGlobalSettings(Button::TButton *button);
|
|
|
267 |
|
|
|
268 |
private:
|
|
|
269 |
Button::POSITION_t calcImagePosition(PAGE_T *page, int width, int height, Button::CENTER_CODE cc, int line);
|
|
|
270 |
int calcLineHeight(const std::string& text, SkFont& font);
|
|
|
271 |
int numberLines(const std::string& str);
|
|
|
272 |
int getSystemSelection(int ta, std::vector<std::string>& list);
|
|
|
273 |
bool getBorderFragment(const std::string& path, const std::string& pathAlpha, SkBitmap* image, SkColor color);
|
|
|
274 |
SkBitmap retrieveBorderImage(const std::string& pa, const std::string& pb, SkColor color, SkColor bgColor);
|
|
|
275 |
bool retrieveImage(const std::string& path, SkBitmap* image);
|
|
|
276 |
SkBitmap colorImage(SkBitmap& base, SkBitmap& alpha, SkColor col, SkColor bg, bool useBG);
|
|
|
277 |
bool stretchImageWidth(SkBitmap *bm, int width);
|
|
|
278 |
bool stretchImageHeight(SkBitmap *bm, int height);
|
|
|
279 |
|
|
|
280 |
Button::BUTTONS_T *mButtons{nullptr}; // Chain of buttons
|
|
|
281 |
int mLastButton{0}; // Internal counter for iterating through button chain.
|
|
|
282 |
std::vector<Button::SR_T> sr; // Button instances
|
|
|
283 |
TFont *mFonts{nullptr}; // Holds the class with the font list
|
|
|
284 |
std::vector<LIST_t> mLists; // Lists of page
|
|
|
285 |
};
|
|
|
286 |
|
|
|
287 |
#endif
|