summaryrefslogtreecommitdiff
path: root/uisimulator/x11
diff options
context:
space:
mode:
authorKjell Ericson <kjell@haxx.se>2002-10-16 08:43:13 +0000
committerKjell Ericson <kjell@haxx.se>2002-10-16 08:43:13 +0000
commitc54ff705a0039ffac847c5d4f7e0cc76aae33d4b (patch)
tree6a1fff11fdf70f2c9166f3a98b9fac177e5c9a9c /uisimulator/x11
parentc72a17742b147d983c0aa2cb5f915837728c86dd (diff)
downloadrockbox-c54ff705a0039ffac847c5d4f7e0cc76aae33d4b.tar.gz
rockbox-c54ff705a0039ffac847c5d4f7e0cc76aae33d4b.zip
First attempt to adjust the drawing routines to be able to zoom the window.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2675 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/x11')
-rw-r--r--uisimulator/x11/uibasic.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/uisimulator/x11/uibasic.c b/uisimulator/x11/uibasic.c
index 2eac2f8e06..bf7d32e281 100644
--- a/uisimulator/x11/uibasic.c
+++ b/uisimulator/x11/uibasic.c
@@ -42,12 +42,11 @@
42 42
43/* -- -- */ 43/* -- -- */
44 44
45GC draw_gc, erase_gc; 45GC draw_gc;
46static Colormap cmap; 46static Colormap cmap;
47static XColor color_track, color_car;
48 47
49static long maxx, maxy; 48static long maxx, maxy;
50static double track_zoom=1; 49static int display_zoom=2;
51 50
52Display *dpy; 51Display *dpy;
53Window window; 52Window window;
@@ -74,40 +73,29 @@ void init_window ()
74 73
75 XGetWindowAttributes (dpy, window, &xgwa); 74 XGetWindowAttributes (dpy, window, &xgwa);
76 75
77 color_track.red=65535;
78 color_track.green=65535;
79 color_track.blue=65535;
80
81 color_car.red=65535;
82 color_car.green=65535;
83 color_car.blue=0;
84
85 cmap = xgwa.colormap; 76 cmap = xgwa.colormap;
86 77
87 gcv.function = GXxor; 78 gcv.function = GXxor;
88 gcv.foreground = 79 gcv.foreground =
89 get_pixel_resource ("foreground", "Foreground", dpy, cmap); 80 get_pixel_resource ("foreground", "Foreground", dpy, cmap);
90 draw_gc = erase_gc = XCreateGC (dpy, window, GCForeground, &gcv); 81 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
91 XAllocColor (dpy, cmap, &color_track);
92 XAllocColor (dpy, cmap, &color_car);
93 82
94 screen_resized(200, 100); 83 screen_resized(200, 100);
95} 84}
96 85
97void screen_resized(int width, int height) 86void screen_resized(int width, int height)
98{ 87{
99#if 0
100 XWindowAttributes xgwa;
101 XGetWindowAttributes (dpy, window, &xgwa);
102 maxx = ((long)(xgwa.width));
103 maxy = ((long)(xgwa.height));
104#else
105 maxx = width-1; 88 maxx = width-1;
106 maxy = height-1; 89 maxy = height-1;
107#endif 90
91 display_zoom = maxy/64;
92 if (maxx/120 < display_zoom)
93 display_zoom = maxx/120;
94 if (display_zoom<1)
95 display_zoom = 1;
108 XSetForeground (dpy, draw_gc, get_pixel_resource ("background", "Background", 96 XSetForeground (dpy, draw_gc, get_pixel_resource ("background", "Background",
109 dpy, cmap)); 97 dpy, cmap));
110 XFillRectangle(dpy, window, draw_gc, 0, 0, width, height); 98 XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom, height*display_zoom);
111 99
112} 100}
113 101
@@ -129,10 +117,10 @@ void drawline(int color, int x1, int y1, int x2, int y2)
129 get_pixel_resource("foreground", "Foreground", dpy, cmap)); 117 get_pixel_resource("foreground", "Foreground", dpy, cmap));
130 118
131 XDrawLine(dpy, window, draw_gc, 119 XDrawLine(dpy, window, draw_gc,
132 (int)(x1*track_zoom), 120 (int)(x1*display_zoom),
133 (int)(y1*track_zoom), 121 (int)(y1*display_zoom),
134 (int)(x2*track_zoom), 122 (int)(x2*display_zoom),
135 (int)(y2*track_zoom)); 123 (int)(y2*display_zoom));
136} 124}
137 125
138void drawdot(int color, int x, int y) 126void drawdot(int color, int x, int y)
@@ -145,7 +133,8 @@ void drawdot(int color, int x, int y)
145 XSetForeground(dpy, draw_gc, 133 XSetForeground(dpy, draw_gc,
146 get_pixel_resource("foreground", "Foreground", dpy, cmap)); 134 get_pixel_resource("foreground", "Foreground", dpy, cmap));
147 135
148 XDrawPoint(dpy, window, draw_gc, x, y); 136 XFillRectangle(dpy, window, draw_gc, x*display_zoom, y*display_zoom,
137 display_zoom, display_zoom);
149} 138}
150 139
151void drawdots(int color, XPoint *points, int count) 140void drawdots(int color, XPoint *points, int count)
@@ -158,8 +147,13 @@ void drawdots(int color, XPoint *points, int count)
158 XSetForeground(dpy, draw_gc, 147 XSetForeground(dpy, draw_gc,
159 get_pixel_resource("foreground", "Foreground", dpy, cmap)); 148 get_pixel_resource("foreground", "Foreground", dpy, cmap));
160 149
161 150 while (count-->=0) {
162 XDrawPoints(dpy, window, draw_gc, points, count, CoordModeOrigin); 151 XFillRectangle(dpy, window, draw_gc,
152 points[count].x*display_zoom,
153 points[count].y*display_zoom,
154 display_zoom,
155 display_zoom);
156 }
163} 157}
164 158
165void drawtext(int color, int x, int y, char *text) 159void drawtext(int color, int x, int y, char *text)
@@ -172,7 +166,7 @@ void drawtext(int color, int x, int y, char *text)
172 XSetForeground(dpy, draw_gc, 166 XSetForeground(dpy, draw_gc,
173 get_pixel_resource("foreground", "Foreground", dpy, cmap)); 167 get_pixel_resource("foreground", "Foreground", dpy, cmap));
174 168
175 XDrawString(dpy, window, draw_gc, x, y, text, strlen(text)); 169 XDrawString(dpy, window, draw_gc, x*display_zoom, y*display_zoom, text, strlen(text));
176} 170}
177 171
178/* this is where the applicaton starts */ 172/* this is where the applicaton starts */