Re: drawing_area->window != NULL
- From: "Andrés" Giraldo <andres_giraldo yahoo com>
- To: Gtk List <gtk-list gnome org>
- Subject: Re: drawing_area->window != NULL
- Date: Tue, 12 Jun 2001 12:35:44 -0700 (PDT)
Thanks for your help...
Ok I've got it! The window is not realized yet, so I
put the drawing code in the expose_event function,
but...
It only works if I connect the expose event signal to
the drawing_area member, not if I connect it to the
entire structure... why?
This is using the entire structure (That's how I want
it). It doesn't work...
/*****************************************************/
typedef struct _GtkNewLabel GtkNewLabel;
struct _GtkNewLabel
{
GtkVBox vbox;
GtkWidget *drawing_area;
};
static void gtk_newlabel_init (GtkNewLabel *newlabel)
{
GtkWidget *table;
table = gtk_table_new (1, 1, TRUE);
gtk_container_add (GTK_CONTAINER (newlabel),
table);
gtk_widget_show (table);
newlabel->drawing_area = gtk_drawing_area_new ();
gtk_table_attach_defaults (GTK_TABLE(table),
newlabel->drawing_area, 0, 1, 0, 1);
gtk_widget_show (GTK_WIDGET (newlabel));
gtk_signal_connect(GTK_OBJECT (newlabel),
"expose_event",
GTK_SIGNAL_FUNC
(on_gtk_newlabel_expose_event), &newlabel);
}
void on_gtk_newlabel_expose_event (GtkNewLabel
*newlabel)
{
GdkGC *gc_back, *gc_fore;
GdkDrawable *drawable;
drawable = newlabel->drawing_area->window;
gc_back = GetPen (NewColor (newlabel->back_red,
newlabel->back_green,
newlabel->back_blue),
drawable);
}
GdkGC *GetPen (GdkColor *c, GdkDrawable *drawable)
{
GdkGC *gc;
gc = gdk_gc_new (drawable);
gdk_gc_set_foreground (gc, c);
return (gc);
}
GdkColor *NewColor (long red, long green, long blue)
{
GdkColor *c = (GdkColor *) g_malloc (sizeof
(GdkColor));
c->red = red;
c->green = green;
c->blue = blue;
gdk_color_alloc (gdk_colormap_get_system (), c);
return (c);
}
/*****************************************************/
And this is using the drawing_area member, It Works...
static void gtk_newlabel_init (GtkNewLabel *newlabel)
{
GtkWidget *table;
table = gtk_table_new (1, 1, TRUE);
gtk_container_add (GTK_CONTAINER (newlabel),
table);
gtk_widget_show (table);
newlabel->drawing_area = gtk_drawing_area_new ();
gtk_table_attach_defaults (GTK_TABLE(table),
newlabel->drawing_area, 0, 1, 0, 1);
gtk_widget_show (newlabel->drawing_area);
gtk_signal_connect(GTK_OBJECT
(newlabel->drawing_area), "expose_event",
GTK_SIGNAL_FUNC
(on_gtk_newlabel_expose_event), NULL);
}
void on_gtk_newlabel_expose_event (gpointer data)
{
GdkGC *gc_back, *gc_fore;
GdkDrawable *drawable = GTK_WIDGET(data)->window;
drawable = newlabel->drawing_area->window;
gc_back = GetPen (NewColor (newlabel->back_red,
newlabel->back_green,
newlabel->back_blue),
drawable);
}
So... what I'm doing wrong?
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]