Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
72 andreas 1
/*
99 andreas 2
 * Copyright (C) 2021, 2022 by Andreas Theofilu <andreas@theosys.at>
72 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 __TSYSTEMDRAW_H__
20
#define __TSYSTEMDRAW_H__
21
 
22
#include <string>
23
#include <vector>
24
#include <functional>
25
 
26
#include <expat.h>
27
 
28
#include "tvalidatefile.h"
29
 
99 andreas 30
typedef enum SLIDER_GRTYPE_t
31
{
32
    SGR_TOP,
33
    SGR_BOTTOM,
34
    SGR_LEFT,
35
    SGR_RIGHT,
36
    SGR_HORIZONTAL,
37
    SGR_VERTICAL
38
}SLIDER_GRTYPE_t;
39
 
72 andreas 40
typedef struct FAMILY_t
41
{
42
    std::string name;
43
    std::vector<std::string> member;
73 andreas 44
}FAMILY_t;
72 andreas 45
 
73 andreas 46
typedef struct BORDER_STYLE_t
47
{
48
    std::string name;
49
    std::string off;
50
    std::string on;
51
    std::string drag;
52
    std::string drop;
53
    std::vector<int> g3Equiv;
54
}BORDER_STYLE_t;
55
 
79 andreas 56
typedef struct BORDER_DATA_t
57
{
58
    std::string name;
59
    std::string baseFile;
60
    int multiColor;
61
    int fillTop;
62
    int fillLeft;
63
    int fillBottom;
64
    int fillRight;
65
    int textTop;
66
    int textLeft;
67
    int textBottom;
68
    int textRight;
69
    int idealWidth;
70
    int idealHeight;
71
    int minHeight;
72
    int minWidth;
73
    int incHeight;
74
    int incWidth;
75
}BORDER_DATA_t;
76
 
73 andreas 77
typedef struct CURSOR_STYLE_t
78
{
79
    std::string name;
80
    std::string baseFile;
81
    int multiColor;
82
    std::vector<int> g3Equiv;
83
}CURSOR_STYLE_t;
84
 
85
typedef struct SLIDER_STYLE_t
86
{
87
    std::string name;
88
    std::string baseFile;
89
    int multiColor;
90
    int incRepeat;
91
    int minSize;
92
    int fixedSize;
93
    std::vector<int> g3Equiv;
94
}SLIDER_STYLE_t;
95
 
96
typedef struct EFFECT_STYLE_t
97
{
98
    std::string name;
99
    int number;
100
    int startx;
101
    int starty;
102
    int height;
103
    int width;
104
    int cutout;
105
    std::string pixelMap;
106
}EFFECT_STYLE_t;
107
 
108
typedef struct POPUP_EFFECT_t
109
{
110
    std::string name;
111
    int number;
112
    int valueUsed;
113
}POPUP_EFFECT_t;
114
 
72 andreas 115
typedef struct DRAW_t
116
{
73 andreas 117
    std::vector<FAMILY_t> borders;
118
    std::vector<BORDER_STYLE_t> borderStyles;
79 andreas 119
    std::vector<BORDER_DATA_t> borderData;
73 andreas 120
    std::vector<FAMILY_t> cursors;
121
    std::vector<CURSOR_STYLE_t> cursorStyles;
122
    std::vector<FAMILY_t> sliders;
123
    std::vector<SLIDER_STYLE_t> sliderStyles;
124
    std::vector<FAMILY_t> effects;
125
    std::vector<EFFECT_STYLE_t> effectStyles;
126
    std::vector<POPUP_EFFECT_t> popupEffects;
72 andreas 127
}DRAW_t;
128
 
79 andreas 129
typedef struct BORDER_t
130
{
131
    std::string bl;         // bottom left corner
132
    std::string b;          // bottom
133
    std::string br;         // bottom right corner
134
    std::string r;          // right
135
    std::string tr;         // top right corner
136
    std::string t;          // top
137
    std::string tl;         // top left corner
138
    std::string l;          // left
139
    BORDER_DATA_t border;   // Border data
81 andreas 140
    BORDER_STYLE_t bdStyle; // The border style data
79 andreas 141
}BORDER_t;
142
 
99 andreas 143
typedef struct SLIDER_t
144
{
145
    SLIDER_GRTYPE_t type;   //<! The type of the file the path is pointing to
146
    std::string path;       //<! The path and file name of the graphics mask file.
147
    std::string pathAlpha;  //<! The path and file name of the graphics file containing the alpha part of the image.
148
}SLIDER_t;
149
 
150
/**
151
 * @brief Class to manage system resources like borders, sliders, ...
152
 *
153
 * \c TSystemDraw reads the system configuration file draw.xma. This is
154
 * usualy located in the system directory __system/graphics.
155
 */
