Update the message text
| 1552 | // Update the message text |
| 1553 | // |
| 1554 | void ProgressDialog::SetMessage(const TranslatableString & message) |
| 1555 | { |
| 1556 | if (!message.empty()) |
| 1557 | { |
| 1558 | mMessage->SetLabel(message.Translation()); |
| 1559 | |
| 1560 | int w, h; |
| 1561 | wxClientDC dc(mMessage); |
| 1562 | dc.GetMultiLineTextExtent(message.Translation(), &w, &h); |
| 1563 | |
| 1564 | auto sizeUpdated = false; |
| 1565 | const auto currentSize = GetClientSize(); |
| 1566 | auto ds = currentSize; |
| 1567 | |
| 1568 | // TODO: make the following work in case of message tables |
| 1569 | if (w > mLastW) |
| 1570 | { |
| 1571 | ds.x += (w - mLastW); |
| 1572 | sizeUpdated = true; |
| 1573 | mLastW = w; |
| 1574 | } |
| 1575 | |
| 1576 | if (h > mLastH) |
| 1577 | { |
| 1578 | ds.y += (h - mLastH); |
| 1579 | sizeUpdated = true; |
| 1580 | mLastH = h; |
| 1581 | } |
| 1582 | |
| 1583 | if (sizeUpdated) |
| 1584 | { |
| 1585 | #if defined(__WXMAC__) |
| 1586 | wxSize sz = mMessage->GetSize(); |
| 1587 | mMessage->SetMinSize(wxSize(wxMax(sz.x, mLastW), wxMax(sz.y, mLastH))); |
| 1588 | #endif |
| 1589 | // No need to adjust for the margin here since we only add |
| 1590 | // to the existing dimensions. |
| 1591 | ds.x = wxMax(wxMax(ds.x, mLastW), wxMax(ds.y, mLastH)); |
| 1592 | SetClientSize(ds); |
| 1593 | SetPosition(GetPosition() - (ds - currentSize) / 2); |
| 1594 | wxDialogWrapper::Update(); |
| 1595 | } |
| 1596 | } |
| 1597 | } |
| 1598 | |
| 1599 | // |
| 1600 | // Recursivaly search the window list for the given window. |