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