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
235 andreas 27
#include <qglobal.h>
28
 
3 andreas 29
#include "tpagelist.h"
30
#include "tpage.h"
31
#include "tsubpage.h"
32
#include "tsettings.h"
4 andreas 33
#include "tpalette.h"
7 andreas 34
#include "tbutton.h"
35
#include "tfont.h"
32 andreas 36
#include "texternal.h"
11 andreas 37
#include "tamxnet.h"
38
#include "tamxcommands.h"
73 andreas 39
#include "tsystemdraw.h"
123 andreas 40
#include "tsipclient.h"
169 andreas 41
#include "tvector.h"
3 andreas 42
 
14 andreas 43
#define REG_CMD(func, name)     registerCommand(bind(&TPageManager::func, this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3),name)
3 andreas 44
 
8 andreas 45
class TIcons;
14 andreas 46
class TPageManager;
21 andreas 47
 
48
extern bool prg_stopped;
8 andreas 49
extern TIcons *gIcons;
50
extern TPrjResources *gPrjResources;
14 andreas 51
extern TPageManager *gPageManager;
8 andreas 52
 
93 andreas 53
#ifdef __ANDROID__
54
#define NETSTATE_WIFI   1
55
#define NETSTATE_CELL   2
56
#endif
57
 
11 andreas 58
class TPageManager : public TAmxCommands
3 andreas 59
{
60
    public:
134 andreas 61
        typedef enum J_ORIENTATION
62
        {
63
            O_UNDEFINED = -1,
64
            O_LANDSCAPE = 0,
65
            O_PORTRAIT = 1,
66
            O_REVERSE_LANDSCAPE = 8,
67
            O_REVERSE_PORTRAIT = 9,
68
            O_FACE_UP = 15,
69
            O_FACE_DOWN = 16
70
        }J_ORIENTATION;
71
 
153 andreas 72
        typedef enum SWIPES
73
        {
74
            SW_UNKNOWN,
75
            SW_LEFT,
76
            SW_RIGHT,
77
            SW_UP,
78
            SW_DOWN
79
        }SWIPES;
80
 
3 andreas 81
        TPageManager();
82
        ~TPageManager();
83
 
192 andreas 84
        bool readPages();                               //!< Read all pages and subpages
85
        bool readPage(const std::string& name);         //!< Read the page with name \p name
86
        bool readPage(int ID);                          //!< Read the page with id \p ID
87
        bool readSubPage(const std::string& name);      //!< Read the subpage with name \p name
88
        bool readSubPage(int ID);                       //!< Read the subpage with ID \p ID
89
        void updateActualPage();                        //!< Updates all elements of the actual page
90
        void updateSubpage(int ID);                     //!< Updates all elements of a subpage
91
        void updateSubpage(const std::string& name);    //!< Updates all elements of a subpage
3 andreas 92
 
62 andreas 93
        TPageList *getPageList() { return mPageList; }      //!< Get the list of all pages
94
        TSettings *getSettings() { return mTSettings; }     //!< Get the (system) settings of the panel
197 andreas 95
        TSettings *getSystemSettings() { return mSystemSettings; } //!< Get the system settings of the setup pages
3 andreas 96
 
62 andreas 97
        TPage *getActualPage();                             //!< Get the actual page
98
        int getActualPageNumber() { return mActualPage; }   //!< Get the ID of the actual page
99
        int getPreviousPageNumber() { return mPreviousPage; }   //!< Get the ID of the previous page, if there was any.
4 andreas 100
        TSubPage *getFirstSubPage();
101
        TSubPage *getNextSubPage();
154 andreas 102
        TSubPage *getPrevSubPage();
103
        TSubPage *getLastSubPage();
11 andreas 104
        TSubPage *getFirstSubPageGroup(const std::string& group);
105
        TSubPage *getNextSubPageGroup();
106
        TSubPage *getNextSubPageGroup(const std::string& group, TSubPage *pg);
107
        TSubPage *getTopPage();
4 andreas 108
 
109
        TPage *getPage(int pageID);
110
        TPage *getPage(const std::string& name);
198 andreas 111
        bool setPage(int PageID, bool forget=false);
168 andreas 112
        bool setPage(const std::string& name, bool forget=false);
4 andreas 113
        TSubPage *getSubPage(int pageID);
114
        TSubPage *getSubPage(const std::string& name);
96 andreas 115
        TSubPage *deliverSubPage(const std::string& name, TPage **pg=nullptr);
198 andreas 116
        TSubPage *deliverSubPage(int number, TPage **pg=nullptr);
14 andreas 117
        bool havePage(const std::string& name);
118
        bool haveSubPage(const std::string& name);
119
        bool haveSubPage(int id);
120
        bool haveSubPage(const std::string& page, const std::string& name);
121
        bool haveSubPage(const std::string& page, int id);
50 andreas 122
        TFont *getFonts() { return mFonts; }
51 andreas 123
        Button::TButton *findButton(ulong handle);
153 andreas 124
        void onSwipeEvent(SWIPES sw);
164 andreas 125
        double getDPI() { return mDPI; }
126
        void setDPI(const double dpi) { mDPI = dpi; }
4 andreas 127
 
6 andreas 128
        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; }
190 andreas 129
        void registerDropButton(std::function<void(ulong hanlde)> dropButton) { _dropButton = dropButton; }
