]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
1e79165fd4f02af21af122262de1ac7929cd411a
[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
28         private:
29                 void finish() override;
30
31                 void graphic_normal(const std::string &);
32                 void graphic(State, const std::string &);
33                 void align(float, float);
34                 void fill(float, float);
35                 void margin();
36                 void size(unsigned, unsigned);
37         };
38
39 private:
40         std::string name;
41         const Graphic *graphic[N_STATES_] = { };
42         Geometry geom;
43         Sides margin;
44         Alignment align;
45
46 public:
47         Part(const std::string &);
48
49         const std::string &get_name() const { return name; }
50         const Graphic *get_graphic(State) const;
51         const Geometry &get_geometry() const { return geom; }
52         const Sides &get_margin() const { return margin; }
53         const Alignment &get_alignment() const { return align; }
54         void build(const Geometry &, State, PartCache &) const;
55 };
56
57 } // namespace GLtk
58 } // namespace Msp
59
60 #endif