// Constructor.  Called from the "Screen" class.
	internal RootWindow(Display dpy, Screen screen, XWindow handle)
			: base(dpy, screen, DrawableKind.Widget, null)
			{
				// Set this window's handle and add it to the handle map.
				this.handle = (XDrawable)handle;
				if(dpy.handleMap == null)
				{
					dpy.handleMap = new HandleMap();
				}
				dpy.handleMap[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;

				// Get the current state of the RESOURCE_MANAGER property.
				// We extract color theme information from it.
				resourceManager = Xlib.XInternAtom
					(dpy.dpy, "RESOURCE_MANAGER", XBool.False);
				IntPtr resptr = Xlib.XSharpGetResources(dpy.dpy, handle);
				if(resptr != IntPtr.Zero)
				{
					resources = Marshal.PtrToStringAnsi(resptr);
					Xlib.XSharpFreeResources(resptr);
				}

				// Select for property notifications so that we can
				// track changes to the RESOURCE_MANAGER property.
				SelectInput(EventMask.PropertyChangeMask);
			}
Esempio n. 2
0
	// Constructor that is called from the "Screen" class.
	internal Colormap(Display dpy, Screen screen, XColormap colormap)
			{
				this.dpy = dpy;
				this.screen = screen;
				this.colormap = colormap;
				this.cachedPixels = new Hashtable(1024); // create hash with big capacity to avoid expansions of hashtable
			}
Esempio n. 3
0
	// Constructor.
	internal Widget(Display dpy, Screen screen,
					DrawableKind kind, Widget parent)
			: base(dpy, screen, kind)
			{
				// Set the initial widget properties.
				cursor = null;
				autoMapChildren = true;
				sensitive = true;

				// Insert this widget into the widget tree under its parent.
				this.parent = parent;
				this.topChild = null;
				this.nextAbove = null;
				if(parent != null)
				{
					ancestorSensitive =
						(parent.sensitive && parent.ancestorSensitive);
					nextBelow = parent.topChild;
					if(parent.topChild != null)
					{
						parent.topChild.nextAbove = this;
					}
					parent.topChild = this;
				}
				else
				{
					ancestorSensitive = true;
					nextBelow = null;
				}
				this.eventMask = 0;
			}
	// Convert an image frame into an XImage.
	public static IntPtr FrameToXImage(Screen screen, Frame frame)
			{
				int[] fpalette;
				XPixel[] palette;
				int index, color;
				Colormap colormap = screen.DefaultColormap;

				// Create a palette to use to render the image.
				fpalette = frame.Palette;
				if(fpalette != null)
				{
					// Convert the palette within the image frame itself.
					palette = new XPixel [256];
					for(index = 0; index < 256 && index < fpalette.Length;
						++index)
					{
						color = fpalette[index];
						palette[index] = colormap.RGBToPixel
							(new Color((color >> 16) & 0xFF,
									   (color >> 8) & 0xFF, color & 0xFF));
					}
				}
				else
				{
					// We have an RGB image: use a standard palette.
					palette = colormap.GetStandardPalette();
				}

				// Convert the frame into an XImage and return it.
				return Xlib.XSharpCreateImageFromDIB
						(screen.screen, frame.Width, frame.Height,
						 frame.Stride, (int)(frame.PixelFormat),
						 frame.Data, 0, palette);
			}
	// Constructor.
	public DrawingImage(Screen screen, DotGNU.Images.Image image, int frame)
		: base(image, frame)
			{
				this.screen = screen;
				base.frame = frame;
				base.image = image;
				ImageChanged();
			}
	// Convert an image frame into an XImage bitmap.
	public static IntPtr FrameToXImageBitmap(Screen screen, Frame frame)
			{
				byte[] data = frame.Data;
				if(data == null)
				{
					return IntPtr.Zero;
				}
				return Xlib.XSharpCreateImageFromDIB
					(screen.screen, frame.Width, frame.Height,
					 frame.Stride, (int)(PixelFormat.Format1bppIndexed),
					 data, 1, null);
			}
	// Convert an image frame's mask into an XImage.  IntPtr.Zero if no mask.
	public static IntPtr MaskToXImage(Screen screen, Frame frame)
			{
				byte[] mask = frame.Mask;
				if(mask == null)
				{
					return IntPtr.Zero;
				}
				return Xlib.XSharpCreateImageFromDIB
					(screen.screen, frame.Width, frame.Height,
					 frame.MaskStride, (int)(PixelFormat.Format1bppIndexed),
					 mask, 1, null);
			}
Esempio n. 8
0
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
	/// that represents an off-screen image.</para>
	/// </summary>
	///
	/// <param name="width">
	/// <para>The width of the new image.</para>
	/// </param>
	///
	/// <param name="height">
	/// <para>The height of the new image.</para>
	/// </param>
	///
	/// <param name="hasMask">
	/// <para>Set to <see langword="null"/> if the optional mask
	/// should also be created.</para>
	/// </param>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>The <paramref name="width"/> or <paramref name="height"/>
	/// values are out of range.</para>
	/// </exception>
	public Image(int width, int height, bool hasMask)
			{
				pixmap = new Pixmap(width, height);
				screen = pixmap.screen;
				if(hasMask)
				{
					mask = new Bitmap(width, height);
				}
				else
				{
					mask = null;
				}
			}
Esempio n. 9
0
	/// <summary>
	/// <para>Construct a new clipboard, associated with a particular
	/// screen and selection name.</para>
	/// </summary>
	///
	/// <param name="screen">
	/// <para>The screen to attach the clipboard to, or <see langword="null"/>
	/// to use the default screen.</para>
	/// </param>
	///
	/// <param name="name">
	/// <para>The name of the selection to use for clipboard access.
	/// This is usually <c>PRIMARY</c> for the X selection or
	/// <c>CLIPBOARD</c> for the explicit copy/cut/paste clipboard.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>The <paramref name="name"/> parameter is
	/// <see langword="null"/>.</para>
	/// </exception>
	public Clipboard(Screen screen, String name)
			: base(TopLevelWindow.GetRoot(screen), -1, -1, 1, 1)
			{
				if(name == null)
				{
					throw new ArgumentNullException("name");
				}
				try
				{
					IntPtr display = dpy.Lock();
					this.name = Xlib.XInternAtom
						(display, name, XBool.False);
					this.targets = Xlib.XInternAtom
						(display, "TARGETS", XBool.False);
				}
				finally
				{
					dpy.Unlock();
				}
			}
Esempio n. 10
0
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
	/// that represents an off-screen image on a particular 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 image.</para>
	/// </param>
	///
	/// <param name="height">
	/// <para>The height of the new image.</para>
	/// </param>
	///
	/// <param name="image">
	/// <para>The bits that make up the image.</para>
	/// </param>
	///
	/// <param name="mask">
	/// <para>The bits that make up the mask.</para>
	/// </param>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>The <paramref name="width"/> or <paramref name="height"/>
	/// values are out of range.</para>
	/// </exception>
	public Image(Screen screen, int width, int height, byte[] image, byte[] mask)
			{
				Display dpy;
				if(screen != null)
				{
					dpy = screen.DisplayOfScreen;
				}
				else
				{
					dpy = Application.Primary.Display;
					screen = dpy.DefaultScreenOfDisplay;
				}
				this.screen = screen;
				if(width < 1 || width > 32767 ||
					height < 1 || height > 32767)
				{
					throw new XException(S._("X_InvalidBitmapSize"));
				}
				if(image == null)
				{
					throw new ArgumentNullException("bits");
				}
				if(((((width + 15) & ~15) * height) / 8) > image.Length)
				{
					throw new XException(S._("X_InvalidBitmapBits"));
				}
				try
				{
					IntPtr display = dpy.Lock();
					XDrawable drawable = (XDrawable)
						Xlib.XRootWindowOfScreen(screen.screen);
					XPixmap pixmap = Xlib.XCreateBitmapFromData
						(display, drawable, image, (uint)width, (uint)height);
					this.pixmap = new Pixmap(dpy, screen, pixmap);
				}
				finally
				{
					dpy.Unlock();
				}
				if (mask != null)
					this.mask = new Bitmap(screen, width, height, mask);
				
			}
	// Convert an XImage mask into a Bitmap object.
	public static Bitmap XImageMaskToBitmap(Screen screen, IntPtr ximage)
			{
				int width, height;
				Xlib.XSharpGetImageSize(ximage, out width, out height);
				Bitmap bitmap = new Bitmap(screen, width, height);
				Graphics graphics = new Graphics(bitmap);
				graphics.PutXImage(ximage, 0, 0, 0, 0, width, height);
				graphics.Dispose();
				return bitmap;
			}
Esempio n. 12
0
	// 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;
			}
