Re: why that not working?
- From: "Jean-Christophe Berthon" <jean-christophe berthon cgey com>
- To: "¶À¼y Kason Huang" <kasonhuang kinposh com cn>, "Gtk List" <gtk-list gnome org>
- Subject: Re: why that not working?
- Date: Mon, 21 Jan 2002 12:16:04 +0100
Hello :-)
This is not working because "&cyan" means that you give the address of the
variable "cyan" which then should be declare somewhere.
gdk_windows_set_background require as a second argument a pointer to a
GdkColor structure. To allocate this structure you need to declare a
GdkColor object. You can do that :
GdkColor xMyCyanColor;
Now to fill up this structure you can use to ways. Or you set the red, green
and blue color manually (take care each of this three properties as a value
from 0 to ~65535) like in the example I send before or you use a string like
"cyan" or "red" with this function :
if (gdk_color_parse("cyan", &xMyCyanColor))
{
/* The color is created (enough system ressource) */
/* So now you have to allocate it to the colormap in order to use it */
gdk_colormap_alloc_color(pxColorMap, &xMyCyanColor, FALSE, TRUE);
/* See my previous email on how to get a colormap */
}
else
{
/* Error not enough system ressource... (well I guess that's the reason
or
the color doesn't exist, for example you put "hello" for the color
;-) */
}
I hope, I'm clear enough. If you need other help, just ask me :-)
PS: btw I'm not sure if you then need to free the color. I just saw that
there is a gdk_color_free function in the API. Maybe someone-else can help
us about that!
Best regards,
---
Jean-Christophe Berthon
Cap Gemini -- Ernst & Young
France
Skill IS -- Image Quality
Email: Jean-Christophe Berthon cgey com
Tel: (+33) 561 31 6671
----- Original Message -----
From: "¶À¼y Kason Huang" <kasonhuang kinposh com cn>
To: <gtk-list gnome org>
Sent: Monday, January 21, 2002 9:44 AM
Subject: why that not working?
hello:
for creating a colorful button,I do a testing code,however,that not working?
why and how to do?anyone could help me?
#include<gtk/gtk.h>
#include<gdk/gdkx.h>
GdkColor cyan = {0,0x0000,0xFFFF,0xFFFF};
int main(int argc,char *argv[])
{
GtkWidget *window;
GttkWidget *button1;
GtkWidget *button2;
GtkWidget *vbox;
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(gtk_exit),NU
LL);
vbox = gtk_vbox_new(TRUE,2);
gtk_container_add(GTK_CONTAINER(window),vbox);
button1= gtk_button_new_with_label("1");
gtk_widget_realize(button1);
gdk_window_set_background(button1->window,&cyan); //not working,why?
gtk_box_pack_start(GTK_BOX(vbox),button1,TRUE,FALSE,0);
button2= gtk_button_new_with_label("2");
gtk_widget_realize(button2);
gdk_window_set_background(button2->window,&cyan); //not working,why?
gtk_box_pack_start(GTK_BOX(vbox),button2,TRUE,FALSE,0);
gtk_widget_show(button1);
gtk_widget_show(button2);
gtk_widget_show(vbox);
gtk_widget_show(window);
gtk_main();
return 1;
}
Thank you in advance! waiting for your mail back.
you can get me by mail :
kasonhuang kinposh com cn
kason
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]