Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 andreas 1
/*
15 andreas 2
 * Copyright (C) 2020, 2021 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
 
2 andreas 31
#include "treadxml.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"
2 andreas 38
 
8 andreas 39
#define ORD_ELEM_COUNT  5
40
 
21 andreas 41
extern bool prg_stopped;
42
 
8 andreas 43
class SkFont;
21 andreas 44
struct RESOURCE_T;
8 andreas 45
 
2 andreas 46
namespace Button
47
{
15 andreas 48
    typedef enum BUTTONTYPE
49
    {
50
        NONE,
51
        GENERAL,
52
        MULTISTATE_GENERAL,
53
        BARGRAPH,
54
        MULTISTATE_BARGRAPH,
55
        JOISTICK,
56
        TEXT_INPUT,
57
        COMPUTER_CONTROL,
58
        TAKE_NOTE,
59
        SUBPAGE_VIEW
60
    } BUTTONTYPE;
61
 
4 andreas 62
    typedef struct SYSBORDER_t
63
    {
8 andreas 64
        int id{0};
4 andreas 65
        char *name{nullptr};
66
        int number{0};
67
        char *style{nullptr};
68
        int width{0};
69
        int radius{0};
70
    }SYSBORDER_t;
71
 
15 andreas 72
    typedef struct SYSBUTTONS_t
73
    {
74
        int channel{0};             // Channel number
75
        BUTTONTYPE type{NONE};      // Type of button
76
        int states{0};              // Maximum number of states
77
        int ll{0};                  // Level low range
78
        int lh{0};                  // Level high range
79
    }SYSBUTTONS_t;
80
 
3 andreas 81
    typedef enum TEXT_ORIENTATION
82
    {
83
        ORI_ABSOLUT,
84
        ORI_TOP_LEFT,
85
        ORI_TOP_MIDDLE,
86
        ORI_TOP_RIGHT,
87
        ORI_CENTER_LEFT,
88
        ORI_CENTER_MIDDLE,		// default
89
        ORI_CENTER_RIGHT,
90
        ORI_BOTTOM_LEFT,
91
        ORI_BOTTOM_MIDDLE,
92
        ORI_BOTTOM_RIGHT
93
    } TEXT_ORIENTATION;
2 andreas 94
 
7 andreas 95
    typedef enum TEXT_EFFECT
96
    {
97
        EFFECT_NONE,
98
        EFFECT_OUTLINE_S,
99
        EFFECT_OUTLINE_M,
100
        EFFECT_OUTLINE_L,
101
        EFFECT_OUTLINE_X,
102
        EFFECT_GLOW_S,
103
        EFFECT_GLOW_M,
104
        EFFECT_GLOW_L,
105
        EFFECT_GLOW_X,
106
        EFFECT_SOFT_DROP_SHADOW_1,
107
        EFFECT_SOFT_DROP_SHADOW_2,
108
        EFFECT_SOFT_DROP_SHADOW_3,
109
        EFFECT_SOFT_DROP_SHADOW_4,
110
        EFFECT_SOFT_DROP_SHADOW_5,
111
        EFFECT_SOFT_DROP_SHADOW_6,
112
        EFFECT_SOFT_DROP_SHADOW_7,
113
        EFFECT_SOFT_DROP_SHADOW_8,
114
        EFFECT_MEDIUM_DROP_SHADOW_1,
115
        EFFECT_MEDIUM_DROP_SHADOW_2,
116
        EFFECT_MEDIUM_DROP_SHADOW_3,
117
        EFFECT_MEDIUM_DROP_SHADOW_4,
118
        EFFECT_MEDIUM_DROP_SHADOW_5,
119
        EFFECT_MEDIUM_DROP_SHADOW_6,
120
        EFFECT_MEDIUM_DROP_SHADOW_7,
121
        EFFECT_MEDIUM_DROP_SHADOW_8,
122
        EFFECT_HARD_DROP_SHADOW_1,
123
        EFFECT_HARD_DROP_SHADOW_2,
124
        EFFECT_HARD_DROP_SHADOW_3,
125
        EFFECT_HARD_DROP_SHADOW_4,
126
        EFFECT_HARD_DROP_SHADOW_5,
127
        EFFECT_HARD_DROP_SHADOW_6,
128
        EFFECT_HARD_DROP_SHADOW_7,
129
        EFFECT_HARD_DROP_SHADOW_8,
130
        EFFECT_SOFT_DROP_SHADOW_1_WITH_OUTLINE,
131
        EFFECT_SOFT_DROP_SHADOW_2_WITH_OUTLINE,
132
        EFFECT_SOFT_DROP_SHADOW_3_WITH_OUTLINE,
133
        EFFECT_SOFT_DROP_SHADOW_4_WITH_OUTLINE,
134
        EFFECT_SOFT_DROP_SHADOW_5_WITH_OUTLINE,
135
        EFFECT_SOFT_DROP_SHADOW_6_WITH_OUTLINE,
136
        EFFECT_SOFT_DROP_SHADOW_7_WITH_OUTLINE,
137
        EFFECT_SOFT_DROP_SHADOW_8_WITH_OUTLINE,
138
        EFFECT_MEDIUM_DROP_SHADOW_1_WITH_OUTLINE,
139
        EFFECT_MEDIUM_DROP_SHADOW_2_WITH_OUTLINE,
140
        EFFECT_MEDIUM_DROP_SHADOW_3_WITH_OUTLINE,
141
        EFFECT_MEDIUM_DROP_SHADOW_4_WITH_OUTLINE,
142
        EFFECT_MEDIUM_DROP_SHADOW_5_WITH_OUTLINE,
143
        EFFECT_MEDIUM_DROP_SHADOW_6_WITH_OUTLINE,
144
        EFFECT_MEDIUM_DROP_SHADOW_7_WITH_OUTLINE,
145
        EFFECT_MEDIUM_DROP_SHADOW_8_WITH_OUTLINE,
146
        EFFECT_HARD_DROP_SHADOW_1_WITH_OUTLINE,
147
        EFFECT_HARD_DROP_SHADOW_2_WITH_OUTLINE,
148
        EFFECT_HARD_DROP_SHADOW_3_WITH_OUTLINE,
149
        EFFECT_HARD_DROP_SHADOW_4_WITH_OUTLINE,
150
        EFFECT_HARD_DROP_SHADOW_5_WITH_OUTLINE,
151
        EFFECT_HARD_DROP_SHADOW_6_WITH_OUTLINE,
152
        EFFECT_HARD_DROP_SHADOW_7_WITH_OUTLINE,
153
        EFFECT_HARD_DROP_SHADOW_8_WITH_OUTLINE
154
    }TEXT_EFFECT;
155
 
8 andreas 156
    typedef enum DRAW_ORDER
157
    {
158
        ORD_ELEM_NONE,
159
        ORD_ELEM_FILL,
160
        ORD_ELEM_BITMAP,
161
        ORD_ELEM_ICON,
162
        ORD_ELEM_TEXT,
163
        ORD_ELEM_BORDER
164
    }DRAW_ORDER;
165
 
3 andreas 166
    typedef struct SR_T
167
    {
168
        int number{0};
6 andreas 169
        std::string _do;        // Order on how to show a multistate bargraph (010203...)
170
        std::string bs;         // Frame type (circle, ...)
171
        std::string mi;         // Chameleon image
172
        int mi_width{0};        // Width of image
173
        int mi_height{0};       // Height of image
174
        std::string cb;         // Border color
175
        std::string cf;         // Fill color
176
        std::string ct;         // Text Color
177
        std::string ec;         // Text effect color
178
        std::string bm;         // bitmap file name
179
        std::string sd;         // Sound file to play
180
        int bm_width{0};        // Width of image
181
        int bm_height{0};       // Height of image
182
        bool dynamic{false};    // TRUE = moving image
183
        int sb{0};              // Index to external graphics download
184
        int ii{0};              // Icon index number
10 andreas 185
        int ix{0};              // Icon X position
186
        int iy{0};              // Icon Y position
7 andreas 187
        int ji{5};              // Icon style / position like "jt", default 5 = center+middle
188
        int jb{5};              // Image position (center, left, ...), default 5 = center+middle
10 andreas 189
        int bx{0};              // Absolute image position x
190
        int by{0};              // Absolute image position y
191
        int fi{0};              // Font index
6 andreas 192
        std::string te;         // Text
193
        TEXT_ORIENTATION jt{ORI_CENTER_MIDDLE}; // Text orientation
194
        int tx{0};              // Text X position
195
        int ty{0};              // Text Y position
196
        int ww{0};              // line break when 1
197
        int et{0};              // Text effect (^TEF)
8 andreas 198
        int oo{-1};             // Over all opacity
3 andreas 199
    } SR_T;
2 andreas 200
 
3 andreas 201
    typedef enum FEEDBACK
202
    {
203
        FB_NONE,
204
        FB_CHANNEL,
6 andreas 205
        FB_INV_CHANNEL,     // inverted channel
3 andreas 206
        FB_ALWAYS_ON,
207
        FB_MOMENTARY,
208
        FB_BLINK
209
    } FEEDBACK;
2 andreas 210
 
3 andreas 211
    typedef struct PUSH_FUNC
212
    {
6 andreas 213
        std::string pfType; // command to execute when button was pushed
214
        std::string pfName; // Name of popup
3 andreas 215
    } PUSH_FUNC_T;
2 andreas 216
 
4 andreas 217
    typedef enum CENTER_CODE
218
    {
219
        SC_ICON = 0,
220
        SC_BITMAP,
221
        SC_TEXT
222
    }CENTER_CODE;
223
 
224
    typedef struct POSITION_t
225
    {
226
        int width{0};
227
        int height{0};
10 andreas 228
        int left{1};
229
        int top{1};
17 andreas 230
        bool overflow{false};
4 andreas 231
        bool valid{false};
232
    }POSITION_t;
233
 
21 andreas 234
    typedef struct THR_REFRESH_t
235
    {
236
        ulong handle{0};
237
        ulong parent{0};
238
        int bi{0};
239
        TImageRefresh *mImageRefresh{nullptr};
240
        THR_REFRESH_t *next{nullptr};
241
    }THR_REFRESH_t;
242
 
3 andreas 243
    class TButton
244
    {
245
        public:
246
            TButton();
247
            ~TButton();
2 andreas 248
 
14 andreas 249
            /**
250
             * The following function parses the parameters of a particular
251
             * button and creates a new button. This function is called either
252
             * from class TPage or TSubPage when a page or subpage is created.
253
             *
254
             * xml     A pointer to the XML reader
255
             * node    A pointer to the actual node in the XML tree.
256
             */
