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