Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 andreas 1
/*
289 andreas 2
 * Copyright (C) 2020 to 2023 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"
201 andreas 27
#include "tpageinterface.h"
306 andreas 28
#include "tintborder.h"
3 andreas 29
 
289 andreas 30
class TBitmap;
31
 
11 andreas 32
typedef struct RECT_T
33
{
34
    int left{0};
35
    int top{0};
36
    int width{0};
37
    int height{0};
38
}RECT_T;
39
 
306 andreas 40
class TSubPage : public TValidateFile, public TPageInterface, public Border::TIntBorder
3 andreas 41
{
42
    public:
43
        TSubPage(const std::string& name);
44
        ~TSubPage();
45
 
4 andreas 46
        void setPalette(TPalette *pal) { mPalette = pal; }
47
 
3 andreas 48
        int getNumber() { return mSubpage.pageID; }
286 andreas 49
        std::string& getPopupType() { return mSubpage.popupType; }
3 andreas 50
        std::string& getName() { return mSubpage.name; }
201 andreas 51
        PAGE_T& getSubPage() { return mSubpage; }
11 andreas 52
        std::string& getGroupName() { return mSubpage.group; }
5 andreas 53
        int getLeft() { return mSubpage.left; }
15 andreas 54
        void setLeft(int l) { mSubpage.left = l; }
5 andreas 55
        int getTop() { return mSubpage.top; }
15 andreas 56
        void setTop(int t) { mSubpage.top = t; }
5 andreas 57
        int getWidth() { return mSubpage.width; }
15 andreas 58
        void setWidth(int w) { mSubpage.width = w; }
5 andreas 59
        int getHeight() { return mSubpage.height; }
15 andreas 60
        void setHeight(int h) { mSubpage.height = h; }
61
        RECT_T getRegion();
14 andreas 62
        int getZOrder() { if (mVisible) return mZOrder; else return -1; }
63
        void setZOrder(int z) { mZOrder = z; }
11 andreas 64
        void setGroup(const std::string& group) { mSubpage.group = group; }
12 andreas 65
        void setModal(int m) { mSubpage.modal = m; }
5 andreas 66
        bool isModal() { return (mSubpage.modal != 0); }
15 andreas 67
        SHOWEFFECT getShowEffect() { return mSubpage.showEffect; }
68
        void setShowEffect(SHOWEFFECT se) { mSubpage.showEffect = se; }
69
        int getShowTime() { return mSubpage.showTime; }
70
        void setShowTime(int t) { mSubpage.showTime = t; }
71
        void setShowEndPosition(int x, int y) { mSubpage.showX = x; mSubpage.showY = y; }
351 andreas 72
        void getShowEndPosition(int *x, int *y) { if (x) *x = mSubpage.showX; if (y) *y = mSubpage.showY; }
15 andreas 73
        SHOWEFFECT getHideEffect() { return mSubpage.hideEffect; }
74
        void setHideEffect(SHOWEFFECT he) { mSubpage.hideEffect = he; }
75
        void setHideEndPosition(int x, int y) { mSubpage.hideX = x; mSubpage.hideY = y; }
348 andreas 76
        void getHideEndPosition(int *x, int *y) { if (x) *x = mSubpage.hideX; if (y) *y = mSubpage.hideY; }
15 andreas 77
        int getHideTime() { return mSubpage.hideTime; }
78
        void setHideTime(int t) { mSubpage.hideTime = t; }
79
        int getTimeout() { return mSubpage.timeout; }
80
        void setTimeout(int t) { mSubpage.timeout = t; }
11 andreas 81
        bool isVisible() { return mVisible; }
154 andreas 82
        ulong getHandle() { return ((mSubpage.pageID << 16) & 0xffff0000); }
306 andreas 83
        ulong getParent() { return mParent; }
84
        void setParent(ulong handle) { mParent = handle; }
281 andreas 85
        std::string getFillColor() { return mSubpage.sr[0].cf; }
86
        std::string getTextColor() { return mSubpage.sr[0].ct; }
289 andreas 87
        SkBitmap& getBgImage();
281 andreas 88
 
6 andreas 89
        void show();
11 andreas 90
        void drop();
91
        void doClick(int x, int y, bool pressed);
54 andreas 92
        void startTimer();
93
        void stopTimer() { mTimerRunning = false; }
262 andreas 94
#ifdef _OPAQUE_SKIA_
289 andreas 95
        void registerCallback(std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> setBackground) { _setBackground = setBackground; }
262 andreas 96
#else
289 andreas 97
        void registerCallback(std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> setBackground) { _setBackground = setBackground; }
262 andreas 98
#endif
391 andreas 99
        void registerCallbackDB(std::function<void(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> displayButton) { _displayButton = displayButton; }
350 andreas 100
        void regCallDropSubPage(std::function<void (ulong handle, ulong parent)> callDropSubPage) { _callDropSubPage = callDropSubPage; }
21 andreas 101
        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 102
 
103
    protected:
104
        void initialize();
53 andreas 105
        void runTimer();
43 andreas 106
#ifdef  _SCALE_SKIA_
31 andreas 107
        void calcPosition(int im_width, int im_height, int *left, int *top, bool scale = false);
43 andreas 108
#else
109
        void calcPosition(int im_width, int im_height, int *left, int *top);
110
#endif
3 andreas 111
    private:
262 andreas 112
#ifdef _OPAQUE_SKIA_
289 andreas 113
        std::function<void (ulong handle, TBitmap image, int width, int height, ulong color)> _setBackground{nullptr};
262 andreas 114
#else
289 andreas 115
        std::function<void (ulong handle, TBitmap image, int width, int height, ulong color, int opacity)> _setBackground{nullptr};
262 andreas 116
#endif
391 andreas 117
        std::function<void (ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough, int marqtype, int marq)> _displayButton{nullptr};
350 andreas 118
        std::function<void (ulong handle, ulong parent)> _callDropSubPage{nullptr};
21 andreas 119
        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 120
 
14 andreas 121
        bool mVisible{false};                   // TRUE = subpage is visible
122
        std::string mFName;                     // The file name of the page
123
        std::string mFile;                      // The path and file name of the page
124
        TPalette *mPalette{nullptr};            // The color palette
201 andreas 125
        PAGE_T mSubpage;                        // Parameters of the subpage
306 andreas 126
        ulong mParent{0};                       // The handle of the parent page or view button
14 andreas 127
        int mZOrder{-1};                        // The Z-Order of the subpage if it is visible
289 andreas 128
        SkBitmap mBgImage;                      // The background image (cache).
53 andreas 129
        std::atomic<bool>mTimerRunning{false};  // TRUE= timer is running
130
        std::thread mThreadTimer;               // The thread started if a timeout is defined.
199 andreas 131
        std::vector<LIST_t> mLists;             // Lists of subpage
3 andreas 132
};
133
 
134
#endif