MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / addRow

Method addRow

src/Interface/TextList.cpp:248–349  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

246 * @param ... Text for each cell in the new row.
247 */
248void 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 }

Callers 15

DebriefingStateMethod · 0.80
CannotReequipStateMethod · 0.80
PromotionsStateMethod · 0.80
fillProjectListMethod · 0.80
TransfersStateMethod · 0.80
fillProductionListMethod · 0.80
fillProjectListMethod · 0.80
TransferBaseStateMethod · 0.80
initMethod · 0.80
MonthlyCostsStateMethod · 0.80
fillProductionListMethod · 0.80
populateBuildListMethod · 0.80

Calls 15

getTextWidthMethod · 0.80
getSpacingMethod · 0.80
getCropMethod · 0.80
getCharMethod · 0.80
setListButtonMethod · 0.80
onMouseClickMethod · 0.80
onMousePressMethod · 0.80
onMouseReleaseMethod · 0.80
getHeightMethod · 0.45
setPaletteMethod · 0.45
getPaletteMethod · 0.45
initTextMethod · 0.45

Tested by 1

TestStateMethod · 0.64