446 |
andreas |
1 |
/*
|
486 |
andreas |
2 |
* Copyright (C) 2020 to 2025 by Andreas Theofilu <andreas@theosys.at>
|
446 |
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 |
#ifndef __TBUTTON_H__
|
|
|
19 |
#define __TBUTTON_H__
|
|
|
20 |
|
|
|
21 |
#include <string>
|
|
|
22 |
#include <vector>
|
|
|
23 |
#include <map>
|
|
|
24 |
#include <functional>
|
|
|
25 |
#include <thread>
|
|
|
26 |
|
|
|
27 |
#include <include/core/SkImage.h>
|
|
|
28 |
#include <include/core/SkCanvas.h>
|
|
|
29 |
#include <include/core/SkBitmap.h>
|
|
|
30 |
|
|
|
31 |
#include "texpat++.h"
|
|
|
32 |
#include "tpalette.h"
|
|
|
33 |
#include "tcolor.h"
|
|
|
34 |
#include "tfont.h"
|
|
|
35 |
#include "tamxnet.h"
|
|
|
36 |
#include "ttimer.h"
|
|
|
37 |
#include "timagerefresh.h"
|
|
|
38 |
#include "tsystem.h"
|
|
|
39 |
#include "tintborder.h"
|
|
|
40 |
#include "tsystemdraw.h"
|
|
|
41 |
|
|
|
42 |
#define ORD_ELEM_COUNT 5
|
|
|
43 |
|
|
|
44 |
extern bool prg_stopped;
|
|
|
45 |
extern bool _restart_;
|
|
|
46 |
|
|
|
47 |
class SkFont;
|
|
|
48 |
class SkTextBlob;
|
|
|
49 |
class TBitmap;
|
|
|
50 |
class TButtonStates;
|
|
|
51 |
|
|
|
52 |
struct RESOURCE_T;
|
|
|
53 |
|
|
|
54 |
namespace Button
|
|
|
55 |
{
|
|
|
56 |
# define STATE_BASE 0
|
|
|
57 |
# define STATE_OFF 0
|
|
|
58 |
# define STATE_ON 1
|
|
|
59 |
# define STATE_1 0
|
|
|
60 |
# define STATE_2 1
|
|
|
61 |
# define STATE_3 2
|
|
|
62 |
# define STATE_4 3
|
|
|
63 |
# define STATE_5 4
|
|
|
64 |
# define STATE_6 5
|
|
|
65 |
# define STATE_7 6
|
|
|
66 |
# define STATE_8 7
|
|
|
67 |
# define STATE_ALL -1
|
|
|
68 |
|
|
|
69 |
# define HANDLE_UNDEF 0
|
|
|
70 |
|
486 |
andreas |
71 |
typedef struct SYSTEF_t // Text effect names
|
446 |
andreas |
72 |
{
|
|
|
73 |
int idx{0};
|
|
|
74 |
std::string name;
|
|
|
75 |
}SYSTEF_t;
|
|
|
76 |
|
479 |
andreas |
77 |
typedef enum ORIENTATION
|
446 |
andreas |
78 |
{
|
|
|
79 |
ORI_ABSOLUT,
|
|
|
80 |
ORI_TOP_LEFT,
|
|
|
81 |
ORI_TOP_MIDDLE,
|
|
|
82 |
ORI_TOP_RIGHT,
|
|
|
83 |
ORI_CENTER_LEFT,
|
486 |
andreas |
84 |
ORI_CENTER_MIDDLE, // default
|
446 |
andreas |
85 |
ORI_CENTER_RIGHT,
|
|
|
86 |
ORI_BOTTOM_LEFT,
|
|
|
87 |
ORI_BOTTOM_MIDDLE,
|
479 |
andreas |
88 |
ORI_BOTTOM_RIGHT,
|
|
|
89 |
ORI_SCALE_FIT, // G5 scale to fit
|
|
|
90 |
ORI_SCALE_ASPECT // G5 scale maintain aspect ratio
|
|
|
91 |
}ORIENTATION;
|
446 |
andreas |
92 |
|
|
|
93 |
typedef enum TEXT_EFFECT
|
|
|
94 |
{
|
|
|
95 |
EFFECT_NONE,
|
|
|
96 |
EFFECT_OUTLINE_S,
|
|
|
97 |
EFFECT_OUTLINE_M,
|
|
|
98 |
EFFECT_OUTLINE_L,
|
|
|
99 |
EFFECT_OUTLINE_X,
|
|
|
100 |
EFFECT_GLOW_S,
|
|
|
101 |
EFFECT_GLOW_M,
|
|
|
102 |
EFFECT_GLOW_L,
|
|
|
103 |
EFFECT_GLOW_X,
|
|
|
104 |
EFFECT_SOFT_DROP_SHADOW_1,
|
|
|
105 |
EFFECT_SOFT_DROP_SHADOW_2,
|
|
|
106 |
EFFECT_SOFT_DROP_SHADOW_3,
|
|
|
107 |
EFFECT_SOFT_DROP_SHADOW_4,
|
|
|
108 |
EFFECT_SOFT_DROP_SHADOW_5,
|
|
|
109 |
EFFECT_SOFT_DROP_SHADOW_6,
|
|
|
110 |
EFFECT_SOFT_DROP_SHADOW_7,
|
|
|
111 |
EFFECT_SOFT_DROP_SHADOW_8,
|
|
|
112 |
EFFECT_MEDIUM_DROP_SHADOW_1,
|
|
|
113 |
EFFECT_MEDIUM_DROP_SHADOW_2,
|
|
|
114 |
EFFECT_MEDIUM_DROP_SHADOW_3,
|
|
|
115 |
EFFECT_MEDIUM_DROP_SHADOW_4,
|
|
|
116 |
EFFECT_MEDIUM_DROP_SHADOW_5,
|
|
|
117 |
EFFECT_MEDIUM_DROP_SHADOW_6,
|
|
|
118 |
EFFECT_MEDIUM_DROP_SHADOW_7,
|
|
|
119 |
EFFECT_MEDIUM_DROP_SHADOW_8,
|
|
|
120 |
EFFECT_HARD_DROP_SHADOW_1,
|
|
|
121 |
EFFECT_HARD_DROP_SHADOW_2,
|
|
|
122 |
EFFECT_HARD_DROP_SHADOW_3,
|
|
|
123 |
EFFECT_HARD_DROP_SHADOW_4,
|
|
|
124 |
EFFECT_HARD_DROP_SHADOW_5,
|
|
|
125 |
EFFECT_HARD_DROP_SHADOW_6,
|
|
|
126 |
EFFECT_HARD_DROP_SHADOW_7,
|
|
|
127 |
EFFECT_HARD_DROP_SHADOW_8,
|
|
|
128 |
EFFECT_SOFT_DROP_SHADOW_1_WITH_OUTLINE,
|
|
|
129 |
EFFECT_SOFT_DROP_SHADOW_2_WITH_OUTLINE,
|
|
|
130 |
EFFECT_SOFT_DROP_SHADOW_3_WITH_OUTLINE,
|
|
|
131 |
EFFECT_SOFT_DROP_SHADOW_4_WITH_OUTLINE,
|
|
|
132 |
EFFECT_SOFT_DROP_SHADOW_5_WITH_OUTLINE,
|
|
|
133 |
EFFECT_SOFT_DROP_SHADOW_6_WITH_OUTLINE,
|
|
|
134 |
EFFECT_SOFT_DROP_SHADOW_7_WITH_OUTLINE,
|
|
|
135 |
EFFECT_SOFT_DROP_SHADOW_8_WITH_OUTLINE,
|
|
|
136 |
EFFECT_MEDIUM_DROP_SHADOW_1_WITH_OUTLINE,
|
|
|
137 |
EFFECT_MEDIUM_DROP_SHADOW_2_WITH_OUTLINE,
|
|
|
138 |
EFFECT_MEDIUM_DROP_SHADOW_3_WITH_OUTLINE,
|
|
|
139 |
EFFECT_MEDIUM_DROP_SHADOW_4_WITH_OUTLINE,
|
|
|
140 |
EFFECT_MEDIUM_DROP_SHADOW_5_WITH_OUTLINE,
|
|
|
141 |
EFFECT_MEDIUM_DROP_SHADOW_6_WITH_OUTLINE,
|
|
|
142 |
EFFECT_MEDIUM_DROP_SHADOW_7_WITH_OUTLINE,
|
|
|
143 |
EFFECT_MEDIUM_DROP_SHADOW_8_WITH_OUTLINE,
|
|
|
144 |
EFFECT_HARD_DROP_SHADOW_1_WITH_OUTLINE,
|
|
|
145 |
EFFECT_HARD_DROP_SHADOW_2_WITH_OUTLINE,
|
|
|
146 |
EFFECT_HARD_DROP_SHADOW_3_WITH_OUTLINE,
|
|
|
147 |
EFFECT_HARD_DROP_SHADOW_4_WITH_OUTLINE,
|
|
|
148 |
EFFECT_HARD_DROP_SHADOW_5_WITH_OUTLINE,
|
|
|
149 |
EFFECT_HARD_DROP_SHADOW_6_WITH_OUTLINE,
|
|
|
150 |
EFFECT_HARD_DROP_SHADOW_7_WITH_OUTLINE,
|
|
|
151 |
EFFECT_HARD_DROP_SHADOW_8_WITH_OUTLINE
|
|
|
152 |
}TEXT_EFFECT;
|
|
|
153 |
|
|
|
154 |
typedef enum DRAW_ORDER
|
|
|
155 |
{
|
|
|
156 |
ORD_ELEM_NONE,
|
|
|
157 |
ORD_ELEM_FILL,
|
|
|
158 |
ORD_ELEM_BITMAP,
|
|
|
159 |
ORD_ELEM_ICON,
|
|
|
160 |
ORD_ELEM_TEXT,
|
|
|
161 |
ORD_ELEM_BORDER
|
|
|
162 |
}DRAW_ORDER;
|
|
|
163 |
|
|
|
164 |
typedef enum FEEDBACK
|
|
|
165 |
{
|
|
|
166 |
FB_NONE,
|
|
|
167 |
FB_CHANNEL,
|
|
|
168 |
FB_INV_CHANNEL, // inverted channel
|
|
|
169 |
FB_ALWAYS_ON,
|
|
|
170 |
FB_MOMENTARY,
|
|
|
171 |
FB_BLINK
|
|
|
172 |
} FEEDBACK;
|
|
|
173 |
|
|
|
174 |
typedef enum PMIX
|
|
|
175 |
{
|
|
|
176 |
PMIX_MULTIPLY,
|
|
|
177 |
PMIX_XOR,
|
|
|
178 |
PMIX_SCREEN,
|
|
|
179 |
PMIX_SRC,
|
|
|
180 |
PMIX_DST,
|
|
|
181 |
PMIX_SRCOVER,
|
|
|
182 |
PMIX_SRCTOP,
|
|
|
183 |
PMIX_DSTTOP,
|
|
|
184 |
PMIX_PLUS
|
|
|
185 |
}PMIX;
|
|
|
186 |
|
|
|
187 |
typedef enum SUBVIEW_POSITION_t
|
|
|
188 |
{
|
|
|
189 |
SVP_CENTER,
|
|
|
190 |
SVP_LEFT_TOP,
|
|
|
191 |
SVP_RIGHT_BOTTOM
|
|
|
192 |
}SUBVIEW_POSITION_t;
|
|
|
193 |
|
486 |
andreas |
194 |
typedef enum BUTTON_ACTION_t
|
|
|
195 |
{
|
|
|
196 |
BT_ACTION_LAUNCH,
|
|
|
197 |
BT_ACTION_PGFLIP
|
|
|
198 |
}BUTTON_ACTION_t;
|
|
|
199 |
|
479 |
andreas |
200 |
/**
|
486 |
andreas |
201 |
* @brief TP5 button events
|
|
|
202 |
* This defines the possible event types on a button.
|
|
|
203 |
*/
|
|
|
204 |
typedef enum BUTTON_EVENT_t
|
|
|
205 |
{
|
|
|
206 |
EVENT_NONE, // No event
|
|
|
207 |
EVENT_PRESS, // Event on button press
|
|
|
208 |
EVENT_RELEASE, // Event on button release
|
|
|
209 |
EVENT_GUESTURE_ANY, // Event on any guesture
|
|
|
210 |
EVENT_GUESTURE_UP, // Event on 1 finger up guesture
|
|
|
211 |
EVENT_GUESTURE_DOWN, // Event on 1 finger down guesture
|
|
|
212 |
EVENT_GUESTURE_LEFT, // Event on 1 finger left guesture
|
|
|
213 |
EVENT_GUESTURE_RIGHT, // Event on 1 finger right guesture
|
|
|
214 |
EVENT_GUESTURE_DBLTAP, // Event on double tap
|
|
|
215 |
EVENT_GUESTURE_2FUP, // Event on 2 finger up guesture
|
|
|
216 |
EVENT_GUESTURE_2FDN, // Event on 2 finger down guesture
|
|
|
217 |
EVENT_GUESTURE_2FLT, // Event on 2 finger left guesture
|
|
|
218 |
EVENT_GUESTURE_2FRT // Event on 2 finger right guesture
|
|
|
219 |
}BUTTON_EVENT_t;
|
|
|
220 |
|
|
|
221 |
/**
|
479 |
andreas |
222 |
* Justification values:
|
|
|
223 |
* 0 = absolut
|
|
|
224 |
* 1 = top right
|
|
|
225 |
* 2 = top middle
|
|
|
226 |
* 3 = top right
|
|
|
227 |
* 4 = center left
|
|
|
228 |
* 5 = center middle (default)
|
|
|
229 |
* 6 = center right
|
|
|
230 |
* 7 = bottom left
|
|
|
231 |
* 8 = bottom middle
|
|
|
232 |
* 9 = bottom right
|
|
|
233 |
* 10 = scale to fit (ignore aspect ration)
|
|
|
234 |
* 11 = scale maintain aspect ratio
|
|
|
235 |
*/
|
|
|
236 |
typedef struct BITMAPS_t // G5 bitmap entry
|
|
|
237 |
{
|
|
|
238 |
std::string fileName; // file name of the bitmap (replaces icons)
|
|
|
239 |
ORIENTATION justification{ORI_CENTER_MIDDLE}; // Justification of bitmap
|
|
|
240 |
int offsetX{0}; // Absolut X position (only if justification is 0)
|
|
|
241 |
int offsetY{0}; // Absolut Y position (only if justification is 0)
|
486 |
andreas |
242 |
int width{0}; // Internal: The width of the image
|
|
|
243 |
int height{0}; // Internal: The height of the image
|
479 |
andreas |
244 |
}BITMAPS_t;
|
|
|
245 |
|
446 |
andreas |
246 |
typedef struct SR_T
|
|
|
247 |
{
|
|
|
248 |
int number{0};
|
|
|
249 |
std::string _do; // Order on how to show a multistate bargraph (010203...)
|
|
|
250 |
std::string bs; // Frame type (circle, ...)
|
|
|
251 |
std::string mi; // Chameleon image
|
|
|
252 |
int mi_width{0}; // Width of image
|
|
|
253 |
int mi_height{0}; // Height of image
|
|
|
254 |
std::string cb; // Border color
|
|
|
255 |
std::string cf; // Fill color
|
|
|
256 |
std::string ct; // Text Color
|
|
|
257 |
std::string ec; // Text effect color
|
|
|
258 |
std::string bm; // bitmap file name
|
479 |
andreas |
259 |
std::vector<BITMAPS_t> bitmaps; // G5 table of bitmaps
|
446 |
andreas |
260 |
std::string sd; // Sound file to play
|
|
|
261 |
int bm_width{0}; // Width of image
|
|
|
262 |
int bm_height{0}; // Height of image
|
|
|
263 |
bool dynamic{false}; // TRUE = moving image
|
|
|
264 |
int sb{0}; // Index to external graphics download
|
|
|
265 |
int ii{0}; // Icon index number
|
|
|
266 |
int ix{0}; // Icon X position
|
|
|
267 |
int iy{0}; // Icon Y position
|
|
|
268 |
int ji{5}; // Icon style / position like "jt", default 5 = center+middle
|
|
|
269 |
int jb{5}; // Image position (center, left, ...), default 5 = center+middle
|
|
|
270 |
int bx{0}; // Absolute image position x
|
|
|
271 |
int by{0}; // Absolute image position y
|
|
|
272 |
int fi{0}; // Font index
|
|
|
273 |
std::string te; // Text
|
479 |
andreas |
274 |
ORIENTATION jt{ORI_CENTER_MIDDLE}; // Text orientation
|
446 |
andreas |
275 |
int tx{0}; // Text X position
|
|
|
276 |
int ty{0}; // Text Y position
|
462 |
andreas |
277 |
std::string ff; // G5 font file name
|
|
|
278 |
int fs{0}; // G5 font size
|
446 |
andreas |
279 |
int ww{0}; // line break when 1
|
|
|
280 |
int et{0}; // Text effect (^TEF)
|
|
|
281 |
int oo{-1}; // Over all opacity
|
|
|
282 |
int md{0}; // Marquee type: 1 = scroll left, 2 = scroll right, 3 = ping pong, 4 = scroll up, 5 = scroll down
|
|
|
283 |
int mr{0}; // Marquee enabled: 1 = enabled, 0 = disabled
|
|
|
284 |
int ms{1}; // Marquee speed: Range: 1 to 10 (look for command ^MSP to see of how to set this)
|
|
|
285 |
} SR_T;
|
|
|
286 |
|
|
|
287 |
typedef struct EXTBUTTON_t
|
|
|
288 |
{
|
|
|
289 |
BUTTONTYPE type;
|
|
|
290 |
int bi{0}; // button ID
|
|
|
291 |
std::string na; // name
|
|
|
292 |
int lt{0}; // pixel from left
|
|
|
293 |
int tp{0}; // pixel from top
|
|
|
294 |
int wt{0}; // width
|
|
|
295 |
int ht{0}; // height
|
|
|
296 |
int zo{0}; // Z-Order
|
|
|
297 |
std::string hs; // bounding, ...
|
|
|
298 |
std::string bs; // Border style (circle, ...)
|
|
|
299 |
FEEDBACK fb{FB_NONE}; // Feedback type (momentary, ...)
|
|
|
300 |
int ap{1}; // Address port (default: 1)
|
|
|
301 |
int ad{0}; // Address channel
|
|
|
302 |
int lp{1}; // Level port (default: 1)
|
|
|
303 |
int lv{0}; // Level code
|
|
|
304 |
std::string dr; // Level "horizontal" or "vertical"
|
|
|
305 |
int lu{0}; // Animate time up (Bargraph)
|
|
|
306 |
int ld{0}; // Animate time down (Bargraph)
|
|
|
307 |
int rl{0}; // Range low
|
|
|
308 |
int rh{0}; // Range high
|
|
|
309 |
int rn{0}; // Bargraph: Range drag increment
|
|
|
310 |
std::string sc; // Color of slider (for bargraph)
|
|
|
311 |
std::vector<SR_T> sr;
|
|
|
312 |
}EXTBUTTON_t;
|
|
|
313 |
|
|
|
314 |
typedef struct PUSH_FUNC
|
|
|
315 |
{
|
486 |
andreas |
316 |
int item{0}; // TP5: Item number
|
480 |
andreas |
317 |
std::string pfType; // command to execute when button was pushed
|
486 |
andreas |
318 |
std::string pfAction; // TP5: Action; Used for launching external apps
|
480 |
andreas |
319 |
std::string pfName; // Name of popup
|
486 |
andreas |
320 |
BUTTON_ACTION_t action{BT_ACTION_PGFLIP}; // TP5: Button action (page flip, ...)
|
|
|
321 |
int ID{0}; // TP5: An ID for launch buttons
|
|
|
322 |
BUTTON_EVENT_t event{EVENT_NONE}; // TP5: Type of event
|
480 |
andreas |
323 |
}PUSH_FUNC_T;
|
446 |
andreas |
324 |
|
|
|
325 |
typedef enum CENTER_CODE
|
|
|
326 |
{
|
|
|
327 |
SC_ICON = 0,
|
|
|
328 |
SC_BITMAP,
|
|
|
329 |
SC_TEXT
|
|
|
330 |
}CENTER_CODE;
|
|
|
331 |
|
|
|
332 |
typedef struct POSITION_t
|
|
|
333 |
{
|
|
|
334 |
int width{0};
|
|
|
335 |
int height{0};
|
|
|
336 |
int left{1};
|
|
|
337 |
int top{1};
|
|
|
338 |
bool overflow{false};
|
|
|
339 |
bool valid{false};
|
|
|
340 |
}POSITION_t;
|
|
|
341 |
|
|
|
342 |
typedef struct POINT_t
|
|
|
343 |
{
|
|
|
344 |
int x{0};
|
|
|
345 |
int y{0};
|
|
|
346 |
}POINT_t;
|
|
|
347 |
|
|
|
348 |
typedef struct IMAGE_SIZE_t
|
|
|
349 |
{
|
|
|
350 |
int width{0};
|
|
|
351 |
int height{0};
|
|
|
352 |
}IMAGE_SIZE_t;
|
|
|
353 |
|
|
|
354 |
typedef struct THR_REFRESH_t
|
|
|
355 |
{
|
|
|
356 |
ulong handle{0};
|
|
|
357 |
ulong parent{0};
|
|
|
358 |
int bi{0};
|
|
|
359 |
TImageRefresh *mImageRefresh{nullptr};
|
|
|
360 |
THR_REFRESH_t *next{nullptr};
|
|
|
361 |
}THR_REFRESH_t;
|
|
|
362 |
|
|
|
363 |
typedef struct BITMAP_t
|
|
|
364 |
{
|
|
|
365 |
unsigned char *buffer{nullptr};
|
|
|
366 |
int left{0};
|
|
|
367 |
int top{0};
|
|
|
368 |
int width{0};
|
|
|
369 |
int height{0};
|
|
|
370 |
size_t rowBytes{0};
|
|
|
371 |
}BITMAP_t;
|
|
|
372 |
|
|
|
373 |
typedef struct BITMAP_CACHE
|
|
|
374 |
{
|
|
|
375 |
ulong handle{0};
|
|
|
376 |
ulong parent{0};
|
|
|
377 |
int left{0};
|
|
|
378 |
int top{0};
|
|
|
379 |
int width{0};
|
|
|
380 |
int height{0};
|
|
|
381 |
int bi{0};
|
|
|
382 |
bool show{false};
|
|
|
383 |
bool ready{false};
|
|
|
384 |
SkBitmap bitmap;
|
|
|
385 |
}BITMAP_CACHE;
|
|
|
386 |
|
|
|
387 |
# define LIST_IMAGE_CELL 1
|
|
|
388 |
# define LIST_TEXT_PRIMARY 2
|
|
|
389 |
# define LIST_TEXT_SECONDARY 4
|
|
|
390 |
|
|
|
391 |
typedef enum LIST_SORT
|
|
|
392 |
{
|
|
|
393 |
LIST_SORT_NONE,
|
|
|
394 |
LIST_SORT_ASC,
|
|
|
395 |
LIST_SORT_DESC,
|
|
|
396 |
LIST_SORT_OVERRIDE
|
|
|
397 |
}LIST_SORT;
|
|
|
398 |
|
|
|
399 |
class TButton : public TSystem, public Border::TIntBorder
|
|
|
400 |
{
|
|
|
401 |
public:
|
|
|
402 |
TButton();
|
|
|
403 |
~TButton();
|
|
|
404 |
|
|
|
405 |
/**
|
|
|
406 |
* The following function parses the parameters of a particular
|
|
|
407 |
* button and creates a new button. This function is called either
|
|
|
408 |
* from class TPage or TSubPage when a page or subpage is created.
|
|
|
409 |
*
|
|
|
410 |
* @param xml A pointer to the XML reader
|
|
|
411 |
* @param node A pointer to the actual node in the XML tree.
|
|
|
412 |
* @return On success the last index processed. On error
|
|
|
413 |
* TExpat::npos is returned.
|
|
|
414 |
*/
|
|
|
415 |
size_t initialize(Expat::TExpat *xml, size_t index);
|
|
|
416 |
|
|
|
417 |
/**
|
|
|
418 |
* Returns the button index. This is a unique number inside a page
|
|
|
419 |
* or subpage.
|
|
|
420 |
*
|
|
|
421 |
* @return return the button index number as defined in the
|
|
|
422 |
* configuration file.
|
|
|
423 |
*/
|
|
|
424 |
int getButtonIndex() { return bi; }
|
|
|
425 |
/**
|
|
|
426 |
* Returns the name of the button.
|
|
|
427 |
*/
|
|
|
428 |
std::string& getButtonName() { return na; }
|
|
|
429 |
/**
|
|
|
430 |
* Returns the description of the button, if there is one.
|
|
|
431 |
*/
|
|
|
432 |
std::string& getButtonDescription() { return bd; }
|
|
|
433 |
/**
|
|
|
434 |
* Returns the width of the button in pixels.
|
|
|
435 |
*/
|
|
|
436 |
int getWidth() { return wt; }
|
|
|
437 |
/**
|
|
|
438 |
* Returns the height of the button in pixels.
|
|
|
439 |
*/
|
|
|
440 |
int getHeight() { return ht; }
|
|
|
441 |
/**
|
|
|
442 |
* Returns the left position in pixels.
|
|
|
443 |
*/
|
|
|
444 |
int getLeftPosition() { return mPosLeft; }
|
|
|
445 |
/**
|
|
|
446 |
* Returns the top position of the button in pixels.
|
|
|
447 |
*/
|
|
|
448 |
int getTopPosition() { return mPosTop; }
|
|
|
449 |
/**
|
|
|
450 |
* Returns the original left position.
|
|
|
451 |
*/
|
|
|
452 |
int getLeftOriginPosition() { return lt; }
|
|
|
453 |
/**
|
|
|
454 |
* Returns the original top position.
|
|
|
455 |
*/
|
|
|
456 |
int getTopOriginPosition() { return tp; }
|
|
|
457 |
/**
|
|
|
458 |
* Returns the Z-order. This number marks the order the buttons
|
|
|
459 |
* are drawed on the screen. Inside a page or subpage the buttons
|
|
|
460 |
* are always sorted.
|
|
|
461 |
*/
|
|
|
462 |
int getZOrder() { return zo; }
|
|
|
463 |
/**
|
|
|
464 |
* Returns the type of the button.
|
|
|
465 |
*/
|
|
|
466 |
BUTTONTYPE getButtonType() { return type; }
|
|
|
467 |
/**
|
|
|
468 |
* Set font file name and optional the size
|
|
|
469 |
*
|
|
|
470 |
* @param name File name of the font
|
|
|
471 |
* @param size The size of the font in PT
|
|
|
472 |
* @param inst The instance of the button
|
|
|
473 |
*
|
|
|
474 |
* @return TRUE success
|
|
|
475 |
*/
|
|
|
476 |
bool setFontFileName(const std::string& name, int size, int inst);
|
|
|
477 |
/**
|
|
|
478 |
* Set font name.
|
|
|
479 |
*
|
|
|
480 |
* @param name The font name
|
|
|
481 |
* @param inst The instance of the button
|
|
|
482 |
*
|
|
|
483 |
* @return TRUE success
|
|
|
484 |
*/
|
|
|
485 |
bool setFontName(const std::string& name, int inst);
|
|
|
486 |
|
|
|
487 |
std::string& getName() { return na; }
|
|
|
488 |
int getRangeLow() { return rl; }
|
|
|
489 |
int getRangeHigh() { return rh; }
|
|
|
490 |
int getLevelRangeUp() { return ru; }
|
|
|
491 |
int getLevelRangeDown() { return rd; }
|
|
|
492 |
int getStateCount() { return stateCount; }
|
|
|
493 |
int getAddressPort() { return ap; }
|
|
|
494 |
int getAddressChannel() { return ad; }
|
|
|
495 |
int getChannelNumber() { return ch; }
|
|
|
496 |
int getChannelPort() { return cp; }
|
|
|
497 |
int getLevelPort() { return lp; }
|
|
|
498 |
int getLevelChannel() { return lv; }
|
|
|
499 |
bool isBargraphInverted() { return (ri != 0); }
|
|
|
500 |
bool isJoystickAuxInverted() { return (ji != 0); }
|
|
|
501 |
int getLevelValue();
|
|
|
502 |
void setLevelValue(int level);
|
|
|
503 |
int getLevelAxisX();
|
|
|
504 |
int getLevelAxisY();
|
|
|
505 |
uint32_t getButtonID() { return mButtonID; }
|
|
|
506 |
std::string getButtonIDstr(uint32_t rid=0x1fffffff);
|
|
|
507 |
std::string& getLevelFuction() { return lf; }
|
|
|
508 |
std::string getText(int inst=0);
|
|
|
509 |
std::string getTextColor(int inst=0);
|
|
|
510 |
std::string getTextEffectColor(int inst=0);
|
|
|
511 |
void setTextEffectColor(const std::string& ec, int inst=-1);
|
|
|
512 |
bool setTextEffectColorOnly(const std::string& ec, int inst=-1);
|
|
|
513 |
int getTextEffect(int inst=0);
|
|
|
514 |
void setTextEffect(int et, int inst=-1);
|
|
|
515 |
std::string getTextEffectName(int inst=0);
|
|
|
516 |
void setTextEffectName(const std::string& name, int inst=-1);
|
|
|
517 |
std::string getFillColor(int inst=0);
|
|
|
518 |
std::string getBitmapName(int inst=0);
|
|
|
519 |
bool isSingleLine() { return ( dt.compare("multiple") != 0); }
|
|
|
520 |
bool isMultiLine() { return ( dt.compare("multiple") == 0); }
|
|
|
521 |
int getTextMaxChars() { return mt; }
|
|
|
522 |
void setTextMaxChars(int m) { mt = m; }
|
|
|
523 |
bool getTextWordWrap(int inst=0);
|
|
|
524 |
bool setTextWordWrap(bool ww, int inst=-1);
|
|
|
525 |
void setMarqueeSpeed(int speed, int inst=-1);
|
|
|
526 |
int getMarqueeSpeed(int inst=0);
|
|
|
527 |
int getFontIndex(int inst=0);
|
|
|
528 |
bool setFontIndex(int fi, int inst=-1);
|
|
|
529 |
int getIconIndex(int inst=0);
|
|
|
530 |
std::string getSound(int inst=0);
|
|
|
531 |
void setSound(const std::string& sd, int inst=-1);
|
|
|
532 |
bool getDynamic(int inst=0);
|
|
|
533 |
void setDynamic(int d, int inst=-1);
|
|
|
534 |
int getNumberInstances() { return (int)sr.size(); }
|
|
|
535 |
int getActiveInstance() { return mActInstance; }
|
|
|
536 |
ulong getHandle() { return mHandle; }
|
|
|
537 |
ulong getParent() { return (mHandle & 0xffff0000); }
|
|
|
538 |
void setActiveInstance(int inst);
|
|
|
539 |
void setEnable(bool en) { mEnabled = en; }
|
|
|
540 |
bool isEnabled() { return mEnabled; }
|
|
|
541 |
void setHandle(ulong handle) { mHandle = handle; };
|
|
|
542 |
void setPalette(TPalette *pal) { mPalette = pal; }
|
|
|
543 |
void setParentWidth(int width) { mParentWidth = width; }
|
|
|
544 |
void setParentHeight(int height) { mParentHeight = height; }
|
|
|
545 |
void setParentSize(int width, int height) { mParentWidth = width; mParentHeight = height; }
|
|
|
546 |
void setFonts(TFont *ft) { mFonts = ft; }
|
|
|
547 |
void setGlobalOpacity(int oo) { if (oo >= 0 && oo <= 255) mGlobalOO = oo; }
|
|
|
548 |
void setVisible(bool v) { visible = v; hd = (v ? 0 : 1); }
|
|
|
549 |
bool isVisible() { return visible; }
|
|
|
550 |
bool isSubViewVertical() { return on == "vert"; }
|
|
|
551 |
bool haveListContent() { return _getListContent != nullptr; }
|
|
|
552 |
bool haveListRow() { return _getListRow != nullptr; }
|
|
|
553 |
int getSubViewID() { return st; }
|
|
|
554 |
bool getSubViewScrollbar() { return (ba == 1 ? true : false); }
|
|
|
555 |
int getSubViewScrollbarOffset() { return (ba > 0 ? bo : 0); }
|
|
|
556 |
bool getWrapSubViewPages() { return (ws != 0 ? true : false); }
|
|
|
557 |
bool isFocused() { return mHasFocus; }
|
|
|
558 |
int getTextCursorPosition() { return mCursorPosition; }
|
|
|
559 |
void setChanged(bool ch) { mChanged = ch; }
|
|
|
560 |
SUBVIEW_POSITION_t getSubViewAnchor();
|
|
|
561 |
std::function<std::vector<std::string>(ulong handle, int ap, int ta, int ti, int rows, int columns)> getCallbackListContent() { return _getListContent; }
|
|
|
562 |
std::function<std::string(int ti, int row)> getCallbackListRow() { return _getListRow; }
|
|
|
563 |
std::function<void (TButton *button)> getCallbackGlobalSettings() { return _getGlobalSettings; };
|
|
|
564 |
|
|
|
565 |
/**
|
|
|
566 |
* @brief setBitmap Sets a new bitmap to the button
|
|
|
567 |
* If there was already a bitmap on this button and if this bitmap
|
|
|
568 |
* is different from the one in \p file, then it is erased.
|
|
|
569 |
* The new bitmap file name is set and it will be loaded and created.
|
|
|
570 |
*
|
|
|
571 |
* @param file File name of a bitmap file.
|
|
|
572 |
* @param instance The instance where to put the new bitmap. If
|
|
|
573 |
* this is 0, the bitmap is set on all instances.
|
486 |
andreas |
574 |
* @param justify Optional; reserved for TP5: Defines the justification
|
|
|
575 |
* @param x Optional; reserved for TP5: Defines the x origin
|
|
|
576 |
* @param y Optional; reserved for TP5: Defines the y origin
|
446 |
andreas |
577 |
* @return TRUE if no errors occures, otherwise FALSE.
|
|
|
578 |
*/
|
486 |
andreas |
579 |
bool setBitmap(const std::string& file, int instance, int index, int justify=5, int x=0, int y=0);
|
446 |
andreas |
580 |
/**
|
|
|
581 |
* @brief setCameleon Sets a new cameleon bitmap to the button
|
|
|
582 |
* If there was already a cameleon bitmap on this button and if this
|
|
|
583 |
* cameleon bitmap is different from the one in \p file, then it is
|
|
|
584 |
* erased. The new cameleon bitmap file name is set and it will be
|
|
|
585 |
* loaded and created.
|
|
|
586 |
*
|
|
|
587 |
* @param file File name of a cameleon bitmap file.
|
|
|
588 |
* @param instance The instance where to put the new bitmap. If
|
|
|
589 |
* this is 0, the bitmap is set on all instances.
|
|
|
590 |
* @return TRUE if no errors occures, otherwise FALSE.
|
|
|
591 |
*/
|
|
|
592 |
bool setCameleon(const std::string& file, int instance);
|
|
|
593 |
/**
|
|
|
594 |
* @brief setOpacity Sets the opacity of this button
|
|
|
595 |
*
|
|
|
596 |
* @param op The opacity in a reange of 0 to 255.
|
|
|
597 |
* @param instance The instance where to put the new bitmap. If
|
|
|
598 |
* this is 0, the bitmap is set on all instances.
|
|
|
599 |
* @return TRUE if no errors occures, otherwise FALSE.
|
|
|
600 |
*/
|
|
|
601 |
bool setOpacity(int op, int instance);
|
|
|
602 |
int getOpacity(int inst=0);
|
|
|
603 |
int getListAp() { return ap; }
|
|
|
604 |
int getListTa() { return ta; }
|
|
|
605 |
int getListTi() { return ti; }
|
|
|
606 |
int getListNumRows() { return tr; }
|
|
|
607 |
int getListNumCols() { return tc; }
|
|
|
608 |
int getSubViewSpace() { return sa; }
|
|
|
609 |
std::string getBounding() { return hs; }
|
|
|
610 |
bool setFont(int id, int instance);
|
|
|
611 |
bool setFontOnly(int id, int instance);
|
|
|
612 |
void setTop(int top);
|
|
|
613 |
void setLeft(int left);
|
|
|
614 |
void setLeftTop(int left, int top);
|
|
|
615 |
void setRectangle(int left, int top, int right, int bottom);
|
|
|
616 |
void getRectangle(int *left, int *top, int *height, int *width);
|
|
|
617 |
void resetButton();
|
|
|
618 |
void setResourceName(const std::string& name, int instance);
|
|
|
619 |
int getBitmapJustification(int *x, int *y, int instance);
|
|
|
620 |
void setBitmapJustification(int j, int x, int y, int instance);
|
|
|
621 |
int getIconJustification(int *x, int *y, int instance);
|
|
|
622 |
void setIconJustification(int j, int x, int y, int instance);
|
|
|
623 |
int getTextJustification(int *x, int *y, int instance);
|
|
|
624 |
void setTextJustification(int j, int x, int y, int instance);
|
|
|
625 |
bool setTextJustificationOnly(int j, int x, int y, int instance);
|
|
|
626 |
bool startAnimation(int start, int end, int time);
|
|
|
627 |
/**
|
|
|
628 |
* @brief registerSystemButton registers the button as a system button.
|
|
|
629 |
*
|
|
|
630 |
* If the button is a system button, than it has special functions.
|
|
|
631 |
* The action of the button depends on the kind of system button.
|
|
|
632 |
*/
|
|
|
633 |
void registerSystemButton();
|
|
|
634 |
bool isSystemButton();
|
|
|
635 |
void addPushFunction(std::string& func, std::string& page);
|
|
|
636 |
void clearPushFunctions() { pushFunc.clear(); }
|
|
|
637 |
void clearPushFunction(const std::string& action);
|
|
|
638 |
void refresh();
|
|
|
639 |
/**
|
|
|
640 |
* Sets a particular instance of the button active. This implies
|
|
|
641 |
* a redraw of the button in case the instance is different from
|
|
|
642 |
* the one already visible.
|
|
|
643 |
*
|
|
|
644 |
* @param instance
|
|
|
645 |
* The instance of the button to be activated.
|
|
|
646 |
*
|
|
|
647 |
* @return
|
|
|
648 |
* On error returns FALSE.
|
|
|
649 |
*/
|
|
|
650 |
bool setActive(int instance);
|
|
|
651 |
/**
|
|
|
652 |
* Sets an Icon on the button. This implies a redraw of the button
|
|
|
653 |
* in case the instance is different from the one already visible.
|
|
|
654 |
*
|
|
|
655 |
* @param id
|
|
|
656 |
* The id number of the icon.
|
|
|
657 |
*
|
|
|
658 |
* @param instance
|
|
|
659 |
* The instance where the icon should be drawed
|
|
|
660 |
*
|
|
|
661 |
* @return On error returns FALSE.
|
|
|
662 |
*/
|
|
|
663 |
bool setIcon(int id, int instance);
|
|
|
664 |
/**
|
|
|
665 |
* Sets an Icon on the button. This implies a redraw of the button
|
|
|
666 |
* in case the instance is different from the one already visible.
|
|
|
667 |
*
|
|
|
668 |
* @param icon
|
|
|
669 |
* The file name of the icon.
|
|
|
670 |
*
|
|
|
671 |
* @param instance
|
|
|
672 |
* The instance where the icon should be drawed
|
|
|
673 |
*
|
|
|
674 |
* @return
|
|
|
675 |
* On error returns FALSE.
|
|
|
676 |
*/
|
|
|
677 |
bool setIcon(const std::string& icon, int instance);
|
|
|
678 |
/**
|
|
|
679 |
* Removes an icon from a button. This implies a redraw of the
|
|
|
680 |
* button.
|
|
|
681 |
*
|
|
|
682 |
* @param instance
|
|
|
683 |
* The instance number involved.
|
|
|
684 |
*
|
|
|
685 |
* @return
|
|
|
686 |
* On error returns FALSE.
|
|
|
687 |
*/
|
|
|
688 |
bool revokeIcon(int instance);
|
|
|
689 |
/**
|
|
|
690 |
* Set a string to a button.
|
|
|
691 |
*
|
|
|
692 |
* @param txt
|
|
|
693 |
* The text to write on top of a button.
|
|
|
694 |
*
|
|
|
695 |
* @param instance
|
|
|
696 |
* The instance number involved.
|
|
|
697 |
*
|
|
|
698 |
* @return
|
|
|
699 |
* On error returns FALSE.
|
|
|
700 |
*/
|
|
|
701 |
bool setText(const std::string& txt, int instance);
|
|
|
702 |
/**
|
|
|
703 |
* Set a string to a button. This method does not trigger a new
|
|
|
704 |
* drawing of the element.
|
|
|
705 |
*
|
|
|
706 |
* @param txt
|
|
|
707 |
* The text to write on top of a button.
|
|
|
708 |
*
|
|
|
709 |
* @param instance
|
|
|
710 |
* The instance number involved.
|
|
|
711 |
*
|
|
|
712 |
* @return
|
|
|
713 |
* On error returns FALSE.
|
|
|
714 |
*/
|
|
|
715 |
bool setTextOnly(const std::string& txt, int instance);
|
|
|
716 |
/**
|
|
|
717 |
* @brief appendText Append non-unicode text.
|
|
|
718 |
* @param txt
|
|
|
719 |
* The text to write on top of a button.
|
|
|
720 |
* @param instance
|
|
|
721 |
* The instance number involved.
|
|
|
722 |
* @return
|
|
|
723 |
* On error returns FALSE.
|
|
|
724 |
*/
|
|
|
725 |
bool appendText(const std::string& txt, int instance);
|
|
|
726 |
/**
|
|
|
727 |
* @brief setTextCursorPosition - Set curso position
|
|
|
728 |
* If the button element is of type TEXT_INPUT, this method sets
|
|
|
729 |
* the cursor position. This position comes usually from an input
|
|
|
730 |
* line managed by the graphical surface.
|
|
|
731 |
* If the \b newPos is less then 0 the curser is set in front of the
|
|
|
732 |
* first character. If the value \b newPos is grater then the number
|
|
|
733 |
* of characters then the curser is set after the last character.
|
|
|
734 |
*
|
|
|
735 |
* @param oldPos The old position of the cursor
|
|
|
736 |
* @param newPos The new position of the cursor
|
|
|
737 |
*/
|
|
|
738 |
void setTextCursorPosition(int oldPos, int newPos);
|
|
|
739 |
/**
|
|
|
740 |
* @brief setTextFocus - Focus of input line changed
|
|
|
741 |
* If the button element is of type TEXT_INPUT, this signals the
|
|
|
742 |
* state of the focus. If \b in is TRUE then the input line got
|
|
|
743 |
* the focus. The ON state of the button is send. If there is
|
|
|
744 |
* a keyboard present the line is then related to this keyboard.
|
|
|
745 |
* If \b in is FALSE the input line lost the focus. The off state
|
|
|
746 |
* is displayed and no more characters are received from a
|
|
|
747 |
* keyboard.
|
|
|
748 |
* If this input line is a system input line, the focus is ignored.
|
|
|
749 |
* It then receives always the keystrokes from a keyboard.
|
|
|
750 |
*
|
|
|
751 |
* @param in TRUE: Input line got focus, FALSE: input line
|
|
|
752 |
* lost focus.
|
|
|
753 |
*/
|
|
|
754 |
void setTextFocus(bool in);
|
|
|
755 |
/**
|
|
|
756 |
* @brief setBorderColor Set the border color.
|
|
|
757 |
* Set the border color to the specified color. Only if the
|
|
|
758 |
* specified border color is not the same as the current color.
|
|
|
759 |
* Note: Color can be assigned by color name (without spaces),
|
|
|
760 |
* number or R,G,B value (RRGGBB or RRGGBBAA).
|
|
|
761 |
* @param color the color
|
|
|
762 |
* @param instance
|
|
|
763 |
* The instance number involved.
|
|
|
764 |
* @return
|
|
|
765 |
* On error returns FALSE.
|
|
|
766 |
*/
|
|
|
767 |
bool setBorderColor(const std::string& color, int instance);
|
|
|
768 |
/**
|
|
|
769 |
* @brief retrieves the current border color.
|
|
|
770 |
* Determines the current border color of the button and returns
|
|
|
771 |
* the color as a string.
|
|
|
772 |
* @param instance The instance number of the button.
|
|
|
773 |
* @return
|
|
|
774 |
* If everything went well it returns the color string of the button
|
|
|
775 |
* instance. On error an empty string is returned.
|
|
|
776 |
*/
|
|
|
777 |
std::string getBorderColor(int instance);
|
|
|
778 |
/**
|
|
|
779 |
* @brief setFillColor Set the fill color.
|
|
|
780 |
* Set the fill color to the specified color. Only if the
|
|
|
781 |
* specified fill color is not the same as the current color.
|
|
|
782 |
* Note: Color can be assigned by color name (without spaces),
|
|
|
783 |
* number or R,G,B value (RRGGBB or RRGGBBAA).
|
|
|
784 |
* @param color the color
|
|
|
785 |
* @param instance
|
|
|
786 |
* The instance number involved.
|
|
|
787 |
* @return
|
|
|
788 |
* On error returns FALSE.
|
|
|
789 |
*/
|
|
|
790 |
bool setFillColor(const std::string& color, int instance);
|
|
|
791 |
/**
|
|
|
792 |
* @brief setTextColor set the text color.
|
|
|
793 |
* Set the text color to the specified color. Only if the
|
|
|
794 |
* specified text color is not the same as the current color. It
|
|
|
795 |
* redraws the button if the color changed.
|
|
|
796 |
* Note: Color can be assigned by color name (without spaces),
|
|
|
797 |
* number or R,G,B value (RRGGBB or RRGGBBAA).
|
|
|
798 |
* @param color the color
|
|
|
799 |
* @param instance
|
|
|
800 |
* The instance number involved.
|
|
|
801 |
* @return
|
|
|
802 |
* On error returns FALSE.
|
|
|
803 |
*/
|
|
|
804 |
bool setTextColor(const std::string& color, int instance);
|
|
|
805 |
/**
|
|
|
806 |
* @brief setTextColorOnly set the text color only.
|
|
|
807 |
* Set the text color to the specified color. Only if the
|
|
|
808 |
* specified text color is not the same as the current color.
|
|
|
809 |
* Note: Color can be assigned by color name (without spaces),
|
|
|
810 |
* number or R,G,B value (RRGGBB or RRGGBBAA).
|
|
|
811 |
* @param color the color
|
|
|
812 |
* @param instance
|
|
|
813 |
* The instance number involved.
|
|
|
814 |
* @return
|
|
|
815 |
* On error returns FALSE.
|
|
|
816 |
*/
|
|
|
817 |
bool setTextColorOnly(const std::string& color, int instance);
|
|
|
818 |
/**
|
|
|
819 |
* @brief setDrawOrder - Set the button draw order.
|
|
|
820 |
* Determines what order each layer of the button is drawn.
|
|
|
821 |
* @param order the draw order
|
|
|
822 |
* @param instance
|
|
|
823 |
* The instance number involved.
|
|
|
824 |
* @return
|
|
|
825 |
* On error returns FALSE.
|
|
|
826 |
*/
|
|
|
827 |
bool setDrawOrder(const std::string& order, int instance);
|
|
|
828 |
/**
|
|
|
829 |
* @brief setFeedback - Set the feedback type of the button.
|
|
|
830 |
* ONLY works on General-type buttons.
|
|
|
831 |
* @param fb The feedback type
|
|
|
832 |
* @return On error returns FALSE.
|
|
|
833 |
*/
|
|
|
834 |
bool setFeedback(FEEDBACK feedback);
|
|
|
835 |
/**
|
|
|
836 |
* @brief setFeedback - Sets the feedback type.
|
|
|
837 |
* This retrieves the feedback type of a button. Only if the button
|
|
|
838 |
* is a general type one, a valid value is returned.
|
|
|
839 |
*
|
|
|
840 |
* @return The feedback type of a button.
|
|
|
841 |
*/
|
|
|
842 |
FEEDBACK getFeedback();
|
|
|
843 |
/**
|
|
|
844 |
* Set a border to a specific border style associated with a border
|
|
|
845 |
* value for those buttons with a defined address range.
|
|
|
846 |
* @param style The name of the border style
|
|
|
847 |
* @param instance -1 = style for all instances
|
|
|
848 |
* > 0 means the style is valid only for this instance.
|
|
|
849 |
*/
|
|
|
850 |
bool setBorderStyle(const std::string& style, int instance=-1);
|
|
|
851 |
/**
|
|
|
852 |
* Set a border to a specific border style associated with a border
|
|
|
853 |
* value for those buttons with a defined address range.
|
|
|
854 |
* @param style The index number of the border style
|
|
|
855 |
* @param instance -1 = style for all instances
|
|
|
856 |
* > 0 means the style is valid only for this instance.
|
|
|
857 |
*/
|
|
|
858 |
bool setBorderStyle(int style, int instance=-1);
|
|
|
859 |
/**
|
|
|
860 |
* Retrieves the border style, if any, of the instance \p instance
|
|
|
861 |
* and returns it.
|
|
|
862 |
* @param instance The instance from where the border style is
|
|
|
863 |
* wanted. This value must be between 1 and the
|
|
|
864 |
* number of available instances.
|
|
|
865 |
* @return The border style if there is any or an empty string.
|
|
|
866 |
*/
|
|
|
867 |
std::string getBorderStyle(int instance=-1);
|
|
|
868 |
/**
|
|
|
869 |
* Set the bargraph upper limit. Range = 1 to 65535.
|
|
|
870 |
* @param limit the new limit
|
|
|
871 |
* @return TRUE on success.
|
|
|
872 |
*/
|
|
|
873 |
bool setBargraphUpperLimit(int limit);
|
|
|
874 |
/**
|
|
|
875 |
* Set the bargraph lower limit. Range = 1 to 65535.
|
|
|
876 |
* @param limit the new limit
|
|
|
877 |
* @return TRUE on success.
|
|
|
878 |
*/
|
|
|
879 |
bool setBargraphLowerLimit(int limit);
|
|
|
880 |
/**
|
|
|
881 |
* Change the bargraph slider color or joystick cursor color.
|
|
|
882 |
* A user can also assign the color by Name and R,G,B value
|
|
|
883 |
* (RRGGBB or RRGGBBAA).
|
|
|
884 |
* @param color The color value.
|
|
|
885 |
* @return TRUE on success.
|
|
|
886 |
*/
|
|
|
887 |
bool setBargraphSliderColor(const std::string& color);
|
|
|
888 |
/**
|
|
|
889 |
* Set the name of the bargraph slider name or the joystick cursor
|
|
|
890 |
* name.
|
|
|
891 |
* @param name The name of the slider/cursor.
|
|
|
892 |
* @return TRUE on success.
|
|
|
893 |
*/
|
|
|
894 |
bool setBargraphSliderName(const std::string& name);
|
|
|
895 |
/**
|
|
|
896 |
* Sets the input mask for the text area. This method has no
|
|
|
897 |
* effect on any non input button.
|
|
|
898 |
* @param mask The mask.
|
|
|
899 |
* @return If all mask letters are valid it returns TRUE.
|
|
|
900 |
*/
|
|
|
901 |
bool setInputMask(const std::string& mask);
|
|
|
902 |
/**
|
|
|
903 |
* Returns the input mask of the button.
|
|
|
904 |
* @rturn The input mask of the text area, if there is any. If
|
|
|
905 |
* there is no input mask present, an empty string is returned.
|
|
|
906 |
*/
|
|
|
907 |
std::string& getInputMask() { return im; }
|
|
|
908 |
/**
|
|
|
909 |
* Read the images, if any, from files and create an image. If there
|
|
|
910 |
* are no files, draw the image as defined.
|
|
|
911 |
*
|
|
|
912 |
* @param force
|
|
|
913 |
* This parameter forces the function to reload the image. This is
|
|
|
914 |
* necessary if the image of the button was changed by a command.
|
|
|
915 |
* This parameter is optional. Defaults to FALSE.
|
|
|
916 |
*
|
|
|
917 |
* @return
|
|
|
918 |
* On error returns FALSE.
|
|
|
919 |
*/
|
|
|
920 |
bool createButtons(bool force = false);
|
|
|
921 |
/**
|
|
|
922 |
* Register a callback function to display a ready image. This
|
|
|
923 |
* function is used for nearly every kind of button or bargraph.
|
|
|
924 |
* It is up to the surface to bring the buttons to screen.
|
|
|
925 |
*/
|
|
|
926 |
void registerCallback(std::function<void (ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> displayButton)
|
|
|
927 |
{
|
|
|
928 |
_displayButton = displayButton;
|
|
|
929 |
}
|
|
|
930 |
/**
|
|
|
931 |
* Register a callback function to display a video on a special
|
|
|
932 |
* button. It is up to the surface to display a video. So the
|
|
|
933 |
* callback passes only the size, position and the url together
|
|
|
934 |
* with a user name and password, if there is one.
|
|
|
935 |
*/
|
|
|
936 |
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; };
|
|
|
937 |
/**
|
|
|
938 |
* Registers a callback function to get the content of a list.
|
|
|
939 |
* This function is called to get from the parent the content of
|
|
|
940 |
* a list.
|
|
|
941 |
*/
|
|
|
942 |
void regCallListContent(std::function<std::vector<std::string>(ulong handle, int ap, int ta, int ti, int rows, int columns)> getListCtnt) { _getListContent = getListCtnt; }
|
|
|
943 |
/**
|
|
|
944 |
* Registers a callback function to get the global settings of the
|
|
|
945 |
* global page/subpage.
|
|
|
946 |
*/
|
|
|
947 |
void regCallGlobalSettings(std::function<void (TButton *button)> getGlobalSettings) { _getGlobalSettings = getGlobalSettings; };
|
|
|
948 |
/**
|
|
|
949 |
* Registers a callback function to get the content of a particular
|
|
|
950 |
* row of the list. This function is called for each row detected
|
|
|
951 |
* in a list. If a row contains more than one column then the
|
|
|
952 |
* columns are separated by a "|" symbol.
|
|
|
953 |
*/
|
|
|
954 |
void regCallListRow(std::function<std::string(int ti, int row)> getListRow) { _getListRow = getListRow; }
|
|
|
955 |
/**
|
|
|
956 |
* @brief Registers a callback which will be called on every button
|
|
|
957 |
* press.
|
|
|
958 |
* This is used for system buttons to catch the keyboard keys.
|
|
|
959 |
*
|
|
|
960 |
* @param buttonPress The function pointer.
|
|
|
961 |
*/
|
|
|
962 |
void regCallButtonPress(std::function<void(int channel, uint handle, bool pressed)> buttonPress) { _buttonPress = buttonPress; }
|
|
|
963 |
/**
|
|
|
964 |
* Make a pixel array and call the callback function to display the
|
|
|
965 |
* image. If there is no callback function registered, nothing
|
|
|
966 |
* happens.
|
|
|
967 |
* This method draws a general button. It is used for most
|
|
|
968 |
* specialized buttons too.
|
|
|
969 |
*
|
|
|
970 |
* @param instance
|
|
|
971 |
* Optional. The instance of the button to draw. If the base
|
|
|
972 |
* instance should be drawn, the parameter can be omitted.
|
|
|
973 |
*
|
|
|
974 |
* @param show
|
|
|
975 |
* Optional. By defualt TRUE. If set to FALSE, the button image is
|
|
|
976 |
* not send to GUI. The image is available in the variable
|
|
|
977 |
* "mLastImage" immediately after ending the method.
|
|
|
978 |
*
|
|
|
979 |
* @param subview
|
|
|
980 |
* Optional. If this is set to true, an internal marker is set to
|
|
|
981 |
* mark the button as part of a subview. If it is pressed, it calls
|
|
|
982 |
* another function to show the changed state.
|
|
|
983 |
*
|
|
|
984 |
* @return
|
|
|
985 |
* On error returns FALSE.
|
|
|
986 |
*/
|
|
|
987 |
bool drawButton(int instance=0, bool show=true, bool subview=false);
|
|
|
988 |
/**
|
|
|
989 |
* Creates a pixel array and holds it for access through a callback
|
|
|
990 |
* function which receives this class as a whole. The callback
|
|
|
991 |
* function displays a keyboard and handles input to this text area.
|
|
|
992 |
* The created image can be obtained by calling the function
|
|
|
993 |
* getLastImage().
|
|
|
994 |
*
|
|
|
995 |
* @param instance
|
|
|
996 |
* Optional. The instance of the button to draw. If the base
|
|
|
997 |
* instance should be drawn, the parameter can be omitted.
|
|
|
998 |
*
|
|
|
999 |
* @param show
|
|
|
1000 |
* Optional. By defualt TRUE. If set to FALSE, the button image is
|
|
|
1001 |
* not send to GUI. The image is available in the variable
|
|
|
1002 |
* "mLastImage" immediately after ending the method.
|
|
|
1003 |
*
|
|
|
1004 |
* @return
|
|
|
1005 |
* On error returns FALSE.
|
|
|
1006 |
*/
|
|
|
1007 |
bool drawTextArea(int instance=0);
|
|
|
1008 |
/**
|
|
|
1009 |
* Method to draw a multistate animated button. It creates a thread
|
|
|
1010 |
* with a timer and starts an animation by drawing every instance in
|
|
|
1011 |
* the defined order.
|
|
|
1012 |
*
|
|
|
1013 |
* @return
|
|
|
1014 |
* On error returns FALSE.
|
|
|
1015 |
*/
|
|
|
1016 |
bool drawButtonMultistateAni();
|
|
|
1017 |
/**
|
|
|
1018 |
* Draws a normal bargraph with an ON and OFF state. Takes care
|
|
|
1019 |
* about cameleon images. If registered, it calls a callback
|
|
|
1020 |
* function to the GUI to display the ready image.
|
|
|
1021 |
*
|
|
|
1022 |
* @param instance
|
|
|
1023 |
* The instance of the bargraph to draw. This value must be in the
|
|
|
1024 |
* range of 0 to "stateCount".
|
|
|
1025 |
*
|
|
|
1026 |
* @param level
|
|
|
1027 |
* This is the level to show on the bargraph. It must be a value
|
|
|
1028 |
* the range of "rl" (range low) and "rh" (range high). A lower
|
|
|
1029 |
* value than "rl" is interpreted as "rl" and a value higher than
|
|
|
1030 |
* "rh" is interpreted as "rh".
|
|
|
1031 |
*
|
|
|
1032 |
* @param show
|
|
|
1033 |
* Optional. By default TRUE. If set to FALSE, the bargraph image is
|
|
|
1034 |
* not send to GUI. The image is available in the variable
|
|
|
1035 |
* "mLastImage" immediately after ending the method.
|
|
|
1036 |
*
|
|
|
1037 |
* @return
|
|
|
1038 |
* On error returns FALSE.
|
|
|
1039 |
*/
|
|
|
1040 |
bool drawBargraph(int instance, int level, bool show=true);
|
|
|
1041 |
/**
|
|
|
1042 |
* @brief drawMultistateBargraph draws a bargraph comparable to a button.
|
|
|
1043 |
* This method draws a multistate bargraph. This is like many
|
|
|
1044 |
* buttons in one. But they behave like a bargraph. This means, that
|
|
|
1045 |
* it depends on the level how many buttons are ON and which are OFF.
|
|
|
1046 |
*
|
|
|
1047 |
* @param level The level. This defines how many buttons are at ON state.
|
|
|
1048 |
* @param show If this is false, the button is invisible.
|
|
|
1049 |
* @return If everything went well, TRUE is returned. If an error
|
|
|
1050 |
* occurred it returns FALSE.
|
|
|
1051 |
*/
|
|
|
1052 |
bool drawMultistateBargraph(int level, bool show=true);
|
|
|
1053 |
/**
|
|
|
1054 |
* @brief Invert bargraph/joystick
|
|
|
1055 |
* This method sets or unsets inverting bargraphs or the axis of a
|
|
|
1056 |
* joystick.
|
|
|
1057 |
*
|
|
|
1058 |
* @param invert A value between 0 and 3. If it is a bargraph
|
|
|
1059 |
* any value > 0 means to invert the axis. For
|
|
|
1060 |
* joysticks the values mean:
|
|
|
1061 |
* 0 = no invert
|
|
|
1062 |
* 1 = invert horizontal axis
|
|
|
1063 |
* 2 = invert vertical axis
|
|
|
1064 |
* 3 = invert both axis
|
|
|
1065 |
*/
|
|
|
1066 |
void setBargraphInvert(int invert);
|
|
|
1067 |
/**
|
|
|
1068 |
* @brief Change ramp down time
|
|
|
1069 |
*
|
|
|
1070 |
* @param t Time in 1/10 seconds
|
|
|
1071 |
*/
|
|
|
1072 |
void setBargraphRampDownTime(int t);
|
|
|
1073 |
/**
|
|
|
1074 |
* @brief Change ramp up time
|
|
|
1075 |
*
|
|
|
1076 |
* @param t Time in 1/10 seconds
|
|
|
1077 |
*/
|
|
|
1078 |
void setBargraphRampUpTime(int t);
|
|
|
1079 |
/**
|
|
|
1080 |
* @brief Set the increment step factor
|
|
|
1081 |
*
|
|
|
1082 |
* @param inc Step increment.
|
|
|
1083 |
*/
|
|
|
1084 |
void setBargraphDragIncrement(int inc);
|
|
|
1085 |
/**
|
|
|
1086 |
* @brief Draws a joystick field.
|
|
|
1087 |
* The method draws a rectangular field acting as a joystick. This
|
|
|
1088 |
* means, that every touch of move is translated into coordinates
|
|
|
1089 |
* who are send to the NetLinx.
|
|
|
1090 |
* This works the same prinzyp as the bargraphs do, but with 2
|
|
|
1091 |
* dimensions.
|
|
|
1092 |
*
|
|
|
1093 |
* @param x The x coordinate to set the curser. If this is
|
|
|
1094 |
* -1 the default position is used.
|
|
|
1095 |
* @param y The y coordinate to set the cursor. If this is
|
|
|
1096 |
* -1 the default position is used.
|
|
|
1097 |
* @return If everything went well, TRUE is returned.
|
|
|
1098 |
*/
|
|
|
1099 |
bool drawJoystick(int x, int y);
|
|
|
1100 |
/**
|
|
|
1101 |
* Draws the curser of the joystick, if there is one. The method
|
|
|
1102 |
* calculates the pixel position of the cursor out of the level
|
|
|
1103 |
* values.
|
|
|
1104 |
*
|
|
|
1105 |
* @param bm The bitmap where to draw the curser.
|
|
|
1106 |
* @param x The x coordinate to set the curser (X level).
|
|
|
1107 |
* @param y The y coordinate to set the cursor (Y level).
|
|
|
1108 |
* @return If everything went well, TRUE is returned.
|
|
|
1109 |
*/
|
|
|
1110 |
bool drawJoystickCursor(SkBitmap *bm, int x, int y);
|
|
|
1111 |
/**
|
|
|
1112 |
* Draws the background and the frame, if any, of the box. It takes
|
|
|
1113 |
* the number of rows in account.
|
|
|
1114 |
*
|
|
|
1115 |
* @param show Optional: If set to false the button will not be
|
|
|
1116 |
* shown.
|
|
|
1117 |
* @return If everything went well, TRUE is returned. If an error
|
|
|
1118 |
* occurred it returns FALSE.
|
|
|
1119 |
*/
|
|
|
1120 |
bool drawList(bool show=true);
|
|
|
1121 |
/**
|
|
|
1122 |
* Show the button with it's current state.
|
|
|
1123 |
*/
|
|
|
1124 |
void show();
|
|
|
1125 |
/**
|
|
|
1126 |
* Hide the button. In case of an animated button, the animation is
|
|
|
1127 |
* stopped.
|
|
|
1128 |
*
|
|
|
1129 |
* @param total
|
|
|
1130 |
* Optional. When set to TRUE, a transparent button is displayed.
|
|
|
1131 |
*/
|
|
|
1132 |
void hide(bool total=false);
|
|
|
1133 |
/**
|
|
|
1134 |
* This method sends the image together with all data to the GUI,
|
|
|
1135 |
* where it will be shown. The variable mLastImage must not be
|
|
|
1136 |
* empty for the method to succeed.
|
|
|
1137 |
*/
|
|
|
1138 |
void showLastButton();
|
|
|
1139 |
/**
|
|
|
1140 |
* Handle a mouse click.
|
|
|
1141 |
*
|
|
|
1142 |
* @param x
|
|
|
1143 |
* The x coordinate of the mouse press
|
|
|
1144 |
*
|
|
|
1145 |
* @param y
|
|
|
1146 |
* The y coordinate of the mouse press
|
|
|
1147 |
*
|
|
|
1148 |
* @param pressed
|
|
|
1149 |
* TRUE = Button was pressed, FALSE = Button was released.
|
|
|
1150 |
*
|
|
|
1151 |
* @return
|
|
|
1152 |
* TRUE = Button was clickable and processed. FALSE = Button was not
|
|
|
1153 |
* clickable.
|
|
|
1154 |
*/
|
|
|
1155 |
bool doClick(int x, int y, bool pressed);
|
|
|
1156 |
/**
|
|
|
1157 |
* Creates a button but uses the informations in the structure
|
|
|
1158 |
* instead of reading it from a file.
|
|
|
1159 |
*
|
|
|
1160 |
* @param bt A structure containing all information to create a button.
|
|
|
1161 |
* @return On success returns TRUE, else FALSE.
|
|
|
1162 |
*/
|
|
|
1163 |
bool createSoftButton(const EXTBUTTON_t& bt);
|
|
|
1164 |
/**
|
|
|
1165 |
* Returns the image in mLastImage as a pixel array with the defined
|
|
|
1166 |
* dimensions.
|
|
|
1167 |
*
|
|
|
1168 |
* @return A typedef IMAGE_t containing the ingredentials of the
|
|
|
1169 |
* image. It contains a pointer with allocated memory holding the
|
|
|
1170 |
* image. This buffer must NOT be freed!
|
|
|
1171 |
*/
|
|
|
1172 |
BITMAP_t getLastImage();
|
|
|
1173 |
/**
|
|
|
1174 |
* Returns the image in mLastImage as a TBitmap with the defined
|
|
|
1175 |
* dimensions.
|
|
|
1176 |
*
|
|
|
1177 |
* @return TBitmap class
|
|
|
1178 |
*/
|
|
|
1179 |
TBitmap getLastBitmap();
|
|
|
1180 |
/**
|
|
|
1181 |
* Returns the fint the button uses.
|
|
|
1182 |
* @return A structure containing the informations for the font
|
|
|
1183 |
* to load.
|
|
|
1184 |
*/
|
|
|
1185 |
FONT_T getFont();
|
|
|
1186 |
/**
|
|
|
1187 |
* Returns the style of the font.
|
|
|
1188 |
* @return The font style.
|
|
|
1189 |
*/
|
|
|
1190 |
FONT_STYLE getFontStyle();
|
|
|
1191 |
/**
|
|
|
1192 |
* Tests the button if it is clickable.
|
|
|
1193 |
* @return TRUE if it is clickable, FALSE otherwise.
|
|
|
1194 |
*/
|
|
|
1195 |
bool isClickable(int x = -1, int y = -1);
|
|
|
1196 |
/**
|
|
|
1197 |
* Returns the password character.
|
|
|
1198 |
*
|
|
|
1199 |
* @return An integer representing the password character. If there
|
|
|
1200 |
* is no password character 0 is returned.
|
|
|
1201 |
*/
|
|
|
1202 |
uint getPasswordChar() { return (pc.empty() ? 0 : pc[0]); }
|
|
|
1203 |
/**
|
|
|
1204 |
* Set the level of a bargraph or a multistate bargraph.
|
|
|
1205 |
* The method checks the level whether it is inside the defined
|
|
|
1206 |
* range or not.
|
|
|
1207 |
*
|
|
|
1208 |
* @param level The new level value
|
|
|
1209 |
*/
|
|
|
1210 |
void setBargraphLevel(int level);
|
|
|
1211 |
/**
|
|
|
1212 |
* @brief Move the level to the mouse position
|
|
|
1213 |
* The method moves the level to the mouse position while the left
|
|
|
1214 |
* button is pressed. The exact behavior depends on the settings for
|
|
|
1215 |
* the bargraph.
|
|
|
1216 |
*
|
|
|
1217 |
* @param x The x coordinate of the mouse
|
|
|
1218 |
* @param y The y coordinate of the mouse
|
|
|
1219 |
*/
|
|
|
1220 |
void moveBargraphLevel(int x, int y);
|
|
|
1221 |
/**
|
|
|
1222 |
* @brief Send the levels of a joystick
|
|
|
1223 |
* The method sends the level of the x and y axes of a joystick to
|
|
|
1224 |
* the NetLinx.
|
|
|
1225 |
*/
|
|
|
1226 |
void sendJoystickLevels();
|
|
|
1227 |
/**
|
|
|
1228 |
* @brief Send the level of the bargraph
|
|
|
1229 |
* The method sends the level of the bargraph to the NetLinx.
|
|
|
1230 |
*/
|
|
|
1231 |
void sendBargraphLevel();
|
|
|
1232 |
/**
|
|
|
1233 |
* @brief invalidate - Mark a button internal as hidden.
|
|
|
1234 |
* This method does not call any surface methods and marks the
|
|
|
1235 |
* the button only internal hidden. The graphic remains.
|
|
|
1236 |
*
|
|
|
1237 |
* @return TRUE on success.
|
|
|
1238 |
*/
|
|
|
1239 |
bool invalidate();
|
|
|
1240 |
/**
|
|
|
1241 |
* Returns the draw order of the elements of a button.
|
|
|
1242 |
*
|
|
|
1243 |
* @param instance The button instance. This value must be >= 0.
|
|
|
1244 |
* @return The draw order as a string with a length of 10.
|
|
|
1245 |
*/
|
|
|
1246 |
std::string& getDrawOrder(int instance);
|
|
|
1247 |
/**
|
|
|
1248 |
* Returns the rows of the list in case this button is a list.
|
|
|
1249 |
* Otherwise an empty list is returned.
|
|
|
1250 |
*
|
|
|
1251 |
* @return A vector list containing the rows of the list.
|
|
|
1252 |
*/
|
|
|
1253 |
std::vector<std::string>& getListContent() { return mListContent; }
|
|
|
1254 |
/**
|
|
|
1255 |
* @brief Listview Data Source
|
|
|
1256 |
* This command sets the data source to drive the Listview entries.
|
|
|
1257 |
* Note that this command only configures the data source it does
|
|
|
1258 |
* not actually cause the data to be fetched. The ^LVR refresh
|
|
|
1259 |
* command must be issued to load the data.
|
|
|
1260 |
*
|
|
|
1261 |
* @param source A string containing the source for list data.
|
|
|
1262 |
* This can be either a URL or the name of a dynamic resource data.
|
|
|
1263 |
* @param configs One or more configurations defining the layout
|
|
|
1264 |
* of the source.
|
|
|
1265 |
*
|
|
|
1266 |
* @return If the source is valid it returns TRUE.
|
|
|
1267 |
*/
|
|
|
1268 |
bool setListSource(const std::string &source, const std::vector<std::string>& configs);
|
|
|
1269 |
/**
|
|
|
1270 |
* Returns the set source for list data.
|
|
|
1271 |
*
|
|
|
1272 |
* @return A string containg the source or and empty string if no
|
|
|
1273 |
* valid source was set.
|
|
|
1274 |
*/
|
|
|
1275 |
std::string& getListSource() { return listSource; }
|
|
|
1276 |
/**
|
|
|
1277 |
* Sets a filter for the data of a listView.
|
|
|
1278 |
*
|
|
|
1279 |
* @param filter A string used as a filter for the data.
|
|
|
1280 |
*
|
|
|
1281 |
* @return Returns true if the string was evaluated ok.
|
|
|
1282 |
*/
|
|
|
1283 |
bool setListSourceFilter(const std::string& filter);
|
|
|
1284 |
/**
|
|
|
1285 |
* Returns the filter string for a listView data source.
|
|
|
1286 |
*
|
|
|
1287 |
* @return The filter string.
|
|
|
1288 |
*/
|
|
|
1289 |
std::string& getListSourceFilter() { return listFilter; }
|
|
|
1290 |
/**
|
|
|
1291 |
* Sets the listView event number. A value of 0 turns off event
|
|
|
1292 |
* reporting. Any other number activates the events. Currently are
|
|
|
1293 |
* only refresh events are reported.
|
|
|
1294 |
*
|
|
|
1295 |
* @param num The event number.
|
|
|
1296 |
*/
|
|
|
1297 |
void setListViewEventNumber(int num) { listEvNum = num; }
|
|
|
1298 |
/**
|
|
|
1299 |
* Returns the event number of the listView. By default this number
|
|
|
1300 |
* is 1401. But with the command ^LVE this number can be changed.
|
|
|
1301 |
*
|
|
|
1302 |
* @return The event number of the listView.
|
|
|
1303 |
*/
|
|
|
1304 |
int getListViewEventNumber() { return listEvNum; };
|
|
|
1305 |
void setListViewColumns(int cols);
|
|
|
1306 |
int getListViewColumns() { return tc; }
|
|
|
1307 |
void setListViewLayout(int layout);
|
|
|
1308 |
int getListViewLayout() { return listLayout; }
|
|
|
1309 |
void setListViewComponent(int comp);
|
|
|
1310 |
int getListViewComponent() { return listComponent; }
|
|
|
1311 |
void setListViewCellheight(int height, bool percent=false);
|
|
|
1312 |
int getListViewCellheight() { return tj; }
|
|
|
1313 |
void setListViewP1(int p1);
|
|
|
1314 |
int getListViewP1() { return listViewP1; }
|
|
|
1315 |
void setListViewP2(int p2);
|
|
|
1316 |
int getListViewP2() { return listViewP2; }
|
|
|
1317 |
void setListViewColumnFilter(bool filter) { listViewColFiler = filter; }
|
|
|
1318 |
bool getListViewColumnFilter() { return listViewColFiler; }
|
|
|
1319 |
void setListViewFilterHeight(int height, bool percent=false);
|
|
|
1320 |
int getListViewFilterHeight() { return listViewColFilterHeight; }
|
|
|
1321 |
void setListViewAlphaScroll(bool alpha) { listAlphaScroll = alpha; }
|
|
|
1322 |
bool getListViewAlphaScroll() { return listAlphaScroll; }
|
|
|
1323 |
void setListViewFieldMap(const std::map<std::string,std::string>& map) { listFieldMap = map; }
|
|
|
1324 |
std::map<std::string,std::string>& getListViewFieldMap() { return listFieldMap; }
|
|
|
1325 |
void listViewNavigate(const std::string& command, bool select=false);
|
|
|
1326 |
void listViewRefresh(int interval, bool force=false);
|
|
|
1327 |
void listViewSortData(const std::vector<std::string>& columns, LIST_SORT order, const std::string& override);
|
|
|
1328 |
int getBorderSize(const std::string& name);
|
|
|
1329 |
void setPassword(const std::string& pw) { mPassword = pw; }
|
|
|
1330 |
void setUserName(const std::string& user);
|
|
|
1331 |
|
|
|
1332 |
protected:
|
|
|
1333 |
BUTTONTYPE getButtonType(const std::string& bt);
|
|
|
1334 |
FEEDBACK getButtonFeedback(const std::string& fb);
|
|
|
1335 |
SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
|
|
|
1336 |
SkBitmap combineImages(SkBitmap& base, SkBitmap& alpha, SkColor col);
|
|
|
1337 |
|
|
|
1338 |
void funcTimer(const amx::ANET_BLINK& blink);
|
|
|
1339 |
void funcNetwork(int state);
|
|
|
1340 |
void funcResource(const RESOURCE_T *resource, const std::string& url, BITMAP_CACHE bc, int instance);
|
|
|
1341 |
#ifdef __ANDROID__
|
|
|
1342 |
void funcBattery(int level, bool charging, int chargeType);
|
|
|
1343 |
#endif
|
|
|
1344 |
#if TARGET_OS_SIMULATOR || TARGET_OS_IOS
|
|
|
1345 |
void funcBattery(int level, int state);
|
|
|
1346 |
#endif
|
|
|
1347 |
void funcNetworkState(int level);
|
|
|
1348 |
|
|
|
1349 |
private:
|
|
|
1350 |
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};
|
|
|
1351 |
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};
|
|
|
1352 |
std::function<std::vector<std::string>(ulong handle, int ap, int ta, int ti, int rows, int columns)> _getListContent{nullptr};
|
|
|
1353 |
std::function<std::string(int ti, int row)> _getListRow{nullptr};
|
|
|
1354 |
std::function<void (TButton *button)> _getGlobalSettings{nullptr};
|
|
|
1355 |
std::function<void (int channel, uint handle, bool pressed)> _buttonPress{nullptr};
|
|
|
1356 |
|
|
|
1357 |
// Mutexes used in class
|
|
|
1358 |
std::mutex mutex_button;
|
|
|
1359 |
std::mutex mutex_click;
|
|
|
1360 |
std::mutex mutex_text;
|
|
|
1361 |
std::mutex mutex_bargraph;
|
|
|
1362 |
std::mutex mutex_sysdraw;
|
|
|
1363 |
std::mutex mutex_bmCache;
|
|
|
1364 |
|
|
|
1365 |
std::string buttonTypeToString();
|
|
|
1366 |
std::string buttonTypeToString(BUTTONTYPE t);
|
|
|
1367 |
POSITION_t calcImagePosition(int width, int height, CENTER_CODE cc, int number, int line = 0);
|
|
|
1368 |
IMAGE_SIZE_t calcImageSize(int imWidth, int imHeight, int instance, bool aspect=false);
|
|
|
1369 |
void calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY);
|
|
|
1370 |
SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
|
|
|
1371 |
TEXT_EFFECT textEffect(const std::string& effect);
|
|
|
1372 |
int numberLines(const std::string& str);
|
|
|
1373 |
SkRect calcRect(int width, int height, int pen);
|
|
|
1374 |
void runAnimation(); // Method started as thread for button animation
|
|
|
1375 |
void runAnimationRange(int start, int end, ulong step); // Method started as thread for a limited time
|
|
|
1376 |
bool drawAlongOrder(SkBitmap *imgButton, int instance);
|
|
|
1377 |
|
|
|
1378 |
void getDrawOrder(const std::string& sdo, DRAW_ORDER *order);
|
|
|
1379 |
bool buttonFill(SkBitmap *bm, int instance);
|
|
|
1380 |
bool buttonBitmap(SkBitmap *bm, int instance);
|
486 |
andreas |
1381 |
bool buttonBitmap5(SkBitmap *bm, int instance, bool ignFirst=false);
|
446 |
andreas |
1382 |
bool buttonDynamic(SkBitmap *bm, int instance, bool show, bool *state=nullptr);
|
|
|
1383 |
bool buttonIcon(SkBitmap *bm, int instance);
|
|
|
1384 |
bool buttonText(SkBitmap *bm, int instance);
|
|
|
1385 |
bool buttonBorder(SkBitmap *bm, int instance, TSystemDraw::LINE_TYPE_t lnType=TSystemDraw::LT_OFF);
|
|
|
1386 |
bool isPixelTransparent(int x, int y);
|
|
|
1387 |
bool barLevel(SkBitmap *bm, int instance, int level);
|
|
|
1388 |
bool makeElement(int instance=-1);
|
|
|
1389 |
bool loadImage(SkBitmap *bm, SkBitmap& image, int instance);
|
|
|
1390 |
void _TimerCallback(ulong counter);
|
|
|
1391 |
void _imageRefresh(const std::string& url);
|
|
|
1392 |
static THR_REFRESH_t *_addResource(TImageRefresh *refr, ulong handle, ulong parent, int bi);
|
|
|
1393 |
static THR_REFRESH_t *_findResource(ulong handle, ulong parent, int bi);
|
|
|
1394 |
int calcLineHeight(const std::string& text, SkFont& font);
|
|
|
1395 |
bool textEffect(SkCanvas *canvas, sk_sp<SkTextBlob>& blob, SkScalar startX, SkScalar startY, int instance);
|
479 |
andreas |
1396 |
std::string getFormatString(ORIENTATION to);
|
446 |
andreas |
1397 |
bool checkForSound();
|
|
|
1398 |
bool scaleImage(SkBitmap *bm, double scaleWidth, double scaleHeight);
|
|
|
1399 |
bool stretchImageWidth(SkBitmap *bm, int width);
|
|
|
1400 |
bool stretchImageHeight(SkBitmap *bm, int height);
|
|
|
1401 |
bool stretchImageWH(SkBitmap *bm, int width, int height);
|
|
|
1402 |
SkBitmap colorImage(SkBitmap& base, SkBitmap& alpha, SkColor col, SkColor bg=0, bool useBG=false);
|
|
|
1403 |
bool retrieveImage(const std::string& path, SkBitmap *image);
|
|
|
1404 |
bool getBorderFragment(const std::string& path, const std::string& pathAlpha, SkBitmap *image, SkColor color);
|
|
|
1405 |
SkBitmap drawSliderButton(const std::string& slider, SkColor col);
|
|
|
1406 |
SkBitmap drawCursorButton(const std::string& cursor, SkColor col);
|
|
|
1407 |
POINT_t getImagePosition(int width, int height);
|
|
|
1408 |
|
|
|
1409 |
void addToBitmapCache(BITMAP_CACHE& bc);
|
|
|
1410 |
BITMAP_CACHE& getBCentryByHandle(ulong handle, ulong parent);
|
|
|
1411 |
BITMAP_CACHE& getBCentryByBI(int bIdx);
|
|
|
1412 |
void removeBCentry(std::vector<BITMAP_CACHE>::iterator *elem);
|
|
|
1413 |
void setReady(ulong handle);
|
|
|
1414 |
void setInvalid(ulong handle);
|
|
|
1415 |
void setBCBitmap(ulong handle, SkBitmap& bm);
|
|
|
1416 |
void showBitmapCache();
|
|
|
1417 |
uint32_t pixelMix(uint32_t s, uint32_t d, uint32_t a, PMIX mix);
|
|
|
1418 |
bool isPassThrough();
|
|
|
1419 |
SkColor& flipColorLevelsRB(SkColor& color);
|
|
|
1420 |
void runBargraphMove(int distance, bool moveUp=false);
|
|
|
1421 |
void threadBargraphMove(int distance, bool moveUp);
|
|
|
1422 |
TButtonStates *getButtonState();
|
486 |
andreas |
1423 |
bool isButtonEvent(const std::string& token, const std::vector<std::string>& events); // TP5: Tests for a button event
|
|
|
1424 |
BUTTON_EVENT_t getButtonEvent(const std::string& token); // TP5: Returns the button event
|
446 |
andreas |
1425 |
|
|
|
1426 |
BUTTONTYPE type;
|
|
|
1427 |
int bi{0}; // button ID
|
|
|
1428 |
std::string na; // name
|
|
|
1429 |
std::string bd; // Description --> ignored
|
|
|
1430 |
int lt{0}; // pixel from left
|
|
|
1431 |
int tp{0}; // pixel from top
|
|
|
1432 |
int wt{0}; // width
|
|
|
1433 |
int ht{0}; // height
|
|
|
1434 |
int zo{0}; // Z-Order
|
|
|
1435 |
std::string hs; // bounding, ...
|
|
|
1436 |
std::string bs; // Border style (circle, ...)
|
|
|
1437 |
FEEDBACK fb{FB_NONE}; // Feedback type (momentary, ...)
|
|
|
1438 |
int ap{1}; // Address port (default: 1)
|
|
|
1439 |
int ad{0}; // Address channel
|
|
|
1440 |
int ch{0}; // Channel number
|
|
|
1441 |
int cp{1}; // Channel port (default: 1)
|
|
|
1442 |
int lp{1}; // Level port (default: 1)
|
|
|
1443 |
int lv{0}; // Level code
|
|
|
1444 |
int ta{0}; // Listbox table channel
|
|
|
1445 |
int ti{0}; // Listbox table index number of rows (all rows have this number in "cp")
|
|
|
1446 |
int tr{0}; // Listbox number of rows
|
|
|
1447 |
int tc{0}; // Listbox number of columns
|
|
|
1448 |
int tj{0}; // Listbox row height
|
|
|
1449 |
int tk{0}; // Listbox preferred row height
|
|
|
1450 |
int of{0}; // Listbox list offset: 0=disabled/1=enabled
|
|
|
1451 |
int tg{0}; // Listbox managed: 0=no/1=yes
|
|
|
1452 |
int so{1}; // String output port
|
|
|
1453 |
int co{1}; // Command port
|
|
|
1454 |
std::vector<std::string> cm; // Commands to send on each button hit
|
|
|
1455 |
std::string dr; // Level "horizontal" or "vertical"
|
|
|
1456 |
int va{0}; // Level control value
|
|
|
1457 |
int stateCount{0}; // State count with multistate buttons (number of states)
|
|
|
1458 |
int rm{0}; // State count with multistate buttons?
|
|
|
1459 |
int nu{2}; // Animate time up
|
|
|
1460 |
int nd{2}; // Animate time down
|
|
|
1461 |
int ar{0}; // Auto repeat (1 = true)
|
|
|
1462 |
int ru{2}; // Animate time up (bargraph)
|
|
|
1463 |
int rd{2}; // Animate time down (bargraph)
|
|
|
1464 |
int lu{2}; // Animate time up (Bargraph)
|
|
|
1465 |
int ld{2}; // Animate time down (Bargraph)
|
|
|
1466 |
int rv{0}; // Level control repeat time
|
|
|
1467 |
int rl{0}; // Range low
|
|
|
1468 |
int rh{0}; // Range high
|
|
|
1469 |
int ri{0}; // Bargraph inverted (0 = normal, 1 = inverted)
|
|
|
1470 |
int ji{0}; // Joystick aux inverted (0 = normal, 1 = inverted)
|
|
|
1471 |
int rn{0}; // Bargraph: Range drag increment
|
|
|
1472 |
int ac_di{0}; // (guess) Direction of text: 0 = left to right (default); 1 = right to left
|
|
|
1473 |
int hd{0}; // 1 = Hidden, 0 = Normal visible
|
|
|
1474 |
int da{0}; // 1 = Disabled, 0 = Normal active
|
|
|
1475 |
int pp{0}; // >0 = password protected; Range 1 to 4
|
|
|
1476 |
std::string lf; // Bargraph function: empty = display only, active, active centering, drag, drag centering
|
|
|
1477 |
std::string sd; // Name/Type of slider for a bargraph
|
|
|
1478 |
std::string vt; // Level control type (rel = relative, abs = absolute)
|
|
|
1479 |
std::string cd; // Name of cursor for a joystick
|
|
|
1480 |
std::string sc; // Color of slider (for bargraph)
|
|
|
1481 |
std::string cc; // Color of cursor (for joystick)
|
|
|
1482 |
int mt{0}; // Length of text area (0 = 2000)
|
|
|
1483 |
std::string dt; // "multiple" textarea has multiple lines, else single line
|
|
|
1484 |
std::string im; // Input mask of a text area
|
|
|
1485 |
int st{0}; // SubPageView: ID of subview list
|
|
|
1486 |
int ws{0}; // SubPageView: Wrap subpages; 1 = YES
|
|
|
1487 |
std::string on; // SubPageView: direction: vert = vertical, if empty: horizontal which is default
|
|
|
1488 |
int sa{0}; // SubPageView: Percent of space between items in list
|
|
|
1489 |
int dy{0}; // SubPageView: Allow dynamic reordering; 1 = YES
|
|
|
1490 |
int rs{0}; // SubPageView: Reset view on show; 1 = YES
|
|
|
1491 |
int ba{0}; // SubPageView: 1 = Scrollbar is visible, 0 = No scrollbar visible
|
|
|
1492 |
int bo{0}; // SubPageView: Scrollbar offset in pixels; Only valid if "ba" > 0
|
|
|
1493 |
std::string we; // SubPageView: Anchor position: Empty = Center, "l/t" = left/top, "r/b" = right/bottom
|
|
|
1494 |
std::string pc; // Password character for text area
|
|
|
1495 |
std::string op; // String the button send
|
|
|
1496 |
bool visible{true}; // TRUE=Button is visible
|
|
|
1497 |
std::vector<PUSH_FUNC_T> pushFunc; // Push functions: This are executed on button press
|
|
|
1498 |
std::vector<SR_T> sr; // The elements the button consists of
|
|
|
1499 |
// ListView settings (G5)
|
|
|
1500 |
std::string listSource; // Defines the data source for a list.
|
|
|
1501 |
int listEvNum{1401}; // ListView event number.
|
|
|
1502 |
std::string listFilter; // ListView filter string.
|
|
|
1503 |
int listComponent{0}; // ListView component
|
|
|
1504 |
int listLayout{0}; // ListView layout.
|
|
|
1505 |
std::map<std::string,std::string> listFieldMap; // Maps the fields from the source to the columns of the list
|
|
|
1506 |
// LIST_SORT listSort{LIST_SORT_NONE}; // ListView sort algorithm
|
|
|
1507 |
std::string listSortOverride; // A SQL ORDER BY command like sort option. Only valid if listStort == LIST_SORT_OVERRIDE
|
|
|
1508 |
std::string listSourceUser; // The user name (optional)
|
|
|
1509 |
std::string listSourcePass; // The password (optional)
|
|
|
1510 |
bool listSourceCsv{false}; // TRUE = Source of listView is in CSV data
|
|
|
1511 |
bool listSourceHasHeader{false}; // TRUE = The listView data has a had line which must be ignored.
|
|
|
1512 |
int listViewP1{0}; // ListView layout percentage 1
|
|
|
1513 |
int listViewP2{0}; // ListView layout percentage 2
|
|
|
1514 |
bool listViewColFiler{false}; // ListView column filter state (TRUE = on)
|
|
|
1515 |
int listViewColFilterHeight{0}; // ListView column filter height
|
|
|
1516 |
bool listAlphaScroll{false}; // ListView alpha scroll state (TRUE = scrollbar visible)
|
|
|
1517 |
|
|
|
1518 |
TPalette *mPalette{nullptr}; // The color palette
|
|
|
1519 |
// Image management
|
|
|
1520 |
SkBitmap mLastImage; // The last calculated image
|
|
|
1521 |
ulong mHandle{0}; // internal used handle to identify button
|
|
|
1522 |
uint32_t mButtonID{0}; // A CRC32 checksum identifying the button.
|
|
|
1523 |
int mParentHeight{0}; // The height of the parent page / subpage
|
|
|
1524 |
int mParentWidth{0}; // The width of the parent page / subpage
|
|
|
1525 |
bool mEnabled{true}; // By default a button is enabled (TRUE); FALSE = Button disabled
|
|
|
1526 |
TFont *mFonts{nullptr}; // The font table
|
|
|
1527 |
int mGlobalOO{-1}; // Opacity of the whole subpage, if any
|
|
|
1528 |
int mActInstance{0}; // Active instance
|
|
|
1529 |
DRAW_ORDER mDOrder[ORD_ELEM_COUNT]; // The order to draw the elements of a button
|
|
|
1530 |
std::thread mThrAni; // Thread handle for animation
|
|
|
1531 |
std::thread mThrRes; // A resouce (download of a remote image/video) running in background
|
|
|
1532 |
std::thread mThrSlider; // Thread to move a slider (bargraph)
|
|
|
1533 |
std::atomic<bool> mAniRunning{false}; // TRUE = Animation is running
|
|
|
1534 |
std::atomic<bool> mAniStop{false}; // If TRUE, the running animation will stop
|
|
|
1535 |
// int mLastLevel{0}; // The last level value for a bargraph
|
|
|
1536 |
int mBarStartLevel{0}; // The level when a drag bargraph started.
|
|
|
1537 |
int mBarThreshold{0}; // The difference between start coordinate and actual coordinate (drag bargraph only)
|
|
|
1538 |
bool mRunBargraphMove{false}; // TRUE = The thread to move the bargraph level should run.
|
|
|
1539 |
bool mThreadRunMove{false}; // TRUE the thread to move the bargrapg slider is running.
|
|
|
1540 |
// int mLastJoyX{0}; // The last x position of the joystick curser
|
|
|
1541 |
// int mLastJoyY{0}; // The last y position of the joystick curser
|
|
|
1542 |
// int mLastSendLevelX{0}; // This is the last level send from a bargraph or the X level of a joystick
|
|
|
1543 |
// int mLastSendLevelY{0}; // This is the last Y level from a joystick
|
|
|
1544 |
bool mSystemReg{false}; // TRUE = registered as system button
|
|
|
1545 |
amx::ANET_BLINK mLastBlink; // This is used for the system clock buttons
|
|
|
1546 |
TTimer *mTimer{nullptr}; // This is for buttons displaying the time or a date. It's a thread running in background.
|
|
|
1547 |
static THR_REFRESH_t *mThrRefresh; // If we have a source to reread periodicaly, this starts a thread to do that.
|
|
|
1548 |
ulong mAniRunTime{0}; // The time in milliseconds an animation should run. 0 = run forever.
|
|
|
1549 |
BITMAP_CACHE mBCDummy; // A dummy retuned in case no cache exists or the element was not found.
|
|
|
1550 |
bool mChanged{true}; // TRUE=Something changed --> button must be redrawn
|
|
|
1551 |
int mBorderWidth{0}; // If there is a border this is set to the pixels the border is using
|
|
|
1552 |
std::vector<std::string> mListContent; // The content of a list, if this button is one
|
|
|
1553 |
bool mSubViewPart{false}; // TRUE = The button is part of a subview item.
|
|
|
1554 |
int mCursorPosition{0}; // The cursor position if this is of type TEXT_INPUT
|
|
|
1555 |
bool mHasFocus{false}; // If this is of type TEXT_INPUT this holds the focus state
|
|
|
1556 |
std::string dummy; // dummy string used to return an empty string.
|
|
|
1557 |
std::string mPassword; // Contains the last typed password (askPassword()).
|
|
|
1558 |
std::string mUser; // If this contains a user name contained in the User Password list, the user is asked for a password.
|
|
|
1559 |
int mPosLeft{0}; // The actual left position of the button
|
|
|
1560 |
int mPosTop{0}; // The actual top position of the button
|
|
|
1561 |
int mWidthOrig{0}; // The original width
|
|
|
1562 |
int mHeightOrig{0}; // The original height
|
|
|
1563 |
|
|
|
1564 |
};
|
|
|
1565 |
|
|
|
1566 |
typedef struct BUTTONS_T
|
|
|
1567 |
{
|
|
|
1568 |
TButton *button{nullptr};
|
|
|
1569 |
BUTTONS_T *previous{nullptr};
|
|
|
1570 |
BUTTONS_T *next{nullptr};
|
|
|
1571 |
} BUTTONS_T;
|
|
|
1572 |
}
|
|
|
1573 |
|
|
|
1574 |
#endif
|