Hello,

I am trying to implement a rubber band for my drawing application in
Gtk#. I want to make use of the Gdk XOR drawing for this purpose. But,
for some reason, it does not work appropriately. I have this simple
code:

using System;
using Gtk;
using Gdk;

public class MyDrawingArea: Gtk.DrawingArea {
        public MyDrawingArea()
        {
                SetSizeRequest (500, 500);
                AddEvents ((int)Gdk.EventMask.AllEventsMask);
        }
        
        protected override bool OnButtonPressEvent (EventButton ev)
        {
                Gdk.GC gc = new Gdk.GC(ev.Window);
                gc.Function = Gdk.Function.Xor;
                ev.Window.DrawRectangle(gc, true, 100, 100, 200, 200);
                return true;
        }

}

public class MyWindow: Gtk.Window {
        public MyWindow(): base("My Window")
        {
                MyDrawingArea area = new MyDrawingArea();
                Add(area);
                ShowAll();
        }
        
        public static void Main()
        {
                Application.Init();
                new MyWindow();
                Application.Run();
        }
        
}

When I assign the XOR function to the Gdk GC, I would expect that the
first time I click on the Drawing Area, a rectangle should be drawn,
the second time, the rectangle should be erased. The problem is that,
once I set Xor as the function, the rectangle it is never draw. Other
functions like Invert works fine, but Xor does not seem to work at
all. Is there a problem with my code?

In advance, thank you. And please excuse my bad english

Manuel Alejandro Cerón Estrada
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to