X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fui%2Fwidgets.cpp;h=a81defc0e549cc983795808a71c45988c154e4f7;hp=b0d44e20969fa23a55bbfe589e76d4b0fa3332be;hb=392826deaf802ac0960ed3924a3f98b9d18d381b;hpb=b4deadd9f4e399207e2530ea39a447c0d9d260a3 diff --git a/src/ui/widgets.cpp b/src/ui/widgets.cpp index b0d44e2..a81defc 100644 --- a/src/ui/widgets.cpp +++ b/src/ui/widgets.cpp @@ -35,61 +35,6 @@ Label *Label::Text(const std::string &t) { return this; } -Label *Label::Decimal(double n, int prec) { - std::stringstream s; - s << std::fixed << std::setprecision(prec) << n; - return Text(s.str()); -} - -Label *Label::Length(double m) { - std::stringstream s; - s << std::fixed << std::setprecision(3); - if (m > 1500.0) { - s << (m * 0.001) << "km"; - } else if (m < 0.1) { - s << (m * 1000.0) << "mm"; - } else { - s << m << "m"; - } - return Text(s.str()); -} - -Label *Label::Mass(double kg) { - std::stringstream s; - s << std::fixed << std::setprecision(3); - if (kg > 1500.0) { - s << (kg * 0.001) << "t"; - } else if (kg < 0.1) { - s << (kg * 1000.0) << "g"; - } else if (kg < 0.0001) { - s << (kg * 1.0e6) << "mg"; - } else { - s << kg << "kg"; - } - return Text(s.str()); -} - -Label *Label::Percentage(double n) { - std::stringstream s; - s << std::fixed << std::setprecision(1) << (n * 100.0) << '%'; - return Text(s.str()); -} - -Label *Label::Time(double s) { - int is = int(s); - std::stringstream ss; - if (is >= 3600) { - ss << (is / 3600) << "h "; - is %= 3600; - } - if (is >= 60) { - ss << (is / 60) << "m "; - is %= 60; - } - ss << is << 's'; - return Text(ss.str()); -} - Label *Label::Font(const graphics::Font &f) { if (font != &f) { dirty = true;