Esempio n. 13
0
	// Internal constructor that wraps a pixmap XID.
	internal Pixmap(Display dpy, Screen screen, XPixmap pixmap)
			: base(dpy, screen, DrawableKind.Bitmap)
			{
				SetPixmapHandle(pixmap);
				try
				{
					// Get the geometry of the pixmap from the X server.
					IntPtr display = dpy.Lock();
					XWindow root_return;
					Xlib.Xint x_return, y_return;
					Xlib.Xuint width_return, height_return;
					Xlib.Xuint border_width_return, depth_return;
					Xlib.XGetGeometry
						(display, handle, out root_return,
						 out x_return, out y_return,
						 out width_return, out height_return,
						 out border_width_return, out depth_return);
					this.width = (int)width_return;
					this.height = (int)height_return;
				}
				finally
				{
					dpy.Unlock();
				}
			}
Esempio n. 14
0
	/// <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, (XDrawable)
							Xlib.XRootWindowOfScreen(screen.screen),
						 (uint)width, (uint)height,
						 (uint)Xlib.XDefaultDepthOfScreen(screen.screen)));
					this.width = width;
					this.height = height;
				}
				finally
				{
					dpy.Unlock();
				}
			}
Esempio n. 15
0
	/// <summary>
	/// <para>Create a new cursor, based on a user-supplied image frame.</para>
	/// </summary>
	///
	/// <param name="screen">
	/// <para>The screen to create the cursor for, or
	/// <see langword="null"/> for the default screen on the
	/// default display.</para>
	/// </param>
	///
	/// <param name="frame">
	/// <para>The frame defining the cursor image.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException"/>
	/// <para>Raised if <paramref name="frame"/> is
	/// <see langword="null"/>.</para>
	/// </exception>
	public Cursor(Screen screen, Frame frame)
			{
				Display dpy;
				if(frame == null)
				{
					throw new ArgumentNullException("frame");
				}
				if(screen != null)
				{
					dpy = screen.DisplayOfScreen;
				}
				else
				{
					dpy = Application.Primary.Display;
					screen = dpy.DefaultScreenOfDisplay;
				}
				if( /* irgnore pixel format! frame.PixelFormat != PixelFormat.Format1bppIndexed  || */
				   frame.Mask == null)
				{
					// The frame is not suitable for use as a cursor.
					this.type = CursorType.XC_left_ptr;
					this.source = null;
					this.mask = null;
					this.cursor = XCursor.Zero;
				}
				else
				{
					this.type = CursorType.XC_inherit_parent;
					this.cursor = XCursor.Zero;
					try
					{
						dpy.Lock();
						IntPtr pixmapXImage =
							ConvertImage.FrameToXImageBitmap(screen, frame);
						IntPtr maskXImage = ConvertImage.MaskToXImage
							(screen, frame);
						source = ConvertImage.XImageMaskToBitmap
							(screen, pixmapXImage);
						mask = ConvertImage.XImageMaskToBitmap
							(screen, maskXImage);
						Xlib.XSharpDestroyImage(pixmapXImage);
						Xlib.XSharpDestroyImage(maskXImage);
						hotspotX = frame.HotspotX;
						hotspotY = frame.HotspotY;
						if(frame.Palette != null && frame.Palette[0] == 0)
						{
							reverse = true;
						}
					}
					finally
					{
						dpy.Unlock();
					}
				}
			}
	// Convert an XImage into a Pixmap object.
	public static Pixmap XImageToPixmap(Screen screen, IntPtr ximage)
			{
				int width, height;
				Xlib.XSharpGetImageSize(ximage, out width, out height);
				Pixmap pixmap = new Pixmap(screen, width, height);
				Graphics graphics = new Graphics(pixmap);
				graphics.PutXImage(ximage, 0, 0, 0, 0, width, height);
				graphics.Dispose();
				return pixmap;
			}
