]> git.tdb.fi Git - libs/gltk.git/blob - source/style.h
Change Style so it doesn't need a special loading function
[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/datafile/loader.h>
7 #include "part.h"
8
9 namespace Msp {
10 namespace GLtk {
11
12 class Resources;
13
14 /**
15 Styles define what wigets look like.  They are made up of Parts and some
16 generic properties.
17 */
18 class Style
19 {
20 public:
21         class Loader: public DataFile::Loader
22         {
23         private:
24                 Style &style;
25                 Resources &res;
26
27         public:
28                 typedef Resources Collection;
29
30                 Loader(Style &, Resources &);
31                 Style &get_object() const { return style; }
32                 Resources &get_collection() const { return res; }
33         private:
34                 void font(const std::string &);
35                 void font_color(float, float, float);
36                 void part();
37                 void part(const std::string &);
38         };
39
40         typedef std::list<Part> PartSeq;
41
42 private:
43         const GL::Font *font;
44         unsigned font_size;
45         GL::Color font_color;
46         PartSeq parts;
47
48 public:
49         Style();
50         const GL::Font &get_font() const;
51         unsigned get_font_size() const { return font_size; }
52         const GL::Color &get_font_color() const { return font_color; }
53         const PartSeq &get_parts() const { return parts; }
54         const Part *get_part(const std::string &) const;
55 };
56
57 } // namespace GLtk
58 } // namespace Msp
59
60 #endif