3 andreas 257
            void initialize(TReadXML *xml, mxml_node_t *node);
2 andreas 258
 
14 andreas 259
            /**
260
             * Returns the button index. This is a unique number inside a page
261
             * or subpage.
262
             */
3 andreas 263
            int getButtonIndex() { return bi; }
14 andreas 264
            /**
265
             * Returns the name of the button.
266
             */
3 andreas 267
            std::string& getButtonName() { return na; }
14 andreas 268
            /**
269
             * Returns the description of the button, if there is one.
270
             */
3 andreas 271
            std::string& getButtonDescription() { return bd; }
14 andreas 272
            /**
273
             * Returns the width of the button in pixels.
274
             */
3 andreas 275
            int getWidth() { return wt; }
14 andreas 276
            /**
277
             * Returns the height of the button in pixels.
278
             */
3 andreas 279
            int getHeight() { return ht; }
14 andreas 280
            /**
281
             * Returns the left position in pixels.
282
             */
3 andreas 283
            int getLeftPosition() { return lt; }
14 andreas 284
            /**
285
             * Returns the top position of the button in pixels.
286
             */
3 andreas 287
            int getTopPosition() { return tp; }
14 andreas 288
            /**
289
             * Returns the Z-order. This number marks the order the buttons
290
             * are drawed on the screen. Inside a page or subpage the buttons
291
             * are always sorted.
292
             */
