[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-libs-commits] CVS: xsharp/Xsharp/XWindows Canvas.cs,1.1.1.1,1.2
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-libs-commits] CVS: xsharp/Xsharp/XWindows Canvas.cs,1.1.1.1,1.2 Colormap.cs,1.1.1.1,1.2 InputOnlyWidget.cs,1.3,1.4 InputOutputWidget.cs,1.2,1.3 Screen.cs,1.1.1.1,1.2 StandardColor.cs,1.1.1.1,1.2 Xlib.cs.in,1.3,1.4 |
Date: |
Fri, 27 Sep 2002 08:56:50 -0400 |
Update of /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows
In directory subversions:/tmp/cvs-serv14018/Xsharp/XWindows
Modified Files:
Canvas.cs Colormap.cs InputOnlyWidget.cs InputOutputWidget.cs
Screen.cs StandardColor.cs Xlib.cs.in
Log Message:
implement background pixmaps for widgets and canvas area clears.
Index: Canvas.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/Canvas.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Canvas.cs 26 Sep 2002 10:32:41 -0000 1.1.1.1
--- Canvas.cs 27 Sep 2002 12:56:48 -0000 1.2
***************
*** 1047,1050 ****
--- 1047,1223 ----
}
+ // Clear a rectangular area within a drawable.
+ private void ClearArea(IntPtr display, int x, int y, int width, int
height)
+ {
+ InputOutputWidget widget;
+ Color bg;
+ Pixmap pixmap;
+ int tx, ty;
+ XGCValues values;
+
+ // Bail out if the area is zero-sized.
+ if(width <= 0 || height <= 0)
+ {
+ return;
+ }
+
+ // Determine the background pattern to clear
with.
+ if((widget = (drawable as InputOutputWidget))
!= null)
+ {
+ widget.GetBackgroundInfo(out bg, out
pixmap,
+
out tx, out ty);
+ }
+ else
+ {
+ bg = background;
+ pixmap = null;
+ tx = 0;
+ ty = 0;
+ }
+
+ // Save the current GC settings that we are
about to modify.
+ Xlib.XGetGCValues(display, gc,
+
(uint)(GCValueMask.GCForeground |
+
GCValueMask.GCFillStyle |
+
GCValueMask.GCTileStipXOrigin |
+
GCValueMask.GCTileStipYOrigin),
+ out values);
+
+ // Draw a filled rectangle using the background
pattern.
+ if(pixmap != null)
+ {
+ Xlib.XSetTile(display, gc,
pixmap.GetPixmapHandle());
+ Xlib.XSetTSOrigin(display, gc, tx, ty);
+ Xlib.XSetFillStyle
+ (display, gc,
(int)(XWindows.FillStyle.FillTiled));
+ }
+ else
+ {
+ Xlib.XSetForeground(display, gc,
drawable.ToPixel(bg));
+ Xlib.XSetFillStyle
+ (display, gc,
(int)(XWindows.FillStyle.FillSolid));
+ }
+ Xlib.XFillRectangle(display, drawableHandle, gc,
+ x, y, width,
height);
+
+ // Restore the previous GC settings.
+ Xlib.XSetForeground(display, gc,
values.foreground);
+ if(tile != null)
+ {
+ Xlib.XSetTile(display, gc,
tile.GetPixmapHandle());
+ }
+ else if(stipple != null)
+ {
+ Xlib.XSetStipple(display, gc,
stipple.GetPixmapHandle());
+ }
+ Xlib.XSetTSOrigin(display, gc,
values.ts_x_origin,
+
values.ts_y_origin);
+ Xlib.XSetFillStyle(display, gc,
(int)(values.fill_style));
+ }
+
+ /// <summary>
+ /// <para>Clear the entire drawable to its background color.</para>
+ /// </summary>
+ ///
+ /// <remarks>
+ /// <para>If the drawable is an input-output widget, it uses the
+ /// background color (or pixmap) of the widget, not the background
+ /// color of the canvas.</para>
+ ///
+ /// <para>If the canvas has an active clipping region, then the
+ /// cleared area will be clipped to the region.</para>
+ /// </remarks>
+ public void Clear()
+ {
+ try
+ {
+ IntPtr display = Lock();
+ ClearArea(display, 0, 0,
drawable.Width, drawable.Height);
+ }
+ finally
+ {
+ dpy.Unlock();
+ }
+ }
+
+ /// <summary>
+ /// <para>Clear a rectangular area within the drawable to
+ /// its background color.</para>
+ /// </summary>
+ ///
+ /// <param name="x">
+ /// <para>The X co-ordinate of the top-left point.</para>
+ /// </param>
+ ///
+ /// <param name="y">
+ /// <para>The Y co-ordinate of the top-left point.</para>
+ /// </param>
+ ///
+ /// <param name="width">
+ /// <para>The width of the rectangle. The pixel at
+ /// <i>x + width - 1</i> is the right-most side of the rectangle.</para>
+ /// </param>
+ ///
+ /// <param name="height">
+ /// <para>The height of the rectangle. The pixel at
+ /// <i>y + height - 1</i> is the bottom-most side of the
rectangle.</para>
+ /// </param>
+ ///
+ /// <remarks>
+ /// <para>If the drawable is an input-output widget, it uses the
+ /// background color (or pixmap) of the widget, not the background
+ /// color of the canvas.</para>
+ ///
+ /// <para>If the canvas has an active clipping region, then the
+ /// cleared area will be clipped to the region.</para>
+ /// </remarks>
+ ///
+ /// <exception cref="T:XWindows.XException">
+ /// <para>One of the co-ordinate or size values is out of range.</para>
+ /// </exception>
+ public void Clear(int x, int y, int width, int height)
+ {
+ if(x < -32768 || x > 32767 || width < 0 ||
width > 65535 ||
+ y < -32768 || y > 32767 || height < 0 ||
height > 65535)
+ {
+ throw new
XException(S._("X_RectCoordRange"));
+ }
+ try
+ {
+ IntPtr display = Lock();
+ ClearArea(display, x, y, width, height);
+ }
+ finally
+ {
+ dpy.Unlock();
+ }
+ }
+
+ /// <summary>
+ /// <para>Clear a rectangular area within the drawable to
+ /// its background color.</para>
+ /// </summary>
+ ///
+ /// <param name="rect">
+ /// <para>The rectangle to be cleared.</para>
+ /// </param>
+ ///
+ /// <remarks>
+ /// <para>If the drawable is an input-output widget, it uses the
+ /// background color (or pixmap) of the widget, not the background
+ /// color of the canvas.</para>
+ ///
+ /// <para>If the canvas has an active clipping region, then the
+ /// cleared area will be clipped to the region.</para>
+ /// </remarks>
+ ///
+ /// <exception cref="T:XWindows.XException">
+ /// <para>One of the co-ordinate or size values is out of range.</para>
+ /// </exception>
+ public void Clear(Rectangle rect)
+ {
+ Clear(rect.x, rect.y, rect.width, rect.height);
+ }
+
/// <summary>
/// <para>Draw a line between two points.</para>
***************
*** 1301,1306 ****
public void DrawRectangle(int x, int y, int width, int height)
{
! if(x < -32768 || x > 32767 || width < 0 ||
width > 65536 ||
! y < -32768 || y > 32767 || height < 0 ||
height > 65536)
{
throw new
XException(S._("X_RectCoordRange"));
--- 1474,1479 ----
public void DrawRectangle(int x, int y, int width, int height)
{
! if(x < -32768 || x > 32767 || width < 0 ||
width > 65535 ||
! y < -32768 || y > 32767 || height < 0 ||
height > 65535)
{
throw new
XException(S._("X_RectCoordRange"));
Index: Colormap.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/Colormap.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Colormap.cs 26 Sep 2002 10:32:41 -0000 1.1.1.1
--- Colormap.cs 27 Sep 2002 12:56:48 -0000 1.2
***************
*** 70,76 ****
int blue = color.Blue;
xcolor.pixel = Xlib.Pixel.Zero;
! xcolor.red = (ushort)((red << 8) | red);
! xcolor.green = (ushort)((green << 8) |
green);
! xcolor.blue = (ushort)((blue << 8) |
blue);
xcolor.flags =
(sbyte)(XColor.DoRed |
XColor.DoGreen | XColor.DoBlue);
--- 70,76 ----
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);
Index: InputOnlyWidget.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/InputOnlyWidget.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** InputOnlyWidget.cs 27 Sep 2002 07:51:11 -0000 1.3
--- InputOnlyWidget.cs 27 Sep 2002 12:56:48 -0000 1.4
***************
*** 84,87 ****
--- 84,88 ----
DrawableKind.InputOnlyWidget, parent)
{
+ bool ok = false;
try
{
***************
*** 130,139 ****
layer = 0x7FFFFFFF;
Layer = 0;
}
finally
{
! // Creation failed, so detach ourselves
from
! // the parent's widget tree.
! Detach();
}
}
--- 131,144 ----
layer = 0x7FFFFFFF;
Layer = 0;
+ ok = true;
}
finally
{
! if(!ok)
! {
! // Creation failed, so detach
ourselves from
! // the parent's widget tree.
! Detach();
! }
}
}
***************
*** 183,188 ****
ref attrs);
SetWidgetHandle(window);
!
Xlib.XSetWindowBackground(display, window,
!
ToPixel(background));
if(parent.AutoMapChildren)
{
--- 188,201 ----
ref attrs);
SetWidgetHandle(window);
! if(background.Index ==
StandardColor.Inherit)
! {
!
Xlib.XSetWindowBackgroundPixmap
! (display,
window, Xlib.Pixmap.ParentRelative);
! }
! else
! {
!
Xlib.XSetWindowBackground(display, window,
!
ToPixel(background));
! }
if(parent.AutoMapChildren)
{
Index: InputOutputWidget.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/InputOutputWidget.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** InputOutputWidget.cs 27 Sep 2002 05:54:12 -0000 1.2
--- InputOutputWidget.cs 27 Sep 2002 12:56:48 -0000 1.3
***************
*** 37,40 ****
--- 37,41 ----
private Color foreground;
private Color background;
+ private Pixmap backgroundPixmap;
private PaintEventHandler paint;
private Region exposeRegion;
***************
*** 86,93 ****
int width, int height)
: base(parent, x, y, width, height,
! new Color(StandardColor.Background), false,
false)
{
foreground = new
Color(StandardColor.Foreground);
! background = new
Color(StandardColor.Background);
}
--- 87,94 ----
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);
}
***************
*** 211,215 ****
set
{
! if(background != value)
{
try
--- 212,216 ----
set
{
! if(background != value ||
backgroundPixmap != null)
{
try
***************
*** 218,221 ****
--- 219,223 ----
Xlib.Window window =
GetWidgetHandle();
background = value;
+ backgroundPixmap = null;
Xlib.XSetWindowBackground
(display,
window, ToPixel(value));
***************
*** 236,239 ****
--- 238,309 ----
/// <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>
***************
*** 270,275 ****
IntPtr display = dpy.Lock();
Xlib.Window window = GetWidgetHandle();
! Xlib.XSetWindowBackground
! (display, window,
ToPixel(background));
if(mapped && AncestorsMapped)
{
--- 340,351 ----
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)
{
***************
*** 386,389 ****
--- 462,504 ----
region.Dispose();
}
+ }
+ }
+
+ // Get the background information for use in canvas clears.
+ internal void GetBackgroundInfo(out Color bg, out Pixmap pixmap,
+ out int
tx, out int ty)
+ {
+ if(bg.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(bg.Index == StandardColor.Pixmap)
+ {
+ bg = background;
+ pixmap = backgroundPixmap;
+ tx = 0;
+ ty = 0;
+ }
+ else
+ {
+ bg = background;
+ pixmap = null;
+ tx = 0;
+ ty = 0;
}
}
Index: Screen.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/Screen.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** Screen.cs 26 Sep 2002 10:32:43 -0000 1.1.1.1
--- Screen.cs 27 Sep 2002 12:56:48 -0000 1.2
***************
*** 308,311 ****
--- 308,316 ----
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];
}
Index: StandardColor.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/StandardColor.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** StandardColor.cs 26 Sep 2002 10:32:43 -0000 1.1.1.1
--- StandardColor.cs 27 Sep 2002 12:56:48 -0000 1.2
***************
*** 57,60 ****
--- 57,64 ----
ContentTrim,
+ // Special color values for widget backgrounds.
+ Inherit,
+ Pixmap,
+
// Must be the last color index.
Last
Index: Xlib.cs.in
===================================================================
RCS file: /cvsroot/dotgnu-libs/xsharp/Xsharp/XWindows/Xlib.cs.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Xlib.cs.in 27 Sep 2002 07:51:11 -0000 1.3
--- Xlib.cs.in 27 Sep 2002 12:56:48 -0000 1.4
***************
*** 45,49 ****
public enum Drawable : @X_ulong@ { Zero }
public enum Font : @X_ulong@ { Zero }
! public enum Pixmap : @X_ulong@ { Zero }
public enum Cursor : @X_ulong@ { Zero }
public enum Colormap : @X_ulong@ { Zero }
--- 45,49 ----
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 }
***************
*** 192,195 ****
--- 192,199 ----
[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,
***************
*** 366,369 ****
--- 370,383 ----
[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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-libs-commits] CVS: xsharp/Xsharp/XWindows Canvas.cs,1.1.1.1,1.2 Colormap.cs,1.1.1.1,1.2 InputOnlyWidget.cs,1.3,1.4 InputOutputWidget.cs,1.2,1.3 Screen.cs,1.1.1.1,1.2 StandardColor.cs,1.1.1.1,1.2 Xlib.cs.in,1.3,1.4,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-libs-commits] CVS: xsharp ChangeLog,1.6,1.7
- Next by Date:
[Dotgnu-libs-commits] CVS: xsharp/m4/make pnet_library.am,1.1.1.1,1.2 pnet_program.am,1.1.1.1,1.2
- Previous by thread:
[Dotgnu-libs-commits] CVS: xsharp ChangeLog,1.6,1.7
- Next by thread:
[Dotgnu-libs-commits] CVS: xsharp/m4/make pnet_library.am,1.1.1.1,1.2 pnet_program.am,1.1.1.1,1.2
- Index(es):