Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 andreas 1
/*
89 andreas 2
 * Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
3 andreas 3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TPAGEMANAGER_H__
20
#define __TPAGEMANAGER_H__
21
 
5 andreas 22
#include <functional>
11 andreas 23
#include <thread>
36 andreas 24
#ifdef __ANDROID__
25
#include <jni.h>
26
#endif
3 andreas 27
#include "tpagelist.h"
28
#include "tpage.h"
29
#include "tsubpage.h"
30
#include "tsettings.h"
4 andreas 31
#include "tpalette.h"
7 andreas 32
#include "tbutton.h"
33
#include "tfont.h"
32 andreas 34
#include "texternal.h"
11 andreas 35
#include "tamxnet.h"
36
#include "tamxcommands.h"
73 andreas 37
#include "tsystemdraw.h"
3 andreas 38
 
14 andreas 39
#define REG_CMD(func, name)     registerCommand(bind(&TPageManager::func, this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3),name)
3 andreas 40
 
8 andreas 41
class TIcons;
14 andreas 42
class TPageManager;
21 andreas 43
 
44
extern bool prg_stopped;
8 andreas 45
extern TIcons *gIcons;
46
extern TPrjResources *gPrjResources;
14 andreas 47
extern TPageManager *gPageManager;
8 andreas 48
 
93 andreas 49
#ifdef __ANDROID__
50
#define NETSTATE_WIFI   1
51
#define NETSTATE_CELL   2
52
#endif
53
 
11 andreas 54
class TPageManager : public TAmxCommands
3 andreas 55
{
56
    public:
57
        TPageManager();
58
        ~TPageManager();
59
 
62 andreas 60
        bool readPages();                           //!< Read all pages and subpages
61
        bool readPage(const std::string& name);     //!< Read the page with name \p name
62
        bool readPage(int ID);                      //!< Read the page with id \p ID
63
        bool readSubPage(const std::string& name);  //!< Read the subpage with name \p name
64
        bool readSubPage(int ID);                   //!< Read the subpage with ID \p ID
3 andreas 65
 
62 andreas 66
        TPageList *getPageList() { return mPageList; }      //!< Get the list of all pages
67
        TSettings *getSettings() { return mTSettings; }     //!< Get the (system) settings of the panel
3 andreas 68
 
62 andreas 69
        TPage *getActualPage();                             //!< Get the actual page
70
        int getActualPageNumber() { return mActualPage; }   //!< Get the ID of the actual page
71
        int getPreviousPageNumber() { return mPreviousPage; }   //!< Get the ID of the previous page, if there was any.
4 andreas 72
        TSubPage *getFirstSubPage();
73
        TSubPage *getNextSubPage();
11 andreas 74
        TSubPage *getFirstSubPageGroup(const std::string& group);
75
        TSubPage *getNextSubPageGroup();
76
        TSubPage *getNextSubPageGroup(const std::string& group, TSubPage *pg);
77
        TSubPage *getTopPage();
4 andreas 78
 
79
        TPage *getPage(int pageID);
80
        TPage *getPage(const std::string& name);
15 andreas 81
        bool setPage(int PageID);
82
        bool setPage(const std::string& name);
4 andreas 83
        TSubPage *getSubPage(int pageID);
84
        TSubPage *getSubPage(const std::string& name);
96 andreas 85
        TSubPage *deliverSubPage(const std::string& name, TPage **pg=nullptr);
14 andreas 86
        bool havePage(const std::string& name);
87
        bool haveSubPage(const std::string& name);
88
        bool haveSubPage(int id);
89
        bool haveSubPage(const std::string& page, const std::string& name);
90
        bool haveSubPage(const std::string& page, int id);
50 andreas 91
        TFont *getFonts() { return mFonts; }
51 andreas 92
        Button::TButton *findButton(ulong handle);
4 andreas 93
 
6 andreas 94
        void registerCallbackDB(std::function<void(ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> displayButton) { _displayButton = displayButton; }
98 andreas 95
        void registerCBsetVisible(std::function<void(ulong handle, bool state)> setVisible) { _setVisible = setVisible; }
5 andreas 96
        void registerCallbackSP(std::function<void (ulong handle, int width, int height)> setPage) { _setPage = setPage; }
41 andreas 97
        void registerCallbackSSP(std::function<void (ulong handle, int left, int top, int width, int height, ANIMATION_t animate)> setSubPage) { _setSubPage = setSubPage; }
38 andreas 98
        void registerCallbackSB(std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> setBackground) {_setBackground = setBackground; }
26 andreas 99
        void deployCallbacks();
36 andreas 100
#ifdef __ANDROID__
101
        void initNetworkState();
102
        void stopNetworkState();
38 andreas 103
        void initBatteryState();
104
        void stopBatteryState();
61 andreas 105
        void initPhoneState();
36 andreas 106
        void informTPanelNetwork(jboolean conn, jint level, jint type);
38 andreas 107
        void informBatteryStatus(jint level, jboolean charging, jint chargeType);
61 andreas 108
        void informPhoneState(bool call, const std::string& pnumber);
36 andreas 109
#endif
11 andreas 110
        void regCallDropPage(std::function<void (ulong handle)> callDropPage) { _callDropPage = callDropPage; }
111
        void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
21 andreas 112
        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)> callPlayVideo) { _callPlayVideo = callPlayVideo; };
52 andreas 113
        void regCallInputText(std::function<void (Button::TButton *button, Button::BITMAP_t& bm)> callInputText) { _callInputText = callInputText; }
63 andreas 114
        void regCallbackKeyboard(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeyboard) { _callKeyboard = callKeyboard; }
115
        void regCallbackKeypad(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeypad) { _callKeypad = callKeypad; }
116
        void regCallResetKeyboard(std::function<void ()> callResetKeyboard) { _callResetKeyboard = callResetKeyboard; }
64 andreas 117
        void regCallShowSetup(std::function<void ()> callShowSetup) { _callShowSetup = callShowSetup; }
36 andreas 118
        void regCallbackNetState(std::function<void (int level)> callNetState, ulong handle);
119
        void unregCallbackNetState(ulong handle);
38 andreas 120
        void regCallbackBatteryState(std::function<void (int level, bool charging, int chargeType)> callBatteryState, ulong handle);
121
        void unregCallbackBatteryState(ulong handle);
44 andreas 122
        void regCallbackResetSurface(std::function<void ()> resetSurface) { _resetSurface = resetSurface; }
64 andreas 123
        void regCallbackShutdown(std::function<void ()> shutdown) { _shutdown = shutdown; }
71 andreas 124
        void regCallbackPlaySound(std::function<void (const std::string& file)> playSound) { _playSound = playSound; }
111 andreas 125
        void regSendVirtualKeys(std::function<void (const std::string& str)> sendVirtualKeys) { _sendVirtualKeys = sendVirtualKeys; }
11 andreas 126
 
127
        /**
128
         * The following function must be called to start non graphics part
129
         * of the panel simulator. If everything worked well, it returns TRUE.
130
         * otherwise a FALSE is returned and the program should be terminated.
131
         */
