Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 andreas 1
/*
99 andreas 2
 * Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
2 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>
3 andreas 23
#include <map>
6 andreas 24
#include <functional>
15 andreas 25
#include <thread>
6 andreas 26
 
4 andreas 27
#include <include/core/SkImage.h>
28
#include <include/core/SkCanvas.h>
6 andreas 29
#include <include/core/SkBitmap.h>
30
 
76 andreas 31
#include "texpat++.h"
4 andreas 32
#include "tpalette.h"
33
#include "tcolor.h"
7 andreas 34
#include "tfont.h"
15 andreas 35
#include "tamxnet.h"
36
#include "ttimer.h"
21 andreas 37
#include "timagerefresh.h"
160 andreas 38
#include "tsystemdraw.h"
195 andreas 39
#include "tsystem.h"
2 andreas 40
 
8 andreas 41
#define ORD_ELEM_COUNT  5
42
 
21 andreas 43
extern bool prg_stopped;
97 andreas 44
extern bool _restart_;
21 andreas 45
 
8 andreas 46
class SkFont;
66 andreas 47
class SkTextBlob;
48
 
21 andreas 49
struct RESOURCE_T;
8 andreas 50
 
2 andreas 51
namespace Button
52
{
4 andreas 53
    typedef struct SYSBORDER_t
54
    {
81 andreas 55
        int id{0};                  // Internal unique ID number
56
        char *name{nullptr};        // Name of the border
57
        int number{0};              // AMX number
58
        char *style{nullptr};       // Style to use if dynamicaly calculated
59
        int width{0};               // The width of the border
60
        int radius{0};              // Radius for rounded corners
61
        bool calc{false};           // TRUE = Calculated inside, FALSE = Read from images
4 andreas 62
    }SYSBORDER_t;
63
 
110 andreas 64
    typedef struct SYSTEF_t         // Text effect names
65
    {
66
        int idx{0};
67
        std::string name;
68
    }SYSTEF_t;
69
 
3 andreas 70
    typedef enum TEXT_ORIENTATION
71
    {
72
        ORI_ABSOLUT,
73
        ORI_TOP_LEFT,
74
        ORI_TOP_MIDDLE,
75
        ORI_TOP_RIGHT,
76
        ORI_CENTER_LEFT,
77
        ORI_CENTER_MIDDLE,		// default
78
        ORI_CENTER_RIGHT,
79
        ORI_BOTTOM_LEFT,
80
        ORI_BOTTOM_MIDDLE,
81
        ORI_BOTTOM_RIGHT
82
    } TEXT_ORIENTATION;
2 andreas 83
 
7 andreas 84
    typedef enum TEXT_EFFECT
85
    {
86
        EFFECT_NONE,
87
        EFFECT_OUTLINE_S,
88
        EFFECT_OUTLINE_M,
89
        EFFECT_OUTLINE_L,
90
        EFFECT_OUTLINE_X,
91
        EFFECT_GLOW_S,
92
        EFFECT_GLOW_M,
93
        EFFECT_GLOW_L,
94
        EFFECT_GLOW_X,
95
        EFFECT_SOFT_DROP_SHADOW_1,
96
        EFFECT_SOFT_DROP_SHADOW_2,
97
        EFFECT_SOFT_DROP_SHADOW_3,
98
        EFFECT_SOFT_DROP_SHADOW_4,
99
        EFFECT_SOFT_DROP_SHADOW_5,
100
        EFFECT_SOFT_DROP_SHADOW_6,
101
        EFFECT_SOFT_DROP_SHADOW_7,
102
        EFFECT_SOFT_DROP_SHADOW_8,
103
        EFFECT_MEDIUM_DROP_SHADOW_1,
104
        EFFECT_MEDIUM_DROP_SHADOW_2,
105
        EFFECT_MEDIUM_DROP_SHADOW_3,
106
        EFFECT_MEDIUM_DROP_SHADOW_4,
107
        EFFECT_MEDIUM_DROP_SHADOW_5,
108
        EFFECT_MEDIUM_DROP_SHADOW_6,
109
        EFFECT_MEDIUM_DROP_SHADOW_7,
110
        EFFECT_MEDIUM_DROP_SHADOW_8,
111
        EFFECT_HARD_DROP_SHADOW_1,
112
        EFFECT_HARD_DROP_SHADOW_2,
113
        EFFECT_HARD_DROP_SHADOW_3,
114
        EFFECT_HARD_DROP_SHADOW_4,
115
        EFFECT_HARD_DROP_SHADOW_5,
116
        EFFECT_HARD_DROP_SHADOW_6,
117
        EFFECT_HARD_DROP_SHADOW_7,
118
        EFFECT_HARD_DROP_SHADOW_8,
119
        EFFECT_SOFT_DROP_SHADOW_1_WITH_OUTLINE,
120
        EFFECT_SOFT_DROP_SHADOW_2_WITH_OUTLINE,
121
        EFFECT_SOFT_DROP_SHADOW_3_WITH_OUTLINE,
122
        EFFECT_SOFT_DROP_SHADOW_4_WITH_OUTLINE,
123
        EFFECT_SOFT_DROP_SHADOW_5_WITH_OUTLINE,
124
        EFFECT_SOFT_DROP_SHADOW_6_WITH_OUTLINE,
125
        EFFECT_SOFT_DROP_SHADOW_7_WITH_OUTLINE,
126
        EFFECT_SOFT_DROP_SHADOW_8_WITH_OUTLINE,
127
        EFFECT_MEDIUM_DROP_SHADOW_1_WITH_OUTLINE,
128
        EFFECT_MEDIUM_DROP_SHADOW_2_WITH_OUTLINE,
129
        EFFECT_MEDIUM_DROP_SHADOW_3_WITH_OUTLINE,
130
        EFFECT_MEDIUM_DROP_SHADOW_4_WITH_OUTLINE,
131
        EFFECT_MEDIUM_DROP_SHADOW_5_WITH_OUTLINE,
132
        EFFECT_MEDIUM_DROP_SHADOW_6_WITH_OUTLINE,
133
        EFFECT_MEDIUM_DROP_SHADOW_7_WITH_OUTLINE,
134
        EFFECT_MEDIUM_DROP_SHADOW_8_WITH_OUTLINE,
135
        EFFECT_HARD_DROP_SHADOW_1_WITH_OUTLINE,
136
        EFFECT_HARD_DROP_SHADOW_2_WITH_OUTLINE,
137
        EFFECT_HARD_DROP_SHADOW_3_WITH_OUTLINE,
138
        EFFECT_HARD_DROP_SHADOW_4_WITH_OUTLINE,
139
        EFFECT_HARD_DROP_SHADOW_5_WITH_OUTLINE,
140
        EFFECT_HARD_DROP_SHADOW_6_WITH_OUTLINE,
141
        EFFECT_HARD_DROP_SHADOW_7_WITH_OUTLINE,
142
        EFFECT_HARD_DROP_SHADOW_8_WITH_OUTLINE
143
    }TEXT_EFFECT;
144
 
8 andreas 145
    typedef enum DRAW_ORDER
146
    {
147
        ORD_ELEM_NONE,
148
        ORD_ELEM_FILL,
149
        ORD_ELEM_BITMAP,
150
        ORD_ELEM_ICON,
151
        ORD_ELEM_TEXT,
152
        ORD_ELEM_BORDER
153
    }DRAW_ORDER;
154
 
43 andreas 155
    typedef enum FEEDBACK
156
    {
157
        FB_NONE,
158
        FB_CHANNEL,
159
        FB_INV_CHANNEL,     // inverted channel
160
        FB_ALWAYS_ON,
161
        FB_MOMENTARY,
162
        FB_BLINK
163
    } FEEDBACK;
164
 
159 andreas 165
    typedef enum PMIX
166
    {
167
        PMIX_MULTIPLY,
168
        PMIX_XOR,
169
        PMIX_SCREEN,
170
        PMIX_SRC,
171
        PMIX_DST,
172
        PMIX_SRCOVER,
173
        PMIX_SRCTOP,
174
        PMIX_DSTTOP,
175
        PMIX_PLUS
176
    }PMIX;
177
 
3 andreas 178
    typedef struct SR_T
179
    {
180
        int number{0};
6 andreas 181
        std::string _do;        // Order on how to show a multistate bargraph (010203...)
182
        std::string bs;         // Frame type (circle, ...)
183
        std::string mi;         // Chameleon image
184
        int mi_width{0};        // Width of image
185
        int mi_height{0};       // Height of image
186
        std::string cb;         // Border color
187
        std::string cf;         // Fill color
188
        std::string ct;         // Text Color
189
        std::string ec;         // Text effect color
190
        std::string bm;         // bitmap file name
191
        std::string sd;         // Sound file to play
192
        int bm_width{0};        // Width of image
193
        int bm_height{0};       // Height of image
194
        bool dynamic{false};    // TRUE = moving image
195
        int sb{0};              // Index to external graphics download
196
        int ii{0};              // Icon index number
10 andreas 197
        int ix{0};              // Icon X position
198
        int iy{0};              // Icon Y position
7 andreas 199
        int ji{5};              // Icon style / position like "jt", default 5 = center+middle
200
        int jb{5};              // Image position (center, left, ...), default 5 = center+middle
10 andreas 201
        int bx{0};              // Absolute image position x
202
        int by{0};              // Absolute image position y
203
        int fi{0};              // Font index
6 andreas 204
        std::string te;         // Text
205
        TEXT_ORIENTATION jt{ORI_CENTER_MIDDLE}; // Text orientation
206
        int tx{0};              // Text X position
207
        int ty{0};              // Text Y position
208
        int ww{0};              // line break when 1
209
        int et{0};              // Text effect (^TEF)
8 andreas 210
        int oo{-1};             // Over all opacity
3 andreas 211
    } SR_T;
2 andreas 212
 
43 andreas 213
    typedef struct EXTBUTTON_t
3 andreas 214
    {
43 andreas 215
        BUTTONTYPE type;
216
        int bi{0};              // button ID
217
        std::string na;         // name
218
        int lt{0};              // pixel from left
219
        int tp{0};              // pixel from top
220
        int wt{0};              // width
221
        int ht{0};              // height
222
        int zo{0};              // Z-Order
223
        std::string hs;         // bounding, ...
224
        std::string bs;         // Border style (circle, ...)
225
        FEEDBACK fb{FB_NONE};   // Feedback type (momentary, ...)
226
        int ap{1};              // Address port (default: 1)
227
        int ad{0};              // Address channel
228
        int lp{1};              // Level port (default: 1)
229
        int lv{0};              // Level code
230
        std::string dr;         // Level "horizontal" or "vertical"
231
        int lu{0};              // Animate time up (Bargraph)
232
        int ld{0};              // Animate time down (Bargraph)
233
        int rl{0};              // Range low
234
        int rh{0};              // Range high
235
        int rn{0};              // Bargraph: Range drag increment
236
        std::string sc;         // Color of slider (for bargraph)
237
        std::vector<SR_T> sr;
238
    }EXTBUTTON_t;
2 andreas 239
 
3 andreas 240
    typedef struct PUSH_FUNC
241
    {
6 andreas 242
        std::string pfType; // command to execute when button was pushed
243
        std::string pfName; // Name of popup
3 andreas 244
    } PUSH_FUNC_T;
2 andreas 245
 
4 andreas 246
    typedef enum CENTER_CODE
247
    {
248
        SC_ICON = 0,
249
        SC_BITMAP,
250
        SC_TEXT
251
    }CENTER_CODE;
252
 
253
    typedef struct POSITION_t
254
    {
255
        int width{0};
256
        int height{0};
10 andreas 257
        int left{1};
258
        int top{1};
17 andreas 259
        bool overflow{false};
4 andreas 260
        bool valid{false};
261
    }POSITION_t;
262
 
99 andreas 263
    typedef struct IMAGE_SIZE_t
264
    {
265
        int width{0};
266
        int height{0};
267
    }IMAGE_SIZE_t;
268
 
21 andreas 269
    typedef struct THR_REFRESH_t
270
    {
271
        ulong handle{0};
272
        ulong parent{0};
273
        int bi{0};
274
        TImageRefresh *mImageRefresh{nullptr};
275
        THR_REFRESH_t *next{nullptr};
276
    }THR_REFRESH_t;
277
 
50 andreas 278
    typedef struct BITMAP_t
279
    {
52 andreas 280
        unsigned char *buffer{nullptr};
281
        int left{0};
282
        int top{0};
283
        int width{0};
284
        int height{0};
285
        size_t rowBytes{0};
50 andreas 286
    }BITMAP_t;
287
 
94 andreas 288
    typedef struct BITMAP_CACHE
289
    {
290
        ulong handle{0};
291
        ulong parent{0};
292
        int left{0};
293
        int top{0};
294
        int width{0};
295
        int height{0};
296
        int bi{0};
97 andreas 297
        bool show{false};
94 andreas 298
        bool ready{false};
299
        SkBitmap bitmap;
300
    }BITMAP_CACHE;
301
 
225 andreas 302
#   define LIST_IMAGE_CELL     1
303
#   define LIST_TEXT_PRIMARY   2
304
#   define LIST_TEXT_SECONDARY 4
305
 
306
    typedef enum LIST_SORT
307
    {
308
        LIST_SORT_NONE,
309
        LIST_SORT_ASC,
310
        LIST_SORT_DESC,
311
        LIST_SORT_OVERRIDE
312
    }LIST_SORT;
313
 
195 andreas 314
    class TButton : public TSystem
3 andreas 315
    {
316
        public:
317
            TButton();
318
            ~TButton();
2 andreas 319
 
14 andreas 320
            /**
321
             * The following function parses the parameters of a particular
322
             * button and creates a new button. This function is called either
323
             * from class TPage or TSubPage when a page or subpage is created.
324
             *
23 andreas 325
             * @param xml     A pointer to the XML reader
326
             * @param node    A pointer to the actual node in the XML tree.
76 andreas 327
             * @return On success the last index processed. On error
328
             * TExpat::npos is returned.
14 andreas 329
             */
