diff --git a/src/util/alignment.cpp b/src/util/alignment.cpp index 0b81fb44..6f1921e0 100644 --- a/src/util/alignment.cpp +++ b/src/util/alignment.cpp @@ -34,13 +34,23 @@ RealPoint align_in_rect(Alignment align, const RealSize& to_align, const RealRec // ----------------------------------------------------------------------------- : Reflection stuff /// Convert a String to an Alignment -Alignment fromString(const String& str) { - int al = 0; +Alignment from_string(const String& s) { + int al = ALIGN_TOP_LEFT; + if (s.find(_("left")) !=String::npos) al = ALIGN_LEFT | (al & ALIGN_VERTICAL); + if (s.find(_("center")) !=String::npos) al = ALIGN_CENTER | (al & ALIGN_VERTICAL); + if (s.find(_("right")) !=String::npos) al = ALIGN_RIGHT | (al & ALIGN_VERTICAL); + if (s.find(_("justify")) !=String::npos) al = ALIGN_JUSTIFY | (al & ALIGN_VERTICAL); + if (s.find(_("justify-words")) !=String::npos) al = ALIGN_JUSTIFY_WORDS | (al & ALIGN_VERTICAL); + if (s.find(_("shrink-overflow"))!=String::npos) al = ALIGN_JUSTIFY_OVERFLOW | (al & ~ALIGN_JUSTIFY_OVERFLOW); + if (s.find(_("top")) !=String::npos) al = ALIGN_TOP | (al & ALIGN_HORIZONTAL); + if (s.find(_("middle")) !=String::npos) al = ALIGN_MIDDLE | (al & ALIGN_HORIZONTAL); + if (s.find(_("bottom")) !=String::npos) al = ALIGN_BOTTOM | (al & ALIGN_HORIZONTAL); + if (s.find(_("stretch")) !=String::npos) al = ALIGN_STRETCH; return static_cast(al); } /// Convert an Alignment to a String -String toString(Alignment align) { +String to_string(Alignment align) { String ret; // vertical if (align & ALIGN_TOP) ret += _(" top"); @@ -61,11 +71,11 @@ String toString(Alignment align) { // we need custom io, because there can be both a horizontal and a vertical component template <> void Reader::handle(Alignment& align) { - align = fromString(value); + align = from_string(value); } template <> void Writer::handle(const Alignment& align) { - handle(toString(align)); + handle(to_string(align)); } template <> void GetDefaultMember::handle(const Alignment& align) { - handle(toString(align)); + handle(to_string(align)); }