Fwd: Re: text on a pixmap



----------  Message transmis  ----------
Subject: Re: text on a pixmap
Date: Fri, 12 Apr 2002 17:46:53 +0200
From: Jean-Yves Lamoureux <jylam lnxscene org>
To: Chris Nystrom <ccn olenska hn org>


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

Ok, I've the principle, but ...
it doesn't work :)

I've a blank window where I want to put the pixmap. I make the window, set
sets expose event callback to the drawing function, and it doesn't work.
Maybe GdkPixmap is not the same format as a standard xpm, or something ...
(Bellow is my code :)

Thanks

Lamoureux Jean-Yves
Software developper



About_xpm is a simple xpm, wrote by gimp, so must be ok :) (glade loads it
 ok)

int AboutAlambikViewer(GtkWidget      *widget,  GdkEventExpose *event )
{
  GtkWidget *AboutWindow;
  GdkPixmap *pixmap;

  AboutWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (AboutWindow, "About");
  gtk_object_set_data (GTK_OBJECT (AboutWindow), "About", AboutWindow);
  gtk_window_set_title (GTK_WINDOW (AboutWindow), "About Alambik Viewer");
  gtk_window_set_default_size (GTK_WINDOW (AboutWindow), 400, 200);
  gtk_window_set_policy (GTK_WINDOW (AboutWindow), FALSE, TRUE, FALSE);
  gtk_widget_show (AboutWindow);
  gtk_signal_connect (GTK_OBJECT (AboutWindow), "expose_event",
GTK_SIGNAL_FUNC (MyExposeEvent), NULL);
  return FALSE;
}


int MyExposeEvent(GtkWidget *widget, GdkEventExpose *event )
{


  printf("Expose appelé\n");

 gdk_flush();
  gdk_draw_pixmap(widget->window,
                  widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                  About_xpm,
                  event->area.x, event->area.y,
                  event->area.x, event->area.y,
                  event->area.width, event->area.height);
   gdk_flush();
  return FALSE;
}

-------------------------------------------------------



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