3 andreas 293
            int getZOrder() { return zo; }
14 andreas 294
            /**
295
             * Returns the type of the button.
296
             */
297
            BUTTONTYPE getButtonType() { return type; }
15 andreas 298
 
299
            int getRangeLow() { return rl; }
300
            int getRangeHigh() { return rh; }
301
            int getStateCount() { return stateCount; }
14 andreas 302
            int getAddressPort() { return ap; }
303
            int getAddressChannel() { return ad; }
304
            int getChannelNumber() { return ch; }
305
            int getChannelPort() { return cp; }
306
            int getLevelPort() { return lp; }
307
            int getLevelValue() { return lv; }
308
            int getNumberInstances() { return (int)sr.size(); }
15 andreas 309
            int getActiveInstance() { return mActInstance; }
16 andreas 310
            ulong getHandle() { return mHandle; }
311
            void setEnable(bool en) { mEnabled = en; }
312
            bool isEnabled() { return mEnabled; }
15 andreas 313
            void setHandle(ulong handle);
4 andreas 314
            void setPalette(TPalette *pal) { mPalette = pal; }
6 andreas 315
            void setParentWidth(int width) { mParentWidth = width; }
316
            void setParentHeight(int height) { mParentHeight = height; }
317
            void setParentSize(int width, int height) { mParentWidth = width; mParentHeight = height; }
