* Try to set optimum widget size for a multiline text widget. * The window will need to be reinited if the size is changed. * @param str Multiline string contents that will fill the widget. * @param max_line Maximum number of lines. * @return true iff the widget minimum size has changed. */
| 1112 | * @return true iff the widget minimum size has changed. |
| 1113 | */ |
| 1114 | bool NWidgetResizeBase::UpdateMultilineWidgetSize(const std::string &str, int max_lines) |
| 1115 | { |
| 1116 | int y = GetStringHeight(str, this->current_x); |
| 1117 | if (y > max_lines * GetCharacterHeight(FS_NORMAL)) { |
| 1118 | /* Text at the current width is too tall, so try to guess a better width. */ |
| 1119 | Dimension d = GetStringBoundingBox(str); |
| 1120 | d.height *= max_lines; |
| 1121 | d.width /= 2; |
| 1122 | return this->UpdateSize(d.width, d.height); |
| 1123 | } |
| 1124 | return this->UpdateVerticalSize(y); |
| 1125 | } |
| 1126 | |
| 1127 | /** |
| 1128 | * Set absolute (post-scaling) minimal size of the widget. |
no test coverage detected