Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2021, 2022 by Andreas Theofilu <andreas@theosys.at>
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
#include "tdirectory.h"
30
 
31
typedef enum SLIDER_GRTYPE_t
32
{
33
    SGR_TOP,
34
    SGR_BOTTOM,
35
    SGR_LEFT,
36
    SGR_RIGHT,
37
    SGR_HORIZONTAL,
38
    SGR_VERTICAL
39
}SLIDER_GRTYPE_t;
40
 
41
typedef struct FAMILY_t
42
{
43
    std::string name;
44
    std::vector<std::string> member;
45
}FAMILY_t;
46
 
47
typedef struct BORDER_STYLE_t
48
{
49
    std::string name;
50
    std::string off;
51
    std::string on;
52
    std::string drag;
53
    std::string drop;
54
    std::vector<int> g3Equiv;
55
}BORDER_STYLE_t;
56
 
57
typedef struct BORDER_DATA_t
58
{
59
    std::string name;
60
    std::string baseFile;
61
    int multiColor;
62
    int fillTop;
63
    int fillLeft;
64
    int fillBottom;
65
    int fillRight;
66
    int textTop;
67
    int textLeft;
68
    int textBottom;
69
    int textRight;
70
    int idealWidth;
71
    int idealHeight;
72
    int minHeight;
73
    int minWidth;
74
    int incHeight;
75
    int incWidth;
76
 
77
    void init()
78
    {
79
        multiColor = 0;
80
        fillTop = 0;
81
        fillLeft = 0;
82
        fillBottom = 0;
83
        fillRight = 0;
84
        textTop = 0;
85
        textLeft = 0;
86
        textBottom = 0;
87
        textRight = 0,
88
        idealWidth = 0;
89
        idealHeight = 0;
90
        minHeight = 0;
91
        minWidth = 0;
92
        incHeight = 0;
93
        incWidth = 0;
94
    }
95
}BORDER_DATA_t;
96
 
97
typedef struct CURSOR_STYLE_t
98
{
99
    std::string name;
100
    std::string baseFile;
101
    int multiColor;
102
    std::vector<int> g3Equiv;
103
 
104
    void init()
105
    {
106
        multiColor = 0;
107
    }
108
}CURSOR_STYLE_t;
109
 
110
typedef struct SLIDER_STYLE_t
111
{
112
    std::string name;
113
    std::string baseFile;
114
    int multiColor;
115
    int incRepeat;
116
    int minSize;
117
    int fixedSize;
118
    std::vector<int> g3Equiv;
119
 
120
    void init()
121
    {
122
        multiColor = 0;
123
        incRepeat = 0;
124
        minSize = 0;
125
        fixedSize = 0;
126
    }
127
}SLIDER_STYLE_t;
128
 
129
typedef struct EFFECT_STYLE_t
130
{
131
    std::string name;
132
    int number;
133
    int startx;
134
    int starty;
135
    int height;
136
    int width;
137
    int cutout;
138
    std::string pixelMap;
139
 
140
    void init()
141
    {
142
        number = 0;
143
        startx = 0;
144
        starty = 0;
145
        height = 0;
146
        width = 0;
147
        cutout = 0;
148
    }
149
}EFFECT_STYLE_t;
150
 
151
typedef struct POPUP_EFFECT_t
152
{
153
    std::string name;
154
    int number;
155
    int valueUsed;
156
 
157
    void init()
158
    {
159
        number = 0;
160
        valueUsed = 0;
161
    }
162
}POPUP_EFFECT_t;
163
 
164
typedef struct DRAW_t
165
{
166
    std::vector<FAMILY_t> borders;
167
    std::vector<BORDER_STYLE_t> borderStyles;
168
    std::vector<BORDER_DATA_t> borderData;
169
    std::vector<FAMILY_t> cursors;
170
    std::vector<CURSOR_STYLE_t> cursorStyles;
171
    std::vector<FAMILY_t> sliders;
172
    std::vector<SLIDER_STYLE_t> sliderStyles;
173
    std::vector<FAMILY_t> effects;
174
    std::vector<EFFECT_STYLE_t> effectStyles;
175
    std::vector<POPUP_EFFECT_t> popupEffects;
176
}DRAW_t;
177
 
