242 |
shutdown_loop(context); |
shutdown_loop(context); |
243 |
} |
} |
244 |
|
|
245 |
|
/* draw shape */ |
246 |
|
#define ARROW_BORDER 20 |
247 |
|
#define CORNER_RADIUS 10 |
248 |
|
|
249 |
|
static void popup_window_shape(GtkWidget *window, int tip_x, int tip_y) { |
250 |
|
GdkBitmap *mask = gdk_pixmap_new(NULL, POPUP_WIDTH, POPUP_HEIGHT, 1); |
251 |
|
|
252 |
|
GdkGC *gc = gdk_gc_new(mask); |
253 |
|
GdkColormap *colormap; |
254 |
|
GdkColor black; |
255 |
|
GdkColor white; |
256 |
|
|
257 |
|
/* get black/white color values */ |
258 |
|
colormap = gdk_colormap_get_system(); |
259 |
|
gdk_color_black(colormap, &black); |
260 |
|
gdk_color_white(colormap, &white); |
261 |
|
|
262 |
|
/* erase */ |
263 |
|
gdk_gc_set_foreground(gc, &black); |
264 |
|
gdk_gc_set_background(gc, &white); |
265 |
|
|
266 |
|
/* erase background */ |
267 |
|
gdk_draw_rectangle(mask, gc, TRUE, 0, 0, POPUP_WIDTH, POPUP_HEIGHT); |
268 |
|
|
269 |
|
gdk_gc_set_foreground(gc, &white); |
270 |
|
gdk_gc_set_background(gc, &black); |
271 |
|
|
272 |
|
gdk_draw_rectangle(mask, gc, TRUE, |
273 |
|
0, ARROW_BORDER + CORNER_RADIUS, |
274 |
|
POPUP_WIDTH, |
275 |
|
POPUP_HEIGHT - 2*CORNER_RADIUS - 2*ARROW_BORDER); |
276 |
|
|
277 |
|
gdk_draw_rectangle(mask, gc, TRUE, |
278 |
|
CORNER_RADIUS, ARROW_BORDER, |
279 |
|
POPUP_WIDTH - 2*CORNER_RADIUS, |
280 |
|
POPUP_HEIGHT - 2*ARROW_BORDER); |
281 |
|
|
282 |
|
int off[][2] = { |
283 |
|
{ CORNER_RADIUS, ARROW_BORDER + CORNER_RADIUS }, |
284 |
|
{ POPUP_WIDTH - CORNER_RADIUS, |
285 |
|
ARROW_BORDER + CORNER_RADIUS }, |
286 |
|
{ POPUP_WIDTH - CORNER_RADIUS, |
287 |
|
POPUP_HEIGHT - CORNER_RADIUS - ARROW_BORDER }, |
288 |
|
{ CORNER_RADIUS, |
289 |
|
POPUP_HEIGHT - CORNER_RADIUS - ARROW_BORDER}}; |
290 |
|
|
291 |
|
int i; |
292 |
|
for(i=0;i<4;i++) { |
293 |
|
gdk_draw_arc(mask, gc, TRUE, |
294 |
|
off[i][0]-CORNER_RADIUS, off[i][1]-CORNER_RADIUS, |
295 |
|
2*CORNER_RADIUS, 2*CORNER_RADIUS, |
296 |
|
0, 360*64); |
297 |
|
} |
298 |
|
|
299 |
|
GdkPoint points[3] = { {POPUP_WIDTH*1/3, POPUP_HEIGHT/2}, |
300 |
|
{POPUP_WIDTH*2/3, POPUP_HEIGHT/2}, |
301 |
|
{tip_x,tip_y} }; |
302 |
|
gdk_draw_polygon(mask, gc, TRUE, points, 3); |
303 |
|
|
304 |
|
|
305 |
|
gdk_window_shape_combine_mask(window->window, mask, 0, 0); |
306 |
|
} |
307 |
|
|
308 |
void cache_popup(map_context_t *mcontext, cache_t *cache) { |
void cache_popup(map_context_t *mcontext, cache_t *cache) { |
309 |
popup_context_t pcontext; |
popup_context_t pcontext; |
310 |
pcontext.appdata = mcontext->appdata; |
pcontext.appdata = mcontext->appdata; |
362 |
if(sy > mcontext->widget->allocation.height/2) |
if(sy > mcontext->widget->allocation.height/2) |
363 |
ay = POPUP_HEIGHT; |
ay = POPUP_HEIGHT; |
364 |
|
|
365 |
|
#if !defined(USE_HILDON) || (MAEMO_VERSION_MAJOR < 5) |
366 |
|
GdkColor color; |
367 |
|
gdk_color_parse("darkgray", &color); |
368 |
|
gtk_widget_modify_bg(GTK_WIDGET(pcontext.window), GTK_STATE_NORMAL, &color); |
369 |
|
#endif |
370 |
|
|
371 |
gtk_window_move(GTK_WINDOW(pcontext.window), |
gtk_window_move(GTK_WINDOW(pcontext.window), |
372 |
x + mcontext->widget->allocation.x + sx - ax, |
x + mcontext->widget->allocation.x + sx - ax, |
373 |
y + mcontext->widget->allocation.y + sy - ay); |
y + mcontext->widget->allocation.y + sy - ay); |
374 |
|
|
375 |
/* a frame with a vscale inside */ |
|
376 |
GtkWidget *frame = gtk_frame_new(NULL); |
GtkWidget *frame = gtk_frame_new(NULL); |
377 |
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT); |
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); |
378 |
|
gtk_container_set_border_width(GTK_CONTAINER(frame), |
379 |
|
ARROW_BORDER+CORNER_RADIUS); |
380 |
|
gtk_container_add(GTK_CONTAINER(frame), |
381 |
|
gtk_button_new_with_label(cache->name)); |
382 |
|
|
|
gtk_container_add(GTK_CONTAINER(frame), gtk_label_new(cache->name)); |
|
383 |
gtk_container_add(GTK_CONTAINER(pcontext.window), frame); |
gtk_container_add(GTK_CONTAINER(pcontext.window), frame); |
384 |
|
|
385 |
|
/* --------- give the window its shape ----------- */ |
386 |
|
popup_window_shape(pcontext.window, ax, ay); |
387 |
|
|
388 |
gtk_widget_show_all(pcontext.window); |
gtk_widget_show_all(pcontext.window); |
389 |
|
|
390 |
/* handle this popup until it's gone */ |
/* handle this popup until it's gone */ |