Esempio n. 17
0
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
	/// that represents an off-screen image on a particular 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 image.</para>
	/// </param>
	///
	/// <param name="height">
	/// <para>The height of the new image.</para>
	/// </param>
	///
	/// <param name="hasMask">
	/// <para>Set to <see langword="null"/> if the optional mask
	/// should also be created.</para>
	/// </param>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>The <paramref name="width"/> or <paramref name="height"/>
	/// values are out of range.</para>
	/// </exception>
	public Image(Screen screen, int width, int height, bool hasMask)
			{
				pixmap = new Xsharp.Pixmap(screen, width, height);
				screen = pixmap.screen;
				if(hasMask)
				{
					mask = new Bitmap(screen, width, height);
				}
				else
				{
					mask = null;
				}
			}
		// Constructor.
		public AppGroupWidget(Display dpy, Screen screen, XAppGroup group,
							  EmbeddedApplication parent)
				: base(dpy, screen, DrawableKind.Widget, null)
				{
					embedParent = parent;
					handle = (XDrawable)group;
					dpy.handleMap[(XWindow)handle] = this;
				}
Esempio n. 19
0
	/// <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"/>, using the
	/// supplied bitmap data.</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>
	///
	/// <param name="bits">
	/// <para>The bits that make up the data.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>Raised if <paramref name="bits"/> 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, or <paramref name="bits"/> is invalid
	/// in some way.</para>
	/// </exception>
	public Bitmap(Screen screen, int width, int height, byte[] bits)
			: base(GetDisplay(screen), screen, DrawableKind.Bitmap)
			{
				if(width < 1 || width > 32767 ||
				   height < 1 || height > 32767)
				{
					throw new XException(S._("X_InvalidBitmapSize"));
				}
				if(bits == null)
				{
					throw new ArgumentNullException("bits");
				}
				if(((((width + 15) & ~15) * height) / 8) > bits.Length)
				{
					throw new XException(S._("X_InvalidBitmapBits"));
				}
				try
				{
					IntPtr display = dpy.Lock();
					XDrawable drawable = (XDrawable)
							Xlib.XRootWindowOfScreen(screen.screen);
					SetPixmapHandle(Xlib.XCreateBitmapFromData
						(display, drawable, bits, (uint)width, (uint)height));
					this.width = width;
					this.height = height;
				}
				finally
				{
					dpy.Unlock();
				}
			}