76 andreas 330
            size_t initialize(Expat::TExpat *xml, size_t index);
2 andreas 331
 
14 andreas 332
            /**
333
             * Returns the button index. This is a unique number inside a page
334
             * or subpage.
23 andreas 335
             *
336
             * @return return the button index number as defined in the
337
             * configuration file.
14 andreas 338
             */
3 andreas 339
            int getButtonIndex() { return bi; }
14 andreas 340
            /**
341
             * Returns the name of the button.
342
             */
3 andreas 343
            std::string& getButtonName() { return na; }
14 andreas 344
            /**
345
             * Returns the description of the button, if there is one.
346
             */
3 andreas 347
            std::string& getButtonDescription() { return bd; }
14 andreas 348
            /**
349
             * Returns the width of the button in pixels.
350
             */
3 andreas 351
            int getWidth() { return wt; }
14 andreas 352
            /**
353
             * Returns the height of the button in pixels.
354
             */
3 andreas 355
            int getHeight() { return ht; }
14 andreas 356
            /**
357
             * Returns the left position in pixels.
358
             */
3 andreas 359
            int getLeftPosition() { return lt; }
14 andreas 360
            /**
361
             * Returns the top position of the button in pixels.
362
             */
3 andreas 363
            int getTopPosition() { return tp; }
