]> git.tdb.fi Git - libs/gltk.git/blob - source/style.h
ee25b251dcb50ba932efe40d368f465ab78719c9
[libs/gltk.git] / source / style.h
1 #ifndef MSP_GLTK_STYLE_H_
2 #define MSP_GLTK_STYLE_H_
3
4 #include <msp/gl/color.h>
5 #include <msp/gl/font.h>
6 #include <msp/gl/sampler.h>
7 #include <msp/datafile/objectloader.h>
8 #include "mspgltk_api.h"
9 #include "part.h"
10
11 namespace Msp {
12 namespace GLtk {
13
14 class Resources;
15
16 /**
17 Styles define what wigets look like.  They are made up of Parts and some
18 generic properties.
19 */
20 class MSPGLTK_API Style
21 {
22 public:
23         class Loader: public DataFile::CollectionObjectLoader<Style, Resources>
24         {
25         public:
26                 Loader(Style &, Resources &);
27
28         private:
29                 void font(const std::string &);
30                 void font_color_normal(float, float, float);
31                 void font_color(State, float, float, float);
32                 void part(const std::string &);
33                 void unnamed_part();
34         };
35
36         typedef std::list<Part> PartSeq;
37
38 private:
39         const GL::Font *font = 0;
40         unsigned font_size = 0;
41         GL::Color font_color[N_STATES_];
42         const GL::Sampler *sampler = 0;
43         PartSeq parts;
44
45 public:
46         const GL::Font &get_font() const;
47         unsigned get_font_size() const { return font_size; }
48         const GL::Color &get_font_color(State) const;
49         const GL::Sampler &get_sampler() const;
50         const PartSeq &get_parts() const { return parts; }
51         const Part *get_part(const std::string &) const;
52         bool compare_states(State, State) const;
53 };
54
55 } // namespace GLtk
56 } // namespace Msp
57
58 #endif