예제 #1
0
파일: Bitmap.cs 프로젝트: ForNeVeR/pnet
 // Internal constructor that wraps a bitmap XID.
 internal Bitmap(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();
     }
 }
예제 #2
0
        // Load builtin bitmaps for a particular display.
        public BuiltinBitmaps(Display display)
        {
            IntPtr    dpy      = display.dpy;
            XDrawable 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);
            Close = Xlib.XCreateBitmapFromData
                        (dpy, drawable, close_button_bits, (uint)9, (uint)9);
            Minimize = Xlib.XCreateBitmapFromData
                           (dpy, drawable, minimize_button_bits, (uint)9, (uint)9);
            Maximize = Xlib.XCreateBitmapFromData
                           (dpy, drawable, maximize_button_bits, (uint)9, (uint)9);
            Restore = Xlib.XCreateBitmapFromData
                          (dpy, drawable, restore_button_bits, (uint)9, (uint)9);
            Help = Xlib.XCreateBitmapFromData
                       (dpy, drawable, help_button_bits, (uint)9, (uint)9);
        }
예제 #3
0
파일: Drawable.cs 프로젝트: ForNeVeR/pnet
 // Set the handle for this drawable, assuming it is a pixmap.
 internal void SetPixmapHandle(XPixmap handle)
 {
     try
     {
         dpy.Lock();
         this.handle = (XDrawable)handle;
     }
     finally
     {
         dpy.Unlock();
     }
 }
예제 #4
0
	// Set the handle for this drawable, assuming it is a pixmap.
	internal void SetPixmapHandle(XPixmap handle)
			{
				try
				{
					dpy.Lock();
					this.handle = (XDrawable)handle;
				}
				finally
				{
					dpy.Unlock();
				}
			}
예제 #5
0
파일: Image.cs 프로젝트: ForNeVeR/pnet
        /// <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);
            }
        }
예제 #6
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();
				}
			}
	// Load builtin bitmaps for a particular display.
	public BuiltinBitmaps(Display display)
			{
				IntPtr dpy = display.dpy;
				XDrawable 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);
				Close = Xlib.XCreateBitmapFromData
					(dpy, drawable, close_button_bits, (uint)9, (uint)9);
				Minimize = Xlib.XCreateBitmapFromData
					(dpy, drawable, minimize_button_bits, (uint)9, (uint)9);
				Maximize = Xlib.XCreateBitmapFromData
					(dpy, drawable, maximize_button_bits, (uint)9, (uint)9);
				Restore = Xlib.XCreateBitmapFromData
					(dpy, drawable, restore_button_bits, (uint)9, (uint)9);
				Help = Xlib.XCreateBitmapFromData
					(dpy, drawable, help_button_bits, (uint)9, (uint)9);
			}
예제 #8
0
	extern public static int XSetClipMask
			(IntPtr display, IntPtr gc, XPixmap pixmap);
예제 #9
0
	extern public static int XSetStipple
			(IntPtr display, IntPtr gc, XPixmap stipple);
예제 #10
0
	extern public static int XSetTile
			(IntPtr display, IntPtr gc, XPixmap tile);
예제 #11
0
	extern public static int XFreePixmap
			(IntPtr display, XPixmap pixmap);
예제 #12
0
	extern public static int XSetWindowBackgroundPixmap
			(IntPtr display, XWindow w, XPixmap background_pixmap);
예제 #13
0
	extern public static XCursor XCreatePixmapCursor
			(IntPtr display, XPixmap source, XPixmap mask,
			 ref XColor foreground, ref XColor background,
			 uint x, uint y);
예제 #14
0
	// Draw a caption button.  Returns the width of the button.
	private static int DrawCaptionButton
					(Graphics graphics, Rectangle rect,
					 int subtract, bool pressed, bool draw,
					 XPixmap buttonPixmap)
			{
				int buttonSize = rect.height - 4;
				int x = rect.x + rect.width - subtract - buttonSize;
				int y = rect.y + 2;
				if(draw)
				{
					if(pressed)
					{
						graphics.DrawEffect(x, y, buttonSize, buttonSize,
											Effect.CaptionButtonIndented);
						++x;
						++y;
					}
					else
					{
						graphics.DrawEffect(x, y, buttonSize, buttonSize,
											Effect.CaptionButtonRaised);
					}
					x += (buttonSize - 9) / 2;
					y += (buttonSize - 9) / 2;
					graphics.DrawBitmap(x, y, 9, 9, buttonPixmap);
				}
				return buttonSize;
			}
예제 #15
0
	// Draw a simple bitmap.
	internal void DrawBitmap(int x, int y, int width, int height,
							 XPixmap bitmap)
			{
				try
				{
					IntPtr display = Lock();
					Xlib.XSetStipple(display, gc, bitmap);
					Xlib.XSetTSOrigin(display, gc, x, y);
					Xlib.XSetForeground(display, gc,
						drawable.ToPixel
							(new Color(StandardColor.Foreground)));
					Xlib.XSetFillStyle
						(display, gc, (int)(FillStyle.FillStippled));
					Xlib.XFillRectangle(display, drawableHandle, gc,
										x, y, width, height);
					Xlib.XSetTSOrigin(display, gc, 0, 0);
					Xlib.XSetFillStyle
						(display, gc, (int)(FillStyle.FillSolid));
				}
				finally
				{
					dpy.Unlock();
				}
			}