| 112 | }; |
| 113 | |
| 114 | DialogProgress::DialogProgress(wxWindow *parent, wxString const& title_text, wxString const& message) |
| 115 | : wxDialog(parent, -1, title_text, wxDefaultPosition, wxDefaultSize, wxBORDER_RAISED) |
| 116 | , pulse_timer(GetEventHandler()) |
| 117 | { |
| 118 | title = new wxStaticText(this, -1, title_text, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE); |
| 119 | gauge = new wxGauge(this, -1, 300, wxDefaultPosition, wxSize(300,20)); |
| 120 | text = new wxStaticText(this, -1, message, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE); |
| 121 | cancel_button = new wxButton(this, wxID_CANCEL); |
| 122 | log_output = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(600, 240), wxTE_MULTILINE | wxTE_READONLY); |
| 123 | |
| 124 | // make the title a slightly larger font |
| 125 | wxFont title_font = title->GetFont(); |
| 126 | int fontsize = title_font.GetPointSize(); |
| 127 | title_font.SetPointSize(fontsize * 1.375); |
| 128 | title_font.SetWeight(wxFONTWEIGHT_BOLD); |
| 129 | title->SetFont(title_font); |
| 130 | |
| 131 | wxSizer *sizer = new wxBoxSizer(wxVERTICAL); |
| 132 | sizer->Add(title, wxSizerFlags().Expand()); |
| 133 | sizer->Add(gauge, wxSizerFlags(1).Expand().Border()); |
| 134 | sizer->Add(text, wxSizerFlags().Expand()); |
| 135 | sizer->Add(cancel_button, wxSizerFlags().Center().Border()); |
| 136 | sizer->Add(log_output, wxSizerFlags().Expand().Border(wxALL & ~wxTOP)); |
| 137 | sizer->Hide(log_output); |
| 138 | |
| 139 | SetSizerAndFit(sizer); |
| 140 | CenterOnParent(); |
| 141 | |
| 142 | Bind(wxEVT_SHOW, &DialogProgress::OnShow, this); |
| 143 | Bind(wxEVT_TIMER, [=, this](wxTimerEvent&) { gauge->Pulse(); }); |
| 144 | } |
| 145 | |
| 146 | void DialogProgress::Run(std::function<void(agi::ProgressSink*)> task) { |
| 147 | DialogProgressSink ps(this); |