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

Method UpdateWidgetSize

src/date_gui.cpp:102–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100 }
101
102 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
103 {
104 Dimension d = {0, 0};
105 switch (widget) {
106 default: return;
107
108 case WID_SD_DAY:
109 for (uint i = 0; i < 31; i++) {
110 d = maxdim(d, GetStringBoundingBox(STR_DAY_NUMBER_1ST + i));
111 }
112 break;
113
114 case WID_SD_MONTH:
115 for (uint i = 0; i < 12; i++) {
116 d = maxdim(d, GetStringBoundingBox(STR_MONTH_JAN + i));
117 }
118 break;
119
120 case WID_SD_YEAR:
121 d = maxdim(d, GetStringBoundingBox(GetString(STR_JUST_INT, GetParamMaxValue(this->max_year.base()))));
122 break;
123 }
124
125 d.width += padding.width;
126 d.height += padding.height;
127 size = d;
128 }
129
130 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
131 {

Callers

nothing calls this directly

Calls 5

maxdimFunction · 0.85
GetStringBoundingBoxFunction · 0.85
GetParamMaxValueFunction · 0.85
GetStringFunction · 0.70
baseMethod · 0.45

Tested by

no test coverage detected