98 andreas 130
        void registerCBsetVisible(std::function<void(ulong handle, bool state)> setVisible) { _setVisible = setVisible; }
5 andreas 131
        void registerCallbackSP(std::function<void (ulong handle, int width, int height)> setPage) { _setPage = setPage; }
217 andreas 132
        void registerCallbackSSP(std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, ANIMATION_t animate)> setSubPage) { _setSubPage = setSubPage; }
38 andreas 133
        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 134
        void deployCallbacks();
36 andreas 135
#ifdef __ANDROID__
136
        void initNetworkState();
137
        void stopNetworkState();
38 andreas 138
        void initBatteryState();
139
        void stopBatteryState();
61 andreas 140
        void initPhoneState();
36 andreas 141
        void informTPanelNetwork(jboolean conn, jint level, jint type);
38 andreas 142
        void informBatteryStatus(jint level, jboolean charging, jint chargeType);
61 andreas 143
        void informPhoneState(bool call, const std::string& pnumber);
130 andreas 144
        void initOrientation();
36 andreas 145
#endif
247 andreas 146
#ifdef Q_OS_IOS
147
        void informBatteryStatus(int level, int state);
250 andreas 148
        void informTPanelNetwork(bool conn, int level, int type);
247 andreas 149
#endif
11 andreas 150
        void regCallDropPage(std::function<void (ulong handle)> callDropPage) { _callDropPage = callDropPage; }
151
        void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
21 andreas 152
        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; };
192 andreas 153
        void regCallInputText(std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> callInputText) { _callInputText = callInputText; }
200 andreas 154
        void regCallListBox(std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> callListBox) { _callListBox = callListBox; }
63 andreas 155
        void regCallbackKeyboard(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeyboard) { _callKeyboard = callKeyboard; }
156
        void regCallbackKeypad(std::function<void (const std::string& init, const std::string& prompt, bool priv)> callKeypad) { _callKeypad = callKeypad; }
157
        void regCallResetKeyboard(std::function<void ()> callResetKeyboard) { _callResetKeyboard = callResetKeyboard; }
64 andreas 158
        void regCallShowSetup(std::function<void ()> callShowSetup) { _callShowSetup = callShowSetup; }
36 andreas 159
        void regCallbackNetState(std::function<void (int level)> callNetState, ulong handle);
160
        void unregCallbackNetState(ulong handle);
247 andreas 161
#ifdef Q_OS_ANDROID
38 andreas 162
        void regCallbackBatteryState(std::function<void (int level, bool charging, int chargeType)> callBatteryState, ulong handle);
247 andreas 163
#endif
164
#ifdef Q_OS_IOS
165
        void regCallbackBatteryState(std::function<void (int level, int state)> callBatteryState, ulong handle);
166
#endif
167
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
38 andreas 168
        void unregCallbackBatteryState(ulong handle);
247 andreas 169
#endif
44 andreas 170
        void regCallbackResetSurface(std::function<void ()> resetSurface) { _resetSurface = resetSurface; }
64 andreas 171
        void regCallbackShutdown(std::function<void ()> shutdown) { _shutdown = shutdown; }
71 andreas 172
        void regCallbackPlaySound(std::function<void (const std::string& file)> playSound) { _playSound = playSound; }
141 andreas 173
        void regCallbackStopSound(std::function<void ()> stopSound) { _stopSound = stopSound; }
174
        void regCallbackMuteSound(std::function<void (bool state)> muteSound) { _muteSound = muteSound; }
111 andreas 175
        void regSendVirtualKeys(std::function<void (const std::string& str)> sendVirtualKeys) { _sendVirtualKeys = sendVirtualKeys; }
140 andreas 176
        void regShowPhoneDialog(std::function<void (bool state)> showPhoneDialog) { _showPhoneDialog = showPhoneDialog; }
177
        void regSetPhoneNumber(std::function<void (const std::string& number)> setPhoneNumber) { _setPhoneNumber = setPhoneNumber; }
178
        void regSetPhoneStatus(std::function<void (const std::string& msg)> setPhoneStatus) { _setPhoneStatus = setPhoneStatus; }
179
        void regSetPhoneState(std::function<void (int state, int id)> setPhoneState) { _setPhoneState = setPhoneState; }
206 andreas 180
        void regDisplayMessage(std::function<void (const std::string& msg, const std::string& title)> msg) { _displayMessage = msg; }
209 andreas 181
        void regFileDialogFunction(std::function<void (ulong handle, const std::string& path, const std::string& extension, const std::string& suffix)> fdlg) { _fileDialog = fdlg; }
235 andreas 182
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
130 andreas 183
        void regOnOrientationChange(std::function<void (int orientation)> orientationChange) { _onOrientationChange = orientationChange; }
184
#endif
142 andreas 185
        void regRepaintWindows(std::function<void ()> repaintWindows) { _repaintWindows = repaintWindows; }
151 andreas 186
        void regToFront(std::function<void (ulong handle)> toFront) { _toFront = toFront; }
197 andreas 187
        void regSetMainWindowSize(std::function<void (int width, int height)> setSize) { _setMainWindowSize = setSize; }
206 andreas 188
        void regDownloadSurface(std::function<void (const std::string& file, size_t size)> dl) { _downloadSurface = dl; }
