[Gtk-sharp-list] Background image
Anset
Anset at anset.org
Fri Aug 12 07:12:04 EDT 2005
Hi,
I had the same problem some time ago.
Settig a background should be done with the widget Style object. There
is a bgpixmap (or something like that, cannot check now) that you should
use.
However, gtksharp apparantly does not work that way (yet).
The only way I found that actually works is using the RC class.
Either use a gtkrc resource file or use the Rc.Parse function to parse a
resource sting.
More info on the Rc class can be found on the gnomedeveloper pages. (gtk
api).
I posted some examples to this list a couple of days ago.
wkr,
Anset
Freon wrote:
> Hi,
>
> I'd like to set an image background to a window (and still be able to
> add things inside, that's why using a Gtk.Image is out of question).
> I've made some researches and found out how it was done in classic
> gtk. Yet, it couldn't get it to work with Gtk#.
>
> I've made a simple test program (attached). The window background
> isn't changed, but when I resize the window, the image flashes before
> the content of the window is redrawn (see attached screenshot).
> I guess Gtk tries to fill my window with the background color. Maybe I
> should set it to transparent somehow?
>
> To build the test class, copy win.cs and window.png somewhere and run
> mcs win.cs /pkg:gtk-sharp /out:win.exe
> run with
> mono win.exe
>
> I'm using Mono 1.1.7.1+Gtk# bundle on Windows.
>
> Thanks in advance :)
>
>
> ------------------------------------------------------------------------
>
> using System;
> using Gtk;
>
> public class ImageTest
> {
> public static void Main (string[] args)
> {
> Gtk.Application.Init();
>
> Window win = new Window("background test");
> win.Resize( 400, 400 );
> win.ShowAll();
>
> Gdk.Pixbuf image = new Gdk.Pixbuf( "window.png" );
> Gdk.Pixmap pixmap, pixmap_mask;
> image.RenderPixmapAndMask( out pixmap, out pixmap_mask, 255 );
> win.GdkWindow.SetBackPixmap( pixmap, false );
>
> win.DeleteEvent += new DeleteEventHandler(onDeleteEvent);
>
> Application.Run();
> }
>
> private static void onDeleteEvent(object o, DeleteEventArgs args)
> {
> Application.Quit();
> }
> }
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
More information about the Gtk-sharp-list
mailing list