5 andreas 132
        bool run();
11 andreas 133
        /**
134
         * Set an X value to add to the coordinated reported by the mouse catch
135
         * event. In case the X coordinate reported by the event is not the real
136
         * X coordinate, it's possible to set an X coordinate to translate the
137
         * internal used coordinates.
138
         *
14 andreas 139
         * @param x
140
         * The left most pixel which correspond to X = 0
11 andreas 141
         */
10 andreas 142
        void setFirstLeftPixel(int x) { mFirstLeftPixel = x; }
11 andreas 143
        /**
144
         * Set an Y value to add to the coordinated reported by the mouse catch
145
         * event. In case the Y coordinate reported by the event is not the real
146
         * Y coordinate, it's possible to set an Y coordinate to translate the
147
         * internal used coordinates.
148
         *
14 andreas 149
         * @param y
43 andreas 150
         * The top most pixel which correspond to Y = 0
11 andreas 151
         */
10 andreas 152
        void setFirstTopPixel(int y) { mFirstTopPixel = y; }
11 andreas 153
        /**
154
         * This function must be called from a GUI whenever the left mouse
155
         * button was pressed or released. Also if there was a touch event
14 andreas 156
         * this function must be called in the same way. It's up to any GUI
11 andreas 157
         * to handle the mouse and or touch events.
158
         *
14 andreas 159
         * @param x
160
         * the X coordinate of the mouse/touch event
161
         *
162
         * @param y
163
         * the y coordinate if the mouse/touch event
164
         *
165
         * @return
11 andreas 166
         * pressed TRUE = button was pressed; FALSE = button was released
167
         */