7 andreas 318
            void setFonts(TFont *ft) { mFonts = ft; }
10 andreas 319
            void setGlobalOpacity(int oo) { if (oo >= 0 && oo <= 255) mGlobalOO = oo; }
14 andreas 320
            void setVisible(bool v) { visible = v; }
16 andreas 321
            bool setBitmap(const std::string& file, int instance);
322
            bool setOpacity(int op, int instance);
323
            bool setWorWrap(bool state, int instance);
324
            bool setFont(int id, int instance);
325
            void setTop(int top);
326
            void setLeft(int left);
327
            void setLeftTop(int left, int top);
21 andreas 328
            void setResourceName(const std::string& name, int instance);
15 andreas 329
            void addPushFunction(std::string& func, std::string& page);
330
            void registerSystemButton();
331
            bool isSystemButton();
16 andreas 332
            void clearPushFunctions() { pushFunc.clear(); }
333
            void clearPushFunction(const std::string& action);
334
            void refresh();
3 andreas 335
            /**
14 andreas 336
             * Sets a particular instance of the button active. This implies
337
             * a redraw of the button in case the instance is different from
338
             * the one already visible.
339
             *
340
             * @param instance
341
             * The instance of the button to be activated.
342
             *
343
             * @return
344
             * On error returns FALSE.
345
             */
346
            bool setActive(int instance);
347
            /**
348
             * Sets an Icon on the button. This implies a redraw of the button
349
             * in case the instance is different from the one already visible.
350
             *
351
             * @param id
352
             * The id number of the icon.
353
             *
354
             * @param instance
355
             * The instance where the icon should be drawed
356
             *
357
             * @return On error returns FALSE.
358
             */
359
            bool setIcon(int id, int instance);
360
            /**
361
             * Sets an Icon on the button. This implies a redraw of the button
362
             * in case the instance is different from the one already visible.
363
             *
364
             * @param icon
365
             * The file name of the icon.
366
             *
367
             * @param instance
368
             * The instance where the icon should be drawed
369
             *
370
             * @return
371
             * On error returns FALSE.
372
             */
373
            bool setIcon(const std::string& icon, int instance);
374
            /**
375
             * Removes an icon from a button. This implies a redraw of the
376
             * button.
377
             *
378
             * @param instance
379
             * The instance number involved.
380
             *
381
             * @return
382
             * On error returns FALSE.
383
             */
