diff options
author | Daniel Stenberg <daniel@haxx.se> | 2005-07-14 10:02:04 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2005-07-14 10:02:04 +0000 |
commit | 9872813c7d5025e72941719ef9252b1fa4ae41c6 (patch) | |
tree | 9dd6aa0beb5b8d9e701fdd34c8d19b6c00e2c342 /uisimulator/x11/uibasic.c | |
parent | 4d45987e374737af5e2aa7215c608d4501c07672 (diff) | |
download | rockbox-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
Diffstat (limited to 'uisimulator/x11/uibasic.c')
-rw-r--r-- | uisimulator/x11/uibasic.c | 137 |
1 files changed, 59 insertions, 78 deletions
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 | }; |
59 | char *progclass = "rockboxui"; | 59 | char *progclass = "rockboxui"; |
60 | 60 | ||
61 | char *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 | |||
70 | char *defaults [] = { | ||
71 | ".background: " BGCOLOR, | ||
69 | ".foreground: black", | 72 | ".foreground: black", |
70 | "*help: false", | 73 | "*help: false", |
71 | 0 | 74 | 0 |
72 | }; | 75 | }; |
73 | 76 | ||
77 | static 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 */ | ||
81 | static 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 | |||
74 | void init_window () | 98 | void 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) | |||
106 | void drawrect(int color, int x1, int y1, int x2, int y2) | 151 | void 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 | ||
127 | void drawline(int color, int x1, int y1, int x2, int y2) | 166 | static 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 | ||
145 | void drawdot(int color, int x, int y) | 179 | void 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 | |||
160 | void 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 | ||
180 | void 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 | |||
200 | void 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 */ |
216 | extern void app_main(void); | 197 | extern void app_main(void); |
217 | 198 | ||