14 andreas 364
            /**
365
             * Returns the Z-order. This number marks the order the buttons
366
             * are drawed on the screen. Inside a page or subpage the buttons
367
             * are always sorted.
368
             */
3 andreas 369
            int getZOrder() { return zo; }
14 andreas 370
            /**
371
             * Returns the type of the button.
372
             */
373
            BUTTONTYPE getButtonType() { return type; }
149 andreas 374
            /**
375
             * Set font file name and optional the size
376
             *
377
             * @param font  File name of the font
378
             * @param size  The size of the font in PT
379
             * @param inst  The instance of the button
380
             */
381
            bool setFontFileName(const std::string& name, int size, int inst);
15 andreas 382
 
383
            int getRangeLow() { return rl; }
384
            int getRangeHigh() { return rh; }
385
            int getStateCount() { return stateCount; }
14 andreas 386
            int getAddressPort() { return ap; }
387
            int getAddressChannel() { return ad; }
388
            int getChannelNumber() { return ch; }
389
            int getChannelPort() { return cp; }
390
            int getLevelPort() { return lp; }
391
            int getLevelValue() { return lv; }
110 andreas 392
            std::string getText(int inst=0);
393
            std::string getTextColor(int inst=0);
394
            std::string getTextEffectColor(int inst=0);
108 andreas 395
            void setTextEffectColor(const std::string& ec, int inst=-1);
205 andreas 396
            bool setTextEffectColorOnly(const std::string& ec, int inst=-1);
110 andreas 397
            int getTextEffect(int inst=0);
398
            void setTextEffect(int et, int inst=-1);
399
            std::string getTextEffectName(int inst=0);
400
            void setTextEffectName(const std::string& name, int inst=-1);
401
            std::string getFillColor(int inst=0);
402
            std::string getBitmapName(int inst=0);
51 andreas 403
            bool isSingleLine() { return ( dt.compare("multiple") != 0); }
404
            bool isMultiLine() { return ( dt.compare("multiple") == 0); }
405
            int getTextMaxChars() { return mt; }
110 andreas 406
            void setTextMaxChars(int m) { mt = m; }
407
            bool getTextWordWrap(int inst=0);
408
            bool setTextWordWrap(bool ww, int inst=-1);
409
            int getFontIndex(int inst=0);
410
            bool setFontIndex(int fi, int inst=-1);
411
            int getIconIndex(int inst=0);
412
            std::string getSound(int inst=0);
413
            void setSound(const std::string& sd, int inst=-1);
414
            bool getDynamic(int inst=0);
107 andreas 415
            void setDynamic(int d, int inst=-1);
14 andreas 416
            int getNumberInstances() { return (int)sr.size(); }
15 andreas 417
            int getActiveInstance() { return mActInstance; }
16 andreas 418
            ulong getHandle() { return mHandle; }
50 andreas 419
            ulong getParent() { return (mHandle & 0xffff0000); }
51 andreas 420
            void setActiveInstance(int inst);
16 andreas 421
            void setEnable(bool en) { mEnabled = en; }
422
            bool isEnabled() { return mEnabled; }
26 andreas 423
            void setHandle(ulong handle) { mHandle = handle; };
4 andreas 424
            void setPalette(TPalette *pal) { mPalette = pal; }
6 andreas 425
            void setParentWidth(int width) { mParentWidth = width; }
426
            void setParentHeight(int height) { mParentHeight = height; }
427
            void setParentSize(int width, int height) { mParentWidth = width; mParentHeight = height; }
7 andreas 428
            void setFonts(TFont *ft) { mFonts = ft; }
10 andreas 429
            void setGlobalOpacity(int oo) { if (oo >= 0 && oo <= 255) mGlobalOO = oo; }
100 andreas 430
            void setVisible(bool v) { visible = v; hd = (v ? 0 : 1); }
97 andreas 431
            bool isVisible() { return visible; }
199 andreas 432
            bool haveListContent() { return _getListContent != nullptr; }
433
            bool haveListRow() { return _getListRow != nullptr; }
200 andreas 434
            std::function<std::vector<std::string>(ulong handle, int ap, int ta, int ti, int rows, int columns)> getCallbackListContent() { return _getListContent; }
435
            std::function<std::string(int ti, int row)> getCallbackListRow() { return _getListRow; }
436
            std::function<void (TButton *button)> getCallbackGlobalSettings() { return _getGlobalSettings; };
38 andreas 437
 
438
            /**
439
             * @brief setBitmap Sets a new bitmap to the button
440
             * If there was already a bitmap on this button and if this bitmap
441
             * is different from the one in \p file, then it is erased.
442
             * The new bitmap file name is set and it will be loaded and created.
443
             *
444
             * @param file      File name of a bitmap file.
445
             * @param instance  The instance where to put the new bitmap. If
446
             *                  this is 0, the bitmap is set on all instances.
447
             * @return TRUE if no errors occures, otherwise FALSE.
448
             */
16 andreas 449
            bool setBitmap(const std::string& file, int instance);
38 andreas 450
            /**
104 andreas 451
             * @brief setCameleon Sets a new cameleon bitmap to the button
452
             * If there was already a cameleon bitmap on this button and if this
453
             * cameleon bitmap is different from the one in \p file, then it is
454
             * erased. The new cameleon bitmap file name is set and it will be
455
             * loaded and created.
456
             *
457
             * @param file      File name of a cameleon bitmap file.
458
             * @param instance  The instance where to put the new bitmap. If
459
             *                  this is 0, the bitmap is set on all instances.
460
             * @return TRUE if no errors occures, otherwise FALSE.
461
             */
462
            bool setCameleon(const std::string& file, int instance);
