コード例 #1
0
        /// <summary> Draw the border. </summary>
        /// <param name="display"> The display pointer, that specifies the connection to the X server. <see cref="IntPtr"/> </param>
        /// <param name="window"> The window to draw on. <see cref="IntPtr"/> </param>
        /// <param name="gc"> The graphics context to use for drawing. <see cref="IntPtr"/> </param>
        /// <param name="borderArea"> The area to draw the border on. <see cref="TRectangle"/> </param>
        /// <param name="borderWidth"> The width of the border. <see cref="System.Int32"/> </param>
        public virtual void DrawBorder(IntPtr display, IntPtr window, IntPtr gc, TRectangle borderArea, int borderWidth)
        {
            if (display == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::DrawOuterBorder () ERROR: Argument null: display");
                return;
            }
            if (window == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::DrawOuterBorder () ERROR: Argument null: window");
                return;
            }
            if (gc == IntPtr.Zero)
            {
                Console.WriteLine(CLASS_NAME + "::DrawOuterBorder () ERROR: Argument null: gc");
                return;
            }

            if (borderWidth <= 0)
            {
                return;
            }

            for (int counter = 0; counter < (int)borderWidth; counter++)
            {
                // Top: L ==> R
                X11lib.XDrawLine(display, window, gc, (X11.TInt)(borderArea.Left + counter), (X11.TInt)(borderArea.Top + counter),
                                 (X11.TInt)((int)borderArea.Right - counter - 1), (X11.TInt)(borderArea.Top + counter));
                // Right: T ==> B
                X11lib.XDrawLine(display, window, gc, (X11.TInt)((int)borderArea.Right - counter - 1), (X11.TInt)(borderArea.Top + counter),
                                 (X11.TInt)((int)borderArea.Right - counter - 1), (X11.TInt)((int)borderArea.Bottom - counter - 1));
                // Bottom: R ==> L
                X11lib.XDrawLine(display, window, gc, (X11.TInt)((int)borderArea.Right - counter - 1), (X11.TInt)((int)borderArea.Bottom - counter - 1),
                                 (X11.TInt)(borderArea.Left + counter), (X11.TInt)((int)borderArea.Bottom - counter - 1));
                // Left: B ==> T
                X11lib.XDrawLine(display, window, gc, (X11.TInt)(borderArea.Left + counter), (X11.TInt)((int)borderArea.Bottom - counter - 1),
                                 (X11.TInt)(borderArea.Left + counter), (X11.TInt)(borderArea.Top + counter));
                // Fix X11lib drawing problems (not drawn pixel at bottom right corner).
                X11lib.XDrawPoint(display, window, gc, (X11.TInt)((int)borderArea.Right - (int)counter - 1), (X11.TInt)(borderArea.Bottom - (int)counter - 1));
            }
        }