Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 andreas 1
/*
193 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 __TSUBPAGE_H__
20
#define __TSUBPAGE_H__
21
 
22
#include <string>
23
#include <vector>
24
#include "tbutton.h"
25
#include "tvalidatefile.h"
4 andreas 26
#include "tpalette.h"
7 andreas 27
#include "tfont.h"
201 andreas 28
#include "tpageinterface.h"
3 andreas 29
 
11 andreas 30
typedef struct RECT_T
31
{
32
    int left{0};
33
    int top{0};
34
    int width{0};
35
    int height{0};
36
}RECT_T;
37
 
203 andreas 38
class TSubPage : public TValidateFile, public TPageInterface
3 andreas 39
{
40
    public:
41
        TSubPage(const std::string& name);
42
        ~TSubPage();
43
 
4 andreas 44
        void setPalette(TPalette *pal) { mPalette = pal; }
45
 
3 andreas 46
        int getNumber() { return mSubpage.pageID; }
47
        std::string& getName() { return mSubpage.name; }
201 andreas 48
        PAGE_T& getSubPage() { return mSubpage; }
11 andreas 49
        std::string& getGroupName() { return mSubpage.group; }
5 andreas 50
        int getLeft() { return mSubpage.left; }
15 andreas 51
        void setLeft(int l) { mSubpage.left = l; }
5 andreas 52
        int getTop() { return mSubpage.top; }
15 andreas 53
        void setTop(int t) { mSubpage.top = t; }
5 andreas 54
        int getWidth() { return mSubpage.width; }
15 andreas 55
        void setWidth(int w) { mSubpage.width = w; }
5 andreas 56
        int getHeight() { return mSubpage.height; }
15 andreas 57
        void setHeight(int h) { mSubpage.height = h; }
58
        RECT_T getRegion();
14 andreas 59
        int getZOrder() { if (mVisible) return mZOrder; else return -1; }
60
        void setZOrder(int z) { mZOrder = z; }
11 andreas 61
        void setGroup(const std::string& group) { mSubpage.group = group; }
12 andreas 62
        void setModal(int m) { mSubpage.modal = m; }
5 andreas 63
        bool isModal() { return (mSubpage.modal != 0); }
15 andreas 64
        SHOWEFFECT getShowEffect() { return mSubpage.showEffect; }
65
        void setShowEffect(SHOWEFFECT se) { mSubpage.showEffect = se; }
66
        int getShowTime() { return mSubpage.showTime; }
67
        void setShowTime(int t) { mSubpage.showTime = t; }
68
        void setShowEndPosition(int x, int y) { mSubpage.showX = x; mSubpage.showY = y; }
69
        SHOWEFFECT getHideEffect() { return mSubpage.hideEffect; }
70
        void setHideEffect(SHOWEFFECT he) { mSubpage.hideEffect = he; }
71
        void setHideEndPosition(int x, int y) { mSubpage.hideX = x; mSubpage.hideY = y; }
72
        int getHideTime() { return mSubpage.hideTime; }
73
        void setHideTime(int t) { mSubpage.hideTime = t; }
74
        int getTimeout() { return mSubpage.timeout; }
75
        void setTimeout(int t) { mSubpage.timeout = t; }
11 andreas 76
        bool isVisible() { return mVisible; }
154 andreas 77
        ulong getHandle() { return ((mSubpage.pageID << 16) & 0xffff0000); }
6 andreas 78
        void show();
11 andreas 79
        void drop();
80
        void doClick(int x, int y, bool pressed);
54 andreas 81
        void startTimer();
82
        void stopTimer() { mTimerRunning = false; }
38 andreas 83
        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; }
6 andreas 84
        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; }
11 andreas 85
        void regCallDropSubPage(std::function<void (ulong handle)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
21 andreas 86
        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; };
3 andreas 87
 
88
    protected:
89
        void initialize();
53 andreas 90
        void runTimer();
43 andreas 91
#ifdef  _SCALE_SKIA_
31 andreas 92
        void calcPosition(int im_width, int im_height, int *left, int *top, bool scale = false);
43 andreas 93
#else
94
        void calcPosition(int im_width, int im_height, int *left, int *top);
95
#endif
3 andreas 96
    private:
38 andreas 97
        std::function<void (ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color)> _setBackground{nullptr};
6 andreas 98
        std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
11 andreas 99
        std::function<void (ulong handle)> _callDropSubPage{nullptr};
21 andreas 100
        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};
6 andreas 101
 
14 andreas 102
        bool mVisible{false};                   // TRUE = subpage is visible
103
        std::string mFName;                     // The file name of the page
104
        std::string mFile;                      // The path and file name of the page
105
        TPalette *mPalette{nullptr};            // The color palette
201 andreas 106
        PAGE_T mSubpage;                        // Parameters of the subpage
14 andreas 107
        int mZOrder{-1};                        // The Z-Order of the subpage if it is visible
53 andreas 108
        std::atomic<bool>mTimerRunning{false};  // TRUE= timer is running
109
        std::thread mThreadTimer;               // The thread started if a timeout is defined.
199 andreas 110
        std::vector<LIST_t> mLists;             // Lists of subpage
3 andreas 111
};
112
 
113
#endif