Re: Drawing with cairo
- From: Doug Baldwin <baldwin geneseo edu>
- To: "Diego A. Fons" <diegofons apexar com>
- Cc: gtk-list <gtk-list gnome org>
- Subject: Re: Drawing with cairo
- Date: Thu, 15 May 2008 11:34:15 -0400
On May 15, 2008, at 11:05 AM, Diego A. Fons wrote:
Like Theodore I'm using gtkmm. This is an extrac of the code which
doesn't work:
void Plotter::on_realize( void )
{
// Create the GDK window
refGdkWindow = Gdk::Window::create(get_window(), &attributes,
GDK_WA_X | GDK_WA_Y);
// Create Cairo context
Cairo::RefPtr<Cairo::Context> cr = refGdkWindow-
>create_cairo_context();
}
bool Plotter::on_expose_event( GdkEventExpose* event )
{
// ... Use cr to do some drawing
}
Both cr and refGdkWindow are members of the class Plotter....
Isn't variable cr local to Plotter::on_realize in the above? Even if
you declare a similarly-named variable in the class, I'm pretty sure
the declaration in the on_realize method will shadow the class member.
You might get the result you want if you drop the declaration from the
statement that saves the context in cr, i.e., change the second half
of Plotter::on_realize to...
// Create Cairo context
cr = refGdkWindow->create_cairo_context();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]