Re: Drawing with cairo
- From: "Diego A. Fons" <diegofons apexar com>
- To: Theodore Papadopoulo <Theodore Papadopoulo sophia inria fr>
- Cc: gtk-list <gtk-list gnome org>
- Subject: Re: Drawing with cairo
- Date: Thu, 15 May 2008 12:05:02 -0300
Theodore Papadopoulo wrote:
Igor Gorbounov wrote:
Diego A. Fons пишет:
[...]
My question is if there is a way of preserve the cairo context intact
between the the calls to on_expose_event()? Why getting the cairo
context in the on_realize() handler and storing it in a variable doesn't
work?
Why, it works! Those are just examples. I use a context variable
as a member of my Plot class, and this variable is assigned in
an initialization method, and reassigned when plot area is resized.
Igor Gorbounov
Strange because I have kind of the same experience as Diego...
At least using gtk-- and storing the cairo context obtained at
configure time (maybe not at realization time, I have tried many
variants I do
not remember if I tried that variant), to use it in the handling of
expose events
just did not work. I had to request a new cairo context for each expose
events.
I never had time to fully investigate the problem, but I certainly had a
similar experience...
Theo.
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
Hi,
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. Instead if i
do this everything goes fine:
void Plotter::on_realize( void )
{
// Create the GDK window
refGdkWindow = Gdk::Window::create(get_window(), &attributes,
GDK_WA_X | GDK_WA_Y);
}
bool Plotter::on_expose_event( GdkEventExpose* event )
{
// Get cr to do some drawing
Cairo::RefPtr<Cairo::Context> cr = refGdkWindow->create_cairo_context();
// Do some drawing ...
}
The last code works fine and i can implement it, but i prefer not
redrawing all the graph because performance issues, I'm developing this
application for an embedded device.
So, if anyone can see what's wrong in the first code or just explain me
(us) why i can't do that, you are wellcome!
Regards,
Diego A. Fons.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]