142 andreas 189
 
11 andreas 190
        /**
191
         * The following function must be called to start non graphics part
192
         * of the panel simulator. If everything worked well, it returns TRUE.
193
         * otherwise a FALSE is returned and the program should be terminated.
194
         */
5 andreas 195
        bool run();
11 andreas 196
        /**
197
         * Set an X value to add to the coordinated reported by the mouse catch
198
         * event. In case the X coordinate reported by the event is not the real
199
         * X coordinate, it's possible to set an X coordinate to translate the
200
         * internal used coordinates.
201
         *
14 andreas 202
         * @param x
203
         * The left most pixel which correspond to X = 0
11 andreas 204
         */
10 andreas 205
        void setFirstLeftPixel(int x) { mFirstLeftPixel = x; }
11 andreas 206
        /**
207
         * Set an Y value to add to the coordinated reported by the mouse catch
208
         * event. In case the Y coordinate reported by the event is not the real
209
         * Y coordinate, it's possible to set an Y coordinate to translate the
210
         * internal used coordinates.
211
         *
14 andreas 212
         * @param y
43 andreas 213
         * The top most pixel which correspond to Y = 0
11 andreas 214
         */
10 andreas 215
        void setFirstTopPixel(int y) { mFirstTopPixel = y; }
11 andreas 216
        /**
217
         * This function must be called from a GUI whenever the left mouse
218
         * button was pressed or released. Also if there was a touch event
14 andreas 219
         * this function must be called in the same way. It's up to any GUI
11 andreas 220
         * to handle the mouse and or touch events.
221
         *
14 andreas 222
         * @param x
223
         * the X coordinate of the mouse/touch event
224
         *
225
         * @param y
226
         * the y coordinate if the mouse/touch event
227
         *
228
         * @return
11 andreas 229
         * pressed TRUE = button was pressed; FALSE = button was released
230
         */
10 andreas 231
        void mouseEvent(int x, int y, bool pressed);
51 andreas 232
        /**
233
         * Searches for a button with the handle \p handle and determines all
234
         * buttons with the same port and channel. Then it sets \p txt to all
235
         * found buttons.
236
         *
237
         * @param handle    The handle of a button.
238
         * @param txt       The text usualy comming from an input line.
208 andreas 239
         * @param redraw    If this is set to true the button is redrawn.
51 andreas 240
         */
208 andreas 241
        void setTextToButton(ulong handle, const std::string& txt, bool redraw=false);
51 andreas 242
        /**
243
         * Iterates through all active subpages of the active page and drops
244
         * them.
245
         */
14 andreas 246
        void dropAllSubPages();
51 andreas 247
        /**
248
         * Closes all subpages in the group \p group.
249
         *
250
         * @param group The name of the group.
251
         */
14 andreas 252
        void closeGroup(const std::string& group);
51 andreas 253
        /**
198 andreas 254
         * Displays the subpage \p name. If the subpage is part of a group
51 andreas 255
         * the open subpage in the group is closed, if there was one open. Then
256
         * the subpage is displayed. If the subpage is not already in the
257
         * internal buffer it's configuration file is read and the page is
258
         * created.
259
         *
260
         * @param name  The name of the subpage to display.
261
         */
14 andreas 262
        void showSubPage(const std::string& name);
51 andreas 263
        /**
198 andreas 264
         * Displays the subpage \p number. If the subpage is part of a group
265
         * the open subpage in the group is closed, if there was one open. Then
266
         * the subpage is displayed. If the subpage is not already in the
267
         * internal buffer it's configuration file is read and the page is
268
         * created.
269
         *
270
         * @param name  The name of the subpage to display.
271
         */
272
        void showSubPage(int number, bool force=false);
273
        /**
51 andreas 274
         * Hides the subpage \p name.
275
         *
276
         * @param name  The name of the subpage to hide.
277
         */
14 andreas 278
        void hideSubPage(const std::string& name);
192 andreas 279
        /**
280
         * This is called whenever an input button finished or changed it's
281
         * content. It is called out of the class TQEditLine.
282
         * The method writes the content into the text area of the button the
283
         * handle points to.
284
         *
285
         * @param handle   The handle of the button.
286
         * @param content  The content of the text area.
287
         */
288
        void inputButtonFinished(ulong handle, const std::string& content);
43 andreas 289
#ifdef _SCALE_SKIA_
24 andreas 290
        void setScaleFactor(double scale) { mScaleFactor = scale; }
291
        double getScaleFactor() { return mScaleFactor; }
31 andreas 292
        void setScaleFactorWidth(double scale) { mScaleFactorWidth = scale; }
293
        double getScaleFactorWidth() { return mScaleFactorWidth; }
294
        void setScaleFactorHeight(double scale) { mScaleFactorHeight = scale; }
295
        double getScaleFactorHeight() { return mScaleFactorHeight; }
43 andreas 296
#endif
62 andreas 297
        /**
298
         * This method handles some external buttons. Some original panels from
299
         * AMX have external hard buttons. TPanel simulates some of them like
300
         * the arrow keys, enter button and volume. The graphical surface may
301
         * display a toolbar on the right side (only if there is enough space
302
         * left) which offers this buttons. When such a button was pressed, this
303
         * method is called to send them to the controller.
304
         *
305
         * @param bt        The button who was pressed
306
         * @param checked   On button press this is TRUE, and on release it is FALSE.
307
         */