463
            /**
38 andreas 464
             * @brief setOpacity Sets the opacity of this button
465
             *
466
             * @param op        The opacity in a reange of 0 to 255.
467
             * @param instance  The instance where to put the new bitmap. If
468
             *                  this is 0, the bitmap is set on all instances.
469
             * @return TRUE if no errors occures, otherwise FALSE.
470
             */
16 andreas 471
            bool setOpacity(int op, int instance);
110 andreas 472
            int getOpacity(int inst=0);
200 andreas 473
            int getListAp() { return ap; }
474
            int getListTa() { return ta; }
475
            int getListTi() { return ti; }
476
            int getListNumRows() { return tr; }
477
            int getListNumCols() { return tc; }
16 andreas 478
            bool setFont(int id, int instance);
205 andreas 479
            bool setFontOnly(int id, int instance);
16 andreas 480
            void setTop(int top);
481
            void setLeft(int left);
482
            void setLeftTop(int left, int top);
152 andreas 483
            void setRectangle(int left, int top, int right, int bottom);
21 andreas 484
            void setResourceName(const std::string& name, int instance);
106 andreas 485
            int getBitmapJustification(int *x, int *y, int instance);
486
            void setBitmapJustification(int j, int x, int y, int instance);
487
            int getIconJustification(int *x, int *y, int instance);
104 andreas 488
            void setIconJustification(int j, int x, int y, int instance);
106 andreas 489
            int getTextJustification(int *x, int *y, int instance);
104 andreas 490
            void setTextJustification(int j, int x, int y, int instance);
205 andreas 491
            bool setTextJustificationOnly(int j, int x, int y, int instance);
38 andreas 492
            bool startAnimation(int start, int end, int time);
493
            /**
494
             * @brief registerSystemButton registers the button as a system button.
495
             *
496
             * If the button is a system button, than it has special functions.
497
             * The action of the button depends on the kind of system button.
498
             */
15 andreas 499
            void registerSystemButton();
500
            bool isSystemButton();
38 andreas 501
            void addPushFunction(std::string& func, std::string& page);
16 andreas 502
            void clearPushFunctions() { pushFunc.clear(); }
503
            void clearPushFunction(const std::string& action);
504
            void refresh();
3 andreas 505
            /**
14 andreas 506
             * Sets a particular instance of the button active. This implies
507
             * a redraw of the button in case the instance is different from
508
             * the one already visible.
509
             *
510
             * @param instance
511
             * The instance of the button to be activated.
512
             *
513
             * @return
514
             * On error returns FALSE.
515
             */
516
            bool setActive(int instance);
517
            /**
518
             * Sets an Icon on the button. This implies a redraw of the button
519
             * in case the instance is different from the one already visible.
520
             *
521
             * @param id
522
             * The id number of the icon.
523
             *
524
             * @param instance
525
             * The instance where the icon should be drawed
526
             *
527
             * @return On error returns FALSE.
528
             */
529
            bool setIcon(int id, int instance);
530
            /**
531
             * Sets an Icon on the button. This implies a redraw of the button
532
             * in case the instance is different from the one already visible.
533
             *
534
             * @param icon
535
             * The file name of the icon.
536
             *
537
             * @param instance
538
             * The instance where the icon should be drawed
539
             *
540
             * @return
541
             * On error returns FALSE.
542
             */
543
            bool setIcon(const std::string& icon, int instance);
544
            /**
545
             * Removes an icon from a button. This implies a redraw of the
546
             * button.
547
             *
548
             * @param instance
549
             * The instance number involved.
550
             *
551
             * @return
552
             * On error returns FALSE.
553
             */
554
            bool revokeIcon(int instance);
555
            /**
556
             * Set a string to a button.
557
             *
558
             * @param txt
559
             * The text to write on top of  a button.
560
             *
561
             * @param instance
562
             * The instance number involved.
563
             *
564
             * @return
565
             * On error returns FALSE.
566
             */
567
            bool setText(const std::string& txt, int instance);
568
            /**
51 andreas 569
             * Set a string to a button. This method does not trigger a new
570
             * drawing of the element.
571
             *
572
             * @param txt
573
             * The text to write on top of  a button.
574
             *
575
             * @param instance
576
             * The instance number involved.
577
             *
578
             * @return
579
             * On error returns FALSE.
580
             */
581
            bool setTextOnly(const std::string& txt, int instance);
582
            /**
43 andreas 583
             * @brief appendText    Append non-unicode text.
584
             * @param txt
585
             * The text to write on top of  a button.
586
             * @param instance
587
             * The instance number involved.
588
             * @return
589
             * On error returns FALSE.
590
             */
591
            bool appendText(const std::string& txt, int instance);
592
            /**
593
             * @brief setBorderColor Set the border color.
594
             * Set the border color to the specified color. Only if the
595
             * specified border color is not the same as the current color.
596
             * Note: Color can be assigned by color name (without spaces),
597
             * number or R,G,B value (RRGGBB or RRGGBBAA).
598
             * @param color     the color
599
             * @param instance
600
             * The instance number involved.
601
             * @return
602
             * On error returns FALSE.
603
             */
604
            bool setBorderColor(const std::string& color, int instance);
605
            /**
82 andreas 606
             * @brief retrieves the current border color.
607
             * Determines the current border color of the button and returns
608
             * the color as a string.
609
             * @param instance  The instance number of the button.
610
             * @return
611
             * If everything went well it returns the color string of the button
612
             * instance. On error an empty string is returned.
613
             */
614
            std::string getBorderColor(int instance);
615
            /**
60 andreas 616
             * @brief setFillColor Set the fill color.
617
             * Set the fill color to the specified color. Only if the
618
             * specified fill color is not the same as the current color.
619
             * Note: Color can be assigned by color name (without spaces),
620
             * number or R,G,B value (RRGGBB or RRGGBBAA).
621
             * @param color     the color
622
             * @param instance
623
             * The instance number involved.
624
             * @return
625
             * On error returns FALSE.
626
             */
627
            bool setFillColor(const std::string& color, int instance);
628
            /**
205 andreas 629
             * @brief setTextColor set the text color.
60 andreas 630
             * Set the text color to the specified color. Only if the
205 andreas 631
             * specified text color is not the same as the current color. It
632
             * redraws the button if the color changed.
60 andreas 633
             * Note: Color can be assigned by color name (without spaces),
634
             * number or R,G,B value (RRGGBB or RRGGBBAA).
635
             * @param color     the color
636
             * @param instance
637
             * The instance number involved.
638
             * @return
639
             * On error returns FALSE.
640
             */
641
            bool setTextColor(const std::string& color, int instance);
642
            /**
205 andreas 643
             * @brief setTextColorOnly set the text color only.
644
             * Set the text color to the specified color. Only if the
645
             * specified text color is not the same as the current color.
646
             * Note: Color can be assigned by color name (without spaces),
647
             * number or R,G,B value (RRGGBB or RRGGBBAA).
648
             * @param color     the color
649
             * @param instance
650
             * The instance number involved.
651
             * @return
652
             * On error returns FALSE.
653
             */
654
            bool setTextColorOnly(const std::string& color, int instance);
