]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
35b8f7d52d820333f74d9f44a0aa23e26dfd313c
[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 "mspgltk_api.h"
8 #include "state.h"
9
10 namespace Msp {
11 namespace GLtk {
12
13 class Graphic;
14 class PartCache;
15 class Resources;
16
17 /**
18 Defines a single graphical element of a widget style.
19 */
20 class MSPGLTK_API Part
21 {
22 public:
23         class Loader: public DataFile::CollectionObjectLoader<Part>
24         {
25         public:
26                 Loader(Part &, Resources &);
27                 ~Loader();
28         private:
29                 void graphic_normal(const std::string &);
30                 void graphic(State, const std::string &);
31                 void align(float, float);
32                 void fill(float, float);
33                 void margin();
34                 void size(unsigned, unsigned);
35         };
36
37 private:
38         std::string name;
39         const Graphic *graphic[N_STATES_] = { };
40         Geometry geom;
41         Sides margin;
42         Alignment align;
43
44 public:
45         Part(const std::string &);
46         const std::string &get_name() const { return name; }
47         const Graphic *get_graphic(State) const;
48         const Geometry &get_geometry() const { return geom; }
49         const Sides &get_margin() const { return margin; }
50         const Alignment &get_alignment() const { return align; }
51         void build(const Geometry &, State, PartCache &) const;
52 };
53
54 } // namespace GLtk
55 } // namespace Msp
56
57 #endif