[Gtk-sharp-list] Points/Lines and Glade
Sebastian Vorköper
sv@fogman.de
Thu, 01 Apr 2004 22:00:03 +0200
--Boundary_(ID_5Rbx4IM9KZ8ilq6DKMLMXQ)
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: QUOTED-PRINTABLE
Ok,
Attached is what i came up with.
It seams (for me) that if you use the keyword "static" with
"[Glade.Widget]" something gets screwed up.
Thats why i had to get the drawingarea (darea) manually with
darea=3D(Gtk.DrawingArea)gxml.GetWidget("darea");
Greetings,
Sebastian Vork=F6per
sv@fogman.de
--Boundary_(ID_5Rbx4IM9KZ8ilq6DKMLMXQ)
Content-type: text/x-csharp; charset=ANSI_X3.4-1968; name=drawglade.cs
Content-transfer-encoding: QUOTED-PRINTABLE
Content-disposition: attachment; filename=drawglade.cs
// Sebastian Vorkoeper sv@fogman.de
// Most parts are from the scribble example which i thank for.
using Gtk;
using Gdk;
using System;
using GtkSharp;
using Glade;
public class GladeTest {
=09[Glade.Widget] static Gtk.DrawingArea darea;
=09private static Gdk.Pixmap pixmap=3Dnull;
=09
=09public static void Main (string[] args) {
=09=09new GladeTest(args);
=09}
=09=09
=09public GladeTest (string[] args) {
=09=09Glade.XML gxml;
=09=09=09
=09=09Application.Init ();
=09=09=09
=09=09// Load the Glade File
=09=09gxml =3D new Glade.XML ("drawglade.glade", "window1", null);
=09=09gxml.Autoconnect (this);
=09=09=09
=09=09// Get the DrawingArea. (Dont know why Glade doesn't connect by=
himself?
=09=09darea=3D(Gtk.DrawingArea)gxml.GetWidget("darea");
=09=09// Set the expose event. So everytime the window gets changed c=
all this
=09=09// method to copy the pixmap to the front. (eg. redraw)
=09=09darea.ExposeEvent +=3D new ExposeEventHandler (DrawingExposeEve=
nt);
=09=09
=09=09// Create the Pixmap (size 200x200)
=09=09pixmap =3D new Gdk.Pixmap (darea.GdkWindow, 200, 200, -1);
=09=09// Make it white by drawing a white rectangle over the hole siz=
e.
=09=09pixmap.DrawRectangle (darea.Style.WhiteGC, true, 0, 0, 200, 200=
);
=09=09// Draw a black line from 0,0 to 200,200
=09=09pixmap.DrawLine(darea.Style.BlackGC,0,0,200,200);
=09=09// Show the DrawingArea
=09=09darea.ShowAll();
=09=09// We all know what this means :) go go go ...
=09=09Application.Run ();
=09}
=09static void Window_Delete (object obj, DeleteEventArgs args) {
=09=09Application.Quit ();
=09=09args.RetVal =3D true;
=09}
=09
=09static void DrawingExposeEvent (object obj, ExposeEventArgs args) =
{
=09=09Gdk.Rectangle area =3D args.Event.Area;
=09=09Console.WriteLine("Expose");
=09=09args.Event.Window.DrawDrawable (darea.Style.WhiteGC,pixmap,
=09=09=09=09area.X, area.Y, area.X, area.Y,=09area.Width, area.Height=
);
=09=09=09args.RetVal =3D false;
=09}
}
--Boundary_(ID_5Rbx4IM9KZ8ilq6DKMLMXQ)
Content-type: application/x-glade; name=drawglade.glade
Content-transfer-encoding: BASE64
Content-disposition: attachment; filename=drawglade.glade
PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PiA8IS0tKi0gbW9k
ZTogeG1sIC0qLS0+CjwhRE9DVFlQRSBnbGFkZS1pbnRlcmZhY2UgU1lTVEVNICJo
dHRwOi8vZ2xhZGUuZ25vbWUub3JnL2dsYWRlLTIuMC5kdGQiPgoKPGdsYWRlLWlu
dGVyZmFjZT4KCjx3aWRnZXQgY2xhc3M9Ikd0a1dpbmRvdyIgaWQ9IndpbmRvdzEi
PgogIDxwcm9wZXJ0eSBuYW1lPSJ2aXNpYmxlIj5UcnVlPC9wcm9wZXJ0eT4KICA8
cHJvcGVydHkgbmFtZT0idGl0bGUiIHRyYW5zbGF0YWJsZT0ieWVzIj53aW5kb3cx
PC9wcm9wZXJ0eT4KICA8cHJvcGVydHkgbmFtZT0idHlwZSI+R1RLX1dJTkRPV19U
T1BMRVZFTDwvcHJvcGVydHk+CiAgPHByb3BlcnR5IG5hbWU9IndpbmRvd19wb3Np
dGlvbiI+R1RLX1dJTl9QT1NfTk9ORTwvcHJvc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