Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
202 andreas 1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
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 __TPAGEINTERFACE_H__
20
#define __TPAGEINTERFACE_H__
21
 
211 andreas 22
#include <functional>
23
 
202 andreas 24
#include "tfont.h"
25
#include "tbutton.h"
26
 
206 andreas 27
#define REGULAR_PAGE_START              0
28
#define REGULAR_SUBPAGE_START           500
29
 
30
#define SYSTEM_PAGE_START               5000
31
#define SYSTEM_SUBPAGE_START            5500
32
 
208 andreas 33
#define SYSTEM_PAGE_LOGGING             5001
34
#define SYSTEM_PAGE_LOG_TXLOGFILE       22
35
#define SYSTEM_PAGE_LOG_BTRESET         23
36
#define SYSTEM_PAGE_LOG_BTFILE          24
37
 
206 andreas 38
#define SYSTEM_PAGE_CONTROLLER          5002
39
#define SYSTEM_PAGE_CTRL_SURFACE        23
40
#define SYSTEM_PAGE_CTRL_DOWNLOAD       27
41
#define SYSTEM_SUBPAGE_SURFACE          5502
42
 
43
#define SYSTEM_PAGE_SOUND               5005
44
#define SYSTEM_PAGE_SOUND_TXSYSSOUND    10
45
#define SYSTEM_PAGE_SOUND_TXSINGLEBEEP  12
46
#define SYSTEM_PAGE_SOUND_TXDOUBLEBEEP  14
47
#define SYSTEM_SUBPAGE_SYSTEMSOUND      5503
48
#define SYSTEM_SUBPAGE_SINGLEBEEP       5504
49
#define SYSTEM_SUBPAGE_DOUBLEBEEP       5505
50
 
51
#define SYSTEM_LIST_SURFACE             2023
52
#define SYSTEM_LIST_SYSTEMSOUND         2024
53
#define SYSTEM_LIST_SINGLEBEEP          2025
54
#define SYSTEM_LIST_DOUBLEBEEP          2026
55
 
56
#define SYSTEM_ITEM_SYSGAIN             6
57
#define SYSTEM_ITEM_CONNSTATE           8
58
#define SYSTEM_ITEM_SYSVOLUME           9
59
#define SYSTEM_ITEM_SOUNDSWITCH         17
60
#define SYSTEM_ITEM_FTPSURFACE          25
61
#define SYSTEM_ITEM_SETUPPAGE           73
62
#define SYSTEM_ITEM_SHUTDOWN            80
63
#define SYSTEM_ITEM_CONNSTRENGTH        81
209 andreas 64
#define SYSTEM_ITEM_NETLINX_IP          122
65
#define SYSTEM_ITEM_NETLINX_CHANNEL     123
66
#define SYSTEM_ITEM_NETLINX_PORT        124
67
 
206 andreas 68
#define SYSTEM_ITEM_STANDARDTIME        141
69
#define SYSTEM_ITEM_TIMEAMPM            142
70
#define SYSTEM_ITEM_TIME24              143
71
#define SYSTEM_ITEM_NETLINXPORT         144
72
#define SYSTEM_ITEM_DATEWEEKDAY         151
73
#define SYSTEM_ITEM_DATEMMDD            152
74
#define SYSTEM_ITEM_DATEDDMM            153
75
#define SYSTEM_ITEM_DATEMMDDYYYY        154
76
#define SYSTEM_ITEM_DATEDDMMYYYY        155
77
#define SYSTEM_ITEM_DATEMONDDYYYY       156
78
#define SYSTEM_ITEM_DATEDDMONYYYY       157
79
#define SYSTEM_ITEM_DATEYYYYMMDD        158
80
#define SYSTEM_ITEM_SOUNDPLAYTESTSOUND  159
81
#define SYSTEM_ITEM_VOLUMEUP            171
82
#define SYSTEM_ITEM_VOLUMEDOWN          172
83
#define SYSTEM_ITEM_VOLUMEMUTE          173
209 andreas 84
 
85
#define SYSTEM_ITEM_NETLINX_PTYPE       199
86
 
206 andreas 87
#define SYSTEM_ITEM_BATTERYCHARGING     234
88
#define SYSTEM_ITEM_BATTERYLEVEL        242
209 andreas 89
 
90
#define SYSTEM_ITEM_SINGLEBEEP          404
91
#define SYSTEM_ITEM_DOUBLEBEEP          405
92
 