72 andreas 156
class TSystemDraw : public TValidateFile
157
{
158
    public:
79 andreas 159
        typedef enum LINE_TYPE_t
160
        {
161
            LT_OFF,
162
            LT_ON,
163
            LT_DRAG,
164
            LT_DROP
165
        }LINE_TYPE_t;
166
 
72 andreas 167
        TSystemDraw(const std::string& path);
168
        ~TSystemDraw();
169
 
170
        bool loadConfig();
99 andreas 171
 
79 andreas 172
        bool getBorder(const std::string& family, LINE_TYPE_t lt, BORDER_t *border);
173
        bool existBorder(const std::string& family);
81 andreas 174
        int getBorderWidth(const std::string& family, LINE_TYPE_t lt = LT_OFF);
175
        int getBorderHeight(const std::string& family, LINE_TYPE_t lt = LT_OFF);
72 andreas 176
 
99 andreas 177
        bool existSlider(const std::string& slider);
178
        bool getSlider(const std::string& slider, SLIDER_STYLE_t *style);
179
        std::vector<SLIDER_t> getSliderFiles(const std::string& slider);
180
 
81 andreas 181
    protected:
182
        static void startElement(void *, const XML_Char *name, const XML_Char **);
183
        static void XMLCALL endElement(void *userData, const XML_Char *name);
184
        static void XMLCALL CharacterDataHandler(void *userData, const XML_Char *s, int len);
185
 
186
 
187
    private:
72 andreas 188
        typedef enum XELEMENTS_t
189
        {
190
            X_NONE,
79 andreas 191
            X_BORDER,
72 andreas 192
            X_BORDER_DATA,
193
            X_BORDER_FAMILY,
73 andreas 194
            X_BORDER_STYLE,
72 andreas 195
            X_CURSOR_DATA,
196
            X_CURSOR_FAMILY,
73 andreas 197
            X_CURSOR_STYLE,
72 andreas 198
            X_SLIDER_DATA,
199
            X_SLIDER_FAMILY,
73 andreas 200
            X_SLIDER_STYLE,
72 andreas 201
            X_EFFECT_DATA,
202
            X_EFFECT_FAMILY,
73 andreas 203
            X_EFFECT_STYLE,
72 andreas 204
            X_POPUP_EFFECT_DATA,
205
            X_POPUP_EFFECT
206
        }XELEMENTS_t;
207
 
208
 
209
        std::string mPath;          // The path to the system directory tree
210
        bool mValid{false};         // TRUE = the path mPath is a valid directory
211
        bool mHaveBorders{false};   // TRUE = system directory borders exist
212
        bool mHaveCursors{false};   // TRUE = system directory cursors exist
213
        bool mHaveFonts{false};     // TRUE = system directory fonts exist
214
        bool mHaveImages{false};    // TRUE = system directory images exist
215
        bool mHaveSliders{false};   // TRUE = system directory sliders exist
216
 
217
        DRAW_t mDraw;
218
 
219
        static XELEMENTS_t mActData;
220
        static XELEMENTS_t mActFamily;
221
        static std::string mActElement;
222
};
223
 
224
#endif