10 andreas 168
        void mouseEvent(int x, int y, bool pressed);
51 andreas 169
        /**
170
         * Searches for a button with the handle \p handle and determines all
171
         * buttons with the same port and channel. Then it sets \p txt to all
172
         * found buttons.
173
         *
174
         * @param handle    The handle of a button.
175
         * @param txt       The text usualy comming from an input line.
176
         */
177
        void setTextToButton(ulong handle, const std::string& txt);
178
        /**
179
         * Iterates through all active subpages of the active page and drops
180
         * them.
181
         */
14 andreas 182
        void dropAllSubPages();
51 andreas 183
        /**
184
         * Closes all subpages in the group \p group.
185
         *
186
         * @param group The name of the group.
187
         */
14 andreas 188
        void closeGroup(const std::string& group);
51 andreas 189
        /**
190
         * Displays a the subpage \p name. If the subpage is part of a group
191
         * the open subpage in the group is closed, if there was one open. Then
192
         * the subpage is displayed. If the subpage is not already in the
193
         * internal buffer it's configuration file is read and the page is
194
         * created.
195
         *
196
         * @param name  The name of the subpage to display.
197
         */
14 andreas 198
        void showSubPage(const std::string& name);
51 andreas 199
        /**
200
         * Hides the subpage \p name.
201
         *
202
         * @param name  The name of the subpage to hide.
203
         */
14 andreas 204
        void hideSubPage(const std::string& name);
43 andreas 205
#ifdef _SCALE_SKIA_
24 andreas 206
        void setScaleFactor(double scale) { mScaleFactor = scale; }
207
        double getScaleFactor() { return mScaleFactor; }
31 andreas 208
        void setScaleFactorWidth(double scale) { mScaleFactorWidth = scale; }
209
        double getScaleFactorWidth() { return mScaleFactorWidth; }
210
        void setScaleFactorHeight(double scale) { mScaleFactorHeight = scale; }
211
        double getScaleFactorHeight() { return mScaleFactorHeight; }
43 andreas 212
#endif
62 andreas 213
        /**
214
         * This method handles some external buttons. Some original panels from
215
         * AMX have external hard buttons. TPanel simulates some of them like
216
         * the arrow keys, enter button and volume. The graphical surface may
217
         * display a toolbar on the right side (only if there is enough space
218
         * left) which offers this buttons. When such a button was pressed, this
219
         * method is called to send them to the controller.
220
         *
221
         * @param bt        The button who was pressed
222
         * @param checked   On button press this is TRUE, and on release it is FALSE.
223
         */
33 andreas 224
        void externalButton(extButtons_t bt, bool checked);
62 andreas 225
        void sendKeyboard(const std::string& text);
226
        void sendKeypad(const std::string& text);
227
        void sendString(uint handle, const std::string& text);
111 andreas 228
        void sendKeyStroke(char key);
62 andreas 229
        /**
230
         * This starts the communication with the AMX controller. The method
231
         * registers the callbacks and starts a thread. This thread runs as
232
         * long as a valid communication is possible or until the communication
233
         * end by a command.
234
         */
38 andreas 235
        void startUp();
14 andreas 236
 
62 andreas 237
        // Callbacks who will be registered by the graphical surface.
26 andreas 238
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> getCallbackDB() { return _displayButton; }
98 andreas 239
        std::function<void (ulong handle, bool state)> getVisible() { return _setVisible; };
38 andreas 240
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> getCallbackBG() { return _setBackground; }
26 andreas 241
        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)> getCallbackPV() { return _callPlayVideo; }
38 andreas 242
        std::function<void (ulong handle, int width, int height)> getCallbackSetPage() { return _setPage; }
