Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
/*
21 andreas 2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
4 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 __TPALETTE_H__
20
#define __TPALETTE_H__
21
 
22
#include <string>
23
#include <map>
24
#include <vector>
25
#include "tvalidatefile.h"
26
 
27
typedef struct PDATA_T
28
{
29
    int index{0};
30
    std::string name;
31
    unsigned long color{0};
32
 
33
    void clear()
34
    {
35
        index = 0;
36
        name.clear();
37
        color = 0;
38
    }
39
}PDATA_T;
40
 
41
class TPalette : public TValidateFile
42
{
43
    public:
44
        TPalette();
45
        TPalette(const std::string& file);
46
        ~TPalette();
47
 
48
        void initialize(const std::string& file);
49
        PDATA_T findColor(const std::string& name);
50
        PDATA_T findColor(int pID);
11 andreas 51
        void reset();
4 andreas 52
 
53
    private:
54
        bool havePalette(const std::string& name);
55
 
56
        std::map<std::string, PDATA_T> mColors;
57
        std::vector<std::string> mPaletteNames;
58
};
59
 
60
#endif