33 andreas 308
        void externalButton(extButtons_t bt, bool checked);
62 andreas 309
        void sendKeyboard(const std::string& text);
310
        void sendKeypad(const std::string& text);
311
        void sendString(uint handle, const std::string& text);
134 andreas 312
        void sendGlobalString(const std::string& text);
123 andreas 313
        void sendPHNcommand(const std::string& cmd);
111 andreas 314
        void sendKeyStroke(char key);
147 andreas 315
        void sendCommandString(int port, const std::string& cmd);
62 andreas 316
        /**
317
         * This starts the communication with the AMX controller. The method
318
         * registers the callbacks and starts a thread. This thread runs as
319
         * long as a valid communication is possible or until the communication
320
         * end by a command.
321
         */
38 andreas 322
        void startUp();
147 andreas 323
        /**
169 andreas 324
         * This starts a thread running the command loop. Each event from the
192 andreas 325
         * Netlinx is entered into a vector array (doCommand()) and this
169 andreas 326
         * method starts the event loop as a thread running as long as this
327
         * class exists.
328
         */
329
        void runCommands();
330
        /**
331
         * This method is the thread started by the command runCommands().
332
         */
333
        void commandLoop();
334
        /**
147 andreas 335
         * Callback function for the AMX controller part. This function must
336
         * be registered to the class TAmxNet and is called from this module
337
         * every time an event occured from the controller.
338
         * This method handles the commands comming from the controller and
339
         * draws the necessary elements before they are sent to the GUI.
340
         *
341
         * @param cmd
342
         * An ANET_COMMAND structure containing the received command.
343
         */
344
        void doCommand(const amx::ANET_COMMAND& cmd);
193 andreas 345
        /**
346
         * Returns the state of setup. If the setup pages are active it returns
347
         * TRUE.
348
         *
349
         * @return State of setup pages
350
         */
351
        bool isSetupActive() { return mSetupActive; }
197 andreas 352
        /**
353
         * Activates the setup pages unless they are not visible already.
354
         */
355
        void showSetup();
356
        /**
357
         * Deactivates the setup pages and restores the previous normal page.
358
         */
359
        void hideSetup();
360
        /**
205 andreas 361
         * Determines the page or subpage the handle points to and returns the
362
         * selected row of a list, if there is one.
363
         * The row index starts by 1!
364
         *
365
         * @param handle    The handle of the button.
366
         * @return If the button is a list and a row was selected then a number
367
         * grater than 0 is returned. Otherwise -1 is returned.
368
         */
369
        int getSelectedRow(ulong handle);
370
        /**
371
         * Finds the page or subpage and returns the selected item as a string.
372
         * If there was no list, or no items in the list, or nothing selected,
373
         * an empty string is returned.
374
         *
375
         * @param handle    The handle of the button
376
         * @return The string of the selected item or an empty string.
377
         */
378
        std::string getSelectedItem(ulong handle);
379
        /**
380
         * Finds the corresponding list and sets the selected row. The \b row
381
         * must be a value starting by 1. It must not be bigger that items in
382
         * the list.
383
         *
384
         * @param handle    The handle of the button
385
         * @param row       The number of the selected row.
386
         */
206 andreas 387
        void setSelectedRow(ulong handle, int row, const std::string& text);
247 andreas 388
#ifdef Q_OS_IOS
389
        void setBattery(int level, int state) { mLastBatteryLevel = level; mLastBatteryState = state; }
390
#endif
205 andreas 391
#ifdef _SCALE_SKIA_
392
        /**
197 andreas 393
         * Set the scale factor for the system setup pages. On a desktop this
394
         * factor is in relation to the size of the normal pages, if there any.
395
         * On a mobile device the factor is in relation to the resolution of
396
         * the display.
397
         * The scale factor is calculated in qtmain.cpp: MainWindow::calcScaleSetup()
398
         *
399
         * @param scale  The overall scale factor. This is used for calculations
400
         * and ensures that the ratio of the objects is maintained.
401
         * @param sw     The scale factor for the width.
402
         * @param sh     The scale factor for the height.
403
         */
404
        void setSetupScaleFactor(double scale, double sw, double sh);
198 andreas 405
#endif
62 andreas 406
        // Callbacks who will be registered by the graphical surface.
26 andreas 407
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> getCallbackDB() { return _displayButton; }
190 andreas 408
        std::function<void (ulong handle)> getCallDropButton() { return _dropButton; }
98 andreas 409
        std::function<void (ulong handle, bool state)> getVisible() { return _setVisible; };
38 andreas 410
        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 411
        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 412
        std::function<void (ulong handle, int width, int height)> getCallbackSetPage() { return _setPage; }
192 andreas 413
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> getCallbackInputText() { return _callInputText; }
200 andreas 414
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> getCallbackListBox() { return _callListBox; }
217 andreas 415
        std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, ANIMATION_t animate)> getCallbackSetSubPage() { return _setSubPage; }
38 andreas 416
        std::function<void (ulong handle)> getCallDropPage() { return _callDropPage; }
417
        std::function<void (ulong handle)> getCallDropSubPage() { return _callDropSubPage; }