52 andreas 243
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm)> getCallbackInputText() { return _callInputText; }
41 andreas 244
        std::function<void (ulong handle, int left, int top, int width, int height, ANIMATION_t animate)> getCallbackSetSubPage() { return _setSubPage; }
38 andreas 245
        std::function<void (ulong handle)> getCallDropPage() { return _callDropPage; }
246
        std::function<void (ulong handle)> getCallDropSubPage() { return _callDropSubPage; }
71 andreas 247
        std::function<void (const std::string& file)> getCallPlaySound() { return _playSound; }
111 andreas 248
        std::function<void (const std::string& str)> sendVirtualKeys() { return _sendVirtualKeys; }
26 andreas 249
 
71 andreas 250
        bool havePlaySound() { return _playSound != nullptr; }
73 andreas 251
        TSystemDraw *getSystemDraw() { return mSystemDraw; }
89 andreas 252
        void reset();
111 andreas 253
        bool getPassThrough() { return mPassThrough; }
113 andreas 254
        bool haveSetupPage() { return _callShowSetup != nullptr; }
255
        bool haveShutdown() { return _shutdown != nullptr; }
256
        void callSetupPage() { if (_callShowSetup) _callShowSetup(); }
257
        void callShutdown() { if (_shutdown) _shutdown(); }
71 andreas 258
 
3 andreas 259
    protected:
260
        PAGELIST_T findPage(const std::string& name);
261
        PAGELIST_T findPage(int ID);
262
        SUBPAGELIST_T findSubPage(const std::string& name);
263
        SUBPAGELIST_T findSubPage(int ID);
264
 
265
        bool addPage(TPage *pg);
266
        bool addSubPage(TSubPage *pg);
11 andreas 267
        TSubPage *getCoordMatch(int x, int y);
40 andreas 268
        Button::TButton *getCoordMatchPage(int x, int y);
11 andreas 269
        void initialize();
270
        void dropAllPages();
92 andreas 271
        bool startComm();
3 andreas 272
 
273
    private:
6 andreas 274
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
98 andreas 275
        std::function<void (ulong handle, bool state)> _setVisible{nullptr};
5 andreas 276
        std::function<void (ulong handle, int width, int height)> _setPage{nullptr};
41 andreas 277
        std::function<void (ulong handle, int left, int top, int width, int height, ANIMATION_t animate)> _setSubPage{nullptr};
38 andreas 278
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> _setBackground{nullptr};
7 andreas 279
        std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)> _setText{nullptr};
11 andreas 280
        std::function<void (ulong handle)> _callDropPage{nullptr};
281
        std::function<void (ulong handle)> _callDropSubPage{nullptr};
21 andreas 282
        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)> _callPlayVideo{nullptr};
52 andreas 283
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm)> _callInputText{nullptr};
63 andreas 284
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeyboard{nullptr};
285
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeypad{nullptr};
286
        std::function<void ()> _callResetKeyboard{nullptr};
64 andreas 287
        std::function<void ()> _callShowSetup{nullptr};
44 andreas 288
        std::function<void ()> _resetSurface{nullptr};
64 andreas 289
        std::function<void ()> _shutdown{nullptr};
71 andreas 290
        std::function<void (const std::string& file)> _playSound{nullptr};
111 andreas 291
        std::function<void (const std::string& str)> _sendVirtualKeys{nullptr};
5 andreas 292
 
32 andreas 293
        /**
294
         * @brief doOverlap checks for overlapping objects
295
         *
296
         * The function checks whether some objects on the surface overlap or
297
         * not. If they do it returns TRUE.
298
         * This is used for images where we should check for a transparent
299
         * pixel.
300
         *
301
         * @param r1    The rectangular of the first object
302
         * @param r2    The rectangular of the second object
303
         * @return If the objects \p r1 and \p r2 overlap at least partialy,
304
         * TRUE is returned. Otherwise FALSE.
305
         */
11 andreas 306
        bool doOverlap(RECT_T r1, RECT_T r2);
