2 |
andreas |
1 |
/*
|
21 |
andreas |
2 |
* Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
|
2 |
andreas |
3 |
*
|
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
|
6 |
* the Free Software Foundation; either version 3 of the License, or
|
|
|
7 |
* (at your option) any later version.
|
|
|
8 |
*
|
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
* GNU General Public License for more details.
|
|
|
13 |
*
|
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
|
15 |
* along with this program; if not, write to the Free Software Foundation,
|
|
|
16 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
#ifndef __TPAGE_H__
|
|
|
20 |
#define __TPAGE_H__
|
|
|
21 |
|
|
|
22 |
#include <string>
|
3 |
andreas |
23 |
#include <vector>
|
|
|
24 |
#include "tvalidatefile.h"
|
|
|
25 |
#include "tpagelist.h"
|
|
|
26 |
#include "tsubpage.h"
|
|
|
27 |
#include "tconfig.h"
|
2 |
andreas |
28 |
#include "terror.h"
|
4 |
andreas |
29 |
#include "tpalette.h"
|
7 |
andreas |
30 |
#include "tfont.h"
|
2 |
andreas |
31 |
|
14 |
andreas |
32 |
#define ZORDER_INVALID -1
|
|
|
33 |
|
3 |
andreas |
34 |
typedef struct PAGECHAIN_T
|
2 |
andreas |
35 |
{
|
3 |
andreas |
36 |
TSubPage *subpage{nullptr}; // Ponter to subpage
|
14 |
andreas |
37 |
PAGECHAIN_T *next{nullptr}; // Pointer to next element
|
3 |
andreas |
38 |
}PAGECHAIN_T;
|
|
|
39 |
|
|
|
40 |
class TPage : public TValidateFile
|
|
|
41 |
{
|
2 |
andreas |
42 |
public:
|
|
|
43 |
TPage() {}
|
3 |
andreas |
44 |
TPage(const std::string& name);
|
|
|
45 |
~TPage();
|
2 |
andreas |
46 |
|
3 |
andreas |
47 |
void initialize(const std::string& name);
|
4 |
andreas |
48 |
void setPalette(TPalette *pal) { mPalette = pal; }
|
7 |
andreas |
49 |
void setFonts(TFont *ft) { mFonts = ft; }
|
3 |
andreas |
50 |
|
16 |
andreas |
51 |
int getWidth() { return width; }
|
|
|
52 |
int getHeight() { return height; }
|
3 |
andreas |
53 |
void setName(const std::string& n) { name = n; }
|
|
|
54 |
std::string& getName() { return name; }
|
|
|
55 |
int getNumber() { return pageID; }
|
2 |
andreas |
56 |
bool isVisilble() { return mVisible; }
|
14 |
andreas |
57 |
bool hasButton(int id);
|
|
|
58 |
Button::TButton *getButton(int id);
|
16 |
andreas |
59 |
std::vector<Button::TButton *> getButtons(int ap, int ad);
|
2 |
andreas |
60 |
|
3 |
andreas |
61 |
PAGECHAIN_T *addSubPage(TSubPage *pg);
|
4 |
andreas |
62 |
TSubPage *getSubPage(int pageID);
|
|
|
63 |
TSubPage *getSubPage(const std::string& name);
|
|
|
64 |
TSubPage *getFirstSubPage();
|
|
|
65 |
TSubPage *getNextSubPage();
|
3 |
andreas |
66 |
bool removeSubPage(int ID);
|
|
|
67 |
bool removeSubPage(const std::string& nm);
|
14 |
andreas |
68 |
int getActZOrder() { return mZOrder; }
|
|
|
69 |
int getNextZOrder() { mZOrder++; return mZOrder; }
|
|
|
70 |
int decZOrder() { if (mZOrder > 0) mZOrder--; return mZOrder; }
|
|
|
71 |
void resetZOrder() { mZOrder = ZORDER_INVALID; }
|
3 |
andreas |
72 |
|
|
|
73 |
Button::BUTTONS_T *addButton(Button::TButton *button);
|
|
|
74 |
|
5 |
andreas |
75 |
void registerCallback(std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)> setBackground) { _setBackground = setBackground; }
|
7 |
andreas |
76 |
void registerCallbackFT(std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww)> setText)
|
|
|
77 |
{ _setText = setText; }
|
|
|
78 |
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; }
|
12 |
andreas |
79 |
void regCallDropPage(std::function<void (ulong handle)> callDropPage) { _callDropPage = callDropPage; }
|
|
|
80 |
void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
|
21 |
andreas |
81 |
void regCallPlayVideo(std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> playVideo) { _playVideo = playVideo; };
|
5 |
andreas |
82 |
|
|
|
83 |
void show();
|
12 |
andreas |
84 |
void drop();
|
5 |
andreas |
85 |
|
3 |
andreas |
86 |
protected:
|
|
|
87 |
bool sortButtons();
|
31 |
andreas |
88 |
void calcPosition(int im_width, int im_height, int *left, int *top, bool scale=false);
|
3 |
andreas |
89 |
|
2 |
andreas |
90 |
private:
|
5 |
andreas |
91 |
std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color)> _setBackground{nullptr};
|
7 |
andreas |
92 |
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};
|
|
|
93 |
std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
|
12 |
andreas |
94 |
std::function<void (ulong handle)> _callDropPage{nullptr};
|
|
|
95 |
std::function<void (ulong handle)> _callDropSubPage{nullptr};
|
21 |
andreas |
96 |
std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> _playVideo{nullptr};
|
5 |
andreas |
97 |
|
3 |
andreas |
98 |
std::string mPath; // Path and name of the XML file
|
|
|
99 |
std::string name; // Name of the page
|
|
|
100 |
int pageID{0}; // Number of the page
|
|
|
101 |
int width; // Width of the page
|
|
|
102 |
int height; // height of the page
|
|
|
103 |
Button::BUTTONS_T *mButtons{nullptr}; // Chain of buttons
|
|
|
104 |
std::vector<Button::SR_T> sr; // Background details
|
|
|
105 |
std::string mFile; // The name of the file where the page is defined.
|
|
|
106 |
bool mVisible{false}; // true = Page is visible
|
4 |
andreas |
107 |
TPalette *mPalette{nullptr}; // The color palette
|
2 |
andreas |
108 |
|
3 |
andreas |
109 |
PAGECHAIN_T *mSubPages{nullptr};// Subpages related to this page
|
4 |
andreas |
110 |
int mLastSubPage{0}; // Stores the number of the last subpage
|
7 |
andreas |
111 |
TFont *mFonts{nullptr}; // Holds the class with the font list
|
14 |
andreas |
112 |
int mZOrder{ZORDER_INVALID}; // The Z-Order of the subpages
|
2 |
andreas |
113 |
};
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
3 |
andreas |
117 |
#endif // _TPAGE_H
|