summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-07-14 10:02:04 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-07-14 10:02:04 +0000
commit9872813c7d5025e72941719ef9252b1fa4ae41c6 (patch)
tree9dd6aa0beb5b8d9e701fdd34c8d19b6c00e2c342
parent4d45987e374737af5e2aa7215c608d4501c07672 (diff)
downloadrockbox-9872813c7d5025e72941719ef9252b1fa4ae41c6.tar.gz
rockbox-9872813c7d5025e72941719ef9252b1fa4ae41c6.zip
introducing H1x0 style grayscale support in the X11 sim
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7137 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/common/lcd-playersim.h5
-rw-r--r--uisimulator/x11/lcd-x11.c145
-rw-r--r--uisimulator/x11/lcd-x11.h2
-rw-r--r--uisimulator/x11/resources.c118
-rw-r--r--uisimulator/x11/uibasic.c137
5 files changed, 96 insertions, 311 deletions
diff --git a/uisimulator/common/lcd-playersim.h b/uisimulator/common/lcd-playersim.h
index ef3b14223e..10267de1f1 100644
--- a/uisimulator/common/lcd-playersim.h
+++ b/uisimulator/common/lcd-playersim.h
@@ -30,7 +30,10 @@ struct rectangle {
30 30
31void drawdots(int color, struct coordinate *coord, int count); 31void drawdots(int color, struct coordinate *coord, int count);
32void drawdot(int color, int x, int y); 32void drawdot(int color, int x, int y);
33void drawline(int color, int x1, int y1, int x2, int y2);
34void drawrect(int color, int x1, int y1, int x2, int y2); 33void drawrect(int color, int x1, int y1, int x2, int y2);
35void drawrectangles(int color, struct rectangle *rects, int count); 34void drawrectangles(int color, struct rectangle *rects, int count);
36 35
36
37void dots(int *colors, struct coordinate *points, int count);
38
39
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c
index d538cee9df..3ad5a79ec7 100644
--- a/uisimulator/x11/lcd-x11.c
+++ b/uisimulator/x11/lcd-x11.c
@@ -43,9 +43,11 @@
43#if LCD_DEPTH == 2 43#if LCD_DEPTH == 2
44#define YBLOCK 4 44#define YBLOCK 4
45#define BITOFFS 1 /* take the MSB of each pixel */ 45#define BITOFFS 1 /* take the MSB of each pixel */
46#define ANDBIT 3 /* AND with this to get the color number */
46#else 47#else
47#define YBLOCK 8 48#define YBLOCK 8
48#define BITOFFS 0 49#define BITOFFS 0
50#define ANDBIT 1
49#endif 51#endif
50 52
51extern void screen_resized(int width, int height); 53extern void screen_resized(int width, int height);
@@ -56,48 +58,8 @@ unsigned char lcd_framebuffer_copy[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
56 58
57void lcd_update (void) 59void lcd_update (void)
58{ 60{
59 int x, y; 61 /* update a full screen rect */
60 int p=0; 62 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
61 int bit;
62 struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
63 int cp=0;
64 struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT];
65
66 for(y=0; y<LCD_HEIGHT; y+=YBLOCK) {
67 for(x=0; x<LCD_WIDTH; x++) {
68 if(lcd_framebuffer[y/YBLOCK][x] || lcd_framebuffer_copy[y/YBLOCK][x]) {
69 /* one or more bits/pixels are changed */
70 unsigned char diff =
71 lcd_framebuffer[y/YBLOCK][x] ^ lcd_framebuffer_copy[y/YBLOCK][x];
72
73 for(bit=0; bit<YBLOCK; bit++) {
74 if(lcd_framebuffer[y/YBLOCK][x]&(1<<(bit*LCD_DEPTH+BITOFFS))) {
75 /* set a dot */
76 points[p].x = x + MARGIN_X;
77 points[p].y = y+bit + MARGIN_Y;
78 p++; /* increase the point counter */
79 }
80 else if(diff &(1<<(bit*LCD_DEPTH+BITOFFS))) {
81 /* clear a dot */
82 clearpoints[cp].x = x + MARGIN_X;
83 clearpoints[cp].y = y+bit + MARGIN_Y;
84 cp++; /* increase the point counter */
85 }
86 }
87 }
88 }
89 }
90
91 /* copy a huge block */
92 memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer));
93
94 drawdots(0, &clearpoints[0], cp);
95 drawdots(1, &points[0], p);
96 /* printf("lcd_update: Draws %d pixels, clears %d pixels (max %d/%d)\n",
97 p, cp, p+cp, LCD_HEIGHT*LCD_WIDTH); */
98 XtAppLock(app);
99 XSync(dpy,False);
100 XtAppUnlock(app);
101} 63}
102 64
103void lcd_update_rect(int x_start, int y_start, 65void lcd_update_rect(int x_start, int y_start,
@@ -108,11 +70,10 @@ void lcd_update_rect(int x_start, int y_start,
108 int y; 70 int y;
109 int p=0; 71 int p=0;
110 int bit; 72 int bit;
111 int cp=0;
112 int xmax; 73 int xmax;
113 int ymax; 74 int ymax;
75 int colors[LCD_WIDTH * LCD_HEIGHT];
114 struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; 76 struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
115 struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT];
116 77
117#if 0 78#if 0
118 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", 79 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
@@ -132,24 +93,25 @@ void lcd_update_rect(int x_start, int y_start,
132 for(; yline<=ymax; yline++) { 93 for(; yline<=ymax; yline++) {
133 y = yline * YBLOCK; 94 y = yline * YBLOCK;
134 for(x=x_start; x<xmax; x++) { 95 for(x=x_start; x<xmax; x++) {
135 if(lcd_framebuffer[yline][x] || lcd_framebuffer_copy[yline][x]) { 96 if(lcd_framebuffer[yline][x] != lcd_framebuffer_copy[yline][x]) {
136 /* one or more bits/pixels are changed */ 97 /* one or more bits/pixels are changed */
137 unsigned char diff =
138 lcd_framebuffer[yline][x] ^ lcd_framebuffer_copy[yline][x];
139 98
140 for(bit=0; bit<YBLOCK; bit++) { 99 for(bit=0; bit<YBLOCK; bit++) {
141 if(lcd_framebuffer[yline][x]&(1<<(bit*LCD_DEPTH+BITOFFS))) { 100 unsigned int col;
142 /* set a dot */ 101 col = lcd_framebuffer[yline][x]&(ANDBIT<<(bit*LCD_DEPTH));
143 points[p].x = x + MARGIN_X; 102
144 points[p].y = y+bit + MARGIN_Y; 103#if LCD_DEPTH == 2
145 p++; /* increase the point counter */ 104 /* shift down the value to the lower bits */
146 } 105 col >>= (bit * LCD_DEPTH);
147 else if(diff &(1<<(bit*LCD_DEPTH+BITOFFS))) { 106
148 /* clear a dot */ 107 /* set a dot */
149 clearpoints[cp].x = x + MARGIN_X; 108 colors[p] = col;
150 clearpoints[cp].y = y+bit + MARGIN_Y; 109#else
151 cp++; /* increase the point counter */ 110 colors[p] = col?3:0;
152 } 111#endif
112 points[p].x = x + MARGIN_X;
113 points[p].y = y+bit + MARGIN_Y;
114 p++; /* increase the point counter */
153 } 115 }
154 116
155 /* update the copy */ 117 /* update the copy */
@@ -158,8 +120,7 @@ void lcd_update_rect(int x_start, int y_start,
158 } 120 }
159 } 121 }
160 122
161 drawdots(0, &clearpoints[0], cp); 123 dots(colors, &points[0], p);
162 drawdots(1, &points[0], p);
163 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/ 124 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
164 XtAppLock(app); 125 XtAppLock(app);
165 XSync(dpy,False); 126 XSync(dpy,False);
@@ -175,51 +136,7 @@ unsigned char lcd_remote_framebuffer_copy[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH]
175 136
176void lcd_remote_update (void) 137void lcd_remote_update (void)
177{ 138{
178 int x, y; 139 lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
179 int p=0;
180 int bit;
181 struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
182 int cp=0;
183 struct coordinate clearpoints[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
184
185 for(y=0; y<LCD_REMOTE_HEIGHT; y+=8) {
186 for(x=0; x<LCD_REMOTE_WIDTH; x++) {
187 if(lcd_remote_framebuffer[y/8][x] ||
188 lcd_remote_framebuffer_copy[y/8][x]) {
189 /* one or more bits/pixels are changed */
190 unsigned char diff =
191 lcd_remote_framebuffer[y/8][x] ^
192 lcd_remote_framebuffer_copy[y/8][x];
193
194 for(bit=0; bit<8; bit++) {
195 if(lcd_remote_framebuffer[y/8][x]&(1<<bit)) {
196 /* set a dot */
197 points[p].x = x + REMOTE_MARGIN_X;
198 points[p].y = y+bit + REMOTE_MARGIN_Y;
199 p++; /* increase the point counter */
200 }
201 else if(diff &(1<<bit)) {
202 /* clear a dot */
203 clearpoints[cp].x = x + REMOTE_MARGIN_X;
204 clearpoints[cp].y = y+bit + REMOTE_MARGIN_Y;
205 cp++; /* increase the point counter */
206 }
207 }
208 }
209 }
210 }
211
212 /* copy a huge block */
213 memcpy(lcd_remote_framebuffer_copy, lcd_remote_framebuffer,
214 sizeof(lcd_remote_framebuffer));
215
216 drawdots(0, &clearpoints[0], cp);
217 drawdots(1, &points[0], p);
218 /* printf("lcd_update: Draws %d pixels, clears %d pixels (max %d/%d)\n",
219 p, cp, p+cp, LCD_HEIGHT*LCD_WIDTH); */
220 XtAppLock(app);
221 XSync(dpy,False);
222 XtAppUnlock(app);
223} 140}
224 141
225void lcd_remote_update_rect(int x_start, int y_start, 142void lcd_remote_update_rect(int x_start, int y_start,
@@ -230,11 +147,10 @@ void lcd_remote_update_rect(int x_start, int y_start,
230 int y; 147 int y;
231 int p=0; 148 int p=0;
232 int bit; 149 int bit;
233 int cp=0;
234 int xmax; 150 int xmax;
235 int ymax; 151 int ymax;
236 struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; 152 struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
237 struct coordinate clearpoints[LCD_WIDTH * LCD_HEIGHT]; 153 int colors[LCD_WIDTH * LCD_HEIGHT];
238 154
239#if 0 155#if 0
240 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", 156 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
@@ -264,18 +180,20 @@ void lcd_remote_update_rect(int x_start, int y_start,
264 for(bit=0; bit<8; bit++) { 180 for(bit=0; bit<8; bit++) {
265 if(lcd_remote_framebuffer[yline][x]&(1<<bit)) { 181 if(lcd_remote_framebuffer[yline][x]&(1<<bit)) {
266 /* set a dot */ 182 /* set a dot */
183 colors[p]=3;
267 points[p].x = x + REMOTE_MARGIN_X; 184 points[p].x = x + REMOTE_MARGIN_X;
268 points[p].y = y+bit + REMOTE_MARGIN_Y; 185 points[p].y = y+bit + REMOTE_MARGIN_Y;
269 p++; /* increase the point counter */ 186 p++; /* increase the point counter */
270 } 187 }
271 else if(diff &(1<<bit)) { 188 else if(diff &(1<<bit)) {
272 /* clear a dot */ 189 /* clear a dot */
273 clearpoints[cp].x = x + REMOTE_MARGIN_X; 190 colors[p]=0;
274 clearpoints[cp].y = y+bit + REMOTE_MARGIN_Y; 191 points[p].x = x + REMOTE_MARGIN_X;
275 cp++; /* increase the point counter */ 192 points[p].y = y+bit + REMOTE_MARGIN_Y;
193 p++; /* increase the point counter */
276 } 194 }
277 } 195 }
278 196
279 /* update the copy */ 197 /* update the copy */
280 lcd_remote_framebuffer_copy[yline][x] = 198 lcd_remote_framebuffer_copy[yline][x] =
281 lcd_remote_framebuffer[yline][x]; 199 lcd_remote_framebuffer[yline][x];
@@ -283,8 +201,7 @@ void lcd_remote_update_rect(int x_start, int y_start,
283 } 201 }
284 } 202 }
285 203
286 drawdots(0, &clearpoints[0], cp); 204 dots(colors, &points[0], p);
287 drawdots(1, &points[0], p);
288 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/ 205 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
289 XtAppLock(app); 206 XtAppLock(app);
290 XSync(dpy,False); 207 XSync(dpy,False);
diff --git a/uisimulator/x11/lcd-x11.h b/uisimulator/x11/lcd-x11.h
index b95374c13c..07911b2530 100644
--- a/uisimulator/x11/lcd-x11.h
+++ b/uisimulator/x11/lcd-x11.h
@@ -22,3 +22,5 @@
22 22
23/* include the "real" lcd.h file here */ 23/* include the "real" lcd.h file here */
24#include <lcd.h> 24#include <lcd.h>
25
26
diff --git a/uisimulator/x11/resources.c b/uisimulator/x11/resources.c
index e0925d0fc7..feaf3b8216 100644
--- a/uisimulator/x11/resources.c
+++ b/uisimulator/x11/resources.c
@@ -21,9 +21,6 @@ extern char *progname;
21extern char *progclass; 21extern char *progclass;
22extern XrmDatabase db; 22extern XrmDatabase db;
23 23
24static unsigned int get_time_resource (char *res_name, char *res_class,
25 Bool sec_p);
26
27#ifndef isupper 24#ifndef isupper
28# define isupper(c) ((c) >= 'A' && (c) <= 'Z') 25# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
29#endif 26#endif
@@ -79,57 +76,6 @@ get_boolean_resource (char *res_name, char *res_class)
79 return 0; 76 return 0;
80} 77}
81 78
82int
83get_integer_resource (char *res_name, char *res_class)
84{
85 int val;
86 char c, *s = get_string_resource (res_name, res_class);
87 char *ss = s;
88 if (!s) return 0;
89
90 while (*ss && *ss <= ' ') ss++; /* skip whitespace */
91
92 if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X')) /* 0x: parse as hex */
93 {
94 if (1 == sscanf (ss+2, "%x %c", &val, &c))
95 {
96 free (s);
97 return val;
98 }
99 }
100 else /* else parse as dec */
101 {
102 if (1 == sscanf (ss, "%d %c", &val, &c))
103 {
104 free (s);
105 return val;
106 }
107 }
108
109 fprintf (stderr, "%s: %s must be an integer, not %s.\n",
110 progname, res_name, s);
111 free (s);
112 return 0;
113}
114
115double
116get_float_resource (char *res_name, char *res_class)
117{
118 double val;
119 char c, *s = get_string_resource (res_name, res_class);
120 if (! s) return 0.0;
121 if (1 == sscanf (s, " %lf %c", &val, &c))
122 {
123 free (s);
124 return val;
125 }
126 fprintf (stderr, "%s: %s must be a float, not %s.\n",
127 progname, res_name, s);
128 free (s);
129 return 0.0;
130}
131
132
133unsigned int 79unsigned int
134get_pixel_resource (char *res_name, char *res_class, 80get_pixel_resource (char *res_name, char *res_class,
135 Display *dpy, Colormap cmap) 81 Display *dpy, Colormap cmap)
@@ -165,67 +111,3 @@ get_pixel_resource (char *res_name, char *res_class,
165 : WhitePixel (dpy, DefaultScreen (dpy))); 111 : WhitePixel (dpy, DefaultScreen (dpy)));
166} 112}
167 113
168
169int
170parse_time (const char *string, Bool seconds_default_p, Bool silent_p)
171{
172 unsigned int h, m, s;
173 char c;
174 if (3 == sscanf (string, " %u : %2u : %2u %c", &h, &m, &s, &c))
175 ;
176 else if (2 == sscanf (string, " : %2u : %2u %c", &m, &s, &c) ||
177 2 == sscanf (string, " %u : %2u %c", &m, &s, &c))
178 h = 0;
179 else if (1 == sscanf (string, " : %2u %c", &s, &c))
180 h = m = 0;
181 else if (1 == sscanf (string, " %u %c",
182 (seconds_default_p ? &s : &m), &c))
183 {
184 h = 0;
185 if (seconds_default_p) m = 0;
186 else s = 0;
187 }
188 else
189 {
190 if (! silent_p)
191 fprintf (stderr, "%s: invalid time interval specification \"%s\".\n",
192 progname, string);
193 return -1;
194 }
195 if (s >= 60 && (h != 0 || m != 0))
196 {
197 if (! silent_p)
198 fprintf (stderr, "%s: seconds > 59 in \"%s\".\n", progname, string);
199 return -1;
200 }
201 if (m >= 60 && h > 0)
202 {
203 if (! silent_p)
204 fprintf (stderr, "%s: minutes > 59 in \"%s\".\n", progname, string);
205 return -1;
206 }
207 return ((h * 60 * 60) + (m * 60) + s);
208}
209
210static unsigned int
211get_time_resource (char *res_name, char *res_class, Bool sec_p)
212{
213 int val;
214 char *s = get_string_resource (res_name, res_class);
215 if (!s) return 0;
216 val = parse_time (s, sec_p, False);
217 free (s);
218 return (val < 0 ? 0 : val);
219}
220
221unsigned int
222get_seconds_resource (char *res_name, char *res_class)
223{
224 return get_time_resource (res_name, res_class, True);
225}
226
227unsigned int
228get_minutes_resource (char *res_name, char *res_class)
229{
230 return get_time_resource (res_name, res_class, False);
231}
diff --git a/uisimulator/x11/uibasic.c b/uisimulator/x11/uibasic.c
index 3e7f46c70d..05eb3fff82 100644
--- a/uisimulator/x11/uibasic.c
+++ b/uisimulator/x11/uibasic.c
@@ -58,30 +58,75 @@ XrmOptionDescRec options [] = {
58}; 58};
59char *progclass = "rockboxui"; 59char *progclass = "rockboxui";
60 60
61char *defaults [] = {
62#ifdef IRIVER_H100_SERIES 61#ifdef IRIVER_H100_SERIES
63 ".background: lightblue", 62#define BGCOLOR "lightblue"
64#elif defined ARCHOS_GMINI120 63#elif defined ARCHOS_GMINI120
65 ".background: royalblue", 64#define BGCOLOR "royalblue"
66#else 65#else
67 ".background: lightgreen", 66#define BGCOLOR "lightgreen"
68#endif 67#endif
68
69
70char *defaults [] = {
71 ".background: " BGCOLOR,
69 ".foreground: black", 72 ".foreground: black",
70 "*help: false", 73 "*help: false",
71 0 74 0
72}; 75};
73 76
77static XColor getcolor[4];
78
79/* set a range of bitmap indices to a gradient from startcolour to endcolour
80 inherited from the win32 sim code by Jens Arnold */
81static void lcdcolors(int index, int count, XColor *start, XColor *end)
82{
83 int i;
84 count--;
85 for (i = 0; i <= count; i++)
86 {
87 getcolor[i+index].red = start->red
88 + (end->red - start->red) * i / count;
89 getcolor[i+index].green = start->green
90 + (end->green - start->green) * i / count;
91 getcolor[i+index].blue = start->blue
92 + (end->blue - start->blue) * i / count;
93 XAllocColor (dpy, cmap, &getcolor[i+index]);
94 }
95}
96
97
74void init_window () 98void init_window ()
75{ 99{
76 XGCValues gcv; 100 XGCValues gcv;
77 XWindowAttributes xgwa; 101 XWindowAttributes xgwa;
78 102
79 XGetWindowAttributes (dpy, window, &xgwa); 103 XGetWindowAttributes (dpy, window, &xgwa);
104 XColor bg;
105 XColor fg;
80 106
81 cmap = xgwa.colormap; 107 cmap = xgwa.colormap;
82 108
109 XParseColor (dpy, cmap, BGCOLOR, &bg);
110 XParseColor (dpy, cmap, "black", &fg);
111 getcolor[0] = bg;
112 getcolor[1] = bg;
113 getcolor[2] = bg;
114 getcolor[3] = bg;
115
116 lcdcolors(0, 4, &bg, &fg);
117
118#if 0
119 for(i=0; i<4; i++) {
120 printf("color %d: %d %d %d\n",
121 i,
122 getcolor[i].red,
123 getcolor[i].green,
124 getcolor[i].blue);
125 }
126#endif
127
83 gcv.function = GXxor; 128 gcv.function = GXxor;
84 gcv.foreground = get_pixel_resource("foreground", "Foreground", dpy, cmap); 129 gcv.foreground = getcolor[3].pixel;
85 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv); 130 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
86 131
87 screen_resized(LCD_WIDTH, LCD_HEIGHT); 132 screen_resized(LCD_WIDTH, LCD_HEIGHT);
@@ -94,8 +139,8 @@ void screen_resized(int width, int height)
94 maxy = height; 139 maxy = height;
95 140
96 XtAppLock(app); 141 XtAppLock(app);
97 XSetForeground(dpy, draw_gc, 142 XSetForeground(dpy, draw_gc, getcolor[0].pixel);
98 get_pixel_resource("background", "Background", dpy, cmap)); 143
99 XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom, 144 XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom,
100 height*display_zoom); 145 height*display_zoom);
101 XtAppUnlock(app); 146 XtAppUnlock(app);
@@ -106,13 +151,7 @@ void screen_resized(int width, int height)
106void drawrect(int color, int x1, int y1, int x2, int y2) 151void drawrect(int color, int x1, int y1, int x2, int y2)
107{ 152{
108 XtAppLock(app); 153 XtAppLock(app);
109 if (color==0) 154 XSetForeground(dpy, draw_gc, getcolor[color].pixel);
110 XSetForeground(dpy, draw_gc,
111 get_pixel_resource("background", "Background", dpy, cmap));
112 else
113 XSetForeground(dpy, draw_gc,
114 get_pixel_resource("foreground", "Foreground", dpy, cmap));
115
116 XFillRectangle(dpy, window, draw_gc, x1*display_zoom, y1*display_zoom, 155 XFillRectangle(dpy, window, draw_gc, x1*display_zoom, y1*display_zoom,
117 x2*display_zoom, y2*display_zoom); 156 x2*display_zoom, y2*display_zoom);
118 XtAppUnlock(app); 157 XtAppUnlock(app);
@@ -124,15 +163,10 @@ static void help(void)
124 "usage: " PROGNAME "\n"); 163 "usage: " PROGNAME "\n");
125} 164}
126 165
127void drawline(int color, int x1, int y1, int x2, int y2) 166static void drawline(int color, int x1, int y1, int x2, int y2)
128{ 167{
129 XtAppLock(app); 168 XtAppLock(app);
130 if (color==0) 169 XSetForeground(dpy, draw_gc, getcolor[color].pixel);
131 XSetForeground(dpy, draw_gc,
132 get_pixel_resource("background", "Background", dpy, cmap));
133 else
134 XSetForeground(dpy, draw_gc,
135 get_pixel_resource("foreground", "Foreground", dpy, cmap));
136 170
137 XDrawLine(dpy, window, draw_gc, 171 XDrawLine(dpy, window, draw_gc,
138 (int)(x1*display_zoom), 172 (int)(x1*display_zoom),
@@ -142,32 +176,14 @@ void drawline(int color, int x1, int y1, int x2, int y2)
142 XtAppUnlock(app); 176 XtAppUnlock(app);
143} 177}
144 178
145void drawdot(int color, int x, int y) 179void dots(int *colors, struct coordinate *points, int count)
146{ 180{
181 int color;
147 XtAppLock(app); 182 XtAppLock(app);
148 if (color==0)
149 XSetForeground(dpy, draw_gc,
150 get_pixel_resource("background", "Background", dpy, cmap));
151 else
152 XSetForeground(dpy, draw_gc,
153 get_pixel_resource("foreground", "Foreground", dpy, cmap));
154
155 XFillRectangle(dpy, window, draw_gc, x*display_zoom, y*display_zoom,
156 display_zoom, display_zoom);
157 XtAppUnlock(app);
158}
159
160void drawdots(int color, struct coordinate *points, int count)
161{
162 XtAppLock(app);
163 if (color==0)
164 XSetForeground(dpy, draw_gc,
165 get_pixel_resource("background", "Background", dpy, cmap));
166 else
167 XSetForeground(dpy, draw_gc,
168 get_pixel_resource("foreground", "Foreground", dpy, cmap));
169 183
170 while (count--) { 184 while (count--) {
185 color = colors[count];
186 XSetForeground(dpy, draw_gc, getcolor[color].pixel);
171 XFillRectangle(dpy, window, draw_gc, 187 XFillRectangle(dpy, window, draw_gc,
172 points[count].x*display_zoom, 188 points[count].x*display_zoom,
173 points[count].y*display_zoom, 189 points[count].y*display_zoom,
@@ -177,41 +193,6 @@ void drawdots(int color, struct coordinate *points, int count)
177 XtAppUnlock(app); 193 XtAppUnlock(app);
178} 194}
179 195
180void drawrectangles(int color, struct rectangle *points, int count)
181{
182 XtAppLock(app);
183 if (color==0)
184 XSetForeground(dpy, draw_gc,
185 get_pixel_resource("background", "Background", dpy, cmap));
186 else
187 XSetForeground(dpy, draw_gc,
188 get_pixel_resource("foreground", "Foreground", dpy, cmap));
189
190 while (count--) {
191 XFillRectangle(dpy, window, draw_gc,
192 points[count].x*display_zoom,
193 points[count].y*display_zoom,
194 points[count].width*display_zoom,
195 points[count].height*display_zoom);
196 }
197 XtAppUnlock(app);
198}
199
200void drawtext(int color, int x, int y, char *text)
201{
202 XtAppLock(app);
203 if (color==0)
204 XSetForeground(dpy, draw_gc,
205 get_pixel_resource("background", "Background", dpy, cmap));
206 else
207 XSetForeground(dpy, draw_gc,
208 get_pixel_resource("foreground", "Foreground", dpy, cmap));
209
210 XDrawString(dpy, window, draw_gc, x*display_zoom, y*display_zoom, text,
211 strlen(text));
212 XtAppUnlock(app);
213}
214
215/* this is where the applicaton starts */ 196/* this is where the applicaton starts */
216extern void app_main(void); 197extern void app_main(void);
217 198