- Small improvements. We'd need a derived CellRenderer to put

this into a TreeView


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@917 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-08-20 20:55:29 +00:00
parent 1fe3c4ddf7
commit 0f94562617
2 changed files with 34 additions and 11 deletions

View File

@ -18,50 +18,71 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "gettext.h"
#include "schedulable_state_widget.hh"
#include <glibmm/ustring.h>
#include <cassert>
using namespace sgpem;
Gtk::Tooltips
SchedulableStateWidget::_ttips;
Gtk::Tooltips*
SchedulableStateWidget::_ttips = NULL;
SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
: _color(1, 1, 1)
: Glib::ObjectBase("sgpem_SchedulableStateWidget"), CairoWidget(), _color(1, 1, 1)
{
// Yes, we leak, but this will be up until the end of the app
if(!_ttips) _ttips = new Gtk::Tooltips();
set_scaling_mode(scaling_to_w);
set_state(st);
}
SchedulableStateWidget::~SchedulableStateWidget()
{
_ttips->unset_tip(*this);
}
void
SchedulableStateWidget::set_state(Schedulable::state new_state)
{
Glib::ustring tip;
switch(new_state)
{
case Schedulable::state_future:
_color = Color(1, 1, 1); // White
_ttips.set_tip(*this, "Future");
tip = _("Future");
break;
case Schedulable::state_ready:
_color = Color(1, 1, 0); // Yellow
_ttips.set_tip(*this, "Ready");
tip = _("Ready");
break;
case Schedulable::state_running:
_color = Color(0, 1, 0); // Green
_ttips.set_tip(*this, "Running");
tip = _("Running");
break;
case Schedulable::state_blocked:
_color = Color(0, 0, 1); // Blue
_ttips.set_tip(*this, "Blocked");
tip = _("Blocked");
break;
case Schedulable::state_terminated:
_color = Color(0, 0, 0); // Black
_ttips.set_tip(*this, "Terminated");
tip = _("Terminated");
break;
}
if(is_realized())
{
assert(has_no_window() == false);
_ttips->set_tip(*this, tip);
}
queue_draw();
}

View File

@ -27,6 +27,7 @@
#include "cairo_elements.hh"
#include "cairo_widget.hh"
#include "glibmm/refptr.h"
#include "gtkmm/tooltips.h"
namespace sgpem
@ -35,11 +36,12 @@ namespace sgpem
{
public:
SchedulableStateWidget(Schedulable::state st);
~SchedulableStateWidget();
void set_state(Schedulable::state new_state);
protected:
virtual void draw_widget(cairo_t* ctx) = 0;
virtual void draw_widget(cairo_t* ctx);
// with this method CairoWidget tells the needed drawing dimensions
virtual void calc_drawing_size(size_t& width, size_t& height) const;
@ -48,8 +50,8 @@ namespace sgpem
virtual void calc_widget_size(size_t& width, size_t& height) const;
private:
Color _color;
static Gtk::Tooltips _ttips;
Color _color;
static Gtk::Tooltips* _ttips;
};
} //~ namespace sgpem