diff --git a/Makefile.am b/Makefile.am
index 9d8fc66..89e3d1e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -295,7 +295,7 @@ sgpemv2_SOURCES = \
src/main.cc \
src/parse_opts.cc \
src/schedulables_tree_widget.cc \
- src/schedulables_widget.cc \
+ src/simulation_widget.cc \
src/text_simulation.cc
noinst_HEADERS += \
@@ -305,7 +305,7 @@ noinst_HEADERS += \
src/main.hh \
src/parse_opts.hh \
src/schedulables_tree_widget.hh \
- src/schedulables_widget.hh \
+ src/simulation_widget.hh \
src/text_simulation.hh
# ---------- glade files -----------
diff --git a/glade/main-window.glade b/glade/main-window.glade
index f4e3c58..a37805a 100644
--- a/glade/main-window.glade
+++ b/glade/main-window.glade
@@ -2,7 +2,7 @@
@@ -226,9 +226,6 @@
-
- False
-
diff --git a/src/cairo_widget.cc b/src/cairo_widget.cc
index 3d28e0b..ca95689 100644
--- a/src/cairo_widget.cc
+++ b/src/cairo_widget.cc
@@ -29,13 +29,12 @@
#include
#include
-
using namespace sgpem;
CairoWidget::CairoWidget()
: Glib::ObjectBase("sgpem_CairoWidget"),
- Gtk::Widget(), _h(1), _buf(NULL)
+ Gtk::Widget(), _w(1), _h(1), _buf(NULL)
{
set_flags(Gtk::NO_WINDOW);
// Register this observer:
@@ -58,10 +57,9 @@ CairoWidget::update(const History& history)
return; // Nowhere to draw to.
// Determine the final height before to start drawing
- unsigned int w = get_allocation().get_width();
- _h = calc_height(history);
+ calc_size(history, _w, _h);
- _buf = Gdk::Pixmap::create(get_window(), w, _h);
+ _buf = Gdk::Pixmap::create(get_window(), _w, _h);
// Draw the widget background as the first thing.
// I've seen this is how it's done in the very Gtk+ toolkit
@@ -70,18 +68,16 @@ CairoWidget::update(const History& history)
gtk_paint_box(gStyle, _buf->gobj(),
GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
NULL, this->gobj(), "through",
- 0, 0, w, _h);
+ 0, 0, _w, _h);
cairo_t* ctx = gdk_cairo_create(_buf->gobj());
// do the drawing...
+ cairo_scale(ctx, _w, _h);
draw_widget(ctx);
-
- cairo_scale(ctx, w, _h);
-
- // manually force an expose_event?
cairo_destroy(ctx);
+ // Force redraw
queue_draw();
}
@@ -125,15 +121,6 @@ CairoWidget::on_realize()
get_style()->set_background(window, Gtk::STATE_ACTIVE);
}
-void
-CairoWidget::on_size_request(Gtk::Requisition* requisition)
-{
- // FIXME: take correct measures, consider also using a viewport(?)
- *requisition = Gtk::Requisition();
- requisition->width = get_allocation().get_width();
- requisition->height = _h;
-}
-
void
CairoWidget::on_size_allocate(const Gtk::Allocation& allocation)
@@ -152,9 +139,8 @@ CairoWidget::on_expose_event(GdkEventExpose* event)
if (event == NULL || event->count > 0)
return false;
- // calculated dinamically:
- int w = get_allocation().get_width();
- set_size_request(w, _h);
+ // calculated dinamically on update():
+ set_size_request(_w, _h);
// Clip to redraw only the smallest possible area
// Use double buffering or we're CPU-dead
diff --git a/src/cairo_widget.hh b/src/cairo_widget.hh
index e6a6341..13d02bc 100644
--- a/src/cairo_widget.hh
+++ b/src/cairo_widget.hh
@@ -40,13 +40,14 @@ namespace sgpem
void update(const History& history);
protected:
+ typedef unsigned int size_t;
+
virtual void on_realize();
virtual void on_size_allocate(const Gtk::Allocation& allocation);
- virtual void on_size_request(Gtk::Requisition* requisition);
virtual bool on_expose_event(GdkEventExpose* event);
virtual bool on_button_press_event(GdkEventButton* event);
virtual void draw_widget(cairo_t* ctx) = 0;
- virtual unsigned int calc_height(const History& history) const = 0;
+ virtual void calc_size(const History& history, size_t& width, size_t& height) const = 0;
typedef Gdk::Rectangle area_t;
typedef sigc::mem_functor0 method0_t;
@@ -54,9 +55,10 @@ namespace sgpem
typedef std::vector areas_vect_t;
private:
- // The height the widget will assume, must be determined
- // before starting drawing by calc_height()
- unsigned int _h;
+ // The width and height the widget will assume, must be determined
+ // before starting drawing by calc_size()
+ mutable size_t _w;
+ mutable size_t _h;
// The offscreen pixmap we use for double-buffering
Glib::RefPtr _buf;
diff --git a/src/gui_builder.cc b/src/gui_builder.cc
index bdec679..ae8dd89 100644
--- a/src/gui_builder.cc
+++ b/src/gui_builder.cc
@@ -21,11 +21,8 @@
#include "config.h"
#include "gettext.h"
-#ifdef _SG_SCHEDULABLES_TREE_WIDGET
- #include "schedulables_tree_widget.hh"
-#else
- #include "schedulables_widget.hh"
-#endif
+#include "schedulables_tree_widget.hh"
+#include "simulation_widget.hh"
#include "gui_builder.hh"
@@ -37,6 +34,7 @@
#include
#include
#include
+#include
#include
@@ -78,14 +76,18 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
Expander* scheds_expander = NULL;
_refXml->get_widget("SchedulablesExpander", scheds_expander);
-#ifdef _SG_SCHEDULABLES_TREE_WIDGET
SchedulablesTreeWidget* scheds_widget = manage(new SchedulablesTreeWidget());
-#else
- SchedulablesWidget* scheds_widget = manage(new SchedulablesWidget());
-#endif
scheds_expander->add(*scheds_widget);
// we have to remember to manually show custom added widgets:
scheds_widget->show();
+
+
+ // Main simulation widget
+ ScrolledWindow* simulation_window = NULL;
+ _refXml->get_widget("SimulationScrolledWindow", simulation_window);
+ SimulationWidget* simulation_widget = manage(new SimulationWidget());
+ simulation_window->add(*simulation_widget);
+ simulation_widget->show();
}
diff --git a/src/schedulables_widget.cc b/src/simulation_widget.cc
similarity index 63%
rename from src/schedulables_widget.cc
rename to src/simulation_widget.cc
index e1c5358..3fff453 100644
--- a/src/schedulables_widget.cc
+++ b/src/simulation_widget.cc
@@ -1,4 +1,4 @@
-// src/schedulables_widget.cc - Copyright 2005, 2006, University
+// src/simulation_widget.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@@ -18,26 +18,30 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#include "schedulables_widget.hh"
+#include "simulation_widget.hh"
#include "cairo_elements.hh"
#include
+#ifndef NDEBUG
+#include
+#endif
+
using namespace sgpem;
-SchedulablesWidget::SchedulablesWidget()
- : Glib::ObjectBase("sgpem_SchedulablesWidget"), CairoWidget()
+SimulationWidget::SimulationWidget()
+ : Glib::ObjectBase("sgpem_SimulationWidget"), CairoWidget()
{}
-SchedulablesWidget::~SchedulablesWidget()
+SimulationWidget::~SimulationWidget()
{}
void
-SchedulablesWidget::draw_widget(cairo_t* ctx)
+SimulationWidget::draw_widget(cairo_t* ctx)
{
// NOTE: just to try
CairoElements ce(ctx);
@@ -52,9 +56,17 @@ SchedulablesWidget::draw_widget(cairo_t* ctx)
}
-unsigned int
-SchedulablesWidget::calc_height(const History& history) const
+void
+SimulationWidget::calc_size(const History& history, size_t& width, size_t& height) const
{
// FIXME: write me
- return 400;
+ width = get_allocation().get_width();
+ height = get_allocation().get_height();
+
+#ifndef NDEBUG
+ using namespace std;
+ clog << " [DD] New allocation event on " << hex << this << ": "
+ << dec << width << 'x' << height << endl;
+#endif
+
}
diff --git a/src/schedulables_widget.hh b/src/simulation_widget.hh
similarity index 71%
rename from src/schedulables_widget.hh
rename to src/simulation_widget.hh
index 6ee92c4..026da7e 100644
--- a/src/schedulables_widget.hh
+++ b/src/simulation_widget.hh
@@ -1,4 +1,4 @@
-// src/schedulables_widget.hh - Copyright 2005, 2006, University
+// src/simulation_widget.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@@ -18,8 +18,8 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef SCHEDULABLES_WIDGET_HH
-#define SCHEDULABLES_WIDGET_HH 1
+#ifndef SIMULATION_WIDGET_HH
+#define SIMULATION_WIDGET_HH 1
#include "config.h"
@@ -27,18 +27,18 @@
namespace sgpem
{
- class SchedulablesWidget : public CairoWidget
+ class SimulationWidget : public CairoWidget
{
public:
- SchedulablesWidget();
- virtual ~SchedulablesWidget();
+ SimulationWidget();
+ virtual ~SimulationWidget();
protected:
- virtual void draw_widget(cairo_t* ctx);
- virtual unsigned int calc_height(const History& history) const;
+ void draw_widget(cairo_t* ctx);
+ void calc_size(const History& history, size_t& width, size_t& height) const;
};
} //~ namespace sgpem
-#endif //~ SCHEDULABLES_WIDGET_HH
+#endif //~ SIMULATION_WIDGET_HH
diff --git a/src/testsuite/scheduling-wizards/wizard-complex-test b/src/testsuite/scheduling-wizards/wizard-complex-test
index c6ddfb0..fc91427 100644
--- a/src/testsuite/scheduling-wizards/wizard-complex-test
+++ b/src/testsuite/scheduling-wizards/wizard-complex-test
@@ -1,4 +1,4 @@
-set cpu-policy 1
+set cpu-policy 2
add resource
forchetta