/************************************************************************** ... **************************************************************************/ void map_canvas_expose(Widget w, XEvent *event, Region exposed, void *client_data) { Dimension width, height; bool map_resized; XtVaGetValues(w, XtNwidth, &width, XtNheight, &height, NULL); map_resized = map_canvas_resized(width, height); if (!can_client_change_view()) { if (!intro_gfx_sprite) { load_intro_gfx(); } if (height != scaled_intro_pixmap_height || width != scaled_intro_pixmap_width) { if (scaled_intro_pixmap) { XFreePixmap(display, scaled_intro_pixmap); } scaled_intro_pixmap=x_scale_pixmap(intro_gfx_sprite->pixmap, intro_gfx_sprite->width, intro_gfx_sprite->height, width, height, root_window); scaled_intro_pixmap_width=width; scaled_intro_pixmap_height=height; } if(scaled_intro_pixmap) XCopyArea(display, scaled_intro_pixmap, XtWindow(map_canvas), civ_gc, event->xexpose.x, event->xexpose.y, event->xexpose.width, event->xexpose.height, event->xexpose.x, event->xexpose.y); return; } if(scaled_intro_pixmap) { XFreePixmap(display, scaled_intro_pixmap); scaled_intro_pixmap=0; scaled_intro_pixmap_height=0; } if (map_exists() && !map_resized) { /* First we mark the area to be updated as dirty. Then we unqueue * any pending updates, to make sure only the most up-to-date data * is written (otherwise drawing bugs happen when old data is copied * to screen). Then we draw all changed areas to the screen. */ unqueue_mapview_updates(FALSE); XCopyArea(display, mapview.store->pixmap, XtWindow(map_canvas), civ_gc, event->xexpose.x, event->xexpose.y, event->xexpose.width, event->xexpose.height, event->xexpose.x, event->xexpose.y); } refresh_overview_canvas(); }
/************************************************************************** Redraw map canvas. **************************************************************************/ gboolean map_canvas_draw(GtkWidget *w, cairo_t *cr, gpointer data) { if (can_client_change_view() && map_exists() && !mapview_is_frozen()) { /* First we mark the area to be updated as dirty. Then we unqueue * any pending updates, to make sure only the most up-to-date data * is written (otherwise drawing bugs happen when old data is copied * to screen). Then we draw all changed areas to the screen. */ unqueue_mapview_updates(FALSE); cairo_set_source_surface(cr, mapview.store->surface, 0, 0); cairo_paint(cr); } return TRUE; }
/************************************************************************** Map canvas exposed **************************************************************************/ gboolean map_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer data) { if (can_client_change_view() && map_exists() && !mapview_is_frozen()) { /* First we mark the area to be updated as dirty. Then we unqueue * any pending updates, to make sure only the most up-to-date data * is written (otherwise drawing bugs happen when old data is copied * to screen). Then we draw all changed areas to the screen. */ unqueue_mapview_updates(FALSE); gdk_draw_drawable(map_canvas->window, civ_gc, mapview.store->v.pixmap, ev->area.x, ev->area.y, ev->area.x, ev->area.y, ev->area.width, ev->area.height); } return TRUE; }
/************************************************************************** ... **************************************************************************/ gboolean map_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer data) { static bool cleared = FALSE; if (!can_client_change_view()) { if (!cleared) { gtk_widget_queue_draw(w); cleared = TRUE; } map_center = TRUE; } else { if (map_exists()) { /* do we have a map at all */ /* First we mark the area to be updated as dirty. Then we unqueue * any pending updates, to make sure only the most up-to-date data * is written (otherwise drawing bugs happen when old data is copied * to screen). Then we draw all changed areas to the screen. */ unqueue_mapview_updates(FALSE); gdk_draw_drawable(map_canvas->window, civ_gc, mapview.store->v.pixmap, ev->area.x, ev->area.y, ev->area.x, ev->area.y, ev->area.width, ev->area.height); cleared = FALSE; } else { if (!cleared) { gtk_widget_queue_draw(w); cleared = TRUE; } } if (!map_center) { center_on_something(); map_center = FALSE; } } map_configure = FALSE; return TRUE; }
/************************************************************************** This function will reset the mouse cursor if it leaves the map. **************************************************************************/ gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event) { if (gtk_notebook_get_current_page(GTK_NOTEBOOK(top_notebook)) != gtk_notebook_page_num(GTK_NOTEBOOK(top_notebook), map_widget)) { /* Map is not currently topmost tab. Do not use tile specific cursors. */ update_mouse_cursor(CURSOR_DEFAULT); return TRUE; } /* Bizarrely, this function can be called even when we don't "leave" * the map canvas, for instance, it gets called any time the mouse is * clicked. */ if (map_exists() && event->x >= 0 && event->y >= 0 && event->x < mapview.width && event->y < mapview.height) { control_mouse_cursor(canvas_pos_to_tile(event->x, event->y)); } else { update_mouse_cursor(CURSOR_DEFAULT); } update_unit_info_label(get_units_in_focus()); return TRUE; }