]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
Enable loading of entry widgets from datafiles
[libs/gltk.git] / source / part.h
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GLTK_PART_H_
9 #define MSP_GLTK_PART_H_
10
11 #include <map>
12 #include <string>
13 #include <msp/datafile/loader.h>
14 //#include "alignment.h"
15 #include "geometry.h"
16 #include "state.h"
17
18 namespace Msp {
19 namespace GLtk {
20
21 class Graphic;
22 class Resources;
23
24 /**
25 Defines a single graphical element of a widget style.
26 */
27 class Part
28 {
29 public:
30         class Loader: public DataFile::Loader
31         {
32         private:
33                 Part &part;
34                 Resources &res;
35
36         public:
37                 Loader(Part &, Resources &);
38                 ~Loader();
39         private:
40                 void graphic(State, const std::string &);
41                 void align(float, float);
42                 void fill(bool, bool);
43                 void margin();
44         };
45
46 private:
47         std::string name;
48         const Graphic *graphic[N_STATES_];
49         Geometry geom;
50         Sides margin;
51         Alignment align;
52         bool fill_x;
53         bool fill_y;
54
55 public:
56         Part(const std::string &);
57         const std::string &get_name() const { return name; }
58         const Graphic *get_graphic(State) const;
59         const Geometry &get_geometry() const { return geom; }
60         const Sides &get_margin() const { return margin; }
61         const Alignment &get_alignment() const { return align; }
62         bool get_fill_x() const { return fill_x; }
63         bool get_fill_y() const { return fill_y; }
64         void render(const Geometry &, State) const;
65 };
66 typedef std::list<Part> PartSeq;
67
68 } // namespace GLtk
69 } // namespace Msp
70
71 #endif