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;
118 andreas 75
 
76
    void init()
77
    {
78
        multiColor = 0;
79
        fillTop = 0;
80
        fillLeft = 0;
81
        fillBottom = 0;
82
        fillRight = 0;
83
        textTop = 0;
84
        textLeft = 0;
85
        textBottom = 0;
86
        textRight = 0,
87
        idealWidth = 0;
88
        idealHeight = 0;
89
        minHeight = 0;
90
        minWidth = 0;
91
        incHeight = 0;
92
        incWidth = 0;
93
    }
79 andreas 94
}BORDER_DATA_t;
95
 
73 andreas 96
typedef struct CURSOR_STYLE_t
97
{
98
    std::string name;
99
    std::string baseFile;
100
    int multiColor;
101
    std::vector<int> g3Equiv;
118 andreas 102
 
103
    void init()
104
    {
105
        multiColor = 0;
106
    }
73 andreas 107
}CURSOR_STYLE_t;
108
 
109
typedef struct SLIDER_STYLE_t
110
{
111
    std::string name;
112
    std::string baseFile;
113
    int multiColor;
114
    int incRepeat;
115
    int minSize;
116
    int fixedSize;
117
    std::vector<int> g3Equiv;
118 andreas 118
 
119
    void init()
120
    {
121
        multiColor = 0;
122
        incRepeat = 0;
123
        minSize = 0;
124
        fixedSize = 0;
125
    }
73 andreas 126
}SLIDER_STYLE_t;
127
 
128
typedef struct EFFECT_STYLE_t
129
{
130
    std::string name;
131
    int number;
132
    int startx;
133
    int starty;
134
    int height;
135
    int width;
136
    int cutout;
137
    std::string pixelMap;
118 andreas 138
 
139
    void init()
140
    {
141
        number = 0;
142
        startx = 0;
143
        starty = 0;
144
        height = 0;
145
        width = 0;
146
        cutout = 0;
147
    }
73 andreas 148
}EFFECT_STYLE_t;
149
 
150
typedef struct POPUP_EFFECT_t
151
{
152
    std::string name;
153
    int number;
154
    int valueUsed;
118 andreas 155
 
156
    void init()
157
    {
158
        number = 0;
159
        valueUsed = 0;
160
    }
73 andreas 161
}POPUP_EFFECT_t;
162
 
72 andreas 163
typedef struct DRAW_t
164
{
73 andreas 165
    std::vector<FAMILY_t> borders;
166
    std::vector<BORDER_STYLE_t> borderStyles;
79 andreas 167
    std::vector<BORDER_DATA_t> borderData;
73 andreas 168
    std::vector<FAMILY_t> cursors;
169
    std::vector<CURSOR_STYLE_t> cursorStyles;
170
    std::vector<FAMILY_t> sliders;
171
    std::vector<SLIDER_STYLE_t> sliderStyles;
172
    std::vector<FAMILY_t> effects;
173
    std::vector<EFFECT_STYLE_t> effectStyles;
174
    std::vector<POPUP_EFFECT_t> popupEffects;
72 andreas 175
}DRAW_t;
176
 
79 andreas 177
typedef struct BORDER_t
178
{
179
    std::string bl;         // bottom left corner
180
    std::string b;          // bottom
181
    std::string br;         // bottom right corner
182
    std::string r;          // right
183
    std::string tr;         // top right corner
184
    std::string t;          // top
185
    std::string tl;         // top left corner
186
    std::string l;          // left
187
    BORDER_DATA_t border;   // Border data
81 andreas 188
    BORDER_STYLE_t bdStyle; // The border style data
79 andreas 189
}BORDER_t;
190
 
99 andreas 191
typedef struct SLIDER_t
192
{
193
    SLIDER_GRTYPE_t type;   //<! The type of the file the path is pointing to
194
    std::string path;       //<! The path and file name of the graphics mask file.
195
    std::string pathAlpha;  //<! The path and file name of the graphics file containing the alpha part of the image.
196
}SLIDER_t;
197
 
198
/**
199
 * @brief Class to manage system resources like borders, sliders, ...
200
 *
201
 * \c TSystemDraw reads the system configuration file draw.xma. This is
202
 * usualy located in the system directory __system/graphics.
203
 */
72 andreas 204
class TSystemDraw : public TValidateFile
205
{
206
    public:
79 andreas 207
        typedef enum LINE_TYPE_t
208
        {
209
            LT_OFF,
210
            LT_ON,
211
            LT_DRAG,
212
            LT_DROP
213
        }LINE_TYPE_t;
214
 
72 andreas 215
        TSystemDraw(const std::string& path);
216
        ~TSystemDraw();
217
 
218
        bool loadConfig();
99 andreas 219
 
79 andreas 220
        bool getBorder(const std::string& family, LINE_TYPE_t lt, BORDER_t *border);
221
        bool existBorder(const std::string& family);
81 andreas 222
        int getBorderWidth(const std::string& family, LINE_TYPE_t lt = LT_OFF);
223
        int getBorderHeight(const std::string& family, LINE_TYPE_t lt = LT_OFF);
72 andreas 224
 
99 andreas 225
        bool existSlider(const std::string& slider);
226
        bool getSlider(const std::string& slider, SLIDER_STYLE_t *style);
227
        std::vector<SLIDER_t> getSliderFiles(const std::string& slider);
228
 
81 andreas 229
    protected:
230
        static void startElement(void *, const XML_Char *name, const XML_Char **);
231
        static void XMLCALL endElement(void *userData, const XML_Char *name);
232
        static void XMLCALL CharacterDataHandler(void *userData, const XML_Char *s, int len);
233
 
234
 
235
    private:
72 andreas 236
        typedef enum XELEMENTS_t
237
        {
238
            X_NONE,
79 andreas 239
            X_BORDER,
72 andreas 240
            X_BORDER_DATA,
241
            X_BORDER_FAMILY,
73 andreas 242
            X_BORDER_STYLE,
72 andreas 243
            X_CURSOR_DATA,
244
            X_CURSOR_FAMILY,
73 andreas 245
            X_CURSOR_STYLE,
72 andreas 246
            X_SLIDER_DATA,
247
            X_SLIDER_FAMILY,
73 andreas 248
            X_SLIDER_STYLE,
72 andreas 249
            X_EFFECT_DATA,
250
            X_EFFECT_FAMILY,
73 andreas 251
            X_EFFECT_STYLE,
72 andreas 252
            X_POPUP_EFFECT_DATA,
253
            X_POPUP_EFFECT
254
        }XELEMENTS_t;
255
 
256
 
257
        std::string mPath;          // The path to the system directory tree
258
        bool mValid{false};         // TRUE = the path mPath is a valid directory
259
        bool mHaveBorders{false};   // TRUE = system directory borders exist
260
        bool mHaveCursors{false};   // TRUE = system directory cursors exist
261
        bool mHaveFonts{false};     // TRUE = system directory fonts exist
262
        bool mHaveImages{false};    // TRUE = system directory images exist
263
        bool mHaveSliders{false};   // TRUE = system directory sliders exist
264
 
265
        DRAW_t mDraw;
266
 
267
        static XELEMENTS_t mActData;
268
        static XELEMENTS_t mActFamily;
269
        static std::string mActElement;
270
};
271
 
272
#endif