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"
159 andreas 29
#include "tdirectory.h"
72 andreas 30
 
99 andreas 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
 
72 andreas 41
typedef struct FAMILY_t
42
{
43
    std::string name;
44
    std::vector<std::string> member;
73 andreas 45
}FAMILY_t;
72 andreas 46
 
73 andreas 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
 
79 andreas 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;
118 andreas 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
    }
79 andreas 95
}BORDER_DATA_t;
96
 
73 andreas 97
typedef struct CURSOR_STYLE_t
98
{
99
    std::string name;
100
    std::string baseFile;
101
    int multiColor;
102
    std::vector<int> g3Equiv;
118 andreas 103
 
104
    void init()
105
    {
106
        multiColor = 0;
107
    }
73 andreas 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;
118 andreas 119
 
120
    void init()
121
    {
122
        multiColor = 0;
123
        incRepeat = 0;
124
        minSize = 0;
125
        fixedSize = 0;
126
    }
73 andreas 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;
118 andreas 139
 
140
    void init()
141
    {
142
        number = 0;
143
        startx = 0;
144
        starty = 0;
145
        height = 0;
146
        width = 0;
147
        cutout = 0;
148
    }
73 andreas 149
}EFFECT_STYLE_t;
150
 
151
typedef struct POPUP_EFFECT_t
152
{
153
    std::string name;
154
    int number;
155
    int valueUsed;
118 andreas 156
 
157
    void init()
158
    {
159
        number = 0;
160
        valueUsed = 0;
161
    }
73 andreas 162
}POPUP_EFFECT_t;
163
 
72 andreas 164
typedef struct DRAW_t
165
{
73 andreas 166
    std::vector<FAMILY_t> borders;
167
    std::vector<BORDER_STYLE_t> borderStyles;
79 andreas 168
    std::vector<BORDER_DATA_t> borderData;
73 andreas 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;
72 andreas 176
}DRAW_t;
177
 
79 andreas 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
    BORDER_DATA_t border;   // Border data
81 andreas 189
    BORDER_STYLE_t bdStyle; // The border style data
79 andreas 190
}BORDER_t;
191
 
99 andreas 192
typedef struct SLIDER_t
193
{
194
    SLIDER_GRTYPE_t type;   //<! The type of the file the path is pointing to
195
    std::string path;       //<! The path and file name of the graphics mask file.
196
    std::string pathAlpha;  //<! The path and file name of the graphics file containing the alpha part of the image.
197
}SLIDER_t;
198
 
199
/**
200
 * @brief Class to manage system resources like borders, sliders, ...
201
 *
202
 * \c TSystemDraw reads the system configuration file draw.xma. This is
203
 * usualy located in the system directory __system/graphics.
204
 */
72 andreas 205
class TSystemDraw : public TValidateFile
206
{
207
    public:
79 andreas 208
        typedef enum LINE_TYPE_t
209
        {
210
            LT_OFF,
211
            LT_ON,
212
            LT_DRAG,
213
            LT_DROP
214
        }LINE_TYPE_t;
215
 
72 andreas 216
        TSystemDraw(const std::string& path);
217
        ~TSystemDraw();
218
 
219
        bool loadConfig();
99 andreas 220
 
306 andreas 221
        bool getBorder(const std::string& family, LINE_TYPE_t lt, BORDER_t *border, const std::string& family2="", bool info=false);
222
        bool getBorderInfo(const std::string& family, LINE_TYPE_t lt, BORDER_t *border, const std::string& family2="");
79 andreas 223
        bool existBorder(const std::string& family);
81 andreas 224
        int getBorderWidth(const std::string& family, LINE_TYPE_t lt = LT_OFF);
225
        int getBorderHeight(const std::string& family, LINE_TYPE_t lt = LT_OFF);
72 andreas 226
 
99 andreas 227
        bool existSlider(const std::string& slider);
228
        bool getSlider(const std::string& slider, SLIDER_STYLE_t *style);
229
        std::vector<SLIDER_t> getSliderFiles(const std::string& slider);
230
 
81 andreas 231
    protected:
232
        static void startElement(void *, const XML_Char *name, const XML_Char **);
233
        static void XMLCALL endElement(void *userData, const XML_Char *name);
234
        static void XMLCALL CharacterDataHandler(void *userData, const XML_Char *s, int len);
235
 
236
 
237
    private:
72 andreas 238
        typedef enum XELEMENTS_t
239
        {
240
            X_NONE,
79 andreas 241
            X_BORDER,
72 andreas 242
            X_BORDER_DATA,
243
            X_BORDER_FAMILY,
73 andreas 244
            X_BORDER_STYLE,
72 andreas 245
            X_CURSOR_DATA,
246
            X_CURSOR_FAMILY,
73 andreas 247
            X_CURSOR_STYLE,
72 andreas 248
            X_SLIDER_DATA,
249
            X_SLIDER_FAMILY,
73 andreas 250
            X_SLIDER_STYLE,
72 andreas 251
            X_EFFECT_DATA,
252
            X_EFFECT_FAMILY,
73 andreas 253
            X_EFFECT_STYLE,
72 andreas 254
            X_POPUP_EFFECT_DATA,
255
            X_POPUP_EFFECT
256
        }XELEMENTS_t;
257
 
159 andreas 258
        std::string getDirEntry(dir::TDirectory *dir, const std::string& part, bool alpha = true);
222 andreas 259
        bool evaluateName(const std::vector<std::string>& parts, const std::string& name);
72 andreas 260
 
261
        std::string mPath;          // The path to the system directory tree
262
        bool mValid{false};         // TRUE = the path mPath is a valid directory
263
        bool mHaveBorders{false};   // TRUE = system directory borders exist
264
        bool mHaveCursors{false};   // TRUE = system directory cursors exist
265
        bool mHaveFonts{false};     // TRUE = system directory fonts exist
266
        bool mHaveImages{false};    // TRUE = system directory images exist
267
        bool mHaveSliders{false};   // TRUE = system directory sliders exist
268
 
269
        DRAW_t mDraw;
270
 
271
        static XELEMENTS_t mActData;
272
        static XELEMENTS_t mActFamily;
273
        static std::string mActElement;
274
};
275
 
276
#endif