pixmap doesn´t show in drawing_area
- From: der gilb tripmywire de
- To: gtk-list gnome org
- Subject: pixmap doesn´t show in drawing_area
- Date: Sun, 24 Mar 2002 02:22:28 +0100
Hello,
I´d like my programm to open a window and draw some boxes (or what ever)
into it. I came to the conclusion that a drawing_area and a pixmap
should do this.
So I created a drawing_area and a pixmap. Then I tried to draw someting
onto the pixmap and put it on the drawing_area. But nothing was
displayed in the window.
Perhaps I did some mistakes with the draw methods, I thought, so I tried
to show an xpm.
But only the window with the empty drawing_area and some errors/
warnings
(
Gdk-WARNING **: Creating pixmap from xpm with NULL window and colormap
Gdk-CRITICAL **: file gdkdraw.c: line 379 (gdk_draw_pixmap): assertion
'drawable != NULL' failed.
) appeared.
I think
pixmap = gdk_pixmap_create_from_xpm(drawing_area->window,0,0,
"vnterm.xpm");
causes the trouble. If I write NULL instead of 0, my compiler tells me:
ANSI C++ forbids implicit conversion from 'void *' in argument passing.
I use gcc 2.95.3 and GTK 1.2.9
The Tutorial/ FAQ and the few help I found in the net couldn´t help me.
I attached my code and hope somebody can and is willing to help me.
Thank you,
dennis
<code>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
int main (int argc, char *argv[])
{
gint window_delete_event(void);
void exit_prog( GtkWidget *,gpointer data);
GtkWidget *main_window;
GtkWidget *drawing_area;
GdkGC *gc;
GdkPixmap *pixmap;
gtk_init(&argc, &argv);
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
drawing_area = gtk_drawing_area_new();
gtk_container_add (GTK_CONTAINER(main_window), drawing_area);
gtk_signal_connect ( GTK_OBJECT (main_window),
"delete_event",
GTK_SIGNAL_FUNC (window_delete_event),
NULL);
gtk_signal_connect ( GTK_OBJECT(main_window),
"destroy",
GTK_SIGNAL_FUNC(exit_prog),
NULL);
pixmap = gdk_pixmap_create_from_xpm(drawing_area->window,0,0,
"vnterm.xpm");
gc = drawing_area->style->fg_gc[GTK_WIDGET_STATE(drawing_area)];
gdk_draw_pixmap(drawing_area->window,
gc,
pixmap,
0,0,0,0,300,300);
gtk_widget_show(drawing_area);
gtk_widget_show(main_window);
gtk_main();
return(0);
}
gint window_delete_event(void)
{
return(FALSE);
}
void exit_prog( GtkWidget *,
gpointer data)
{
gtk_main_quit();
}
</code>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]