dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp .cvsignore,NONE,1.1 Applicati


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/Xsharp .cvsignore,NONE,1.1 Application.cs,NONE,1.1 ArcMode.cs,NONE,1.1 Bitmap.cs,NONE,1.1 BuiltinBitmaps.cs,NONE,1.1 ButtonName.cs,NONE,1.1 CapStyle.cs,NONE,1.1 Color.cs,NONE,1.1 Colormap.cs,NONE,1.1 CrossingDetail.cs,NONE,1.1 CrossingMode.cs,NONE,1.1 CursorType.cs,NONE,1.1 Display.cs,NONE,1.1 Drawable.cs,NONE,1.1 DrawableKind.cs,NONE,1.1 Effect.cs,NONE,1.1 EventHandlers.cs,NONE,1.1 FillRule.cs,NONE,1.1 FillStyle.cs,NONE,1.1 Font.cs,NONE,1.1 FontStyle.cs,NONE,1.1 Function.cs,NONE,1.1 Graphics.cs,NONE,1.1 IconData.cs,NONE,1.1 InputOnlyWidget.cs,NONE,1.1 InputOutputWidget.cs,NONE,1.1 JoinStyle.cs,NONE,1.1 KeyName.cs,NONE,1.1 LineStyle.cs,NONE,1.1 Makefile.am,NONE,1.1 Makefile.in,NONE,1.1 ModifierMask.cs,NONE,1.1 Pixmap.cs,NONE,1.1 Point.cs,NONE,1.1 Rectangle.cs,NONE,1.1 Region.cs,NONE,1.1 RootWindow.cs,NONE,1.1 S.cs,NONE,1.1 Screen.cs,NONE,1.1 StandardColor.cs,NONE,1.1 SubwindowMode.cs,NONE,1.1 TopLevelWindow.cs,NONE,1.1 Widget.cs,NONE,1.1 XCannotConnectException.cs,NONE,1.1 XException.cs,NONE,1.1 XInvalidOperationException.cs,NONE,1.1 Xlib.cs.in,NONE,1.1 Xsharp.build,NONE,1.1
Date: Wed, 28 May 2003 00:17:55 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv20758/Xsharp

Added Files:
        .cvsignore Application.cs ArcMode.cs Bitmap.cs 
        BuiltinBitmaps.cs ButtonName.cs CapStyle.cs Color.cs 
        Colormap.cs CrossingDetail.cs CrossingMode.cs CursorType.cs 
        Display.cs Drawable.cs DrawableKind.cs Effect.cs 
        EventHandlers.cs FillRule.cs FillStyle.cs Font.cs FontStyle.cs 
        Function.cs Graphics.cs IconData.cs InputOnlyWidget.cs 
        InputOutputWidget.cs JoinStyle.cs KeyName.cs LineStyle.cs 
        Makefile.am Makefile.in ModifierMask.cs Pixmap.cs Point.cs 
        Rectangle.cs Region.cs RootWindow.cs S.cs Screen.cs 
        StandardColor.cs SubwindowMode.cs TopLevelWindow.cs Widget.cs 
        XCannotConnectException.cs XException.cs 
        XInvalidOperationException.cs Xlib.cs.in Xsharp.build 
Log Message:


Add the Xsharp library to pnetlib.


--- NEW FILE ---
Makefile
Makefile.in
.deps
*.dll
*.exe
*.pdb
*.iltmp
*.xml
Xlib.cs

