* Adds a new row of text to the list, automatically creating * the required Text objects lined up where they need to be. * @param cols Number of columns. * @param ... Text for each cell in the new row. */
| 246 | * @param ... Text for each cell in the new row. |
| 247 | */ |
| 248 | void TextList::addRow(int cols, ...) |
| 249 | { |
| 250 | va_list args; |
| 251 | va_start(args, cols); |
| 252 | std::vector<Text*> temp; |
| 253 | int rowX = 0, rows = 1; |
| 254 | |
| 255 | for (int i = 0; i < cols; ++i) |
| 256 | { |
| 257 | // Place text |
| 258 | Text* txt = new Text(_columns[i], _font->getHeight(), _margin + rowX, getY()); |
| 259 | txt->setPalette(this->getPalette()); |
| 260 | txt->initText(_big, _small, _lang); |
| 261 | txt->setColor(_color); |
| 262 | txt->setSecondaryColor(_color2); |
| 263 | if (_align[i]) |
| 264 | { |
| 265 | txt->setAlign(_align[i]); |
| 266 | } |
| 267 | txt->setHighContrast(_contrast); |
| 268 | if (_font == _big) |
| 269 | { |
| 270 | txt->setBig(); |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | txt->setSmall(); |
| 275 | } |
| 276 | txt->setText(va_arg(args, wchar_t*)); |
| 277 | // Wordwrap text if necessary |
| 278 | if (_wrap && txt->getTextWidth() > txt->getWidth()) |
| 279 | { |
| 280 | txt->setHeight(_font->getHeight() * 2 + _font->getSpacing()); |
| 281 | txt->setWordWrap(true, true); |
| 282 | rows = 2; |
| 283 | } |
| 284 | // Places dots between text |
| 285 | if (_dot && i < cols - 1) |
| 286 | { |
| 287 | std::wstring buf = txt->getText(); |
| 288 | int w = txt->getTextWidth(); |
| 289 | while (w < _columns[i]) |
| 290 | { |
| 291 | w += _font->getChar('.')->getCrop()->w + _font->getSpacing(); |
| 292 | buf += '.'; |
| 293 | } |
| 294 | txt->setText(buf); |
| 295 | } |
| 296 | |
| 297 | temp.push_back(txt); |
| 298 | if (_condensed) |
| 299 | { |
| 300 | rowX += txt->getTextWidth(); |
| 301 | } |
| 302 | else |
| 303 | { |
| 304 | rowX += _columns[i]; |
| 305 | } |