Re: [gnomemm] Overriding the draw_background signal from Gnome::Canvas::Canvas



"r ve" <kaas_10 hotmail com> writes:
> I've got a Gnome::Canvas::canvas, queried from libglademm.
> I'm now trying to override the draw_background signal by doing this:
> 
> pCanvas->signal_draw_background().connect( bind(slot(pCanvas,
> &MainWindow::on_draw_background), pCanvas) );
> 
> where pCanvas is a the Gnome::Canvas::canvas and MainWindow a Gtk::Window.
> 
> The definition for the overriding on_draw_background method is done
> like the following, exactly like shown in the docs:
> 
> void MainWindow::on_draw_background(const Glib::RefPtr<Gdk::Drawable>&
>  drawable, int x, int y, int width, int height);

Hold it right there. Your function definition is

  void on_draw_background(drawable, x, y, int, int);

and you're trying to bind a canvas pointer to the last part of it:

  bind(slot(pCanvas, &MainWindow::on_draw_background), pCanvas));

That it, you're trying to bind

  void on_draw_background(drawable, x, y, int, int);

into

  void on_draw_background(drawable, x, y, int);

where the last parameter will be the pCanvas. This is obviously not
legal.


I think you meant

  pCanvas->signal_draw_background()
     .connect(SigC::slot(<mainwindowref>, &MainWindow::on_draw_background));

where <mainwindowref> is probably *this if you're inside a member
function of MainWindow. The slot will then call the on_draw_background
member function of the reference.

If you want to transfer the canvas pointer, I suggest you store it
elsewhere in MainWindow (although it is possible to transfer it with
the binding mechanism).

-- 
Ole Laursen
http://www.cs.auc.dk/~olau/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]