]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
Derive Resources from DataFile::Collection
[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/datafile/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 DataFile::Loader
20         {
21         private:
22                 Part &part;
23                 Resources &res;
24
25         public:
26                 Loader(Part &, Resources &);
27                 ~Loader();
28         private:
29                 void graphic(State, const std::string &);
30                 void align(int, int);
31                 void fill(bool, bool);
32         };
33
34         Part(const std::string &);
35         const std::string &get_name() const { return name; }
36         const Graphic *get_graphic(State) const;
37         unsigned get_width() const { return width; }
38         unsigned get_height() const { return height; }
39         const Alignment &get_alignment() const { return align; }
40         bool get_fill_x() const { return fill_x; }
41         bool get_fill_y() const { return fill_y; }
42         void render(const Geometry &, State) const;
43 private:
44         std::string name;
45         const Graphic *graphic[N_STATES_];
46         unsigned width;
47         unsigned height;
48         Alignment align;
49         bool fill_x;
50         bool fill_y;
51 };
52 typedef std::list<Part> PartSeq;
53
54 } // namespace GLtk
55 } // namespace Msp
56
57 #endif