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