]> git.tdb.fi Git - libs/gltk.git/blob - source/part.h
Reorder class members
[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 "state.h"
16
17 namespace Msp {
18 namespace GLtk {
19
20 class Graphic;
21 class Resources;
22
23 /**
24 Defines a single graphical element of a widget style.
25 */
26 class Part
27 {
28 public:
29         class Loader: public DataFile::Loader
30         {
31         private:
32                 Part &part;
33                 Resources &res;
34
35         public:
36                 Loader(Part &, Resources &);
37                 ~Loader();
38         private:
39                 void graphic(State, const std::string &);
40                 void align(int, int);
41                 void fill(bool, bool);
42         };
43
44 private:
45         std::string name;
46         const Graphic *graphic[N_STATES_];
47         unsigned width;
48         unsigned height;
49         Alignment align;
50         bool fill_x;
51         bool fill_y;
52
53 public:
54         Part(const std::string &);
55         const std::string &get_name() const { return name; }
56         const Graphic *get_graphic(State) const;
57         unsigned get_width() const { return width; }
58         unsigned get_height() const { return height; }
59         const Alignment &get_alignment() const { return align; }
60         bool get_fill_x() const { return fill_x; }
61         bool get_fill_y() const { return fill_y; }
62         void render(const Geometry &, State) const;
63 };
64 typedef std::list<Part> PartSeq;
65
66 } // namespace GLtk
67 } // namespace Msp
68
69 #endif