1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 #include <sys/types.h>
33 #include "screenhack.h"
38 #include "lcd-playersim.h"
40 #define MAX(x,y) ((x)>(y)?(x):(y))
41 #define MIN(x,y) ((x)<(y)?(x):(y))
43 #define PROGNAME "rockboxui"
54 bool lcd_display_redraw
=true;
56 XrmOptionDescRec options
[] = {
57 /* { "-subtractive", ".additive", XrmoptionNoArg, "false" }, */
58 { "-server", ".server", XrmoptionSepArg
, 0 },
59 { "-help", ".help", XrmoptionNoArg
, "false" },
62 char *progclass
= "rockboxui";
66 ".background: lightblue",
68 ".background: lightgreen",
78 XWindowAttributes xgwa
;
80 XGetWindowAttributes (dpy
, window
, &xgwa
);
86 get_pixel_resource ("foreground", "Foreground", dpy
, cmap
);
87 draw_gc
= XCreateGC (dpy
, window
, GCForeground
, &gcv
);
89 screen_resized(LCD_WIDTH
, LCD_HEIGHT
);
92 void screen_resized(int width
, int height
)
98 XSetForeground (dpy
, draw_gc
, get_pixel_resource ("background", "Background",
100 XFillRectangle(dpy
, window
, draw_gc
, 0, 0, width
*display_zoom
, height
*display_zoom
);
101 lcd_display_redraw
=true;
105 void drawrect(int color
, int x1
, int y1
, int x2
, int y2
)
108 XSetForeground(dpy
, draw_gc
,
109 get_pixel_resource("background", "Background", dpy
, cmap
));
112 XSetForeground(dpy
, draw_gc
,
113 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
114 XFillRectangle(dpy
, window
, draw_gc
, x1
*display_zoom
, y1
*display_zoom
,
115 x2
*display_zoom
, y2
*display_zoom
);
119 static void help(void)
121 printf(PROGNAME
" " ROCKBOXUI_VERSION
" " __DATE__
"\n"
122 "usage: " PROGNAME
"\n"
126 void drawline(int color
, int x1
, int y1
, int x2
, int y2
)
129 XSetForeground(dpy
, draw_gc
,
130 get_pixel_resource("background", "Background", dpy
, cmap
));
133 XSetForeground(dpy
, draw_gc
,
134 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
136 XDrawLine(dpy
, window
, draw_gc
,
137 (int)(x1
*display_zoom
),
138 (int)(y1
*display_zoom
),
139 (int)(x2
*display_zoom
),
140 (int)(y2
*display_zoom
));
143 void drawdot(int color
, int x
, int y
)
146 XSetForeground(dpy
, draw_gc
,
147 get_pixel_resource("background", "Background", dpy
, cmap
));
150 XSetForeground(dpy
, draw_gc
,
151 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
153 XFillRectangle(dpy
, window
, draw_gc
, x
*display_zoom
, y
*display_zoom
,
154 display_zoom
, display_zoom
);
157 void drawdots(int color
, struct coordinate
*points
, int count
)
160 XSetForeground(dpy
, draw_gc
,
161 get_pixel_resource("background", "Background", dpy
, cmap
));
164 XSetForeground(dpy
, draw_gc
,
165 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
168 XFillRectangle(dpy
, window
, draw_gc
,
169 points
[count
].x
*display_zoom
,
170 points
[count
].y
*display_zoom
,
176 void drawrectangles(int color
, struct rectangle
*points
, int count
)
179 XSetForeground(dpy
, draw_gc
,
180 get_pixel_resource("background", "Background", dpy
, cmap
));
183 XSetForeground(dpy
, draw_gc
,
184 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
187 XFillRectangle(dpy
, window
, draw_gc
,
188 points
[count
].x
*display_zoom
,
189 points
[count
].y
*display_zoom
,
190 points
[count
].width
*display_zoom
,
191 points
[count
].height
*display_zoom
);
196 void drawtext(int color
, int x
, int y
, char *text
)
199 XSetForeground(dpy
, draw_gc
,
200 get_pixel_resource("background", "Background", dpy
, cmap
));
203 XSetForeground(dpy
, draw_gc
,
204 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
206 XDrawString(dpy
, window
, draw_gc
, x
*display_zoom
, y
*display_zoom
, text
, strlen(text
));
209 /* this is where the applicaton starts */
210 extern void app_main(void);
213 screenhack (Display
*the_dpy
, Window the_window
)
217 /* This doesn't work, but I don't know why (Daniel 1999-12-01) */
218 helpme
= get_boolean_resource ("help", "Boolean");
222 printf(PROGNAME
" " ROCKBOXUI_VERSION
" (" __DATE__
")\n");
236 /* draw a border around the "Recorder" screen */
239 #define X2 (LCD_WIDTH + MARGIN_X*2)
240 #define Y2 (LCD_HEIGHT + MARGIN_Y)
242 drawline(1, X1
, Y1
, X2
, Y1
);
243 drawline(1, X2
, Y1
, X2
, Y2
);
244 drawline(1, X1
, Y2
, X2
, Y2
);
245 drawline(1, X1
, Y1
, X1
, Y2
);