206 andreas 93
#define SYSTEM_ITEM_BTSAVESETTINGS      412
94
#define SYSTEM_ITEM_BTCANCELSETTINGS    413
95
#define SYSTEM_ITEM_SIPENABLE           416
209 andreas 96
#define SYSTEM_ITEM_SIPPROXY            418
97
#define SYSTEM_ITEM_SIPPORT             419
98
#define SYSTEM_ITEM_SIPSTUN             420
99
#define SYSTEM_ITEM_SIPDOMAIN           421
100
#define SYSTEM_ITEM_SIPUSER             422
101
#define SYSTEM_ITEM_SIPPASSWORD         423
206 andreas 102
 
209 andreas 103
#define SYSTEM_ITEM_SYSTEMSOUND         1143
104
 
206 andreas 105
#define SYSTEM_ITEM_DEBUGINFO           2000
106
#define SYSTEM_ITEM_DEBUGWARNING        2001
107
#define SYSTEM_ITEM_DEBUGERROR          2002
108
#define SYSTEM_ITEM_DEBUGTRACE          2003
109
#define SYSTEM_ITEM_DEBUGDEBUG          2004
110
#define SYSTEM_ITEM_DEBUGPROTOCOL       2005
111
#define SYSTEM_ITEM_DEBUGALL            2006
112
#define SYSTEM_ITEM_DEBUGPROFILE        2007
113
#define SYSTEM_ITEM_DEBUGLONG           2008
208 andreas 114
#define SYSTEM_ITEM_LOGLOGFILE          2009
115
#define SYSTEM_ITEM_LOGRESET            2010
116
#define SYSTEM_ITEM_LOGFILEOPEN         2011
117
 
209 andreas 118
#define SYSTEM_ITEM_FTPUSER             2020
119
#define SYSTEM_ITEM_FTPPASSWORD         2021
206 andreas 120
#define SYSTEM_ITEM_FTPDOWNLOAD         2030
121
#define SYSTEM_ITEM_FTPPASSIVE          2031
122
 
123
#define SYSTEM_ITEM_SOUNDPLAYSYSSOUND   2050
124
#define SYSTEM_ITEM_SOUNDPLAYBEEP       2051
125
#define SYSTEM_ITEM_SOUNDPLAYDBEEP      2052
126
#define SYSTEM_ITEM_SIPIPV4             2060
127
#define SYSTEM_ITEM_SIPIPV6             2061
128
#define SYSTEM_ITEM_SIPIPHONE           2062
129
#define SYSTEM_ITEM_VIEWSCALEFIT        2070
130
#define SYSTEM_ITEM_VIEWBANNER          2071
131
#define SYSTEM_ITEM_VIEWNOTOOLBAR       2072
132
#define SYSTEM_ITEM_VIEWTOOLBAR         2073
133
#define SYSTEM_ITEM_VIEWROTATE          2074
134
 
202 andreas 135
enum SHOWEFFECT
136
{
137
    SE_NONE,
138
    SE_FADE,
139
    SE_SLIDE_LEFT,
140
    SE_SLIDE_RIGHT,
141
    SE_SLIDE_TOP,
142
    SE_SLIDE_BOTTOM,
143
    SE_SLIDE_LEFT_FADE,
144
    SE_SLIDE_RIGHT_FADE,
145
    SE_SLIDE_TOP_FADE,
146
    SE_SLIDE_BOTTOM_FADE
147
};
148
 
149
typedef SHOWEFFECT SHOWEFFECT_t;
150
 
151
typedef struct ANIMATION_t
152
{
153
    SHOWEFFECT_t showEffect{SE_NONE};
154
    int showTime{0};
155
    SHOWEFFECT_t hideEffect{SE_NONE};
156
    int hideTime{0};
157
}ANIMATION_t;
158
 
159
typedef struct PAGE_T
160
{
161
    std::string popupType;                  // The type of the popup (popup only)
162
    int pageID{0};                          // Unique ID of popup/page
163
    std::string name;                       // The name of the popup/page
164
    int left{0};                            // Left position of popup (always 0 for pages)
165
    int top{0};                             // Top position of popup (always 0 for pages)
166
    int width{0};                           // Width of popup
167
    int height{0};                          // Height of popup
168
    int modal{0};                           // 0 = Popup/Page = non modal
169
    std::string group;                      // Name of the group the popup belongs (popup only)
170
    int timeout{0};                         // Time after the popup hides in 1/10 seconds (popup only)
171
    SHOWEFFECT showEffect{SE_NONE};         // The effect when the popup is shown (popup only)
172
    int showTime{0};                        // The time reserved for the show effect (popup only)
173
    int showX{0};                           // End of show effect position (by default "left+width"); (popup only)
174
    int showY{0};                           // End of show effect position (by default "top+height"); (popup only)
175
    SHOWEFFECT hideEffect{SE_NONE};         // The effect when the popup hides (popup only)
176
    int hideTime{0};                        // The time reserved for the hide effect (popup only)
177
    int hideX{0};                           // End of hide effect position (by default "left"); (popup only)
178
    int hideY{0};                           // End of hide effect position (by default "top"); (popup only)
179
    std::vector<Button::SR_T> sr;           // Page/Popup description
180
}PAGE_T;
181
 