71 andreas 418
        std::function<void (const std::string& file)> getCallPlaySound() { return _playSound; }
141 andreas 419
        std::function<void ()> getCallStopSound() { return _stopSound; }
420
        std::function<void (bool state)> getCallMuteSound() { return _muteSound; }
111 andreas 421
        std::function<void (const std::string& str)> sendVirtualKeys() { return _sendVirtualKeys; }
140 andreas 422
        std::function<void (bool state)> getShowPhoneDialog() { return _showPhoneDialog; }
423
        std::function<void (const std::string& number)> getSetPhoneNumber() { return _setPhoneNumber; }
424
        std::function<void (const std::string& msg)> getSetPhoneStatus() { return _setPhoneStatus; }
425
        std::function<void (int state, int id)> getSetPhoneState() { return _setPhoneState; }
151 andreas 426
        std::function<void (ulong handle)> getToFront() { return _toFront; }
197 andreas 427
        std::function<void (int width, int height)> getMainWindowSizeFunc() { return _setMainWindowSize; }
206 andreas 428
        std::function<void (const std::string& file, size_t size)> getDownloadSurface() { return _downloadSurface; }
429
        std::function<void (const std::string& msg, const std::string& title)> getDisplayMessage() { return _displayMessage; }
209 andreas 430
        std::function<void (ulong handle, const std::string& path, const std::string& extension, const std::string& suffix)> getFileDialogFunction() { return _fileDialog; }
235 andreas 431
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
130 andreas 432
        std::function<void (int orientation)> onOrientationChange() { return _onOrientationChange; }
433
#endif
142 andreas 434
        std::function<void ()> getRepaintWindows() { return _repaintWindows; }
134 andreas 435
        int getOrientation() { return mOrientation; }
436
        void setOrientation(int ori) { mOrientation = ori; }
437
        bool getInformOrientation() { return mInformOrientation; }
438
        void sendOrientation();
71 andreas 439
        bool havePlaySound() { return _playSound != nullptr; }
73 andreas 440
        TSystemDraw *getSystemDraw() { return mSystemDraw; }
89 andreas 441
        void reset();
111 andreas 442
        bool getPassThrough() { return mPassThrough; }
113 andreas 443
        bool haveSetupPage() { return _callShowSetup != nullptr; }
444
        bool haveShutdown() { return _shutdown != nullptr; }
445
        void callSetupPage() { if (_callShowSetup) _callShowSetup(); }
446
        void callShutdown() { if (_shutdown) _shutdown(); }
129 andreas 447
#ifndef _NOSIP_
123 andreas 448
        bool getPHNautoanswer() { return mPHNautoanswer; }
449
        void sendPHN(std::vector<std::string>& cmds);
141 andreas 450
        void actPHN(std::vector<std::string>& cmds);
140 andreas 451
        void phonePickup(int id);
452
        void phoneHangup(int id);
129 andreas 453
#endif
206 andreas 454
        void addFtpSurface(const std::string& file, size_t size) { mFtpSurface.push_back(_FTP_SURFACE_t{file, size}); };
455
 
456
        inline size_t getFtpSurfaceSize(const std::string& file)
457
        {
458
            if (mFtpSurface.empty())
459
                return 0;
460
 
461
            std::vector<_FTP_SURFACE_t>::iterator iter;
462
 
463
            for (iter = mFtpSurface.begin(); iter != mFtpSurface.end(); ++iter)
464
            {
465
                if (iter->file == file)
466
                    return iter->size;
467
            }
468
 
469
            return 0;
470
        }
471
 
472
        void clearFtpSurface() { mFtpSurface.clear(); }
473
 
3 andreas 474
    protected:
475
        PAGELIST_T findPage(const std::string& name);
476
        PAGELIST_T findPage(int ID);
477
        SUBPAGELIST_T findSubPage(const std::string& name);
478
        SUBPAGELIST_T findSubPage(int ID);
479
 
480
        bool addPage(TPage *pg);
481
        bool addSubPage(TSubPage *pg);
11 andreas 482
        TSubPage *getCoordMatch(int x, int y);
40 andreas 483
        Button::TButton *getCoordMatchPage(int x, int y);
11 andreas 484
        void initialize();
485
        void dropAllPages();
92 andreas 486
        bool startComm();
3 andreas 487
 
488
    private:
6 andreas 489
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
190 andreas 490
        std::function<void (ulong handle)> _dropButton{nullptr};
98 andreas 491
        std::function<void (ulong handle, bool state)> _setVisible{nullptr};
5 andreas 492
        std::function<void (ulong handle, int width, int height)> _setPage{nullptr};
217 andreas 493
        std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, ANIMATION_t animate)> _setSubPage{nullptr};
38 andreas 494
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> _setBackground{nullptr};
7 andreas 495
        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 496
        std::function<void (ulong handle)> _callDropPage{nullptr};
497
        std::function<void (ulong handle)> _callDropSubPage{nullptr};
21 andreas 498
        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};
192 andreas 499
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> _callInputText{nullptr};
200 andreas 500
        std::function<void (Button::TButton *button, Button::BITMAP_t& bm, int frame)> _callListBox{nullptr};
63 andreas 501
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeyboard{nullptr};
502
        std::function<void (const std::string& init, const std::string& prompt, bool priv)> _callKeypad{nullptr};
