]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
Loader improvements
[libs/gltk.git] / source / part.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_PART_H_
9 #define MSP_GLTK_PART_H_
10
11 #include <string>
12 #include <msp/datafile/objectloader.h>
13 #include "geometry.h"
14 #include "state.h"
15
16 namespace Msp {
17 namespace GLtk {
18
19 class Graphic;
20 class Resources;
21
22 /**
23 Defines a single graphical element of a widget style.
24 */
25 class Part
26 {
27 public:
28         class Loader: public DataFile::CollectionObjectLoader<Part>
29         {
30         public:
31                 Loader(Part &, Resources &);
32                 ~Loader();
33         private:
34                 void graphic(State, const std::string &);
35                 void align(float, float);
36                 void fill(float, float);
37                 void margin();
38                 void size(unsigned, unsigned);
39         };
40
41 private:
42         std::string name;
43         const Graphic *graphic[N_STATES_];
44         Geometry geom;
45         Sides margin;
46         Alignment align;
47
48 public:
49         Part(const std::string &);
50         const std::string &get_name() const { return name; }
51         const Graphic *get_graphic(State) const;
52         const Geometry &get_geometry() const { return geom; }
53         const Sides &get_margin() const { return margin; }
54         const Alignment &get_alignment() const { return align; }
55         void render(const Geometry &, State) const;
56 };
57
58 } // namespace GLtk
59 } // namespace Msp
60
61 #endif