Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 andreas 1
/*
201 andreas 2
 * Copyright (C) 2020 to 2022 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 "tsubpage.h"
4 andreas 26
#include "tpalette.h"
201 andreas 27
#include "tpageinterface.h"
2 andreas 28
 
14 andreas 29
#define ZORDER_INVALID      -1
154 andreas 30
#define MAX_PAGE_ID         500
14 andreas 31
 
154 andreas 32
 
3 andreas 33
typedef struct PAGECHAIN_T
2 andreas 34
{
3 andreas 35
    TSubPage *subpage{nullptr}; // Ponter to subpage
154 andreas 36
    PAGECHAIN_T *prev{nullptr}; // Pointer to previous element
14 andreas 37
    PAGECHAIN_T *next{nullptr}; // Pointer to next element
3 andreas 38
}PAGECHAIN_T;
39
 
203 andreas 40
class TPage : public TValidateFile, public TPageInterface
3 andreas 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; }
3 andreas 49
 
201 andreas 50
        int getWidth() { return mPage.width; }
51
        int getHeight() { return mPage.height; }
52
        void setName(const std::string& n) { mPage.name = n; }
53
        std::string& getName() { return mPage.name; }
54
        int getNumber() { return mPage.pageID; }
2 andreas 55
        bool isVisilble() { return mVisible; }
217 andreas 56
        ulong getHandle() { return (mPage.pageID << 16) & 0xffff0000; }
2 andreas 57
 
3 andreas 58
        PAGECHAIN_T *addSubPage(TSubPage *pg);
4 andreas 59
        TSubPage *getSubPage(int pageID);
60
        TSubPage *getSubPage(const std::string& name);
61
        TSubPage *getFirstSubPage();
62
        TSubPage *getNextSubPage();
154 andreas 63
        TSubPage *getPrevSubPage();
64
        TSubPage *getLastSubPage();
3 andreas 65
        bool removeSubPage(int ID);
66
        bool removeSubPage(const std::string& nm);
14 andreas 67
        int getActZOrder() { return mZOrder; }
152 andreas 68
        int getNextZOrder();
151 andreas 69
        int decZOrder();
14 andreas 70
        void resetZOrder() { mZOrder = ZORDER_INVALID; }
3 andreas 71
 
38 andreas 72
        void registerCallback(std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> setBackground) { _setBackground = setBackground; }
7 andreas 73
        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 74
        void regCallDropPage(std::function<void (ulong handle)> callDropPage) { _callDropPage = callDropPage; }
75
        void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
21 andreas 76
        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 77
 
78
        void show();
12 andreas 79
        void drop();
151 andreas 80
        void sortSubpages();
5 andreas 81
 
3 andreas 82
    protected:
203 andreas 83
//        bool sortButtons();
43 andreas 84
#ifdef _SCALE_SKIA_
31 andreas 85
        void calcPosition(int im_width, int im_height, int *left, int *top, bool scale=false);
43 andreas 86
#else
87
        void calcPosition(int im_width, int im_height, int *left, int *top);
88
#endif
89
    private:
90
        void addProgress();
3 andreas 91
 
38 andreas 92
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> _setBackground{nullptr};
7 andreas 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
201 andreas 99
        PAGE_T mPage;                   // Definitions of page
3 andreas 100
        std::vector<Button::SR_T> sr;   // Background details
101
        std::string mFile;              // The name of the file where the page is defined.
102
        bool mVisible{false};           // true = Page is visible
4 andreas 103
        TPalette *mPalette{nullptr};    // The color palette
2 andreas 104
 
3 andreas 105
        PAGECHAIN_T *mSubPages{nullptr};// Subpages related to this page
4 andreas 106
        int mLastSubPage{0};            // Stores the number of the last subpage
14 andreas 107
        int mZOrder{ZORDER_INVALID};    // The Z-Order of the subpages
198 andreas 108
        std::vector<LIST_t> mLists;     // Lists of page
2 andreas 109
};
110
 
111
 
112
 
3 andreas 113
#endif // _TPAGE_H