503
        std::function<void ()> _callResetKeyboard{nullptr};
64 andreas 504
        std::function<void ()> _callShowSetup{nullptr};
44 andreas 505
        std::function<void ()> _resetSurface{nullptr};
64 andreas 506
        std::function<void ()> _shutdown{nullptr};
71 andreas 507
        std::function<void (const std::string& file)> _playSound{nullptr};
141 andreas 508
        std::function<void ()> _stopSound{nullptr};
509
        std::function<void (bool state)> _muteSound{nullptr};
111 andreas 510
        std::function<void (const std::string& str)> _sendVirtualKeys{nullptr};
140 andreas 511
        std::function<void (bool state)> _showPhoneDialog{nullptr};
512
        std::function<void (const std::string& number)> _setPhoneNumber{nullptr};
513
        std::function<void (const std::string& msg)> _setPhoneStatus{nullptr};
514
        std::function<void (int state, int id)> _setPhoneState{nullptr};
142 andreas 515
        std::function<void ()> _repaintWindows{nullptr};
151 andreas 516
        std::function<void (uint handle)> _toFront{nullptr};
197 andreas 517
        std::function<void (int width, int height)> _setMainWindowSize{nullptr};
206 andreas 518
        std::function<void (const std::string& file, size_t size)> _downloadSurface{nullptr};
519
        std::function<void (const std::string& msg, const std::string& title)> _displayMessage{nullptr};
209 andreas 520
        std::function<void (ulong handle, const std::string& path, const std::string& extension, const std::string& suffix)> _fileDialog{nullptr};
235 andreas 521
#if defined(__ANDROID__) || defined(Q_OS_IOS)
130 andreas 522
        std::function<void (int orientation)> _onOrientationChange{nullptr};
523
#endif
206 andreas 524
        typedef struct _FTP_SURFACE_t
525
        {
526
            std::string file;
527
            size_t size{0};
528
        }_FTP_SURFACE_t;
529
 
32 andreas 530
        /**
531
         * @brief doOverlap checks for overlapping objects
532
         *
533
         * The function checks whether some objects on the surface overlap or
534
         * not. If they do it returns TRUE.
535
         * This is used for images where we should check for a transparent
536
         * pixel.
537
         *
538
         * @param r1    The rectangular of the first object
539
         * @param r2    The rectangular of the second object
540
         * @return If the objects \p r1 and \p r2 overlap at least partialy,
541
         * TRUE is returned. Otherwise FALSE.
542
         */
11 andreas 543
        bool doOverlap(RECT_T r1, RECT_T r2);
544
        /**
14 andreas 545
         * The following function is used internaly. It searches in the map
546
         * table for the button corresponding to the port and channel number
547
         * and puts the result into a chain of buttons. This chain is returned.
548
         *
549
         * If there are some pages not yet in memory, they will be created just
550
         * to be able to set the button(s).
551
         */
193 andreas 552
        std::vector<Button::TButton *> collectButtons(std::vector<TMap::MAP_T>& map);
44 andreas 553
        /**
554
         * This internal function frees and destroys all settings, loaded pages
555
         * and sub pages as well as all buttons ens elements belonging to this
556
         * pages. Wehen the function is finished, the state is the same as it
557
         * was immediately at startup.
558
         * This method is called when a filetransfer starts. It is necessary to
559
         * start all over and read in the changed pages.
560
         *
561
         * @return Returns TRUE on success. Else it returns FALSE and the error
562
         * flag is set.
563
         */
564
        bool destroyAll();
209 andreas 565
 
