using std::string;
using std::list;
using std::map;
+using std::min;
using std::cout;
using boost::shared_ptr;
using boost::weak_ptr;
, _window (window)
, _panel (panel)
, _table (table)
+ , _pause (0)
{
int n = 0;
- wxStaticText* m = new wxStaticText (panel, wxID_ANY, std_to_wx (_job->name ()));
- table->Insert (n, m, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6);
+ _name = new wxStaticText (panel, wxID_ANY, "");
+ string const jn = "<b>" + _job->name () + "</b>";
+ _name->SetLabelMarkup (std_to_wx (jn));
+ table->Insert (n, _name, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6);
++n;
_gauge = new wxGauge (panel, wxID_ANY, 100);
+ /* This seems to be required to allow the gauge to shrink under OS X */
+ _gauge->SetMinSize (wxSize (0, -1));
table->Insert (n, _gauge, 1, wxEXPAND | wxLEFT | wxRIGHT);
++n;
private:
+ void update_job_name ()
+ {
+ string n = "<b>" + _job->name () + "</b>";
+ if (!_job->sub_name().empty ()) {
+ n += "\n" + _job->sub_name ();
+ }
+
+ if (n != _last_name) {
+ _name->SetLabelMarkup (std_to_wx (n));
+ _last_name = n;
+ }
+ }
+
void progress ()
{
- float const p = _job->overall_progress ();
+ float const p = _job->progress ();
if (p >= 0) {
checked_set (_message, _job->status ());
- _gauge->SetValue (p * 100);
+ update_job_name ();
+ int const pp = min (100.0f, p * 100);
+ _gauge->SetValue (pp);
}
_table->Layout ();
void finished ()
{
checked_set (_message, _job->status ());
+ update_job_name ();
+
if (!_job->finished_cancelled ()) {
_gauge->SetValue (100);
}
_cancel->Enable (false);
+ if (_pause) {
+ _pause->Enable (false);
+ }
if (!_job->error_details().empty ()) {
_details->Enable (true);
}
wxScrolledWindow* _window;
wxPanel* _panel;
wxFlexGridSizer* _table;
+ wxStaticText* _name;
wxGauge* _gauge;
wxStaticText* _message;
wxButton* _cancel;
wxButton* _pause;
wxButton* _details;
+ std::string _last_name;
};
/** Must be called in the GUI thread */
_panel->SetSizer (_table);
SetScrollRate (0, 32);
+ EnableScrolling (false, true);
Bind (wxEVT_TIMER, boost::bind (&JobManagerView::periodic, this));
_timer.reset (new wxTimer (this));
_timer->Start (1000);
-
+
+ Bind (wxEVT_SIZE, boost::bind (&JobManagerView::sized, this, _1));
JobManager::instance()->JobAdded.connect (bind (&JobManagerView::job_added, this, _1));
}
+void
+JobManagerView::sized (wxSizeEvent& ev)
+{
+ _table->FitInside (_panel);
+ _table->Layout ();
+ ev.Skip ();
+}
+
void
JobManagerView::job_added (weak_ptr<Job> j)
{