Re: drawables and refresh rates [solved I think]



Carl Nygard wrote:
On Mon, 2004-12-06 at 15:54, Rob Benton wrote:

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);
}


void drawingarea_realize()
{
  	Glib::RefPtr<Gdk::Window> window = _drawarea.get_window();
	_pixmap = Gdk::Pixmap::create(window, width, height);
	update_drawingarea();
}


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


bool drawingarea_expose_event(GdkEventExpose* e)
{
	Glib::RefPtr<Gdk::Window> window = _drawarea.get_window();
window->draw_drawable(_gc, _pixmap, e->x, e->y, e->width, e->height); // Guessing at e->* but you get the idea
}


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);
}


void update_drawingarea()
{
	_pixmap->draw_rectangle(// args here, set color beforehand);
	_pixmap->draw_arc( /* blue circle */ );
	_pixmap->draw_arc( /* red arc */ );
	_drawarea->queue_draw();
}

I let background be transparent in my Gtk::DrawingArea. Is there a way to capture that color to send to the pixmap so that I don't screw up the user's gtk theme?


======================================================================

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.

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list








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