Re: drawables and refresh rates [solved I think]



Thanks to everyone who helped me with this. I think I have it figured out but would appreciate it if someone would double-check my logic.


(Draw an arc on top of a circle using input from a scale widget)
======================================================================
_drawarea.signal_realize().connect(&drawingarea_realize);
_drawarea.signal_expose_event().connect(&drawingarea_expose_event);
_hscale.signal_value_changed().connect(&update_drawingarea);

void drawingarea_realize()
{
	Glib::RefPtr<Gdk::Window> window = _drawarea.get_window();
	window->clear();
	window->draw_arc( /* blue circle */ );
	window->draw_arc( /* red arc */ );
	_pixmap = Gdk::Pixmap::create(window, width, height);
}

bool drawingarea_expose_event(GdkEventExpose * e)
{
	update_drawingarea();
	return true;
}

void update_drawingarea()
{
	Glib::RefPtr<Gdk::Window> window = _drawarea.get_window();
	_pixmap->draw_drawable(_gc, window, 0, 0, 0, 0);
	_pixmap->draw_arc( /* blue circle */ );
	_pixmap->draw_arc( /* red arc */ );
	window->draw_drawable(_gc, _pixmap, 0, 0, 0, 0);
}
======================================================================

Now I only have 2 questions:

1. Is there anything like Gdk::Window::clear() for Gdk::Pixmap? Right now I'm copying the Gtk::DrawingArea into it before I do anything, otherwise the pixmap will have random junk in it. This seems kind of inefficient.

2. Can I emit the expose_event signal on the Gtk::DrawingArea from the Gtk::HScale value_changed callback? That would eliminate my 3rd function.




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