--- NEW FILE ---
/*
 * Application.cs - The main application object for a display.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Collections;

/// <summary>
/// <para>The <see cref="T:Xsharp.Application"/> class manages
/// initialization and event handling for an application.</para>
/// </summary>
public sealed class Application : IDisposable
{
        // Internal state.
        private String resourceName;
        private String resourceClass;
        private String programName;
        private String[] cmdLineArgs;
        private String displayName;
        private Display display;
        private bool startIconic;
        private String title;
        private String geometry;
        private Font defaultFont;
        private static Application primary;

        /// <summary>
        /// <para>Construct a new application object, process command-line
        /// options, and open the display.</para>
        /// </summary>
        ///
        /// <param name="name">
        /// <para>The resource name and class for the application.</para>
        /// </param>
        ///
        /// <param name="args">
        /// <para>The arguments that came from the application's "Main"
        /// method.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XCannotConnectException">
        /// <para>A connection to the X display server could not
        /// be established.</para>
        /// </exception>
        public Application(String name, String[] args)
                        {
                                String[] envCmdLine;
                                int firstArg = 0;
                                String fontName;

                                // Set this as the primary application object 
if necessary.
                                lock(typeof(Application))
                                {
                                        if(primary == null)
                                        {
                                                primary = this;
                                        }
                                }

                                // Choose defaults for the parameters.
                                try
                                {
                                        envCmdLine = 
Environment.GetCommandLineArgs();
                                }
                                catch(NotSupportedException)
                                {
                                        envCmdLine = null;
                                }
                                if(envCmdLine != null && envCmdLine.Length > 0)
                                {
                                        programName = envCmdLine[0];
                                }
                                else
                                {
                                        programName = "Xsharp-application";
                                }
                                if(name == null)
                                {
                                        // Strip the path from the program name 
to
                                        // get the default resource name to use.
                                        int index = 
programName.LastIndexOf(programName, '/');
                                        if(index == -1)
                                        {
                                                index = 
programName.LastIndexOf(programName, '\\');
                                        }
                                        if(index != -1)
                                        {
                                                name = 
programName.Substring(index);
                                        }
                                        else
                                        {
                                                name = programName;
                                        }
                                }
                                if(args == null)
                                {
                                        if(envCmdLine != null && 
envCmdLine.Length > 0)
                                        {
                                                args = envCmdLine;
                                                firstArg = 1;
                                        }
                                        else
                                        {
                                                args = new String [0];
                                        }
                                }

                                // Initialize the application state.
                                resourceName = name;
                                resourceClass = name;
                                displayName = null;
                                startIconic = false;
                                title = null;
                                geometry = null;
                                fontName = null;

                                // Process the standard Xt command-line options.
                                ArrayList newArgs = new ArrayList();
                                while(firstArg < args.Length)
                                {
                                        switch(args[firstArg])
                                        {
                                                case "-display":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                displayName = 
args[firstArg];
                                                        }
                                                }
                                                break;

                                                case "-iconic":
                                                {
                                                        startIconic = true;
                                                }
                                                break;

                                                case "-name":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                resourceName = 
args[firstArg];
                                                        }
                                                }
                                                break;

                                                case "-title":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                title = 
args[firstArg];
                                                        }
                                                }
                                                break;

                                                case "-bg":
                                                case "-background":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                // TODO: set 
the application's background color.
                                                        }
                                                }
                                                break;

                                                case "-fg":
                                                case "-foreground":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                // TODO: set 
the application's foreground color.
                                                        }
                                                }
                                                break;

                                                case "-fn":
                                                case "-font":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                fontName = 
args[firstArg];
                                                        }
                                                }
                                                break;

                                                case "-geometry":
                                                {
                                                        ++firstArg;
                                                        if(firstArg < 
args.Length)
                                                        {
                                                                title = 
args[firstArg];
                                                        }
                                                }
                                                break;

                                                // Ignore other Xt toolkit 
options that aren't
                                                // relevant to us.  We may add 
some of these later.
                                                case "-reverse":
                                                case "-rv":
                                                case "+rv":
                                                case "+synchronous":
                                                case "-synchronous":
                                                        break;
                                                case "-bw":
                                                case "-borderwidth":
                                                case "-bd":
                                                case "-bordercolor":
                                                case "-selectionTimeout":
                                                case "-xnllanguage":
                                                case "-xrm":
                                                case "-xtsessionID":
                                                        ++firstArg;
                                                        break;

                                                default:
                                                {
                                                        // Unknown option - 
copy it to "newArgs".
                                                        
newArgs.Add(args[firstArg]);
                                                }
                                                break;
                                        }
                                        ++firstArg;
                                }
                                cmdLineArgs = 
(String[])(newArgs.ToArray(typeof(String)));

                                // Connect to the display.
                                display = Xsharp.Display.Open(displayName, 
this);

                                // Create the default font.
                                defaultFont = Font.CreateFromXLFD(fontName);
                                defaultFont.GetFontSet(display);
                        }

        /// <summary>
        /// <para>Close the application if it is currently active.</para>
        /// </summary>
        ~Application()
                        {
                                Close();
                        }

        /// <summary>
        /// <para>Close the application if it is currently active.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>This method implements the <see cref="T:System.IDisposable"/>
        /// interface.</para>
        /// </remarks>
        public void Dispose()
                        {
                                Close();
                        }

        /// <summary>
        /// <para>Close the application if it is currently active.</para>
        /// </summary>
        public void Close()
                        {
                                lock(typeof(Application))
                                {
                                        if(display != null)
                                        {
                                                display.Close();
                                                display = null;
                                        }
                                        if(primary == this)
                                        {
                                                primary = null;
                                        }
                                }

                        }

        /// <summary>
        /// <para>Run the main event loop on this application.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>The main event loop will run until the <c>Quit</c>
        /// method is called on the display.</para>
        /// </remarks>
        public void Run()
                        {
                                if(display != null)
                                {
                                        display.Run();
                                }
                        }

        /// <summary>
        /// <para>Get the name of this program (i.e. the argv[0] value).</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The program name.</para>
        /// </value>
        public String ProgramName
                        {
                                get
                                {
                                        return programName;
                                }
                        }

        /// <summary>
        /// <para>Get the resource name of this program's primary window.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The resource name.</para>
        /// </value>
        public String ResourceName
                        {
                                get
                                {
                                        return resourceName;
                                }
                        }

        /// <summary>
        /// <para>Get the resource class of this program.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The resource class.</para>
        /// </value>
        public String ResourceClass
                        {
                                get
                                {
                                        return resourceClass;
                                }
                        }

        /// <summary>
        /// <para>Get the command-line arguments for this program that
        /// were left after standard options were removed.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The argument array.</para>
        /// </value>
        public String[] Args
                        {
                                get
                                {
                                        return cmdLineArgs;
                                }
                        }

        /// <summary>
        /// <para>Get the name of the display that we connected to,
        /// or <see langword="null"/> for the default display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The display name.</para>
        /// </value>
        public String DisplayName
                        {
                                get
                                {
                                        return displayName;
                                }
                        }

        /// <summary>
        /// <para>Get the display that is associated with this 
application.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The display object.</para>
        /// </value>
        public Display Display
                        {
                                get
                                {
                                        return display;
                                }
                        }

        /// <summary>
        /// <para>Determine if the program's primary window should
        /// start in an iconic state.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>Returns <see langword="true"/> if the window should
        /// start iconic, or <see langword="false"/> if not.</para>
        /// </value>
        public bool StartIconic
                        {
                                get
                                {
                                        return startIconic;
                                }
                        }

        /// <summary>
        /// <para>Get the value of the "-title" command-line option,
        /// or <see langword="null"/> if no title override.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The window title.</para>
        /// </value>
        public String Title
                        {
                                get
                                {
                                        return title;
                                }
                        }

        /// <summary>
        /// <para>Get the value of the "-geometry" command-line option,
        /// or <see langword="null"/> if no geometry override.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The window geometry.</para>
        /// </value>
        public String Geometry
                        {
                                get
                                {
                                        return geometry;
                                }
                        }

        /// <summary>
        /// <para>Get the application's default font.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The default font object.</para>
        /// </value>
        public Font DefaultFont
                        {
                                get
                                {
                                        return defaultFont;
                                }
                        }

        /// <summary>
        /// <para>Get the primary application object.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The application object.</para>
        /// </value>
        public static Application Primary
                        {
                                get
                                {
                                        return primary;
                                }
                        }

} // class Application

} // namespace Xsharp

--- NEW FILE ---
/*
 * ArcMode.cs - GC arc drawing modes.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.ArcMode"/> enumeration specifies
/// the arc drawing mode for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum ArcMode
{

        ArcChord    = 0,
        ArcPieSlice = 1

} // enum ArcMode

} // namespace Xsharp

--- NEW FILE ---
/*
 * Bitmap.cs - Basic bitmap handling for X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Bitmap"/> class manages off-screen
/// bitmaps on an X display screen.</para>
/// </summary>
public sealed class Bitmap : Drawable
{
        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Bitmap"/> instance
        /// that represents an off-screen bitmap.  The bitmap is created
        /// on the default screen of the primary display.</para>
        /// </summary>
        ///
        /// <param name="width">
        /// <para>The width of the new bitmap.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new bitmap.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="width"/> or <paramref name="height"/>
        /// values are out of range.</para>
        /// </exception>
        public Bitmap(int width, int height)
                        : base(Xsharp.Application.Primary.Display,
                                   
Xsharp.Application.Primary.Display.DefaultScreenOfDisplay,
                                   DrawableKind.Bitmap)
                        {
                                if(width < 1 || width > 32767 ||
                                   height < 1 || height > 32767)
                                {
                                        throw new 
XException(S._("X_InvalidBitmapSize"));
                                }
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        SetPixmapHandle(Xlib.XCreatePixmap
                                                (display, (Xlib.Drawable)
                                                        
Xlib.XRootWindowOfScreen(screen.screen),
                                                 (uint)width, (uint)height, 
(uint)1));
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Bitmap"/> instance
        /// that represents an off-screen bitmap.  The bitmap is created
        /// on the specified <paramref name="screen"/>.</para>
        /// </summary>
        ///
        /// <param name="screen">
        /// <para>The screen upon which to create the new bitmap.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new bitmap.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new bitmap.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>The <paramref name="screen"/> value is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="width"/> or <paramref name="height"/>
        /// values are out of range.</para>
        /// </exception>
        public Bitmap(Screen screen, int width, int height)
                        : base(GetDisplay(screen), screen, DrawableKind.Bitmap)
                        {
                                if(width < 1 || width > 32767 ||
                                   height < 1 || height > 32767)
                                {
                                        throw new 
XException(S._("X_InvalidBitmapSize"));
                                }
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        SetPixmapHandle(Xlib.XCreatePixmap
                                                (display, (Xlib.Drawable)
                                                        
Xlib.XRootWindowOfScreen(screen.screen),
                                                 (uint)width, (uint)height, 
(uint)1));
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        // Get the display value from a specified screen, and check for null.
        private static Display GetDisplay(Screen screen)
                        {
                                if(screen == null)
                                {
                                        throw new 
ArgumentNullException("screen");
                                }
                                return screen.DisplayOfScreen;
                        }

        /// <summary>
        /// <para>Destroy this bitmap if it is currently active.</para>
        /// </summary>
        public override void Destroy()
                        {
                                try
                                {
                                        IntPtr d = dpy.Lock();
                                        if(handle != Xlib.Drawable.Zero)
                                        {
                                                Xlib.XFreePixmap(d, 
(Xlib.Pixmap)handle);
                                                handle = Xlib.Drawable.Zero;
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        // Convert a color into a pixel value, relative to this drawable.
        // Should be called with the display lock.
        internal override Xlib.Pixel ToPixel(Color color)
                        {
                                // Expand standard colors before conversion.
                                if(color.Index != StandardColor.RGB)
                                {
                                        color = screen.ToColor(color.Index);
                                }

                                // Convert the color into monochrome, where 1 
is black
                                // foreground and 0 is white background.
                                if(((color.Red * 54 + color.Green * 183 +
                                     color.Blue * 19) / 256) < 128)
                                {
                                        return (Xlib.Pixel)1;
                                }
                                else
                                {
                                        return (Xlib.Pixel)0;
                                }
                        }

} // class Bitmap

} // namespace Xsharp

--- NEW FILE ---
/*
 * BuiltinBitmaps.cs - Builtin bitmaps for drawing special decorations.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

internal sealed class BuiltinBitmaps
{

        // Size of special bitmaps.
        public const int RadioWidth = 12;
        public const int RadioHeight = 12;

        // Radio button - bottom shadow color.
        private static readonly byte[] radio_b_bits = {
                0xf0, 0x00, 0x0c, 0x03, 0x02, 0x00, 0x02, 0x02, 0x01, 0x00, 
0x01, 0x00,
                0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 
0x00, 0x00
        };

        // Radio button - enhanced bottom shadow color.
        private static readonly byte[] radio_B_bits = {
                0x00, 0x00, 0xf0, 0x00, 0x0c, 0x03, 0x04, 0x00, 0x02, 0x00, 
0x02, 0x00,
                0x02, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00
        };

        // Radio button - top shadow color.
        private static readonly byte[] radio_t_bits = {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x08, 
0x00, 0x08,
                0x00, 0x08, 0x00, 0x08, 0x00, 0x04, 0x00, 0x04, 0x0c, 0x03, 
0xf0, 0x00
        };

        // Radio button - enhanced top shadow color.
        private static readonly byte[] radio_T_bits = {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 
0x00, 0x04,
                0x00, 0x04, 0x00, 0x04, 0x00, 0x02, 0x0c, 0x03, 0xf0, 0x00, 
0x00, 0x00
        };

        // Radio button - "white" background.
        private static readonly byte[] radio_w_bits = {
                0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xf8, 0x01, 0x9c, 0x03, 
0x0c, 0x03,
                0x0c, 0x03, 0x9c, 0x03, 0xf8, 0x01, 0xf0, 0x00, 0x00, 0x00, 
0x00, 0x00
        };

        // Radio button - "black" foreground.
        private static readonly byte[] radio_f_bits = {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 
0xf0, 0x00,
                0xf0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
0x00, 0x00
        };

        // Pre-loaded bitmaps for the current object's display.
        public Xlib.Pixmap RadioBottom;
        public Xlib.Pixmap RadioBottomEnhanced;
        public Xlib.Pixmap RadioTop;
        public Xlib.Pixmap RadioTopEnhanced;
        public Xlib.Pixmap RadioBackground;
        public Xlib.Pixmap RadioForeground;

        // Load builtin bitmaps for a particular display.
        public BuiltinBitmaps(Display display)
                        {
                                IntPtr dpy = display.dpy;
                                Xlib.Drawable drawable = 
display.DefaultRootWindow.handle;
                                RadioBottom = Xlib.XCreateBitmapFromData
                                        (dpy, drawable, radio_b_bits, (uint)12, 
(uint)12);
                                RadioBottomEnhanced = Xlib.XCreateBitmapFromData
                                        (dpy, drawable, radio_B_bits, (uint)12, 
(uint)12);
                                RadioTop = Xlib.XCreateBitmapFromData
                                        (dpy, drawable, radio_t_bits, (uint)12, 
(uint)12);
                                RadioTopEnhanced = Xlib.XCreateBitmapFromData
                                        (dpy, drawable, radio_T_bits, (uint)12, 
(uint)12);
                                RadioBackground = Xlib.XCreateBitmapFromData
                                        (dpy, drawable, radio_w_bits, (uint)12, 
(uint)12);
                                RadioForeground = Xlib.XCreateBitmapFromData
                                        (dpy, drawable, radio_f_bits, (uint)12, 
(uint)12);
                        }

} // class BuiltinBitmaps

} // namespace Xsharp

--- NEW FILE ---
/*
 * ButtonName.cs - Button name codes.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.ButtonName"/> enumeration specifies
/// the button names that are used in button events.</para>
/// </summary>
public enum ButtonName
{

        Button1 = 1,
        Button2 = 2,
        Button3 = 3,
        Button4 = 4,
        Button5 = 5

} // enum ButtonName

} // namespace Xsharp

--- NEW FILE ---
/*
 * CapStyle.cs - GC line capping styles.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.CapStyle"/> enumeration specifies
/// the line capping style for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum CapStyle
{

        CapNotLast    = 0,
        CapButt       = 1,
        CapRound      = 2,
        CapProjecting = 3

} // enum CapStyle

} // namespace Xsharp

--- NEW FILE ---
/*
 * Color.cs - Color structure type for X#.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Color"/> structure defines
/// a specific screen color as red, green, blue values, or as
/// an index into a standard color palette.</para>
/// </summary>
///
/// <remarks>
/// <para>This structure represents colors as a 24-bit RGB specification,
/// or as an index into a standardised palette.  It replaces the raw
/// pixels values that are used by the X protocol.  This makes the
/// application sensitive to theme changes.</para>
///
/// <para>Theoretically, X can handle displays with 48-bit RGB values.
/// Few applications need this level of color precision, and few X
/// servers support more than 24-bit color.</para>
/// </remarks>
public struct Color
{
        // Internal state.
        private uint value;

        /// <summary>
        /// <para>A <see cref="T:Xsharp.Color"/> value representing
        /// black.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The color value.</para>
        /// </value>
        public static readonly Color Black = new Color(0x00, 0x00, 0x00);

        /// <summary>
        /// <para>A <see cref="T:Xsharp.Color"/> value representing
        /// white.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The color value.</para>
        /// </value>
        public static readonly Color White = new Color(0xFF, 0xFF, 0xFF);

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Color"/> value
        /// from red, green, and blue values.</para>
        /// </summary>
        ///
        /// <param name="red">
        /// <para>The red component, between 0 and 255.</para>
        /// </param>
        ///
        /// <param name="green">
        /// <para>The green component, between 0 and 255.</para>
        /// </param>
        ///
        /// <param name="blue">
        /// <para>The blue component, between 0 and 255.</para>
        /// </param>
        public Color(int red, int green, int blue)
                        {
                                value = (((uint)red) << 16) | (((uint)green) << 
8) |
                                                 ((uint)blue);
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Color"/> value
        /// from an index into a standardised palette.</para>
        /// </summary>
        ///
        /// <param name="index">
        /// <para>The index into the standard color palette.</para>
        /// </param>
        ///
        /// <remarks>
        /// <para>It is recommended that you use standard colors where
        /// possible, so that the application is sensitive to theme 
changes.</para>
        /// </remarks>
        public Color(StandardColor index)
                        {
                                value = (((uint)index) << 24);
                        }

        /// <summary>
        /// <para>Get the red component from this color.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The red component of the color, or 0 if this value is
        /// an index into the standard color palette.</para>
        /// </value>
        public byte Red
                        {
                                get
                                {
                                        return (byte)(value >> 16);
                                }
                        }

        /// <summary>
        /// <para>Get the green component from this color.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The green component of the color, or 0 if this value is
        /// an index into the standard color palette.</para>
        /// </value>
        public byte Green
                        {
                                get
                                {
                                        return (byte)(value >> 8);
                                }
                        }

        /// <summary>
        /// <para>Get the blue component from this color.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The blue component of the color, or 0 if this value is
        /// an index into the standard color palette.</para>
        /// </value>
        public byte Blue
                        {
                                get
                                {
                                        return (byte)value;
                                }
                        }

        /// <summary>
        /// <para>Get the index into the standard color palette.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The standard color index, or <c>StandardColor.RGB</c> if
        /// this value has red, green, and blue components instead.</para>
        /// </value>
        public StandardColor Index
                        {
                                get
                                {
                                        return (StandardColor)(value >> 24);
                                }
                        }

        /// <summary>
        /// <para>Compare two color values for equality.</para>
        /// </summary>
        ///
        /// <param name="c1">
        /// <para>The first color value to compare.</para>
        /// </param>
        ///
        /// <param name="c2">
        /// <para>The second color value to compare.</para>
        /// </param>
        public static bool operator==(Color c1, Color c2)
                        {
                                return (c1.value == c2.value);
                        }

        /// <summary>
        /// <para>Compare two color values for inequality.</para>
        /// </summary>
        ///
        /// <param name="c1">
        /// <para>The first color value to compare.</para>
        /// </param>
        ///
        /// <param name="c2">
        /// <para>The second color value to compare.</para>
        /// </param>
        public static bool operator!=(Color c1, Color c2)
                        {
                                return (c1.value != c2.value);
                        }

        /// <summary>
        /// <para>Get the hash code for this color value.</para>
        /// </summary>
        public override int GetHashCode()
                        {
                                return (int)value;
                        }

        /// <summary>
        /// <para>Determine if two color values are equal.</para>
        /// </summary>
        ///
        /// <param name="obj">
        /// <para>The color object to compare against.</para>
        /// </param>
        public override bool Equals(Object obj)
                        {
                                if(obj is Color)
                                {
                                        Color c = (Color)obj;
                                        return (c.value == value);
                                }
                                return false;
                        }

} // struct Color

} // namespace Xsharp

--- NEW FILE ---
/*
 * Colormap.cs - Colormap handling for X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Collections;
using Xsharp.Types;

/// <summary>
/// <para>The <see cref="T:Xsharp.Colormap"/> class manages colormaps
/// for an X display screen.</para>
/// </summary>
public sealed class Colormap
{
        // Internal state.
        private Display dpy;
        private Screen screen;
        private Xlib.Colormap colormap;
        private Hashtable cachedPixels;

        // Constructor that is called from the "Screen" class.
        internal Colormap(Display dpy, Screen screen, Xlib.Colormap colormap)
                        {
                                this.dpy = dpy;
                                this.screen = screen;
                                this.colormap = colormap;
                                this.cachedPixels = new Hashtable();
                        }

        // Convert an RGB color value into a pixel using this colormap.
        // This assumes that standard colors have already been expanded.
        internal Xlib.Pixel RGBToPixel(Color color)
                        {
                                try
                                {
                                        // Acquire the display lock.
                                        IntPtr display = dpy.Lock();

                                        // Do we already have a cached pixel 
value for this color?
                                        Object cached = cachedPixels[color];
                                        if(cached != null)
                                        {
                                                return (Xlib.Pixel)(cached);
                                        }

                                        // Try to allocate the color from the X 
display server.
                                        XColor xcolor;
                                        int red = color.Red;
                                        int green = color.Green;
                                        int blue = color.Blue;
                                        xcolor.pixel = Xlib.Pixel.Zero;
                                        xcolor.red = (ushort)(red << 8);
                                        xcolor.green = (ushort)(green << 8);
                                        xcolor.blue = (ushort)(blue << 8);
                                        xcolor.flags =
                                                (sbyte)(XColor.DoRed | 
XColor.DoGreen | XColor.DoBlue);
                                        xcolor.pad = (sbyte)0;
                                        if(Xlib.XAllocColor(display, colormap, 
ref xcolor) != 0)
                                        {
                                                // Cache the value for next 
time.
                                                cachedPixels[color] = 
xcolor.pixel;
                                                return xcolor.pixel;
                                        }

                                        // TODO: do a closest color match for 
the color.

                                        // Last ditch: return black or white 
depending upon
                                        // the intensity of the color.
                                        if(((color.Red * 54 + color.Green * 183 
+
                                             color.Blue * 19) / 256) < 128)
                                        {
                                                return 
Xlib.XBlackPixelOfScreen(screen.screen);
                                        }
                                        else
                                        {
                                                return 
Xlib.XWhitePixelOfScreen(screen.screen);
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

} // class Colormap

} // namespace Xsharp

--- NEW FILE ---
/*
 * CrossingDetail.cs - "Detail" values for Enter/Leave events.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.CrossingDetail"/> enumeration specifies
/// notification details for Enter and Leave events on a widget.
/// </para>
/// </summary>
public enum CrossingDetail
{
        NotifyAncestor         = 0,
        NotifyVirtual          = 1,
        NotifyInferior         = 2,
        NotifyNonlinear        = 3,
        NotifyNonlinearVirtual = 4,
        NotifyPointer          = 5,
        NotifyPointerRoot      = 6,
        NotifyDetailNone       = 7

} // enum CrossingDetail

} // namespace Xsharp

--- NEW FILE ---
/*
 * CrossingMode.cs - "Mode" values for Enter/Leave events.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.CrossingMode"/> enumeration specifies
/// notification modes for Enter and Leave events on a widget.
/// </para>
/// </summary>
public enum CrossingMode
{
        NotifyNormal       = 0,
        NotifyGrab         = 1,
        NotifyUngrab       = 2,
        NotifyWhileGrabbed = 3

} // enum CrossingMode

} // namespace Xsharp

--- NEW FILE ---
/*
 * CursorType.cs - Types of cursors that are supported by the system.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.CursorType"/> enumeration specifies
/// the types of cursors that may be set on a widget.</para>
/// </summary>
public enum CursorType
{

        XC_inherit_parent = -1,
        XC_X_cursor = 0,
        XC_arrow = 2,
        XC_based_arrow_down = 4,
        XC_based_arrow_up = 6,
        XC_boat = 8,
        XC_bogosity = 10,
        XC_bottom_left_corner = 12,
        XC_bottom_right_corner = 14,
        XC_bottom_side = 16,
        XC_bottom_tee = 18,
        XC_box_spiral = 20,
        XC_center_ptr = 22,
        XC_circle = 24,
        XC_clock = 26,
        XC_coffee_mug = 28,
        XC_cross = 30,
        XC_cross_reverse = 32,
        XC_crosshair = 34,
        XC_diamond_cross = 36,
        XC_dot = 38,
        XC_dotbox = 40,
        XC_double_arrow = 42,
        XC_draft_large = 44,
        XC_draft_small = 46,
        XC_draped_box = 48,
        XC_exchange = 50,
        XC_fleur = 52,
        XC_gobbler = 54,
        XC_gumby = 56,
        XC_hand1 = 58,
        XC_hand2 = 60,
        XC_heart = 62,
        XC_icon = 64,
        XC_iron_cross = 66,
        XC_left_ptr = 68,
        XC_left_side = 70,
        XC_left_tee = 72,
        XC_leftbutton = 74,
        XC_ll_angle = 76,
        XC_lr_angle = 78,
        XC_man = 80,
        XC_middlebutton = 82,
        XC_mouse = 84,
        XC_pencil = 86,
        XC_pirate = 88,
        XC_plus = 90,
        XC_question_arrow = 92,
        XC_right_ptr = 94,
        XC_right_side = 96,
        XC_right_tee = 98,
        XC_rightbutton = 100,
        XC_rtl_logo = 102,
        XC_sailboat = 104,
        XC_sb_down_arrow = 106,
        XC_sb_h_double_arrow = 108,
        XC_sb_left_arrow = 110,
        XC_sb_right_arrow = 112,
        XC_sb_up_arrow = 114,
        XC_sb_v_double_arrow = 116,
        XC_shuttle = 118,
        XC_sizing = 120,
        XC_spider = 122,
        XC_spraycan = 124,
        XC_star = 126,
        XC_target = 128,
        XC_tcross = 130,
        XC_top_left_arrow = 132,
        XC_top_left_corner = 134,
        XC_top_right_corner = 136,
        XC_top_side = 138,
        XC_top_tee = 140,
        XC_trek = 142,
        XC_ul_angle = 144,
        XC_umbrella = 146,
        XC_ur_angle = 148,
        XC_watch = 150,
        XC_xterm = 152,
        XC_num_glyphs = 154

} // enum CursorType

} // namespace Xsharp

--- NEW FILE ---
/*
 * Display.cs - Access an X display server.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Collections;
using System.Threading;
using Xsharp.Events;

/// <summary>
/// <para>The <see cref="T:Xsharp.Display"/> class manages connections
/// to X display servers.</para>
///
/// <para>The application normally obtains a <see cref="T:Xsharp.Display"/>
/// instance by creating an instance of <see cref="T:Xsharp.Application"/>.
/// </para>
/// </summary>
public sealed class Display : IDisposable
{
        // Internal state.
        internal IntPtr dpy;
        private String displayName;
        private Screen[] screens;
        private int defaultScreen;
        private Application app;
        private bool quit;
        private bool pendingExposes;
        private InputOutputWidget exposeList;
        private bool inMainLoop;
        private Xlib.Cursor[] cursors;
        internal Xlib.Time knownEventTime;
        internal Hashtable handleMap;
        private static bool threadsInited;
        internal Xlib.Atom wmProtocols;
        internal Xlib.Atom wmDeleteWindow;
        internal Xlib.Atom wmTakeFocus;
        internal ButtonName selectButton;
        internal ButtonName menuButton;
        internal Hashtable fonts;
        internal BuiltinBitmaps bitmaps;

        // Constructor.
        private Display(IntPtr dpy, String displayName, Application app)
                        {
                                // Copy parameters in from the create process.
                                this.dpy = dpy;
                                this.displayName = displayName;
                                this.app = app;

                                // Create objects for each of the display 
screens.
                                int nscreens = (int)(Xlib.XScreenCount(dpy));
                                screens = new Screen [nscreens];
                                for(int scr = 0; scr < nscreens; ++scr)
                                {
                                        screens[scr] = new Screen
                                                (this, scr, 
Xlib.XScreenOfDisplay(dpy, scr));
                                }

                                // Get the index of the default screen.
                                defaultScreen = (int)(Xlib.XDefaultScreen(dpy));

                                // Create an array to hold the standard cursors.
                                cursors = new Xlib.Cursor 
[(int)(CursorType.XC_num_glyphs)];

                                // Reset the time of the last known event.
                                knownEventTime = Xlib.Time.CurrentTime;

                                // Construct the window handle map if not 
already present.
                                if(handleMap == null)
                                {
                                        handleMap = new Hashtable();
                                }

                                // Initialize the standard window manager atoms 
that we use.
                                wmProtocols = Xlib.XInternAtom
                                        (dpy, "WM_PROTOCOLS", Xlib.Bool.False);
                                wmDeleteWindow = Xlib.XInternAtom
                                        (dpy, "WM_DELETE_WINDOW", 
Xlib.Bool.False);
                                wmTakeFocus = Xlib.XInternAtom
                                        (dpy, "WM_TAKE_FOCUS", Xlib.Bool.False);

                                // Which buttons should we use for "Select" and 
"Menu"?
                                byte[] buttons = new byte [5];
                                if(Xlib.XGetPointerMapping(dpy, buttons, 5) == 
3)
                                {
                                        menuButton = ButtonName.Button3;
                                }
                                else
                                {
                                        menuButton = ButtonName.Button2;
                                }
                                selectButton = ButtonName.Button1;

                                // Construct the font map.
                                fonts = new Hashtable();

                                // Load the builtin bitmaps.
                                bitmaps = new BuiltinBitmaps(this);
                        }

        /// <summary>
        /// <para>Close the X display connection if it is currently 
active.</para>
        /// </summary>
        ~Display()
                        {
                                Close();
                        }

        /// <summary>
        /// <para>Close the X display connection if it is currently 
active.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>This method implements the <see cref="T:System.IDisposable"/>
        /// interface.</para>
        /// </remarks>
        public void Dispose()
                        {
                                Close();
                        }

        // Internal version of "Open()" that is called once the
        // type lock has been acquired.
        private static Display OpenInternal(String displayName, Application app)
                        {
                                try
                                {
                                        try
                                        {
                                                // Initialize Xlib thread 
support.
                                                if(!threadsInited)
                                                {
                                                        threadsInited = true;
                                                        Xlib.XInitThreads();
                                                }
                                        }
                                        catch(MissingMethodException)
                                        {
                                                // The "X11" library may not 
have support for
                                                // threads, which is OK(-ish) 
because we will
                                                // be locking every access to 
the display anyway.
                                        }
                                        IntPtr dpy = 
Xlib.XOpenDisplay(displayName);
                                        if(dpy != IntPtr.Zero)
                                        {
                                                // We have opened the display 
successfully.
                                                return new Display(dpy, 
displayName, app);
                                        }
                                        else
                                        {
                                                // We were unable to connect to 
the display.
                                                if(displayName != null)
                                                {
                                                        throw new 
XCannotConnectException
                                                                
(String.Format(S._("X_CannotOpenTo"),
                                                                                
           displayName));
                                                }
                                                else
                                                {
                                                        throw new 
XCannotConnectException
                                                                
(S._("X_CannotOpen"));
                                                }
                                        }
                                }
                                catch(MissingMethodException)
                                {
                                        // The engine was unable to locate 
"XOpenDisplay",
                                        // so we probably don't have an X 
library, or it
                                        // is not on the LD_LIBRARY_PATH.
                                        throw new XCannotConnectException
                                                (S._("X_LibraryNotPresent"));
                                }
                        }

        // Open a connection to a specific X display server.
        internal static Display Open(String displayName, Application app)
                        {
                                lock(typeof(Display))
                                {
                                        return OpenInternal(displayName, app);
                                }
                        }

        /// <summary>
        /// <para>Close the X display connection if it is currently 
active.</para>
        /// </summary>
        public void Close()
                        {
                                lock(this)
                                {
                                        if(dpy != IntPtr.Zero)
                                        {
                                                lock(typeof(Display))
                                                {
                                                        // Disassociate window 
handles from all windows.
                                                        for(int scr = 0; scr < 
screens.Length; ++scr)
                                                        {
                                                                
screens[scr].RootWindow.Disassociate();
                                                        }

                                                        // Disassociate the 
fonts from this display.
                                                        foreach(Font font in 
fonts)
                                                        {
                                                                
font.Disassociate(this);
                                                        }
                                                        fonts.Clear();

                                                        // Close the connection 
to the X server.
                                                        Xlib.XCloseDisplay(dpy);
                                                        dpy = IntPtr.Zero;
                                                }
                                        }
                                }
                        }

        // Lock this display and get the raw display pointer.
        internal IntPtr Lock()
                        {
                                Monitor.Enter(this);
                                if(dpy == IntPtr.Zero)
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_ConnectionLost"));
                                }
                                return dpy;
                        }

        // Unlock this display.  The correct way to use "Lock" and
        // "Unlock" is as follows:
        //
        //              try
        //              {
        //                      IntPtr dpy = display.Lock();
        //                      ... use the display pointer ...
        //              }
        //              finally
        //              {
        //                      display.Unlock();
        //              }
        //
        // This sequence ensures that there can be no race conditions
        // where a raw display pointer is used when the connection is
        // closed or in use by another thread.
        //
        internal void Unlock()
                        {
                                Monitor.Exit(this);
                        }

        /// <summary>
        /// <para>Get the default screen for this display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The default screen instance.</para>
        /// </value>
        public Screen DefaultScreenOfDisplay
                        {
                                get
                                {
                                        return screens[defaultScreen];
                                }
                        }

        /// <summary>
        /// <para>Get the root window for the default screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The default root window instance.</para>
        /// </value>
        public RootWindow DefaultRootWindow
                        {
                                get
                                {
                                        return 
DefaultScreenOfDisplay.RootWindow;
                                }
                        }

        /// <summary>
        /// <para>Get the display name associated with this display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The display name string.</para>
        /// </value>
        public String DisplayString
                        {
                                get
                                {
                                        try
                                        {
                                                return 
Xlib.XDisplayString(Lock());
                                        }
                                        finally
                                        {
                                                Unlock();
                                        }
                                }
                        }

        /// <summary>
        /// <para>Get the number of screens that are attached to
        /// this display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The number of screens.</para>
        /// </value>
        public int ScreenCount
                        {
                                get
                                {
                                        return screens.Length;
                                }
                        }

        /// <summary>
        /// <para>Get the index of the default screen that is attached
        /// to this display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The default screen index.</para>
        /// </value>
        public int DefaultScreen
                        {
                                get
                                {
                                        return defaultScreen;
                                }
                        }

        /// <summary>
        /// <para>Get the application object that owns this display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The application object.</para>
        /// </value>
        public Application Application
                        {
                                get
                                {
                                        return app;
                                }
                        }

        /// <summary>
        /// <para>Get a specific screen from this display, by index.</para>
        /// </summary>
        ///
        /// <param name="scr">
        /// <para>The index of the screen to get.</para>
        /// </param>
        ///
        /// <returns>
        /// <para>The <see cref="T:Xsharp.Screen"/> instance that corresponds
        /// to <paramref name="scr"/>.</para>
        /// </returns>
        ///
        /// <exception cref="T:System.IndexOutOfRangeException">
        /// <para>Raised if <paramref name="scr"/> is less than zero or
        /// greater than or equal to <c>ScreenCount</c>.</para>
        /// </exception>
        public Screen ScreenOfDisplay(int scr)
                        {
                                return screens[scr];
                        }

        /// <summary>
        /// <para>Flush all pending requests to the X display server.</para>
        /// </summary>
        public void Flush()
                        {
                                try
                                {
                                        Xlib.XFlush(Lock());
                                }
                                finally
                                {
                                        Unlock();
                                }
                        }

        /// <summary>
        /// <para>Synchronize operations against the X display server.</para>
        /// </summary>
        public void Sync()
                        {
                                try
                                {
                                        Xlib.XSync(Lock(), Xlib.Bool.False);
                                }
                                finally
                                {
                                        Unlock();
                                }
                        }

        /// <summary>
        /// <para>Ring the X display server bell.</para>
        /// </summary>
        ///
        /// <param name="percent">
        /// <para>The percentage of the base bell volume to ring at.
        /// This must be between -100 and 100 inclusive.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentOfRangeException">
        /// <para>The <paramref name="percent"/> value is less than
        /// -100 or greater than 100.</para>
        /// </exception>
        public void Bell(int percent)
                        {
                                try
                                {
                                        IntPtr dpy = Lock();
                                        if(percent >= -100 && percent <= 100)
                                        {
                                                Xlib.XBell(dpy, percent);
                                        }
                                        else
                                        {
                                                throw new 
ArgumentOutOfRangeException
                                                        ("percent", 
S._("X_BellPercent"));
                                        }
                                }
                                finally
                                {
                                        Unlock();
                                }
                        }

        /// <summary>
        /// <para>Ring the X display server bell at top volume.</para>
        /// </summary>
        public void Bell()
                        {
                                Bell(100);
                        }

        /// <summary>
        /// <para>Run the main event loop on this display.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>The main event loop will run until the <c>Quit</c>
        /// method is called.</para>
        /// </remarks>
        public void Run()
                        {
                                try
                                {
                                        IntPtr dpy = Lock();
                                        XEvent xevent;
                                        Xlib.XFlush(dpy);
                                        inMainLoop = true;
                                        while(!quit)
                                        {
                                                // Do we have pending expose 
events to process?
                                                if(pendingExposes)
                                                {
                                                        // If there are still 
events in the queue,
                                                        // then process them 
before the exposes.
                                                        if(Xlib.XEventsQueued
                                                                        (dpy, 2 
/* QueuedAfterFlush */) != 0)
                                                        {
                                                                // Read the 
next event and dispatch it.
                                                                
Xlib.XNextEvent(dpy, out xevent);
                                                                
DispatchEvent(ref xevent);
                                                        }
                                                        else
                                                        {
                                                                // Process the 
pending expose events.
                                                                
InputOutputWidget widget;
                                                                
while(exposeList != null)
                                                                {
                                                                        widget 
= exposeList;
                                                                        
exposeList = exposeList.nextExpose;
                                                                        
widget.Expose();
                                                                }
                                                                pendingExposes 
= false;
                                                        }
                                                }
                                                else
                                                {
                                                        // Wait for the next 
event.
                                                        Xlib.XNextEvent(dpy, 
out xevent);
                                                        DispatchEvent(ref 
xevent);
                                                }
                                        }
                                }
                                finally
                                {
                                        inMainLoop = false;
                                        Unlock();
                                }
                        }

        /// <summary>
        /// <para>Tell the main event loop on this display to quit.</para>
        /// </summary>
        public void Quit()
                        {
                                quit = true;
                        }

        // Dispatch an event that occurred on this display.  We currently
        // have the display lock.
        private void DispatchEvent(ref XEvent xevent)
                        {
                                // Record the time at which the event occurred. 
 We need
                                // this to process keyboard and pointer grabs 
correctly.
                                switch(xevent.type)
                                {
                                        case EventType.KeyPress:
                                        case EventType.KeyRelease:
                                        {
                                                knownEventTime = 
xevent.xkey.time;
                                        }
                                        break;

                                        case EventType.ButtonPress:
                                        case EventType.ButtonRelease:
                                        {
                                                knownEventTime = 
xevent.xbutton.time;
                                        }
                                        break;

                                        case EventType.MotionNotify:
                                        {
                                                knownEventTime = 
xevent.xmotion.time;
                                        }
                                        break;

                                        case EventType.EnterNotify:
                                        case EventType.LeaveNotify:
                                        {
                                                knownEventTime = 
xevent.xcrossing.time;
                                        }
                                        break;

                                        case EventType.PropertyNotify:
                                        {
                                                knownEventTime = 
xevent.xproperty.time;
                                        }
                                        break;

                                        case EventType.SelectionClear:
                                        {
                                                knownEventTime = 
xevent.xselectionclear.time;
                                        }
                                        break;

                                        case EventType.SelectionNotify:
                                        {
                                                knownEventTime = 
xevent.xselection.time;
                                        }
                                        break;

                                        case EventType.SelectionRequest:
                                        {
                                                knownEventTime = 
xevent.xselectionrequest.time;
                                        }
                                        break;

                                        default:
                                        {
                                                // We don't have a time value 
for this event.
                                                knownEventTime = 
Xlib.Time.CurrentTime;
                                        }
                                        break;
                                }

                                // Find the widget that should process the 
event.
                                Widget widget = 
(Widget)(handleMap[(int)(xevent.window)]);

                                // Dispatch the event to the widget.
                                if(widget != null)
                                {
                                        widget.DispatchEvent(ref xevent);
                                }
                        }

        // Simulate an out of memory exception.
        internal static void OutOfMemory()
                        {
                                // Try to perform a memory allocation that we 
know
                                // the engine will reject as being too big.
                                int[] x = new int [0x7FFFFFFF];
                        }

        // Retrieve or create a standard cursor.  Call with the display lock.
        internal Xlib.Cursor GetCursor(CursorType type)
                        {
                                uint shape = (uint)type;
                                if(shape >= (uint)(CursorType.XC_num_glyphs))
                                {
                                        shape = (uint)(CursorType.XC_X_cursor);
                                }
                                Xlib.Cursor cursor = cursors[(int)shape];
                                if(cursor != Xlib.Cursor.Zero)
                                {
                                        return cursor;
                                }
                                cursor = cursors[(int)shape] =
                                        Xlib.XCreateFontCursor(dpy, shape);
                                return cursor;
                        }

        // Add an input/output widget to the pending expose list.
        internal void AddPendingExpose(InputOutputWidget widget)
                        {
                                widget.nextExpose = exposeList;
                                exposeList = widget;
                                pendingExposes = true;
                        }

        // Remove an input/output widget from the pending expose list.
        internal void RemovePendingExpose(InputOutputWidget widget)
                        {
                                InputOutputWidget current, prev;
                                current = exposeList;
                                prev = null;
                                while(current != null && current != widget)
                                {
                                        prev = current;
                                        current = current.nextExpose;
                                }
                                if(current != null)
                                {
                                        if(prev != null)
                                        {
                                                prev.nextExpose = 
current.nextExpose;
                                        }
                                        else
                                        {
                                                exposeList = current.nextExpose;
                                        }
                                }
                        }

        // Get the maximum request size for the display.
        internal long MaxRequestSize()
                        {
                                try
                                {
                                        IntPtr display = Lock();
                                        return Xlib.XMaxRequestSize(display);
                                }
                                finally
                                {
                                        Unlock();
                                }
                        }

} // class Display

} // namespace Xsharp