384
            bool revokeIcon(int instance);
385
            /**
386
             * Set a string to a button.
387
             *
388
             * @param txt
389
             * The text to write on top of  a button.
390
             *
391
             * @param instance
392
             * The instance number involved.
393
             *
394
             * @return
395
             * On error returns FALSE.
396
             */
397
            bool setText(const std::string& txt, int instance);
398
            /**
3 andreas 399
             * Read the images, if any, from files and create an image. If there
400
             * are no files, draw the image as defined.
14 andreas 401
             *
402
             * @return
403
             * On error returns FALSE.
3 andreas 404
             */
4 andreas 405
            bool createButtons();
406
            /**
407
             * Register a callback function to display a ready image.
408
             */
6 andreas 409
            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 410
            {
411
                _displayButton = displayButton;
412
            }
7 andreas 413
            void registerCallbackFT(std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, TEXT_ORIENTATION ori, TEXT_EFFECT effect, bool ww)> setText)
414
            { _setText = setText; }
21 andreas 415
            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; };
7 andreas 416
 
4 andreas 417
            /**
418
             * Make a pixel array and call the callback function to display the
419
             * image. If there is no callback function registered, nothing
420
             * happens.
15 andreas 421
             * This method draws a general button. It is used for most
422
             * specialized buttons too.
14 andreas 423
             *
15 andreas 424
             * @param instance
425
             * Optional. The instance of the button to draw. If the base
426
             * instance should be drawn, the parameter can be omitted.
427
             *
428
             * @param show
429
             * Optional. By defualt TRUE. If set to FALSE, the button image is
430
             * not send to GUI. The image is available in the variable
431
             * "mLastImage" immediately after ending the method.
432
             *
14 andreas 433
             * @return
434
             * On error returns FALSE.
4 andreas 435
             */
15 andreas 436
            bool drawButton(int instance = 0, bool show=true);
6 andreas 437
            /**
15 andreas 438
             * Method to draw a multistate animated button. It creates a thread
439
             * with a timer and starts an animation by drawing every instance in
440
             * the defined order.
441
             *
442
             * @return
443
             * On error returns FALSE.
444
             */
445
            bool drawButtonMultistateAni();
446
            /**
447
             * Draws a normal bargraph with an ON and OFF state. Takes care
448
             * about cameleon images. If registered, it calls a callback
449
             * function to the GUI to display the ready image.
450
             *
451
             * @param instance
452
             * The instance of the bargraph to draw. This value must be in the
453
             * range of 0 to "stateCount".
454
             *
455
             * @param level
456
             * This is the level to show on the bargraph. It must be a value
457
             * the range of "rl" (range low) and "rh" (range high). A lower
458
             * value than "rl" is interpreted as "rl" and a value higher than
459
             * "rh" is interpreted as "rh".
460
             *
461
             * @param show
462
             * Optional. By default TRUE. If set to FALSE, the bargraph image is
463
             * not send to GUI. The image is available in the variable
464
             * "mLastImage" immediately after ending the method.
465
             *
466
             * @return
467
             * On error returns FALSE.
468
             */
469
            bool drawBargraph(int instance, int level, bool show=true);
470
            /**
6 andreas 471
             * Show the button with it's current state.
472
             */
473
            void show();
11 andreas 474
            /**
15 andreas 475
             * Hide the button. In case of an animated button, the animation is
476
             * stopped.
477
             *
478
             * @param total
479
             * Optional. When set to TRUE, a transparent button is displayed.
480
             */
481
            void hide(bool total=false);
482
            /**
483
             * This method sends the image together with all data to the GUI,
484
             * where it will be shown. The variable mLastImage must not be
485
             * empty for the method to succeed.
486
             */
487
            void showLastButton();
488
            /**
11 andreas 489
             * Handle a mouse click.
15 andreas 490
             *
491
             * @param pressed
492
             * TRUE = Button was pressed, FALSE = Button was released.
493
             *
494
             * @return
495
             * TRUE = Button was clickable and processed. FALSE = Button was not
496
             * clickable.
11 andreas 497
             */
