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>
32 #include "screenhack.h"
37 #include "lcd-playersim.h"
39 #define MAX(x,y) ((x)>(y)?(x):(y))
40 #define MIN(x,y) ((x)<(y)?(x):(y))
42 #define PROGNAME "rockboxui"
53 bool lcd_display_redraw
=true;
55 XrmOptionDescRec options
[] = {
56 /* { "-subtractive", ".additive", XrmoptionNoArg, "false" }, */
57 { "-server", ".server", XrmoptionSepArg
, 0 },
58 { "-help", ".help", XrmoptionNoArg
, "false" },
61 char *progclass
= "rockboxui";
64 ".background: lightgreen",
73 XWindowAttributes xgwa
;
75 XGetWindowAttributes (dpy
, window
, &xgwa
);
81 get_pixel_resource ("foreground", "Foreground", dpy
, cmap
);
82 draw_gc
= XCreateGC (dpy
, window
, GCForeground
, &gcv
);
84 screen_resized(LCD_WIDTH
, LCD_HEIGHT
);
87 void screen_resized(int width
, int height
)
93 XSetForeground (dpy
, draw_gc
, get_pixel_resource ("background", "Background",
95 XFillRectangle(dpy
, window
, draw_gc
, 0, 0, width
*display_zoom
, height
*display_zoom
);
96 lcd_display_redraw
=true;
100 void drawrect(int color
, int x1
, int y1
, int x2
, int y2
)
103 XSetForeground(dpy
, draw_gc
,
104 get_pixel_resource("background", "Background", dpy
, cmap
));
107 XSetForeground(dpy
, draw_gc
,
108 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
109 XFillRectangle(dpy
, window
, draw_gc
, x1
*display_zoom
, y1
*display_zoom
,
110 x2
*display_zoom
, y2
*display_zoom
);
114 static void help(void)
116 printf(PROGNAME
" " ROCKBOXUI_VERSION
" " __DATE__
"\n"
117 "usage: " PROGNAME
"\n"
121 void drawline(int color
, int x1
, int y1
, int x2
, int y2
)
124 XSetForeground(dpy
, draw_gc
,
125 get_pixel_resource("background", "Background", dpy
, cmap
));
128 XSetForeground(dpy
, draw_gc
,
129 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
131 XDrawLine(dpy
, window
, draw_gc
,
132 (int)(x1
*display_zoom
),
133 (int)(y1
*display_zoom
),
134 (int)(x2
*display_zoom
),
135 (int)(y2
*display_zoom
));
138 void drawdot(int color
, int x
, int y
)
141 XSetForeground(dpy
, draw_gc
,
142 get_pixel_resource("background", "Background", dpy
, cmap
));
145 XSetForeground(dpy
, draw_gc
,
146 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
148 XFillRectangle(dpy
, window
, draw_gc
, x
*display_zoom
, y
*display_zoom
,
149 display_zoom
, display_zoom
);
152 void drawdots(int color
, struct coordinate
*points
, int count
)
155 XSetForeground(dpy
, draw_gc
,
156 get_pixel_resource("background", "Background", dpy
, cmap
));
159 XSetForeground(dpy
, draw_gc
,
160 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
163 XFillRectangle(dpy
, window
, draw_gc
,
164 points
[count
].x
*display_zoom
,
165 points
[count
].y
*display_zoom
,
171 void drawrectangles(int color
, struct rectangle
*points
, int count
)
174 XSetForeground(dpy
, draw_gc
,
175 get_pixel_resource("background", "Background", dpy
, cmap
));
178 XSetForeground(dpy
, draw_gc
,
179 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
182 XFillRectangle(dpy
, window
, draw_gc
,
183 points
[count
].x
*display_zoom
,
184 points
[count
].y
*display_zoom
,
185 points
[count
].width
*display_zoom
,
186 points
[count
].height
*display_zoom
);
191 void drawtext(int color
, int x
, int y
, char *text
)
194 XSetForeground(dpy
, draw_gc
,
195 get_pixel_resource("background", "Background", dpy
, cmap
));
198 XSetForeground(dpy
, draw_gc
,
199 get_pixel_resource("foreground", "Foreground", dpy
, cmap
));
201 XDrawString(dpy
, window
, draw_gc
, x
*display_zoom
, y
*display_zoom
, text
, strlen(text
));
204 /* this is where the applicaton starts */
205 extern void app_main(void);
208 screenhack (Display
*the_dpy
, Window the_window
)
212 /* This doesn't work, but I don't know why (Daniel 1999-12-01) */
213 helpme
= get_boolean_resource ("help", "Boolean");
217 printf(PROGNAME
" " ROCKBOXUI_VERSION
" (" __DATE__
")\n");
231 /* draw a border around the "Recorder" screen */
234 #define X2 (LCD_WIDTH + MARGIN_X*2)
235 #define Y2 (LCD_HEIGHT + MARGIN_Y)
237 drawline(1, X1
, Y1
, X2
, Y1
);
238 drawline(1, X2
, Y1
, X2
, Y2
);
239 drawline(1, X1
, Y2
, X2
, Y2
);
240 drawline(1, X1
, Y1
, X1
, Y2
);