[Gtk-sharp-list] ExposeEvent attached to Cairo Context?
MrFreeman
biggestsonicfan at gmail.com
Mon Apr 4 21:47:23 EDT 2011
Greetings,
I am writing a custom widget that appears as a popup according to a user
defined transparent pixbuf, and when clicked it preforms an action. I am
having trouble attaching an eventbox to the widget.
using System;
using Gtk;
using Cairo;
public partial class MainWindow : Gtk.Window
{
public MainWindow (string imgstring) : base(Gtk.WindowType.Popup)
{
Gtk.Image img = new Gtk.Image(imgsring);
Gdk.Pixbuf _pba = img.Pixbuf;
base.Resize(_pba.Width, _pba.Height);
base.Move(Gdk.Screen.Default.Width - _pba.Width, Gdk.Screen.Default.Height
- _pba.Height);
base.ExposeEvent += delegate(object o, ExposeEventArgs args) {
Context context = Gdk.CairoHelper.Create(base.GdkWindow);
context.SetSourceRGBA(1.0, 1.0, 1.0, 0.0);
context.Operator = Operator.Source;
context.Paint();
Gdk.CairoHelper.SetSourcePixbuf(context, _pba.AddAlpha(true, 213, 218,
240), 0, 0);
context.Paint();
((IDisposable)context).Dispose();
};
base.DeleteEvent += new DeleteEventHandler(OnDeleteEvent);
base.Decorated = false;
base.AppPaintable = true;
base.Colormap = base.Screen.RgbaColormap;
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}
What the widget is supposed to do is grab an image from a file location,
place it in the lower right hand corner of the screen, draw the image with a
transparent background, and I would like click-able events on the widget,
but no matter what I do, I can't seem to get both an EventBox working and
the Transparency working at the same time.
What I'd REALLY like if is I could overload Gdk.Image or Gtk.Image to always
draw the image with Cairo with the transparency per pixbuf, as I am having a
hard time manually redrawing each pixbuf iter from a pixbufanimation from an
animated GIF file.
--
View this message in context: http://mono.1490590.n4.nabble.com/ExposeEvent-attached-to-Cairo-Context-tp3427011p3427011.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20110404/102f31c1/attachment.html
More information about the Gtk-sharp-list
mailing list