void Button::Loader::text(const std::string &t)
{
- static_cast<Button &>(wdg).text = t;
+ static_cast<Button &>(obj).text = t;
}
} // namespace GLtk
void Dropdown::Loader::item(const string &str)
{
- dynamic_cast<Dropdown &>(wdg).append(str);
+ dynamic_cast<Dropdown &>(obj).append(str);
}
} // namespace GLtk
Sides::Loader::Loader(Sides &s):
- sides(s)
+ DataFile::ObjectLoader<Sides>(s)
{
add("top", &Sides::top);
add("right", &Sides::right);
#ifndef MSP_GLTK_GEOMETRY_H_
#define MSP_GLTK_GEOMETRY_H_
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
namespace Msp {
namespace GLtk {
*/
struct Sides
{
- class Loader: public DataFile::Loader
+ class Loader: public DataFile::ObjectLoader<Sides>
{
public:
Loader(Sides &);
- Sides &get_object() { return sides; }
- private:
- Sides &sides;
};
unsigned top;
void Label::Loader::text(const string &t)
{
- static_cast<Label &>(wdg).text = t;
+ static_cast<Label &>(obj).text = t;
}
} // namespace GLtk
void List::Loader::item(const string &v)
{
- dynamic_cast<List &>(wdg).append(v);
+ dynamic_cast<List &>(obj).append(v);
}
} // namespace GLtk
Part::Loader::Loader(Part &p, Resources &r):
- part(p),
- res(r)
+ DataFile::CollectionObjectLoader<Part>(p, &r)
{
add("graphic", &Loader::graphic);
add("align", &Loader::align);
Part::Loader::~Loader()
{
for(unsigned i=0; i<N_STATES_; ++i)
- if(part.graphic[i])
+ if(obj.graphic[i])
{
- const Sides &shadow = part.graphic[i]->get_shadow();
- part.geom.w = max(part.geom.w, part.graphic[i]->get_width()-shadow.left-shadow.right);
- part.geom.h = max(part.geom.h, part.graphic[i]->get_height()-shadow.bottom-shadow.top);
+ const Graphic &grph = *obj.graphic[i];
+ const Sides &shadow = grph.get_shadow();
+ obj.geom.w = max(obj.geom.w, grph.get_width()-shadow.left-shadow.right);
+ obj.geom.h = max(obj.geom.h, grph.get_height()-shadow.bottom-shadow.top);
}
}
void Part::Loader::graphic(State s, const string &n)
{
- Graphic *grph = res.get<Graphic>(n);
+ Graphic *grph = get_collection().get<Graphic>(n);
for(int i=0; i<N_STATES_; ++i)
if((i&s)==s)
- part.graphic[i] = grph;
+ obj.graphic[i] = grph;
}
void Part::Loader::align(float x, float y)
{
- part.align.x = x;
- part.align.y = y;
+ obj.align.x = x;
+ obj.align.y = y;
}
void Part::Loader::fill(float w, float h)
{
- part.align.w = w;
- part.align.h = h;
+ obj.align.w = w;
+ obj.align.h = h;
}
void Part::Loader::margin()
{
- load_sub(part.margin);
+ load_sub(obj.margin);
}
void Part::Loader::size(unsigned w, unsigned h)
{
- part.geom.w = w;
- part.geom.h = h;
+ obj.geom.w = w;
+ obj.geom.h = h;
}
} // namespace GLtk
#define MSP_GLTK_PART_H_
#include <string>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
#include "geometry.h"
#include "state.h"
class Part
{
public:
- class Loader: public DataFile::Loader
+ class Loader: public DataFile::CollectionObjectLoader<Part>
{
- private:
- Part ∂
- Resources &res;
-
public:
Loader(Part &, Resources &);
~Loader();
Label *lbl_tooltip;
int pointer_x;
int pointer_y;
- Msp::Time::TimeStamp tooltip_timeout;
+ Time::TimeStamp tooltip_timeout;
Widget *tooltip_target;
public:
Slider &Slider::Loader::get_object() const
{
- return static_cast<Slider &>(wdg);
+ return static_cast<Slider &>(obj);
}
} // namespace GLtk
void Table::Loader::cell_text(unsigned r, unsigned c, const string &t)
{
- static_cast<Table &>(wdg).set_cell_text(r, c, t);
+ static_cast<Table &>(obj).set_cell_text(r, c, t);
}
void Table::Loader::column_width(unsigned c, unsigned w)
{
- static_cast<Table &>(wdg).set_column_width(c, w);
+ static_cast<Table &>(obj).set_column_width(c, w);
}
void Table::Loader::columns(unsigned c)
{
- static_cast<Table &>(wdg).set_columns(c);
+ static_cast<Table &>(obj).set_columns(c);
}
void Table::Loader::rows(unsigned r)
{
- static_cast<Table &>(wdg).set_rows(r);
+ static_cast<Table &>(obj).set_rows(r);
}
} // namespace GLtk
Toggle &Toggle::Loader::get_object() const
{
- return static_cast<Toggle &>(wdg);
+ return static_cast<Toggle &>(obj);
}
void Toggle::Loader::finish()
{
- Toggle &tgl = static_cast<Toggle &>(wdg);
+ Toggle &tgl = get_object();
if(tgl.value)
tgl.state |= ACTIVE;
else
void Toggle::Loader::text(const string &t)
{
- static_cast<Toggle &>(wdg).text = t;
+ get_object().text = t;
}
} // namespace GLtk
Widget::Loader::Loader(Widget &w):
- wdg(w)
+ DataFile::ObjectLoader<Widget>(w)
{
add("position", &Loader::position);
add("size", &Loader::size);
void Widget::Loader::position(int x, int y)
{
- wdg.set_position(x, y);
+ obj.set_position(x, y);
}
void Widget::Loader::size(unsigned w, unsigned h)
{
- wdg.set_size(w, h);
+ obj.set_size(w, h);
}
void Widget::Loader::style(const string &s)
{
- wdg.set_style(s);
+ obj.set_style(s);
}
} // namespace GLtk
#define MSP_GLTK_WIDGET_H_
#include <string>
+#include <msp/datafile/objectloader.h>
#include "geometry.h"
#include "state.h"
friend class Container;
public:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public DataFile::ObjectLoader<Widget>
{
- protected:
- Widget &wdg;
-
public:
Loader(Widget &);
- Widget &get_object() const { return wdg; }
private:
void position(int, int);
void size(unsigned, unsigned);