655
            /**
60 andreas 656
             * @brief setDrawOrder - Set the button draw order.
657
             * Determines what order each layer of the button is drawn.
658
             * @param order     the draw order
659
             * @param instance
660
             * The instance number involved.
661
             * @return
662
             * On error returns FALSE.
663
             */
664
            bool setDrawOrder(const std::string& order, int instance);
665
            /**
666
             * @brief setFeedback - Set the feedback type of the button.
667
             * ONLY works on General-type buttons.
668
             * @param fb    The feedback type
669
             * @return On error returns FALSE.
670
             */
671
            bool setFeedback(FEEDBACK feedback);
672
            /**
673
             * Set a border to a specific border style associated with a border
674
             * value for those buttons with a defined address range.
675
             * @param style     The name of the border style
676
             * @param instance  -1 = style for all instances
106 andreas 677
             * > 0 means the style is valid only for this instance.
60 andreas 678
             */
679
            bool setBorderStyle(const std::string& style, int instance=-1);
680
            /**
106 andreas 681
             * Retrieves the border style, if any, of the instance \p instance
682
             * and returns it.
683
             * @param instance  The instance from where the border style is
684
             *                  wanted. This value must be between 1 and the
685
             *                  number of available instances.
686
             * @return The border style if there is any or an empty string.
687
             */
688
            std::string getBorderStyle(int instance=-1);
689
            /**
60 andreas 690
             * Set the bargraph upper limit. Range = 1 to 65535.
691
             * @param limit the new limit
692
             * @return TRUE on success.
693
             */
694
            bool setBargraphUpperLimit(int limit);
695
            /**
696
             * Set the bargraph lower limit. Range = 1 to 65535.
697
             * @param limit the new limit
698
             * @return TRUE on success.
699
             */
700
            bool setBargraphLowerLimit(int limit);
701
            /**
108 andreas 702
             * Change the bargraph slider color or joystick cursor color.
703
             * A user can also assign the color by Name and R,G,B value
704
             * (RRGGBB or RRGGBBAA).
705
             * @param color     The color value.
706
             * @return TRUE on success.
707
             */
708
            bool setBargraphSliderColor(const std::string& color);
709
            /**
224 andreas 710
             * Sets the input mask for the text area. This method has no
711
             * effect on any non input button.
712
             * @param mask  The mask.
713
             * @return If all mask letters are valid it returns TRUE.
714
             */
715
            bool setInputMask(const std::string& mask);
716
            /**
717
             * Returns the input mask of the button.
718
             * @rturn The input mask of the text area, if there is any. If
719
             * there is no input mask present, an empty string is returned.
720
             */
721
            std::string& getInputMask() { return im; }
722
            /**
3 andreas 723
             * Read the images, if any, from files and create an image. If there
724
             * are no files, draw the image as defined.
14 andreas 725
             *
40 andreas 726
             * @param force
727
             * This parameter forces the function to reload the image. This is
728
             * necessary if the image of the button was changed by a command.
729
             * This parameter is optional. Defaults to FALSE.
730
             *
14 andreas 731
             * @return
732
             * On error returns FALSE.
3 andreas 733
             */
40 andreas 734
            bool createButtons(bool force = false);
4 andreas 735
            /**
53 andreas 736
             * Register a callback function to display a ready image. This
737
             * function is used for nearly every kind of button or bargraph.
738
             * It is up to the surface to bring the buttons to screen.
4 andreas 739
             */
6 andreas 740
            void registerCallback(std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> displayButton)
4 andreas 741
            {
742
                _displayButton = displayButton;
743
            }
53 andreas 744
            /**
745
             * Register a callback function to display a video on a special
746
             * button. It is up to the surface to display a video. So the
747
             * callback passes only the size, position and the url together
748
             * with a user name and password, if there is one.
749
             */
21 andreas 750
            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; };
4 andreas 751
            /**
198 andreas 752
             * Registers a callback function to get the content of a list.
753
             * This function is called to get from the parent the content of
754
             * a list.
755
             */
200 andreas 756
            void regCallListContent(std::function<std::vector<std::string>(ulong handle, int ap, int ta, int ti, int rows, int columns)> getListCtnt) { _getListContent = getListCtnt; }
198 andreas 757
            /**
200 andreas 758
             * Registers a callback function to get the global settings of the
759
             * global page/subpage.
760
             */
761
            void regCallGlobalSettings(std::function<void (TButton *button)> getGlobalSettings) { _getGlobalSettings = getGlobalSettings; };
762
            /**
198 andreas 763
             * Registers a callback function to get the content of a particular
764
             * row of the list. This function is called for each row detected
765
             * in a list. If a row contains more than one column then the
766
             * columns are separated by a "|" symbol.
767
             */
199 andreas 768
            void regCallListRow(std::function<std::string(int ti, int row)> getListRow) { _getListRow = getListRow; }
198 andreas 769
            /**
4 andreas 770
             * Make a pixel array and call the callback function to display the
771
             * image. If there is no callback function registered, nothing
772
             * happens.
15 andreas 773
             * This method draws a general button. It is used for most
774
             * specialized buttons too.
14 andreas 775
             *
15 andreas 776
             * @param instance
777
             * Optional. The instance of the button to draw. If the base
778
             * instance should be drawn, the parameter can be omitted.
779
             *
780
             * @param show
781
             * Optional. By defualt TRUE. If set to FALSE, the button image is
782
             * not send to GUI. The image is available in the variable
783
             * "mLastImage" immediately after ending the method.
784
             *
14 andreas 785
             * @return
786
             * On error returns FALSE.
4 andreas 787
             */
50 andreas 788
            bool drawButton(int instance=0, bool show=true);
6 andreas 789
            /**
50 andreas 790
             * Creates a pixel array and holds it for access through a callback
791
             * function which receives this class as a whole. The callback
792
             * function displays a keyboard and handles input to this text area.
793
             * The created image can be obtained by calling the function
794
             * getLastImage().
795
             *
796
             * @param instance
797
             * Optional. The instance of the button to draw. If the base
798
             * instance should be drawn, the parameter can be omitted.
799
             *
800
             * @param show
801
             * Optional. By defualt TRUE. If set to FALSE, the button image is
802
             * not send to GUI. The image is available in the variable
803
             * "mLastImage" immediately after ending the method.
804
             *
805
             * @return
806
             * On error returns FALSE.
807
             */
808
            bool drawTextArea(int instance=0);
809
            /**
15 andreas 810
             * Method to draw a multistate animated button. It creates a thread
811
             * with a timer and starts an animation by drawing every instance in
812
             * the defined order.
813
             *
814
             * @return
815
             * On error returns FALSE.
816
             */
817
            bool drawButtonMultistateAni();
