]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/part.h
Add a shortcut for defining normal graphic
[libs/gltk.git] / source / part.h
index 58386ca8f611560ad5fa21ba9cf28b8259dea365..252d5a3cbecad1d2fafe1eec17edbced1a592fdf 100644 (file)
@@ -1,55 +1,54 @@
 #ifndef MSP_GLTK_PART_H_
 #define MSP_GLTK_PART_H_
 
-#include <map>
 #include <string>
-#include <msp/datafile/loader.h>
-#include "alignment.h"
+#include <msp/datafile/objectloader.h>
+#include "geometry.h"
 #include "state.h"
 
 namespace Msp {
 namespace GLtk {
 
 class Graphic;
+class PartCache;
 class Resources;
 
+/**
+Defines a single graphical element of a widget style.
+*/
 class Part
 {
 public:
-       class Loader: public DataFile::Loader
+       class Loader: public DataFile::CollectionObjectLoader<Part>
        {
-       private:
-               Part &part;
-               Resources &res;
-
        public:
                Loader(Part &, Resources &);
                ~Loader();
        private:
+               void graphic_normal(const std::string &);
                void graphic(State, const std::string &);
-               void align(int, int);
-               void fill(bool, bool);
+               void align(float, float);
+               void fill(float, float);
+               void margin();
+               void size(unsigned, unsigned);
        };
 
-       Part(const std::string &);
-       const std::string &get_name() const { return name; }
-       const Graphic *get_graphic(State) const;
-       unsigned get_width() const { return width; }
-       unsigned get_height() const { return height; }
-       const Alignment &get_alignment() const { return align; }
-       bool get_fill_x() const { return fill_x; }
-       bool get_fill_y() const { return fill_y; }
-       void render(const Geometry &, State) const;
 private:
        std::string name;
        const Graphic *graphic[N_STATES_];
-       unsigned width;
-       unsigned height;
+       Geometry geom;
+       Sides margin;
        Alignment align;
-       bool fill_x;
-       bool fill_y;
+
+public:
+       Part(const std::string &);
+       const std::string &get_name() const { return name; }
+       const Graphic *get_graphic(State) const;
+       const Geometry &get_geometry() const { return geom; }
+       const Sides &get_margin() const { return margin; }
+       const Alignment &get_alignment() const { return align; }
+       void build(const Geometry &, State, PartCache &) const;
 };
-typedef std::list<Part> PartSeq;
 
 } // namespace GLtk
 } // namespace Msp