--- NEW FILE ---
/*
 * Drawable.cs - Base class for widgets and pixmaps.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Drawable"/> class manages widget
/// windows or pixmaps on an X display screen.</para>
///
/// <para>This is an abstract base class.  Instantiate or inherit one of
/// the classes <see cref="T:Xsharp.Pixmap"/>,
/// <see cref="T:Xsharp.InputOutputWidget"/>,
/// <see cref="T:Xsharp.InputOnlyWidget"/>, or
/// <see cref="T:Xsharp.TopLevelWindow"/> in user applications.</para>
/// </summary>
public abstract class Drawable : IDisposable
{
        // Internal state.
        internal Display dpy;
        internal Screen screen;
        internal DrawableKind kind;
        internal Xlib.Drawable handle;
        internal int width, height;

        // Constructor.
        internal Drawable(Display dpy, Screen screen, DrawableKind kind)
                        {
                                this.dpy = dpy;
                                this.screen = screen;
                                this.kind = kind;
                        }

        /// <summary>
        /// <para>Destroy the drawable if it is currently active.</para>
        /// </summary>
        ~Drawable()
                        {
                                Destroy();
                        }

        // Set the handle for this drawable, assuming it is a widget.
        internal void SetWidgetHandle(Xlib.Window handle)
                        {
                                try
                                {
                                        dpy.Lock();
                                        this.handle = (Xlib.Drawable)handle;
                                        dpy.handleMap[(int)handle] = this;
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        // Set the handle for this drawable, assuming it is a pixmap.
        internal void SetPixmapHandle(Xlib.Pixmap handle)
                        {
                                try
                                {
                                        dpy.Lock();
                                        this.handle = (Xlib.Drawable)handle;
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        // Get the handle for drawable, assuming that it is
        // a widget.  Should be called with the display lock.
        internal Xlib.Window GetWidgetHandle()
                        {
                                if(handle != Xlib.Drawable.Zero)
                                {
                                        return (Xlib.Window)handle;
                                }
                                else
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_WidgetDestroyed"));
                                }
                        }

        // Get the handle for drawable, assuming that it is
        // a pixmap.  Should be called with the display lock.
        internal Xlib.Pixmap GetPixmapHandle()
                        {
                                if(handle != Xlib.Drawable.Zero)
                                {
                                        return (Xlib.Pixmap)handle;
                                }
                                else if(kind == DrawableKind.Pixmap)
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_PixmapDestroyed"));
                                }
                                else
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_BitmapDestroyed"));
                                }
                        }

        // Get the handle for drawable, for use in a graphics object.
        // Should be called with the display lock.
        internal Xlib.Drawable GetGCHandle()
                        {
                                if(kind == DrawableKind.InputOnlyWidget)
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_GraphicsIsOutputOnly"));
                                }
                                else if(handle != Xlib.Drawable.Zero)
                                {
                                        return handle;
                                }
                                else if(kind == DrawableKind.Widget)
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_WidgetDestroyed"));
                                }
                                else if(kind == DrawableKind.Pixmap)
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_PixmapDestroyed"));
                                }
                                else
                                {
                                        throw new XInvalidOperationException
                                                (S._("X_BitmapDestroyed"));
                                }
                        }

        /// <summary>
        /// <para>Destroy this drawable if it is currently active.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>This method implements the <see cref="T:System.IDisposable"/>
        /// interface.</para>
        /// </remarks>
        public void Dispose()
                        {
                                Destroy();
                        }

        /// <summary>
        /// <para>Destroy this drawable if it is currently active.</para>
        /// </summary>
        public virtual void Destroy()
                        {
                                // Nothing to do here: overridden in subclasses.
                        }

        /// <summary>
        /// <para>Get the display that is associated with this drawable.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The <see cref="T:Xsharp.Display"/> instance.</para>
        /// </value>
        public Display Display
                        {
                                get
                                {
                                        return dpy;
                                }
                        }

        /// <summary>
        /// <para>Get the screen that is associated with this drawable.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The <see cref="T:Xsharp.Screen"/> instance.</para>
        /// </value>
        public Screen Screen
                        {
                                get
                                {
                                        return screen;
                                }
                        }

        /// <summary>
        /// <para>Get the kind of this drawable.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The <see cref="T:Xsharp.DrawableKind"/> value.</para>
        /// </value>
        public DrawableKind Kind
                        {
                                get
                                {
                                        return kind;
                                }
                        }

        /// <summary>
        /// <para>Get the width of this drawable.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The width of this drawable in pixels.</para>
        /// </value>
        public int Width
                        {
                                get
                                {
                                        return width;
                                }
                        }

        /// <summary>
        /// <para>Get the height of this drawable.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The height of this widget in drawable.</para>
        /// </value>
        public int Height
                        {
                                get
                                {
                                        return height;
                                }
                        }

        /// <summary>
        /// <para>Get the application object that owns this drawable.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The application object.</para>
        /// </value>
        public Application Application
                        {
                                get
                                {
                                        return dpy.Application;
                                }
                        }

        // Convert a color into a pixel value, relative to this drawable.
        internal virtual Xlib.Pixel ToPixel(Color color)
                        {
                                // Expand standard color indices.
                                if(color.Index != StandardColor.RGB)
                                {
                                        color = screen.ToColor(color.Index);
                                }

                                // Map the color using the screen's colormap.
                                return screen.DefaultColormap.RGBToPixel(color);
                        }

} // class Drawable

} // namespace Xsharp

--- NEW FILE ---
/*
 * DrawableKind.cs - Kinds of drawables that are present in the system.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.DrawableKind"/> enumeration specifies
/// the kinds of drawable that may be present in the system (one of
/// "widget", "input-only widget", or "pixmap").</para>
/// </summary>
public enum DrawableKind
{

        Widget          = 0,
        InputOnlyWidget = 1,
        Pixmap          = 2,
        Bitmap          = 2

} // enum DrawableKind

} // namespace Xsharp

--- NEW FILE ---
/*
 * Effect.cs - 3D effect codes for "Graphics.DrawEffect".
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Effect"/> enumeration specifies
/// 3D effects (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
[Flags]
public enum Effect
{

        Raised                                          = (1<<0),
        Indented                                        = (1<<1),
        Etched                                          = (1<<2),
        Horizontal                                      = (1<<3),
        Vertical                                        = (1<<4),
        RadioBlank                                      = (1<<5),
        RadioSelected                           = (1<<6),
        RadioDisabled                           = (1<<7),
        RadioSelectedDisabled           = (1<<8),
        CheckBlank                                      = (1<<9),
        CheckSelected                           = (1<<10),
        CheckDisabled                           = (1<<11),
        CheckSelectedDisabled           = (1<<12),
        MenuSelected                            = (1<<13),
        MenuSelectedHighlighted         = (1<<14),
        MenuSelectedDisabled            = (1<<15),
        ContentColors                           = (1<<16),
        DefaultButton                           = (1<<17)

} // enum Effect

} // namespace Xsharp

--- NEW FILE ---
/*
 * EventHandlers.cs - Event handler delegate types for X#.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.MovedEventHandler"/> delegate is
/// used to describe widget move events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that was moved.</para>
/// </param>
///
/// <param name="x">
/// <para>The new X co-ordinate for the widget.</para>
/// </param>
///
/// <param name="y">
/// <para>The new Y co-ordinate for the widget.</para>
/// </param>
public delegate void MovedEventHandler(Widget widget, int x, int y);

/// <summary>
/// <para>The <see cref="T:Xsharp.ResizedEventHandler"/> delegate is
/// used to describe widget resize events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that was resized.</para>
/// </param>
///
/// <param name="width">
/// <para>The new width for the widget.</para>
/// </param>
///
/// <param name="height">
/// <para>The new height for the widget.</para>
/// </param>
public delegate void ResizedEventHandler(Widget widget, int width, int height);

/// <summary>
/// <para>The <see cref="T:Xsharp.MapStateEventHandler"/> delegate is
/// used to describe widget map state change events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that was mapped or unmapped.</para>
/// </param>
///
/// <param name="mapped">
/// <para>Set to <see langword="true"/> if the widget has just been
/// mapped; <see langword="false"/> otherwise.</para>
/// </param>
public delegate void MapStateEventHandler(Widget widget, bool mapped);

/// <summary>
/// <para>The <see cref="T:Xsharp.PaintEventHandler"/> delegate is
/// used to describe widget paint events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that is being painted.</para>
/// </param>
///
/// <param name="graphics">
/// <para>The graphics object to use to repaint the widget.  This
/// graphics object will have been initialised with the widgets foreground and
/// background colors, and with the clipping region set to the area
/// that needs to be repainted.</para>
/// </param>
public delegate void PaintEventHandler(Widget widget, Graphics graphics);

/// <summary>
/// <para>The <see cref="T:Xsharp.MapStateEventHandler"/> delegate is
/// used to describe widget iconic state change events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that was iconified or de-iconified.</para>
/// </param>
///
/// <param name="iconified">
/// <para>Set to <see langword="true"/> if the widget has just been
/// iconified; <see langword="false"/> if it was de-iconified.</para>
/// </param>
public delegate void IconicStateEventHandler(Widget widget, bool iconified);

/// <summary>
/// <para>The <see cref="T:Xsharp.ClosedEventHandler"/> delegate is
/// used to describe widget close requests.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that is to be closed.</para>
/// </param>
///
/// <returns>
/// <para>Returns <see langword="true"/> if the window can be closed,
/// or <see langword="false"/> if some condition is preventing to
/// window from being closed.</para>
/// </returns>
public delegate bool ClosedEventHandler(Widget widget);

/// <summary>
/// <para>The <see cref="T:Xsharp.ButtonPressEventHandler"/> delegate is
/// used to process button press events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that received the event.</para>
/// </param>
///
/// <param name="x">
/// <para>The X co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="y">
/// <para>The Y co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="button">
/// <para>The button that was pressed.</para>
/// </param>
///
/// <param name="modifiers">
/// <para>Other button and shift flags that were active.</para>
/// </param>
public delegate void ButtonPressEventHandler(Widget widget, int x, int y,
                                                                                
         ButtonName button,
                                                                                
         ModifierMask modifiers);

/// <summary>
/// <para>The <see cref="T:Xsharp.ButtonReleaseEventHandler"/> delegate is
/// used to process button release events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that received the event.</para>
/// </param>
///
/// <param name="x">
/// <para>The X co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="y">
/// <para>The Y co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="button">
/// <para>The button that was released.</para>
/// </param>
///
/// <param name="modifiers">
/// <para>Other button and shift flags that were active.</para>
/// </param>
public delegate void ButtonReleaseEventHandler(Widget widget, int x, int y,
                                                                                
           ButtonName button,
                                                                                
           ModifierMask modifiers);

/// <summary>
/// <para>The <see cref="T:Xsharp.PointerMotionEventHandler"/> delegate is
/// used to process mouse pointer motion events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that received the event.</para>
/// </param>
///
/// <param name="x">
/// <para>The X co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="y">
/// <para>The Y co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="modifiers">
/// <para>Button and shift flags that were active.</para>
/// </param>
public delegate void PointerMotionEventHandler(Widget widget, int x, int y,
                                                                                
           ModifierMask modifiers);

/// <summary>
/// <para>The <see cref="T:Xsharp.KeyPressEventHandler"/> delegate is
/// used to process key press events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that received the event.</para>
/// </param>
///
/// <param name="key">
/// <para>The key code.</para>
/// </param>
///
/// <param name="modifiers">
/// <para>Other button and shift flags that were active.</para>
/// </param>
///
/// <param name="str">
/// <para>The translated string that corresponds to the key, or
/// <see langword="null"/> if the key does not have a translation.</para>
/// </param>
///
/// <returns>
/// <para>Returns <see langword="true"/> if the key has been processed
/// and it should not be passed further up the focus tree.  Returns
/// <see langword="false"/> if the key should be passed further up
/// the focus tree.</para>
/// </returns>
///
/// <remarks>The <paramref name="key"/> parameter indicates the X11
/// symbol that corresponds to the key, which allows cursor control
/// and function keys to be easily distinguished.  The <paramref name="str"/>
/// is primarily of use to text input widgets.</remarks>
public delegate bool KeyPressEventHandler(Widget widget, KeyName key,
                                                                                
  ModifierMask modifiers, String str);

/// <summary>
/// <para>The <see cref="T:Xsharp.CrossingEventHandler"/> delegate is
/// used to process Enter and Leave events on a widget.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that received the event.</para>
/// </param>
///
/// <param name="child">
/// <para>The child widget that contained the previous or final
/// position, or <see langword="null"/> if no applicable child widget.</para>
/// </param>
///
/// <param name="x">
/// <para>The X co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="y">
/// <para>The Y co-ordinate of the pointer position.</para>
/// </param>
///
/// <param name="modifiers">
/// <para>Button and shift flags that were active.</para>
/// </param>
///
/// <param name="mode">
/// <para>The notification mode value from the event.</para>
/// </param>
///
/// <param name="detail">
/// <para>The notification detail value from the event.</para>
/// </param>
public delegate void CrossingEventHandler(Widget widget, Widget child,
                                                                                
  int x, int y,
                                                                                
  ModifierMask modifiers,
                                                                                
  CrossingMode mode,
                                                                                
  CrossingDetail detail);

/// <summary>
/// <para>The <see cref="T:Xsharp.FocusChangeEventHandler"/> delegate is
/// used to process focus change events.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget that received the event.</para>
/// </param>
///
/// <param name="other">
/// <para>If this is a focus in event, <paramref name="other"/> is the
/// previous widget within the same top-level window that had
/// the focus, or <see langword="null"/> if the focus is entering the
/// top-level window from outside.</para>
///
/// <para>If this is a focus out event, <paramref name="other"/> is the
/// new widget within the same top-level window that will receive
/// the focus, or <see langword="null"/> if the focus is leaving the
/// top-level window.</para>
/// </param>
public delegate void FocusChangeEventHandler(Widget widget, Widget other);

/// <summary>
/// <para>The <see cref="T:Xsharp.SensitivityChangedEventHandler"/>
/// delegate is used to process changes in input event sensitivity.</para>
/// </summary>
///
/// <param name="widget">
/// <para>The widget whose sensitivity has changed.</para>
/// </param>
public delegate void SensitivityChangedEventHandler(Widget widget);

} // namespace Xsharp

--- NEW FILE ---
/*
 * FillRule.cs - GC area fill rules.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.FillRule"/> enumeration specifies
/// the area fill rule for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum FillRule
{

        EvenOddRule = 0,
        WindingRule = 1

} // enum FillRule

} // namespace Xsharp

--- NEW FILE ---
/*
 * FillStyle.cs - GC area fill styles.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.FillStyle"/> enumeration specifies
/// the area fill style for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum FillStyle
{

        FillSolid          = 0,
        FillTiled          = 1,
        FillStippled       = 2,
        FillOpaqueStippled = 3

} // enum FillStyle

} // namespace Xsharp

--- NEW FILE ---
/*
 * Font.cs - Font object for X#.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Font"/> class encapsulates
/// the operations on an X font.</para>
/// </summary>
public sealed class Font
{
        // Internal class that keeps track of displays and fontsets.
        private class FontInfo
        {
                public FontInfo next;
                public Display dpy;
                public IntPtr fontSet;

        } // class FontInfo

        // Internal state.
        private String family;
        private int pointSize;
        private FontStyle style;
        private String xname;
        private FontInfo infoList;

        /// <summary>
        /// <para>The family name for the default sans-serif font.</para>
        /// </summary>
        public static readonly String SansSerif = "helvetica";

        /// <summary>
        /// <para>The family name for the default serif font.</para>
        /// </summary>
        public static readonly String Serif = "times";

        /// <summary>
        /// <para>The family name for the default fixed-width font.</para>
        /// </summary>
        public static readonly String Fixed = "courier";

        /// <summary>
        /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>.
        /// </para>
        /// </summary>
        ///
        /// <param name="family">
        /// <para>The name of the font family, or <see langword="null"/> to
        /// use the default sans-serif font.</para>
        /// </param>
        ///
        /// <param name="pointSize">
        /// <para>The point size (120 is typically "normal height").</para>
        /// </param>
        ///
        /// <param name="style">
        /// <para>Additional styles to apply to the font.</para>
        /// </param>
        public Font(String family, int pointSize, FontStyle style)
                        {
                                if(family != null)
                                        this.family = family;
                                else
                                        this.family = SansSerif;
                                if(pointSize < 0 || pointSize > 1000)
                                        this.pointSize = 120;
                                else
                                        this.pointSize = pointSize;
                                this.style = style;
                                this.xname = null;
                                this.infoList = null;
                        }

        /// <summary>
        /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
        /// with a default point size and style.</para>
        /// </summary>
        ///
        /// <param name="family">
        /// <para>The name of the font family, or <see langword="null"/> to
        /// use the default sans-serif font.</para>
        /// </param>
        public Font(String family)
                        : this(family, 120, FontStyle.Normal)
                        {
                                // Nothing to do here.
                        }

        /// <summary>
        /// <para>Constructs a new instance of <see cref="T:Xsharp.Font"/>
        /// with a default style.</para>
        /// </summary>
        ///
        /// <param name="family">
        /// <para>The name of the font family, or <see langword="null"/> to
        /// use the default sans-serif font.</para>
        /// </param>
        ///
        /// <param name="pointSize">
        /// <para>The point size (120 is typically "normal height").</para>
        /// </param>
        public Font(String family, int pointSize)
                        : this(family, pointSize, FontStyle.Normal)
                        {
                                // Nothing to do here.
                        }

        // Internal constructor that is called from "CreateFromXLFD".
        private Font(String name, bool unused)
                        {
                                this.family = null;
                                this.pointSize = 0;
                                this.style = FontStyle.Normal;
                                this.xname = name;
                                this.infoList = null;
                        }

        /// <summary>
        /// <para>Get the family name of this font.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The family name, or <see langword="null"/> if this font
        /// was created from an XLFD name.</para>
        /// </value>
        public String Family
                        {
                                get
                                {
                                        return family;
                                }
                        }

        /// <summary>
        /// <para>Get the point size of this font.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The point size.</para>
        /// </value>
        public int PointSize
                        {
                                get
                                {
                                        return pointSize;
                                }
                        }

        /// <summary>
        /// <para>Get the extra styles that are associated with this 
font.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The extra styles.</para>
        /// </value>
        public FontStyle Style
                        {
                                get
                                {
                                        return style;
                                }
                        }

        /// <summary>
        /// <para>Get the XLFD name of this font.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The XLFD name, or <see langword="null"/> if this font
        /// was not created from an XLFD name.</para>
        /// </value>
        public String XLFD
                        {
                                get
                                {
                                        return xname;
                                }
                        }

        /// <summary>
        /// <para>Determine if two font descriptions are equal.</para>
        /// </summary>
        ///
        /// <param name="obj">
        /// <para>The font object to compare against.</para>
        /// </param>
        ///
        /// <returns>
        /// <para>Returns <see langword="true"/> if the two fonts are equal;
        /// <see langword="false"/> otherwise.</para>
        /// </returns>
        public override bool Equals(Object obj)
                        {
                                Font other = (obj as Font);
                                if(other != null)
                                {
                                        if(this == other)
                                        {
                                                return true;
                                        }
                                        else
                                        {
                                                return (this.family == 
other.family &&
                                                        this.pointSize == 
other.pointSize &&
                                                                this.style == 
other.style &&
                                                                this.xname == 
other.xname);
                                        }
                                }
                                else
                                {
                                        return false;
                                }
                        }

        /// <summary>
        /// <para>Get the hash code for a font.</para>
        /// </summary>
        ///
        /// <returns>
        /// <para>Returns the hash code.</para>
        /// </returns>
        public override int GetHashCode()
                        {
                                return (((family == null) ? xname.GetHashCode()
                                                                                
  : family.GetHashCode()) +
                                                pointSize + (int)style);
                        }

        /// <summary>
        /// <para>Construct a font from an XLFD name.</para>
        /// </summary>
        ///
        /// <param name="name">
        /// <para>The XLFD name of the font.</para>
        /// </param>
        ///
        /// <returns>
        /// <para>The font object that corresponds to
        /// <paramref name="name"/>.</para>
        /// </returns>
        public static Font CreateFromXLFD(String name)
                        {
                                if(name == null)
                                {
                                        return new Font(null);
                                }
                                else
                                {
                                        return new Font(name, true);
                                }
                        }

        // Get the XFontSet structure for this font on a particular display.
        internal IntPtr GetFontSet(Display dpy)
                        {
                                lock(typeof(Font))
                                {
                                        // Map this object to the one that 
actually stores
                                        // the font set information.
                                        Font font = (Font)(dpy.fonts[this]);
                                        if(font == null)
                                        {
                                                font = this;
                                        }

                                        // Search for existing font set 
information.
                                        FontInfo info = font.infoList;
                                        while(info != null)
                                        {
                                                if(info.dpy == dpy)
                                                {
                                                        return info.fontSet;
                                                }
                                                info = info.next;
                                        }

                                        // TODO: create a new font set.

                                        // TODO: associate the font set with 
the display.

                                        return IntPtr.Zero;
                                }
                        }

        // Disassociate this font from a particular display.
        internal void Disassociate(Display dpy)
                        {
                                lock(typeof(Font))
                                {
                                        FontInfo info, prev;
                                        info = infoList;
                                        prev = null;
                                        while(info != null && info.dpy != dpy)
                                        {
                                                prev = info;
                                                info = info.next;
                                        }
                                        if(info != null)
                                        {
                                                if(prev != null)
                                                {
                                                        prev.next = info.next;
                                                }
                                                else
                                                {
                                                        infoList = info.next;
                                                }
                                                Xlib.XFreeFontSet(dpy.dpy, 
info.fontSet);
                                        }
                                }
                        }

} // class Font

} // namespace Xsharp

--- NEW FILE ---
/*
 * FontStyle.cs - Font style values.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.FontStyle"/> enumeration specifies
/// masks for font styles like bold, italic, etc.</para>
/// </summary>
[Flags]
public enum FontStyle
{

        Normal          = 0,
        Bold            = (1<<0),
        Italic          = (1<<1),
        Underlined      = (1<<2)

} // enum FontStyle

} // namespace Xsharp

--- NEW FILE ---
/*
 * Function.cs - GC function modes.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Function"/> enumeration specifies
/// the function mode for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum Function
{

        GXclear                 = 0x0,          /* 0 */
        GXand                   = 0x1,          /* src AND dst */
        GXandReverse    = 0x2,          /* src AND NOT dst */
        GXcopy                  = 0x3,          /* src */
        GXandInverted   = 0x4,          /* NOT src AND dst */
        GXnoop                  = 0x5,          /* dst */
        GXxor                   = 0x6,          /* src XOR dst */
        GXor                    = 0x7,          /* src OR dst */
        GXnor                   = 0x8,          /* NOT src AND NOT dst */
        GXequiv                 = 0x9,          /* NOT src XOR dst */
        GXinvert                = 0xa,          /* NOT dst */
        GXorReverse             = 0xb,          /* src OR NOT dst */
        GXcopyInverted  = 0xc,          /* NOT src */
        GXorInverted    = 0xd,          /* NOT src OR dst */
        GXnand                  = 0xe,          /* NOT src OR NOT dst */
        GXset                   = 0xf           /* 1 */

} // enum Function

} // namespace Xsharp