Esempio n. 20
0
	// 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 XCursor [(int)(CursorType.XC_num_glyphs)];

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

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

				// Initialize the standard window manager atoms that we use.
				wmProtocols = Xlib.XInternAtom
					(dpy, "WM_PROTOCOLS", XBool.False);
				wmDeleteWindow = Xlib.XInternAtom
					(dpy, "WM_DELETE_WINDOW", XBool.False);
				wmTakeFocus = Xlib.XInternAtom
					(dpy, "WM_TAKE_FOCUS", XBool.False);
				wmMwmHints = Xlib.XInternAtom
					(dpy, "_MOTIF_WM_HINTS", XBool.False);
				wmContextHelp = Xlib.XInternAtom
					(dpy, "_NET_WM_CONTEXT_HELP", XBool.False);
				wmState = Xlib.XInternAtom
					(dpy, "WM_STATE", XBool.False);
				wmNetState = Xlib.XInternAtom
					(dpy, "_NET_WM_STATE", XBool.False);
				wmPing = Xlib.XInternAtom
					(dpy, "_NET_WM_PING", XBool.False);
				internalBeginInvoke = Xlib.XInternAtom
					(dpy, "INTERNAL_BEGIN_INVOKE", XBool.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);
			}
	// Helper method to get the root window of a specified screen.
	internal static Widget GetRoot(Screen screen)
			{
				if(screen == null)
				{
					return Xsharp.Application.Primary
								.Display.DefaultRootWindow;
				}
				else
				{
					return screen.RootWindow;
				}
			}
	/// <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)
			: this(GetRoot(screen), name, 0, 0, width, height)
			{
				// Nothing to do here.
			}
