#include "positionlabel.hpp"
PositionLabel::PositionLabel (int elevator, const std::string text)
- : Gtk::Label (text)
+ : Gtk::Table (1, 2)
+ , label_(text)
+ , direction_img_(Gtk::Stock::YES, Gtk::ICON_SIZE_BUTTON)
, elevator_(elevator)
{
- // Intentionally Left Empty
+ attach (label_, 0, 1, 0, 1);
+ attach (direction_img_, 1, 2, 0, 1);
+ show ();
}
int PositionLabel::getElevatorNumber () const
return elevator_;
}
+void PositionLabel::update_position (float floor, Direction direction)
+{
+ switch (direction)
+ {
+ case UP:
+ direction_img_.set(Gtk::Stock::GO_UP, Gtk::ICON_SIZE_BUTTON);
+ break;
+ case DOWN:
+ direction_img_.set(Gtk::Stock::GO_DOWN, Gtk::ICON_SIZE_BUTTON);
+ break;
+ case IDLE:
+ direction_img_.set(Gtk::Stock::YES, Gtk::ICON_SIZE_BUTTON);
+ break;
+ default:
+ std::cout << "Bad direction in PositionLabel->update_position(" << floor
+ << ", " << direction << ")" << std::endl;
+ break;
+ }
+
+ std::ostringstream str;
+
+ // Generate the text
+ str << std::setiosflags (std::ios_base::showpoint | std::ios_base::fixed)
+ << std::setprecision(1) << floor;
+
+ label_.set_text (str.str());
+}
+
+
/* vim: set ts=4 sts=4 sw=4 noet tw=112: */