3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
13 bool Geometry::is_inside(int x_, int y_) const
15 return (x_>=x && x_<x+static_cast<int>(w) && y_>=y && y_<y+static_cast<int>(h));
18 bool Geometry::is_inside_relative(int x_, int y_) const
20 return (x_>=0 && x_<static_cast<int>(w) && y_>=0 && y_<static_cast<int>(h));
32 Sides::Loader::Loader(Sides &s):
35 add("top", &Sides::top);
36 add("right", &Sides::right);
37 add("bottom", &Sides::bottom);
38 add("left", &Sides::left);
42 void Alignment::apply(Geometry &geom, const Geometry &parent) const
45 geom.w+=static_cast<unsigned>((parent.w-geom.w)*w);
47 geom.h+=static_cast<unsigned>((parent.h-geom.h)*h);
49 geom.x+=static_cast<int>((parent.w-geom.w)*x);
50 geom.y+=static_cast<int>((parent.h-geom.h)*y);
53 void Alignment::apply(Geometry &geom, const Geometry &parent, const Sides &margin) const
55 unsigned pw=parent.w-margin.left-margin.right;
56 unsigned ph=parent.h-margin.bottom-margin.top;
59 geom.w+=static_cast<unsigned>((pw-geom.w)*w);
61 geom.h+=static_cast<unsigned>((ph-geom.h)*h);
63 geom.x+=static_cast<int>(margin.left+(pw-geom.w)*x);
64 geom.y+=static_cast<int>(margin.bottom+(ph-geom.h)*y);