Esempio n. 23
0
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.PopupWindow"/>
	/// instance.</para>
	/// </summary>
	///
	/// <param name="screen">
	/// <para>The screen to display the window on, or <see langword="null"/>
	/// to use the default screen of the primary display.</para>
	/// </param>
	///
	/// <param name="x">
	/// <para>The X position of the new window.</para>
	/// </param>
	///
	/// <param name="y">
	/// <para>The Y position of the new window.</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 any of the parameters are out of range.</para>
	/// </exception>
	public PopupWindow(Screen screen, int x, int y, int width, int height)
			: base(TopLevelWindow.GetRoot(screen), x, y, width, height)
			{
				// Nothing to do here.
			}
Esempio n. 24
0
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
	/// from a <see cref="T:DotGNU.Images.Frame"/> instance.</para>
	/// </summary>
	///
	/// <param name="screen">
	/// <para>The screen upon which to create the new image.</para>
	/// </param>
	///
	/// <param name="frame">
	/// <para>The frame to load the image from.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>The <paramref name="frame"/> parameter is
	/// <see langword="null"/>.</para>
	/// </exception>
	///
	/// <exception cref="T:Xsharp.XInvalidOperationException">
	/// <para>Raised if <paramref name="filename"/> could not be
	/// loaded for some reason.</para>
	/// </exception>
	public Image(Screen screen, Frame frame)
			{
				Display dpy;
				if(frame == null)
				{
					throw new ArgumentNullException("frame");
				}
				if(screen != null)
				{
					dpy = screen.DisplayOfScreen;
				}
				else
				{
					dpy = Application.Primary.Display;
					screen = dpy.DefaultScreenOfDisplay;
				}
				this.screen = screen;
				try
				{
					dpy.Lock();
					pixmapXImage = ConvertImage.FrameToXImage(screen, frame);
					maskXImage = ConvertImage.MaskToXImage(screen, frame);
				}
				finally
				{
					dpy.Unlock();
				}
			}
Esempio n. 25
0
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.Image"/> instance
	/// that represents an off-screen image that was loaded
	/// from a file.</para>
	/// </summary>
	///
	/// <param name="screen">
	/// <para>The screen upon which to create the new pixmap.</para>
	/// </param>
	///
	/// <param name="filename">
	/// <para>The file to load the image from.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>The <paramref name="filename"/> parameter is
	/// <see langword="null"/>.</para>
	/// </exception>
	///
	/// <exception cref="T:System.FormatException">
	/// <para>The image format is not recognized.</para>
	/// </exception>
	///
	/// <exception cref="T:Xsharp.XInvalidOperationException">
	/// <para>Raised if <paramref name="filename"/> could not be
	/// loaded for some reason.</para>
	/// </exception>
	public Image(Screen screen, String filename)
			{
				Display dpy;
				if(filename == null)
				{
					throw new ArgumentNullException("filename");
				}
				if(screen != null)
				{
					dpy = screen.DisplayOfScreen;
				}
				else
				{
					dpy = Application.Primary.Display;
					screen = dpy.DefaultScreenOfDisplay;
				}
				this.screen = screen;
				DotGNU.Images.Image img = new DotGNU.Images.Image();
				img.Load(filename);
				Frame frame = img.GetFrame(0);
				try
				{
					dpy.Lock();
					pixmapXImage = ConvertImage.FrameToXImage(screen, frame);
					maskXImage = ConvertImage.MaskToXImage(screen, frame);
				}
				finally
				{
					dpy.Unlock();
				}
			}
Esempio n. 26
0
	// Constructor.
	internal Drawable(Display dpy, Screen screen, DrawableKind kind)
			{
				this.dpy = dpy;
				this.screen = screen;
				this.kind = kind;
			}