818
            /**
819
             * Draws a normal bargraph with an ON and OFF state. Takes care
820
             * about cameleon images. If registered, it calls a callback
821
             * function to the GUI to display the ready image.
822
             *
823
             * @param instance
824
             * The instance of the bargraph to draw. This value must be in the
825
             * range of 0 to "stateCount".
826
             *
827
             * @param level
828
             * This is the level to show on the bargraph. It must be a value
829
             * the range of "rl" (range low) and "rh" (range high). A lower
830
             * value than "rl" is interpreted as "rl" and a value higher than
831
             * "rh" is interpreted as "rh".
832
             *
833
             * @param show
834
             * Optional. By default TRUE. If set to FALSE, the bargraph image is
835
             * not send to GUI. The image is available in the variable
836
             * "mLastImage" immediately after ending the method.
837
             *
838
             * @return
839
             * On error returns FALSE.
840
             */
841
            bool drawBargraph(int instance, int level, bool show=true);
842
            /**
38 andreas 843
             * @brief drawMultistateBargraph draws a bargraph comparable to a button.
844
             * This method draws a multistate bargraph. This is like many
845
             * buttons in one. But they behave like a bargraph. This means, that
846
             * it depends on the level how many buttons are ON and which are OFF.
847
             *
848
             * @param level The level. This defines how many buttons are at ON state.
849
             * @param show  If this is false, the button is invisible.
850
             * @return If everything went well, TRUE is returned. If an error
851
             * occurred it returns FALSE.
852
             */
853
            bool drawMultistateBargraph(int level, bool show=true);
854
            /**
200 andreas 855
             * Draws the background and the frame, if any, of the box. It takes
856
             * the number of rows in account.
857
             *
858
             * @param show  Optional: If set to false the button will not be
859
             * shown.
860
             * @return If everything went well, TRUE is returned. If an error
861
             * occurred it returns FALSE.
862
             */
863
            bool drawList(bool show=true);
864
            /**
6 andreas 865
             * Show the button with it's current state.
866
             */
867
            void show();
11 andreas 868
            /**
15 andreas 869
             * Hide the button. In case of an animated button, the animation is
870
             * stopped.
871
             *
872
             * @param total
873
             * Optional. When set to TRUE, a transparent button is displayed.
874
             */
875
            void hide(bool total=false);
876
            /**
877
             * This method sends the image together with all data to the GUI,
878
             * where it will be shown. The variable mLastImage must not be
879
             * empty for the method to succeed.
880
             */
881
            void showLastButton();
882
            /**
11 andreas 883
             * Handle a mouse click.
15 andreas 884
             *
38 andreas 885
             * @param x
886
             * The x coordinate of the mouse press
887
             *
888
             * @param y
889
             * The y coordinate of the mouse press
890
             *
15 andreas 891
             * @param pressed
892
             * TRUE = Button was pressed, FALSE = Button was released.
893
             *
894
             * @return
895
             * TRUE = Button was clickable and processed. FALSE = Button was not
896
             * clickable.
11 andreas 897
             */
15 andreas 898
            bool doClick(int x, int y, bool pressed);
43 andreas 899
            /**
900
             * Creates a button but uses the informations in the structure
901
             * instead of reading it from a file.
902
             *
903
             * @param bt    A structure containing all informations to create a button.
904
             * @return On success returns TRUE, else FALSE.
905
             */
906
            bool createSoftButton(const EXTBUTTON_t& bt);
50 andreas 907
            /**
908
             * Returns the image in mLastImage as a pixel array with the defined
909
             * dimensions.
910
             *
911
             * @return A typedef IMAGE_t containing the ingredentials of the
912
             * image. It contains a pointer with allocated memory holding the
913
             * image. This buffer must NOT be freed!
914
             */
915
            BITMAP_t getLastImage();
916
            /**
917
             * Returns the fint the button uses.
918
             * @return A structure containing the informations for the font
919
             * to load.
920
             */
921
            FONT_T getFont();
922
            /**
923
             * Returns the style of the font.
924
             * @return The font style.
925
             */
51 andreas 926
            FONT_STYLE getFontStyle();
146 andreas 927
            /**
928
             * Tests the button if it is clickable.
929
             * @return TRUE if it is clickable, FALSE otherwise.
930
             */
154 andreas 931
            bool isClickable(int x = -1, int y = -1);
192 andreas 932
            /**
933
             * Returns the password character.
934
             *
935
             * @return An integer representing the password character. If there
936
             * is no password character 0 is returned.
937
             */
938
            uint getPasswordChar() { return (pc.empty() ? 0 : pc[0]); }
200 andreas 939
            /**
940
             * Returns the rows of the list in case this button is a list.
941
             * Otherwise an empty list is returned.
942
             *
943
             * @return A vector list containing the rows of the list.
944
             */
945
            std::vector<std::string>& getListContent() { return mListContent; }
225 andreas 946
            /**
947
             * @brief Listview Data Source
948
             * This command sets the data source to drive the Listview entries.
949
             * Note that this command only configures the data source it does
950
             * not actually cause the data to be fetched. The ^LVR refresh
951
             * command must be issued to load the data.
952
             *
953
             * @param source    A string containing the source for list data.
954
             * This can be either a URL or the name of a dynamic resource data.
955
             * @param configs   One or more configurations defining the layout
956
             * of the source.
957
             *
958
             * @return If the source is valid it returns TRUE.
959
             */
960
            bool setListSource(const std::string &source, const std::vector<std::string>& configs);
961
            /**
962
             * Returns the set source for list data.
963
             *
964
             * @return A string containg the source or and empty string if no
965
             * valid source was set.
966
             */
967
            std::string& getListSource() { return listSource; }
227 andreas 968
            /**
969
             * Sets a filter for the data of a listView.
970
             *
971
             * @param filter    A string used as a filter for the data.
972
             *
973
             * @return Returns true if the string was evaluated ok.
974
             */
975
            bool setListSourceFilter(const std::string& filter);
976
            /**
977
             * Returns the filter string for a listView data source.
978
             *
979
             * @return The filter string.
980
             */
230 andreas 981
            std::string& getListSourceFilter() { return listFilter; }
982
            /**
983
             * Sets the listView event number. A value of 0 turns off event
984
             * reporting. Any other number activates the events. Currently are
985
             * only refresh events are reported.
986
             *
987
             * @param num   The event number.
988
             */
989
            void setListViewEventNumber(int num) { listEvNum = num; }
990
            /**
991
             * Returns the event number of the listView. By default this number
992
             * is 1401. But with the command ^LVE this number can be changed.
993
             *
994
             * @return The event number of the listView.
995
             */
996
            int getListViewEventNumber() { return listEvNum; };
233 andreas 997
            void setListViewColumns(int cols);
998
            int getListViewColumns() { return tc; }
999
            void setListViewLayout(int layout);
1000
            int getListViewLayout() { return listLayout; }
1001
            void setListViewComponent(int comp);
1002
            int getListViewComponent() { return listComponent; }
1003
            void setListViewCellheight(int height, bool percent=false);
1004
            int getListViewCellheight() { return tj; }
1005
            void setListViewP1(int p1);
1006
            int getListViewP1() { return listViewP1; }
1007
            void setListViewP2(int p2);
1008
            int getListViewP2() { return listViewP2; }
1009
            void setListViewColumnFilter(bool filter) { listViewColFiler = filter; }
1010
            bool getListViewColumnFilter() { return listViewColFiler; }
