| 179 | } |
| 180 | |
| 181 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 182 | { |
| 183 | switch (widget) { |
| 184 | case WID_EM_FACE: { |
| 185 | const Company *c = Company::Get(this->company); |
| 186 | DrawCompanyManagerFace(c->face, c->colour, r); |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | case WID_EM_MESSAGE: |
| 191 | if (this->detailed_msg.empty()) { |
| 192 | DrawStringMultiLineWithClipping(r, this->summary_msg.GetDecodedString(), TC_FROMSTRING, SA_CENTER); |
| 193 | } else if (this->extra_msg.empty()) { |
| 194 | /* Extra space when message is shorter than company face window */ |
| 195 | int extra = (r.Height() - this->height_summary - this->height_detailed - WidgetDimensions::scaled.vsep_wide) / 2; |
| 196 | |
| 197 | /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */ |
| 198 | DrawStringMultiLineWithClipping(r.WithHeight(this->height_summary + extra, false), this->summary_msg.GetDecodedString(), TC_WHITE, SA_CENTER); |
| 199 | DrawStringMultiLineWithClipping(r.WithHeight(this->height_detailed + extra, true), this->detailed_msg.GetDecodedString(), TC_WHITE, SA_CENTER); |
| 200 | } else { |
| 201 | /* Extra space when message is shorter than company face window */ |
| 202 | int extra = (r.Height() - this->height_summary - this->height_detailed - this->height_extra - (WidgetDimensions::scaled.vsep_wide * 2)) / 3; |
| 203 | |
| 204 | /* Note: NewGRF supplied error message often do not start with a colour code, so default to white. */ |
| 205 | Rect top_section = r.WithHeight(this->height_summary + extra, false); |
| 206 | Rect bottom_section = r.WithHeight(this->height_extra + extra, true); |
| 207 | Rect middle_section = top_section.WithY(top_section.bottom, bottom_section.top); |
| 208 | DrawStringMultiLineWithClipping(top_section, this->summary_msg.GetDecodedString(), TC_WHITE, SA_CENTER); |
| 209 | DrawStringMultiLineWithClipping(middle_section, this->detailed_msg.GetDecodedString(), TC_WHITE, SA_CENTER); |
| 210 | DrawStringMultiLineWithClipping(bottom_section, this->extra_msg.GetDecodedString(), TC_WHITE, SA_CENTER); |
| 211 | } |
| 212 | |
| 213 | break; |
| 214 | |
| 215 | default: |
| 216 | break; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void OnPaint() override |
| 221 | { |
nothing calls this directly
no test coverage detected