--- src/win/wgraph.c.ORG	Mon Sep 07 10:09:34 2009
+++ src/win/wgraph.c	Thu Dec 03 12:08:42 2009
@@ -139,6 +139,9 @@
 #define GWOPMAX 4096
 
 
+/* shige */
+#define USEFRACFS
+#ifndef USEFRACFS
 /* bitmaps for filled boxes (ULIG) */
 /* zeros represent the foreground color and ones represent the background color */
 /* FIXME HBB 20010916: *never* extern in a C source! */
@@ -161,6 +164,7 @@
 static HBRUSH halftone_brush[halftone_num];
 static BITMAP halftone_bitdata[halftone_num];
 static HBITMAP halftone_bitmap[halftone_num];
+#endif /* !USEFFACFS */
 
 static unsigned char pattern_bitmaps[][16] = {
   {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -193,6 +197,9 @@
 
 static TBOOLEAN brushes_initialized = FALSE;
 
+#ifdef USEFRACFS
+static COLORREF thisbrushcolor = RGB(0,0,0);
+#endif
 
 /* ================================== */
 
@@ -553,6 +560,7 @@
 	if( ! brushes_initialized ) {
 		int i;
 
+#ifndef USEFRACFS
 		for(i=0; i < halftone_num; i++) {
 			halftone_bitdata[i].bmType       = 0;
 			halftone_bitdata[i].bmWidth      = 16;
@@ -564,6 +572,7 @@
 			halftone_bitmap[i] = CreateBitmapIndirect(&halftone_bitdata[i]);
 			halftone_brush[i] = CreatePatternBrush(halftone_bitmap[i]);
 		}
+#endif
 
 		for(i=0; i < pattern_num; i++) {
 			pattern_bitdata[i].bmType       = 0;
@@ -596,10 +605,12 @@
 	if( brushes_initialized ) {
 		int i;
 
+#ifndef USEFRACFS
 		for( i=0; i<halftone_num; i++ ) {
 			DeleteObject(halftone_bitmap[i]);
 			DeleteObject(halftone_brush[i]);
 		}
+#endif
 		for( i=0; i<pattern_num; i++ ) {
 			DeleteObject(pattern_bitmap[i]);
 			DeleteObject(pattern_brush[i]);
@@ -959,6 +970,9 @@
 
 		pen = cur_pen;
 		SelectObject(hdc, lpgw->colorbrush[pen]);
+#ifdef USEFRACFS
+		thisbrushcolor = lpgw->colorpen[pen].lopnColor;
+#endif
 		/* Text color is also used for pattern fill */
 		SetTextColor(hdc, cur_penstruct.lopnColor);
 	    }
@@ -991,6 +1005,11 @@
 
 	case W_boxfill:   /* ULIG */
 
+#ifdef USEFRACFS
+	  {
+	    static HBRUSH last_pm3d_brush = NULL;
+	    HBRUSH this_brush;
+#endif
 	    assert (polyi == 1);
 
 	    /* NOTE: the x and y passed with this call are the width and
@@ -1000,6 +1019,7 @@
 	    switch(fillstyle & 0x0f) {
 		case FS_SOLID:
 		case FS_TRANSPARENT_SOLID:
+#ifndef USEFRACFS
 		    /* style == 1 --> use halftone fill pattern
 		     * according to filldensity. Density is from
 		     * 0..100 percent: */
@@ -1009,6 +1029,26 @@
 		    if (idx > halftone_num - 1)
 			idx = halftone_num - 1;
 		    SelectObject(hdc, halftone_brush[idx]);
+#else
+		    {
+		      double density = (fillstyle >> 4)*0.01;
+		      int r,g,b;
+		      COLORREF c; 
+		      if (density < 0.0) density = 0.0;
+		      else if (density > 1.0) density = 1.0;
+		      r = thisbrushcolor & 0xff;
+		      g = thisbrushcolor >> 8 & 0xff;
+		      b = thisbrushcolor >> 16 & 0xff;
+		      c = RGB((int)(255 - (255 - r)*density),
+			      (int)(255 - (255 - g)*density),
+			      (int)(255 - (255 - b)*density));
+		      this_brush = CreateSolidBrush(c);
+		      SelectObject(hdc, this_brush);
+		      if (last_pm3d_brush != NULL)
+			DeleteObject(last_pm3d_brush);
+		      last_pm3d_brush = this_brush;
+		    }
+#endif /* USEFRACFS */
 		    break;
 		case FS_PATTERN:
 		case FS_TRANSPARENT_PATTERN:
@@ -1027,7 +1067,15 @@
 		case FS_EMPTY:
 		default:
 		    /* fill with background color */
+#ifndef USEFRACFS 
 		    SelectObject(hdc, halftone_brush[0]);
+#else
+		    this_brush = CreateSolidBrush(thisbrushcolor);
+		    SelectObject(hdc, this_brush);
+		    if (last_pm3d_brush != NULL)
+		      DeleteObject(last_pm3d_brush);
+		    last_pm3d_brush = this_brush;
+#endif
 		    break;
 	    }
 
@@ -1036,6 +1084,9 @@
 	    PatBlt(hdc, ppt[0].x, ppt[0].y, xdash, ydash, PATCOPY);
 	    polyi = 0;
 	    break;
+#ifdef USEFRACFS 
+	  }
+#endif
   	case W_text_angle:
  	    if (lpgw->angle != (short int)curptr->x) {
  		lpgw->angle = (short int)curptr->x;
@@ -1108,6 +1159,9 @@
 		    rgb255_color rgb255;
 		    rgb255maxcolors_from_gray(curptr->x / (double)WIN_PAL_COLORS, &rgb255);
 		    c = RGB(rgb255.r, rgb255.g, rgb255.b);
+#ifdef USEFRACFS
+		    thisbrushcolor = c;
+#endif
 		}
 		else if (curptr->y == (TC_LT << 8)) {	/* TC_LT */
 		    short pen = curptr->x;
@@ -1119,9 +1173,15 @@
 			pen += 2;
 			c = lpgw->colorpen[pen].lopnColor;
 		    }
+#ifdef USEFRACFS
+		    thisbrushcolor = c;
+#endif
 		}
 		else {					/* TC_RGB */
 		    c = RGB(curptr->y & 0xff, (curptr->x >> 8) & 0xff, curptr->x & 0xff);
+#ifdef USEFRACFS
+		    thisbrushcolor = c;
+#endif
 		}
 
 		/* Solid fill brush */
