MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawWidget

Method DrawWidget

src/news_gui.cpp:1226–1243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1224 }
1225
1226 void DrawWidget(const Rect &r, WidgetID widget) const override
1227 {
1228 if (widget != WID_MH_BACKGROUND || std::empty(_news)) return;
1229
1230 /* Fill the widget with news items. */
1231 bool rtl = _current_text_dir == TD_RTL;
1232 Rect news = r.Shrink(WidgetDimensions::scaled.framerect).Indent(this->date_width + WidgetDimensions::scaled.hsep_wide, rtl);
1233 Rect date = r.Shrink(WidgetDimensions::scaled.framerect).WithWidth(this->date_width, rtl);
1234 int y = news.top;
1235
1236 auto [first, last] = this->vscroll->GetVisibleRangeIterators(_news);
1237 for (auto ni = first; ni != last; ++ni) {
1238 DrawString(date.left, date.right, y, GetString(STR_JUST_DATE_TINY, ni->date), TC_WHITE);
1239
1240 DrawNewsString(news.left, news.right, y, TC_WHITE, *ni);
1241 y += this->line_height;
1242 }
1243 }
1244
1245 /**
1246 * Some data on this window has become invalid.

Callers

nothing calls this directly

Calls 8

emptyFunction · 0.85
DrawNewsStringFunction · 0.85
IndentMethod · 0.80
ShrinkMethod · 0.80
WithWidthMethod · 0.80
DrawStringFunction · 0.70
GetStringFunction · 0.70

Tested by

no test coverage detected