1 /************************************************************************/
2 /*									*/
3 /*  Ted, Draw ornaments: Borders and Shading.				*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"tedConfig.h"
8 
9 #   include	<stddef.h>
10 #   include	<stdio.h>
11 
12 #   include	"docDraw.h"
13 #   include	"tedApp.h"
14 #   include	"tedDraw.h"
15 #   include	"tedLayout.h"
16 #   include	<psShading.h>
17 
18 #   include	<appDebugon.h>
19 
20 /************************************************************************/
21 /*									*/
22 /*  Start drawing a border.						*/
23 /*									*/
24 /************************************************************************/
25 
tedDrawSetBorderColor(DrawingContext * dc,ScreenDrawingData * sdd,int colorNumber,int asGrid)26 static void tedDrawSetBorderColor(	DrawingContext *	dc,
27 					ScreenDrawingData *	sdd,
28 					int			colorNumber,
29 					int			asGrid )
30     {
31     if  ( asGrid )
32 	{ docDrawSetColorRgb( dc, (void *)sdd, &(sdd->sddGridColor) );	}
33     else{ docDrawSetColorNumber( dc, (void *)sdd, colorNumber );	}
34 
35     return;
36     }
37 
38 /************************************************************************/
39 /*									*/
40 /*  Draw background ornaments.						*/
41 /*									*/
42 /************************************************************************/
43 
tedDrawOrnaments(const BlockOrnaments * bo,int page,const DocumentRectangle * drOutside,const DocumentRectangle * drInside,void * through,struct DrawingContext * dc)44 int tedDrawOrnaments(	const BlockOrnaments *		bo,
45 			int				page,
46 			const DocumentRectangle *	drOutside,
47 			const DocumentRectangle *	drInside,
48 			void *				through,
49 			struct DrawingContext *		dc )
50     {
51     ScreenDrawingData *		sdd= (ScreenDrawingData *)through;
52     const LayoutContext *	lc= &(dc->dcLayoutContext);
53     const BufferDocument *	bd= lc->lcDocument;
54 
55     DocumentRectangle		drOutPixels;
56     DocumentRectangle		drInPixels;
57 
58     int				topAsGrid= 0;
59     int				leftAsGrid= 0;
60     int				rightAsGrid= 0;
61     int				bottomAsGrid= 0;
62 
63     docGetPixelRect( &drOutPixels, lc, drOutside, page );
64     drInPixels= drOutPixels;
65 
66     if  ( dc->dcClipRect						&&
67 	  ! geoIntersectRectangle( (DocumentRectangle *)0,
68 					&drOutPixels, dc->dcClipRect )	)
69 	{ return 0;	}
70 
71     docGetPixelRect( &drInPixels, lc, drInside, page );
72 
73     if  ( drOutside->drX0 < drInside->drX0	&&
74 	  drOutPixels.drX0 >= drInPixels.drX0	)
75 	{ drInPixels.drX0= drOutPixels.drX0+ 1;	}
76 
77     if  ( drOutside->drY0 < drInside->drY0	&&
78 	  drOutPixels.drY0 >= drInPixels.drY0	)
79 	{ drInPixels.drY0= drOutPixels.drY0+ 1;	}
80 
81     if  ( drOutside->drY1 > drInside->drY1	&&
82 	  drOutPixels.drY1 <= drInPixels.drY1	)
83 	{ drInPixels.drY1= drOutPixels.drY1- 1;	}
84 
85     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawTOP_GRID ) )
86 	{
87 	topAsGrid= 1;
88 	drInPixels.drY0= drOutPixels.drY0+ 1;
89 	}
90 
91     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawLEFT_GRID ) )
92 	{
93 	leftAsGrid= 1;
94 	drInPixels.drX0= drOutPixels.drX0+ 1;
95 	}
96 
97     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawRIGHT_GRID ) )
98 	{
99 	rightAsGrid= 1;
100 	drOutPixels.drX1++;
101 	}
102 
103     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawBOTTOM_GRID ) )
104 	{
105 	bottomAsGrid= 1;
106 	drOutPixels.drY1++;
107 	}
108 
109     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawTOP_BORDER )	)
110 	{
111 	if  ( drInPixels.drY0 == drOutPixels.drY0 )
112 	    { drInPixels.drY0++;	}
113 	}
114 
115     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawLEFT_BORDER ) )
116 	{
117 	if  ( drInPixels.drX0 == drOutPixels.drX0 )
118 	    { drInPixels.drX0++;	}
119 	}
120 
121     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawRIGHT_BORDER ) )
122 	{
123 	if  ( drInPixels.drX1 == drOutPixels.drX1 )
124 	    { drInPixels.drX1--;	}
125 	}
126 
127     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawBOTTOM_BORDER ) )
128 	{
129 	if  ( drInPixels.drY1 == drOutPixels.drY1 )
130 	    { drInPixels.drY1--;	}
131 	}
132 
133     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawSHADE ) )
134 	{
135 	DocumentRectangle	drShade= drInPixels;
136 
137 	if  ( ! dc->dcClipRect						||
138 	      geoIntersectRectangle( &drShade, &drInPixels,
139 						    dc->dcClipRect )	)
140 	    {
141 	    ItemShading		is= bo->boShading;
142 
143 	    int			isFilled= 0;
144 	    RGB8Color		rgb8;
145 
146 	    if  ( docGetSolidRgbShadeOfItem( &isFilled, &rgb8, bd, &is ) )
147 		{ LDEB(1);	}
148 
149 	    if  ( is.isPattern != DOCspSOLID )
150 		{
151 		int		level= 0;
152 
153 		switch( is.isPattern )
154 		    {
155 		    case PSshdHORIZ:		level= 15; break;
156 		    case PSshdVERT:		level= 15; break;
157 		    case PSshdFDIAG:		level= 15; break;
158 		    case PSshdBDIAG:		level= 15; break;
159 		    case PSshdCROSS:		level= 15; break;
160 		    case PSshdDCROSS:		level= 15; break;
161 
162 		    case PSshdDKHORIZ:	level= 30; break;
163 		    case PSshdDKVERT:		level= 30; break;
164 		    case PSshdDKFDIAG:	level= 30; break;
165 		    case PSshdDKBDIAG:	level= 30; break;
166 		    case PSshdDKCROSS:	level= 30; break;
167 		    case PSshdDKDCROSS:	level= 30; break;
168 		    }
169 
170 		if  ( bo->boShading.isForeColor == 0 )
171 		    {
172 		    if  ( bo->boShading.isBackColor == 0 )
173 			{ utilRGB8SolidBlack( &rgb8 );	}
174 
175 		    rgb8.rgb8Red= ( ( 100- level )* rgb8.rgb8Red )/ 100;
176 		    rgb8.rgb8Green= ( ( 100- level )* rgb8.rgb8Green )/ 100;
177 		    rgb8.rgb8Blue= ( ( 100- level )* rgb8.rgb8Blue )/ 100;
178 		    isFilled= 1;
179 		    }
180 		else{
181 		    is.isLevel= 100* level;
182 		    is.isPattern= DOCspSOLID;
183 
184 		    if  ( docGetSolidRgbShadeOfItem( &isFilled, &rgb8,
185 								    bd, &is ) )
186 			{ LDEB(1);	}
187 		    }
188 		}
189 
190 	    if  ( isFilled )
191 		{
192 		DocumentRectangle	drFill= drShade;
193 
194 		docDrawSetColorRgb( dc, (void *)sdd, &rgb8 );
195 
196 		geoShiftRectangle( &drFill, -lc->lcOx, -lc->lcOy );
197 		drawFillRectangle( lc->lcDrawingSurface, &drFill );
198 		}
199 	    }
200 	}
201 
202     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawTOP_BORDER )	||
203 	  PROPmaskISSET( &(bo->boPropMask), ORNdrawTOP_GRID )	)
204 	{
205 	DocumentRectangle	drBorder= drOutPixels;
206 
207 	drBorder.drY1= drInPixels.drY0;
208 	drBorder.drY1= drInPixels.drY0- 1;
209 	if  ( drBorder.drY1 < drBorder.drY0 )
210 	    { drBorder.drY1=  drBorder.drY0;	}
211 
212 	if  ( ! dc->dcClipRect						  ||
213 	      geoIntersectRectangle( &drBorder, &drBorder, dc->dcClipRect ) )
214 	    {
215 	    tedDrawSetBorderColor( dc, sdd,
216 				    bo->boTopBorder.bpColor, topAsGrid );
217 
218 	    geoShiftRectangle( &drBorder, -lc->lcOx, -lc->lcOy );
219 	    drawFillRectangle( lc->lcDrawingSurface, &drBorder );
220 	    }
221 	}
222 
223     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawLEFT_BORDER )	||
224 	  PROPmaskISSET( &(bo->boPropMask), ORNdrawLEFT_GRID )		)
225 	{
226 	DocumentRectangle	drBorder= drOutPixels;
227 
228 	drBorder.drY0= drInPixels.drY0;
229 	drBorder.drY1= drInPixels.drY1;
230 	drBorder.drX1= drInPixels.drX0- 1;
231 
232 	if  ( drBorder.drX1 < drBorder.drX0 )
233 	    { drBorder.drX1=  drBorder.drX0;	}
234 
235 	if  ( ! dc->dcClipRect						  ||
236 	      geoIntersectRectangle( &drBorder, &drBorder, dc->dcClipRect ) )
237 	    {
238 	    tedDrawSetBorderColor( dc, sdd,
239 				    bo->boLeftBorder.bpColor, leftAsGrid );
240 
241 	    geoShiftRectangle( &drBorder, -lc->lcOx, -lc->lcOy );
242 	    drawFillRectangle( lc->lcDrawingSurface, &drBorder );
243 	    }
244 	}
245 
246     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawRIGHT_BORDER )	||
247 	  PROPmaskISSET( &(bo->boPropMask), ORNdrawRIGHT_GRID )		)
248 	{
249 	DocumentRectangle	drBorder= drOutPixels;
250 
251 	drBorder.drY0= drInPixels.drY0;
252 	drBorder.drY1= drInPixels.drY1;
253 	drBorder.drX0= drInPixels.drX1+ 1;
254 
255 	if  ( drBorder.drX0 > drBorder.drX1 )
256 	    { drBorder.drX0=  drBorder.drX1;	}
257 
258 	/* Avoid overlaps with fills
259 	drBorder.drX0--;
260 	drBorder.drX1--;
261 	*/
262 
263 	if  ( ! dc->dcClipRect						  ||
264 	      geoIntersectRectangle( &drBorder, &drBorder, dc->dcClipRect ) )
265 	    {
266 	    tedDrawSetBorderColor( dc, sdd,
267 				    bo->boRightBorder.bpColor, rightAsGrid );
268 
269 	    geoShiftRectangle( &drBorder, -lc->lcOx, -lc->lcOy );
270 	    drawFillRectangle( lc->lcDrawingSurface, &drBorder );
271 	    }
272 	}
273 
274     if  ( PROPmaskISSET( &(bo->boPropMask), ORNdrawBOTTOM_BORDER )	||
275 	  PROPmaskISSET( &(bo->boPropMask), ORNdrawBOTTOM_GRID )	)
276 	{
277 	DocumentRectangle	drBorder= drOutPixels;
278 
279 	drBorder.drY0= drInPixels.drY1+ 1;
280 
281 	if  ( drBorder.drY0 > drBorder.drY1 )
282 	    { drBorder.drY0=  drBorder.drY1;	}
283 
284 	/* Avoid overlaps with fills
285 	drBorder.drY0--;
286 	drBorder.drY1--;
287 	*/
288 
289 	if  ( ! dc->dcClipRect						  ||
290 	      geoIntersectRectangle( &drBorder, &drBorder, dc->dcClipRect ) )
291 	    {
292 	    tedDrawSetBorderColor( dc, sdd,
293 				    bo->boBottomBorder.bpColor, bottomAsGrid );
294 
295 	    geoShiftRectangle( &drBorder, -lc->lcOx, -lc->lcOy );
296 	    drawFillRectangle( lc->lcDrawingSurface, &drBorder );
297 	    }
298 	}
299 
300     return 0;
301     }
302 
303 /************************************************************************/
304 /*									*/
305 /*  Draw a shaded rectangle.						*/
306 /*									*/
307 /************************************************************************/
308 
tedDrawShadedRectangle(const LayoutContext * lc,DrawingSurface shadingPixmaps[PSshd_COUNT],int pattern,const DocumentRectangle * drShade)309 void tedDrawShadedRectangle(
310 		const LayoutContext *		lc,
311 		DrawingSurface			shadingPixmaps[PSshd_COUNT],
312 		int				pattern,
313 		const DocumentRectangle *	drShade )
314     {
315     if  ( ! shadingPixmaps[pattern] )
316 	{
317 	const int		wide= 8;
318 	const int		high= 8;
319 	const int		d= 4;
320 	int			t;
321 	int			s= 0;
322 
323 	DocumentRectangle	drFill;
324 
325 	int			x;
326 	int			y;
327 
328 	shadingPixmaps[pattern]= drawMakeDrawingSurfaceForParent(
329 					lc->lcDrawingSurface, wide, high );
330 	if  ( ! shadingPixmaps[pattern] )
331 	    { XDEB(shadingPixmaps[pattern]); return;	}
332 
333 	drFill.drX0= 0;
334 	drFill.drY0= 0;
335 	drFill.drX1= wide- 1;
336 	drFill.drY1= high- 1;
337 
338 	drawSetForegroundColorWhite( shadingPixmaps[pattern] );
339 	drawFillRectangle( shadingPixmaps[pattern], &drFill );
340 
341 	drawSetForegroundColorBlack( shadingPixmaps[pattern] );
342 
343 	switch( pattern )
344 	    {
345 	    case DOCspSOLID:
346 		LDEB(pattern);
347 		t= 0; s= 0;
348 		break;
349 
350 	    case PSshdHORIZ:
351 	    case PSshdVERT:
352 	    case PSshdFDIAG:
353 	    case PSshdBDIAG:
354 	    case PSshdCROSS:
355 	    case PSshdDCROSS:
356 		t= 1; s= 0;
357 		break;
358 
359 	    case PSshdDKHORIZ:
360 	    case PSshdDKVERT:
361 	    case PSshdDKFDIAG:
362 	    case PSshdDKBDIAG:
363 	    case PSshdDKCROSS:
364 	    case PSshdDKDCROSS:
365 		t= 2; s= 1;
366 		break;
367 
368 	    default:
369 		LDEB(pattern);
370 		return;
371 	    }
372 
373 	if  ( t > 0 )
374 	    {
375 	    drawSetLineAttributes( shadingPixmaps[pattern],
376 			t, LineStyleSolid, LineCapProjecting, LineJoinMiter,
377 			(unsigned char *)0, 0 );
378 	    }
379 
380 	switch( pattern )
381 	    {
382 	    case DOCspSOLID:
383 		LDEB(pattern);
384 		break;
385 
386 	    case PSshdHORIZ:
387 	    case PSshdDKHORIZ:
388 		y= 0;
389 		while( y < high )
390 		    {
391 		    drawLine( shadingPixmaps[pattern], 0, y+ s, wide- 1, y+ s );
392 		    y += d;
393 		    }
394 		break;
395 
396 	    case PSshdVERT:
397 	    case PSshdDKVERT:
398 		x= 0;
399 		while( x < wide )
400 		    {
401 		    drawLine( shadingPixmaps[pattern], x+ s, 0, x+ s, high- 1 );
402 		    x += d;
403 		    }
404 		break;
405 
406 	    case PSshdFDIAG:
407 	    case PSshdDKFDIAG:
408 		x= -high;
409 		while( x < wide )
410 		    {
411 		    drawLine( shadingPixmaps[pattern], x+ s, 0, x+ high+ s, high );
412 		    x += d;
413 		    }
414 		break;
415 
416 	    case PSshdBDIAG:
417 	    case PSshdDKBDIAG:
418 		x= 0;
419 		while( x < wide+ high )
420 		    {
421 		    drawLine( shadingPixmaps[pattern], x, 0, x- high, high );
422 		    x += d;
423 		    }
424 		break;
425 
426 	    case PSshdCROSS:
427 	    case PSshdDKCROSS:
428 		y= 0;
429 		while( y < high )
430 		    {
431 		    drawLine( shadingPixmaps[pattern], 0, y+ s, wide- 1, y+ s );
432 		    y += d;
433 		    }
434 		x= 0;
435 		while( x < wide )
436 		    {
437 		    drawLine( shadingPixmaps[pattern], x+ s, 0, x+ s, high- 1 );
438 		    x += d;
439 		    }
440 		break;
441 
442 	    case PSshdDCROSS:
443 	    case PSshdDKDCROSS:
444 		x= -high;
445 		while( x < wide )
446 		    {
447 		    /*
448 		    drawLine( shadingPixmaps[pattern], x+ s, 0, x+ high+ s, high );
449 		    */
450 		    drawLine( shadingPixmaps[pattern], x, 0, x+ high, high );
451 		    x += d;
452 		    }
453 		x= 0;
454 		while( x < wide+ high )
455 		    {
456 		    drawLine( shadingPixmaps[pattern], x, 0, x- high, high );
457 		    x += d;
458 		    }
459 		break;
460 
461 	    default:
462 		LDEB(pattern);
463 		return;
464 	    }
465 	}
466 
467 # if 0
468 #   ifdef USE_MOTIF
469     XSetFillStyle( lc->lcAdd->addDisplay, lc->lcAdd->addGc, FillTiled );
470     XSetTile( lc->lcAdd->addDisplay, lc->lcAdd->addGc, shadingPixmaps[pattern] );
471 #   endif
472 #   ifdef USE_GTK
473     gdk_gc_set_fill( lc->lcAdd->addGc, GDK_TILED );
474     gdk_gc_set_tile( lc->lcAdd->addGc, shadingPixmaps[pattern] );
475 #   endif
476 
477     drawFillRectangle( lc->lcAdd, drShade );
478 
479 #   ifdef USE_MOTIF
480     XSetFillStyle( lc->lcAdd->addDisplay, lc->lcAdd->addGc, FillSolid );
481 #   endif
482 #   ifdef USE_GTK
483     gdk_gc_set_fill( lc->lcAdd->addGc, GDK_SOLID );
484 #   endif
485 # endif
486 
487     return;
488     }
489 
490 
491 /************************************************************************/
492 /*									*/
493 /*  Draw actual lines for a segment in a horizontal border.		*/
494 /*									*/
495 /************************************************************************/
496 
tedBorderSetLineSolid(DrawingSurface ds,int thick)497 static void tedBorderSetLineSolid(	DrawingSurface		ds,
498 					int			thick )
499     {
500     drawSetLineAttributes( ds,
501 		    thick, LineStyleSolid, LineCapButt, LineJoinMiter,
502 		    (unsigned char *)0, 0 );
503     }
504 
tedBorderSetLineDashes(DrawingSurface ds,const unsigned char * dashes,int dashCount,int thick)505 static void tedBorderSetLineDashes(	DrawingSurface		ds,
506 					const unsigned char *	dashes,
507 					int			dashCount,
508 					int			thick )
509     {
510     drawSetLineAttributes( ds,
511 		    thick, LineStyleSingleDash, LineCapButt, LineJoinMiter,
512 		    dashes, dashCount );
513     }
514 
515 static const unsigned char TED_Border_DOT[]=	{ 1, 2 };
516 static const unsigned char TED_Border_DASH[]=	{ 3, 3 };
517 static const unsigned char TED_Border_DASHSM[]=	{ 3, 1 };
518 static const unsigned char TED_Border_DASHD[]=	{ 4, 2, 2, 2 };
519 static const unsigned char TED_Border_DASHDD[]=	{ 4, 2, 2, 2, 2, 2 };
520 
tedDrawHorizontalBorderLine(DrawingSurface ds,int style,int minThick,int x0,int x1,int y)521 void tedDrawHorizontalBorderLine(	DrawingSurface		ds,
522 					int			style,
523 					int			minThick,
524 					int			x0,
525 					int			x1,
526 					int			y )
527     {
528     int		yy;
529     int		xx;
530 
531     switch( style )
532 	{
533 	case DOCbsNONE:
534 	    break;
535 
536 	case DOCbsS:
537 	    tedBorderSetLineSolid( ds, 1 );
538 	    drawLine( ds, x0, y, x1, y );
539 	    break;
540 
541 	case DOCbsTH:
542 	    tedBorderSetLineSolid( ds, 2 );
543 	    drawLine( ds, x0, y, x1, y );
544 	    break;
545 
546 	case DOCbsSH:
547 	    tedBorderSetLineSolid( ds, 2 );
548 	    drawLine( ds, x0, y, x1, y );
549 	    break;
550 
551 	case DOCbsDB:
552 	    tedBorderSetLineSolid( ds, 1 );
553 	    yy= y- 1;
554 	    drawLine( ds, x0, yy, x1, yy );
555 	    yy= y+ 1;
556 	    drawLine( ds, x0, yy, x1, yy );
557 	    break;
558 
559 	case DOCbsHAIR:
560 	    tedBorderSetLineSolid( ds, 1 );
561 	    drawLine( ds, x0, y, x1, y );
562 	    break;
563 
564 	case DOCbsDOT:
565 	    tedBorderSetLineDashes( ds,
566 			    TED_Border_DOT, sizeof( TED_Border_DOT ), 1 );
567 	    drawLine( ds, x0, y, x1, y );
568 	    break;
569 
570 	case DOCbsDASH:
571 	    tedBorderSetLineDashes( ds,
572 			    TED_Border_DASH, sizeof( TED_Border_DASH ), 1 );
573 	    drawLine( ds, x0, y, x1, y );
574 	    break;
575 
576 	case DOCbsDASHD:
577 	    tedBorderSetLineDashes( ds,
578 			TED_Border_DASHD, sizeof( TED_Border_DASHD ), 1 );
579 	    drawLine( ds, x0, y, x1, y );
580 	    break;
581 
582 	case DOCbsDASHDD:
583 	    tedBorderSetLineDashes( ds,
584 			TED_Border_DASHDD, sizeof( TED_Border_DASHDD ), 1 );
585 	    drawLine( ds, x0, y, x1, y );
586 	    break;
587 
588 	case DOCbsTRIPLE:
589 	    tedBorderSetLineSolid( ds, 1 );
590 	    yy= y- 2;
591 	    drawLine( ds, x0, yy, x1, yy );
592 	    yy= y;
593 	    drawLine( ds, x0, yy, x1, yy );
594 	    yy= y+ 2;
595 	    drawLine( ds, x0, yy, x1, yy );
596 	    break;
597 
598 	case DOCbsTNTHSG:
599 	    tedBorderSetLineSolid( ds, 1 );
600 	    yy= y- 2;
601 	    drawLine( ds, x0, yy, x1, yy );
602 	    tedBorderSetLineSolid( ds, 2 );
603 	    yy= y+ 1;
604 	    drawLine( ds, x0, yy, x1, yy );
605 	    break;
606 
607 	case DOCbsTHTNSG:
608 	    tedBorderSetLineSolid( ds, 2 );
609 	    yy= y- 1;
610 	    drawLine( ds, x0, yy, x1, yy );
611 	    tedBorderSetLineSolid( ds, 1 );
612 	    yy= y+ 1;
613 	    drawLine( ds, x0, yy, x1, yy );
614 	    break;
615 
616 	case DOCbsTNTHTNSG:
617 	    tedBorderSetLineSolid( ds, 1 );
618 	    yy= y- 3;
619 	    drawLine( ds, x0, yy, x1, yy );
620 	    tedBorderSetLineSolid( ds, 2 );
621 	    yy= y+ 0;
622 	    drawLine( ds, x0, yy, x1, yy );
623 	    tedBorderSetLineSolid( ds, 1 );
624 	    yy= y+ 2;
625 	    drawLine( ds, x0, yy, x1, yy );
626 	    break;
627 
628 	case DOCbsTNTHMG:
629 	    tedBorderSetLineSolid( ds, 1 );
630 	    yy= y- 2;
631 	    drawLine( ds, x0, yy, x1, yy );
632 	    tedBorderSetLineSolid( ds, 3 );
633 	    yy= y+ 1;
634 	    drawLine( ds, x0, yy, x1, yy );
635 	    break;
636 
637 	case DOCbsTHTNMG:
638 	    tedBorderSetLineSolid( ds, 3 );
639 	    yy= y- 2;
640 	    drawLine( ds, x0, yy, x1, yy );
641 	    tedBorderSetLineSolid( ds, 1 );
642 	    yy= y+ 1;
643 	    drawLine( ds, x0, yy, x1, yy );
644 	    break;
645 
646 	case DOCbsTNTHTNMG:
647 	    tedBorderSetLineSolid( ds, 1 );
648 	    yy= y- 3;
649 	    drawLine( ds, x0, yy, x1, yy );
650 	    tedBorderSetLineSolid( ds, 3 );
651 	    yy= y+ 0;
652 	    drawLine( ds, x0, yy, x1, yy );
653 	    tedBorderSetLineSolid( ds, 1 );
654 	    yy= y+ 3;
655 	    drawLine( ds, x0, yy, x1, yy );
656 	    break;
657 
658 	case DOCbsTNTHLG:
659 	    tedBorderSetLineSolid( ds, 1 );
660 	    yy= y- 3;
661 	    drawLine( ds, x0, yy, x1, yy );
662 	    tedBorderSetLineSolid( ds, 4 );
663 	    yy= y+ 2;
664 	    drawLine( ds, x0, yy, x1, yy );
665 	    break;
666 
667 	case DOCbsTHTNLG:
668 	    tedBorderSetLineSolid( ds, 4 );
669 	    yy= y- 2;
670 	    drawLine( ds, x0, yy, x1, yy );
671 	    tedBorderSetLineSolid( ds, 1 );
672 	    yy= y+ 2;
673 	    drawLine( ds, x0, yy, x1, yy );
674 	    break;
675 
676 	case DOCbsTNTHTNLG:
677 	    tedBorderSetLineSolid( ds, 1 );
678 	    yy= y- 4;
679 	    drawLine( ds, x0, yy, x1, yy );
680 	    tedBorderSetLineSolid( ds, 4 );
681 	    yy= y+ 0;
682 	    drawLine( ds, x0, yy, x1, yy );
683 	    tedBorderSetLineSolid( ds, 1 );
684 	    yy= y+ 3;
685 	    drawLine( ds, x0, yy, x1, yy );
686 	    break;
687 
688 	case DOCbsWAVY:
689 	    tedBorderSetLineSolid( ds, 1 );
690 	    xx= x0;
691 #	    define	W	2
692 #	    define	W2	4
693 	    drawLine( ds, xx, y, xx+ W, y+ W ); xx += W;
694 	    while( xx < x1 )
695 		{
696 		drawLine( ds, xx, y+ W, xx+ W2, y- W ); xx += W2;
697 		drawLine( ds, xx, y- W, xx+ W2, y+ W ); xx += W2;
698 		}
699 	    break;
700 
701 	case DOCbsWAVYDB:
702 	    tedBorderSetLineSolid( ds, 1 );
703 	    yy= y- 2;
704 	    xx= x0;
705 	    drawLine( ds, xx, yy, xx+ W, yy+ W ); xx += W;
706 	    while( xx < x1 )
707 		{
708 		drawLine( ds, xx, yy+ W, xx+ W2, yy- W ); xx += W2;
709 		drawLine( ds, xx, yy- W, xx+ W2, yy+ W ); xx += W2;
710 		}
711 
712 	    yy= y+ 2;
713 	    xx= x0;
714 	    drawLine( ds, xx, yy, xx+ W, yy+ W ); xx += W;
715 	    while( xx < x1 )
716 		{
717 		drawLine( ds, xx, yy+ W, xx+ W2, yy- W ); xx += W2;
718 		drawLine( ds, xx, yy- W, xx+ W2, yy+ W ); xx += W2;
719 		}
720 	    break;
721 
722 	case DOCbsDASHSM:
723 	    tedBorderSetLineDashes( ds,
724 			TED_Border_DASHSM, sizeof( TED_Border_DASHSM ), 1 );
725 	    drawLine( ds, x0, y, x1, y );
726 	    break;
727 
728 	case DOCbsDASHDOTSTR:
729 	    xx= x0- 2;
730 	    while( xx < x1 )
731 		{
732 		drawLine( ds, xx, y+ 1, xx+ 3, y- 2 ); xx += 2;
733 		drawLine( ds, xx, y+ 1, xx+ 3, y- 2 ); xx += 1;
734 		drawLine( ds, xx, y+ 1, xx+ 3, y- 2 ); xx += 2;
735 		}
736 	    break;
737 
738 	case DOCbsEMBOSS:
739 	case DOCbsENGRAVE:
740 	case DOCbsFRAME:
741 	case DOCbsOUTSET:
742 	    tedBorderSetLineSolid( ds, 1 );
743 	    drawLine( ds, x0, y, x1, y );
744 	    break;
745 
746 	case DOCbsTBL:
747 	case DOCbsNIL:
748 	    /*no border*/
749 	    break;
750 
751 	default:
752 	    LDEB(style);
753 	    break;
754 	}
755 
756     return;
757     }
758