- 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:
parent
1fe3c4ddf7
commit
0f94562617
|
@ -18,50 +18,71 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
#include "schedulable_state_widget.hh"
|
#include "schedulable_state_widget.hh"
|
||||||
|
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
|
|
||||||
Gtk::Tooltips
|
Gtk::Tooltips*
|
||||||
SchedulableStateWidget::_ttips;
|
SchedulableStateWidget::_ttips = NULL;
|
||||||
|
|
||||||
|
|
||||||
SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
|
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_scaling_mode(scaling_to_w);
|
||||||
set_state(st);
|
set_state(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SchedulableStateWidget::~SchedulableStateWidget()
|
||||||
|
{
|
||||||
|
_ttips->unset_tip(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SchedulableStateWidget::set_state(Schedulable::state new_state)
|
SchedulableStateWidget::set_state(Schedulable::state new_state)
|
||||||
{
|
{
|
||||||
|
Glib::ustring tip;
|
||||||
switch(new_state)
|
switch(new_state)
|
||||||
{
|
{
|
||||||
case Schedulable::state_future:
|
case Schedulable::state_future:
|
||||||
_color = Color(1, 1, 1); // White
|
_color = Color(1, 1, 1); // White
|
||||||
_ttips.set_tip(*this, "Future");
|
tip = _("Future");
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_ready:
|
case Schedulable::state_ready:
|
||||||
_color = Color(1, 1, 0); // Yellow
|
_color = Color(1, 1, 0); // Yellow
|
||||||
_ttips.set_tip(*this, "Ready");
|
tip = _("Ready");
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_running:
|
case Schedulable::state_running:
|
||||||
_color = Color(0, 1, 0); // Green
|
_color = Color(0, 1, 0); // Green
|
||||||
_ttips.set_tip(*this, "Running");
|
tip = _("Running");
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_blocked:
|
case Schedulable::state_blocked:
|
||||||
_color = Color(0, 0, 1); // Blue
|
_color = Color(0, 0, 1); // Blue
|
||||||
_ttips.set_tip(*this, "Blocked");
|
tip = _("Blocked");
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_terminated:
|
case Schedulable::state_terminated:
|
||||||
_color = Color(0, 0, 0); // Black
|
_color = Color(0, 0, 0); // Black
|
||||||
_ttips.set_tip(*this, "Terminated");
|
tip = _("Terminated");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_realized())
|
||||||
|
{
|
||||||
|
assert(has_no_window() == false);
|
||||||
|
_ttips->set_tip(*this, tip);
|
||||||
|
}
|
||||||
|
|
||||||
queue_draw();
|
queue_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "cairo_elements.hh"
|
#include "cairo_elements.hh"
|
||||||
#include "cairo_widget.hh"
|
#include "cairo_widget.hh"
|
||||||
|
|
||||||
|
#include "glibmm/refptr.h"
|
||||||
#include "gtkmm/tooltips.h"
|
#include "gtkmm/tooltips.h"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
|
@ -35,11 +36,12 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SchedulableStateWidget(Schedulable::state st);
|
SchedulableStateWidget(Schedulable::state st);
|
||||||
|
~SchedulableStateWidget();
|
||||||
|
|
||||||
void set_state(Schedulable::state new_state);
|
void set_state(Schedulable::state new_state);
|
||||||
|
|
||||||
protected:
|
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
|
// with this method CairoWidget tells the needed drawing dimensions
|
||||||
virtual void calc_drawing_size(size_t& width, size_t& height) const;
|
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;
|
virtual void calc_widget_size(size_t& width, size_t& height) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Color _color;
|
Color _color;
|
||||||
static Gtk::Tooltips _ttips;
|
static Gtk::Tooltips* _ttips;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
||||||
|
|
Loading…
Reference in New Issue