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