182
/**
183
 * This class in an interface to manage pages and subpages. Both classes of
184
 * TPage and TSubpage have a lot of identical functions. This functions are
185
 * in this class.
186
 */
187
class TPageInterface
188
{
189
    public:
206 andreas 190
        virtual ~TPageInterface() {}
191
 
202 andreas 192
        bool drawText(PAGE_T& pinfo, SkBitmap *img);
193
 
194
        virtual int getNumber() = 0;
195
        virtual std::string& getName() = 0;
196
        virtual void show() = 0;
197
        virtual void drop() = 0;
198
 
199
        void setButtons(Button::BUTTONS_T *bt) { mButtons = bt; }
200
        Button::BUTTONS_T *getButtons() { return mButtons; }
203 andreas 201
        Button::BUTTONS_T *addButton(Button::TButton* button);
202
        Button::TButton *getButton(int id);
203
        std::vector<Button::TButton *> getButtons(int ap, int ad);
204
        std::vector<Button::TButton *> getAllButtons();
205
        bool hasButton(int id);
206
        bool sortButtons();
207
        Button::TButton *getFirstButton();
208
        Button::TButton *getNextButton();
209
        Button::TButton *getLastButton();
210
        Button::TButton *getPreviousButton();
202 andreas 211
 
212
        void setSR(std::vector<Button::SR_T>& s) { sr = s; }
213
        std::vector<Button::SR_T>& getSR() { return sr; }
214
 
215
        void setFonts(TFont *f) { mFonts = f; }
216
        TFont *getFonts() { return mFonts; }
217
 
205 andreas 218
        void setSelectedRow(ulong handle, int row);
219
        int getSelectedRow(ulong handle);
220
        std::string getSelectedItem(ulong handle);
221
 
204 andreas 222
        template<typename T>
223
        inline void registerListCallback(Button::TButton *button, T *pg)
224
        {
225
            if (!button || !pg)
226
                return;
202 andreas 227
 
211 andreas 228
            button->regCallListContent(std::bind(&TPageInterface::getListContent, pg, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6));
229
            button->regCallListRow(std::bind(&TPageInterface::getListRow, pg, std::placeholders::_1, std::placeholders::_2));
230
            button->regCallGlobalSettings(std::bind(&TPageInterface::setGlobalSettings, pg, std::placeholders::_1));
204 andreas 231
        }
232
 
206 andreas 233
        static bool isSystemPage(int ID) { return ID >= SYSTEM_PAGE_START && ID < SYSTEM_SUBPAGE_START; }
234
        static bool isSystemSubPage(int ID) { return ID >= SYSTEM_SUBPAGE_START; }
235
        static bool isRegularPage(int ID) { return ID > REGULAR_PAGE_START && ID < REGULAR_SUBPAGE_START; }
236
        static bool isRegularSubPage(int ID) { return ID >= REGULAR_SUBPAGE_START && ID < SYSTEM_PAGE_START; }
237
 
202 andreas 238
    protected:
239
        typedef struct LIST_t
240
        {
205 andreas 241
            ulong handle{0};
242
            int ap{0};
243
            int ta{0};
244
            int ti{0};
245
            int rows{0};
246
            int columns{0};
247
            int selected{-1};
202 andreas 248
            std::vector<std::string> list;
249
        }LIST_t;
250
 
204 andreas 251
        std::vector<std::string> getListContent(ulong handle, int ap, int ta, int ti, int rows, int columns);
252
        std::string getListRow(int ti, int row);
253
        void setGlobalSettings(Button::TButton *button);
254
 
202 andreas 255
    private:
203 andreas 256
        Button::POSITION_t calcImagePosition(PAGE_T *page, int width, int height, Button::CENTER_CODE cc, int line);
204 andreas 257
        int calcLineHeight(const std::string& text, SkFont& font);
258
        int numberLines(const std::string& str);
205 andreas 259
        int getSystemSelection(int ta, std::vector<std::string>& list);
203 andreas 260
 
202 andreas 261
        Button::BUTTONS_T *mButtons{nullptr};    // Chain of buttons
203 andreas 262
        int mLastButton{0};             // Internal counter for iterating through button chain.
202 andreas 263
        std::vector<Button::SR_T> sr;
264
        TFont *mFonts{nullptr};         // Holds the class with the font list
204 andreas 265
        std::vector<LIST_t> mLists;     // Lists of page
202 andreas 266
};
267
 
268
#endif