]> git.tdb.fi Git - libs/gltk.git/blob - source/style.cpp
Strip copyright messages and id tags from individual files
[libs/gltk.git] / source / style.cpp
1 #include "resources.h"
2 #include "style.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GLtk {
8
9 Style::Style(Resources &r):
10         font(&r.get_default_font())
11 { }
12
13 const Part *Style::get_part(const string &name) const
14 {
15         for(PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
16                 if(i->get_name()==name)
17                         return &*i;
18
19         return 0;
20 }
21
22
23 Style::Loader::Loader(Style &s, Resources &r):
24         style(s),
25         res(r)
26 {
27         add("font",       &Style::font);
28         add("font_color", &Loader::font_color);
29         add("part",       static_cast<void (Loader::*)()>(&Loader::part));
30         add("part",       static_cast<void (Loader::*)(const std::string &)>(&Loader::part));
31         // Deprecated alias
32         add("special",    static_cast<void (Loader::*)(const std::string &)>(&Loader::part));
33 }
34
35 void Style::Loader::font_color(float r, float g, float b)
36 {
37         style.font_color = GL::Color(r, g, b);
38 }
39
40 void Style::Loader::part()
41 {
42         part(string());
43 }
44
45 void Style::Loader::part(const string &n)
46 {
47         Part p(n);
48         load_sub(p, res);
49         style.parts.push_back(p);
50 }
51
52 } // namespace GLtk
53 } // namespace Msp