| 875 | } |
| 876 | |
| 877 | wxStatusBar* ProjectWindow::CreateProjectStatusBar() |
| 878 | { |
| 879 | auto statusBar = GetStatusBar(); |
| 880 | |
| 881 | if (statusBar != nullptr) |
| 882 | statusBar->Destroy(); |
| 883 | |
| 884 | auto pProject = FindProject(); |
| 885 | |
| 886 | // Note that the first field of the status bar is a dummy, and its width is |
| 887 | // set to zero latter in the code. This field is needed for wxWidgets 2.8.12 |
| 888 | // because if you move to the menu bar, the first field of the menu bar is |
| 889 | // cleared, which is undesirable behaviour. In addition, the help strings of |
| 890 | // menu items are by default sent to the first field. Currently there are no |
| 891 | // such help strings, but it they were introduced, then there would need to |
| 892 | // be an event handler to send them to the appropriate field. |
| 893 | statusBar = CreateStatusBar( |
| 894 | 1 + ProjectStatusFieldsRegistry::Count(pProject.get())); |
| 895 | |
| 896 | statusBar->Bind( |
| 897 | wxEVT_SIZE, |
| 898 | [this](auto& evt) |
| 899 | { |
| 900 | evt.Skip(); |
| 901 | auto pProject = FindProject(); |
| 902 | if (pProject != nullptr) |
| 903 | ProjectStatusFieldsRegistry::OnSize(*pProject); |
| 904 | }); |
| 905 | |
| 906 | // We have a new status bar now, we need a full content update |
| 907 | if (pProject) |
| 908 | { |
| 909 | int index = 1; |
| 910 | ProjectStatusFieldsRegistry::Visit( |
| 911 | [&](const StatusBarFieldItem& field, const auto&) |
| 912 | { |
| 913 | if (field.IsVisible(*pProject)) |
| 914 | statusBar->SetStatusText( |
| 915 | field.GetText(*pProject).Translation(), index++); |
| 916 | }); |
| 917 | } |
| 918 | |
| 919 | return statusBar; |
| 920 | } |
| 921 | |
| 922 | void ProjectWindow::UpdateStatusWidths() |
| 923 | { |
no test coverage detected