1011
            void setListViewFilterHeight(int height, bool percent=false);
1012
            int getListViewFilterHeight() { return listViewColFilterHeight; }
1013
            void setListViewAlphaScroll(bool alpha) { listAlphaScroll = alpha; }
1014
            bool getListViewAlphaScroll() { return listAlphaScroll; }
1015
            void setListViewFieldMap(const std::map<std::string,std::string>& map) { listFieldMap = map; }
1016
            std::map<std::string,std::string>& getListViewFieldMap() { return listFieldMap; }
1017
            void listViewNavigate(const std::string& command, bool select=false);
1018
            void listViewRefresh(int interval, bool force=false);
1019
            void listViewSortData(const std::vector<std::string>& columns, LIST_SORT order, const std::string& override);
3 andreas 1020
 
1021
        protected:
1022
            BUTTONTYPE getButtonType(const std::string& bt);
1023
            FEEDBACK getButtonFeedback(const std::string& fb);
10 andreas 1024
            SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
99 andreas 1025
            SkBitmap combineImages(SkBitmap& base, SkBitmap& alpha, SkColor col);
3 andreas 1026
 
15 andreas 1027
            void funcTimer(const amx::ANET_BLINK& blink);
1028
            void funcNetwork(int state);
94 andreas 1029
            void funcResource(const RESOURCE_T *resource, const std::string& url, BITMAP_CACHE bc, int instance);
247 andreas 1030
#ifdef __ANDROID__
38 andreas 1031
            void funcBattery(int level, bool charging, int chargeType);
247 andreas 1032
#endif
1033
#if TARGET_OS_SIMULATOR || TARGET_OS_IOS
1034
            void funcBattery(int level, int state);
1035
#endif
36 andreas 1036
            void funcNetworkState(int level);
15 andreas 1037
 
3 andreas 1038
        private:
6 andreas 1039
            std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
21 andreas 1040
            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};
199 andreas 1041
            std::function<std::vector<std::string>(ulong handle, int ap, int ta, int ti, int rows, int columns)> _getListContent{nullptr};
1042
            std::function<std::string(int ti, int row)> _getListRow{nullptr};
200 andreas 1043
            std::function<void (TButton *button)> _getGlobalSettings{nullptr};
6 andreas 1044
 
40 andreas 1045
            POSITION_t calcImagePosition(int width, int height, CENTER_CODE cc, int number, int line = 0);
99 andreas 1046
            IMAGE_SIZE_t calcImageSize(int imWidth, int imHeight, int instance, bool aspect=false);
4 andreas 1047
            int getBorderSize(const std::string& name);
1048
            void calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY);
10 andreas 1049
            SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
7 andreas 1050
            TEXT_EFFECT textEffect(const std::string& effect);
8 andreas 1051
            int numberLines(const std::string& str);
1052
            SkRect calcRect(int width, int height, int pen);
15 andreas 1053
            void runAnimation();    // Method started as thread for button animation
38 andreas 1054
            void runAnimationRange(int start, int end, ulong step);     // Method started as thread for a limited time
99 andreas 1055
            bool drawAlongOrder(SkBitmap *imgButton, int instance);
3 andreas 1056
 
8 andreas 1057
            void getDrawOrder(const std::string& sdo, DRAW_ORDER *order);
1058
            bool buttonFill(SkBitmap *bm, int instance);
1059
            bool buttonBitmap(SkBitmap *bm, int instance);
97 andreas 1060
            bool buttonDynamic(SkBitmap *bm, int instance, bool show, bool *state=nullptr);
8 andreas 1061
            bool buttonIcon(SkBitmap *bm, int instance);
1062
            bool buttonText(SkBitmap *bm, int instance);
1063
            bool buttonBorder(SkBitmap *bm, int instance);
15 andreas 1064
            bool isPixelTransparent(int x, int y);
1065
            bool barLevel(SkBitmap *bm, int instance, int level);
1066
            bool makeElement(int instance=-1);
21 andreas 1067
            bool loadImage(SkBitmap *bm, SkBitmap& image, int instance);
15 andreas 1068
            void _TimerCallback(ulong counter);
21 andreas 1069
            void _imageRefresh(const std::string& url);
1070
            static THR_REFRESH_t *_addResource(TImageRefresh *refr, ulong handle, ulong parent, int bi);
1071
            static THR_REFRESH_t *_findResource(ulong handle, ulong parent, int bi);
69 andreas 1072
            int calcLineHeight(const std::string& text, SkFont& font);
66 andreas 1073
            bool textEffect(SkCanvas *canvas, sk_sp<SkTextBlob>& blob, SkScalar startX, SkScalar startY, int instance);
69 andreas 1074
            std::string getFormatString(TEXT_ORIENTATION to);
71 andreas 1075
            bool checkForSound();
79 andreas 1076
            bool scaleImage(SkBitmap *bm, double scaleWidth, double scaleHeight);
1077
            bool stretchImageWidth(SkBitmap *bm, int width);
1078
            bool stretchImageHeight(SkBitmap *bm, int height);
157 andreas 1079
            bool stretchImageWH(SkBitmap *bm, int width, int height);
161 andreas 1080
            SkBitmap colorImage(SkBitmap& base, SkBitmap& alpha, SkColor col, SkColor bg=0, bool useBG=false);
1081
            SkBitmap retrieveBorderImage(const std::string& bs, const std::string& bsa, SkColor color, SkColor bgColor);
99 andreas 1082
            bool retrieveImage(const std::string& path, SkBitmap *image);
1083
            SkBitmap drawSliderButton(const std::string& slider, SkColor col);
8 andreas 1084
 
94 andreas 1085
            void addToBitmapCache(BITMAP_CACHE& bc);
1086
            BITMAP_CACHE& getBCentryByHandle(ulong handle, ulong parent);
1087
            BITMAP_CACHE& getBCentryByBI(int bIdx);
1088
            void removeBCentry(std::vector<BITMAP_CACHE>::iterator *elem);
1089
            void setReady(ulong handle);
97 andreas 1090
            void setInvalid(ulong handle);
94 andreas 1091
            void setBCBitmap(ulong handle, SkBitmap& bm);
1092
            void showBitmapCache();
159 andreas 1093
            uint32_t pixelMix(uint32_t s, uint32_t d, uint32_t a, PMIX mix);
94 andreas 1094
 
3 andreas 1095
            BUTTONTYPE type;
1096
            int bi{0};              // button ID
1097
            std::string na;         // name
1098
            std::string bd;         // Description --> ignored
1099
            int lt{0};              // pixel from left
1100
            int tp{0};              // pixel from top
1101
            int wt{0};              // width
1102
            int ht{0};              // height
1103
            int zo{0};              // Z-Order
1104
            std::string hs;         // bounding, ...
1105
            std::string bs;         // Border style (circle, ...)
41 andreas 1106
            FEEDBACK fb{FB_NONE};   // Feedback type (momentary, ...)
14 andreas 1107
            int ap{1};              // Address port (default: 1)
3 andreas 1108
            int ad{0};              // Address channel
1109
            int ch{0};              // Channel number
