1 /**
2  ** BCC2GRX  -  Interfacing Borland based graphics programs to LIBGRX
3  ** Copyright (C) 1993-97 by Hartmut Schirmer
4  **
5  **
6  ** Contact :                Hartmut Schirmer
7  **                          Feldstrasse 118
8  **                  D-24105 Kiel
9  **                          Germany
10  **
11  ** e-mail : hsc@techfak.uni-kiel.de
12  **
13  ** This file is part of the GRX graphics library.
14  **
15  ** The GRX graphics library is free software; you can redistribute it
16  ** and/or modify it under some conditions; see the "copying.grx" file
17  ** for details.
18  **
19  ** This library is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22  **
23  **/
24 
25 #include "bccgrx00.h"
26 
27 static unsigned short usr_pat = 0x0000;
28 
29 #define user_len (2*16+1)
30 static unsigned char user[user_len];
31 
getlinesettings(struct linesettingstype * lineinfo)32 void getlinesettings(struct linesettingstype  *lineinfo)
33 {
34   _DO_INIT_CHECK;
35   lineinfo->linestyle = __gr_lstyle;
36   lineinfo->upattern  = usr_pat;
37   lineinfo->thickness = LNE.lno_width;
38 }
39 
40 /* ----------------------------------------------------------------- */
setlinestyle(int linestyle,unsigned upattern,int thickness)41 void setlinestyle(int linestyle, unsigned upattern, int thickness)
42 {
43   int i, j;
44 
45   _DO_INIT_CHECK;
46   switch (linestyle) {
47     case SOLID_LINE  : LNE.lno_pattlen = 0;
48 		       LNE.lno_dashpat = NULL;
49 		       break;
50     case DOTTED_LINE : LNE.lno_pattlen = 4;
51 		       LNE.lno_dashpat = "\0\2\2\0";
52 		       break;
53     case CENTER_LINE : LNE.lno_pattlen = 6;
54 		       LNE.lno_dashpat = "\0\3\4\3\6\0";
55 		       break;
56     case DASHED_LINE : LNE.lno_pattlen = 6;
57 		       LNE.lno_dashpat = "\0\3\5\3\5\0";
58 		       break;
59     case USERBIT_LINE: usr_pat = upattern;
60 		       if (upattern == 0xFFFF) {
61 			 LNE.lno_pattlen = 0;
62 			 LNE.lno_dashpat = NULL;
63 			 break;
64 		       }
65 		       j = 0;
66 		       user[0] = 0;
67 		       for (i=0; i < 16; ++i) {
68 			 if ( (upattern & 1) == 0) {
69 			   if ( (j&1) == 0) {
70 			     ++j;
71 			     user[j] = 0;
72 			   }
73 			   ++user[j];
74 			 } else {
75 			   if ( (j&1) != 0) {
76 			     ++j;
77 			     user[j] = 0;
78 			   }
79 			   ++user[j];
80 			 }
81 			 upattern >>= 1;
82 		       }
83 #ifdef GRX_VERSION
84 		       if (j==1 && user[0]==0)
85 			   j = 0;
86 		       else
87 #endif
88 		       if ( (j&1) == 0)
89 			 user[++j] = 0;
90 		       LNE.lno_pattlen = j+1;
91 		       LNE.lno_dashpat = user;
92 		       break;
93     default          : ERR = grError;
94 		       return;
95   }
96   __gr_lstyle     = linestyle;
97   LNE.lno_width   = thickness;
98 }
99