/*! Find the height for a given width \param defaultFont Font, used for the calculation if the text has no font \param width Width \return Calculated height */ int QwtText::heightForWidth(int width, const QFont &defaultFont) const { const QwtMetricsMap map = QwtPainter::metricsMap(); width = map.layoutToScreenX(width); #if QT_VERSION < 0x040000 const QFont font = usedFont(defaultFont); #else // We want to calculate in screen metrics. So // we need a font that uses screen metrics const QFont font(usedFont(defaultFont), QApplication::desktop()); #endif int h = 0; if ( d_data->layoutAttributes & MinimumLayout ) { int left, right, top, bottom; d_data->textEngine->textMargins(font, d_data->text, left, right, top, bottom); h = d_data->textEngine->heightForWidth( font, d_data->renderFlags, d_data->text, width + left + right); h -= top + bottom; } else { h = d_data->textEngine->heightForWidth( font, d_data->renderFlags, d_data->text, width); } h = map.screenToLayoutY(h); return h; }
/** * Prepares to draw info about best solver. * @param status shared level status */ SolverDrawer::SolverDrawer(LevelStatus *status) { try { Font usedFont(Path::dataReadPath("font/font_menu.ttf"), 14); SDL_Color usedColor = {255, 255, 255, 255}; Labels labels(Path::dataReadPath("script/labels.lua")); const char *labelName; switch (status->compareToBest()) { case 1: labelName = "solver_better"; break; case 0: labelName = "solver_equals"; break; default: labelName = "solver_worse"; } StringTool::t_args args; args.push_back(""); args.push_back(StringTool::toString(status->getBestMoves())); args.push_back(status->getBestAuthor()); WiPara *para = new WiPara( labels.getFormatedLabel(labelName, args), usedFont, usedColor); para->enableCentered(); para->recenter(); addWidget(para); } catch (BaseException &e) { LOG_WARNING(e.info()); } }
//----------------------------------------------------------------- MenuHelp::MenuHelp() { Font usedFont(Path::dataReadPath("font/font_menu.ttf"), 14); SDL_Color usedColor = {255, 255, 255, 255}; Labels labels(Path::dataReadPath("script/labels.lua")); m_help = new WiPara(labels.getLabel("help"), usedFont, usedColor); takeHandler(new HelpInput(this)); registerDrawable(this); registerDrawable(m_help); }