3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
10 #include "resources.h"
17 Part::Part(const string &n):
24 for(unsigned i=0; i<N_STATES_; ++i)
28 const Graphic *Part::get_graphic(State state) const
31 throw InvalidParameterValue("Invalid state");
33 return graphic[state];
36 void Part::render(const Geometry &geom, State state) const
38 unsigned gw=(fill_x ? geom.w : width);
39 unsigned gh=(fill_y ? geom.h : height);
40 align.apply(geom, gw, gh);
41 graphic[state]->render(gw, gh);
45 Part::Loader::Loader(Part &p, Resources &r):
49 add("graphic", &Loader::graphic);
50 add("align", &Loader::align);
51 add("fill", &Loader::fill);
54 Part::Loader::~Loader()
56 for(unsigned i=0; i<N_STATES_; ++i)
60 const Sides &shadow=part.graphic[i]->get_shadow();
61 part.width=max(part.width, part.graphic[i]->get_width()-shadow.left-shadow.right);
62 part.height=max(part.height, part.graphic[i]->get_height()-shadow.bottom-shadow.top);
65 part.graphic[i]=part.graphic[NORMAL];
69 void Part::Loader::graphic(State s, const string &n)
71 part.graphic[s]=res.get<Graphic>(n);
74 void Part::Loader::align(int x, int y)
80 void Part::Loader::fill(bool x, bool y)