From 3dbb0dbd8038d76c3434418c961d440063b5ac58 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Wed, 6 Sep 2006 18:56:42 +0000 Subject: [PATCH] - Prettify ReadyQueueWidget adding also the printout of the current simulation instant git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1031 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/holt_widget.cc | 5 ++++- src/ready_queue_widget.cc | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/holt_widget.cc b/src/holt_widget.cc index 525afbd..5b766b6 100644 --- a/src/holt_widget.cc +++ b/src/holt_widget.cc @@ -705,7 +705,10 @@ HoltWidget::draw_widget(cairo_t* ctx) void HoltWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height) { +#ifndef DNDEBUG cout << "Holt widget BEFORE calc_drawing_size width=" << width << " height=" << height << endl; +#endif + // int pos = _simulation->get_front(); // const History& hist = _simulation->get_history(); int max = _n_proc; @@ -714,7 +717,7 @@ HoltWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height) cairo_text_extents_t extents; // std::cout << " x_unit: " << std::endl; - Glib::ustring val("Process 999 Resource 999"); + static const Glib::ustring val("Process 999 Resource 999"); cairo_text_extents(ctx, val.c_str(), &extents); _radius = extents.width/4.0; diff --git a/src/ready_queue_widget.cc b/src/ready_queue_widget.cc index dee519b..9f5a1ce 100644 --- a/src/ready_queue_widget.cc +++ b/src/ready_queue_widget.cc @@ -35,11 +35,11 @@ using namespace sgpem; static const Glib::ustring string_start = _("Ready queue: { "); -static const Glib::ustring string_end = " }"; -static const Glib::ustring separator = " ~ "; +static const Glib::ustring string_end = _(" } at instant "); +static const Glib::ustring separator = " ~ "; ReadyQueueWidget::ReadyQueueWidget(History& history) - : Gtk::Label(string_start + string_end), _h(history) + : Gtk::Label(string_start + string_end + "0"), _h(history) { _h.attach(*this); @@ -58,16 +58,18 @@ ReadyQueueWidget::~ReadyQueueWidget() void ReadyQueueWidget::update(const History& changed_history) { - Glib::ustring text(string_start); - + std::ostringstream oss; + oss << string_start; + const ReadyQueue& rq = changed_history.get_last_environment().get_sorted_queue(); size_t size = rq.size(); for(size_t i = 0; i < size; ++i) - text += Glib::Markup::escape_text(rq.get_item_at(i).get_name()) + separator; + oss << Glib::Markup::escape_text(rq.get_item_at(i).get_name()) << separator; - text += string_end; + unsigned int instant = changed_history.get_front() == 0 ? 0 : changed_history.get_front() - 1; + oss << string_end << instant; - set_markup(text); + set_markup(oss.str()); }