- Create SimulationWidget
- Drop the old SchedulablesWidget in favor of a simple Gtk::TreeView - Update the GuiBuilder consequentially - FIXME: in cairo_widget.cc : have we to scale the context before or after drawing on it? git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@845 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
51fdeea4d1
commit
59edb09c14
|
@ -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 -----------
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!-- Generated with glade3
|
||||
Version: 2.91.3
|
||||
Date: Fri Aug 4 21:13:04 2006
|
||||
Date: Sat Aug 12 16:16:48 2006
|
||||
User: matteo
|
||||
Host: tulip
|
||||
-->
|
||||
|
@ -226,9 +226,6 @@
|
|||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="SimulationScrolledWindow">
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
|
||||
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
|
||||
|
|
|
@ -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<void, CairoWidget> method0_t;
|
||||
|
@ -54,9 +55,10 @@ namespace sgpem
|
|||
typedef std::vector<area_callback_t> 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<Gdk::Pixmap> _buf;
|
||||
|
|
|
@ -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 <gtkmm/expander.h>
|
||||
#include <gtkmm/main.h>
|
||||
#include <gtkmm/menuitem.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 <cassert>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <iostream>
|
||||
#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
|
||||
|
||||
}
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
set cpu-policy 1
|
||||
set cpu-policy 2
|
||||
|
||||
add resource
|
||||
forchetta
|
||||
|
|
Loading…
Reference in New Issue