150 andreas 566
        bool overlap(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
209 andreas 567
        TPage *loadPage(PAGELIST_T& pl, bool *refresh=nullptr);
18 andreas 568
        void setButtonCallbacks(Button::TButton *bt);
110 andreas 569
        bool sendCustomEvent(int value1, int value2, int value3, const std::string& msg, int evType, int cp, int cn);
209 andreas 570
        void reloadSystemPage(TPage *page);
129 andreas 571
#ifndef _NOSIP_
127 andreas 572
        std::string sipStateToString(TSIPClient::SIP_STATE_t s);
129 andreas 573
#endif
11 andreas 574
        // List of command functions
23 andreas 575
        void doFTR(int port, std::vector<int>&, std::vector<std::string>& pars);
576
 
14 andreas 577
        void doON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
578
        void doOFF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 579
        void doLEVEL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
580
        void doBLINK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
127 andreas 581
        void doVER(int port, std::vector<int>& channels, std::vector<std::string>& pars);
582
        void doWCN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 583
 
147 andreas 584
        void doAFP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 585
        void doAPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
586
        void doCPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
587
        void doDPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 588
        void doPHE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
589
        void doPHP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
590
        void doPHT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 591
        void doPPA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 592
        void doPPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
593
        void doPPG(int port, std::vector<int>& channels, std::vector<std::string>& pars);
594
        void doPPK(int port, std::vector<int>& channels, std::vector<std::string>& pars);
595
        void doPPM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
596
        void doPPN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 597
        void doPPT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 598
        void doPPX(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 599
        void doPSE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
600
        void doPSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
601
        void doPST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
12 andreas 602
        void doPAGE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
11 andreas 603
 
38 andreas 604
        void doANI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 605
        void doAPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
43 andreas 606
        void doBAT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 607
        void doBAU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
43 andreas 608
        void doBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 609
        void getBCB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 610
        void doBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 611
        void getBCF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 612
        void doBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 613
        void getBCT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 614
        void doBDO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
615
        void doBFB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
224 andreas 616
        void doBIM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
106 andreas 617
        void doBMC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
149 andreas 618
        void doBMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 619
        void doBML(int port, std::vector<int>& channels, std::vector<std::string>& pars);
15 andreas 620
        void doBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 621
        void getBMP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 622
        void doBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
106 andreas 623
        void getBOP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 624
        void doBOR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 625
        void doBOS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 626
        void doBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 627
        void getBRD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 628
        void doBSP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
107 andreas 629
        void doBSM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
630
        void doBSO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 631
        void doBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 632
        void getBWW(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 633
        void doCPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
634
        void doDPF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
635
        void doENA(int port, std::vector<int>& channels, std::vector<std::string>& pars);
636
        void doFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 637
        void getFON(int port, std::vector<int>& channels, std::vector<std::string>& pars);
60 andreas 638
        void doGLH(int port, std::vector<int>& channels, std::vector<std::string>& pars);
639
        void doGLL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 640
        void doGSC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 641
        void doICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 642
        void getICO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
643
        void doJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
644
        void getJSB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
645
        void doJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
646
        void getJSI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
647
        void doJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
648
        void getJST(int port, std::vector<int>& channels, std::vector<std::string>& pars);
16 andreas 649
        void doSHO(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 650
        void doTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
651
        void getTEC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 652
        void doTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
653
        void getTEF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
14 andreas 654
        void doTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
110 andreas 655
        void getTXT(int port, std::vector<int>& channels, std::vector<std::string>& pars);
104 andreas 656
        void doUNI(int port, std::vector<int>& channels, std::vector<std::string>& pars);
657
        void doUTF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
148 andreas 658
        void doVTP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
4 andreas 659
 
111 andreas 660
        void doKPS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
661
        void doVKS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
662
 
21 andreas 663
        void doBBR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
97 andreas 664
        void doRAF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
665
        void doRFR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
21 andreas 666
        void doRMF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
111 andreas 667
        void doRSR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
21 andreas 668
 
62 andreas 669
        void doAKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
670
        void doAKEYB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
671
        void doAKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
672
        void doAKEYP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 673
        void doAKEYR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
674
        void doAKR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
108 andreas 675
        void doABEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
676
        void doADBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
71 andreas 677
        void doBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
678
        void doDBEEP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
62 andreas 679
        void doEKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 680
        void doPKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
681
        void doPKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
64 andreas 682
        void doSetup(int port, std::vector<int>& channels, std::vector<std::string>& pars);
683
        void doShutdown(int port, std::vector<int>& channels, std::vector<std::string>& pars);
82 andreas 684
        void doSOU(int port, std::vector<int>& channels, std::vector<std::string>& pars);
63 andreas 685
        void doTKP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
686
        void doVKB(int port, std::vector<int>& channels, std::vector<std::string>& pars);
129 andreas 687
#ifndef _NOSIP_
123 andreas 688
        void doPHN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
127 andreas 689
        void getPHN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
129 andreas 690
#endif
225 andreas 691
        // Commands for ListView (G5)
227 andreas 692
        void doLVD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
230 andreas 693
        void doLVE(int port, std::vector<int>& channels, std::vector<std::string>& pars);
227 andreas 694
        void doLVF(int port, std::vector<int>& channels, std::vector<std::string>& pars);
230 andreas 695
        void doLVL(int port, std::vector<int>& channels, std::vector<std::string>& pars);
233 andreas 696
        void doLVM(int port, std::vector<int>& channels, std::vector<std::string>& pars);
697
        void doLVN(int port, std::vector<int>& channels, std::vector<std::string>& pars);
698
        void doLVR(int port, std::vector<int>& channels, std::vector<std::string>& pars);
699
        void doLVS(int port, std::vector<int>& channels, std::vector<std::string>& pars);
134 andreas 700
        // Commands inherited from TPControl (Touch Panel Control)
701
        void doTPCCMD(int port, std::vector<int>& channels, std::vector<std::string>& pars);
702
        void doTPCACC(int port, std::vector<int>& channels, std::vector<std::string>& pars);
153 andreas 703
        void doTPCSIP(int port, std::vector<int>& channels, std::vector<std::string>& pars);
134 andreas 704
 
14 andreas 705
        int mActualPage{0};                             // The number of the actual visible page
15 andreas 706
        int mPreviousPage{0};                           // The number of the previous page
197 andreas 707
        int mSavedPage{0};                              // The number of the last normal page. This is set immediately before a setup page is shown
14 andreas 708
        int mFirstLeftPixel{0};                         // Pixels to add to left (x) mouse coordinate
709
        int mFirstTopPixel{0};                          // Pixels to add to top (y) mouse position
710
        std::string mActualGroupName;                   // The name of the actual group
70 andreas 711
        TSubPage *mActualGroupPage{nullptr};            // Pointer to subpage of a group which is visible
14 andreas 712
 
713
        amx::TAmxNet *mAmxNet{nullptr};                 // Pointer to class TAmxNet; Handles the communication with the controller
714
        TPageList *mPageList{nullptr};                  // List of available pages and subpages
715
        PCHAIN_T *mPchain{nullptr};                     // Pointer to chain of pages in memory
716
        SPCHAIN_T *mSPchain{nullptr};                   // Pointer to chain of subpages in memory for the actual page
717
        TSettings *mTSettings{nullptr};                 // Pointer to basic settings for the panel
193 andreas 718
        TSettings *mSystemSettings{nullptr};            // Pointer to basic system settings for setup
14 andreas 719
        TPalette *mPalette{nullptr};                    // Pointer to the color handler
720
        TFont *mFonts{nullptr};                         // Pointer to the font handler
32 andreas 721
        TExternal *mExternal{nullptr};                  // Pointer to the external buttons (if any)
73 andreas 722
        TSystemDraw *mSystemDraw{nullptr};              // A pointer to the (optional) system resources
14 andreas 723
        std::thread mThreadAmxNet;                      // The thread handle to the controler handler
169 andreas 724
        TVector<amx::ANET_COMMAND> mCommands;           // Command queue of commands received from controller
725
        std::atomic<bool> mBusy{false};                 // Internal used to block the command handler
14 andreas 726
        std::string mCmdBuffer;                         // Internal used buffer for commands who need more than one network package
62 andreas 727
        std::string mAkbText;                           // This is the text for the virtual keyboard (@AKB)
73 andreas 728
        std::string mAkpText;                           // This is the text for the virtual keyad (@AKP)
111 andreas 729
        bool mPassThrough{false};                       // Can ve set to true with the command ^KPS
134 andreas 730
        bool mInformOrientation{false};                 // TRUE = The actual screen orientation is reported to the controller if it change.
731
        int mOrientation{0};                            // Contains the actual orientation.
154 andreas 732
        int mLastPagePush{0};                           // The number of the last page received a push (key press / mouse hit)
164 andreas 733
        double mDPI{96.0};                              // DPI (Dots Per Inch) of the primary display.
169 andreas 734
        std::atomic<bool> cmdLoop_busy{false};          // As long as this is true the command loop thread is active
735
        std::thread mThreadCommand;                     // Thread handle for command loop thread.
193 andreas 736
        bool mSetupActive{false};                       // TRUE = Setup pages are active
198 andreas 737
        std::vector<int> mSavedSubpages;                // When setup pages are called this contains the actual open subpages
206 andreas 738
        std::vector<_FTP_SURFACE_t> mFtpSurface;        // Contains a list of TP4 surface files gained from a NetLinx.
123 andreas 739
        // SIP
129 andreas 740
#ifndef _NOSIP_
123 andreas 741
        bool mPHNautoanswer{false};                     // The state of the SIP autoanswer
127 andreas 742
        TSIPClient *mSIPClient{nullptr};                // Includes the SIP client
129 andreas 743
#endif
70 andreas 744
#ifdef _SCALE_SKIA_
24 andreas 745
        double mScaleFactor{1.0};                       // The scale factor to zoom or shrink all components
31 andreas 746
        double mScaleFactorWidth{1.0};                  // The individual scale factor for the width
747
        double mScaleFactorHeight{1.0};                 // The individual scale factor for the height
198 andreas 748
 
197 andreas 749
        double mScaleSystem{1.0};                       // The scale factor for the system setup pages
750
        double mScaleSystemWidth{1.0};                  // The width scale factor for the system setup pages
751
        double mScaleSystemHeight{1.0};                 // The height scale factor for the system setup pages
198 andreas 752
#endif
250 andreas 753
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
754
        int mNetState{0};                               // On Android and IOS remembers the type of connection to the network (cell or wifi)
93 andreas 755
#endif
36 andreas 756
        std::map<int, std::function<void (int level)> > mNetCalls;  // List of callbacks for the network state multistate bargraph
247 andreas 757
#ifdef Q_OS_ANDROID
38 andreas 758
        std::map<int, std::function<void (int level, bool charging, int chargeType)> > mBatteryCalls;
247 andreas 759
#endif
760
#ifdef Q_OS_IOS
761
        std::map<int, std::function<void (int level, int state)> > mBatteryCalls;
762
        int mLastBatteryLevel{0};
763
        int mLastBatteryState{0};
764
#endif
3 andreas 765
};
766
 
36 andreas 767
#ifdef __ANDROID__
768
extern "C" {
769
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_NetworkStatus_informTPanelNetwork(JNIEnv */*env*/, jclass /*clazz*/, jboolean conn, jint level, jint type);
38 andreas 770
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_BatteryState_informBatteryStatus(JNIEnv */*env*/, jclass /*clazz*/, jint level, jboolean charge, jint chargeType);
61 andreas 771
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_PhoneCallState_informPhoneState(JNIEnv *env, jclass cl, jboolean call, jstring pnumber);
772
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Logger_logger(JNIEnv *env, jclass cl, jint mode, jstring msg);
130 andreas 773
    JNIEXPORT void JNICALL Java_org_qtproject_theosys_Orientation_informTPanelOrientation(JNIEnv */*env*/, jclass /*clazz*/, jint orientation);
36 andreas 774
}
775
#endif  // __ANDROID__
776
 
3 andreas 777
#endif