15 andreas 498
            bool doClick(int x, int y, bool pressed);
3 andreas 499
 
500
        protected:
501
            BUTTONTYPE getButtonType(const std::string& bt);
502
            FEEDBACK getButtonFeedback(const std::string& fb);
10 andreas 503
            SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
3 andreas 504
 
15 andreas 505
            void funcTimer(const amx::ANET_BLINK& blink);
506
            void funcNetwork(int state);
21 andreas 507
            void funcResource(const RESOURCE_T *resource, const std::string& url, SkBitmap* bm, int instance);
15 andreas 508
 
3 andreas 509
        private:
510
            typedef struct IMAGE_t
511
            {
512
                int number{0};
6 andreas 513
                SkBitmap imageMi;
514
                SkBitmap imageBm;
3 andreas 515
 
516
                void clear()
517
                {
518
                    number = 0;
6 andreas 519
                    imageMi.reset();
3 andreas 520
                    imageBm.reset();
521
                }
522
            }IMAGE_t;
523
 
6 andreas 524
            std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
7 andreas 525
            std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, TEXT_ORIENTATION ori, TEXT_EFFECT effect, bool ww)> _setText{nullptr};
21 andreas 526
            std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> _playVideo{nullptr};
6 andreas 527
 
4 andreas 528
            POSITION_t calcImagePosition(int width, int height, CENTER_CODE cc, int number);
529
            int getBorderSize(const std::string& name);
530
            void calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY);
10 andreas 531
            SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
7 andreas 532
            TEXT_EFFECT textEffect(const std::string& effect);
8 andreas 533
            int numberLines(const std::string& str);
534
            std::vector<std::string> splitLine(const std::string& str);
535
            std::vector<std::string> splitLine(const std::string& str, int width, int height, SkFont& font, SkPaint& paint);
536
            SkRect calcRect(int width, int height, int pen);
15 andreas 537
            void runAnimation();    // Method started as thread for button animation
3 andreas 538
 
8 andreas 539
            void getDrawOrder(const std::string& sdo, DRAW_ORDER *order);
540
            bool buttonFill(SkBitmap *bm, int instance);
541
            bool buttonBitmap(SkBitmap *bm, int instance);
21 andreas 542
            bool buttonDynamic(SkBitmap *bm, int instance);
8 andreas 543
            bool buttonIcon(SkBitmap *bm, int instance);
544
            bool buttonText(SkBitmap *bm, int instance);
545
            bool buttonBorder(SkBitmap *bm, int instance);
15 andreas 546
            bool isClickable();
547
            bool isPixelTransparent(int x, int y);
548
            bool barLevel(SkBitmap *bm, int instance, int level);
549
            bool makeElement(int instance=-1);
21 andreas 550
            bool loadImage(SkBitmap *bm, SkBitmap& image, int instance);
15 andreas 551
            void _TimerCallback(ulong counter);
21 andreas 552
            void _imageRefresh(const std::string& url);
553
            static THR_REFRESH_t *_addResource(TImageRefresh *refr, ulong handle, ulong parent, int bi);
554
            static THR_REFRESH_t *_findResource(ulong handle, ulong parent, int bi);
8 andreas 555
 
3 andreas 556
            BUTTONTYPE type;
557
            int bi{0};              // button ID
558
            std::string na;         // name
559
            std::string bd;         // Description --> ignored
560
            int lt{0};              // pixel from left
561
            int tp{0};              // pixel from top
562
            int wt{0};              // width
563
            int ht{0};              // height
564
            int zo{0};              // Z-Order
565
            std::string hs;         // bounding, ...
566
            std::string bs;         // Border style (circle, ...)
567
            FEEDBACK fb{FB_NONE};   // momentary, ...
14 andreas 568
            int ap{1};              // Address port (default: 1)
