]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
08803dc5a7074b5d2ff71f8797f785603dc42d88
[libs/gltk.git] / source / part.h
1 #ifndef MSP_GLTK_PART_H_
2 #define MSP_GLTK_PART_H_
3
4 #include <map>
5 #include <string>
6 #include <msp/parser/loader.h>
7 #include "alignment.h"
8 #include "state.h"
9
10 namespace Msp {
11 namespace GLtk {
12
13 class Graphic;
14 class Resources;
15
16 class Part
17 {
18 public:
19         class Loader: public Parser::Loader
20         {
21         public:
22                 Loader(Part &);
23                 ~Loader();
24         private:
25                 Part &part;
26
27                 void graphic(State, const std::string &);
28                 void align(int, int);
29                 void fill(bool, bool);
30         };
31
32         Part(const Resources &, const std::string &);
33         const std::string &get_name() const { return name; }
34         const Graphic *get_graphic(State) const;
35         unsigned get_width() const { return width; }
36         unsigned get_height() const { return height; }
37         const Alignment &get_alignment() const { return align; }
38         bool get_fill_x() const { return fill_x; }
39         bool get_fill_y() const { return fill_y; }
40         void render(const Geometry &, State) const;
41 private:
42         const Resources &res;
43         std::string name;
44         const Graphic *graphic[N_STATES_];
45         unsigned width;
46         unsigned height;
47         Alignment align;
48         bool fill_x;
49         bool fill_y;
50 };
51 typedef std::list<Part> PartSeq;
52
53 } // namespace GLtk
54 } // namespace Msp
55
56 #endif