Problems with fillpatterns and Gtk for Windows

2006-08-04 Thread Guenther Sohler


Hallo Group,


I have problems with fill pattern generation with GTK For windows.
On Linux and Unix my testcase works fine. On GTK For windows just an empty 
window appears
with no fillpattern.

What is wrong ?

Please find my testcase below

#includestdio.h
#includegtk/gtk.h

GdkGC *gc;

int realize(GtkWidget *widget,gpointer data)
{
printf(realize\n);

GdkColor red;
GdkColor green;
GdkPixmap *fillpat;

char pattern[8]={0xff,0x81,0xbe,0xa5,0xa5,0xbe,0x81,0xff};
green.red=0x; green.green=0x; green.blue=0x;
red.red=0x; red.green=0x; red.blue=0x;

gdk_color_alloc(gdk_colormap_get_system(),green);
gdk_color_alloc(gdk_colormap_get_system(),red);

fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, green,red);

gc=gdk_gc_new(widget-window);
gdk_gc_copy(gc,widget-style-black_gc);
gdk_gc_set_foreground(gc,red);

gdk_gc_set_fill(gc,GDK_STIPPLED);
gdk_gc_set_stipple(gc,fillpat);

return TRUE;
}

int expose(GtkWidget *widget,gpointer data)
{
printf(expose\n);
gdk_draw_rectangle(widget-window,gc,TRUE,0,0,50,50);

return TRUE;
}

int main(int argc,char *argv[])
{
gtk_init(argc,argv);

GtkWidget *toplevel=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (toplevel), delete_event, G_CALLBACK 
(gtk_main_quit), NULL);

GtkWidget *drawing_area=gtk_drawing_area_new();
gtk_drawing_area_size((GtkDrawingArea *) drawing_area,50,50);
gtk_container_add(GTK_CONTAINER(toplevel),drawing_area);
g_signal_connect (G_OBJECT (drawing_area), realize, G_CALLBACK 
(realize), NULL);
g_signal_connect (G_OBJECT (drawing_area), expose_event, G_CALLBACK 
(expose), NULL);


gtk_widget_show_all(toplevel);
printf(Hello world!\n);
gtk_main();
return 0;
}


Whats wrong in GTK for Windows ?

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problems with fillpatterns and Gtk for Windows

2006-08-04 Thread Tor Lillqvist
Guenther Sohler writes:
  On Linux and Unix my testcase works fine.

On what kind of visuals, what kind of machines? It doesn't work for me
on Linux on a x86, on a 24-bit default TrueColor visual. I get a
uniform (random?) colour in the window, like on Windows.

  What is wrong ?

  GdkColor red;
  GdkColor green;
  GdkPixmap *fillpat;
  
  char pattern[8]={0xff,0x81,0xbe,0xa5,0xa5,0xbe,0x81,0xff};
  green.red=0x; green.green=0x; green.blue=0x;
  red.red=0x; red.green=0x; red.blue=0x;
  
  gdk_color_alloc(gdk_colormap_get_system(),green);
  gdk_color_alloc(gdk_colormap_get_system(),red);
  
  fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, green,red);

I certainly don't understand these things fully and by heart, and
might be confused here, but isn't it a bit odd to create a depth=1
pixmap, and then pass truecolor pixel values as foreground and
background? Shouldn't you pass GdkColors with the pixel field set to
either zero or one?

When I changed the above snippet like this:

--- sohler-1.c  Fri Aug  4 12:55:28 2006
+++ sohler-2.c  Fri Aug  4 14:00:32 2006
@@ -8,4 +8,5 @@
 printf(realize\n);
 
+GdkColor zero, one;
 GdkColor red;
 GdkColor green;
@@ -19,5 +20,8 @@
 gdk_color_alloc(gdk_colormap_get_system(),red);
 
-fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, green,red);
+zero.pixel = 0;
+one.pixel = 1;
+
+fillpat=gdk_pixmap_create_from_data(NULL,pattern,8,8,1, zero,one);
 
 gc=gdk_gc_new(widget-window);

it works fine both on Linux and Windows for me.

--tml

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problems with fillpatterns and Gtk for Windows

2006-08-04 Thread Guenther Sohler
Dear Tor,

Thank you for your reply!

Now it works!

I have always done it the wrong way so far :(
Maybe the GTK Documentation was not intuitive for me ...

Not wanting to be unpolite. Now I got a different problem .
Now the Letters of the Menus and all the other labels in my program are gone.
All of them are repalced by these square windows boxes. Just one text in a 
special location remains. Maybe Windows did not find the required font.
How can I check, if, and which font is missing ?

rds

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problems with fillpatterns and Gtk for Windows

2006-08-04 Thread Tor Lillqvist
Guenther Sohler writes:
  Now the Letters of the Menus and all the other labels in my program
  are gone.  All of them are repalced by these square windows boxes.

Are you using a recent Pango version, and from where? Is your
pango.aliases file borked? Try using Pango 1.12.3 from
ftp://ftp.gtk.org/pub/gtk/v2.8/win32. Also, do you use the ms-windows
(wimp) theme? Does the problem go away if you don't use that? What
is your default font in the Display Properties:Appearance settings?
(Yeah, I know that is a vague question, but my memory of which font
setting it is that affects the ms-windows theme engine is also
vague...) Have you tried changing to some TrueType outline font, like
Arial?

--tml

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list