From: Masao M. <mu...@hi...> - 2004-07-29 16:31:24
|
On Thu, 29 Jul 2004 05:31:53 -0700 (PDT) Dinesh Nadarajah <din...@sb...> wrote: > I have the following code with which I try to set the background image > window. But the image does not show on the window. When I keep changing > the window size, I can see background image, but when I stop changing > the window size, I don't see the image. I was wondering if anyone elase > had done something similar to what is being done by the following code: Of course, you can use Gdk::Window#set_back_pixmap(), but you need some special implementations because it's a row-level API. e.g.) you need to get expose event yourself and clear area where you expose. If you want to set background images, I recommand to use Gtk::Style instead. ------ require 'gtk2' Gtk.init win = Gtk::Window.new win.signal_connect('delete-event') do Gtk.main_quit end pixbuf = Gdk::Pixbuf.new("logo.png") pixmap, mask = pixbuf.render_pixmap_and_mask win.add(Gtk::Button.new("Test")) win.set_default_size(200, 200) win.border_width = 50 win.border_width = 50 style = Gtk::Style.new # You need to set the Gtk::StateType as you like. style.set_bg_pixmap(Gtk::STATE_NORMAL, pixmap) style.set_bg_pixmap(Gtk::STATE_ACTIVE, pixmap) style.set_bg_pixmap(Gtk::STATE_INSENSITIVE, pixmap) style.set_bg_pixmap(Gtk::STATE_PRELIGHT, pixmap) style.set_bg_pixmap(Gtk::STATE_SELECTED, pixmap) win.style = style win.show_all Gtk.main -- .:% Masao Mutoh<mu...@hi...> |