178
typedef struct BORDER_t
179
{
180
    std::string bl;         // bottom left corner
181
    std::string b;          // bottom
182
    std::string br;         // bottom right corner
183
    std::string r;          // right
184
    std::string tr;         // top right corner
185
    std::string t;          // top
186
    std::string tl;         // top left corner
187
    std::string l;          // left
188
    std::string bl_alpha;   // bottom left corner
189
    std::string b_alpha;    // bottom
190
    std::string br_alpha;   // bottom right corner
191
    std::string r_alpha;    // right
192
    std::string tr_alpha;   // top right corner
193
    std::string t_alpha;    // top
194
    std::string tl_alpha;   // top left corner
195
    std::string l_alpha;    // left
196
    BORDER_DATA_t border;   // Border data
197
    BORDER_STYLE_t bdStyle; // The border style data
198
}BORDER_t;
199
 
200
typedef struct SLIDER_t
201
{
202
    SLIDER_GRTYPE_t type;   //<! The type of the file the path is pointing to
203
    std::string path;       //<! The path and file name of the graphics mask file.
204
    std::string pathAlpha;  //<! The path and file name of the graphics file containing the alpha part of the image.
205
}SLIDER_t;
206
 
207
typedef struct CURSOR_t
208
{
209
    std::string imageBase;  // The base image file.
210
    std::string imageAlpha; // The alpha image file.
211
}CURSOR_t;
212
 
213
/**
214
 * @brief Class to manage system resources like borders, sliders, ...
215
 *
216
 * \c TSystemDraw reads the system configuration file draw.xma. This is
217
 * usualy located in the system directory __system/graphics.
218
 */
219
class TSystemDraw : public TValidateFile
220
{
221
    public:
222
        typedef enum LINE_TYPE_t
223
        {
224
            LT_OFF,
225
            LT_ON,
226
            LT_DRAG,
227
            LT_DROP
228
        }LINE_TYPE_t;
229
 
230
        TSystemDraw(const std::string& path);
231
        ~TSystemDraw();
232
 
233
        bool loadConfig();
234
 
235
        bool getBorder(const std::string& family, LINE_TYPE_t lt, BORDER_t *border, const std::string& family2="", bool info=false);
236
        bool getBorderInfo(const std::string& family, LINE_TYPE_t lt, BORDER_t *border, const std::string& family2="");
237
        bool existBorder(const std::string& family);
238
        int getBorderWidth(const std::string& family, LINE_TYPE_t lt = LT_OFF);
239
        int getBorderHeight(const std::string& family, LINE_TYPE_t lt = LT_OFF);
240
 
241
        bool existSlider(const std::string& slider);
242
        bool getSlider(const std::string& slider, SLIDER_STYLE_t *style);
243
        std::vector<SLIDER_t> getSliderFiles(const std::string& slider);
244
        bool getCursor(const std::string& cursor, CURSOR_STYLE_t *style);
245
        bool existCursor(const std::string& cursor);
246
        CURSOR_t getCursorFiles(const CURSOR_STYLE_t& style);
247
 
248
    protected:
249
        static void startElement(void *, const XML_Char *name, const XML_Char **);
250
        static void XMLCALL endElement(void *userData, const XML_Char *name);
251
        static void XMLCALL CharacterDataHandler(void *userData, const XML_Char *s, int len);
252
 
253
 
254
    private:
255
        typedef enum XELEMENTS_t
256
        {
257
            X_NONE,
258
            X_BORDER,
259
            X_BORDER_DATA,
260
            X_BORDER_FAMILY,
261
            X_BORDER_STYLE,
262
            X_CURSOR_DATA,
263
            X_CURSOR_FAMILY,
264
            X_CURSOR_STYLE,
265
            X_SLIDER_DATA,
266
            X_SLIDER_FAMILY,
267
            X_SLIDER_STYLE,
268
            X_EFFECT_DATA,
269
            X_EFFECT_FAMILY,
270
            X_EFFECT_STYLE,
271
            X_POPUP_EFFECT_DATA,
272
            X_POPUP_EFFECT
273
        }XELEMENTS_t;
274
 
275
        std::string getDirEntry(dir::TDirectory *dir, const std::string& part, bool alpha = true);
276
        bool evaluateName(const std::vector<std::string>& parts, const std::string& name);
277
 
278
        std::string mPath;          // The path to the system directory tree
279
        bool mValid{false};         // TRUE = the path mPath is a valid directory
280
        bool mHaveBorders{false};   // TRUE = system directory borders exist
281
        bool mHaveCursors{false};   // TRUE = system directory cursors exist
282
        bool mHaveFonts{false};     // TRUE = system directory fonts exist
283
        bool mHaveImages{false};    // TRUE = system directory images exist
284
        bool mHaveSliders{false};   // TRUE = system directory sliders exist
285
 
286
        DRAW_t mDraw;
287
 
288
        static XELEMENTS_t mActData;
289
        static XELEMENTS_t mActFamily;
290
        static std::string mActElement;
291
};
292
 
293
#endif