307
        /**
308
         * Callback function for the AMX controller part. This function must
309
         * be registered to the class TAmxNet and is called from this module
310
         * every time an event occured from the controller.
311
         * This method handles the commands comming from the controller and
312
         * draws the necessary elements before they are sent to the GUI.
313
         *
14 andreas 314
         * @param cmd
315
         * An ANET_COMMAND structure containing the received command.
11 andreas 316
         */
317
        void doCommand(const amx::ANET_COMMAND& cmd);
14 andreas 318
        /**
319
         * The following function is used internaly. It searches in the map
320
         * table for the button corresponding to the port and channel number
321
         * and puts the result into a chain of buttons. This chain is returned.
322
         *
323
         * If there are some pages not yet in memory, they will be created just
324
         * to be able to set the button(s).
325
         */
326
        std::vector<Button::TButton *> collectButtons(std::vector<MAP_T>& map);
44 andreas 327
        /**
328
         * This internal function frees and destroys all settings, loaded pages
329
         * and sub pages as well as all buttons ens elements belonging to this
330
         * pages. Wehen the function is finished, the state is the same as it
331
         * was immediately at startup.
332
         * This method is called when a filetransfer starts. It is necessary to
333
         * start all over and read in the changed pages.
334
         *
335
         * @return Returns TRUE on success. Else it returns FALSE and the error
336
         * flag is set.
337
         */
338
        bool destroyAll();
15 andreas 339
        TPage *loadPage(PAGELIST_T& pl);
18 andreas 340
        void setButtonCallbacks(Button::TButton *bt);
110 andreas 341
        bool sendCustomEvent(int value1, int value2, int value3, const std::string& msg, int evType, int cp, int cn);
11 andreas 342
 
343
        // List of command functions
23 andreas 344
        void doFTR(int port, std::vector<int>&, std::vector<std::string>& pars);
345
 
14 andreas 346
        void doON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
347
        void doOFF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 348
        void doLEVEL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
349
        void doBLINK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 350
 
11 andreas 351
        void doAPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
352
        void doCPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
353
        void doDPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 354
        void doPHE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
355
        void doPHP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
356
        void doPHT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 357
        void doPPA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 358
        void doPPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
359
        void doPPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
360
        void doPPK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
361
        void doPPM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