3 andreas 569
            int ad{0};              // Address channel
570
            int ch{0};              // Channel number
14 andreas 571
            int cp{1};              // Channel port (default: 1)
572
            int lp{1};              // Level port (default: 1)
3 andreas 573
            int lv{0};              // Level code
574
            std::string dr;         // Level "horizontal" or "vertical"
575
            int va{0};
576
            int stateCount{0};      // State count with multistate buttons
577
            int rm{0};              // State count with multistate buttons?
15 andreas 578
            int nu{2};              // Animate time up
579
            int nd{2};              // Animate time down
3 andreas 580
            int ar{0};              // Auto repeat (1 = true)
581
            int ru{0};              // Animate time up (bargraph)
582
            int rd{0};              // Animate time down (bargraph)
583
            int lu{0};              // Animate time up (Bargraph)
584
            int ld{0};              // Animate time down (Bargraph)
585
            int rv{0};
586
            int rl{0};              // Range low
587
            int rh{0};              // Range high
588
            int ri{0};              // Bargraph inverted (0 = normal, 1 = inverted)
589
            int rn{0};              // Bargraph: Range drag increment
590
            std::string _if;        // Bargraph function: empty = display only, active, active centering, drag, drag centering
591
            std::string sd;         // Name/Type of slider for a bargraph
592
            std::string sc;         // Color of slider (for bargraph)
593
            int mt{0};              // Length of text area (0 = 2000)
594
            std::string dt;         // "multiple" textarea has multiple lines, else single line
595
            std::string im;         // Input mask of a text area
596
            std::string op;         // String the button send
14 andreas 597
            bool visible{true};     // TRUE=Button is visible
3 andreas 598
            std::vector<PUSH_FUNC_T> pushFunc;  // Push functions: This are executed on button press
599
            std::vector<SR_T> sr;   // The elements the button consists of
7 andreas 600
            TPalette *mPalette{nullptr}; // The color palette
3 andreas 601
            // Image management
602
            std::map<int, IMAGE_t> mImages; // Contains the images in ready to use format, if there any
6 andreas 603
            SkBitmap mLastImage;    // The last calculated image
5 andreas 604
            ulong mHandle{0};       // internal used handle to identify button
7 andreas 605
            int mParentHeight{0};   // The height of the parent page / subpage
606
            int mParentWidth{0};    // The width of the parent page / subpage
16 andreas 607
            bool mEnabled{true};    // By default a button is enabled (TRUE); FALSE = Button disabled
7 andreas 608
            TFont *mFonts{nullptr}; // The font table
10 andreas 609
            int mGlobalOO{-1};      // Opacity of the whole subpage, if any
14 andreas 610
            int mActInstance{0};    // Active instance
8 andreas 611
            DRAW_ORDER mDOrder[ORD_ELEM_COUNT];  // The order to draw the elements of a button
15 andreas 612
            std::thread mThrAni;    // Thread handle for animation
21 andreas 613
            std::thread mThrRes;    // A resouce (download of a remote image/video) running in background
15 andreas 614
            static std::atomic<bool> mAniRunning; // TRUE = Animation is running
615
            int mLastLevel{0};      // The last level value for a bargraph
616
            bool mSystemReg{false}; // TRUE = registered as system button
617
            amx::ANET_BLINK mLastBlink; // This is used for the system clock buttons
21 andreas 618
            TTimer *mTimer{nullptr};    // This is for buttons displaying the time or a date. It's a thread running in background.
619
            static THR_REFRESH_t *mThrRefresh;  // If  we have a source to reread periodicaly, this starts a thread to do that.
620
            bool mResourceRead{false};  // TRUE if the resource should be read only once on startup and this is done.
3 andreas 621
    };
622
 
623
    typedef struct BUTTONS_T
624
    {
625
        TButton *button{nullptr};
626
        BUTTONS_T *previous{nullptr};
627
        BUTTONS_T *next{nullptr};
628
    } BUTTONS_T;
2 andreas 629
}
630
 
631
#endif