|
Post by vagos2108 on Feb 16, 2013 17:52:36 GMT 1
Hello guys
I really need your help about a WINDOW Widget. I wand to give to application the beauty off background but I don't know the way to achieve it. So ... if you know how I put a image background to WINDOW widget please let me know with an example.
With regards vagos2108
|
|
|
Post by Pjot on Feb 16, 2013 21:57:31 GMT 1
Hi Vagos2108,
This cannot be done within HUG. In fact, it is complicated to do in plain GTK also.
Below a small example, just replace the image file with the one you like to load. The extension of the image (jpg, png, etc) does not matter, it is recognized automatically by GTK.
BR, Peter
INCLUDE "hug.bac", INIT, WINDOW, DISPLAY, ATTACH, STOCK, HUGLIB$, CALLBACK, QUIT
INIT
gtk$ = HUGLIB$("gtk") gdk$ = HUGLIB$("gdk")
IMPORT "gtk_widget_get_window(long)" FROM gtk$ TYPE long IMPORT "gtk_widget_set_app_paintable(long,int)" FROM gtk$ TYPE long IMPORT "gdk_window_set_back_pixmap(long,long,int)" FROM gdk$ TYPE void IMPORT "gdk_pixbuf_render_pixmap_and_mask(long,long,void*,int)" FROM gdk$ TYPE void IMPORT "gdk_pixmap_new(long,int,int,int)" FROM gdk$ TYPE long
win = WINDOW("The Image", 400, 400)
'-------------------------------- Start of additional GTK code gtk_widget_set_app_paintable(win, TRUE) gdw = gtk_widget_get_window(win)
pixbuf = gdk_pixbuf_new_from_file("kanzeon.jpg", NULL) pixmap = gdk_pixmap_new(gdw, 400, 400, -1)
gdk_pixbuf_render_pixmap_and_mask(pixbuf, ADDRESS(pixmap), NULL, 0) gdk_window_set_back_pixmap(gdw, pixmap, 0)
g_object_unref(pixbuf) g_object_unref(pixmap) '-------------------------------- End of additional GTK code
button = STOCK("gtk-quit", 100, 50) ATTACH(win, button, 295, 345)
CALLBACK(button, QUIT)
DISPLAY
|
|
|
Post by vagos2108 on Feb 16, 2013 22:16:57 GMT 1
Dear Peter This is the example that I want. Thank you, I appreciate that Thanks again vagos2108
|
|