--- NEW FILE ---
/*
 * Graphics.cs - Graphic drawing objects.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
[...1947 lines suppressed...]
                                                                   
(uint)(GCValueMask.GCFunction |
                                                                                
  GCValueMask.GCForeground |
                                                                                
  GCValueMask.GCFillStyle |
                                                                                
  GCValueMask.GCLineWidth |
                                                                                
  GCValueMask.GCLineStyle |
                                                                                
  GCValueMask.GCJoinStyle |
                                                                                
  GCValueMask.GCCapStyle |
                                                                                
  GCValueMask.GCTileStipXOrigin |
                                                                                
  GCValueMask.GCTileStipYOrigin),
                                                                   ref values);
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

} // class Graphics

} // namespace Xsharp

--- NEW FILE ---
/*
 * IconData.cs - Data handling for icons in X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.IO;
using System.Reflection;

/// <summary>
/// <para>The <see cref="T:Xsharp.IconData"/> class manages simple
/// icons on an X display screen.</para>
/// </summary>
public sealed class IconData : IDisposable
{
        // Internal state.
        private byte[] data;

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.IconData"/> instance
        /// that represents an icon.</para>
        /// </summary>
        ///
        /// <param name="data">
        /// <para>The icon data, containing the color table
        /// and pixel values.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>Raised if <paramref name="data"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="data"/> value is invalid in some 
way.</para>
        /// </exception>
        public IconData(byte[] data)
                        {
                                if(data == null)
                                {
                                        throw new ArgumentNullException("data");
                                }
                                Load(data);
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.IconData"/> instance
        /// that represents an icon from an embedded resource.</para>
        /// </summary>
        ///
        /// <param name="name">
        /// <para>The name of the resource in the calling assembly.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>Raised if <paramref name="name"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="name"/> resource is invalid
        /// in some way.</para>
        /// </exception>
        public IconData(String name)
                        {
                                if(name == null)
                                {
                                        throw new ArgumentNullException("name");
                                }
                                try
                                {
                                        Load(name, 
Assembly.GetCallingAssembly());
                                }
                                catch(NotImplementedException)
                                {
                                        // The runtime engine does not have 
reflection support.
                                        InvalidFormat();
                                }
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.IconData"/> instance
        /// that represents an icon from an embedded resource.</para>
        /// </summary>
        ///
        /// <param name="name">
        /// <para>The name of the resource.</para>
        /// </param>
        ///
        /// <param name="assembly">
        /// <para>The assembly to look for the resource in.  This can be
        /// <see langword="null"/> to use the calling assembly.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>Raised if <paramref name="name"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="name"/> resource is invalid
        /// in some way.</para>
        /// </exception>
        public IconData(String name, Assembly assembly)
                        {
                                if(name == null)
                                {
                                        throw new ArgumentNullException("name");
                                }
                                if(assembly == null)
                                {
                                        try
                                        {
                                                assembly = 
Assembly.GetCallingAssembly();
                                        }
                                        catch(NotImplementedException)
                                        {
                                                // The runtime engine does not 
have reflection support.
                                                InvalidFormat();
                                        }
                                }
                                Load(name, assembly);
                        }

        // Load the contents of an icon resource from a specific assembly.
        private void Load(String name, Assembly assembly)
                        {
                                Stream stream = null;

                                // Get a stream for the icon resource.
                                try
                                {
                                        stream = 
assembly.GetManifestResourceStream(name);
                                        if(stream == null)
                                        {
                                                InvalidFormat();
                                        }
                                }
                                catch(NotImplementedException)
                                {
                                        // The runtime engine does not have 
reflection support.
                                        InvalidFormat();
                                }

                                // Load the contents of the stream into a 
buffer.
                                int len = (int)(stream.Length);
                                byte[] data = new byte [len];
                                if(stream.Read(data, 0, len) != len)
                                {
                                        stream.Close();
                                        InvalidFormat();
                                }
                                stream.Close();

                                // Load the icon data.
                                Load(data);
                        }

        // Load an icon resource from an explicit data buffer.
        private void Load(byte[] data)
                        {
                                this.data = data;
                        }

        // Throw an invalid icon format exception.
        private static void InvalidFormat()
                        {
                                throw new XException(S._("X_InvalidIcon"));
                        }

        /// <summary>
        /// <para>Dispose an instance of <see cref="T:Xsharp.IconData"/>.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>This method implements the <see cref="T:System.IDisposeable"/>
        /// interface.</para>
        /// </remarks>
        public void Dispose()
                        {
                                data = null;
                        }

} // class IconData

} // namespace Xsharp

--- NEW FILE ---
/*
 * InputOnlyWidget.cs - Widget handling for input-only widgets.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
[...986 lines suppressed...]
                                                
widget.DeselectInput(EventMask.ButtonPressMask);
                                        }
                                }

                // Deselect ButtonRelease events if nothing else is interested 
in them.
                public void DeselectButtonRelease(Widget widget)
                                {
                                        if(((Object)release) == null &&
                                           ((Object)selectRelease) == null &&
                                           ((Object)menuRelease) == null)
                                        {
                                                
widget.DeselectInput(EventMask.ButtonReleaseMask);
                                        }
                                }

        } // class InputEventHandlers

} // class InputOnlyWidget

} // namespace Xsharp

--- NEW FILE ---
/*
 * InputOutputWidget.cs - Widget handling for input-output widgets.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using Xsharp.Types;
using Xsharp.Events;

/// <summary>
/// <para>The <see cref="T:Xsharp.InputOutputWidget"/> class manages widgets
/// that occupy screen real estate for the purpose of keyboard and pointer
/// handling, and which have output functionality.</para>
/// </summary>
public class InputOutputWidget : InputOnlyWidget
{
        // Internal state.
        private Color foreground;
        private Color background;
        private Pixmap backgroundPixmap;
        private PaintEventHandler paint;
        private Region exposeRegion;
        internal InputOutputWidget nextExpose;

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.InputOutputWidget"/>
        /// instance underneath a specified parent widget.</para>
        /// </summary>
        ///
        /// <param name="parent">
        /// <para>The parent of the new widget.</para>
        /// </param>
        ///
        /// <param name="x">
        /// <para>The X co-ordinate of the top-left corner of
        /// the new widget.</para>
        /// </param>
        ///
        /// <param name="y">
        /// <para>The Y co-ordinate of the top-left corner of
        /// the new widget.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new widget.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new widget.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>Raised if <paramref name="parent"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>Raised if <paramref name="x"/>, <paramref name="y"/>,
        /// <paramref name="width"/>, or <paramref name="height"/> are
        /// out of range.</para>
        /// </exception>
        ///
        /// <exception cref="T.Xsharp.XInvalidOperationException">
        /// <para>Raised if <paramref name="parent"/> is disposed, the
        /// root window, or an input-only window.</para>
        /// </exception>
        public InputOutputWidget(Widget parent, int x, int y,
                                                         int width, int height)
                        : base(parent, x, y, width, height,
                               new Color(StandardColor.Inherit), false, false)
                        {
                                foreground = new 
Color(StandardColor.Foreground);
                                background = new Color(StandardColor.Inherit);
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.InputOutputWidget"/>
        /// instance underneath a specified parent widget, with
        /// specified foreground and background colors.</para>
        /// </summary>
        ///
        /// <param name="parent">
        /// <para>The parent of the new widget.</para>
        /// </param>
        ///
        /// <param name="x">
        /// <para>The X co-ordinate of the top-left corner of
        /// the new widget.</para>
        /// </param>
        ///
        /// <param name="y">
        /// <para>The Y co-ordinate of the top-left corner of
        /// the new widget.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new widget.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new widget.</para>
        /// </param>
        ///
        /// <param name="foreground">
        /// <para>The foreground color for the widget.</para>
        /// </param>
        ///
        /// <param name="background">
        /// <para>The background color for the widget.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>Raised if <paramref name="parent"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>Raised if <paramref name="x"/>, <paramref name="y"/>,
        /// <paramref name="width"/>, or <paramref name="height"/> are
        /// out of range.</para>
        /// </exception>
        ///
        /// <exception cref="T.Xsharp.XInvalidOperationException">
        /// <para>Raised if <paramref name="parent"/> is disposed, the
        /// root window, or an input-only window.</para>
        /// </exception>
        public InputOutputWidget(Widget parent, int x, int y,
                                                         int width, int height,
                                                         Color foreground, 
Color background)
                        : base(parent, x, y, width, height, background, false, 
false)
                        {
                                this.foreground = foreground;
                                this.background = background;
                        }

        // Internal constructor that is used by "TopLevelWindow" and
        // "OverrideWindow".
        internal InputOutputWidget(Widget parent, int x, int y,
                                                           int width, int 
height,
                                                           Color foreground, 
Color background,
                                                           bool rootAllowed, 
bool overrideRedirect)
                        : base(parent, x, y, width, height, background,
                                   rootAllowed, overrideRedirect)
                        {
                                this.foreground = foreground;
                                this.background = background;
                        }

        /// <summary>
        /// <para>Get or set the foreground color for this widget.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The foreground color to use.</para>
        /// </value>
        ///
        /// <remarks>
        /// <para>The foreground color does not become active until the
        /// next time a <see cref="T:Xsharp.Graphics"/> object is created
        /// for the widget.  Usually this happens the next time the
        /// widget is repainted.</para>
        /// </remarks>
        public Color Foreground
                        {
                                get
                                {
                                        return foreground;
                                }
                                set
                                {
                                        foreground = value;
                                }
                        }

        /// <summary>
        /// <para>Get or set the background color for this widget.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The background color to use.</para>
        /// </value>
        ///
        /// <remarks>
        /// <para>The background color becomes active immediately.  If the
        /// widget is mapped, a repaint will be forced.</para>
        /// </remarks>
        public Color Background
                        {
                                get
                                {
                                        return background;
                                }
                                set
                                {
                                        if(background != value || 
backgroundPixmap != null)
                                        {
                                                try
                                                {
                                                        IntPtr display = 
dpy.Lock();
                                                        Xlib.Window window = 
GetWidgetHandle();
                                                        background = value;
                                                        backgroundPixmap = null;
                                                        
Xlib.XSetWindowBackground
                                                                (display, 
window, ToPixel(value));
                                                        if(mapped && 
AncestorsMapped)
                                                        {
                                                                
Xlib.XClearArea(display, window,
                                                                                
                0, 0, (uint)0, (uint)0,
                                                                                
                Xlib.Bool.True);
                                                        }
                                                }
                                                finally
                                                {
                                                        dpy.Unlock();
                                                }
                                        }
                                }
                        }

        /// <summary>
        /// <para>Get or set the background pixmap for this widget.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The background pixmap to use.  Returns <see langword="null"/>
        /// if the background is set to a color or if it inherits the parent's
        /// background.  Setting the pixmap to <see langword="null"/> makes
        /// this widget inherit the parent's background.</para>
        /// </value>
        ///
        /// <remarks>
        /// <para>The background pixmap becomes active immediately.  If the
        /// widget is mapped, a repaint will be forced.</para>
        /// </remarks>
        public Pixmap BackgroundPixmap
                        {
                                get
                                {
                                        return backgroundPixmap;
                                }
                                set
                                {
                                        // Bail out if the background will be 
unchanged.
                                        if(background.Index == 
StandardColor.Pixmap &&
                                           value != null && backgroundPixmap == 
value)
                                        {
                                                return;
                                        }
                                        else if(background.Index == 
StandardColor.Inherit &&
                                                        value == null && 
backgroundPixmap == value)
                                        {
                                                return;
                                        }

                                        // Change the background to the new 
value.
                                        try
                                        {
                                                IntPtr display = dpy.Lock();
                                                Xlib.Window window = 
GetWidgetHandle();
                                                if(value == null)
                                                {
                                                        background = new 
Color(StandardColor.Inherit);
                                                        backgroundPixmap = null;
                                                        
Xlib.XSetWindowBackgroundPixmap
                                                                (display, 
window, Xlib.Pixmap.ParentRelative);
                                                }
                                                else
                                                {
                                                        background = new 
Color(StandardColor.Pixmap);
                                                        backgroundPixmap = 
value;
                                                        
Xlib.XSetWindowBackgroundPixmap
                                                                (display, 
window, value.GetPixmapHandle());
                                                }
                                                if(mapped && AncestorsMapped)
                                                {
                                                        
Xlib.XClearArea(display, window,
                                                                                
        0, 0, (uint)0, (uint)0,
                                                                                
        Xlib.Bool.True);
                                                }
                                        }
                                        finally
                                        {
                                                dpy.Unlock();
                                        }
                                }
                        }

        /// <summary>
        /// <para>Force a repaint of this widget.</para>
        /// </summary>
        public void Repaint()
                        {
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        if(mapped && AncestorsMapped)
                                        {
                                                Xlib.XClearArea(display, 
GetWidgetHandle(),
                                                                                
0, 0, (uint)0, (uint)0,
                                                                                
Xlib.Bool.True);
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Process a color theme change for this widget.</para>
        /// </summary>
        public override void ThemeChange()
                        {
                                // Pass the theme change on to all of the child 
widgets.
                                base.ThemeChange();

                                // Change the background pixel to match the new 
theme
                                // settings, and then force a repaint on the 
widget.
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        Xlib.Window window = GetWidgetHandle();
                                        StandardColor sc = background.Index;
                                        if(sc != StandardColor.Inherit &&
                                           sc != StandardColor.Pixmap &&
                                           sc != StandardColor.RGB)
                                        {
                                                Xlib.XSetWindowBackground
                                                        (display, window, 
ToPixel(background));
                                        }
                                        if(mapped && AncestorsMapped)
                                        {
                                                Xlib.XClearArea(display, window,
                                                                                
0, 0, (uint)0, (uint)0,
                                                                                
Xlib.Bool.True);
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Event that is raised when the widget needs to be
        /// painted in reponse to an <c>Expose</c> event.</para>
        /// </summary>
        public event PaintEventHandler Paint
                        {
                                add
                                {
                                        // Add ExposureMask to the widget's 
select mask if this
                                        // is the first delegate that was added 
to the event.
                                        if(paint == null)
                                        {
                                                
SelectInput(EventMask.ExposureMask);
                                        }
                                        paint += value;
                                }
                                remove
                                {
                                        // Remove ExposureMask from the 
widget's select mask if
                                        // this was the last delegate to be 
removed from the event.
                                        paint -= value;
                                        if(paint == null)
                                        {
                                                
DeselectInput(EventMask.ExposureMask);
                                                RemovePendingExpose();
                                        }
                                }
                        }

        // Dispatch an event to this widget.
        internal override void DispatchEvent(ref XEvent xevent)
                        {
                                switch(xevent.type)
                                {
                                        case EventType.Expose:
                                        case EventType.GraphicsExpose:
                                        {
                                                // Process exposures, and call 
"Paint" when ready.
                                                if(paint != null)
                                                {
                                                        // Add the area to the 
expose region.
                                                        if(exposeRegion == null)
                                                        {
                                                                // This is the 
first rectangle in an expose.
                                                                exposeRegion = 
new Region
                                                                        
(xevent.xexpose.x,
                                                                         
xevent.xexpose.y,
                                                                         
xevent.xexpose.width,
                                                                         
xevent.xexpose.height);

                                                                // Queue this 
widget for later repainting.
                                                                // We don't do 
it now or the system will be
                                                                // very slow 
during opaque window drags.
                                                                
dpy.AddPendingExpose(this);
                                                        }
                                                        else
                                                        {
                                                                // This is an 
extra rectangle in an expose.
                                                                
exposeRegion.Union
                                                                        
(xevent.xexpose.x,
                                                                         
xevent.xexpose.y,
                                                                         
xevent.xexpose.width,
                                                                         
xevent.xexpose.height);
                                                        }
                                                }
                                        }
                                        break;
                                }
                                base.DispatchEvent(ref xevent);
                        }

        // Remove this widget from the pending expose list.
        internal void RemovePendingExpose()
                        {
                                dpy.RemovePendingExpose(this);
                                if(exposeRegion != null)
                                {
                                        exposeRegion.Dispose();
                                        exposeRegion = null;
                                }
                        }

        // Process pending exposures on this widget.
        internal void Expose()
                        {
                                Region region = exposeRegion;
                                if(region != null)
                                {
                                        exposeRegion = null;
                                        if(paint != null)
                                        {
                                                Graphics graphics = new 
Graphics(this);
                                                graphics.SetClipRegion(region);
                                                region.Dispose();
                                                paint(this, graphics);
                                                graphics.Dispose();
                                        }
                                        else
                                        {
                                                region.Dispose();
                                        }
                                }
                        }

        // Get the background information for use in graphics object clears.
        internal void GetBackgroundInfo(out Color bg, out Pixmap pixmap,
                                                                        out int 
tx, out int ty)
                        {
                                if(background.Index == StandardColor.Inherit)
                                {
                                        InputOutputWidget parent =
                                                (Parent as InputOutputWidget);
                                        if(parent != null)
                                        {
                                                parent.GetBackgroundInfo
                                                        (out bg, out pixmap, 
out tx, out ty);
                                                tx -= x;
                                                ty -= y;
                                        }
                                        else
                                        {
                                                bg = new 
Color(StandardColor.Background);
                                                pixmap = null;
                                                tx = 0;
                                                ty = 0;
                                        }
                                }
                                else if(background.Index == 
StandardColor.Pixmap)
                                {
                                        bg = background;
                                        pixmap = backgroundPixmap;
                                        tx = 0;
                                        ty = 0;
                                }
                                else
                                {
                                        bg = background;
                                        pixmap = null;
                                        tx = 0;
                                        ty = 0;
                                }
                        }

} // class InputOutputWidget

} // namespace Xsharp

--- NEW FILE ---
/*
 * JoinStyle.cs - GC line join styles.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.JoinStyle"/> enumeration specifies
/// the line join style for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum JoinStyle
{

        JoinMiter = 0,
        JoinRound = 1,
        JoinBevel = 2

} // enum JoinStyle

} // namespace Xsharp

--- NEW FILE ---
/*
 * KeyName.cs - Key name codes.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
[...1703 lines suppressed...]
    XK_combining_acute = 0x1ef3,
    XK_combining_hook = 0x1efe,
    XK_combining_belowdot = 0x1eff,
    XK_EcuSign = 0x20a0,
    XK_ColonSign = 0x20a1,
    XK_CruzeiroSign = 0x20a2,
    XK_FFrancSign = 0x20a3,
    XK_LiraSign = 0x20a4,
    XK_MillSign = 0x20a5,
    XK_NairaSign = 0x20a6,
    XK_PesetaSign = 0x20a7,
    XK_RupeeSign = 0x20a8,
    XK_WonSign = 0x20a9,
    XK_NewSheqelSign = 0x20aa,
    XK_DongSign = 0x20ab,
    XK_EuroSign = 0x20ac

} // enum KeyName

} // namespace Xsharp

--- NEW FILE ---
/*
 * LineStyle.cs - GC line style modes.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.LineStyle"/> enumeration specifies
/// the line style mode for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum LineStyle
{

        LineSolid      = 0,
        LineOnOffDash  = 1,
        LineDoubleDash = 2

} // enum LineStyle

} // namespace Xsharp

--- NEW FILE ---

.PHONY: Xsharp.dll

all-local: Xsharp.dll

Xsharp.dll:
        "$(CSANT)" $(CSANT_FLAGS) -f Xsharp.build all

CLEANFILES = Xsharp.dll
DISTCLEANFILES = Xlib.cs

pnetassembliesdir = $(libdir)/cscc/lib
pnetassemblies_DATA = Xsharp.dll

--- NEW FILE ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.


SHELL = @SHELL@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

DESTDIR =

pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@

top_builddir = ..

ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@

NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
ASSEMBLY_LINKER = @ASSEMBLY_LINKER@
AWK = @AWK@
CC = @CC@
CSANT = @CSANT@
CSANT_FLAGS = @CSANT_FLAGS@
CSCC_FLAGS = @CSCC_FLAGS@
CSHARP_COMPILER = @CSHARP_COMPILER@
CSHARP_COMPILER_CYGWIN = @CSHARP_COMPILER_CYGWIN@
CSHARP_PLUGIN = @CSHARP_PLUGIN@
CYGPATH = @CYGPATH@
EXEEXT = @EXEEXT@
ILFIND = @ILFIND@
ILRUN = @ILRUN@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PNET_PATH = @PNET_PATH@
PROFILE_NAME = @PROFILE_NAME@
RESGEN = @RESGEN@
RESGEN_FLAGS = @RESGEN_FLAGS@
TREECC = @TREECC@
VERSION = @VERSION@
X_int = @X_int@
X_long = @X_long@
X_uint = @X_uint@
X_ulong = @X_ulong@

CLEANFILES = Xsharp.dll
DISTCLEANFILES = Xlib.cs

pnetassembliesdir = $(libdir)/cscc/lib
pnetassemblies_DATA = Xsharp.dll
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =  Xlib.cs
DATA =  $(pnetassemblies_DATA)

DIST_COMMON =  Makefile.am Makefile.in Xlib.cs.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am 
$(top_srcdir)/configure.in $(ACLOCAL_M4) 
        cd $(top_srcdir) && $(AUTOMAKE) --gnu Xsharp/Makefile

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
        cd $(top_builddir) \
          && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

Xlib.cs: $(top_builddir)/config.status Xlib.cs.in
        cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= 
$(SHELL) ./config.status

install-pnetassembliesDATA: $(pnetassemblies_DATA)
        @$(NORMAL_INSTALL)
        $(mkinstalldirs) $(DESTDIR)$(pnetassembliesdir)
        @list='$(pnetassemblies_DATA)'; for p in $$list; do \
          if test -f $(srcdir)/$$p; then \
            echo " $(INSTALL_DATA) $(srcdir)/$$p 
$(DESTDIR)$(pnetassembliesdir)/$$p"; \
            $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pnetassembliesdir)/$$p; \
          else if test -f $$p; then \
            echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pnetassembliesdir)/$$p"; \
            $(INSTALL_DATA) $$p $(DESTDIR)$(pnetassembliesdir)/$$p; \
          fi; fi; \
        done

uninstall-pnetassembliesDATA:
        @$(NORMAL_UNINSTALL)
        list='$(pnetassemblies_DATA)'; for p in $$list; do \
          rm -f $(DESTDIR)$(pnetassembliesdir)/$$p; \
        done
tags: TAGS
TAGS:


distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = Xsharp

distdir: $(DISTFILES)
        here=`cd $(top_builddir) && pwd`; \
        top_distdir=`cd $(top_distdir) && pwd`; \
        distdir=`cd $(distdir) && pwd`; \
        cd $(top_srcdir) \
          && $(AUTOMAKE) --include-deps --build-dir=$$here 
--srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Xsharp/Makefile
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
            cp -pr $$d/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
            || cp -p $$d/$$file $(distdir)/$$file || :; \
          fi; \
        done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am

install-data-am: install-pnetassembliesDATA
install-data: install-data-am

install-am: all-am
        @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-pnetassembliesDATA
uninstall: uninstall-am
all-am: Makefile $(DATA) all-local
all-redirect: all-am
install-strip:
        $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
        $(mkinstalldirs)  $(DESTDIR)$(pnetassembliesdir)


mostlyclean-generic:

clean-generic:
        -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)

distclean-generic:
        -rm -f Makefile $(CONFIG_CLEAN_FILES)
        -rm -f config.cache config.log stamp-h stamp-h[0-9]*
        -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)

maintainer-clean-generic:
mostlyclean-am:  mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am:  clean-generic mostlyclean-am

clean: clean-am

distclean-am:  distclean-generic clean-am

distclean: distclean-am

maintainer-clean-am:  maintainer-clean-generic distclean-am
        @echo "This command is intended for maintainers to use;"
        @echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: uninstall-pnetassembliesDATA install-pnetassembliesDATA tags \
distdir info-am info dvi-am dvi check check-am installcheck-am \
installcheck install-exec-am install-exec install-data-am install-data \
install-am install uninstall-am uninstall all-local all-redirect all-am \
all installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean


.PHONY: Xsharp.dll

all-local: Xsharp.dll

Xsharp.dll:
        "$(CSANT)" $(CSANT_FLAGS) -f Xsharp.build all

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

--- NEW FILE ---
/*
 * ModifierMask.cs - Key modifier mask values.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.ModifierMask"/> enumeration specifies
/// masks for key modifiers such as Shift, Control, etc.</para>
/// </summary>
[Flags]
public enum ModifierMask
{

        ShiftMask               = (1<<0),
        LockMask                = (1<<1),
        ControlMask             = (1<<2),
        Mod1Mask                = (1<<3),
        Mod2Mask                = (1<<4),
        Mod3Mask                = (1<<5),
        Mod4Mask                = (1<<6),
        Mod5Mask                = (1<<7),
        Button1Mask             = (1<<8),
        Button2Mask             = (1<<9),
        Button3Mask             = (1<<10),
        Button4Mask             = (1<<11),
        Button5Mask             = (1<<12),
        AnyModifier             = (1<<15)

} // enum ModifierMask

} // namespace Xsharp

--- NEW FILE ---
/*
 * Pixmap.cs - Basic pixmap handling for X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Pixmap"/> class manages off-screen
/// pixmaps on an X display screen.</para>
/// </summary>
public sealed class Pixmap : Drawable
{
        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Pixmap"/> instance
        /// that represents an off-screen pixmap.  The pixmap is created
        /// on the default screen of the primary display.</para>
        /// </summary>
        ///
        /// <param name="width">
        /// <para>The width of the new pixmap.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new pixmap.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="width"/> or <paramref name="height"/>
        /// values are out of range.</para>
        /// </exception>
        public Pixmap(int width, int height)
                        : base(Xsharp.Application.Primary.Display,
                                   
Xsharp.Application.Primary.Display.DefaultScreenOfDisplay,
                                   DrawableKind.Pixmap)
                        {
                                if(width < 1 || width > 32767 ||
                                   height < 1 || height > 32767)
                                {
                                        throw new 
XException(S._("X_InvalidPixmapSize"));
                                }
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        SetPixmapHandle(Xlib.XCreatePixmap
                                                (display, (Xlib.Drawable)
                                                        
Xlib.XRootWindowOfScreen(screen.screen),
                                                 (uint)width, (uint)height,
                                                 
(uint)Xlib.XDefaultDepthOfScreen(screen.screen)));
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.Pixmap"/> instance
        /// that represents an off-screen pixmap.  The pixmap is created
        /// on the specified <paramref name="screen"/>.</para>
        /// </summary>
        ///
        /// <param name="screen">
        /// <para>The screen upon which to create the new pixmap.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new pixmap.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new pixmap.</para>
        /// </param>
        ///
        /// <exception cref="T:System.ArgumentNullException">
        /// <para>The <paramref name="screen"/> value is <see langword="null"/>.
        /// </para>
        /// </exception>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>The <paramref name="width"/> or <paramref name="height"/>
        /// values are out of range.</para>
        /// </exception>
        public Pixmap(Screen screen, int width, int height)
                        : base(GetDisplay(screen), screen, DrawableKind.Pixmap)
                        {
                                if(width < 1 || width > 32767 ||
                                   height < 1 || height > 32767)
                                {
                                        throw new 
XException(S._("X_InvalidPixmapSize"));
                                }
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        SetPixmapHandle(Xlib.XCreatePixmap
                                                (display, (Xlib.Drawable)
                                                        
Xlib.XRootWindowOfScreen(screen.screen),
                                                 (uint)width, (uint)height,
                                                 
(uint)Xlib.XDefaultDepthOfScreen(screen.screen)));
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        // Get the display value from a specified screen, and check for null.
        private static Display GetDisplay(Screen screen)
                        {
                                if(screen == null)
                                {
                                        throw new 
ArgumentNullException("screen");
                                }
                                return screen.DisplayOfScreen;
                        }

        /// <summary>
        /// <para>Destroy this pixmap if it is currently active.</para>
        /// </summary>
        public override void Destroy()
                        {
                                try
                                {
                                        IntPtr d = dpy.Lock();
                                        if(handle != Xlib.Drawable.Zero)
                                        {
                                                Xlib.XFreePixmap(d, 
(Xlib.Pixmap)handle);
                                                handle = Xlib.Drawable.Zero;
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

} // class Pixmap

} // namespace Xsharp

--- NEW FILE ---
/*
 * Point.cs - Public point structure type for X#.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Point"/> structure defines
/// a specific screen location in pixels.</para>
/// </summary>
public struct Point
{
        /// <summary>
        /// <para>The X co-ordinate of the point.</para>
        /// </summary>
        public int x;

        /// <summary>
        /// <para>The Y co-ordinate of the point.</para>
        /// </summary>
        public int y;

        /// <summary>
        /// <para>Constructs a new point from a pair of co-ordinates.</para>
        /// </summary>
        ///
        /// <param name="x">
        /// <para>The X co-ordinate of the point.</para>
        /// </param>
        ///
        /// <param name="y">
        /// <para>The Y co-ordinate of the point.</para>
        /// </param>
        public Point(int x, int y)
                        {
                                this.x = x;
                                this.y = y;
                        }

} // struct Point

} // namespace Xsharp

--- NEW FILE ---
/*
 * Rectangle.cs - Public rectangle structure type for X#.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.Rectangle"/> structure defines
/// a rectangular screen area in pixels.</para>
/// </summary>
public struct Rectangle
{
        /// <summary>
        /// <para>The X co-ordinate of the top-left corner of the 
rectangle.</para>
        /// </summary>
        public int x;

        /// <summary>
        /// <para>The Y co-ordinate of the top-left corner of the 
rectangle.</para>
        /// </summary>
        public int y;

        /// <summary>
        /// <para>The width of the rectangle.</para>
        /// </summary>
        public int width;

        /// <summary>
        /// <para>The height of the rectangle.</para>
        /// </summary>
        public int height;

        /// <summary>
        /// <para>Constructs a new rectangle from a set of co-ordinates.</para>
        /// </summary>
        ///
        /// <param name="x">
        /// <para>The X co-ordinate of the top-left corner of the 
rectangle.</para>
        /// </param>
        ///
        /// <param name="y">
        /// <para>The Y co-ordinate of the top-left corner of the 
rectangle.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the rectangle.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the rectangle.</para>
        /// </param>
        public Rectangle(int x, int y, int width, int height)
                        {
                                this.x = x;
                                this.y = y;
                                this.width = width;
                                this.height = height;
                        }

} // struct Rectangle

} // namespace Xsharp

--- NEW FILE ---
/*
 * Region.cs - Region management for X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
[...1266 lines suppressed...]
        // Get the Xlib region structure, and make sure it is non-NULL.
        internal IntPtr GetRegion()
                        {
                                lock(typeof(Region))
                                {
                                        if(region == IntPtr.Zero)
                                        {
                                                region = Xlib.XCreateRegion();
                                                if(region == IntPtr.Zero)
                                                {
                                                        Display.OutOfMemory();
                                                }
                                        }
                                        return region;
                                }
                        }

} // class Region

} // namespace Xsharp

--- NEW FILE ---
/*
 * RootWindow.cs - Root window handling for X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Collections;

/// <summary>
/// <para>The <see cref="T:Xsharp.RootWindow"/> class manages the
/// root window for an X display screen.</para>
///
/// <para>The root window is special in that it does not have a parent,
/// and that it cannot be destroyed, resized, or moved.</para>
/// </summary>
public sealed class RootWindow : Widget
{
        // Constructor.  Called from the "Screen" class.
        internal RootWindow(Display dpy, Screen screen, Xlib.Window handle)
                        : base(dpy, screen, DrawableKind.Widget, null)
                        {
                                // Set this window's handle and add it to the 
handle map.
                                this.handle = (Xlib.Drawable)handle;
                                if(dpy.handleMap == null)
                                {
                                        dpy.handleMap = new Hashtable();
                                }
                                dpy.handleMap[(int)handle] = this;

                                // Adjust the root window object to match the 
screen state.
                                width = 
(int)(Xlib.XWidthOfScreen(screen.screen));
                                height = 
(int)(Xlib.XHeightOfScreen(screen.screen));
                                mapped = true;
                                AutoMapChildren = false;
                        }

        /// <summary>
        /// <para>Destroy this window if it is currently active.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>The root window cannot be destroyed except by closing
        /// the connection to the X display server.  If this method is
        /// called on a root window, the request will be ignored.</para>
        /// </remarks>
        public override void Destroy()
                        {
                                // Nothing to do here.
                        }

        /// <summary>
        /// <para>Move this widget to a new location relative to its 
parent.</para>
        /// </summary>
        ///
        /// <param name="x">
        /// <para>The X co-ordinate of the new top-left widget corner.</para>
        /// </param>
        ///
        /// <param name="y">
        /// <para>The Y co-ordinate of the new top-left widget corner.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>Raised if <paramref name="x"/> or <paramref name="y"/>
        /// is out of range.</para>
        /// </exception>
        public override void Move(int x, int y)
                        {
                                throw new XInvalidOperationException
                                        (S._("X_NonRootOperation"));
                        }

        /// <summary>
        /// <para>Resize this widget to a new sie.</para>
        /// </summary>
        ///
        /// <param name="width">
        /// <para>The new width for the widget.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The new width for the widget.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>Raised if <paramref name="width"/> or <paramref 
name="height"/>
        /// is out of range.</para>
        /// </exception>
        public override void Resize(int width, int height)
                        {
                                throw new XInvalidOperationException
                                        (S._("X_NonRootOperation"));
                        }

        /// <summary>
        /// <para>Map this widget to the screen.</para>
        /// </summary>
        public override void Map()
                        {
                                throw new XInvalidOperationException
                                        (S._("X_NonRootOperation"));
                        }

        /// <summary>
        /// <para>Unmap this widget from the screen.</para>
        /// </summary>
        public override void Unmap()
                        {
                                throw new XInvalidOperationException
                                        (S._("X_NonRootOperation"));
                        }

        /// <summary>
        /// <para>Get or set the cursor that is associated with this 
widget.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The cursor shape to set for the widget.  If the value is
        /// <c>CursorType.XC_inherit_parent</c>, then the widget inherits the
        /// cursor that is set on the parent widget.</para>
        /// </value>
        public override CursorType Cursor
                        {
                                get
                                {
                                        // We don't know what the root window 
has set
                                        // cursor to, so we always return the 
default.
                                        return CursorType.XC_inherit_parent;
                                }
                                set
                                {
                                        // Cannot change the mouse cursor on 
the root window.
                                        throw new XInvalidOperationException
                                                (S._("X_NonRootOperation"));
                                }
                        }

} // class RootWindow

} // namespace Xsharp

--- NEW FILE ---
/*
 * S.cs - Process string resources for the X# library.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Resources;
using System.Reflection;

internal sealed class S
{
        // Cached copy of the resources for this assembly.
        private static ResourceManager stringResources = null;

        // Helper for obtaining string resources for this assembly.
        public static String _(String tag)
                        {
                                lock(typeof(S))
                                {
                                        if(stringResources == null)
                                        {
                                                stringResources = new 
ResourceManager
                                                        ("Xsharp", 
(typeof(S)).Assembly);
                                        }
                                        return stringResources.GetString(tag, 
null);
                                }
                        }

} // class S

} // namespace Xsharp

--- NEW FILE ---
/*
 * Screen.cs - Access an X display screen.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Collections;

/// <summary>
/// <para>The <see cref="T:Xsharp.Screen"/> class manages a single
/// screen on an X display server connection.</para>
/// </summary>
public sealed class Screen
{
        // Internal state.
        private Display dpy;
        private int number;
        internal IntPtr screen;
        private Xsharp.RootWindow rootWindow;
        private IntPtr visual;
        private Colormap defaultColormap;
        private IntPtr[] defaultGCs;
        private int numDefaultGCs;
        private IntPtr[] bitmapGCs;
        private int numBitmapGCs;
        private const int GCCacheSize = 16;
        private Color[] standardColors;

        // Constructor.
        internal Screen(Display dpy, int number, IntPtr screen)
                        {
                                // Copy parameters in from the create process.
                                this.dpy = dpy;
                                this.number = number;
                                this.screen = screen;

                                // Create the root window instance for this 
screen.
                                rootWindow = new Xsharp.RootWindow
                                        (dpy, this, 
Xlib.XRootWindowOfScreen(screen));

                                // Get the default root visual for this screen.
                                visual = Xlib.XDefaultVisualOfScreen(screen);

                                // Create a "Colormap" object for the default 
colormap.
                                defaultColormap = new Colormap
                                        (dpy, this, 
Xlib.XDefaultColormapOfScreen(screen));

                                // Create the GC cache.
                                defaultGCs = new IntPtr [GCCacheSize];
                                bitmapGCs = new IntPtr [GCCacheSize];

                                // Initialize the standard colors.
                                InitStandardColors();
                        }

        /// <summary>
        /// <para>Get the display that owns this screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The owning <see cref="T:Xsharp.Display"/> instance.</para>
        /// </value>
        public Display DisplayOfScreen
                        {
                                get
                                {
                                        return dpy;
                                }
                        }

        /// <summary>
        /// <para>Get the index of this screen within its owning display.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The screen index, from <c>0</c> to
        /// <c>DisplayOfScreen.ScreenCount - 1</c></para>.
        /// </value>
        public int ScreenNumber
                        {
                                get
                                {
                                        return number;
                                }
                        }

        /// <summary>
        /// <para>Get the root window of this screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The <see cref="T:Xsharp.Window"/> instance that corresponds
        /// to the root window of this screen.</para>
        /// </value>
        public Xsharp.RootWindow RootWindow
                        {
                                get
                                {
                                        return rootWindow;
                                }
                        }

        /// <summary>
        /// <para>Get the default colormap for this screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The default <see cref="T:Xsharp.Colormap"/> instance.</para>
        /// </value>
        public Colormap DefaultColormap
                        {
                                get
                                {
                                        return defaultColormap;
                                }
                        }

        /// <summary>
        /// <para>Get the default depth of this screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The default depth value.</para>
        /// </value>
        public int DefaultDepth
                        {
                                get
                                {
                                        try
                                        {
                                                dpy.Lock();
                                                return 
(int)(Xlib.XDefaultDepthOfScreen(screen));
                                        }
                                        finally
                                        {
                                                dpy.Unlock();
                                        }
                                }
                        }

        /// <summary>
        /// <para>Get the width of this screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The screen width.</para>
        /// </value>
        public int Width
                        {
                                get
                                {
                                        try
                                        {
                                                dpy.Lock();
                                                return 
(int)(Xlib.XWidthOfScreen(screen));
                                        }
                                        finally
                                        {
                                                dpy.Unlock();
                                        }
                                }
                        }

        /// <summary>
        /// <para>Get the height of this screen.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The screen height.</para>
        /// </value>
        public int Height
                        {
                                get
                                {
                                        try
                                        {
                                                dpy.Lock();
                                                return 
(int)(Xlib.XHeightOfScreen(screen));
                                        }
                                        finally
                                        {
                                                dpy.Unlock();
                                        }
                                }
                        }

        // Get the default visual for this screen.  We currently only
        // support screens with one visual.
        internal IntPtr DefaultVisual
                        {
                                get
                                {
                                        return visual;
                                }
                        }

        // Reuse an Xlib GC value that was previously allocated to this screen.
        // Returns IntPtr.Zero if there are no cached GC's available.
        internal IntPtr GetGC(bool isBitmapGC)
                        {
                                if(!isBitmapGC)
                                {
                                        if(numDefaultGCs > 0)
                                        {
                                                return 
defaultGCs[--numDefaultGCs];
                                        }
                                }
                                else
                                {
                                        if(numBitmapGCs > 0)
                                        {
                                                return 
bitmapGCs[--numBitmapGCs];
                                        }
                                }
                                return IntPtr.Zero;
                        }

        // Release an Xlib GC value from a GC object that was disposed.
        internal void ReleaseGC(IntPtr gc, bool isBitmapGC)
                        {
                                if(!isBitmapGC)
                                {
                                        if(numDefaultGCs < GCCacheSize)
                                        {
                                                defaultGCs[numDefaultGCs++] = 
gc;
                                        }
                                        else
                                        {
                                                Xlib.XFreeGC(dpy.dpy, gc);
                                        }
                                }
                                else
                                {
                                        if(numBitmapGCs < GCCacheSize)
                                        {
                                                bitmapGCs[numBitmapGCs++] = gc;
                                        }
                                        else
                                        {
                                                Xlib.XFreeGC(dpy.dpy, gc);
                                        }
                                }
                        }

        // Initialize the standard colors on this screen.
        private void InitStandardColors()
                        {
                                standardColors = new Color 
[((int)(StandardColor.Last)) - 1];

                                standardColors[((int)StandardColor.Foreground) 
- 1]
                                        = new Color(0x00, 0x00, 0x00);
                                standardColors[((int)StandardColor.Background) 
- 1]
                                        = new Color(0xBF, 0xBF, 0xBF);
                                
standardColors[((int)StandardColor.HighlightForeground) - 1]
                                        = new Color(0xFF, 0xFF, 0xFF);
                                
standardColors[((int)StandardColor.HighlightBackground) - 1]
                                        = new Color(0x00, 0x00, 0x80);
                                standardColors[((int)StandardColor.TopShadow) - 
1]
                                        = new Color(0xFF, 0xFF, 0xFF);
                                
standardColors[((int)StandardColor.TopShadowEnhance) - 1]
                                        = new Color(0xBF, 0xBF, 0xBF);
                                
standardColors[((int)StandardColor.BottomShadow) - 1]
                                        = new Color(0x80, 0x80, 0x80);
                                
standardColors[((int)StandardColor.BottomShadowEnhance) - 1]
                                        = new Color(0x44, 0x44, 0x44);
                                standardColors[((int)StandardColor.Trim) - 1]
                                        = new Color(0x00, 0x00, 0x00);

                                
standardColors[((int)StandardColor.ContentForeground) - 1]
                                        = new Color(0x00, 0x00, 0x00);
                                
standardColors[((int)StandardColor.ContentBackground) - 1]
                                        = new Color(0xFF, 0xFF, 0xFF);
                                standardColors
                                        
[((int)StandardColor.ContentHighlightForeground) - 1]
                                        = new Color(0xFF, 0xFF, 0xFF);
                                standardColors
                                        
[((int)StandardColor.ContentHighlightBackground) - 1]
                                        = new Color(0x00, 0x00, 0x80);
                                
standardColors[((int)StandardColor.ContentTopShadow) - 1]
                                        = new Color(0xFF, 0xFF, 0xFF);
                                standardColors
                                        
[((int)StandardColor.ContentTopShadowEnhance) - 1]
                                        = new Color(0xBF, 0xBF, 0xBF);
                                
standardColors[((int)StandardColor.ContentBottomShadow) - 1]
                                        = new Color(0x80, 0x80, 0x80);
                                standardColors
                                        
[((int)StandardColor.ContentBottomShadowEnhance) - 1]
                                        = new Color(0x44, 0x44, 0x44);
                                standardColors[((int)StandardColor.ContentTrim) 
- 1]
                                        = new Color(0x00, 0x00, 0x00);

                                standardColors[((int)StandardColor.Inherit) - 1]
                                        = 
standardColors[((int)StandardColor.Background) - 1];
                                standardColors[((int)StandardColor.Pixmap) - 1]
                                        = 
standardColors[((int)StandardColor.Background) - 1];
                        }

        // Expand a standard color into a full color value.
        internal Color ToColor(StandardColor color)
                        {
                                if(color > StandardColor.RGB && color < 
StandardColor.Last)
                                {
                                        return standardColors[((int)color) - 1];
                                }
                                else
                                {
                                        return new Color(0x00, 0x00, 0x00);
                                }
                        }

} // class Screen

} // namespace Xsharp

--- NEW FILE ---
/*
 * StandardColor.cs - Indexes into the standard color palette.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.StandardColor"/> enumeration specifies
/// indexes into the standard color palette, independent of the particulars
/// of specific themes.</para>
/// </summary>
public enum StandardColor
{
        // Explicit RGB value (i.e. not a standard palette index).
        RGB,

        // Color set for drawing widget controls (e.g. buttons, dialogs).
        Foreground,
        Background,
        HighlightForeground,
        HighlightBackground,
        TopShadow,
        TopShadowEnhance,
        BottomShadow,
        BottomShadowEnhance,
        Trim,

        // Color set for drawing content widgets (e.g. text boxes, list boxes).
        ContentForeground,
        ContentBackground,
        ContentHighlightForeground,
        ContentHighlightBackground,
        ContentTopShadow,
        ContentTopShadowEnhance,
        ContentBottomShadow,
        ContentBottomShadowEnhance,
        ContentTrim,

        // Special color values for widget backgrounds.
        Inherit,
        Pixmap,

        // Must be the last color index.
        Last

} // enum StandardColor

} // namespace Xsharp

--- NEW FILE ---
/*
 * SubwindowMode.cs - GC subwindow drawing modes.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>The <see cref="T:Xsharp.SubwindowMode"/> enumeration specifies
/// the subwindow drawing mode for graphics objects
/// (<see cref="T:Xsharp.Graphics"/>).
/// </para>
/// </summary>
public enum SubwindowMode
{

        ClipByChildren   = 0,
        IncludeInferiors = 1

} // enum SubwindowMode

} // namespace Xsharp

--- NEW FILE ---
/*
 * TopLevelWindow.cs - Widget handling for top-level application windows.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Runtime.InteropServices;
using Xsharp.Types;
using Xsharp.Events;

/// <summary>
/// <para>The <see cref="T:Xsharp.TopLevelWindow"/> class manages
/// top-level application windows.</para>
/// </summary>
public class TopLevelWindow : InputOutputWidget
{
        // Internal state.
        private String name;
        private bool iconic;
        private bool hasPrimaryFocus;
        private IntPtr keyBuffer;
        private InputOnlyWidget focusWidget;
        private InputOnlyWidget defaultFocus;

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.TopLevelWindow"/>
        /// instance.</para>
        /// </summary>
        ///
        /// <param name="name">
        /// <para>The initial name to display in the title bar.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new window.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new window.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>Raised if <paramref name="width"/> or <paramref 
name="height"/>
        /// is out of range.</para>
        /// </exception>
        ///
        /// <remarks>
        /// <para>The new top-level window will be created on the default
        /// screen of the primary display.  If the primary display is
        /// not open, this constructor will open it.</para>
        /// </remarks>
        public TopLevelWindow(String name, int width, int height)
                        : this(null, name, width, height)
                        {
                                // Nothing to do here: the next constructor 
does all the work.
                        }

        /// <summary>
        /// <para>Constructs a new <see cref="T:Xsharp.TopLevelWindow"/>
        /// instance.</para>
        /// </summary>
        ///
        /// <param name="screen">
        /// <para>The screen to display the new top-level window on, or
        /// <see langword="null"/> to use the default screen of the
        /// primary display.</para>
        /// </param>
        ///
        /// <param name="name">
        /// <para>The initial name to display in the title bar.  If this
        /// is <see langword="null"/> then the empty string will be used.</para>
        /// </param>
        ///
        /// <param name="width">
        /// <para>The width of the new widget.</para>
        /// </param>
        ///
        /// <param name="height">
        /// <para>The height of the new widget.</para>
        /// </param>
        ///
        /// <exception cref="T:Xsharp.XException">
        /// <para>Raised if <paramref name="width"/> or <paramref 
name="height"/>
        /// is out of range.</para>
        /// </exception>
        public TopLevelWindow(Screen screen, String name, int width, int height)
                        : base(GetRoot(screen), 0, 0, width, height,
                               new Color(StandardColor.Foreground),
                               new Color(StandardColor.Background),
                                   true, false)
                        {
                                // Initialize this object's state.
                                this.name = ((name != null) ? name : 
String.Empty);
                                this.iconic = false;
                                this.hasPrimaryFocus = false;
                                this.keyBuffer = IntPtr.Zero;
                                this.focusWidget = this;
                                this.defaultFocus = null;

                                // Set the initial WM properties.
                                try
                                {
                                        // Lock down the display and get the 
window handle.
                                        IntPtr display = dpy.Lock();
                                        Xlib.Window handle = GetWidgetHandle();

                                        // Set the title bar and icon names.
                                        Xlib.XStoreName(display, handle, name);
                                        Xlib.XSetIconName(display, handle, 
name);

                                        // Ask for "WM_DELETE_WINDOW" and 
"WM_TAKE_FOCUS".
                                        Xlib.Atom[] protocols = new Xlib.Atom 
[2];
                                        protocols[0] = dpy.wmDeleteWindow;
                                        protocols[1] = dpy.wmTakeFocus;
                                        Xlib.XSetWMProtocols(display, handle, 
protocols, 2);

                                        // Top-level widgets receive all key 
and focus events.
                                        SelectInput(EventMask.KeyPressMask |
                                                                
EventMask.FocusChangeMask);
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Destroy an instance of <see cref="T:Xsharp.TopLevelWindow"/>.
        /// </para>
        /// </summary>
        ~TopLevelWindow()
                        {
                                if(keyBuffer != IntPtr.Zero)
                                {
                                        Marshal.FreeHGlobal(keyBuffer);
                                        keyBuffer = IntPtr.Zero;
                                }
                        }

        // Helper method to get the root window of a specified screen.
        private static Widget GetRoot(Screen screen)
                        {
                                if(screen == null)
                                {
                                        return Xsharp.Application.Primary
                                                                
.Display.DefaultRootWindow;
                                }
                                else
                                {
                                        return screen.RootWindow;
                                }
                        }

        /// <summary>
        /// <para>Map this widget to the screen.</para>
        /// </summary>
        public override void Map()
                        {
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        if(!mapped)
                                        {
                                                // Use "XMapRaised" to notify 
the window manager
                                                // that we want to be brought 
to the top.
                                                Xlib.XMapRaised(display, 
GetWidgetHandle());
                                                mapped = true;
                                                MapStateChanged();
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Unmap this widget from the screen.</para>
        /// </summary>
        public override void Unmap()
                        {
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        if(mapped)
                                        {
                                                // Send a "withdraw" message to 
the window manager,
                                                // which will take care of 
unmapping the window for us.
                                                Xlib.XWithdrawWindow
                                                        (display, 
GetWidgetHandle(), screen.ScreenNumber);
                                                mapped = false;
                                                MapStateChanged();
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Iconify this window.</para>
        /// </summary>
        public void Iconify()
                        {
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        if(!iconic)
                                        {
                                                // Send an "iconify" message to 
the window manager,
                                                // which will take care of 
iconifying the window.
                                                Xlib.XIconifyWindow
                                                        (display, 
GetWidgetHandle(), screen.ScreenNumber);
                                                iconic = true;
                                                if(IconicState != null)
                                                {
                                                        IconicState(this, true);
                                                }
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>De-iconify this window.</para>
        /// </summary>
        public void Deiconify()
                        {
                                try
                                {
                                        IntPtr display = dpy.Lock();
                                        if(iconic)
                                        {
                                                // Use "XMapRaised" to notify 
the window manager
                                                // that we want to be 
de-iconified.
                                                Xlib.XMapRaised(display, 
GetWidgetHandle());
                                                iconic = false;
                                                if(IconicState != null)
                                                {
                                                        IconicState(this, 
false);
                                                }
                                                if(!mapped)
                                                {
                                                        // We are mapped now as 
well.
                                                        mapped = true;
                                                        MapStateChanged();
                                                }
                                        }
                                }
                                finally
                                {
                                        dpy.Unlock();
                                }
                        }

        /// <summary>
        /// <para>Close this window, as if the user had clicked the close box.
        /// </para>
        /// </summary>
        ///
        /// <returns>
        /// <para>Returns <see langword="true"/> if the window was destroyed,
        /// or <see langword="false"/> if the window is still active
        /// because one of the close event handlers reported
        /// <see langword="false"/>.</para>
        /// </returns>
        public bool Close()
                        {
                                // Bail out if the window has already been 
destroyed.
                                if(handle == Xlib.Drawable.Zero)
                                {
                                        return true;
                                }

                                // Call each of the "Closed" event handlers in 
turn,
                                // until one returns false or the window is 
destroyed.
                                if(Closed != null)
                                {
                                        Delegate[] list = 
Closed.GetInvocationList();
                                        int index;
                                        ClosedEventHandler handler;
                                        for(index = 0; index < list.Length; 
++index)
                                        {
                                                handler = 
(ClosedEventHandler)(list[index]);
                                                if(!handler(this))
                                                {
                                                        // This handler wanted 
us to bail out.
                                                        return (handle == 
Xlib.Drawable.Zero);
                                                }
                                                else if(handle == 
Xlib.Drawable.Zero)
                                                {
                                                        // The handler 
destroyed the window: we assume
                                                        // that it didn't want 
the standard quit logic.
                                                        return true;
                                                }
                                        }
                                }

                                // Destroy the window.
                                Destroy();

                                // If this was the last undestroyed top-level 
window
                                // that was still mapped, then quit the 
application.
                                Widget child = Parent.TopChild;
                                TopLevelWindow tchild;
                                bool sawActive = false;
                                while(child != null)
                                {
                                        tchild = (child as TopLevelWindow);
                                        if(tchild != null)
                                        {
                                                if(tchild.mapped &&
                                                   tchild.handle != 
Xlib.Drawable.Zero)
                                                {
                                                        sawActive = true;
                                                        break;
                                                }
                                        }
                                        child = child.NextBelow;
                                }
                                if(!sawActive)
                                {
                                        dpy.Quit();
                                }

                                // The window no longer exists.
                                return true;
                        }

        /// <summary>
        /// <para>Get or set the name in the window's title bar.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The value of this property is the name to display in
        /// the title bar.  If the value is set to <see langword="null"/>,
        /// then the empty string will be used.</para>
        /// </value>
        public String Name
                        {
                                get
                                {
                                        return name;
                                }
                                set
                                {
                                        if(name != value)
                                        {
                                                name = ((value != null) ? value 
: String.Empty);
                                                try
                                                {
                                                        // Lock down the 
display and get the window handle.
                                                        IntPtr display = 
dpy.Lock();
                                                        Xlib.Window handle = 
GetWidgetHandle();

                                                        // Set the title bar 
and icon names.
                                                        
Xlib.XStoreName(display, handle, name);
                                                        
Xlib.XSetIconName(display, handle, name);
                                                }
                                                finally
                                                {
                                                        dpy.Unlock();
                                                }
                                        }
                                }
                        }

        /// <summary>
        /// <para>Get or set the child widget that gets the keyboard focus
        /// by default when the top-level window receives the focus.</para>
        /// </summary>
        ///
        /// <value>
        /// <para>The widget that receives the focus, or <see langword="null"/>
        /// if there is no default focus.</para>
        /// </value>
        ///
        /// <exception cref="T.Xsharp.XInvalidOperationException">
        /// <para>Raised if the widget is not a child of this top-level window.
        /// </para>
        /// </exception>
        public Widget DefaultFocus
                        {
                                get
                                {
                                        return defaultFocus;
                                }
                                set
                                {
                                        if(value == null)
                                        {
                                                defaultFocus = null;
                                        }
                                        else
                                        {
                                                if(!(value is InputOnlyWidget) 
||
                                                   value.TopLevel != this)
                                                {
                                                        throw new 
XInvalidOperationException
                                                                
(S._("X_InvalidFocusChild"));
                                                }
                                        }
                                }
                        }

        /// <summary>
        /// <para>Event that is raised when the window's iconic state
        /// changes.</para>
        /// </summary>
        public event IconicStateEventHandler IconicState;

        /// <summary>
        /// <para>Event that is raised when the window's close box is
        /// clicked by the user.</para>
        /// </summary>
        ///
        /// <remarks>
        /// <para>The system will call each close handler in turn.  If one
        /// of them returns <see langword="false"/>, the process stops
        /// and no further actions are taken.</para>
        ///
        /// <para>If all handlers return <see langword="true"/>, or there
        /// are no handlers registered, then <c>Destroy</c> will be called
        /// to destroy the window.  If this was the last mapped top-level
        /// window attached to the screen, then <c>Display.Quit</c> will
        /// then be called to quit the application.</para>
        ///
        /// <para>If an event handler wants to remove the window from the
        /// screen without destroying it or quitting, it should call
        /// <c>Unmap</c> and then return <see langword="false"/>.</para>
        ///
        /// <para>If an event handler wants to destroy a window without
        /// quitting, it should call <c>Destroy</c> and then return
        /// <see langword="false"/>.</para>
        /// </remarks>
        public event ClosedEventHandler Closed;

        // Detect that this top-level window has gained the primary focus.
        private void PrimaryFocusIn()
                        {
                                if(!hasPrimaryFocus)
                                {
                                        hasPrimaryFocus = true;
                                        if(defaultFocus != null)
                                        {
                                                focusWidget = defaultFocus;
                                                
focusWidget.DispatchFocusIn(null);
                                        }
                                        else if(focusWidget != null)
                                        {
                                                
focusWidget.DispatchFocusIn(null);
                                        }
                                }
                        }

        // Set the focus widget to a specific child.
        internal void SetFocus(InputOnlyWidget widget)
                        {
                                if(!hasPrimaryFocus)
                                {
                                        focusWidget = widget;
                                }
                                else if(focusWidget != widget)
                                {
                                        InputOnlyWidget oldFocus = focusWidget;
                                        focusWidget = widget;
                                        oldFocus.DispatchFocusOut(widget);
                                        if(focusWidget == widget)
                                        {
                                                
widget.DispatchFocusIn(oldFocus);
                                        }
                                }
                        }

        // Determine if a specific child currently has the focus.
        internal bool HasFocus(InputOnlyWidget widget)
                        {
                                return (hasPrimaryFocus && focusWidget == 
widget);
                        }

        // Dispatch an event to this widget.
        internal override void DispatchEvent(ref XEvent xevent)
                        {
                                switch(xevent.type)
                                {
                                        case EventType.ClientMessage:
                                        {
                                                // Handle messages from the 
window manager.
                                                if(xevent.xclient.message_type 
== dpy.wmProtocols)
                                                {
                                                        if(xevent.xclient.l(0) 
==
                                                                        
(int)(dpy.wmDeleteWindow))
                                                        {
                                                                // User wants 
the window to close.
                                                                Close();
                                                        }
                                                        if(xevent.xclient.l(0) 
== (int)(dpy.wmTakeFocus))
                                                        {
                                                                // We were 
given the primary input focus.
                                                                
PrimaryFocusIn();
                                                        }
                                                }
                                        }
                                        break;

                                        case EventType.FocusIn:
                                        {
                                                // This window has received the 
focus.
                                                PrimaryFocusIn();
                                        }
                                        break;

                                        case EventType.FocusOut:
                                        {
                                                // This window has lost the 
focus.
                                                if(hasPrimaryFocus)
                                                {
                                                        hasPrimaryFocus = false;
                                                        if(focusWidget != null)
                                                        {
                                                                
focusWidget.DispatchFocusOut(null);
                                                        }
                                                }
                                        }
                                        break;

                                        case EventType.KeyPress:
                                        {
                                                // Convert the event into a 
symbol and a string.
                                                if(keyBuffer == IntPtr.Zero)
                                                {
                                                        keyBuffer = 
Marshal.AllocHGlobal(32);
                                                }
                                                Xlib.KeySym keysym = 0;
                                                int len = Xlib.XLookupString
                                                        (ref xevent.xkey, 
keyBuffer, 32,
                                                         ref keysym, 
IntPtr.Zero);
                                                String str;
                                                if(len > 0)
                                                {
                                                        str = 
Marshal.PtrToStringAnsi(keyBuffer, len);
                                                }
                                                else
                                                {
                                                        str = null;
                                                }

                                                // Dispatch the event.
                                                Widget widget = focusWidget;
                                                InputOnlyWidget io;
                                                while(widget != null)
                                                {
                                                        io = (widget as 
InputOnlyWidget);
                                                        if(io != null)
                                                        {
                                                                
if(io.DispatchKeyEvent
                                                                        
((KeyName)keysym, xevent.xkey.state, str))
                                                                {
                                                                        break;
                                                                }
                                                        }
                                                        if(widget == this)
                                                        {
                                                                break;
                                                        }
                                                        widget = widget.Parent;
                                                }
                                        }
                                        break;
                                }
                                base.DispatchEvent(ref xevent);
                        }

} // class TopLevelWindow

} // namespace Xsharp

--- NEW FILE ---
/*
 * Widget.cs - Basic widget handling for X applications.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
[...1180 lines suppressed...]

        /// <summary>
        /// <para>Event that is raised when the widget is resized to
        /// a new size.</para>
        /// </summary>
        public event ResizedEventHandler Resized;

        /// <summary>
        /// <para>Event that is raised when the widget's map state 
changes.</para>
        /// </summary>
        public event MapStateEventHandler MapState;

        /// <summary>
        /// <para>Event that is raised when the widget's sensitivity 
changes.</para>
        /// </summary>
        public event SensitivityChangedEventHandler SensitivityChanged;

} // class Widget

} // namespace Xsharp

--- NEW FILE ---
/*
 * XCannotConnectException.cs - Exception that is thrown when X#
 *              cannot connect to an X display server.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>Exception type that is thrown when <c>Xsharp.Display.Open</c>
/// cannot connect to an X display server.</para>
/// </summary>
public sealed class XCannotConnectException : XException
{

        // Constructors.
        public XCannotConnectException()
                : base(S._("X_CannotOpen")) {}
        public XCannotConnectException(String msg)
                : base(msg) {}
        public XCannotConnectException(String msg, Exception inner)
                : base(msg, inner) {}

} // class XCannotConnectException

} // namespace Xsharp

--- NEW FILE ---
/*
 * XException.cs - Base class for X# exceptions.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>This is the base class for all exceptions that are thrown
/// by the library.</para>
/// </summary>
public class XException : SystemException
{

        // Constructors.
        public XException()
                : base(S._("X_Exception")) {}
        public XException(String msg)
                : base(msg) {}
        public XException(String msg, Exception inner)
                : base(msg, inner) {}

} // class XException

} // namespace Xsharp

--- NEW FILE ---
/*
 * XInvalidOperationException.cs - Exception that is thrown when
 *              X# has detected an invalid state (e.g. window destroyed).
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;

/// <summary>
/// <para>Exception type that is thrown when the library detects an
/// invalid state.  For example, attempting to move a destroyed window,
/// creating a window on a closed display connection, etc.</para>
/// </summary>
public sealed class XInvalidOperationException : XException
{

        // Constructors.
        public XInvalidOperationException()
                : base(S._("X_InvalidOperation")) {}
        public XInvalidOperationException(String msg)
                : base(msg) {}
        public XInvalidOperationException(String msg, Exception inner)
                : base(msg, inner) {}

} // class XInvalidOperationException

} // namespace Xsharp

--- NEW FILE ---
/*
 * Xlib.cs - Native method interface for Xlib.
 *
 * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Xsharp
{

using System;
using System.Runtime.InteropServices;
using Xsharp.Events;
using Xsharp.Types;

internal sealed class Xlib
{
        // Declare Xlib types that may be different sizes on different 
platforms.
        //
        // Declaring these as enumerated types is a C# trick to get a new
        // integer type of the correct size that is guaranteed to be marshalled
        // to Xlib in the same way as the underlying integer type.

        public enum Pixel    : @X_ulong@ { Zero }
        public enum XID      : @X_ulong@ { Zero }
        public enum Mask     : @X_ulong@ { Zero }
        public enum Atom     : @X_ulong@ { Zero }
        public enum VisualID : @X_ulong@ { Zero }
        public enum Time     : @X_ulong@ { CurrentTime }
        public enum Window   : @X_ulong@ { Zero }
        public enum Drawable : @X_ulong@ { Zero }
        public enum Font     : @X_ulong@ { Zero }
        public enum Pixmap   : @X_ulong@ { Zero, ParentRelative }
        public enum Cursor   : @X_ulong@ { Zero }
        public enum Colormap : @X_ulong@ { Zero }
        public enum GContext : @X_ulong@ { Zero }
        public enum KeySym   : @X_ulong@ { Zero }
        public enum KeyCode  : byte { Zero }
        public enum Bool     : @X_int@ { False, True }
        public enum Status   : @X_int@ { Zero }
        public enum Xint     : @X_int@ { Zero }
        public enum Xuint    : @X_uint@ { Zero }
        public enum Xlong    : @X_long@ { Zero }
        public enum Xulong   : @X_ulong@ { Zero }

        // Declare display-related external functions.

        [DllImport("X11")]
        extern public static Status XInitThreads();

        [DllImport("X11")]
        extern public static IntPtr XOpenDisplay(String display_name);

        [DllImport("X11")]
        extern public static @X_int@ XCloseDisplay(IntPtr display);

        [DllImport("X11")]
        extern public static String XDisplayName(String str);

        [DllImport("X11")]
        extern public static @X_int@ XScreenCount(IntPtr display);

        [DllImport("X11")]
        extern public static IntPtr XScreenOfDisplay(IntPtr display, @X_int@ 
scr);

        [DllImport("X11")]
        extern public static @X_int@ XDefaultScreen(IntPtr display);

        [DllImport("X11")]
        extern public static String XDisplayString(IntPtr display);

        [DllImport("X11")]
        extern public static @X_int@ XFlush(IntPtr display);

        [DllImport("X11")]
        extern public static @X_int@ XSync(IntPtr display, Bool discard);

        [DllImport("X11")]
        extern public static @X_int@ XBell(IntPtr display, @X_int@ percent);

        [DllImport("X11")]
        extern public static @X_long@ XMaxRequestSize(IntPtr display);

        // Declare screen-related external functions.

        [DllImport("X11")]
        extern public static Window XRootWindowOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static Pixel XBlackPixelOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static Pixel XWhitePixelOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static Colormap XDefaultColormapOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static @X_int@ XDefaultDepthOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static @X_int@ XWidthOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static @X_int@ XHeightOfScreen(IntPtr screen);

        [DllImport("X11")]
        extern public static IntPtr XDefaultVisualOfScreen(IntPtr screen);

        // Declare window-related external functions.

        [DllImport("X11")]
        extern public static Window XCreateWindow
                        (IntPtr display, Window parent, @X_int@ x, @X_int@ y,
                     @X_uint@ width, @X_uint@ height, @X_uint@ border_width,
                         @X_int@ depth, @X_int@ c_class, IntPtr visual,
                         @X_ulong@ value_mask, ref XSetWindowAttributes values);

        [DllImport("X11")]
        extern public static Window XCreateWindow
                        (IntPtr display, Window parent, @X_int@ x, @X_int@ y,
                     @X_uint@ width, @X_uint@ height, @X_uint@ border_width,
                         @X_int@ depth, @X_int@ c_class, IntPtr visual,
                         @X_ulong@ value_mask, IntPtr values); // for values == 
null.

        [DllImport("X11")]
        extern public static @X_int@ XDestroyWindow(IntPtr display, Window w);

        [DllImport("X11")]
        extern public static @X_int@ XMoveWindow
                        (IntPtr display, Window w, @X_int@ x, @X_int@ y);

        [DllImport("X11")]
        extern public static @X_int@ XResizeWindow
                        (IntPtr display, Window w, @X_uint@ width, @X_uint@ 
height);

        [DllImport("X11")]
        extern public static @X_int@ XMoveResizeWindow
                        (IntPtr display, Window w, @X_int@ x, @X_int@ y,
                         @X_uint@ width, @X_uint@ height);

        [DllImport("X11")]
        extern public static @X_int@ XConfigureWindow
                        (IntPtr display, Window w, @X_uint@ value_mask,
                         ref XWindowChanges changes);

        [DllImport("X11")]
        extern public static @X_int@ XMapWindow(IntPtr display, Window w);

        [DllImport("X11")]
        extern public static @X_int@ XMapRaised(IntPtr display, Window w);

        [DllImport("X11")]
        extern public static @X_int@ XUnmapWindow(IntPtr display, Window w);

        [DllImport("X11")]
        extern public static Status XWithdrawWindow
                        (IntPtr display, Window w, @X_int@ screen_number);

        [DllImport("X11")]
        extern public static Status XIconifyWindow
                        (IntPtr display, Window w, @X_int@ screen_number);

        [DllImport("X11")]
        extern public static Cursor XCreateFontCursor
                        (IntPtr display, @X_uint@ shape);

        [DllImport("X11")]
        extern public static @X_int@ XDefineCursor
                        (IntPtr display, Window w, Cursor cursor);

        [DllImport("X11")]
        extern public static @X_int@ XUndefineCursor(IntPtr display, Window w);

        [DllImport("X11")]
        extern public static @X_int@ XSetWindowBackground
                        (IntPtr display, Window w, Pixel background_pixel);

        [DllImport("X11")]
        extern public static @X_int@ XSetWindowBackgroundPixmap
                        (IntPtr display, Window w, Pixmap background_pixmap);

        [DllImport("X11")]
        extern public static @X_int@ XClearArea
                        (IntPtr display, Window w, @X_int@ x, @X_int@ y,
                         @X_uint@ width, @X_uint@ height, Bool exposures);

        // Declare pixmap-related external functions.

        [DllImport("X11")]
        extern public static Xlib.Pixmap XCreatePixmap
                        (IntPtr display, Xlib.Drawable d, @X_uint@ width,
                         @X_uint@ height, @X_uint@ depth);

        [DllImport("X11")]
        extern public static @X_int@ XFreePixmap
                        (IntPtr display, Xlib.Pixmap pixmap);

        [DllImport("X11")]
        extern public static Pixmap XCreateBitmapFromData
                        (IntPtr display, Drawable drawable, byte[] data,
                         @X_uint@ width, @X_uint@ height);

        // Declare region-related external functions.

        [DllImport("X11")]
        extern public static IntPtr XCreateRegion();

        [DllImport("X11")]
        extern public static @X_int@ XDestroyRegion(IntPtr r);

        [DllImport("X11")]
        extern public static @X_int@ XUnionRegion(IntPtr sra, IntPtr srb,
                                                                                
          IntPtr dr_return);

        [DllImport("X11")]
        extern public static @X_int@ XUnionRectWithRegion
                        (ref XRectangle rectangle, IntPtr src, IntPtr dest);

        [DllImport("X11")]
        extern public static @X_int@ XIntersectRegion(IntPtr sra, IntPtr srb,
                                                                                
              IntPtr dr_return);

        [DllImport("X11")]
        extern public static @X_int@ XSubtractRegion(IntPtr sra, IntPtr srb,
                                                                                
             IntPtr dr_return);

        [DllImport("X11")]
        extern public static @X_int@ XXorRegion(IntPtr sra, IntPtr srb,
                                                                                
    IntPtr dr_return);

        [DllImport("X11")]
        extern public static @X_int@ XEmptyRegion(IntPtr r);

        [DllImport("X11")]
        extern public static @X_int@ XEqualRegion(IntPtr r1, IntPtr r2);

        [DllImport("X11")]
        extern public static @X_int@ XOffsetRegion
                        (IntPtr r, @X_int@ dx, @X_int@ dy);

        [DllImport("X11")]
        extern public static @X_int@ XShrinkRegion
                        (IntPtr r, @X_int@ dx, @X_int@ dy);

        [DllImport("X11")]
        extern public static @X_int@ XPointInRegion
                        (IntPtr r, @X_int@ x, @X_int@ y);

        [DllImport("X11")]
        extern public static IntPtr XPolygonRegion
                        (XPoint[] points, @X_int@ n, @X_int@ fill_rule);

        [DllImport("X11")]
        extern public static @X_int@ XClipBox(IntPtr region, out XRectangle 
rect);

        [DllImport("X11")]
        extern public static @X_int@ XRectInRegion
                        (IntPtr region, @X_int@ x, @X_int@ y,
                         @X_uint@ width, @X_uint@ height);

        // Declare event-related external functions.

        [DllImport("X11")]
        extern public static @X_int@ XNextEvent(IntPtr display, out XEvent 
xevent);

        [DllImport("X11")]
        extern public static @X_int@ XEventsQueued(IntPtr display, @X_int@ 
mode);

        [DllImport("X11")]
        extern public static @X_int@ XSelectInput(IntPtr display, Window w,
                                                                                
          @X_long@ mode);

        // Declare GC-related external functions.

        [DllImport("X11")]
        extern public static IntPtr XCreateGC(IntPtr display,
                                                                                
  Xlib.Drawable drawable,
                                                                                
  @X_ulong@ values_mask,
                                                                                
  ref XGCValues values);

        [DllImport("X11")]
        extern public static @X_int@ XFreeGC(IntPtr display, IntPtr gc);

        [DllImport("X11")]
        extern public static @X_int@ XChangeGC(IntPtr display, IntPtr gc,
                                                                                
   @X_ulong@ values_mask,
                                                                                
   ref XGCValues values);

        [DllImport("X11")]
        extern public static @X_int@ XGetGCValues(IntPtr display, IntPtr gc,
                                                                                
      @X_ulong@ values_mask,
                                                                                
      out XGCValues values);

        [DllImport("X11")]
        extern public static @X_int@ XSetForeground
                        (IntPtr display, IntPtr gc, Xlib.Pixel foreground);

        [DllImport("X11")]
        extern public static @X_int@ XSetBackground
                        (IntPtr display, IntPtr gc, Xlib.Pixel background);

        [DllImport("X11")]
        extern public static @X_int@ XSetFunction
                        (IntPtr display, IntPtr gc, @X_int@ function);

        [DllImport("X11")]
        extern public static @X_int@ XSetFillStyle
                        (IntPtr display, IntPtr gc, @X_int@ fill_style);

        [DllImport("X11")]
        extern public static @X_int@ XSetTile
                        (IntPtr display, IntPtr gc, Pixmap tile);

        [DllImport("X11")]
        extern public static @X_int@ XSetStipple
                        (IntPtr display, IntPtr gc, Pixmap stipple);

        [DllImport("X11")]
        extern public static @X_int@ XSetTSOrigin
                        (IntPtr display, IntPtr gc, @X_int@ ts_x_origin,
                         @X_int@ ts_y_origin);

        [DllImport("X11")]
        extern public static @X_int@ XSetRegion
                        (IntPtr display, IntPtr gc, IntPtr r);

        [DllImport("X11")]
        extern public static @X_int@ XSetClipMask
                        (IntPtr display, IntPtr gc, Pixmap pixmap);

        [DllImport("X11")]
        extern public static @X_int@ XSetClipOrigin
                        (IntPtr display, IntPtr gc, @X_int@ x, @X_int@ y);

        [DllImport("X11")]
        extern public static @X_int@ XDrawLine
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         @X_int@ x1, @X_int@ y1, @X_int@ x2, @X_int@ y2);

        [DllImport("X11")]
        extern public static @X_int@ XDrawLines
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         XPoint[] points, @X_int@ npoints, @X_int@ mode);

        [DllImport("X11")]
        extern public static @X_int@ XDrawPoint
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         @X_int@ x, @X_int@ y);

        [DllImport("X11")]
        extern public static @X_int@ XDrawPoints
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         XPoint[] points, @X_int@ npoints, @X_int@ mode);

        [DllImport("X11")]
        extern public static @X_int@ XDrawRectangle
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         @X_int@ x, @X_int@ y, @X_int@ width, @X_int@ height);

        [DllImport("X11")]
        extern public static @X_int@ XDrawRectangles
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         XRectangle[] rectangles, @X_int@ nrectangles);

        [DllImport("X11")]
        extern public static @X_int@ XFillRectangle
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         @X_int@ x, @X_int@ y, @X_int@ width, @X_int@ height);

        [DllImport("X11")]
        extern public static @X_int@ XFillRectangles
                        (IntPtr display, Drawable drawable, IntPtr gc,
                         XRectangle[] rectangles, @X_int@ nrectangles);

        // Declare window manager related external functions.

        [DllImport("X11")]
        extern public static @X_int@ XStoreName
                        (IntPtr display, Xlib.Window w, String window_name);

        [DllImport("X11")]
        extern public static @X_int@ XSetIconName
                        (IntPtr display, Xlib.Window w, String window_name);

        [DllImport("X11")]
        extern public static Status XSetWMProtocols
                        (IntPtr display, Xlib.Window w, Atom[] protocols, 
@X_int@ count);

        // Declare color-related external functions.

        [DllImport("X11")]
        extern public static @X_int@ XAllocColor
                        (IntPtr display, Xlib.Colormap colormap, ref XColor 
xcolor);

        // Declare key-related and pointer-related external functions.

        [DllImport("X11")]
        extern public static @X_int@ XLookupString
                        (ref XKeyEvent xevent, IntPtr buffer, @X_int@ 
bytes_buffer,
                         ref KeySym keysym_return, IntPtr status_in_out);

        [DllImport("X11")]
        extern public static KeySym XLookupKeysym
                        (ref XKeyEvent xevent, int index);

        [DllImport("X11")]
        extern public static @X_int@ XGetPointerMapping
                        (IntPtr display, byte[] map_return, @X_int@ nmap);

        // Declare atom-related external functions.

        [DllImport("X11")]
        extern public static Atom XInternAtom
                        (IntPtr display, String name, Bool only_if_exists);

        // Declare font-related external functions.

        [DllImport("X11")]
        extern public static void XFreeFontSet(IntPtr display, IntPtr fontSet);

} // class Xlib

} // namespace Xsharp

--- NEW FILE ---
<?xml version="1.0"?>
<project name="pnetlib Xsharp" default="all">
        <target name="all">

                <!-- Build the Xsharp.dll library -->
                <compile output="Xsharp.dll"
                                 target="library"
                                 unsafe="true"
                                 optimize="true"
                                 debug="${CONFIG_DEBUG_LINES}"
                                 sanewarnings="true">

                        <!-- We add Xlib.cs to the list carefully because it may
                             live in the build directory instead of the source 
-->
                        <sources>
                                <includes name="**/*.cs"/>
                                <excludes name="Xlib.cs"/>
                                <file name="Xlib.cs" 
basedir="${csant.build.dir}"/>
                        </sources>

                        <references>
                                <file name="../runtime/mscorlib.dll"/>
                        </references>

<!--
                        <resources>
                                <file 
name="../resources/${pnet.language}/Xsharp/Xsharp.resources"/>
                        </resources>
-->

                </compile>

        </target>
</project>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]