14 andreas 1110
            int cp{1};              // Channel port (default: 1)
1111
            int lp{1};              // Level port (default: 1)
3 andreas 1112
            int lv{0};              // Level code
193 andreas 1113
            int ta{0};              // Listbox table channel
199 andreas 1114
            int ti{0};              // Listbox table index number of rows (all rows have this number in "cp")
193 andreas 1115
            int tr{0};              // Listbox number of rows
1116
            int tc{0};              // Listbox number of columns
1117
            int tj{0};              // Listbox row height
1118
            int tk{0};              // Listbox preferred row height
1119
            int of{0};              // Listbox list offset: 0=disabled/1=enabled
1120
            int tg{0};              // Listbox managed: 0=no/1=yes
147 andreas 1121
            int co{0};              // Command port
149 andreas 1122
            std::vector<std::string> cm;         // Commands to send on each button hit
3 andreas 1123
            std::string dr;         // Level "horizontal" or "vertical"
1124
            int va{0};
163 andreas 1125
            int stateCount{0};      // State count with multistate buttons (number of states)
3 andreas 1126
            int rm{0};              // State count with multistate buttons?
15 andreas 1127
            int nu{2};              // Animate time up
1128
            int nd{2};              // Animate time down
3 andreas 1129
            int ar{0};              // Auto repeat (1 = true)
1130
            int ru{0};              // Animate time up (bargraph)
1131
            int rd{0};              // Animate time down (bargraph)
1132
            int lu{0};              // Animate time up (Bargraph)
1133
            int ld{0};              // Animate time down (Bargraph)
1134
            int rv{0};
1135
            int rl{0};              // Range low
1136
            int rh{0};              // Range high
1137
            int ri{0};              // Bargraph inverted (0 = normal, 1 = inverted)
1138
            int rn{0};              // Bargraph: Range drag increment
193 andreas 1139
            int ac_di{0};           // (guess) Direction of text: 0 = left to right (default); 1 = right to left
51 andreas 1140
            int hd{0};              // 1 = Hidden, 0 = Normal visible
1141
            int da{0};              // 1 = Disabled, 0 = Normal active
49 andreas 1142
            std::string lf;         // Bargraph function: empty = display only, active, active centering, drag, drag centering
3 andreas 1143
            std::string sd;         // Name/Type of slider for a bargraph
1144
            std::string sc;         // Color of slider (for bargraph)
1145
            int mt{0};              // Length of text area (0 = 2000)
1146
            std::string dt;         // "multiple" textarea has multiple lines, else single line
1147
            std::string im;         // Input mask of a text area
51 andreas 1148
            std::string pc;         // Password character for text area
3 andreas 1149
            std::string op;         // String the button send
14 andreas 1150
            bool visible{true};     // TRUE=Button is visible
3 andreas 1151
            std::vector<PUSH_FUNC_T> pushFunc;  // Push functions: This are executed on button press
1152
            std::vector<SR_T> sr;   // The elements the button consists of
225 andreas 1153
            // ListView settings (G5)
1154
            std::string listSource; // Defines the data source for a list.
230 andreas 1155
            int listEvNum{1401};       // ListView event number.
225 andreas 1156
            std::string listFilter; // ListView filter string.
233 andreas 1157
            int listComponent{0};   // ListView component
225 andreas 1158
            int listLayout{0};      // ListView layout.
1159
            std::map<std::string,std::string> listFieldMap; // Maps the fields from the source to the columns of the list
1160
            LIST_SORT listSort{LIST_SORT_NONE}; // ListView sort algorithm
1161
            std::string listSortOverride;   // A SQL ORDER BY command like sort option. Only valid if listStort == LIST_SORT_OVERRIDE
227 andreas 1162
            std::string listSourceUser;   // The user name (optional)
1163
            std::string listSourcePass;   // The password (optional)
1164
            bool listSourceCsv{false};  // TRUE = Source of listView is in CSV data
1165
            bool listSourceHasHeader{false};    // TRUE = The listView data has a had line which must be ignored.
233 andreas 1166
            int listViewP1{0};      // ListView layout percentage 1
1167
            int listViewP2{0};      // ListView layout percentage 2
1168
            bool listViewColFiler{false};   // ListView column filter state (TRUE = on)
1169
            int listViewColFilterHeight{0}; // ListView column filter height
1170
            bool listAlphaScroll{false};    // ListView alpha scroll state (TRUE = scrollbar visible)
41 andreas 1171
 
7 andreas 1172
            TPalette *mPalette{nullptr}; // The color palette
3 andreas 1173
            // Image management
6 andreas 1174
            SkBitmap mLastImage;    // The last calculated image
5 andreas 1175
            ulong mHandle{0};       // internal used handle to identify button
7 andreas 1176
            int mParentHeight{0};   // The height of the parent page / subpage
1177
            int mParentWidth{0};    // The width of the parent page / subpage
16 andreas 1178
            bool mEnabled{true};    // By default a button is enabled (TRUE); FALSE = Button disabled
7 andreas 1179
            TFont *mFonts{nullptr}; // The font table
10 andreas 1180
            int mGlobalOO{-1};      // Opacity of the whole subpage, if any
14 andreas 1181
            int mActInstance{0};    // Active instance
8 andreas 1182
            DRAW_ORDER mDOrder[ORD_ELEM_COUNT];  // The order to draw the elements of a button
15 andreas 1183
            std::thread mThrAni;    // Thread handle for animation
21 andreas 1184
            std::thread mThrRes;    // A resouce (download of a remote image/video) running in background
38 andreas 1185
            std::atomic<bool> mAniRunning{false}; // TRUE = Animation is running
93 andreas 1186
            std::atomic<bool> mAniStop{false};  // If TRUE, the running animation will stop
15 andreas 1187
            int mLastLevel{0};      // The last level value for a bargraph
1188
            bool mSystemReg{false}; // TRUE = registered as system button
1189
            amx::ANET_BLINK mLastBlink; // This is used for the system clock buttons
21 andreas 1190
            TTimer *mTimer{nullptr};    // This is for buttons displaying the time or a date. It's a thread running in background.
1191
            static THR_REFRESH_t *mThrRefresh;  // If  we have a source to reread periodicaly, this starts a thread to do that.
38 andreas 1192
            ulong mAniRunTime{0};   // The time in milliseconds an animation should run. 0 = run forever.
94 andreas 1193
            BITMAP_CACHE mBCDummy;  // A dummy retuned in case no cache exists or the element was not found.
175 andreas 1194
            bool mChanged{true};    // TRUE=Something changed --> button must be redrawn
192 andreas 1195
            int mBorderWidth{0};    // If there is a border this is set to the pixels the border is using
200 andreas 1196
            std::vector<std::string> mListContent;  // The content of a list, if this button is one
3 andreas 1197
    };
1198
 
1199
    typedef struct BUTTONS_T
1200
    {
1201
        TButton *button{nullptr};
1202
        BUTTONS_T *previous{nullptr};
1203
        BUTTONS_T *next{nullptr};
1204
    } BUTTONS_T;
2 andreas 1205
}
1206
 
1207
#endif