From b2197ff21258cc48fc6ab93a9d90149fb899f8fa Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Wed, 12 Aug 2015 13:43:26 +0200
Subject: Fixed crashes with windows

---
 Linux_C_12/cCrossCall_121.c |   13 +-
 Linux_C_12/cpicture_121.c   | 1189 ++++++++++++++++++++++---------------------
 2 files changed, 603 insertions(+), 599 deletions(-)

(limited to 'Linux_C_12')

diff --git a/Linux_C_12/cCrossCall_121.c b/Linux_C_12/cCrossCall_121.c
index 83b1fa4..56b74e4 100644
--- a/Linux_C_12/cCrossCall_121.c
+++ b/Linux_C_12/cCrossCall_121.c
@@ -303,11 +303,6 @@ void WinKickOsThread (int64_t imess,
                       OS *oos
 					 )
 {
-#ifdef PRINTCROSSCALLS
-        rprintf("WinKickOsThread (");
-        printCCI (&gCci);
-        rprintf(")\n");
-#endif
 	gCci.mess = imess;
 	gCci.p1 = ip1;
 	gCci.p2 = ip2;
@@ -315,6 +310,14 @@ void WinKickOsThread (int64_t imess,
 	gCci.p4 = ip4;
 	gCci.p5 = ip5;
 	gCci.p6 = ip6;
+#ifdef PRINTCROSSCALLS
+	rprintf("WinKickOsThread (");
+	printCCI (&gCci);
+	printf(" - data: %p, %p, %p, %p, %p, %p, %p\n",
+		   gCci.p1, gCci.p2, gCci.p3, gCci.p4,
+		   gCci.p5, gCci.p6, ios);
+	rprintf(")\n");
+#endif
 
 	if (gOSThread != FALSE)
 	{
diff --git a/Linux_C_12/cpicture_121.c b/Linux_C_12/cpicture_121.c
index 08ccf5e..bc95fbf 100644
--- a/Linux_C_12/cpicture_121.c
+++ b/Linux_C_12/cpicture_121.c
@@ -1,12 +1,12 @@
 /********************************************************************************************
-	Clean OS Windows library module version 1.2.1.
-	This module is part of the Clean Object I/O library, version 1.2.1,
-	for the Windows platform.
+    Clean OS Windows library module version 1.2.1.
+    This module is part of the Clean Object I/O library, version 1.2.1,
+    for the Windows platform.
 ********************************************************************************************/
 
 /********************************************************************************************
-	About this module:
-	Routines related to drawing.
+    About this module:
+    Routines related to drawing.
 ********************************************************************************************/
 #include "util_121.h"
 #include <pango/pango.h>
@@ -21,35 +21,35 @@ const gchar* PEN_POS_KEY = "current-pen-position";
 
 void WinGetDC (GtkWidget *widget, OS ios, GdkDrawable **outDraw, OS *oos)
 {
-	GdkWindow *window;
+    GdkWindow *window;
     printf("WinGetDC\n");
-	window = GTK_BIN(GTK_BIN(widget)->child)->child->window;
+    window = GTK_BIN(GTK_BIN(widget)->child)->child->window;
 
-	gdk_window_ref(window);
-	*outDraw = GDK_DRAWABLE(window);
+    gdk_window_ref(window);
+    *outDraw = GDK_DRAWABLE(window);
     *oos = ios;
 }	/* WinGetDC */
 
 OS WinReleaseDC(GtkWidget *widget, GdkDrawable *drawable, OS ios)
 {
     printf("WinReleaseDC\n");
-	gdk_window_unref(GDK_WINDOW(drawable));
-	return ios;
+    gdk_window_unref(GDK_WINDOW(drawable));
+    return ios;
 }	/* WinReleaseDC */
 
 gint OsMMtoVPixels(double mm)
 
 {
     printf("OsMMtoVPixels\n");
-  	InitGTK();
-	return (int) ((mm*gdk_screen_height())/gdk_screen_height_mm());
+    InitGTK();
+    return (int) ((mm*gdk_screen_height())/gdk_screen_height_mm());
 }
 
 gint OsMMtoHPixels(double mm)
 {
     printf("OsMMtoHPixels\n");
-  	InitGTK();
-	return (int) ((mm*gdk_screen_width())/gdk_screen_width_mm());
+    InitGTK();
+    return (int) ((mm*gdk_screen_width())/gdk_screen_width_mm());
 }
 
 /*------------------------------------*\
@@ -72,74 +72,74 @@ static GdkRegion *theClipRgn = NULL;
 
 
 void WinInitPicture (gint size, gint mode, gint pr, gint pg, gint pb,
-					 gint br, gint bg, gint bb, gint x, gint y,
+                     gint br, gint bg, gint bb, gint x, gint y,
                      CLEAN_STRING fname, gint fstyle, gint fsize,
                      gint ox, gint oy, GdkDrawable *inDraw, OS os,
-					 GdkDrawable **outDraw, OS *oos)
+                     GdkDrawable **outDraw, OS *oos)
 {
     printf("WinInitPicture\n");
-	penColor.pixel = 0;
-	penColor.red   = pr*257;
-	penColor.green = pg*257;
-	penColor.blue  = pb*257;
+    penColor.pixel = 0;
+    penColor.red   = pr*257;
+    penColor.green = pg*257;
+    penColor.blue  = pb*257;
 
-	backColor.pixel = 0;
-	backColor.red   = br*257;
-	backColor.green = bg*257;
-	backColor.blue  = bb*257;
+    backColor.pixel = 0;
+    backColor.red   = br*257;
+    backColor.green = bg*257;
+    backColor.blue  = bb*257;
 
-	penSize = size;
-	penMode = mode;
+    penSize = size;
+    penMode = mode;
 
-	if (inDraw)
-	{
+    if (inDraw)
+    {
         printf("inDraw non-null\n");
-		gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &penColor, FALSE, FALSE);
-		gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &backColor, FALSE, FALSE);
-
-		theDrawGC = gdk_gc_new(inDraw);
-		gdk_gc_set_foreground(theDrawGC, &penColor);
-		gdk_gc_set_background(theDrawGC, &backColor);
-		gdk_gc_set_clip_origin(theDrawGC, 0, 0);
-		gdk_gc_set_line_attributes(theDrawGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-
-		theEraseGC = gdk_gc_new(inDraw);
-		gdk_gc_set_foreground(theEraseGC, &backColor);
-		gdk_gc_set_background(theEraseGC, &penColor);
-		gdk_gc_set_clip_origin(theEraseGC, 0, 0);
-		gdk_gc_set_line_attributes(theEraseGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-
-		theInvertGC = gdk_gc_new(inDraw);
-		gdk_gc_set_foreground(theInvertGC, &penColor);
-		gdk_gc_set_background(theInvertGC, &backColor);
-		gdk_gc_set_function(theInvertGC, GDK_INVERT);
-		gdk_gc_set_clip_origin(theInvertGC, 0, 0);
-	}
-	else
-	{
-		theDrawGC = NULL;
-		theEraseGC = NULL;
-		theInvertGC = NULL;
-	}
-
-	theFontDesc = pango_font_description_new();
-	pango_font_description_set_family(theFontDesc,cstring(fname));
-	pango_font_description_set_weight(theFontDesc,(fstyle & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-	pango_font_description_set_style(theFontDesc,(fstyle & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-	/*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
-	/*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
-	pango_font_description_set_size(theFontDesc, fsize*PANGO_SCALE);
-	theFont = gdk_font_from_description(theFontDesc);
+        gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &penColor, FALSE, FALSE);
+        gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &backColor, FALSE, FALSE);
+
+        theDrawGC = gdk_gc_new(inDraw);
+        gdk_gc_set_foreground(theDrawGC, &penColor);
+        gdk_gc_set_background(theDrawGC, &backColor);
+        gdk_gc_set_clip_origin(theDrawGC, 0, 0);
+        gdk_gc_set_line_attributes(theDrawGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+
+        theEraseGC = gdk_gc_new(inDraw);
+        gdk_gc_set_foreground(theEraseGC, &backColor);
+        gdk_gc_set_background(theEraseGC, &penColor);
+        gdk_gc_set_clip_origin(theEraseGC, 0, 0);
+        gdk_gc_set_line_attributes(theEraseGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+
+        theInvertGC = gdk_gc_new(inDraw);
+        gdk_gc_set_foreground(theInvertGC, &penColor);
+        gdk_gc_set_background(theInvertGC, &backColor);
+        gdk_gc_set_function(theInvertGC, GDK_INVERT);
+        gdk_gc_set_clip_origin(theInvertGC, 0, 0);
+    }
+    else
+    {
+        theDrawGC = NULL;
+        theEraseGC = NULL;
+        theInvertGC = NULL;
+    }
+
+    theFontDesc = pango_font_description_new();
+    pango_font_description_set_family(theFontDesc,cstring(fname));
+    pango_font_description_set_weight(theFontDesc,(fstyle & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+    pango_font_description_set_style(theFontDesc,(fstyle & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+    /*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+    /*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+    pango_font_description_set_size(theFontDesc, fsize*PANGO_SCALE);
+    theFont = gdk_font_from_description(theFontDesc);
 
     /*
-  	theClipRgn = NULL;
-  	if (clipRgn)
-  	{
-		theClipRgn = gdk_region_copy(clipRgn);
-  		if (theDrawGC)   gdk_gc_set_clip_region(theDrawGC,   theClipRgn);
-		if (theEraseGC)  gdk_gc_set_clip_region(theEraseGC,  theClipRgn);
-		if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
-	}
+    theClipRgn = NULL;
+    if (clipRgn)
+    {
+        theClipRgn = gdk_region_copy(clipRgn);
+        if (theDrawGC)   gdk_gc_set_clip_region(theDrawGC,   theClipRgn);
+        if (theEraseGC)  gdk_gc_set_clip_region(theEraseGC,  theClipRgn);
+        if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
+    }
     */
 
     /* Remember the pen position */
@@ -162,36 +162,36 @@ void WinDonePicture(GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS* oos)
     printf("WinDonePicture\n");
     inDrawIsWidget = GTK_IS_WIDGET(inDraw);
 
-	if (inDraw)
-	{
+    if (inDraw)
+    {
         printf("inDraw non-null\n");
-		gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &penColor, 1);
-		gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
-	}
-
-	if (theFont)
-	{
-		gdk_font_unref(theFont);
-		theFont = NULL;
-	}
-	if (theFontDesc)
-	{
-		pango_font_description_free(theFontDesc);
-		theFontDesc = NULL;
-	}
-
-	if (theDrawGC)   gdk_gc_unref(theDrawGC);
-	if (theEraseGC)  gdk_gc_unref(theEraseGC);
-	if (theInvertGC) gdk_gc_unref(theInvertGC);
-
-	if (theClipRgn)
-	{
-	   	gdk_region_destroy(theClipRgn);
-	   	theClipRgn = NULL;
-	}
+        gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &penColor, 1);
+        gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
+    }
+
+    if (theFont)
+    {
+        gdk_font_unref(theFont);
+        theFont = NULL;
+    }
+    if (theFontDesc)
+    {
+        pango_font_description_free(theFontDesc);
+        theFontDesc = NULL;
+    }
+
+    if (theDrawGC)   gdk_gc_unref(theDrawGC);
+    if (theEraseGC)  gdk_gc_unref(theEraseGC);
+    if (theInvertGC) gdk_gc_unref(theInvertGC);
+
+    if (theClipRgn)
+    {
+        gdk_region_destroy(theClipRgn);
+        theClipRgn = NULL;
+    }
 
     /* inDraw may not have font context */
-	*outDraw  = inDraw;
+    *outDraw  = inDraw;
     if (! inDrawIsWidget)
     {
         widget = gtk_label_new(NULL);
@@ -216,30 +216,30 @@ void WinDonePicture(GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS* oos)
 }	/* WinDonePicture */
 
 /*	PA: Set and get the clipping region of a picture:
-		WinClipRgnPicture    takes the intersection of the argument clipRgn with the current clipping region.
-		WinSetClipRgnPicture sets the argument clipRgn as the new clipping region.
-		WinGetClipRgnPicture gets the current clipping region.
+        WinClipRgnPicture    takes the intersection of the argument clipRgn with the current clipping region.
+        WinSetClipRgnPicture sets the argument clipRgn as the new clipping region.
+        WinGetClipRgnPicture gets the current clipping region.
 */
 void WinClipRgnPicture (GdkRegion *region, GdkDrawable *drawable, OS ios,
                 GdkDrawable **outDraw, OS *oos)
 {
-	GdkRectangle *rectangles;
-	gint n_rectangles, i;
+    GdkRectangle *rectangles;
+    gint n_rectangles, i;
 
     printf("WinClipRgnPicture\n");
-	if (theClipRgn != NULL)
+    if (theClipRgn != NULL)
+    {
+        gdk_region_intersect(theClipRgn, region);
+    }
+    else
     {
-		gdk_region_intersect(theClipRgn, region);
+        if (region)
+            theClipRgn = gdk_region_copy(region);
     }
-	else
-	{
-		if (region)
-			theClipRgn = gdk_region_copy(region);
-	}
 
-	if (theDrawGC)   gdk_gc_set_clip_region(theDrawGC,   theClipRgn);
-	if (theEraseGC)  gdk_gc_set_clip_region(theEraseGC,  theClipRgn);
-	if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
+    if (theDrawGC)   gdk_gc_set_clip_region(theDrawGC,   theClipRgn);
+    if (theEraseGC)  gdk_gc_set_clip_region(theEraseGC,  theClipRgn);
+    if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
 
     *outDraw = drawable;
     *oos = ios;
@@ -248,20 +248,21 @@ void WinClipRgnPicture (GdkRegion *region, GdkDrawable *drawable, OS ios,
 void WinSetClipRgnPicture (GdkRegion *region, GdkDrawable *drawable, OS ios,
                 GdkDrawable **outDraw, OS *oos)
 {
-	GdkRectangle *rectangles;
-	gint n_rectangles, i;
+    GdkRectangle *rectangles;
+    gint n_rectangles, i;
 
     printf("WinSetClipRgnPicture\n");
-	if (theClipRgn != NULL)
+    if (theClipRgn != NULL)
     {
-		gdk_region_destroy(theClipRgn);
+        gdk_region_destroy(theClipRgn);
     }
 
-	theClipRgn = region ? gdk_region_copy(region) : NULL;
+    theClipRgn = region ? gdk_region_copy(region) : NULL;
+
+    if (theDrawGC)   gdk_gc_set_clip_region(theDrawGC,   theClipRgn);
+    if (theEraseGC)  gdk_gc_set_clip_region(theEraseGC,  theClipRgn);
+    if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
 
-	if (theDrawGC)   gdk_gc_set_clip_region(theDrawGC,   theClipRgn);
-	if (theEraseGC)  gdk_gc_set_clip_region(theEraseGC,  theClipRgn);
-	if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
     *outDraw = drawable;
     *oos = ios;
 }	/* WinSetClipRgnPicture */
@@ -269,15 +270,15 @@ void WinSetClipRgnPicture (GdkRegion *region, GdkDrawable *drawable, OS ios,
 void WinGetClipRgnPicture (GdkDrawable *drawable,OS ios,
                 GdkRegion **outRegion, GdkDrawable **outDraw, OS* oos)
 {
-	GdkRegion *r = NULL;
+    GdkRegion *r = NULL;
 
     printf("WinGetClipRgnPicture\n");
-	if (theClipRgn)
-	{
-		r = gdk_region_copy(theClipRgn);
-	}
+    if (theClipRgn)
+    {
+        r = gdk_region_copy(theClipRgn);
+    }
 
-	*outRegion = r;
+    *outRegion = r;
     *outDraw = drawable;
     *oos = ios;
 }	/* WinGetClipRgnPicture */
@@ -296,8 +297,8 @@ void WinAllocPolyShape (gint size, OS ios, GdkPoint **outPoint, OS *oos)
 OS WinSetPolyPoint (gint i, gint x, gint y, GdkPoint *shape, OS os)
 {
     printf("WinSetPolyPoint\n");
-	shape[i].x = x;
-	shape[i].y = y;
+    shape[i].x = x;
+    shape[i].y = y;
 
     return (os);
 }	/* WinSetPolyPoint */
@@ -316,19 +317,19 @@ OS WinFreePolyShape (GdkPoint *shape, OS os)
 GdkRegion *WinCreateEmptyRgn()
 {
     printf("WinCreateEmptyRgn\n");
-	return gdk_region_new();
+    return gdk_region_new();
 }	/* WinCreateEmptyRgn */
 
 void WinCreateRectRgn (gint nLeftRect, gint nTopRect, gint nRightRect,
                 gint nBottomRect, OS ios, GdkRegion **rgn, OS *oos)
 {
-	GdkRectangle rectangle;
+    GdkRectangle rectangle;
     printf("WinCreateRectRgn\n");
-	rectangle.x = nLeftRect;
-	rectangle.y = nTopRect;
-	rectangle.width  = nRightRect-nLeftRect;
-	rectangle.height = nBottomRect-nTopRect;
-	*rgn = gdk_region_rectangle(&rectangle);
+    rectangle.x = nLeftRect;
+    rectangle.y = nTopRect;
+    rectangle.width  = nRightRect-nLeftRect;
+    rectangle.height = nBottomRect-nTopRect;
+    *rgn = gdk_region_rectangle(&rectangle);
     *oos = ios;
 }	/* WinCreateRectRgn */
 
@@ -336,83 +337,83 @@ void WinCreatePolygonRgn (GdkPoint *points, gint nPoints,
                 gint fnPolyFillMode, OS ios, GdkRegion **rgn, OS *oos)
 {
     printf("WinCreatePolygonRgn\n");
-	*rgn = gdk_region_polygon(points,nPoints, fnPolyFillMode == 1 ? GDK_EVEN_ODD_RULE : GDK_WINDING_RULE);
+    *rgn = gdk_region_polygon(points,nPoints, fnPolyFillMode == 1 ? GDK_EVEN_ODD_RULE : GDK_WINDING_RULE);
     *oos = ios;
 }	/* WinCreatePolygonRgn */
 
 GdkRegion *WinUnionRgn (GdkRegion *src1, GdkRegion *src2)
 {
-	GdkRegion *dst = NULL;
+    GdkRegion *dst = NULL;
     printf("WinUnionRgn\n");
 
-	if (src1)
-	{
-		dst = gdk_region_copy(src1);
-		gdk_region_union(dst, src2);
-	}
+    if (src1)
+    {
+        dst = gdk_region_copy(src1);
+        gdk_region_union(dst, src2);
+    }
 
-	return dst;
+    return dst;
 }	/* WinUnionRgn */
 
 GdkRegion *WinSectRgn (GdkRegion *src1, GdkRegion *src2)
 {
-	GdkRegion *dst = src2;
+    GdkRegion *dst = src2;
     printf("WinSectRgn\n");
 
-	if (src1)
-	{
-		dst = gdk_region_copy(src1);
-		gdk_region_intersect(dst, src2);
-	}
+    if (src1)
+    {
+        dst = gdk_region_copy(src1);
+        gdk_region_intersect(dst, src2);
+    }
 
-	return dst;
+    return dst;
 }	/* WinSectRgn */
 
 GdkRegion *WinDiffRgn (GdkRegion *src1, GdkRegion *src2)
 {
-	GdkRegion *dst = NULL;
+    GdkRegion *dst = NULL;
     printf("WinDiffRgn\n");
 
-	if (src1)
-	{
-		dst = gdk_region_copy(src1);
-		gdk_region_subtract(dst, src2);
-	};
+    if (src1)
+    {
+        dst = gdk_region_copy(src1);
+        gdk_region_subtract(dst, src2);
+    };
 
-	return dst;
+    return dst;
 }	/* WinDiffRgn */
 
 GdkRegion *WinXorRgn (GdkRegion *src1, GdkRegion *src2)
 {
-	GdkRegion *dst = NULL;
+    GdkRegion *dst = NULL;
     printf("WinXorRgn\n");
 
-	if (src1)
-	{
-		dst = gdk_region_copy(src1);
-		gdk_region_xor(dst, src2);
-	}
+    if (src1)
+    {
+        dst = gdk_region_copy(src1);
+        gdk_region_xor(dst, src2);
+    }
 
-	return dst;
+    return dst;
 }	/* WinXorRgn */
 
 void WinGetRgnBox (GdkRegion *region, OS ios, gint *left, gint *top, gint *right,
                 gint *bottom, gboolean *isrect, gboolean *isempty, OS *oos)
 {
-	GdkRegion *tempRegion;
-	GdkRectangle rectangle;
+    GdkRegion *tempRegion;
+    GdkRectangle rectangle;
     printf("WinGetRgnBox\n");
 
-	gdk_region_get_clipbox(region,&rectangle);
-	tempRegion = gdk_region_rectangle(&rectangle);
+    gdk_region_get_clipbox(region,&rectangle);
+    tempRegion = gdk_region_rectangle(&rectangle);
 
-	*left   = rectangle.x;
-	*top    = rectangle.y;
-	*right  = rectangle.x+rectangle.width;
-	*bottom = rectangle.y+rectangle.height;
-	*isrect  = gdk_region_equal(region, tempRegion);
+    *left   = rectangle.x;
+    *top    = rectangle.y;
+    *right  = rectangle.x+rectangle.width;
+    *bottom = rectangle.y+rectangle.height;
+    *isrect  = gdk_region_equal(region, tempRegion);
 
-	gdk_region_destroy(tempRegion);
+    gdk_region_destroy(tempRegion);
 
     *oos = ios;
 }	/* WinGetRgnBox */
@@ -420,13 +421,13 @@ void WinGetRgnBox (GdkRegion *region, OS ios, gint *left, gint *top, gint *right
 gboolean WinIsEmptyRgn(GdkRegion *region)
 {
     printf("WinIsEmptyRgn\n");
-	return gdk_region_empty(region);
+    return gdk_region_empty(region);
 }
 
 void WinDisposeRgn (GdkRegion *region)
 {
     printf("WinDisposeRgn\n");
-	gdk_region_destroy(region);
+    gdk_region_destroy(region);
 }
 
 /*------------------------------------*\
@@ -437,9 +438,9 @@ void WinSetPenSize (gint size, GdkDrawable *inDraw, OS ios,
                 GdkDrawable **outDraw, OS *oos)
 {
     printf("WinSetPenSize\n");
-	if (theDrawGC)  gdk_gc_set_line_attributes(theDrawGC,  size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-	if (theEraseGC) gdk_gc_set_line_attributes(theEraseGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-	penSize = size;
+    if (theDrawGC)  gdk_gc_set_line_attributes(theDrawGC,  size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+    if (theEraseGC) gdk_gc_set_line_attributes(theEraseGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+    penSize = size;
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinSetPenSize */
@@ -448,19 +449,19 @@ void WinSetPenColor (gint red, gint green, gint blue, GdkDrawable *inDraw,
                 OS ios, GdkDrawable **outDraw, OS* oos)
 {
     printf("WinSetPenColor\n");
-	if (inDraw)
-	{
-		gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
-		penColor.pixel = 0;
-		penColor.red   = red*257;
-		penColor.green = green*257;
-		penColor.blue  = blue*257;
-		gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &penColor, FALSE, FALSE);
-
-		gdk_gc_set_foreground(theDrawGC, &penColor);
-		gdk_gc_set_background(theEraseGC, &penColor);
-		gdk_gc_set_foreground(theInvertGC, &penColor);
-	}
+    if (inDraw)
+    {
+        gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
+        penColor.pixel = 0;
+        penColor.red   = red*257;
+        penColor.green = green*257;
+        penColor.blue  = blue*257;
+        gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &penColor, FALSE, FALSE);
+
+        gdk_gc_set_foreground(theDrawGC, &penColor);
+        gdk_gc_set_background(theEraseGC, &penColor);
+        gdk_gc_set_foreground(theInvertGC, &penColor);
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinSetPenColor */
@@ -469,19 +470,19 @@ void WinSetBackColor (gint red, gint green, gint blue, GdkDrawable *inDraw,
                 OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinSetBackColor\n");
-	if (inDraw)
-	{
-		gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
-		backColor.pixel = 0;
-		backColor.red   = red*257;
-		backColor.green = green*257;
-		backColor.blue  = blue*257;
-		gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &backColor, FALSE, FALSE);
-
-		gdk_gc_set_background(theDrawGC, &backColor);
-		gdk_gc_set_foreground(theEraseGC, &backColor);
-		gdk_gc_set_background(theInvertGC, &backColor);
-	}
+    if (inDraw)
+    {
+        gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
+        backColor.pixel = 0;
+        backColor.red   = red*257;
+        backColor.green = green*257;
+        backColor.blue  = blue*257;
+        gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &backColor, FALSE, FALSE);
+
+        gdk_gc_set_background(theDrawGC, &backColor);
+        gdk_gc_set_foreground(theEraseGC, &backColor);
+        gdk_gc_set_background(theInvertGC, &backColor);
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinSetBackColor */
@@ -490,27 +491,27 @@ void WinSetMode (gint mode, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
                 OS *oos)
 {
     printf("WinSetMode\n");
-	switch (mode)
-	{
-		case iModeCopy:
-			penMode = iModeCopy;
-			if (theDrawGC)   gdk_gc_set_function(theDrawGC,   GDK_COPY);
-			if (theEraseGC)  gdk_gc_set_function(theEraseGC,  GDK_COPY);
-			if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_COPY);
-			break;
-		case iModeXor:
-			penMode = iModeXor;
-			if (theDrawGC)   gdk_gc_set_function(theDrawGC,   GDK_XOR);
-			if (theEraseGC)  gdk_gc_set_function(theEraseGC,  GDK_XOR);
-			if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_XOR);
-			break;
-		case iModeOr:
-		default:
-			if (theDrawGC)   gdk_gc_set_function(theDrawGC,   GDK_OR);
-			if (theEraseGC)  gdk_gc_set_function(theEraseGC,  GDK_OR);
-			if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_OR);
-			break;
-	}
+    switch (mode)
+    {
+        case iModeCopy:
+            penMode = iModeCopy;
+            if (theDrawGC)   gdk_gc_set_function(theDrawGC,   GDK_COPY);
+            if (theEraseGC)  gdk_gc_set_function(theEraseGC,  GDK_COPY);
+            if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_COPY);
+            break;
+        case iModeXor:
+            penMode = iModeXor;
+            if (theDrawGC)   gdk_gc_set_function(theDrawGC,   GDK_XOR);
+            if (theEraseGC)  gdk_gc_set_function(theEraseGC,  GDK_XOR);
+            if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_XOR);
+            break;
+        case iModeOr:
+        default:
+            if (theDrawGC)   gdk_gc_set_function(theDrawGC,   GDK_OR);
+            if (theEraseGC)  gdk_gc_set_function(theEraseGC,  GDK_OR);
+            if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_OR);
+            break;
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinSetMode */
@@ -529,7 +530,7 @@ void WinDrawPoint (gint x, gint y, GdkDrawable *inDraw, OS ios,
                 GdkDrawable **outDraw, OS *oos)
 {
     printf("WinDrawPoint\n");
-	if (inDraw) gdk_draw_point(inDraw, theDrawGC, x, y);
+    if (inDraw) gdk_draw_point(inDraw, theDrawGC, x, y);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawPoint */
@@ -538,7 +539,7 @@ void WinDrawLine (gint startx, gint starty, gint endx, gint endy,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinDrawLine\n");
-	if (inDraw) gdk_draw_line(inDraw, theDrawGC, startx, starty, endx, endy);
+    if (inDraw) gdk_draw_line(inDraw, theDrawGC, startx, starty, endx, endy);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawLine */
@@ -547,7 +548,7 @@ void WinUndrawLine (gint startx, gint starty, gint endx, gint endy,
                 GdkDrawable *inDraw)
 {
     printf("WinUndrawLine\n");
-	if (inDraw) gdk_draw_line(inDraw, theEraseGC, startx, starty, endx, endy);
+    if (inDraw) gdk_draw_line(inDraw, theEraseGC, startx, starty, endx, endy);
 }	/* WinDrawLine */
 
 static gfloat PI = 3.1415926535897932384626433832795;
@@ -563,26 +564,26 @@ void WinDrawCurve (gint left, gint top, gint right, gint bottom, gint startradx,
     gfloat from = startradx;
     gfloat to = endradx;
     gboolean clockwise = TRUE;
-	gint cx, cy;
+    gint cx, cy;
 
     printf("WinDrawCurve\n");
-	if (inDraw)
-	{
-		cx	= x  - floor(cos(from)* abs(rx));
-		cy	= y  + floor(sin(from)* abs(ry));
-
-		from = (32*360*from)/PI;
-		to   = (32*360*to)/PI;
-
-		if (clockwise)
-			gdk_draw_arc(inDraw, theDrawGC, FALSE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(from-PI/2),floor(from-to));
-		else
-			gdk_draw_arc(inDraw, theDrawGC, FALSE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(to-PI/2),floor(to-from));
-	}
+    if (inDraw)
+    {
+        cx	= x  - floor(cos(from)* abs(rx));
+        cy	= y  + floor(sin(from)* abs(ry));
+
+        from = (32*360*from)/PI;
+        to   = (32*360*to)/PI;
+
+        if (clockwise)
+            gdk_draw_arc(inDraw, theDrawGC, FALSE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(from-PI/2),floor(from-to));
+        else
+            gdk_draw_arc(inDraw, theDrawGC, FALSE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(to-PI/2),floor(to-from));
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawCurve */
@@ -590,26 +591,26 @@ void WinDrawCurve (gint left, gint top, gint right, gint bottom, gint startradx,
 void WinUndrawCurve(gint x, gint y, gint rx, gint ry, gfloat from, gfloat to,
                 gboolean clockwise,GdkDrawable *drawable)
 {
-	gint cx, cy;
+    gint cx, cy;
 
     printf("WinUndrawCurve\n");
-	if (drawable)
-	{
-		cx	= x  - floor(cos(from)* abs(rx));
-		cy	= y  + floor(sin(from)* abs(ry));
-
-		from = (32*360*from)/PI;
-		to   = (32*360*to)/PI;
-
-		if (clockwise)
-			gdk_draw_arc(drawable, theEraseGC, FALSE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(from-PI/2),floor(from-to));
-		else
-			gdk_draw_arc(drawable, theEraseGC, FALSE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(to-PI/2),floor(to-from));
-	}
+    if (drawable)
+    {
+        cx	= x  - floor(cos(from)* abs(rx));
+        cy	= y  + floor(sin(from)* abs(ry));
+
+        from = (32*360*from)/PI;
+        to   = (32*360*to)/PI;
+
+        if (clockwise)
+            gdk_draw_arc(drawable, theEraseGC, FALSE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(from-PI/2),floor(from-to));
+        else
+            gdk_draw_arc(drawable, theEraseGC, FALSE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(to-PI/2),floor(to-from));
+    }
 }	/* WinDrawCurve */
 
 void WinDrawChar (gchar c, GdkDrawable *inDraw, OS ios,
@@ -619,7 +620,7 @@ void WinDrawChar (gchar c, GdkDrawable *inDraw, OS ios,
     printf("WinDrawChar\n");
 
     InternalGetPenPos(inDraw, &x, &y);
-	if (inDraw) gdk_draw_text(inDraw, theFont, theDrawGC, x, y, &c, 1);
+    if (inDraw) gdk_draw_text(inDraw, theFont, theDrawGC, x, y, &c, 1);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawChar */
@@ -627,7 +628,7 @@ void WinDrawChar (gchar c, GdkDrawable *inDraw, OS ios,
 void WinUndrawChar(gint x, gint y, gchar c, GdkDrawable *drawable)
 {
     printf("WinUndrawChar\n");
-	if (drawable) gdk_draw_text(drawable,theFont,theEraseGC,x,y,&c,1);
+    if (drawable) gdk_draw_text(drawable,theFont,theEraseGC,x,y,&c,1);
 }	/* WinDrawChar */
 
 /*void WinDrawString (int x, int y, CLEAN_STRING string, GdkDrawable *inDraw, */
@@ -652,18 +653,18 @@ void WinDrawString (CLEAN_STRING string, GdkDrawable *inDraw, OS ios,
 void WinUndrawString (gint x, gint y, gchar *string, GdkDrawable *drawable)
 {
     printf("WinUndrawString\n");
-	if (drawable) gdk_draw_string(drawable,theFont,theEraseGC,x,y,string);
+    if (drawable) gdk_draw_string(drawable,theFont,theEraseGC,x,y,string);
 }	/* WinUndrawString */
 
 void WinDrawRectangle (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinDrawRectangle\n");
-	if (inDraw)
-		gdk_draw_rectangle(inDraw, theDrawGC, FALSE,
-	                   left, top,
-	                   right-left-1,
-	                   bot-top-1);
+    if (inDraw)
+        gdk_draw_rectangle(inDraw, theDrawGC, FALSE,
+                       left, top,
+                       right-left-1,
+                       bot-top-1);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawRectangle */
@@ -672,12 +673,12 @@ void WinUndrawRectangle (gint left, gint top, gint right, gint bot,
                 GdkDrawable *drawable)
 {
     printf("WinUndrawRectangle\n");
-	if (drawable)
+    if (drawable)
     {
-		gdk_draw_rectangle(drawable, theEraseGC, FALSE,
-	                   left, top,
-	                   right-left-1,
-	                   bot-top-1);
+        gdk_draw_rectangle(drawable, theEraseGC, FALSE,
+                       left, top,
+                       right-left-1,
+                       bot-top-1);
     }
 }	/* WinDrawRectangle */
 
@@ -685,12 +686,12 @@ void WinFillRectangle (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinFillRectangle\n");
-	if (inDraw)
+    if (inDraw)
     {
-		gdk_draw_rectangle(inDraw, theDrawGC, TRUE,
-	                   left, top,
-	                   right-left,
-	                   bot-top);
+        gdk_draw_rectangle(inDraw, theDrawGC, TRUE,
+                       left, top,
+                       right-left,
+                       bot-top);
     }
     *outDraw = inDraw;
     *oos = ios;
@@ -700,12 +701,12 @@ void WinEraseRectangle (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinEraseRectangle\n");
-	if (inDraw)
+    if (inDraw)
     {
-		gdk_draw_rectangle(inDraw, theEraseGC, TRUE,
-					   left, top,
-					   right-left,
-	                   bot-top);
+        gdk_draw_rectangle(inDraw, theEraseGC, TRUE,
+                       left, top,
+                       right-left,
+                       bot-top);
     }
     *outDraw = inDraw;
     *oos = ios;
@@ -715,12 +716,12 @@ void WinInvertRectangle (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinInvertRectangle\n");
-	if (inDraw)
+    if (inDraw)
     {
-		gdk_draw_rectangle(inDraw, theInvertGC, TRUE,
-					   left, top,
-					   right-left,
-	                   bot-top);
+        gdk_draw_rectangle(inDraw, theInvertGC, TRUE,
+                       left, top,
+                       right-left,
+                       bot-top);
     }
     *outDraw = inDraw;
     *oos = ios;
@@ -730,8 +731,8 @@ void WinMoveRectangleTo (gint left, gint top, gint right, gint bot, gint x,
                 gint y, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
                 OS *oos)
 {
-	printf("WinMoveRectangleTo is not implemented\n");
-	WinMoveRectangle (left,top, right,bot, x-left, y-top, inDraw,ios,
+    printf("WinMoveRectangleTo is not implemented\n");
+    WinMoveRectangle (left,top, right,bot, x-left, y-top, inDraw,ios,
                     outDraw,oos);
 }	/* WinMoveRectangleTo */
 
@@ -739,46 +740,46 @@ void WinMoveRectangle (gint left, gint top, gint right, gint bot, gint dx,
                 gint dy, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
                 OS *oos)
 {
-	printf("WinMoveRectangle is not implemented\n");
+    printf("WinMoveRectangle is not implemented\n");
 /*	int w, h;
-	HWND hwnd;
+    HWND hwnd;
 
-	hwnd = WindowFromDC (ihdc);
-	if (hwnd != NULL)
-	{
-		RECT r;
-		POINT p;
-
-		GetClientRect (hwnd, &r);
-		GetWindowOrgEx (ihdc, &p);
-		left = max (left, r.left + p.x);
-		top = max (top, r.top + p.y);
-		right = min (right, r.right + p.x);
-		bot = min (bot, r.bottom + p.y);
-	}
+    hwnd = WindowFromDC (ihdc);
+    if (hwnd != NULL)
+    {
+        RECT r;
+        POINT p;
+
+        GetClientRect (hwnd, &r);
+        GetWindowOrgEx (ihdc, &p);
+        left = max (left, r.left + p.x);
+        top = max (top, r.top + p.y);
+        right = min (right, r.right + p.x);
+        bot = min (bot, r.bottom + p.y);
+    }
 
-	w = right - left;
-	h = bot - top;
+    w = right - left;
+    h = bot - top;
 
-	WinCopyRectangle (left, top, right, bot, dx, dy, ihdc);
+    WinCopyRectangle (left, top, right, bot, dx, dy, ihdc);
 
 //	StartErasing (ihdc);
 
-	if (dx > w || dy > h)
-	{
-		Rectangle (ihdc, left, top, right + 1, bot + 1);
-		return;
-	}
-
-	if (dx < 0)
-		Rectangle (ihdc, right - dx, top, right + 1, bot + 1);
-	else
-		Rectangle (ihdc, left, top, left + dx + 1, bot + 1);
-
-	if (dy < 0)
-		Rectangle (ihdc, left, bot - dy, right + 1, bot + 1);
-	else
-		Rectangle (ihdc, left, top, right + 1, top + dy + 1);*/
+    if (dx > w || dy > h)
+    {
+        Rectangle (ihdc, left, top, right + 1, bot + 1);
+        return;
+    }
+
+    if (dx < 0)
+        Rectangle (ihdc, right - dx, top, right + 1, bot + 1);
+    else
+        Rectangle (ihdc, left, top, left + dx + 1, bot + 1);
+
+    if (dy < 0)
+        Rectangle (ihdc, left, bot - dy, right + 1, bot + 1);
+    else
+        Rectangle (ihdc, left, top, right + 1, top + dy + 1);*/
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinMoveRectangle */
@@ -788,7 +789,7 @@ void WinCopyRectangleTo (gint left, gint top, gint right, gint bot, gint x,
                 OS *oos)
 {
 /*	WinCopyRectangle (left,top, right,bot, x-left,y-top, ihdc); */
-	printf("WinCopyRectangleTo is not implemented\n");
+    printf("WinCopyRectangleTo is not implemented\n");
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinCopyRectangleTo */
@@ -799,86 +800,86 @@ void WinCopyRectangle (gint left, gint top, gint right, gint bottom, gint dx,
 {
 /*	RECT scrollRect;
 
-	scrollRect.left   = left;
-	scrollRect.top    = top;
-	scrollRect.right  = right;
-	scrollRect.bottom = bottom;
+    scrollRect.left   = left;
+    scrollRect.top    = top;
+    scrollRect.right  = right;
+    scrollRect.bottom = bottom;
 
-	if (!ScrollDC (ihdc, dx,dy, &scrollRect, &scrollRect, NULL, NULL))
-	{
-		rMessageBox (NULL,MB_APPLMODAL,"WinCopyRectangle","ScrollDC failed");
-	}*/
-	printf("WinCopyRectangle is not implemented\n");
+    if (!ScrollDC (ihdc, dx,dy, &scrollRect, &scrollRect, NULL, NULL))
+    {
+        rMessageBox (NULL,MB_APPLMODAL,"WinCopyRectangle","ScrollDC failed");
+    }*/
+    printf("WinCopyRectangle is not implemented\n");
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinCopyRectangle */
 
 /*	PA: new routine to scroll part of the content of a window.
-		It is assumed that scrolling happens in one direction only (dx<>0 && dy==0 || dx==0 && dy<>0).
-		The result rect (oleft,otop,oright,obottom) is the bounding box of the update area that
-		remains to be updated. If all are zero, then nothing needs to be updated.
+        It is assumed that scrolling happens in one direction only (dx<>0 && dy==0 || dx==0 && dy<>0).
+        The result rect (oleft,otop,oright,obottom) is the bounding box of the update area that
+        remains to be updated. If all are zero, then nothing needs to be updated.
 */
 void WinScrollRectangle (gint left, gint top, gint right, gint bottom, gint dx,
                 gint dy, GdkDrawable *inDraw, OS ios, gint *oleft, gint *otop,
                 gint *oright, gint *obottom, GdkDrawable **outDraw, OS *oos)
 {
 /*	RECT scrollRect;
-	HRGN hrgnUpdate, hrgnRect;
-
-	scrollRect.left   = left;
-	scrollRect.top    = top;
-	scrollRect.right  = right;
-	scrollRect.bottom = bottom;
-
-	if (dx<0)
-	{
-		hrgnRect   = CreateRectRgn (right+dx-1,top-1,right+1,bottom+1);
-	}
-	else if (dx>0)
-	{
-		hrgnRect   = CreateRectRgn (left-1,top-1,left+dx+1,bottom+1);
-	}
-	else if (dy<0)
-	{
-		hrgnRect   = CreateRectRgn (left-1,bottom+dy-1,right+1,bottom+1);
-	}
-	else if (dy>0)
-	{
-		hrgnRect   = CreateRectRgn (left-1,top-1,right+1,top+dy+1);
-	}
-	else
-	{
-		hrgnRect   = CreateRectRgn (0,0,0,0);
-	}
-	hrgnUpdate = CreateRectRgn (0,0,1,1);
-
-	if (!ScrollDC (ihdc, dx,dy, &scrollRect, &scrollRect, hrgnUpdate, NULL))
-	{
-		rMessageBox (NULL,MB_APPLMODAL,"WinScrollRectangle","ScrollDC failed");
-	}
-	else
-	{
-		if (CombineRgn (hrgnUpdate, hrgnUpdate, hrgnRect, RGN_DIFF) == NULLREGION)
-		{
-			*oleft   = 0;
-			*otop    = 0;
-			*oright  = 0;
-			*obottom = 0;
-		}
-		else
-		{
-			RECT box;
-			GetRgnBox (hrgnUpdate,&box);
-			*oleft   = box.left;
-			*otop    = box.top;
-			*oright  = box.right;
-			*obottom = box.bottom;
-		}
-	}
-	DeleteObject (hrgnUpdate);
-	DeleteObject (hrgnRect);
+    HRGN hrgnUpdate, hrgnRect;
+
+    scrollRect.left   = left;
+    scrollRect.top    = top;
+    scrollRect.right  = right;
+    scrollRect.bottom = bottom;
+
+    if (dx<0)
+    {
+        hrgnRect   = CreateRectRgn (right+dx-1,top-1,right+1,bottom+1);
+    }
+    else if (dx>0)
+    {
+        hrgnRect   = CreateRectRgn (left-1,top-1,left+dx+1,bottom+1);
+    }
+    else if (dy<0)
+    {
+        hrgnRect   = CreateRectRgn (left-1,bottom+dy-1,right+1,bottom+1);
+    }
+    else if (dy>0)
+    {
+        hrgnRect   = CreateRectRgn (left-1,top-1,right+1,top+dy+1);
+    }
+    else
+    {
+        hrgnRect   = CreateRectRgn (0,0,0,0);
+    }
+    hrgnUpdate = CreateRectRgn (0,0,1,1);
+
+    if (!ScrollDC (ihdc, dx,dy, &scrollRect, &scrollRect, hrgnUpdate, NULL))
+    {
+        rMessageBox (NULL,MB_APPLMODAL,"WinScrollRectangle","ScrollDC failed");
+    }
+    else
+    {
+        if (CombineRgn (hrgnUpdate, hrgnUpdate, hrgnRect, RGN_DIFF) == NULLREGION)
+        {
+            *oleft   = 0;
+            *otop    = 0;
+            *oright  = 0;
+            *obottom = 0;
+        }
+        else
+        {
+            RECT box;
+            GetRgnBox (hrgnUpdate,&box);
+            *oleft   = box.left;
+            *otop    = box.top;
+            *oright  = box.right;
+            *obottom = box.bottom;
+        }
+    }
+    DeleteObject (hrgnUpdate);
+    DeleteObject (hrgnRect);
 */
-	printf("WinScrollRectangle is not implemented\n");
+    printf("WinScrollRectangle is not implemented\n");
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinScrollRectangle */
@@ -888,7 +889,7 @@ void WinUndrawOval (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinUndrawOval\n");
-	if (inDraw) gdk_draw_arc(inDraw,theEraseGC,FALSE,left,top,right-left,bot-top,0,64*360);
+    if (inDraw) gdk_draw_arc(inDraw,theEraseGC,FALSE,left,top,right-left,bot-top,0,64*360);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawOval */
@@ -897,7 +898,7 @@ void WinDrawOval (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinDrawOval\n");
-	if (inDraw) gdk_draw_arc(inDraw,theDrawGC,FALSE,left,top,right-left,bot-top,0,64*360);
+    if (inDraw) gdk_draw_arc(inDraw,theDrawGC,FALSE,left,top,right-left,bot-top,0,64*360);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawOval */
@@ -906,7 +907,7 @@ void WinFillOval (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinFillOval\n");
-	if (inDraw) gdk_draw_arc(inDraw,theDrawGC,TRUE,left,top,right-left,bot-top,0,64*360);
+    if (inDraw) gdk_draw_arc(inDraw,theDrawGC,TRUE,left,top,right-left,bot-top,0,64*360);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinFillOval */
@@ -915,7 +916,7 @@ void WinEraseOval (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinEraseOval\n");
-	if (inDraw) gdk_draw_arc(inDraw,theEraseGC,TRUE,left,top,right-left,bot-top,0,64*360);
+    if (inDraw) gdk_draw_arc(inDraw,theEraseGC,TRUE,left,top,right-left,bot-top,0,64*360);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinEraseOval */
@@ -924,7 +925,7 @@ void WinInvertOval (gint left, gint top, gint right, gint bot,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinInvertOval\n");
-	if (inDraw) gdk_draw_arc(inDraw,theInvertGC,TRUE,left,top,right-left,bot-top,0,64*360);
+    if (inDraw) gdk_draw_arc(inDraw,theInvertGC,TRUE,left,top,right-left,bot-top,0,64*360);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinInvertOval */
@@ -934,7 +935,7 @@ void WinFillWedge (gint left, gint top, gint right, gint bottom, gint startradx,
                 gint startrady, gint endradx, gint endrady, GdkDrawable *inDraw,
                 OS ios, GdkDrawable **outDraw, OS *oos)
 {
-	gint cx, cy;
+    gint cx, cy;
     gint x = left;
     gint y = top;
     gint rx = right;
@@ -944,23 +945,23 @@ void WinFillWedge (gint left, gint top, gint right, gint bottom, gint startradx,
     gboolean clockwise = TRUE;
 
     printf("WinFillWedge\n");
-	if (inDraw)
-	{
-		cx	= x  - floor(cos(from)* abs(rx));
-		cy	= y  + floor(sin(from)* abs(ry));
-
-		from = (32*360*from)/PI;
-		to   = (32*360*to)/PI;
-
-		if (clockwise)
-			gdk_draw_arc(inDraw, theDrawGC, TRUE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(from-PI/2),floor(from-to));
-		else
-			gdk_draw_arc(inDraw, theDrawGC, TRUE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(to-PI/2),floor(to-from));
-	}
+    if (inDraw)
+    {
+        cx	= x  - floor(cos(from)* abs(rx));
+        cy	= y  + floor(sin(from)* abs(ry));
+
+        from = (32*360*from)/PI;
+        to   = (32*360*to)/PI;
+
+        if (clockwise)
+            gdk_draw_arc(inDraw, theDrawGC, TRUE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(from-PI/2),floor(from-to));
+        else
+            gdk_draw_arc(inDraw, theDrawGC, TRUE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(to-PI/2),floor(to-from));
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinFillWedge */
@@ -969,7 +970,7 @@ void WinEraseWedge (gint left, gint top, gint right, gint bottom,
                 gint startradx, gint startrady, gint endradx, gint endrady,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
-	gint cx, cy;
+    gint cx, cy;
     gint x = left;
     gint y = top;
     gint rx = right;
@@ -979,23 +980,23 @@ void WinEraseWedge (gint left, gint top, gint right, gint bottom,
     gboolean clockwise = TRUE;
 
     printf("WinEraseWedge\n");
-	if (inDraw)
-	{
-		cx	= x  - floor(cos(from)* abs(rx));
-		cy	= y  + floor(sin(from)* abs(ry));
-
-		from = (32*360*from)/PI;
-		to   = (32*360*to)/PI;
-
-		if (clockwise)
-			gdk_draw_arc(inDraw, theEraseGC, TRUE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(from-PI/2),floor(from-to));
-		else
-			gdk_draw_arc(inDraw, theEraseGC, TRUE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-					 	floor(to-PI/2),floor(to-from));
-	}
+    if (inDraw)
+    {
+        cx	= x  - floor(cos(from)* abs(rx));
+        cy	= y  + floor(sin(from)* abs(ry));
+
+        from = (32*360*from)/PI;
+        to   = (32*360*to)/PI;
+
+        if (clockwise)
+            gdk_draw_arc(inDraw, theEraseGC, TRUE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(from-PI/2),floor(from-to));
+        else
+            gdk_draw_arc(inDraw, theEraseGC, TRUE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                        floor(to-PI/2),floor(to-from));
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinEraseWedge */
@@ -1004,7 +1005,7 @@ void WinInvertWedge (gint left, gint top, gint right, gint bottom,
                 gint startradx, gint startrady, gint endradx, gint endrady,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
-	gint cx, cy;
+    gint cx, cy;
     gint x = left;
     gint y = top;
     gint rx = right;
@@ -1014,23 +1015,23 @@ void WinInvertWedge (gint left, gint top, gint right, gint bottom,
     gboolean clockwise = TRUE;
 
     printf("WinInvertWedge\n");
-	if (inDraw)
-	{
-		cx	= x  - floor(cos(from)* abs(rx));
-		cy	= y  + floor(sin(from)* abs(ry));
-
-		from = (32*360*from)/PI;
-		to   = (32*360*to)/PI;
-
-		if (clockwise)
-			gdk_draw_arc(inDraw, theInvertGC, TRUE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(from-PI/2),floor(from-to));
-		else
-			gdk_draw_arc(inDraw, theInvertGC, TRUE,
-						 cx-rx, cy-ry, 2*rx, 2*ry,
-						 floor(to-PI/2),floor(to-from));
-	}
+    if (inDraw)
+    {
+        cx	= x  - floor(cos(from)* abs(rx));
+        cy	= y  + floor(sin(from)* abs(ry));
+
+        from = (32*360*from)/PI;
+        to   = (32*360*to)/PI;
+
+        if (clockwise)
+            gdk_draw_arc(inDraw, theInvertGC, TRUE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(from-PI/2),floor(from-to));
+        else
+            gdk_draw_arc(inDraw, theInvertGC, TRUE,
+                         cx-rx, cy-ry, 2*rx, 2*ry,
+                         floor(to-PI/2),floor(to-from));
+    }
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinInvertWedge */
@@ -1039,8 +1040,8 @@ void WinInvertWedge (gint left, gint top, gint right, gint bottom,
 OS WinStartPolygon (gint size, OS ios)
 {
     printf("WinStartPolygon\n");
-	thePolygon = g_new(GdkPoint, size);
-	thePolygonIndex = 0;
+    thePolygon = g_new(GdkPoint, size);
+    thePolygonIndex = 0;
 
     return ios;
 }	/* WinStartPolygon */
@@ -1048,8 +1049,8 @@ OS WinStartPolygon (gint size, OS ios)
 OS WinEndPolygon (OS ios)
 {
     printf("WinEndPolygon\n");
-	rfree (thePolygon);
-	thePolygon = NULL;
+    rfree (thePolygon);
+    thePolygon = NULL;
 
     return ios;
 }	/* WinEndPolygon */
@@ -1057,9 +1058,9 @@ OS WinEndPolygon (OS ios)
 OS WinAddPolygonPoint (gint x, gint y, OS ios)
 {
     printf("WinAddPolygonPoint\n");
-	thePolygon[thePolygonIndex].x = x;
-	thePolygon[thePolygonIndex].y = y;
-	thePolygonIndex++;
+    thePolygon[thePolygonIndex].x = x;
+    thePolygon[thePolygonIndex].y = y;
+    thePolygonIndex++;
 
     return ios;
 }	/* WinAddPolygonPoint */
@@ -1067,7 +1068,7 @@ OS WinAddPolygonPoint (gint x, gint y, OS ios)
 void WinDrawPolygon(GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinDrawPolygon\n");
-	if (inDraw) gdk_draw_polygon(inDraw,theDrawGC,FALSE,thePolygon,thePolygonIndex);
+    if (inDraw) gdk_draw_polygon(inDraw,theDrawGC,FALSE,thePolygon,thePolygonIndex);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawPolygon */
@@ -1075,13 +1076,13 @@ void WinDrawPolygon(GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 void WinUndrawPolygon (GdkDrawable *drawable)
 {
     printf("WinUndrawPolygon\n");
-	if (drawable) gdk_draw_polygon(drawable,theEraseGC,FALSE,thePolygon,thePolygonIndex);
+    if (drawable) gdk_draw_polygon(drawable,theEraseGC,FALSE,thePolygon,thePolygonIndex);
 }	/* WinUndrawPolygon */
 
 void WinFillPolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinFillPolygon\n");
-	if (inDraw) gdk_draw_polygon(inDraw,theDrawGC,TRUE,thePolygon,thePolygonIndex);
+    if (inDraw) gdk_draw_polygon(inDraw,theDrawGC,TRUE,thePolygon,thePolygonIndex);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinFillPolygon */
@@ -1089,7 +1090,7 @@ void WinFillPolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos
 void WinErasePolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinErasePolygon\n");
-	if (inDraw) gdk_draw_polygon(inDraw,theEraseGC,TRUE,thePolygon,thePolygonIndex);
+    if (inDraw) gdk_draw_polygon(inDraw,theEraseGC,TRUE,thePolygon,thePolygonIndex);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinErasePolygon */
@@ -1097,7 +1098,7 @@ void WinErasePolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oo
 void WinInvertPolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinInvertPolygon\n");
-	if (inDraw) gdk_draw_polygon(inDraw,theInvertGC,TRUE,thePolygon,thePolygonIndex);
+    if (inDraw) gdk_draw_polygon(inDraw,theInvertGC,TRUE,thePolygon,thePolygonIndex);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinInvertPolygon */
@@ -1108,7 +1109,7 @@ void WinCreateScreenHDC(OS ios, GdkDrawable **outDraw, OS *oos)
     GdkScreen* theScreen;
     
     printf("WinCreateScreenHDC\n");
-	InitGTK();
+    InitGTK();
     theScreen = gdk_screen_get_default();
     theWindow = gdk_screen_get_root_window(theScreen);
 
@@ -1126,44 +1127,44 @@ OS WinDestroyScreenHDC (GdkDrawable *drawable, OS os)
 
 
 /*	WinDrawResizedBitmap draws a bitmap on screen. For reasons of efficiency it uses an
-	already created bitmap handle.
+    already created bitmap handle.
 */
 void WinDrawResizedBitmap (gint sourcew, gint sourceh, gint destx, gint desty,
                 gint destw, gint desth, GdkPixbuf *pixbuf, GdkDrawable *inDraw,
                 OS ios, GdkDrawable **outDraw, OS *oos)
 {
 /*	HDC compatibleDC;
-	POINT sourcesize, destsize, dest, origin;
-	HGDIOBJ prevObj;
-
-	sourcesize.x = sourcew;
-	sourcesize.y = sourceh;
-	origin.x     = 0;
-	origin.y     = 0;
-	destsize.x   = destw;
-	destsize.y   = desth;
-	dest.x       = destx;
-	dest.y       = desty;
-
-	//	Create a compatible device context
-	compatibleDC = CreateCompatibleDC (hdc);
-	if (compatibleDC == NULL)
-		rMessageBox (NULL,MB_APPLMODAL,"WinDrawResizedBitmap","CreateCompatibleDC failed");
-
-	//	Select bitmap into compatible device context
-	prevObj = SelectObject (compatibleDC, hbmp);
-	SetMapMode (compatibleDC, GetMapMode (hdc));
-	DPtoLP (hdc, &destsize, 1);
-	DPtoLP (hdc, &dest, 1);
-	DPtoLP (compatibleDC, &sourcesize, 1);
-	DPtoLP (compatibleDC, &origin, 1);
-
-	if (!StretchBlt (hdc, dest.x, dest.y, destsize.x, destsize.y, compatibleDC, origin.x, origin.y, sourcesize.x, sourcesize.y, SRCCOPY))
-		rMessageBox (NULL,MB_APPLMODAL,"WinDrawResizedBitmap","StretchBlt failed");
-
-	SelectObject (compatibleDC, prevObj);
-	DeleteDC (compatibleDC);*/
-	printf("WinDrawResizedBitmap is not implemented\n");
+    POINT sourcesize, destsize, dest, origin;
+    HGDIOBJ prevObj;
+
+    sourcesize.x = sourcew;
+    sourcesize.y = sourceh;
+    origin.x     = 0;
+    origin.y     = 0;
+    destsize.x   = destw;
+    destsize.y   = desth;
+    dest.x       = destx;
+    dest.y       = desty;
+
+    //	Create a compatible device context
+    compatibleDC = CreateCompatibleDC (hdc);
+    if (compatibleDC == NULL)
+        rMessageBox (NULL,MB_APPLMODAL,"WinDrawResizedBitmap","CreateCompatibleDC failed");
+
+    //	Select bitmap into compatible device context
+    prevObj = SelectObject (compatibleDC, hbmp);
+    SetMapMode (compatibleDC, GetMapMode (hdc));
+    DPtoLP (hdc, &destsize, 1);
+    DPtoLP (hdc, &dest, 1);
+    DPtoLP (compatibleDC, &sourcesize, 1);
+    DPtoLP (compatibleDC, &origin, 1);
+
+    if (!StretchBlt (hdc, dest.x, dest.y, destsize.x, destsize.y, compatibleDC, origin.x, origin.y, sourcesize.x, sourcesize.y, SRCCOPY))
+        rMessageBox (NULL,MB_APPLMODAL,"WinDrawResizedBitmap","StretchBlt failed");
+
+    SelectObject (compatibleDC, prevObj);
+    DeleteDC (compatibleDC);*/
+    printf("WinDrawResizedBitmap is not implemented\n");
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinDrawResizedBitmap */
@@ -1186,15 +1187,15 @@ void WinDrawBitmap (gint w, gint h, gint destx, gint desty, GdkPixbuf *pixbuf,
 void WinCreateBitmap (gint width, gchar *filename, GdkDrawable *inDraw,OS ios,
                 GdkPixbuf **bitmap, OS* oos)
 {
-	GError *err = NULL;
+    GError *err = NULL;
 
     printf("WinCreateBitmap\n");
-	InitGTK();
-	*bitmap = gdk_pixbuf_new_from_file(filename, &err);
+    InitGTK();
+    *bitmap = gdk_pixbuf_new_from_file(filename, &err);
 
-	/*
+    /*
     *pWidth  = gdk_pixbuf_get_width(pixbuf);
-	*pHeight  = gdk_pixbuf_get_height(pixbuf);
+    *pHeight  = gdk_pixbuf_get_height(pixbuf);
     */
 
     *oos = ios;
@@ -1203,27 +1204,27 @@ void WinCreateBitmap (gint width, gchar *filename, GdkDrawable *inDraw,OS ios,
 void WinDisposeBitmap (GdkPixbuf *pixbuf)
 {
     printf("WinDisposeBitmap\n");
-	gdk_pixbuf_unref(pixbuf);
+    gdk_pixbuf_unref(pixbuf);
 }
 
 
 /*-----------------------------
-	   Font stuff
+       Font stuff
   -----------------------------*/
 
 void WinSetFont (CLEAN_STRING fontName, gint style, gint size,
                 GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinSetFont\n");
-	if (theFont) gdk_font_unref(theFont);
-
-	pango_font_description_set_family(theFontDesc,cstring(fontName));
-	pango_font_description_set_weight(theFontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-	pango_font_description_set_style(theFontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-	/*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
-	/*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
-	pango_font_description_set_size(theFontDesc, size*PANGO_SCALE);
-	theFont = gdk_font_from_description(theFontDesc);
+    if (theFont) gdk_font_unref(theFont);
+
+    pango_font_description_set_family(theFontDesc,cstring(fontName));
+    pango_font_description_set_weight(theFontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+    pango_font_description_set_style(theFontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+    /*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+    /*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+    pango_font_description_set_size(theFontDesc, size*PANGO_SCALE);
+    theFont = gdk_font_from_description(theFontDesc);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinSetFont */
@@ -1234,9 +1235,9 @@ void WinGetFontInfo (CLEAN_STRING fontName, gint style, gint size,
                 gint *leading, OS* oos )
 {
     PangoContext *pc;
-	PangoFontset *fontset;
-	PangoFontMetrics *metrics;
-	PangoFontDescription *fontDesc;
+    PangoFontset *fontset;
+    PangoFontMetrics *metrics;
+    PangoFontDescription *fontDesc;
     GtkWidget *widget;
     gchar *fName;
     gboolean inDrawIsWidget;
@@ -1257,20 +1258,20 @@ void WinGetFontInfo (CLEAN_STRING fontName, gint style, gint size,
     printf("Font Name: %s\n", fName);
     pango_font_description_set_family(fontDesc,fName);
     pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-	pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-	/*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
-	/*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
-	pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
+    pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+    /*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+    /*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+    pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
 
     pango_context_set_font_description(pc, fontDesc);
     metrics = pango_context_get_metrics (pc, fontDesc,
                     pango_context_get_language(pc));
     
 
-	*ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
-	*descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
-	*maxwidth = PANGO_PIXELS(pango_font_metrics_get_approximate_char_width(metrics));
-	*leading = 2; /* FIXME */
+    *ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
+    *descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
+    *maxwidth = PANGO_PIXELS(pango_font_metrics_get_approximate_char_width(metrics));
+    *leading = 2; /* FIXME */
 
     /* Pango gets the heights a bit wrong, so fudge it. */
     *ascent = (*ascent) + 1;
@@ -1282,8 +1283,8 @@ void WinGetFontInfo (CLEAN_STRING fontName, gint style, gint size,
     {
         gtk_widget_destroy(widget);
     }
-	pango_font_metrics_unref(metrics);
-  	pango_font_description_free(fontDesc);
+    pango_font_metrics_unref(metrics);
+    pango_font_description_free(fontDesc);
     printf("Freed it.\n");
     /* Connect the input and output */
     *oos = ios;
@@ -1293,21 +1294,21 @@ void WinGetPicFontInfo (GdkDrawable *inDraw, OS ios, gint *ascent,
                 gint *descent, gint *maxwidth, gint *leading,
                 GdkDrawable **outDraw, OS *oos)
 {
-	PangoFontset *fontset;
-	PangoFontMetrics *metrics;
+    PangoFontset *fontset;
+    PangoFontMetrics *metrics;
 
     printf("WinGetPicFontInfo\n");
-	fontset = pango_font_map_load_fontset
-				(pango_ft2_font_map_for_display(),
-				 gdk_pango_context_get(),
-				 theFontDesc,
-				 pango_language_from_string("EN"));
-	metrics = pango_fontset_get_metrics(fontset);
-	*ascent = pango_font_metrics_get_ascent(metrics);
-	*descent = pango_font_metrics_get_descent(metrics);
-	*maxwidth = pango_font_metrics_get_approximate_char_width(metrics);
-	*leading = 2; /* FIXME */
-	pango_font_metrics_unref(metrics);
+    fontset = pango_font_map_load_fontset
+                (pango_ft2_font_map_for_display(),
+                 gdk_pango_context_get(),
+                 theFontDesc,
+                 pango_language_from_string("EN"));
+    metrics = pango_fontset_get_metrics(fontset);
+    *ascent = pango_font_metrics_get_ascent(metrics);
+    *descent = pango_font_metrics_get_descent(metrics);
+    *maxwidth = pango_font_metrics_get_approximate_char_width(metrics);
+    *leading = 2; /* FIXME */
+    pango_font_metrics_unref(metrics);
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinGetPicFontInfo */
@@ -1335,18 +1336,18 @@ void WinGetStringWidth (CLEAN_STRING string, CLEAN_STRING fontName, gint style,
                 gint size, gint drawablePassed, GdkDrawable *drawable, OS ios,
                 gint *width, OS *oos)
 {
-	GdkFont *font;
-	PangoFontDescription *fontDesc;
+    GdkFont *font;
+    PangoFontDescription *fontDesc;
     PangoContext *pc;
     PangoLayout *pl;
     GtkWidget *widget;
     gchar* fName;
     gboolean inDrawIsWidget;
-	gchar* cstr;
+    gchar* cstr;
     printf("WinGetStringWidth\n");
 
     fName = cstring(fontName);
-	cstr = cstring(string);
+    cstr = cstring(string);
 
     inDrawIsWidget = GTK_IS_WIDGET(drawable);
     
@@ -1365,10 +1366,10 @@ void WinGetStringWidth (CLEAN_STRING string, CLEAN_STRING fontName, gint style,
     printf("Font Name: %s\n", fName);
     pango_font_description_set_family(fontDesc,fName);
     pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-	pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-	/*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
-	/*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
-	pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
+    pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+    /*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+    /*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+    pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
 
     pango_context_set_font_description(pc, fontDesc);
     pl = pango_layout_new(pc);
@@ -1381,7 +1382,7 @@ void WinGetStringWidth (CLEAN_STRING string, CLEAN_STRING fontName, gint style,
     {
         gtk_widget_destroy(GTK_WIDGET(widget));
     }
-  	pango_font_description_free(fontDesc);
+    pango_font_description_free(fontDesc);
 
     /* HACK:  Pango seems to generate overly narrow widths based on
      * the font settings.
@@ -1397,8 +1398,8 @@ void WinGetCharWidth (gchar ch, CLEAN_STRING fontName, gint style, gint size,
                 gint drawablePassed, GdkDrawable *drawable, OS ios, gint* width,
                 OS *oos)
 {
-	GdkFont *font;
-	PangoFontDescription *fontDesc;
+    GdkFont *font;
+    PangoFontDescription *fontDesc;
     PangoContext *pc;
     PangoLanguage *lang;
     PangoFontMetrics *metrics;
@@ -1420,21 +1421,21 @@ void WinGetCharWidth (gchar ch, CLEAN_STRING fontName, gint style, gint size,
     }
 
     pc = gtk_widget_get_pango_context(widget);
-	fontDesc = pango_font_description_new();
+    fontDesc = pango_font_description_new();
     printf("Font Name: %s\n", fName);
 
-	pango_font_description_set_family(fontDesc,cstring(fontName));
-	pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
-	pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-	/*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
-	/*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
-	pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
+    pango_font_description_set_family(fontDesc,cstring(fontName));
+    pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+    pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+    /*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+    /*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+    pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
     lang = pango_context_get_language(pc);
     metrics = pango_context_get_metrics(pc, fontDesc, lang);
 
     *width = pango_font_metrics_get_approximate_char_width(metrics);
 
-  	pango_font_description_free(fontDesc);
+    pango_font_description_free(fontDesc);
     pango_font_metrics_unref(metrics);
     g_object_unref(G_OBJECT(pc));
     if (! inDrawIsWidget)
@@ -1449,18 +1450,18 @@ void WinGetCharWidth (gchar ch, CLEAN_STRING fontName, gint style, gint size,
 void getResolutionC(GdkDrawable *drawable, int *xResP, int *yResP)
 {
     printf("getResolutionC\n");
-	*xResP = gdk_screen_width();
-	*yResP = gdk_screen_height();
+    *xResP = gdk_screen_width();
+    *yResP = gdk_screen_height();
 }	/* getResolutionC */
 
 void WinGetPictureScaleFactor(GdkDrawable* inDraw, OS ios, gint *nh, gint *dh,
                 gint *nv, gint *dv, GdkDrawable **outDraw, OS *oos)
 {
     printf("WinGetPictureScaleFactor\n");
-	*nh = 1;
-	*dh = 1;
-	*nv = 1;
-	*dv = 1;
+    *nh = 1;
+    *dh = 1;
+    *nv = 1;
+    *dv = 1;
     *outDraw = inDraw;
     *oos = ios;
 }	/* WinGetPictureScaleFactor */
@@ -1485,42 +1486,42 @@ void WinSerifFontDef(gchar **fname, gint *fstyle, gint *fsize)
 
 {
     printf("WinSerifFontDef\n");
-	*fname  = "times";
-	*fstyle = 0;
-	*fsize  = 10;
+    *fname  = "times";
+    *fstyle = 0;
+    *fsize  = 10;
 }
 
 void WinSansSerifFontDef(gchar **fname, gint *fstyle, gint *fsize)
 
 {
     printf("WinSansSerifFontDef\n");
-	*fname  = "helvetica";
-	*fstyle = 0;
-	*fsize  = 10;
+    *fname  = "helvetica";
+    *fstyle = 0;
+    *fsize  = 10;
 }
 
 void WinSmallFontDef(gchar **fname, gint *fstyle, gint *fsize)
 {
     printf("WinSmallFontDef\n");
-	*fname  = "helvetica";
-	*fstyle = 0;
-	*fsize  = 7;
+    *fname  = "helvetica";
+    *fstyle = 0;
+    *fsize  = 7;
 }
 
 void WinNonProportionalFontDef(gchar **fname, gint *fstyle, gint *fsize)
 {
     printf("WinNonProportionalFontDef\n");
-	*fname  = "fixed";
-	*fstyle = 0;
-	*fsize  = 10;
+    *fname  = "fixed";
+    *fstyle = 0;
+    *fsize  = 10;
 }
 
 void WinSymbolFontDef(gchar **fname, gint *fstyle, gint *fsize)
 {
     printf("WinSymbolFontDef\n");
-	*fname  = "adobe-symbol";
-	*fstyle = 0;
-	*fsize  = 10;
+    *fname  = "adobe-symbol";
+    *fstyle = 0;
+    *fsize  = 10;
 }
 
 void WinCombineRgn (GdkRegion *dest, GdkRegion *src1, GdkRegion *src2,
@@ -1599,8 +1600,8 @@ void InternalGetPenPos (GdkDrawable *context, gint *x, gint *y)
     p = (GdkPoint*)(g_object_get_data(G_OBJECT(context), PEN_POS_KEY));
     if (p)
     {
-	    *x = p->x;
-	    *y = p->y;
+        *x = p->x;
+        *y = p->y;
         rprintf("Pen Pos: (%d, %d)\n", *x, *y);
     } else {
         rprintf("No data for current-pen-position.\n");
@@ -1766,7 +1767,7 @@ void WinDrawWedge (gint left, gint top, gint right, gint bottom, gint startradx,
                 gint startrady, gint endradx, gint endrady, GdkDrawable *inDraw,
                 OS ios, GdkDrawable **outDraw, OS *oos)
 {
-	gint cx, cy;
+    gint cx, cy;
     gint x = left;
     gint y = top;
     gint rx = right;
@@ -1802,8 +1803,8 @@ void WinSetFontSize (gint size, GdkDrawable *inDraw, OS ios,
                 GdkDrawable **outDraw, OS *oos)
 {
     printf("WinSetFontSize: %d\n", size);
-	pango_font_description_set_size(theFontDesc, size*PANGO_SCALE);
-	theFont = gdk_font_from_description(theFontDesc);
+    pango_font_description_set_size(theFontDesc, size*PANGO_SCALE);
+    theFont = gdk_font_from_description(theFontDesc);
     *outDraw = inDraw;
     *oos = ios;
 }
@@ -1812,10 +1813,10 @@ void WinSetFontStyle (gint style, GdkDrawable *inDraw, OS ios,
                 GdkDrawable **outDraw, OS *oos)
 {
     printf("WinSetFontStyle: %d\n", style);
-	pango_font_description_set_style(theFontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
-	/*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
-	/*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
-	theFont = gdk_font_from_description(theFontDesc);
+    pango_font_description_set_style(theFontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+    /*	plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+    /*	plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+    theFont = gdk_font_from_description(theFontDesc);
     *outDraw = inDraw;
     *oos = ios;
 }
-- 
cgit v1.2.3