362
        void doPPN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 363
        void doPPT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 364
        void doPPX(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 365
        void doPSE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
366
        void doPSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
367
        void doPST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 368
        void doPAGE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 369
 
38 andreas 370
        void doANI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 371
        void doAPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
43 andreas 372
        void doBAT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 373
        void doBAU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
43 andreas 374
        void doBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 375
        void getBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 376
        void doBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 377
        void getBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 378
        void doBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 379
        void getBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 380
        void doBDO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
381
        void doBFB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
106 andreas 382
        void doBMC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 383
        void doBML(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 384
        void doBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 385
        void getBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 386
        void doBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
106 andreas 387
        void getBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 388
        void doBOR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 389
        void doBOS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 390
        void doBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 391
        void getBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 392
        void doBSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 393
        void doBSM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
394
        void doBSO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 395
        void doBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 396
        void getBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 397
        void doCPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
398
        void doDPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
399
        void doENA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
400
        void doFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 401
        void getFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 402
        void doGLH(int port, std::vector<int>& channels, std::vector<std::string>& pars);
403
        void doGLL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 404
        void doGSC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 405
        void doICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 406
        void getICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
407
        void doJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
408
        void getJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
409
        void doJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
410
        void getJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
411
        void doJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
412
        void getJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 413
        void doSHO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 414
        void doTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
415
        void getTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 416
        void doTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
417
        void getTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 418
        void doTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 419
        void getTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
104 andreas 420
        void doUNI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
421
        void doUTF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
4 andreas 422
 
111 andreas 423
        void doKPS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
424
        void doVKS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
425
 
21 andreas 426
        void doBBR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
97 andreas 427
        void doRAF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
428
        void doRFR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
21 andreas 429
        void doRMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
111 andreas 430
        void doRSR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
21 andreas 431
 
62 andreas 432
        void doAKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
433
        void doAKEYB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
434
        void doAKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
435
        void doAKEYP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 436
        void doAKEYR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
437
        void doAKR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 438
        void doABEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
439
        void doADBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
71 andreas 440
        void doBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
441
        void doDBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
62 andreas 442
        void doEKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 443
        void doPKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
444
        void doPKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
64 andreas 445
        void doSetup(int port, std::vector<int>& channels, std::vector<std::string>& pars);
446
        void doShutdown(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 447
        void doSOU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 448
        void doTKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
449
        void doVKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
62 andreas 450
 
14 andreas 451
        int mActualPage{0};                             // The number of the actual visible page
15 andreas 452
        int mPreviousPage{0};                           // The number of the previous page
14 andreas 453
        int mFirstLeftPixel{0};                         // Pixels to add to left (x) mouse coordinate
454
        int mFirstTopPixel{0};                          // Pixels to add to top (y) mouse position
455
        std::string mActualGroupName;                   // The name of the actual group
70 andreas 456
        TSubPage *mActualGroupPage{nullptr};            // Pointer to subpage of a group which is visible
14 andreas 457
 
458
        amx::TAmxNet *mAmxNet{nullptr};                 // Pointer to class TAmxNet; Handles the communication with the controller
459
        TPageList *mPageList{nullptr};                  // List of available pages and subpages
460
        PCHAIN_T *mPchain{nullptr};                     // Pointer to chain of pages in memory
461
        SPCHAIN_T *mSPchain{nullptr};                   // Pointer to chain of subpages in memory for the actual page
462
        TSettings *mTSettings{nullptr};                 // Pointer to basic settings for the panel
463
        TPalette *mPalette{nullptr};                    // Pointer to the color handler
464
        TFont *mFonts{nullptr};                         // Pointer to the font handler
32 andreas 465
        TExternal *mExternal{nullptr};                  // Pointer to the external buttons (if any)
73 andreas 466
        TSystemDraw *mSystemDraw{nullptr};              // A pointer to the (optional) system resources
14 andreas 467
        std::thread mThreadAmxNet;                      // The thread handle to the controler handler
468
        std::vector<amx::ANET_COMMAND> mCommands;       // Command queue of commands received from controller
469
        bool mBusy{false};                              // Internal used to block the command handler
470
        std::string mCmdBuffer;                         // Internal used buffer for commands who need more than one network package
62 andreas 471
        std::string mAkbText;                           // This is the text for the virtual keyboard (@AKB)
73 andreas 472
        std::string mAkpText;                           // This is the text for the virtual keyad (@AKP)
111 andreas 473
        bool mPassThrough{false};                       // Can ve set to true with the command ^KPS
70 andreas 474
#ifdef _SCALE_SKIA_
24 andreas 475
        double mScaleFactor{1.0};                       // The scale factor to zoom or shrink all components
31 andreas 476
        double mScaleFactorWidth{1.0};                  // The individual scale factor for the width
477
        double mScaleFactorHeight{1.0};                 // The individual scale factor for the height
43 andreas 478
#endif
93 andreas 479
#ifdef __ANDROID__
480
        int mNetState{0};                               // On Android remembers the type of connection to the network (cell or wifi)
481
#endif
36 andreas 482
        std::map<int, std::function<void (int level)> > mNetCalls;  // List of callbacks for the network state multistate bargraph
38 andreas 483
        std::map<int, std::function<void (int level, bool charging, int chargeType)> > mBatteryCalls;
3 andreas 484
};
485
 
36 andreas 486
#ifdef __ANDROID__
487
extern "C" {
488
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_NetworkStatus_informTPanelNetwork(JNIEnv */*env*/, jclass /*clazz*/, jboolean conn, jint level, jint type);
38 andreas 489
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_BatteryState_informBatteryStatus(JNIEnv */*env*/, jclass /*clazz*/, jint level, jboolean charge, jint chargeType);
61 andreas 490
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_PhoneCallState_informPhoneState(JNIEnv *env, jclass cl, jboolean call, jstring pnumber);
491
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Logger_logger(JNIEnv *env, jclass cl, jint mode, jstring msg);
36 andreas 492
}
493
#endif  // __ANDROID__
494
 
3 andreas 495
#endif