Re: text on a pixmap



On Fri, 12 Apr 2002, Jean-Yves Lamoureux wrote:

> I'm looking for a way to print some text ON a pixmap.
> Imagine I've a window, with a background pixmap.
> How can I print text on it ? 

You draw the pixmap in the expose event:

gint expose_event( GtkWidget      *widget,
                          GdkEventExpose *event )
{
  GdkPixmap *pixmap;

  pixmap = pixmap_get();

  gdk_draw_pixmap(widget->window,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  pixmap,
                  event->area.x, event->area.y,
                  event->area.x, event->area.y,
                  event->area.width, event->area.height);

  return FALSE;
}

You can use the gdk_draw_string to get text to the pixmap:

  gdk_draw_string(pixmap, font, gc, x, y, s);

And you can use the gtk_wdiget_queue_draw() function to emit an expose
signal:

  gtk_widget_queue_draw(w);

Hope that helps.

Chris






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