summaryrefslogtreecommitdiff
path: root/navit/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'navit/graphics')
-rw-r--r--navit/graphics/Makefile.am11
-rw-r--r--navit/graphics/gtk_drawing_area/Makefile.am5
-rw-r--r--navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c916
-rw-r--r--navit/graphics/gtk_gl_ext/graphics_gtk_gl_ext.c333
-rw-r--r--navit/graphics/null/Makefile.am4
-rw-r--r--navit/graphics/null/graphics_null.c208
-rw-r--r--navit/graphics/opengl/Makefile.am5
-rw-r--r--navit/graphics/opengl/graphics_opengl.c826
-rw-r--r--navit/graphics/qt_qpainter/Makefile.am5
-rw-r--r--navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp682
-rw-r--r--navit/graphics/win32/Makefile.am4
-rw-r--r--navit/graphics/win32/graphics_win32.c794
-rw-r--r--navit/graphics/win32/resources/resource.h4
-rw-r--r--navit/graphics/win32/win32_gui.h75
-rw-r--r--navit/graphics/win32/xpm2bmp.c589
-rw-r--r--navit/graphics/win32/xpm2bmp.h44
16 files changed, 0 insertions, 4505 deletions
diff --git a/navit/graphics/Makefile.am b/navit/graphics/Makefile.am
deleted file mode 100644
index 450fb182..00000000
--- a/navit/graphics/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-SUBDIRS=null
-if GRAPHICS_GTK_DRAWING_AREA
- SUBDIRS+=gtk_drawing_area
-endif
-if GRAPHICS_OPENGL
- SUBDIRS+=opengl
-endif
-if USE_GRAPHICS_QT_QPAINTER
- SUBDIRS+=qt_qpainter
-endif
-SUBDIRS+=win32
diff --git a/navit/graphics/gtk_drawing_area/Makefile.am b/navit/graphics/gtk_drawing_area/Makefile.am
deleted file mode 100644
index ec6f642c..00000000
--- a/navit/graphics/gtk_drawing_area/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(top_srcdir)/Makefile.inc
-AM_CPPFLAGS = @GTK2_CFLAGS@ @FREETYPE2_CFLAGS@ @FONTCONFIG_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=graphics_gtk_drawing_area
-modulegraphics_LTLIBRARIES = libgraphics_gtk_drawing_area.la
-libgraphics_gtk_drawing_area_la_SOURCES = graphics_gtk_drawing_area.c
-libgraphics_gtk_drawing_area_la_LDFLAGS = @GTK2_LIBS@ @FREETYPE2_LIBS@ @FONTCONFIG_LIBS@ @IMLIB2_LIBS@
diff --git a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
deleted file mode 100644
index 90d7ddd6..00000000
--- a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
+++ /dev/null
@@ -1,916 +0,0 @@
-#define GDK_ENABLE_BROKEN
-#include "config.h"
-#include <gtk/gtk.h>
-#include <fontconfig/fontconfig.h>
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#ifdef HAVE_IMLIB2
-#include <Imlib2.h>
-#endif
-
-#ifndef _WIN32
-#include <gdk/gdkx.h>
-#endif
-#include "debug.h"
-#include "point.h"
-#include "graphics.h"
-#include "color.h"
-#include "plugin.h"
-
-struct graphics_priv {
- GdkEventButton button_event;
- int button_timeout;
- GtkWidget *widget;
- GtkWidget *win;
- GdkDrawable *drawable;
- GdkDrawable *background;
- int background_ready;
- GdkColormap *colormap;
- FT_Library library;
- struct point p;
- int width;
- int height;
- int library_init;
- int visible;
- struct graphics_priv *parent;
- struct graphics_priv *overlays;
- struct graphics_priv *next;
- struct graphics_gc_priv *background_gc;
- enum draw_mode_num mode;
- void (*resize_callback)(void *data, int w, int h);
- void *resize_callback_data;
- void (*motion_callback)(void *data, struct point *p);
- void *motion_callback_data;
- void (*button_callback)(void *data, int press, int button, struct point *p);
- void *button_callback_data;
-};
-
-struct graphics_font_priv {
- FT_Face face;
-};
-
-struct graphics_gc_priv {
- GdkGC *gc;
- struct graphics_priv *gr;
-};
-
-struct graphics_image_priv {
- GdkPixbuf *pixbuf;
- int w;
- int h;
-};
-
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
- FcFini();
-}
-
-/**
- * List of font families to use, in order of preference
- */
-static char *fontfamilies[]={
- "Liberation Mono",
- "Arial",
- "DejaVu Sans",
- "NcrBI4nh",
- "luximbi",
- "FreeSans",
- NULL,
-};
-
-static void font_destroy(struct graphics_font_priv *font)
-{
- g_free(font);
- /* TODO: free font->face */
-}
-
-static struct graphics_font_methods font_methods = {
- font_destroy
-};
-
-/**
- * Load a new font using the fontconfig library.
- * First search for each of the font families and require and exact match on family
- * If no font found, let fontconfig pick the best match
- */
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
-{
- struct graphics_font_priv *font=g_new(struct graphics_font_priv, 1);
-
- *meth=font_methods;
- int exact, found;
- char **family;
-
- if (!gr->library_init) {
- FT_Init_FreeType( &gr->library );
- gr->library_init=1;
- }
- found=0;
- for (exact=1;!found && exact>=0;exact--) {
- family=fontfamilies;
- while (*family && !found) {
- dbg(1, "Looking for font family %s. exact=%d\n", *family, exact);
- FcPattern *required = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, *family, NULL);
- if (flags)
- FcPatternAddInteger(required,FC_WEIGHT,FC_WEIGHT_BOLD);
- FcConfigSubstitute(FcConfigGetCurrent(), required, FcMatchFont);
- FcDefaultSubstitute(required);
- FcResult result;
- FcPattern *matched = FcFontMatch(FcConfigGetCurrent(), required, &result);
- if (matched) {
- FcValue v1, v2;
- FcChar8 *fontfile;
- int fontindex;
- FcPatternGet(required, FC_FAMILY, 0, &v1);
- FcPatternGet(matched, FC_FAMILY, 0, &v2);
- FcResult r1 = FcPatternGetString(matched, FC_FILE, 0, &fontfile);
- FcResult r2 = FcPatternGetInteger(matched, FC_INDEX, 0, &fontindex);
- if ((r1 == FcResultMatch) && (r2 == FcResultMatch) && (FcValueEqual(v1,v2) || !exact)) {
- dbg(2, "About to load font from file %s index %d\n", fontfile, fontindex);
- FT_New_Face( gr->library, (char *)fontfile, fontindex, &font->face );
- found=1;
- }
- FcPatternDestroy(matched);
- }
- FcPatternDestroy(required);
- family++;
- }
- }
- if (!found) {
- g_warning("Failed to load font, no labelling");
- g_free(font);
- return NULL;
- }
- FT_Set_Char_Size(font->face, 0, size, 300, 300);
- FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
- return font;
-}
-
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
- g_object_unref(gc->gc);
- g_free(gc);
-}
-
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gdk_gc_set_line_attributes(gc->gc, w, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-}
-
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
- gdk_gc_set_dashes(gc->gc, offset, (gint8 *)dash_list, n);
- gdk_gc_set_line_attributes(gc->gc, w, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-}
-
-static void
-gc_set_color(struct graphics_gc_priv *gc, struct color *c, int fg)
-{
- GdkColor gdkc;
- gdkc.pixel=0;
- gdkc.red=c->r;
- gdkc.green=c->g;
- gdkc.blue=c->b;
- gdk_colormap_alloc_color(gc->gr->colormap, &gdkc, FALSE, TRUE);
- if (fg)
- gdk_gc_set_foreground(gc->gc, &gdkc);
- else
- gdk_gc_set_background(gc->gc, &gdkc);
-}
-
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- gc_set_color(gc, c, 1);
-}
-
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
- gc_set_color(gc, c, 0);
-}
-
-static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
-};
-
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
-
- *meth=gc_methods;
- gc->gc=gdk_gc_new(gr->widget->window);
- gc->gr=gr;
- return gc;
-}
-
-
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot)
-{
- GdkPixbuf *pixbuf;
- struct graphics_image_priv *ret;
- const char *option;
-
- pixbuf=gdk_pixbuf_new_from_file(name, NULL);
- if (! pixbuf)
- return NULL;
- ret=g_new0(struct graphics_image_priv, 1);
- ret->pixbuf=pixbuf;
- ret->w=gdk_pixbuf_get_width(pixbuf);
- ret->h=gdk_pixbuf_get_height(pixbuf);
- *w=ret->w;
- *h=ret->h;
- if (hot) {
- option=gdk_pixbuf_get_option(pixbuf, "x_hot");
- if (option)
- hot->x=atoi(option);
- else
- hot->x=ret->w/2-1;
- option=gdk_pixbuf_get_option(pixbuf, "y_hot");
- if (option)
- hot->y=atoi(option);
- else
- hot->y=ret->h/2-1;
- }
- return ret;
-}
-
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
- if (priv->pixbuf)
- g_object_unref(priv->pixbuf);
- g_free(priv);
-}
-
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
- gdk_draw_lines(gr->drawable, gc->gc, (GdkPoint *)p, count);
- if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
- gdk_draw_lines(gr->widget->window, gc->gc, (GdkPoint *)p, count);
-}
-
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
- gdk_draw_polygon(gr->drawable, gc->gc, TRUE, (GdkPoint *)p, count);
- if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
- gdk_draw_polygon(gr->widget->window, gc->gc, TRUE, (GdkPoint *)p, count);
-}
-
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- gdk_draw_rectangle(gr->drawable, gc->gc, TRUE, p->x, p->y, w, h);
-}
-
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
- gdk_draw_arc(gr->drawable, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360);
- if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
- gdk_draw_arc(gr->widget->window, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360);
-}
-
-
-struct text_glyph {
- int x,y,w,h;
- GdkImage *shadow;
- unsigned char pixmap[0];
-};
-
-struct text_render {
- int x1,y1;
- int x2,y2;
- int x3,y3;
- int x4,y4;
- int glyph_count;
- struct text_glyph *glyph[0];
-};
-
-#ifndef _WIN32
-static GdkImage *
-display_text_render_shadow(struct text_glyph *g)
-{
- int mask0, mask1, mask2, x, y, w=g->w, h=g->h;
- int str=(g->w+9)/8;
- unsigned char *shadow;
- unsigned char *p, *pm=g->pixmap;
- GdkImage *ret;
-
- shadow=malloc(str*(g->h+2)); /* do not use g_malloc() here */
- memset(shadow, 0, str*(g->h+2));
- for (y = 0 ; y < h ; y++) {
- p=shadow+str*y;
- mask0=0x4000;
- mask1=0xe000;
- mask2=0x4000;
- for (x = 0 ; x < w ; x++) {
- if (pm[x+y*w]) {
- p[0]|=(mask0 >> 8);
- if (mask0 & 0xff)
- p[1]|=mask0;
-
- p[str]|=(mask1 >> 8);
- if (mask1 & 0xff)
- p[str+1]|=mask1;
- p[str*2]|=(mask2 >> 8);
- if (mask2 & 0xff)
- p[str*2+1]|=mask2;
- }
- mask0 >>= 1;
- mask1 >>= 1;
- mask2 >>= 1;
- if (!((mask0 >> 8) | (mask1 >> 8) | (mask2 >> 8))) {
- mask0<<=8;
- mask1<<=8;
- mask2<<=8;
- p++;
- }
- }
- }
- ret=gdk_image_new_bitmap(gdk_visual_get_system(), shadow, g->w+2, g->h+2);
- return ret;
-}
-#else
-static GdkImage *
-display_text_render_shadow(struct text_glyph *g)
-{
- int mask0, mask1, mask2, x, y, w=g->w, h=g->h;
- int str=(g->w+9)/8;
- unsigned char *p, *pm=g->pixmap;
- GdkImage *ret;
-
- ret=gdk_image_new( GDK_IMAGE_NORMAL , gdk_visual_get_system(), w+2, h+2);
-
- for (y = 0 ; y < h ; y++) {
- p=ret->mem+str*y;
-
- mask0=0x4000;
- mask1=0xe000;
- mask2=0x4000;
- for (x = 0 ; x < w ; x++) {
- if (pm[x+y*w]) {
- p[0]|=(mask0 >> 8);
- if (mask0 & 0xff)
- p[1]|=mask0;
-
- p[str]|=(mask1 >> 8);
- if (mask1 & 0xff)
- p[str+1]|=mask1;
- p[str*2]|=(mask2 >> 8);
- if (mask2 & 0xff)
- p[str*2+1]|=mask2;
- }
- mask0 >>= 1;
- mask1 >>= 1;
- mask2 >>= 1;
- if (!((mask0 >> 8) | (mask1 >> 8) | (mask2 >> 8))) {
- mask0<<=8;
- mask1<<=8;
- mask2<<=8;
- }
- }
- }
- return ret;
-}
-#endif
-
-static struct text_render *
-display_text_render(char *text, struct graphics_font_priv *font, int dx, int dy, int x, int y)
-{
- FT_GlyphSlot slot = font->face->glyph; // a small shortcut
- FT_Matrix matrix;
- FT_Vector pen;
- FT_UInt glyph_index;
- int n,len;
- struct text_render *ret;
- struct text_glyph *curr;
- char *p=text;
-
- len=g_utf8_strlen(text, -1);
- ret=g_malloc(sizeof(*ret)+len*sizeof(struct text_glyph *));
- ret->glyph_count=len;
-
- matrix.xx = dx;
- matrix.xy = dy;
- matrix.yx = -dy;
- matrix.yy = dx;
-
- pen.x = 0 * 64;
- pen.y = 0 * 64;
- x <<= 6;
- y <<= 6;
- FT_Set_Transform( font->face, &matrix, &pen );
-
- for ( n = 0; n < len; n++ )
- {
-
- glyph_index = FT_Get_Char_Index(font->face, g_utf8_get_char(p));
- FT_Load_Glyph(font->face, glyph_index, FT_LOAD_DEFAULT );
- FT_Render_Glyph(font->face->glyph, ft_render_mode_normal );
-
- curr=g_malloc(sizeof(*curr)+slot->bitmap.rows*slot->bitmap.pitch);
- ret->glyph[n]=curr;
-
- curr->x=(x>>6)+slot->bitmap_left;
- curr->y=(y>>6)-slot->bitmap_top;
- curr->w=slot->bitmap.width;
- curr->h=slot->bitmap.rows;
- if (slot->bitmap.width && slot->bitmap.rows) {
- memcpy(curr->pixmap, slot->bitmap.buffer, slot->bitmap.rows*slot->bitmap.pitch);
- curr->shadow=display_text_render_shadow(curr);
- }
- else
- curr->shadow=NULL;
-#if 0
- printf("height=%d\n", slot->metrics.height);
- printf("height2=%d\n", face->height);
- printf("bbox %d %d %d %d\n", face->bbox.xMin, face->bbox.yMin, face->bbox.xMax, face->bbox.yMax);
-#endif
- x += slot->advance.x;
- y -= slot->advance.y;
- p=g_utf8_next_char(p);
- }
- return ret;
-}
-
-static void
-display_text_draw(struct text_render *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg)
-{
- int i;
- struct text_glyph *g, **gp;
-
- gp=text->glyph;
- i=text->glyph_count;
- while (i-- > 0)
- {
- g=*gp++;
- if (g->shadow && bg)
- gdk_draw_image(gr->drawable, bg->gc, g->shadow, 0, 0, g->x-1, g->y-1, g->w+2, g->h+2);
- }
- gp=text->glyph;
- i=text->glyph_count;
- while (i-- > 0)
- {
- g=*gp++;
- if (g->w && g->h)
- gdk_draw_gray_image(gr->drawable, fg->gc, g->x, g->y, g->w, g->h, GDK_RGB_DITHER_NONE, g->pixmap, g->w);
- }
-}
-
-static void
-display_text_free(struct text_render *text)
-{
- int i;
- struct text_glyph **gp;
-
- gp=text->glyph;
- i=text->glyph_count;
- while (i-- > 0) {
- if ((*gp)->shadow) {
- g_object_unref((*gp)->shadow);
- }
- g_free(*gp++);
- }
- g_free(text);
-}
-
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- struct text_render *t;
-
- if (! font)
- return;
- if (bg) {
- gdk_gc_set_function(fg->gc, GDK_AND_INVERT);
- gdk_gc_set_function(bg->gc, GDK_OR);
- }
-
- t=display_text_render(text, font, dx, dy, p->x, p->y);
- display_text_draw(t, gr, fg, bg);
- display_text_free(t);
- if (bg) {
- gdk_gc_set_function(fg->gc, GDK_COPY);
- gdk_gc_set_function(bg->gc, GDK_COPY);
- }
-}
-
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- gdk_draw_pixbuf(gr->drawable, fg->gc, img->pixbuf, 0, 0, p->x, p->y,
- img->w, img->h, GDK_RGB_DITHER_NONE, 0, 0);
-}
-
-#ifdef HAVE_IMLIB2
-static void
-draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data)
-{
- void *image;
- int w,h;
- dbg(1,"draw_image_warp data=%s\n", data);
- image = imlib_load_image(data);
- imlib_context_set_display(gdk_x11_drawable_get_xdisplay(gr->widget->window));
- imlib_context_set_colormap(gdk_x11_colormap_get_xcolormap(gtk_widget_get_colormap(gr->widget)));
- imlib_context_set_visual(gdk_x11_visual_get_xvisual(gtk_widget_get_visual(gr->widget)));
- imlib_context_set_drawable(gdk_x11_drawable_get_xid(gr->drawable));
- imlib_context_set_image(image);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- if (count == 3) {
- /* 0 1
- 2 */
- imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, p[1].y-p[0].y, p[2].x-p[0].x, p[2].y-p[0].y);
- }
- if (count == 2) {
- /* 0
- 1 */
- imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, 0, 0, p[1].y-p[0].y);
- }
- if (count == 1) {
- /*
- 0
- */
- imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x-w/2, p[0].y-h/2, w, 0, 0, h);
- }
-}
-#endif
-
-static void
-overlay_draw(struct graphics_priv *parent, struct graphics_priv *overlay, int window)
-{
- GdkPixbuf *pixbuf,*pixbuf2;
- GtkWidget *widget=parent->widget;
- guchar *pixels1, *pixels2, *p1, *p2;
- int x,y,w,h;
- int rowstride1,rowstride2;
- int n_channels1,n_channels2;
-
- if (! parent->drawable)
- return;
-
- w=overlay->width;
- if (w < 0)
- w+=parent->width;
- h=overlay->height;
- if (h < 0)
- h+=parent->height;
- pixbuf=gdk_pixbuf_get_from_drawable(NULL, overlay->drawable, NULL, 0, 0, 0, 0, w, h);
- pixbuf2=gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf), TRUE, gdk_pixbuf_get_bits_per_sample(pixbuf),
- gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
-
- rowstride1 = gdk_pixbuf_get_rowstride (pixbuf);
- rowstride2 = gdk_pixbuf_get_rowstride (pixbuf2);
- pixels1=gdk_pixbuf_get_pixels (pixbuf);
- pixels2=gdk_pixbuf_get_pixels (pixbuf2);
- n_channels1 = gdk_pixbuf_get_n_channels (pixbuf);
- n_channels2 = gdk_pixbuf_get_n_channels (pixbuf2);
- for (y = 0 ; y < h ; y++) {
- for (x = 0 ; x < w ; x++) {
- p1 = pixels1 + y * rowstride1 + x * n_channels1;
- p2 = pixels2 + y * rowstride2 + x * n_channels2;
- p2[0]=p1[0];
- p2[1]=p1[1];
- p2[2]=p1[2];
- p2[3]=127;
- }
- }
- x=overlay->p.x;
- if (x < 0)
- x+=parent->width;
- y=overlay->p.y;
- if (y < 0)
- y+=parent->height;
- if (window) {
- if (overlay->background_ready)
- gdk_draw_drawable(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], overlay->background, 0, 0, x, y, w, h);
- }
- else {
- gdk_draw_drawable(overlay->background, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, x, y, 0, 0, w, h);
- overlay->background_ready=1;
- }
- gdk_draw_pixbuf(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], pixbuf2, 0, 0, x, y, w, h, GDK_RGB_DITHER_NONE, 0, 0);
- if (window)
- gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, x, y, x, y, w, h);
- g_object_unref(pixbuf);
- g_object_unref(pixbuf2);
-#if 0
- gdk_draw_drawable(gr->gra->drawable,
- gr->gra->widget->style->fg_gc[GTK_WIDGET_STATE(gr->gra->widget)],
- img->gra->drawable,
- 0, 0, p->x, p->y, img->gra->width, img->gra->height);
-#endif
-}
-
-static void
-draw_restore(struct graphics_priv *gr, struct point *p, int w, int h)
-{
- GtkWidget *widget=gr->widget;
- gdk_draw_drawable(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- gr->drawable,
- p->x, p->y, p->x, p->y, w, h);
-
-}
-
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background_gc=gc;
-}
-
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- struct graphics_priv *overlay;
- GtkWidget *widget=gr->widget;
-
-#if 0
- if (mode == draw_mode_begin) {
- if (! gr->parent && gr->background_gc)
- gdk_draw_rectangle(gr->drawable, gr->background_gc->gc, TRUE, 0, 0, gr->width, gr->height);
- }
-#endif
- if (mode == draw_mode_end && gr->mode == draw_mode_begin) {
- if (gr->parent) {
- overlay_draw(gr->parent, gr, 1);
- } else {
- overlay=gr->overlays;
- while (overlay) {
- overlay_draw(gr, overlay, 0);
- overlay=overlay->next;
- }
- gdk_draw_drawable(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- gr->drawable,
- 0, 0, 0, 0, gr->width, gr->height);
- }
- }
- gr->mode=mode;
-}
-
-/* Events */
-
-static gint
-configure(GtkWidget * widget, GdkEventConfigure * event, gpointer user_data)
-{
- struct graphics_priv *gra=user_data;
- if (! gra->visible)
- return TRUE;
- if (gra->drawable != NULL) {
- g_object_unref(gra->drawable);
- }
- gra->width=widget->allocation.width;
- gra->height=widget->allocation.height;
- gra->drawable = gdk_pixmap_new(widget->window, gra->width, gra->height, -1);
- if (gra->resize_callback)
- (*gra->resize_callback)(gra->resize_callback_data, gra->width, gra->height);
- return TRUE;
-}
-
-static gint
-expose(GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
-{
- struct graphics_priv *gra=user_data;
-
- gra->visible=1;
- if (! gra->drawable)
- configure(widget, NULL, user_data);
- gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- gra->drawable, event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- return FALSE;
-}
-
-#if 0
-static gint
-button_timeout(gpointer user_data)
-{
-#if 0
- struct container *co=user_data;
- int x=co->gra->gra->button_event.x;
- int y=co->gra->gra->button_event.y;
- int button=co->gra->gra->button_event.button;
-
- co->gra->gra->button_timeout=0;
- popup(co, x, y, button);
-
- return FALSE;
-#endif
-}
-#endif
-
-static gint
-button_press(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
-
- p.x=event->x;
- p.y=event->y;
- if (this->button_callback)
- (*this->button_callback)(this->button_callback_data, 1, event->button, &p);
- return FALSE;
-}
-
-static gint
-button_release(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
-
- p.x=event->x;
- p.y=event->y;
- if (this->button_callback)
- (*this->button_callback)(this->button_callback_data, 0, event->button, &p);
- return FALSE;
-}
-
-static gint
-scroll(GtkWidget * widget, GdkEventScroll * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
- int button;
-
- p.x=event->x;
- p.y=event->y;
- if (this->button_callback) {
- switch (event->direction) {
- case GDK_SCROLL_UP:
- button=4;
- break;
- case GDK_SCROLL_DOWN:
- button=5;
- break;
- default:
- button=-1;
- break;
- }
- if (button != -1) {
- (*this->button_callback)(this->button_callback_data, 1, button, &p);
- (*this->button_callback)(this->button_callback_data, 0, button, &p);
- }
- }
- return FALSE;
-}
-
-static gint
-motion_notify(GtkWidget * widget, GdkEventMotion * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
-
- p.x=event->x;
- p.y=event->y;
- if (this->motion_callback)
- (*this->motion_callback)(this->motion_callback_data, &p);
- return FALSE;
-}
-
-static struct graphics_priv *graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth);
-
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h)
-{
- struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
- this->drawable=gdk_pixmap_new(gr->widget->window, w, h, -1);
- this->colormap=gr->colormap;
- this->widget=gr->widget;
- this->p=*p;
- this->width=w;
- this->height=h;
- this->parent=gr;
- this->background=gdk_pixmap_new(gr->widget->window, w, h, -1);
- this->next=gr->overlays;
- gr->overlays=this;
- return this;
-}
-
-static int gtk_argc;
-static char **gtk_argv={NULL};
-
-
-static void *
-get_data(struct graphics_priv *this, char *type)
-{
- if (!strcmp(type,"gtk_widget"))
- return this->widget;
- if (!strcmp(type,"window")) {
- gtk_init(&gtk_argc, &gtk_argv);
- gtk_set_locale();
- this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(this->win), 792, 547);
- gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
- gtk_widget_realize(this->win);
- gtk_container_add(GTK_CONTAINER(this->win), this->widget);
- gtk_widget_show_all(this->win);
- return this->win;
- }
- return NULL;
-}
-
-static void
-register_resize_callback(struct graphics_priv *this, void (*callback)(void *data, int w, int h), void *data)
-{
- this->resize_callback=callback;
- this->resize_callback_data=data;
-}
-
-static void
-register_motion_callback(struct graphics_priv *this, void (*callback)(void *data, struct point *p), void *data)
-{
- this->motion_callback=callback;
- this->motion_callback_data=data;
-}
-
-static void
-register_button_callback(struct graphics_priv *this, void (*callback)(void *data, int press, int button, struct point *p), void *data)
-{
- this->button_callback=callback;
- this->button_callback_data=data;
-}
-
-static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
-#ifdef HAVE_IMLIB2
- draw_image_warp,
-#else
- NULL,
-#endif
- draw_restore,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- register_resize_callback,
- register_button_callback,
- register_motion_callback,
- image_free,
-};
-
-static struct graphics_priv *
-graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth)
-{
- struct graphics_priv *this=g_new0(struct graphics_priv,1);
- *meth=graphics_methods;
-
- return this;
-}
-
-static struct graphics_priv *
-graphics_gtk_drawing_area_new(struct graphics_methods *meth, struct attr **attrs)
-{
- GtkWidget *draw;
-
- draw=gtk_drawing_area_new();
- struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
- this->widget=draw;
-
- this->colormap=gdk_colormap_new(gdk_visual_get_system(),FALSE);
- gtk_widget_set_events(draw, GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_KEY_PRESS_MASK);
- g_signal_connect(G_OBJECT(draw), "expose_event", G_CALLBACK(expose), this);
- g_signal_connect(G_OBJECT(draw), "configure_event", G_CALLBACK(configure), this);
-#if 0
- g_signal_connect(G_OBJECT(draw), "realize_event", G_CALLBACK(realize), co);
-#endif
- g_signal_connect(G_OBJECT(draw), "button_press_event", G_CALLBACK(button_press), this);
- g_signal_connect(G_OBJECT(draw), "button_release_event", G_CALLBACK(button_release), this);
- g_signal_connect(G_OBJECT(draw), "scroll_event", G_CALLBACK(scroll), this);
- g_signal_connect(G_OBJECT(draw), "motion_notify_event", G_CALLBACK(motion_notify), this);
- if (FcInit() != FcTrue)
- dbg(0, "Failed to init fontconfig");
- return this;
-}
-
-void
-plugin_init(void)
-{
- plugin_register_graphics_type("gtk_drawing_area", graphics_gtk_drawing_area_new);
-}
diff --git a/navit/graphics/gtk_gl_ext/graphics_gtk_gl_ext.c b/navit/graphics/gtk_gl_ext/graphics_gtk_gl_ext.c
deleted file mode 100644
index c91e94c6..00000000
--- a/navit/graphics/gtk_gl_ext/graphics_gtk_gl_ext.c
+++ /dev/null
@@ -1,333 +0,0 @@
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include <gtk/gtkgl.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include "point.h"
-#include "graphics.h"
-#include "container.h"
-
-
-struct graphics_gra {
- GtkWidget *widget;
- int width;
- int height;
- int library_init;
- int visible;
- int buffer;
-};
-
-struct graphics_font {
-};
-
-struct graphics_gc {
- double fr,fg,fb;
- double br,bg,bb;
- double width;
- struct graphics_gra *gra;
-};
-
-static struct graphics_font *font_new(struct graphics *gr, int size)
-{
- struct graphics_font *font=g_new(struct graphics_font, 1);
- return font;
-}
-
-static struct graphics_gc *gc_new(struct graphics *gr)
-{
- struct graphics_gc *gc=g_new(struct graphics_gc, 1);
-
- gc->fr=1;
- gc->fg=1;
- gc->fb=1;
- gc->br=0;
- gc->bg=0;
- gc->bb=0;
- gc->width=1;
- gc->gra=gr->gra;
- return gc;
-}
-
-static void
-gc_set_linewidth(struct graphics_gc *gc, int w)
-{
- gc->width=w;
-}
-
-static void
-gc_set_foreground(struct graphics_gc *gc, int r, int g, int b)
-{
- gc->fr=r/65535.0;
- gc->fg=g/65535.0;
- gc->fb=b/65535.0;
-}
-
-static void
-gc_set_background(struct graphics_gc *gc, int r, int g, int b)
-{
- gc->br=r/65535.0;
- gc->bg=g/65535.0;
- gc->bb=b/65535.0;
-}
-
-static void
-vertex(struct point *p)
-{
- double x,y;
- x=p->x;
- y=p->y;
- x/=792;
- y/=469;
- x-=0.5;
- y=0.5-y;
- glVertex3f(x,y,0);
-}
-
-static void
-draw_lines(struct graphics *gr, struct graphics_gc *gc, struct point *p, int count)
-{
- int i;
-
- glLineWidth(gc->width);
- glColor3f(gc->fr, gc->fg, gc->fb);
- glBegin(GL_LINE_STRIP);
- for (i=0 ; i < count ; i++)
- vertex(p++);
- glEnd();
-}
-
-static void
-draw_polygon(struct graphics *gr, struct graphics_gc *gc, struct point *p, int count)
-{
- int i;
- double x,y;
- glColor3f(gc->fr, gc->fg, gc->fb);
- glBegin(GL_POLYGON);
- for (i=0 ; i < count ; i++)
- vertex(p++);
- glEnd();
-}
-
-
-static void
-draw_circle(struct graphics *gr, struct graphics_gc *gc, struct point *p, int r)
-{
-
-}
-
-static void
-draw_text(struct graphics *gr, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, unsigned char *text, int x, int y, int dx, int dy)
-{
-}
-
-static void
-draw_begin(struct graphics *gr)
-{
- printf("draw_begin\n");
- glClearColor(gr->gc[0]->br, gr->gc[0]->bg, gr->gc[0]->bb, 0);
- glNewList(1, GL_COMPILE);
- gr->gra->buffer=1;
-}
-
-static void
-draw_end(struct graphics *gr)
-{
- printf("draw_end\n");
- glEndList();
- gr->gra->buffer=0;
-}
-
-static void realize(GtkWidget * widget, gpointer data)
-{
- GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
- GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);
-
- GLUquadricObj *qobj;
- static GLfloat light_diffuse[] = { 1.0, 0.0, 0.0, 1.0 };
- static GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
-
- /*** OpenGL BEGIN ***/
- if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
- return;
-
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
-#if 0
- glNewList(1, GL_COMPILE);
- gluSphere(qobj, 1.0, 20, 20);
- glBegin(GL_LINE_STRIP);
- glVertex3f(0.0,0.1,0.0);
- glVertex3f(0.1,0.1,0.0);
- glVertex3f(0.1,0.2,0.0);
- glVertex3f(0.2,0.2,0.0);
- glEnd();
- glEndList();
-#endif
-
-#if 0
- glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT0, GL_POSITION, light_position);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_DEPTH_TEST);
-#endif
-
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glClearDepth(1.0);
-
- glViewport(0, 0,
- widget->allocation.width, widget->allocation.height);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(19.0, 1.0, 1.0, 10.0);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
- glTranslatef(0.0, 0.0, 0.0);
-
- gdk_gl_drawable_gl_end(gldrawable);
- /*** OpenGL END ***/
-}
-
-static gboolean
-configure(GtkWidget * widget, GdkEventConfigure * event, gpointer user_data)
-{
- GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
- GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);
- struct container *co=user_data;
- struct graphics_gra *gra=co->gra->gra;
-
-
- printf("configure %d %d\n",gra->width, gra->height);
- gra->width=widget->allocation.width;
- gra->height=widget->allocation.height;
-
- /*** OpenGL BEGIN ***/
- if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
- return FALSE;
-
- glViewport(0, 0,
- widget->allocation.width, widget->allocation.height);
-
- gdk_gl_drawable_gl_end(gldrawable);
- /*** OpenGL END ***/
- if (gra->visible)
- graphics_resize(co, gra->width, gra->height);
-
- return TRUE;
-}
-
-static gboolean
-expose(GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
-{
- GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
- GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);
- struct container *co=user_data;
- struct graphics_gra *gra=co->gra->gra;
-
- printf("expose\n");
- if (! gra->visible) {
- gra->visible=1;
- configure(widget, NULL, user_data);
- }
- /*** OpenGL BEGIN ***/
- if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
- return FALSE;
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glCallList(1);
-
- if (gdk_gl_drawable_is_double_buffered(gldrawable))
- gdk_gl_drawable_swap_buffers(gldrawable);
- else
- glFlush();
-
- gdk_gl_drawable_gl_end(gldrawable);
- /*** OpenGL END ***/
-
- return TRUE;
-}
-
-
-struct graphics *
-graphics_gtk_gl_area_new(struct container *co, GtkWidget **widget)
-{
- GdkGLConfig *glconfig;
- gint major, minor;
- GtkWidget *drawing_area;
-
- struct graphics *this=g_new0(struct graphics,1);
- this->draw_lines=draw_lines;
- this->draw_polygon=draw_polygon;
- this->draw_circle=draw_circle;
- this->draw_text=draw_text;
-#if 0
- this->draw_begin=draw_begin;
- this->draw_end=draw_end;
-#endif
- this->gc_new=gc_new;
- this->gc_set_linewidth=gc_set_linewidth;
- this->gc_set_foreground=gc_set_foreground;
- this->gc_set_background=gc_set_background;
- this->font_new=font_new;
- this->gra=g_new0(struct graphics_gra, 1);
-
- /*
- * Init GtkGLExt.
- */
-
- gtk_gl_init(NULL, NULL);
-
- /*
- * Query OpenGL extension version.
- */
-
- gdk_gl_query_version(&major, &minor);
- g_print("OpenGL extension version - %d.%d\n", major, minor);
-
- /*
- * Configure OpenGL-capable visual.
- */
-
- /* Try double-buffered visual */
- glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB |
- GDK_GL_MODE_DEPTH |
- GDK_GL_MODE_DOUBLE);
- if (glconfig == NULL) {
- g_print("*** Cannot find the double-buffered visual.\n");
- g_print("*** Trying single-buffered visual.\n");
-
- /* Try single-buffered visual */
- glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB |
- GDK_GL_MODE_DEPTH);
- if (glconfig == NULL) {
- g_print
- ("*** No appropriate OpenGL-capable visual found.\n");
- exit(1);
- }
- }
-
-
- drawing_area = gtk_drawing_area_new();
-
- /* Set OpenGL-capability to the widget. */
- gtk_widget_set_gl_capability(drawing_area,
- glconfig,
- NULL, TRUE, GDK_GL_RGBA_TYPE);
-
- g_signal_connect_after(G_OBJECT(drawing_area), "realize",
- G_CALLBACK(realize), NULL);
- g_signal_connect(G_OBJECT(drawing_area), "configure_event",
- G_CALLBACK(configure), co);
- g_signal_connect(G_OBJECT(drawing_area), "expose_event",
- G_CALLBACK(expose), co);
-
- *widget=drawing_area;
- this->gra->widget=drawing_area;
- return this;
-}
-
-
diff --git a/navit/graphics/null/Makefile.am b/navit/graphics/null/Makefile.am
deleted file mode 100644
index 88c0e69a..00000000
--- a/navit/graphics/null/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-include $(top_srcdir)/Makefile.inc
-AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=graphics_null
-modulegraphics_LTLIBRARIES = libgraphics_null.la
-libgraphics_null_la_SOURCES = graphics_null.c
diff --git a/navit/graphics/null/graphics_null.c b/navit/graphics/null/graphics_null.c
deleted file mode 100644
index 8b87e22c..00000000
--- a/navit/graphics/null/graphics_null.c
+++ /dev/null
@@ -1,208 +0,0 @@
-#include <glib.h>
-#include "config.h"
-#include "point.h"
-#include "graphics.h"
-#include "color.h"
-#include "plugin.h"
-
-static int dummy;
-static struct graphics_priv {
- int dummy;
-} graphics_priv;
-
-static struct graphics_font_priv {
- int dummy;
-} graphics_font_priv;
-
-static struct graphics_gc_priv {
- int dummy;
-} graphics_gc_priv;
-
-static struct graphics_image_priv {
- int dummy;
-} graphics_image_priv;
-
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
-}
-
-static void font_destroy(struct graphics_font_priv *font)
-{
-
-}
-
-static struct graphics_font_methods font_methods = {
- font_destroy
-};
-
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size)
-{
- *meth=font_methods;
- return &graphics_font_priv;
-}
-
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
-}
-
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
-}
-
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
-}
-
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
-}
-
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
-}
-
-static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
-};
-
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- *meth=gc_methods;
- return &graphics_gc_priv;
-}
-
-
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h)
-{
- return &graphics_image_priv;
-}
-
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
-}
-
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
-}
-
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
-}
-
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
-}
-
-
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
-}
-
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
-}
-
-static void
-draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data)
-{
-}
-
-static void
-draw_restore(struct graphics_priv *gr, struct point *p, int w, int h)
-{
-}
-
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
-}
-
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
-}
-
-static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h);
-
-static void *
-get_data(struct graphics_priv *this, char *type)
-{
- return &dummy;
-}
-
-
-
-static void
-register_resize_callback(struct graphics_priv *this, void (*callback)(void *data, int w, int h), void *data)
-{
-}
-
-static void
-register_motion_callback(struct graphics_priv *this, void (*callback)(void *data, struct point *p), void *data)
-{
-}
-
-static void
-register_button_callback(struct graphics_priv *this, void (*callback)(void *data, int press, int button, struct point *p), void *data)
-{
-}
-
-static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
- draw_image_warp,
- draw_restore,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- register_resize_callback,
- register_button_callback,
- register_motion_callback,
-};
-
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h)
-{
- *meth=graphics_methods;
- return &graphics_priv;
-}
-
-
-static struct graphics_priv *
-graphics_null_new(struct graphics_methods *meth, struct attr **attrs)
-{
- *meth=graphics_methods;
- return &graphics_priv;
-}
-
-void
-plugin_init(void)
-{
- plugin_register_graphics_type("null", graphics_null_new);
-}
diff --git a/navit/graphics/opengl/Makefile.am b/navit/graphics/opengl/Makefile.am
deleted file mode 100644
index b0a25f38..00000000
--- a/navit/graphics/opengl/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(top_srcdir)/Makefile.inc
-AM_CPPFLAGS = @NAVIT_CFLAGS@ @OPENGL_CFLAGS@ @GLC_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=graphics_opengl
-modulegraphics_LTLIBRARIES = libgraphics_opengl.la
-libgraphics_opengl_la_SOURCES = graphics_opengl.c
-libgraphics_opengl_la_LIBADD = @OPENGL_LIBS@ @GLC_LIBS@
diff --git a/navit/graphics/opengl/graphics_opengl.c b/navit/graphics/opengl/graphics_opengl.c
deleted file mode 100644
index fce72f49..00000000
--- a/navit/graphics/opengl/graphics_opengl.c
+++ /dev/null
@@ -1,826 +0,0 @@
-#include <math.h>
-#include <glib.h>
-#include "config.h"
-#include <GL/glc.h>
-#include "point.h"
-#include "graphics.h"
-#include "color.h"
-#include "plugin.h"
-
-#include "debug.h"
-
-#include <GL/glut.h>
-
-
-void CALLBACK tessBeginCB(GLenum which);
-void CALLBACK tessEndCB();
-void CALLBACK tessErrorCB(GLenum errorCode);
-void CALLBACK tessVertexCB(const GLvoid *data);
-void CALLBACK tessVertexCB2(const GLvoid *data);
-void CALLBACK tessCombineCB(const GLdouble newVertex[3], const GLdouble *neighborVertex[4],
- const GLfloat neighborWeight[4], GLdouble **outData);
-
-
-struct graphics_priv {
- int button_timeout;
- struct point p;
- int width;
- int height;
- int library_init;
- int visible;
- struct graphics_priv *parent;
- struct graphics_priv *overlays;
- struct graphics_priv *next;
- struct graphics_gc_priv *background_gc;
- enum draw_mode_num mode;
- void (*resize_callback)(void *data, int w, int h);
- void *resize_callback_data;
- void (*motion_callback)(void *data, struct point *p);
- void *motion_callback_data;
- void (*button_callback)(void *data, int press, int button, struct point *p);
- void *button_callback_data;
- GLuint DLid;
-};
-
-struct graphics_font_priv {
-#if 0
- FT_Face face;
-#endif
-};
-
-struct graphics_gc_priv {
- struct graphics_priv *gr;
- float fr,fg,fb,fa;
- float br,bg,bb,ba;
- int linewidth;
-};
-
-struct graphics_image_priv {
- int w;
- int h;
-};
-
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
-}
-
-int frame=0;
-
-// http://quesoglc.sourceforge.net/tutorial.php
-
-
-static void font_destroy(struct graphics_font_priv *font)
-{
- g_free(font);
- /* TODO: free font->face */
-}
-
-static struct graphics_font_methods font_methods = {
- font_destroy
-};
-
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size)
-{
-#if 0
- char **filename=fontlist;
- struct graphics_font_priv *font=g_new(struct graphics_font_priv, 1);
-
- *meth=font_methods;
-
- if (!gr->library_init) {
- FT_Init_FreeType( &gr->library );
- gr->library_init=1;
- }
-
- while (*filename) {
- if (!FT_New_Face( gr->library, *filename, 0, &font->face ))
- break;
- filename++;
- }
- if (! *filename) {
- g_warning("Failed to load font, no labelling");
- g_free(font);
- return NULL;
- }
- FT_Set_Char_Size(font->face, 0, size, 300, 300);
- FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
- return font;
-#endif
- return NULL;
-}
-
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
- g_free(gc);
-}
-
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->linewidth=w;
-}
-
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char *dash_list, int n)
-{
-#if 0
- gdk_gc_set_dashes(gc->gc, offset, (gint8 *)dash_list, n);
- gdk_gc_set_line_attributes(gc->gc, width, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-#endif
-}
-
-
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->fr=c->r/65535.0;
- gc->fg=c->g/65535.0;
- gc->fb=c->b/65535.0;
- gc->fa=c->a/65535.0;
-// printf("new alpha : %i\n",c->a);
-}
-
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->br=c->r/65535.0;
- gc->bg=c->g/65535.0;
- gc->bb=c->b/65535.0;
- gc->ba=c->a/65535.0;
-}
-
-static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
-};
-
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
-
- *meth=gc_methods;
- gc->gr=gr;
- gc->linewidth=1;
- return gc;
-}
-
-
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h)
-{
-#if 0
- GdkPixbuf *pixbuf;
- struct graphics_image_priv *ret;
-
- pixbuf=gdk_pixbuf_new_from_file(name, NULL);
- if (! pixbuf)
- return NULL;
- ret=g_new0(struct graphics_image_priv, 1);
- ret->pixbuf=pixbuf;
- ret->w=gdk_pixbuf_get_width(pixbuf);
- ret->h=gdk_pixbuf_get_height(pixbuf);
- *w=ret->w;
- *h=ret->h;
- return ret;
-#endif
- return NULL;
-}
-
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
-/*
- if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
- gdk_draw_lines(gr->drawable, gc->gc, (GdkPoint *)p, count);
- if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
- gdk_draw_lines(gr->widget->window, gc->gc, (GdkPoint *)p, count);
-*/
- /*
- if(gr->mode == draw_mode_begin){
- printf("B");
- } else if (gr->mode == draw_mode_end){
- printf("E");
- } else {
- printf("x");
- }
-*/
-
- for (i = 0 ; i < count-1 ; i++) {
-
-// glEnable( GL_POLYGON_SMOOTH );
-// glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-// glEnable( GL_BLEND );
-
- float dx=p[i+1].x-p[i].x;
- float dy=p[i+1].y-p[i].y;
-
- float cx=(p[i+1].x+p[i].x)/2;
- float cy=(p[i+1].y+p[i].y)/2;
-// printf("(%lx,%lx) -> (%lx,%lx) : (%lx,%lx)\n",p[i].x,p[i].y,p[i+1].x,p[i+1].y,dx,dy);
-
- int w=round(sqrt(pow((dx),2)+pow((dy),2)));
-
- float angle=atan (dy/dx) * 180 / M_PI;
-
- glPushMatrix();
- glTranslatef(cx,cy,1);
- // glColor4f( 0,0,0,1);
- // glRasterPos2f( 1,1 );
- glRotatef(angle,0.0,0.0,1.0);
-
- glColor4f( gc->fr, gc->fg, gc->fb, gc->fa);
-
- int linewidth=gc->linewidth;
-
- glBegin( GL_POLYGON );
- glVertex2f( -w/2,-linewidth/2 );
- glVertex2f( -w/2-4,0 );
- glVertex2f( -w/2,+linewidth/2 );
- glVertex2f( +w/2,+linewidth/2 );
- glVertex2f( +w/2+4,0 );
- glVertex2f( +w/2,-linewidth/2 );
- glVertex2f( -w/2,+linewidth/2 );
- glEnd();
-
-
- // FIXME Roads label can maybe be drawn here, avoid the display_label loop, when playing with Z axis position.
- /*
- if(attr==1){
- glcRenderStyle(GLC_TEXTURE);
- glColor3f(0., 0., 0.);
- glScalef(12, 12, 0.);
- glcRenderString(">>");
- } else if(attr==-1){
- glcRenderStyle(GLC_TEXTURE);
- glColor3f(0., 0., 0.);
- glScalef(12, 12, 0.);
- glcRenderString("<<");
- }
-
- */
- glPopMatrix();
- }
-// glDisable( GL_BLEND );
-// glDisable( GL_POLYGON_SMOOTH );
-
-/*
- if(label){
- if((strlen(label)*6)<w){
- SDL_print(label,cx, cy,-angle);
- }
- }
-*/
-}
-
-
-const char* getPrimitiveType(GLenum type)
-{
- switch(type)
- {
- case 0x0000:
- return "GL_POINTS";
- break;
- case 0x0001:
- return "GL_LINES";
- break;
- case 0x0002:
- return "GL_LINE_LOOP";
- break;
- case 0x0003:
- return "GL_LINE_STRIP";
- break;
- case 0x0004:
- return "GL_TRIANGLES";
- break;
- case 0x0005:
- return "GL_TRIANGLE_STRIP";
- break;
- case 0x0006:
- return "GL_TRIANGLE_FAN";
- break;
- case 0x0007:
- return "GL_QUADS";
- break;
- case 0x0008:
- return "GL_QUAD_STRIP";
- break;
- case 0x0009:
- return "GL_POLYGON";
- break;
- }
-}
-
-void CALLBACK tessBeginCB(GLenum which)
-{
- glBegin(which);
-
- dbg(1,"glBegin( %s );\n",getPrimitiveType(which));
-}
-
-
-
-void CALLBACK tessEndCB()
-{
- glEnd();
-
- dbg(1,"glEnd();\n");
-}
-
-
-
-void CALLBACK tessVertexCB(const GLvoid *data)
-{
- // cast back to double type
- const GLdouble *ptr = (const GLdouble*)data;
-
- glVertex3dv(ptr);
-
- dbg(1," glVertex3d();\n");
-}
-
-
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
-
- GLUtesselator *tess = gluNewTess(); // create a tessellator
- if(!tess) return 0; // failed to create tessellation object, return 0
-
- GLdouble quad1[count][3];
- for (i = 0 ; i < count ; i++) {
- quad1[i][0]=(GLdouble)(p[i].x);
- quad1[i][1]=(GLdouble)(p[i].y);
- quad1[i][2]=0;
- }
-
-
- // register callback functions
- gluTessCallback(tess, GLU_TESS_BEGIN, (void (*)(void))tessBeginCB);
- gluTessCallback(tess, GLU_TESS_END, (void (*)(void))tessEndCB);
- // gluTessCallback(tess, GLU_TESS_ERROR, (void (*)(void))tessErrorCB);
- gluTessCallback(tess, GLU_TESS_VERTEX, (void (*)(void))tessVertexCB);
-
- // tessellate and compile a concave quad into display list
- // gluTessVertex() takes 3 params: tess object, pointer to vertex coords,
- // and pointer to vertex data to be passed to vertex callback.
- // The second param is used only to perform tessellation, and the third
- // param is the actual vertex data to draw. It is usually same as the second
- // param, but It can be more than vertex coord, for example, color, normal
- // and UV coords which are needed for actual drawing.
- // Here, we are looking at only vertex coods, so the 2nd and 3rd params are
- // pointing same address.
- glColor4f( gc->fr, gc->fg, gc->fb, gc->fa);
- gluTessBeginPolygon(tess, 0); // with NULL data
- gluTessBeginContour(tess);
- for (i = 0 ; i < count ; i++) {
- gluTessVertex(tess, quad1[i], quad1[i]);
- }
- gluTessEndContour(tess);
- gluTessEndPolygon(tess);
-
- gluDeleteTess(tess); // delete after tessellation
-
-}
-
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
-#if 0
- gdk_draw_rectangle(gr->drawable, gc->gc, TRUE, p->x, p->y, w, h);
-#endif
-}
-
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
-#if 0
- if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
- gdk_draw_arc(gr->drawable, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360);
- if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
- gdk_draw_arc(gr->widget->window, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360);
-#endif
-}
-
-
-
-void SDL_print(char * label,int x, int y, double angle)
-{
- glPushMatrix();
- glcRenderStyle(GLC_TEXTURE);
- glColor4f(0,0,0,1);
- glTranslatef(x, y, 1);
- glRotatef(180,1,0,0);
- glRotatef(angle,0,0,1);
-
- glScalef(14, 14, 14);
- // FIXME : add some error checking : glcGetError()
- glcRenderString(label);
- glPopMatrix();
-
-}
-
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
-// dbg(0,"%s : %i,%i, %f\n",text,dx,dy,(180*atan2(dx,dy)/3.14));
- SDL_print(text,p->x,p->y,(180*atan2(dx,dy)/3.14)-90);
-}
-
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
-#if 0
- gdk_draw_pixbuf(gr->drawable, fg->gc, img->pixbuf, 0, 0, p->x, p->y,
- img->w, img->h, GDK_RGB_DITHER_NONE, 0, 0);
-#endif
-}
-
-#ifdef HAVE_IMLIB2
-static void
-draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data)
-{
-#if 0
- void *image;
- int w,h;
- printf("draw_image_warp data=%s\n", data);
- image = imlib_load_image(data);
- imlib_context_set_display(gdk_x11_drawable_get_xdisplay(gr->widget->window));
- imlib_context_set_colormap(gdk_x11_colormap_get_xcolormap(gtk_widget_get_colormap(gr->widget)));
- imlib_context_set_visual(gdk_x11_visual_get_xvisual(gtk_widget_get_visual(gr->widget)));
- imlib_context_set_drawable(gdk_x11_drawable_get_xid(gr->drawable));
- imlib_context_set_image(image);
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- if (count == 3) {
- imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, p[1].y-p[0].y, p[2].x-p[0].x, p[2].y-p[0].y);
- }
- if (count == 2) {
- imlib_render_image_on_drawable_skewed(0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, 0, 0, p[1].y-p[0].y);
- }
-#endif
-}
-#endif
-
-static void
-overlay_draw(struct graphics_priv *parent, struct graphics_priv *overlay, int window)
-{
-#if 0
- GdkPixbuf *pixbuf,*pixbuf2;
- GtkWidget *widget=parent->widget;
- guchar *pixels1, *pixels2, *p1, *p2;
- int x,y;
- int rowstride1,rowstride2;
- int n_channels1,n_channels2;
-
- if (! parent->drawable)
- return;
-
- pixbuf=gdk_pixbuf_get_from_drawable(NULL, overlay->drawable, NULL, 0, 0, 0, 0, overlay->width, overlay->height);
- pixbuf2=gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf), TRUE, gdk_pixbuf_get_bits_per_sample(pixbuf),
- gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
-
- rowstride1 = gdk_pixbuf_get_rowstride (pixbuf);
- rowstride2 = gdk_pixbuf_get_rowstride (pixbuf2);
- pixels1=gdk_pixbuf_get_pixels (pixbuf);
- pixels2=gdk_pixbuf_get_pixels (pixbuf2);
- n_channels1 = gdk_pixbuf_get_n_channels (pixbuf);
- n_channels2 = gdk_pixbuf_get_n_channels (pixbuf2);
- for (y = 0 ; y < overlay->height ; y++) {
- for (x = 0 ; x < overlay->width ; x++) {
- p1 = pixels1 + y * rowstride1 + x * n_channels1;
- p2 = pixels2 + y * rowstride2 + x * n_channels2;
- p2[0]=p1[0];
- p2[1]=p1[1];
- p2[2]=p1[2];
- p2[3]=127;
- }
- }
- if (window)
- gdk_draw_pixmap(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], overlay->background, 0, 0, overlay->p.x, overlay->p.y, overlay->width, overlay->height);
- else
- gdk_draw_pixmap(overlay->background, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, overlay->p.x, overlay->p.y, 0, 0, overlay->width, overlay->height);
- gdk_draw_pixbuf(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], pixbuf2, 0, 0, overlay->p.x, overlay->p.y, overlay->width, overlay->height, GDK_RGB_DITHER_NONE, 0, 0);
- if (window)
- gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, overlay->p.x, overlay->p.y, overlay->p.x, overlay->p.y, overlay->width, overlay->height);
-#if 0
- gdk_draw_pixmap(gr->gra->drawable,
- gr->gra->widget->style->fg_gc[GTK_WIDGET_STATE(gr->gra->widget)],
- img->gra->drawable,
- 0, 0, p->x, p->y, img->gra->width, img->gra->height);
-#endif
-#endif
-}
-
-static void
-draw_restore(struct graphics_priv *gr, struct point *p, int w, int h)
-{
-#if 0
- GtkWidget *widget=gr->widget;
- gdk_draw_pixmap(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- gr->drawable,
- p->x, p->y, p->x, p->y, w, h);
-#endif
-
-}
-
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background_gc=gc;
-}
-
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- if (gr->DLid) {
- if (mode == draw_mode_begin)
- glNewList(gr->DLid,GL_COMPILE);
- if (mode == draw_mode_end)
- glEndList();
- }
-
-#if 0
- struct graphics_priv *overlay;
- GtkWidget *widget=gr->widget;
-
- if (mode == draw_mode_begin) {
- if (! gr->parent && gr->background_gc)
- gdk_draw_rectangle(gr->drawable, gr->background_gc->gc, TRUE, 0, 0, gr->width, gr->height);
- }
- if (mode == draw_mode_end && gr->mode == draw_mode_begin) {
- if (gr->parent) {
- overlay_draw(gr->parent, gr, 1);
- } else {
- overlay=gr->overlays;
- while (overlay) {
- overlay_draw(gr, overlay, 0);
- overlay=overlay->next;
- }
- gdk_draw_pixmap(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- gr->drawable,
- 0, 0, 0, 0, gr->width, gr->height);
- }
- }
- gr->mode=mode;
-#endif
-}
-
-#if 0
-/* Events */
-
-static gint
-configure(GtkWidget * widget, GdkEventConfigure * event, gpointer user_data)
-{
- struct graphics_priv *gra=user_data;
- if (! gra->visible)
- return TRUE;
- if (gra->drawable != NULL) {
- gdk_pixmap_unref(gra->drawable);
- }
- gra->width=widget->allocation.width;
- gra->height=widget->allocation.height;
- gra->drawable = gdk_pixmap_new(widget->window, gra->width, gra->height, -1);
- if (gra->resize_callback)
- (*gra->resize_callback)(gra->resize_callback_data, gra->width, gra->height);
- return TRUE;
-}
-
-static gint
-expose(GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
-{
- struct graphics_priv *gra=user_data;
-
- gra->visible=1;
- if (! gra->drawable)
- configure(widget, NULL, user_data);
- gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- gra->drawable, event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- return FALSE;
-}
-
-#if 0
-static gint
-button_timeout(gpointer user_data)
-{
-#if 0
- struct container *co=user_data;
- int x=co->gra->gra->button_event.x;
- int y=co->gra->gra->button_event.y;
- int button=co->gra->gra->button_event.button;
-
- co->gra->gra->button_timeout=0;
- popup(co, x, y, button);
-
- return FALSE;
-#endif
-}
-#endif
-
-static gint
-button_press(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
-
- p.x=event->x;
- p.y=event->y;
- if (this->button_callback)
- (*this->button_callback)(this->button_callback_data, 1, event->button, &p);
- return FALSE;
-}
-
-static gint
-button_release(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
-
- p.x=event->x;
- p.y=event->y;
- if (this->button_callback)
- (*this->button_callback)(this->button_callback_data, 0, event->button, &p);
- return FALSE;
-}
-
-static gint
-scroll(GtkWidget * widget, GdkEventScroll * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
- int button;
-
- p.x=event->x;
- p.y=event->y;
- if (this->button_callback) {
- switch (event->direction) {
- case GDK_SCROLL_UP:
- button=4;
- break;
- case GDK_SCROLL_DOWN:
- button=5;
- break;
- default:
- button=-1;
- break;
- }
- if (button != -1) {
- (*this->button_callback)(this->button_callback_data, 1, button, &p);
- (*this->button_callback)(this->button_callback_data, 0, button, &p);
- }
- }
- return FALSE;
-}
-
-static gint
-motion_notify(GtkWidget * widget, GdkEventMotion * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
-
- p.x=event->x;
- p.y=event->y;
- if (this->motion_callback)
- (*this->motion_callback)(this->motion_callback_data, &p);
- return FALSE;
-}
-
-#endif
-
-
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h)
-{
-#if 0
- struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
- this->drawable=gdk_pixmap_new(gr->widget->window, w, h, -1);
- this->colormap=gr->colormap;
- this->widget=gr->widget;
- this->p=*p;
- this->width=w;
- this->height=h;
- this->parent=gr;
- this->background=gdk_pixmap_new(gr->widget->window, w, h, -1);
- this->next=gr->overlays;
- gr->overlays=this;
- return this;
-#endif
- return NULL;
-}
-
-static void *
-get_data(struct graphics_priv *this, char *type)
-{
- if (strcmp(type,"opengl_displaylist"))
- return NULL;
-#if 0
- dbg(1,"Creating the DL from driver\n");
- this->DLid = glGenLists(1);
-#endif
- return &this->DLid;
-}
-
-static void
-register_resize_callback(struct graphics_priv *this, void (*callback)(void *data, int w, int h), void *data)
-{
- this->resize_callback=callback;
- this->resize_callback_data=data;
-}
-
-static void
-register_motion_callback(struct graphics_priv *this, void (*callback)(void *data, struct point *p), void *data)
-{
- this->motion_callback=callback;
- this->motion_callback_data=data;
-}
-
-static void
-register_button_callback(struct graphics_priv *this, void (*callback)(void *data, int press, int button, struct point *p), void *data)
-{
- this->button_callback=callback;
- this->button_callback_data=data;
-}
-
-static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
-#ifdef HAVE_IMLIB2
- draw_image_warp,
-#else
- NULL,
-#endif
- draw_restore,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- register_resize_callback,
- register_button_callback,
- register_motion_callback,
- NULL, // image_free
-};
-
-static struct graphics_priv *
-graphics_opengl_new(struct graphics_methods *meth, struct attr **attrs)
-{
- struct graphics_priv *this=g_new0(struct graphics_priv,1);
- *meth=graphics_methods;
-
-// GtkWidget *draw;
-
-// draw=gtk_drawnig_area_new();
-
-
- // Initialize the fonts
- int ctx = 0;
- int font = 0;
- ctx = glcGenContext();
- glcContext(ctx);
- font = glcNewFontFromFamily(glcGenFontID(), "Verdana");
- glcFont(font);
- glcStringType(GLC_UTF8_QSO);
-// glcFontFace(font, "Italic");
-
-
-/*
- this->widget=draw;
-
- this->colormap=gdk_colormap_new(gdk_visual_get_system(),FALSE);
- gtk_widget_set_events(draw, GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_KEY_PRESS_MASK);
- g_signal_connect(G_OBJECT(draw), "expose_event", G_CALLBACK(expose), this);
- g_signal_connect(G_OBJECT(draw), "configure_event", G_CALLBACK(configure), this);
-#if 0
- g_signal_connect(G_OBJECT(draw), "realize_event", G_CALLBACK(realize), co);
-#endif
- g_signal_connect(G_OBJECT(draw), "button_press_event", G_CALLBACK(button_press), this);
- g_signal_connect(G_OBJECT(draw), "button_release_event", G_CALLBACK(button_release), this);
- g_signal_connect(G_OBJECT(draw), "scroll_event", G_CALLBACK(scroll), this);
- g_signal_connect(G_OBJECT(draw), "motion_notify_event", G_CALLBACK(motion_notify), this);
- */
- return this;
-}
-
-void
-plugin_init(void)
-{
- plugin_register_graphics_type("opengl", graphics_opengl_new);
-}
diff --git a/navit/graphics/qt_qpainter/Makefile.am b/navit/graphics/qt_qpainter/Makefile.am
deleted file mode 100644
index 4f353541..00000000
--- a/navit/graphics/qt_qpainter/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-include $(top_srcdir)/Makefile.inc
-AM_CPPFLAGS = @QT_GUI_CFLAGS@ @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=graphics_qt_qpainter
-modulegraphics_LTLIBRARIES = libgraphics_qt_qpainter.la
-libgraphics_qt_qpainter_la_SOURCES = graphics_qt_qpainter.cpp
-libgraphics_qt_qpainter_la_LDFLAGS = @QT_GUI_LIBS@
diff --git a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
deleted file mode 100644
index c0f59bc2..00000000
--- a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
+++ /dev/null
@@ -1,682 +0,0 @@
-//##############################################################################################################
-//#
-//# File: graphics_qt_qpainter.cpp
-//# Description: Graphics interface for internal GUI using Qt (Trolltech.com)
-//# Comment:
-//# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
-//#
-//##############################################################################################################
-
-
-#include <glib.h>
-#include "config.h"
-#include "point.h"
-#include "item.h"
-#include "graphics.h"
-#include "color.h"
-#include "debug.h"
-#include "plugin.h"
-
-#if 0
-#define QWS
-#define NO_DEBUG
-#endif
-
-#include <qglobal.h>
-
-#if QT_VERSION < 0x040000
-#include <qwidget.h>
-#include <qapplication.h>
-#include <qpainter.h>
-#include <qpen.h>
-#include <qbrush.h>
-#include <qimage.h>
-#include <qpixmap.h>
-#include <qlistview.h>
-#else
-#include <QApplication>
-#include <QGraphicsScene>
-#include <QGraphicsView>
-#include <QPainter>
-#include <QPen>
-#include <QBrush>
-#include <QPixmap>
-#include <QWidget>
-#include <QPolygonF>
-#include <QtGui>
-#endif
-
-//##############################################################################################################
-//# Description: RenderArea (QWidget) class for the main window (map, menu, ...)
-//# Comment:
-//# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
-//##############################################################################################################
-class RenderArea : public QWidget
- {
- public:
- RenderArea(QWidget *parent = 0);
- QPixmap *pixmap;
- void (*resize_callback)(void *data, int w, int h);
- void *resize_callback_data;
- void (*motion_callback)(void *data, struct point *p);
- void *motion_callback_data;
- void (*button_callback)(void *data, int press, int button, struct point *p);
- void *button_callback_data; // struct navit *
-
-
- protected:
- QSize sizeHint() const;
- void paintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *event);
- void mouseEvent(int pressed, QMouseEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void wheelEvent(QWheelEvent *event);
-
- };
-
-//##############################################################################################################
-//# Description: Constructor
-//# Comment: Using a QPixmap for rendering the graphics
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-RenderArea::RenderArea(QWidget *parent)
- : QWidget(parent)
-{
- pixmap = new QPixmap(800, 600);
-}
-
-//##############################################################################################################
-//# Description: QWidget:sizeHint
-//# Comment: This property holds the recommended size for the widget
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-QSize RenderArea::sizeHint() const
-{
- return QSize(800, 600);
-}
-
-//##############################################################################################################
-//# Description: QWidget:paintEvent
-//# Comment: A paint event is a request to repaint all or part of the widget.
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void RenderArea::paintEvent(QPaintEvent * event)
-{
- QPainter painter(this);
- painter.drawPixmap(0, 0, *pixmap);
-}
-
-
-//##############################################################################################################
-//# Description: QWidget::resizeEvent()
-//# Comment: When resizeEvent() is called, the widget already has its new geometry.
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void RenderArea::resizeEvent(QResizeEvent * event)
-{
- QSize size=event->size();
- delete pixmap;
- pixmap = new QPixmap(size);
- if (this->resize_callback)
- (this->resize_callback)(this->resize_callback_data, size.width(), size.height());
-}
-
-//##############################################################################################################
-//# Description: Method to handle mouse clicks
-//# Comment: Delegate of QWidget::mousePressEvent and QWidget::mouseReleaseEvent (see below)
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void RenderArea::mouseEvent(int pressed, QMouseEvent *event)
-{
- struct point p;
- if (!this->button_callback)
- return;
- p.x=event->x();
- p.y=event->y();
- switch (event->button()) {
- case Qt::LeftButton:
- (this->button_callback)(this->button_callback_data, pressed, 1, &p); // calls navit_button() in navit.c
- break;
- case Qt::MidButton:
- (this->button_callback)(this->button_callback_data, pressed, 2, &p);
- break;
- case Qt::RightButton:
- (this->button_callback)(this->button_callback_data, pressed, 3, &p);
- break;
- default:
- break;
- }
-}
-
-void RenderArea::mousePressEvent(QMouseEvent *event)
-{
- mouseEvent(1, event);
-}
-
-void RenderArea::mouseReleaseEvent(QMouseEvent *event)
-{
- mouseEvent(0, event);
-}
-
-//##############################################################################################################
-//# Description: QWidget::mouseMoveEvent
-//# Comment: If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void RenderArea::mouseMoveEvent(QMouseEvent *event)
-{
- struct point p;
- if (!this->motion_callback)
- return;
- p.x=event->x();
- p.y=event->y();
- (this->motion_callback)(this->motion_callback_data, &p);
-}
-
-
-//##############################################################################################################
-//# Description: Qt Event :: Zoom in/out with the mouse's scrollwheel
-//# Comment:
-//# Authors: Stefan Klumpp (04/2008)
-//##############################################################################################################
-void RenderArea::wheelEvent(QWheelEvent *event)
-{
- struct point p;
- int button;
-
- if (!this->button_callback)
- return;
- p.x=event->x(); // xy-coordinates of the mouse pointer
- p.y=event->y();
-
- if (event->delta() > 0) // wheel movement away from the person
- button=4;
- else if (event->delta() < 0) // wheel movement towards the person
- button=5;
- else
- button=-1;
-
- if (button != -1) {
- (*this->button_callback)(this->button_callback_data, 1, button, &p);
- (*this->button_callback)(this->button_callback_data, 0, button, &p);
- }
-
- event->accept();
-}
-
-//##############################################################################################################
-// General comments:
-// -----------------
-// gr = graphics = draw area
-// gc = graphics context = pen to paint on the draw area
-//##############################################################################################################
-
-static int dummy;
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-struct graphics_priv {
- QApplication *app;
- RenderArea *widget;
- QPainter *painter;
- struct graphics_gc_priv *background_gc;
- enum draw_mode_num mode;
-};
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_font_priv {
- int dummy;
-} graphics_font_priv;
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_gc_priv {
- QPen *pen;
- QBrush *brush;
-} graphics_gc_priv;
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_image_priv {
- QImage *image;
-} graphics_image_priv;
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void graphics_destroy(struct graphics_priv *gr)
-{
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void font_destroy(struct graphics_font_priv *font)
-{
-
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_font_methods font_methods = {
- font_destroy
-};
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
-{
- *meth=font_methods;
- return &graphics_font_priv;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gc_destroy(struct graphics_gc_priv *gc)
-{
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->pen->setWidth(w);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
-#if QT_VERSION >= 0x040000
- QColor col(c->r >> 8, c->g >> 8, c->b >> 8, c->a >> 8);
-#else
- QColor col(c->r >> 8, c->g >> 8, c->b >> 8);
-#endif
- gc->pen->setColor(col);
- gc->brush->setColor(col);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
-};
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- *meth=gc_methods;
- struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
- ret->pen=new QPen();
- ret->brush=new QBrush(Qt::SolidPattern);
- return ret;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot)
-{
- struct graphics_image_priv *ret=g_new0(struct graphics_image_priv, 1);
-
- ret->image=new QImage(path);
- *w=ret->image->width();
- *h=ret->image->height();
- if (hot) {
- hot->x=*w/2;
- hot->y=*h/2;
- }
- return ret;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
-#if QT_VERSION >= 0x040000
- QPolygon polygon;
-#else
- QPointArray polygon;
-#endif
-
- for (i = 0 ; i < count ; i++)
- polygon.putPoints(i, 1, p[i].x, p[i].y);
- gr->painter->setPen(*gc->pen);
- gr->painter->drawPolyline(polygon);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
-#if QT_VERSION >= 0x040000
- QPolygon polygon;
-#else
- QPointArray polygon;
-#endif
-
- for (i = 0 ; i < count ; i++)
- polygon.putPoints(i, 1, p[i].x, p[i].y);
- gr->painter->setPen(*gc->pen);
- gr->painter->setBrush(*gc->brush);
- gr->painter->drawPolygon(polygon);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- gr->painter->fillRect(p->x,p->y, w, h, *gc->brush);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- gr->painter->setPen(*gc->pen);
- gr->painter->drawArc(p->x-r, p->y-r, r*2, r*2, 0, 360*16);
-
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- QString tmp = text;
- gr->painter->drawText(p->x, p->y, tmp);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- gr->painter->drawImage(p->x, p->y, *img->image);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data)
-{
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_restore(struct graphics_priv *gr, struct point *p, int w, int h)
-{
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background_gc=gc;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- dbg(0,"mode=%d\n", mode);
- if (mode == draw_mode_begin) {
- gr->painter->begin(gr->widget->pixmap);
-#if 0
- gr->painter->fillRect(QRect(QPoint(0,0), gr->widget->size()), *gr->background_gc->brush);
-#endif
- }
-#if QT_VERSION < 0x040000
- if (mode == draw_mode_cursor) {
- gr->painter->begin(gr->widget);
- }
-#endif
- if (mode == draw_mode_end) {
- if (gr->mode == draw_mode_begin) {
- gr->painter->end();
- gr->widget->update();
- } else {
-#if QT_VERSION < 0x040000
- gr->painter->end();
-#endif
- }
- }
- gr->mode=mode;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h);
-
-static int argc=1;
-static char *argv[]={"navit",NULL};
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void * get_data(struct graphics_priv *this_, char *type)
-{
- if (strcmp(type, "window"))
- return NULL;
- this_->painter=new QPainter;
- this_->widget->show();
- return &dummy;
-}
-
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void register_resize_callback(struct graphics_priv *this_, void (*callback)(void *data, int w, int h), void *data)
-{
- this_->widget->resize_callback=callback;
- this_->widget->resize_callback_data=data;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void register_motion_callback(struct graphics_priv *this_, void (*callback)(void *data, struct point *p), void *data)
-{
- this_->widget->motion_callback=callback;
- this_->widget->motion_callback_data=data;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void register_button_callback(struct graphics_priv *this_, void (*callback)(void *data, int press, int button, struct point *p), void *data)
-{
- this_->widget->button_callback=callback;
- this_->widget->button_callback_data=data;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
- draw_image_warp,
- draw_restore,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- register_resize_callback,
- register_button_callback,
- register_motion_callback,
-};
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h)
-{
- *meth=graphics_methods;
- return NULL;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-#if QT_VERSION < 0x040000
-static gboolean graphics_qt_qpainter_idle(void *data)
-{
- struct graphics_priv *gr=(struct graphics_priv *)data;
- gr->app->processOneEvent();
- return TRUE;
-}
-#endif
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct graphics_priv * graphics_qt_qpainter_new(struct graphics_methods *meth, struct attr **attrs)
-{
- struct graphics_priv *ret=g_new0(struct graphics_priv, 1);
- *meth=graphics_methods;
- ret->app = new QApplication(argc, argv);
- ret->widget= new RenderArea();
-#if QT_VERSION < 0x040000
- g_idle_add(graphics_qt_qpainter_idle, ret);
-#endif
-
- return ret;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void plugin_init(void)
-{
- plugin_register_graphics_type("qt_qpainter", graphics_qt_qpainter_new);
-}
-
-
-
-
-// *** EOF ***
diff --git a/navit/graphics/win32/Makefile.am b/navit/graphics/win32/Makefile.am
deleted file mode 100644
index 56390a4e..00000000
--- a/navit/graphics/win32/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-include $(top_srcdir)/Makefile.inc
-AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=graphics_win32
-modulegraphics_LTLIBRARIES = libgraphics_win32.la
-libgraphics_win32_la_SOURCES = graphics_win32.c xpm2bmp.c
diff --git a/navit/graphics/win32/graphics_win32.c b/navit/graphics/win32/graphics_win32.c
deleted file mode 100644
index dc878f13..00000000
--- a/navit/graphics/win32/graphics_win32.c
+++ /dev/null
@@ -1,794 +0,0 @@
-#include <windows.h>
-#include <wchar.h>
-#include <wingdi.h>
-#include <glib.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#if defined(__CEGCC__)
-#include <libintl.h>
-#endif
-#include "config.h"
-#include "debug.h"
-#include "point.h"
-#include "graphics.h"
-#include "color.h"
-#include "plugin.h"
-#include "win32_gui.h"
-#include "xpm2bmp.h"
-#include "util.h"
-
-#ifndef GET_WHEEL_DELTA_WPARAM
- #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
-#endif
-
-
-static GHashTable *image_cache_hash = NULL;
-
-
-HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
- int iDeciPtWidth, int iAttributes, BOOL fLogRes) ;
-
-#define EZ_ATTR_BOLD 1
-#define EZ_ATTR_ITALIC 2
-#define EZ_ATTR_UNDERLINE 4
-#define EZ_ATTR_STRIKEOUT 8
-
-HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
- int iDeciPtWidth, int iAttributes, BOOL fLogRes)
-{
- FLOAT cxDpi, cyDpi ;
- HFONT hFont ;
- LOGFONT lf ;
- POINT pt ;
- TEXTMETRIC tm ;
-
- SaveDC (hdc) ;
-
-#if !defined(__CEGCC__)
- SetGraphicsMode (hdc, GM_ADVANCED) ;
- ModifyWorldTransform (hdc, NULL, MWT_IDENTITY) ;
-#endif
- SetViewportOrgEx (hdc, 0, 0, NULL) ;
-#if !defined(__CEGCC__)
- SetWindowOrgEx (hdc, 0, 0, NULL) ;
-#endif
- if (fLogRes)
- {
- cxDpi = (FLOAT) GetDeviceCaps (hdc, LOGPIXELSX) ;
- cyDpi = (FLOAT) GetDeviceCaps (hdc, LOGPIXELSY) ;
- }
- else
- {
- cxDpi = (FLOAT) (25.4 * GetDeviceCaps (hdc, HORZRES) /
- GetDeviceCaps (hdc, HORZSIZE)) ;
-
- cyDpi = (FLOAT) (25.4 * GetDeviceCaps (hdc, VERTRES) /
- GetDeviceCaps (hdc, VERTSIZE)) ;
- }
-
- pt.x = (int) (iDeciPtWidth * cxDpi / 72) ;
- pt.y = (int) (iDeciPtHeight * cyDpi / 72) ;
-
-#if !defined(__CEGCC__)
- DPtoLP (hdc, &pt, 1) ;
-#endif
- lf.lfHeight = - (int) (fabs (pt.y) / 10.0 + 0.5) ;
- lf.lfWidth = 0 ;
- lf.lfEscapement = 0 ;
- lf.lfOrientation = 0 ;
- lf.lfWeight = iAttributes & EZ_ATTR_BOLD ? 700 : 0 ;
- lf.lfItalic = iAttributes & EZ_ATTR_ITALIC ? 1 : 0 ;
- lf.lfUnderline = iAttributes & EZ_ATTR_UNDERLINE ? 1 : 0 ;
- lf.lfStrikeOut = iAttributes & EZ_ATTR_STRIKEOUT ? 1 : 0 ;
- lf.lfCharSet = DEFAULT_CHARSET ;
- lf.lfOutPrecision = 0 ;
- lf.lfClipPrecision = 0 ;
- lf.lfQuality = 0 ;
- lf.lfPitchAndFamily = 0 ;
-
- lstrcpy (lf.lfFaceName, szFaceName) ;
-
- hFont = CreateFontIndirect (&lf) ;
-
- if (iDeciPtWidth != 0)
- {
- hFont = (HFONT) SelectObject (hdc, hFont) ;
-
- GetTextMetrics (hdc, &tm) ;
-
- DeleteObject (SelectObject (hdc, hFont)) ;
-
- lf.lfWidth = (int) (tm.tmAveCharWidth *
- fabs (pt.x) / fabs (pt.y) + 0.5) ;
-
- hFont = CreateFontIndirect (&lf) ;
- }
-
- RestoreDC (hdc, -1) ;
- return hFont ;
-}
-
-struct graphics_image_priv {
- PXPM2BMP pxpm;
-};
-
-
-void ErrorExit(LPTSTR lpszFunction)
-{
- // Retrieve the system error message for the last-error code
-
- LPVOID lpMsgBuf;
- LPVOID lpDisplayBuf;
- DWORD dw = GetLastError();
-
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- dw,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL );
-
- lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
- (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR));
- stprintf ((LPTSTR)lpDisplayBuf, TEXT("%s failed with error %d: %s"), lpszFunction, (int)dw, (char *)lpMsgBuf);
-
- dbg( 0, "%s\n", (char *)lpDisplayBuf );
- MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
-
- LocalFree(lpMsgBuf);
- LocalFree(lpDisplayBuf);
- ExitProcess(dw);
-}
-
-
-
-struct graphics_gc_priv {
- HWND hwnd;
- int line_width;
- COLORREF fg_color;
- COLORREF bg_color;
- struct graphics_priv *gr;
-};
-
-
-//struct graphics_priv *g_gra;
-
-static HDC hMemDC;
-static HBITMAP hBitmap;
-static HBITMAP hOldBitmap;
-
-// Fills the region 'rgn' in graded colours
-static void MakeMemoryDC(HANDLE hWnd, HDC hdc )
-{
- if ( hMemDC )
- {
- if ( hOldBitmap )
- {
- SelectObject( hMemDC, hOldBitmap );
- DeleteObject( hBitmap );
- hBitmap = NULL;
- hOldBitmap = NULL;
- }
- }
-
- // Creates memory DC
- hMemDC = CreateCompatibleDC(hdc);
- if ( hMemDC )
- {
- RECT rectRgn;
- GetClientRect( hWnd, &rectRgn );
-
- int Width = rectRgn.right - rectRgn.left;
- int Height = rectRgn.bottom - rectRgn.top;
- dbg( 1, "resize memDC to: %d %d \n", Width, Height );
-
- hBitmap = CreateCompatibleBitmap(hdc, Width, Height );
-
- if ( hBitmap )
- {
- hOldBitmap = (HBITMAP) SelectObject( hMemDC, hBitmap);
- }
- }
-}
-
-static void HandleButtonClick( struct graphics_priv *gra_priv, int updown, int button, long lParam )
-{
- int xPos = LOWORD(lParam);
- int yPos = HIWORD(lParam);
-
- if (gra_priv->button_callback )
- {
- struct point pt = {xPos, yPos};
- (*gra_priv->button_callback)(gra_priv->button_callback_data, updown, button, &pt);
- }
-}
-
-static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
-{
-
-//if ( Message != 15 )
-//printf( "CHILD %d %d %d \n", Message, wParam, lParam );
-
- struct graphics_priv* gra_priv = (struct graphics_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
- switch(Message)
- {
- case WM_CREATE:
- {
- HDC hdc;
- hdc = GetDC( hwnd );
- MakeMemoryDC(hwnd, hdc );
- ReleaseDC( hwnd, hdc );
- }
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case WM_USER + 1:
- break;
- }
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_USER+1:
- if ( gra_priv )
- {
- RECT rc ;
- HDC hdc;
-
- GetClientRect( hwnd, &rc );
- gra_priv->width = rc.right;
- gra_priv->height = rc.bottom;
-
- hdc = GetDC( hwnd );
- MakeMemoryDC(hwnd, hdc );
- ReleaseDC( hwnd, hdc );
- }
- break;
-
- case WM_SIZE:
- /*
- if ( gra_priv )
- {
- //graphics = GetWindowLong( hwnd, DWL_USER, 0 );
-
-
- {
- HDC hdc;
- hdc = GetDC( hwnd );
- MakeMemoryDC(hwnd, hdc );
- ReleaseDC( hwnd, hdc );
- }
- (*gra_priv->resize_callback)(gra_priv->resize_callback_data, gra_priv->width, gra_priv->height);
-
-
- }
- */
- if ( gra_priv )
- {
- gra_priv->width = LOWORD( lParam );
- gra_priv->height = HIWORD( lParam );
- (*gra_priv->resize_callback)(gra_priv->resize_callback_data, gra_priv->width, gra_priv->height);
- dbg( 1, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height );
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- exit( 0 );
- break;
- case WM_PAINT:
- if ( gra_priv )
- {
- HDC hdc = GetDC(hwnd );
- if ( hMemDC )
- {
- BitBlt( hdc, 0, 0, gra_priv->width , gra_priv->height, hMemDC, 0, 0, SRCCOPY );
- }
- ReleaseDC( hwnd, hdc );
- }
- break;
- case WM_MOUSEMOVE:
- {
- int xPos = LOWORD(lParam);
- int yPos = HIWORD(lParam);
- struct point pt = {xPos, yPos};
-
- dbg( 2, "WM_MOUSEMOVE: %d %d \n", xPos, yPos );
- (*gra_priv->motion_callback)(gra_priv->motion_callback_data, &pt);
- }
-
- break;
-
- case WM_LBUTTONDOWN:
- HandleButtonClick( gra_priv,1, 1,lParam );
- break;
- case WM_LBUTTONUP:
- HandleButtonClick( gra_priv, 0, 1,lParam );
- break;
- case WM_RBUTTONDOWN:
- HandleButtonClick( gra_priv, 1, 3,lParam );
- break;
- case WM_RBUTTONUP:
- HandleButtonClick( gra_priv, 0, 3,lParam );
- break;
-
- default:
- return DefWindowProc(hwnd, Message, wParam, lParam);
- }
- return 0;
-}
-
-
-static const TCHAR g_szClassName[] = TEXT("NAVGRA");
-
-HANDLE CreateGraphicsWindows( struct graphics_priv* gr )
-{
- WNDCLASS wc;
- HWND hwnd;
- RECT rcParent;
-
-// wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 64;
- wc.hInstance = NULL;
- wc.hIcon = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = g_szClassName;
-// wc.hIconSm = NULL;
-
-
- GetClientRect( gr->wnd_parent_handle,&rcParent);
-
- if(!RegisterClass(&wc))
- {
- ErrorExit( TEXT("Window Registration Failed!") );
- return NULL;
- }
-
- gr->width = rcParent.right - rcParent.left;
- gr->height = rcParent.bottom - rcParent.top;
-#if defined(__CEGCC__)
- (*gr->resize_callback)(gr->resize_callback_data, gr->width, gr->height);
-#endif
- hwnd = CreateWindow( g_szClassName,
- TEXT(""),
- WS_CHILD ,
- 0,
- 0,
- gr->width,
- gr->height,
- gr->wnd_parent_handle,
- (HMENU)ID_CHILD_GFX,
- NULL,
- NULL);
-
- if(hwnd == NULL)
- {
- ErrorExit( TEXT("Window Creation Failed!") );
- return NULL;
- }
-
- SetWindowLongPtr( hwnd , DWLP_USER, (LONG_PTR)gr );
-
- ShowWindow( hwnd, TRUE );
- UpdateWindow( hwnd );
-
- gr->wnd_handle = hwnd;
-
- PostMessage( gr->wnd_parent_handle, WM_USER + 1, 0, 0 );
-
- return hwnd;
-}
-
-
-
-static void graphics_destroy(struct graphics_priv *gr)
-{
- g_free( gr );
-}
-
-
-static void gc_destroy(struct graphics_gc_priv *gc)
-{
- g_free( gc );
-}
-
-static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->line_width = w;
-}
-
-static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n)
-{
-// gdk_gc_set_dashes(gc->gc, 0, (gint8 *)dash_list, n);
-// gdk_gc_set_line_attributes(gc->gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-}
-
-
-
-//static void gc_set_color(struct graphics_gc_priv *gc, struct color *c, int fg)
-//{
-//
-// gc->fg_color = RGB( c->r, c->g, c->b );
-//}
-
-static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->fg_color = RGB( c->r, c->g, c->b );
-}
-
-static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->bg_color = RGB( c->r, c->g, c->b );
- if ( hMemDC )
- SetBkColor( hMemDC, gc->bg_color );
-
-}
-
-static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
-};
-
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
- *meth=gc_methods;
- gc->hwnd = gr->wnd_handle;
- gc->line_width = 1;
- gc->fg_color = RGB( 0,0,0 );
- gc->bg_color = RGB( 255,255,255 );
- return gc;
-}
-
-
-static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
- HPEN holdpen;
- HPEN hpen;
-
- hpen = CreatePen( PS_SOLID, gc->line_width, gc->fg_color );
- holdpen = SelectObject( hMemDC, hpen );
-
- SetBkColor( hMemDC, gc->bg_color );
-
- int first = 1;
- for ( i = 0; i< count; i++ )
- {
- if ( first )
- {
- first = 0;
- MoveToEx( hMemDC, p[0].x, p[0].y, NULL );
- }
- else
- {
- LineTo( hMemDC, p[i].x, p[i].y );
- }
- }
-
- SelectObject( hMemDC, holdpen );
- DeleteObject( hpen );
-}
-
-static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
-
- //if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
- {
- int i;
- POINT points[ count ];
- for ( i=0;i< count; i++ )
- {
- points[i].x = p[i].x;
- points[i].y = p[i].y;
- }
- HBRUSH holdbrush;
- HBRUSH hbrush;
-
- SetBkColor( hMemDC, gc->bg_color );
-
- hbrush = CreateSolidBrush( gc->fg_color );
- holdbrush = SelectObject( hMemDC, hbrush );
- Polygon( hMemDC, points,count );
- SelectObject( hMemDC, holdbrush );
- DeleteObject( hbrush );
- }
-}
-
-
-static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
-// gdk_draw_rectangle(gr->drawable, gc->gc, TRUE, p->x, p->y, w, h);
-}
-
-static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- HDC dc = hMemDC;
-
- HPEN holdpen;
- HPEN hpen;
-
- hpen = CreatePen( PS_SOLID, gc->line_width, gc->fg_color );
- holdpen = SelectObject( dc, hpen );
-
- SetBkColor( hMemDC, gc->bg_color );
-
- Ellipse( dc, p->x - r, p->y -r, p->x + r, p->y + r );
-
- SelectObject( dc, holdpen );
- DeleteObject( hpen );
-
-// if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
-// gdk_draw_arc(gr->drawable, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360);
-// if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
-// gdk_draw_arc(gr->widget->window, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360);
-}
-
-
-
-static void draw_restore(struct graphics_priv *gr, struct point *p, int w, int h)
-{
- InvalidateRect( gr->wnd_handle, NULL, FALSE );
-}
-
-static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- dbg( 1, "set draw_mode to %d\n", (int)mode );
-
- if ( mode == draw_mode_begin )
- {
- if ( gr->wnd_handle == NULL )
- {
- CreateGraphicsWindows( gr );
- }
- if ( gr->mode != draw_mode_begin )
- {
- if ( hMemDC )
- {
- RECT rcClient;
- HBRUSH bgBrush = CreateSolidBrush( gr->bg_color );
- GetClientRect( gr->wnd_handle, &rcClient );
- FillRect( hMemDC, &rcClient, bgBrush );
- DeleteObject( bgBrush );
- }
- }
- }
-
- // force paint
- if (mode == draw_mode_end && gr->mode == draw_mode_begin)
- {
- InvalidateRect( gr->wnd_handle, NULL, FALSE );
- }
-
- gr->mode=mode;
-
-}
-
-
-static void * get_data(struct graphics_priv *this_, char *type)
-{
- if ( strcmp( "wnd_parent_handle_ptr", type ) == 0 )
- {
- return &( this_->wnd_parent_handle );
- }
- if ( strcmp( "START_CLIENT", type ) == 0 )
- {
- CreateGraphicsWindows( this_ );
- return NULL;
- }
- return NULL;
-}
-
-
-static void register_resize_callback(struct graphics_priv *this_, void (*callback)(void *data, int w, int h), void *data)
-{
- this_->resize_callback=callback;
- this_->resize_callback_data=data;
-}
-
-static void register_motion_callback(struct graphics_priv *this_, void (*callback)(void *data, struct point *p), void *data)
-{
- this_->motion_callback=callback;
- this_->motion_callback_data=data;
-}
-
-static void register_button_callback(struct graphics_priv *this_, void (*callback)(void *data, int press, int button, struct point *p), void *data)
-{
- this_->button_callback=callback;
- this_->button_callback_data=data;
-}
-
-static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- RECT rcClient;
- HBRUSH bgBrush = CreateSolidBrush( gc->bg_color );
- GetClientRect( gr->wnd_handle, &rcClient );
- FillRect( hMemDC, &rcClient, bgBrush );
- DeleteObject( bgBrush );
- gr->bg_color = gc->bg_color;
-}
-
-struct graphics_font_priv {
- LOGFONT lf;
- HFONT hfont;
- int size;
-};
-
-static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- RECT rcClient;
- GetClientRect( gr->wnd_handle, &rcClient );
-
- int prevBkMode = SetBkMode( hMemDC, TRANSPARENT );
-
- if ( NULL == font->hfont )
- {
- font->hfont = EzCreateFont (hMemDC, TEXT ("Arial"), font->size/2, 0, 0, TRUE) ;
- GetObject ( font->hfont, sizeof (LOGFONT), &font->lf) ;
- }
-
-
- double angle = -atan2( dy, dx ) * 180 / 3.14159 ;
-
- SetTextAlign (hMemDC, TA_BASELINE) ;
- SetViewportOrgEx (hMemDC, p->x, p->y, NULL) ;
- font->lf.lfEscapement = font->lf.lfOrientation = ( angle * 10 ) ;
- DeleteObject (font->hfont) ;
-
- font->hfont = CreateFontIndirect (&font->lf);
- HFONT hOldFont = SelectObject(hMemDC, font->hfont );
-
- gunichar2* utf16 = NULL;
- glong utf16_len = 0;
-
- utf16 = g_utf8_to_utf16( text, -1, NULL, &utf16_len, NULL );
-#if defined(__CEGCC__)
- ExtTextOut(hMemDC, 0,0, ETO_OPAQUE, 0, utf16, (size_t)utf16_len,0 );
-#else
- TextOutW(hMemDC, 0,0, utf16, (size_t)utf16_len );
-#endif
- g_free( utf16 );
-
-
- SelectObject(hMemDC, hOldFont);
- DeleteObject (font->hfont) ;
-
- SetBkMode( hMemDC, prevBkMode );
-
- SetViewportOrgEx (hMemDC, 0, 0, NULL) ;
-
-}
-
-
-
-static void font_destroy(struct graphics_font_priv *font)
-{
- if ( font->hfont )
- {
- DeleteObject(font->hfont);
- }
- g_free(font);
-}
-
-static struct graphics_font_methods font_methods = {
- font_destroy
-};
-
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
-{
- struct graphics_font_priv *font=g_new(struct graphics_font_priv, 1);
- *meth = font_methods;
-
- font->hfont = NULL;
- font->size = size;
- // FontFamily fontFamily( "Liberation Mono");
-//font( &fontFamily, size, FontStyleRegular, UnitPoint );
- return font;
-}
-
-
-void image_cache_hash_add( const char* key, struct graphics_image_priv* val_ptr)
-{
- if ( image_cache_hash == NULL ) {
- image_cache_hash = g_hash_table_new(g_str_hash, g_str_equal);
- }
-
- if ( g_hash_table_lookup(image_cache_hash, key ) == NULL )
- {
- g_hash_table_insert(image_cache_hash, g_strdup( key ), (gpointer)val_ptr );
- }
-
-}
-
-struct graphics_image_priv* image_cache_hash_lookup( const char* key )
-{
- struct graphics_image_priv* val_ptr = NULL;
-
- if ( image_cache_hash != NULL )
- {
- val_ptr = g_hash_table_lookup(image_cache_hash, key );
- }
- return val_ptr;
-}
-
-
-
-static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot)
-{
- struct graphics_image_priv* ret;
-
- if ( NULL == ( ret = image_cache_hash_lookup( name ) ) )
- {
- ret = g_new( struct graphics_image_priv, 1 );
- dbg( 1, "loading image '%s'\n", name );
- ret->pxpm = Xpm2bmp_new();
- Xpm2bmp_load( ret->pxpm, name );
- image_cache_hash_add( name, ret );
- }
-
- return ret;
-}
-
-static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- Xpm2bmp_paint( img->pxpm , hMemDC, p->x, p->y );
-}
-
-static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
-#ifdef HAVE_IMLIB2
- NULL, // draw_image_warp,
-#else
- NULL,
-#endif
- draw_restore,
- font_new,
- gc_new,
- background_gc,
- NULL, // overlay_new,
- image_new,
- get_data,
- register_resize_callback,
- register_button_callback,
- register_motion_callback,
-};
-
-static struct graphics_priv * graphics_win32_drawing_area_new_helper(struct graphics_methods *meth)
-{
- struct graphics_priv *this_=g_new0(struct graphics_priv,1);
- *meth=graphics_methods;
- this_->mode = -1;
- return this_;
-}
-
-struct graphics_priv* win32_graphics_new( struct graphics_methods *meth, struct attr **attrs)
-{
- struct graphics_priv* this_=graphics_win32_drawing_area_new_helper(meth);
- return this_;
-}
-
-void
-plugin_init(void)
-{
- plugin_register_graphics_type("win32", win32_graphics_new);
-}
diff --git a/navit/graphics/win32/resources/resource.h b/navit/graphics/win32/resources/resource.h
deleted file mode 100644
index 55bcc2d7..00000000
--- a/navit/graphics/win32/resources/resource.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <windows.h>
-
-#define IDI_NAVIT 1100
-#define IDB_NAVITTOOLBAR 1101
diff --git a/navit/graphics/win32/win32_gui.h b/navit/graphics/win32/win32_gui.h
deleted file mode 100644
index 32095a0c..00000000
--- a/navit/graphics/win32/win32_gui.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef WIN32_GUI_INCLUDED
-#define WIN32_GUI_INCLUDED
-
-#include "resources/resource.h"
-#include "coord.h"
-#include "point.h"
-#include "graphics.h"
-
-#define ID_CHILD_GFX 100
-#define ID_CHILD_TOOLBAR (ID_CHILD_GFX + 1)
-#define ID_CHILD_1 (ID_CHILD_TOOLBAR + 1)
-#define ID_CHILD_2 (ID_CHILD_1 + 1)
-#define ID_CHILD_3 (ID_CHILD_2 + 1)
-#define ID_CHILD_4 (ID_CHILD_4 + 1)
-
-#define ID_DISPLAY_ZOOMIN 200
-#define ID_DISPLAY_ZOOMOUT 201
-#define ID_DISPLAY_REFRESH 202
-#define ID_DISPLAY_CURSOR 203
-#define ID_DISPLAY_ORIENT 204
-#define ID_DISPLAY_DESTINATION 205
-
-#define ID_FILE_EXIT 9001
-#define ID_STUFF_GO 9002
-
-#define _(text) gettext(text)
-
-#define POPUP_MENU_OFFSET 4000
-
-struct statusbar_methods;
-struct menu_methods;
-struct datawindow_methods;
-struct navit;
-struct callback;
-
-
-struct menu_priv {
- HWND wnd_handle;
- HMENU hMenu;
- struct callback* cb;
-};
-
-struct gui_priv {
- struct navit *nav;
- HANDLE hwnd;
-};
-
-
-struct graphics_priv {
- struct point p;
- int width;
- int height;
- int library_init;
- int visible;
- HANDLE wnd_parent_handle;
- HANDLE wnd_handle;
- COLORREF bg_color;
-
-
- void (*resize_callback)(void *data, int w, int h);
- void *resize_callback_data;
- void (*motion_callback)(void *data, struct point *p);
- void *motion_callback_data;
- void (*button_callback)(void *data, int press, int button, struct point *p);
- void *button_callback_data;
- enum draw_mode_num mode;
-};
-
-
-struct graphics_priv* win32_graphics_new( struct graphics_methods *meth, struct attr **attrs);
-HANDLE create_destination_window( struct navit *nav );
-BOOL register_destination_window();
-
-
-#endif
diff --git a/navit/graphics/win32/xpm2bmp.c b/navit/graphics/win32/xpm2bmp.c
deleted file mode 100644
index 4c02448d..00000000
--- a/navit/graphics/win32/xpm2bmp.c
+++ /dev/null
@@ -1,589 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <wingdi.h>
-#include "xpm2bmp.h"
-
-#define _DBG
-
-// function prototypes
-static int CreateBitmapFromXpm( const char* filename, PXPM2BMP pXpm2bmp );
-
-// typedefs
-static XPMCOLORENTRY theRGBRecords[] =
-{
- {"ALICEBLUE", 240, 248, 255},
- {"ANTIQUEWHITE", 250, 235, 215},
- {"AQUAMARINE", 50, 191, 193},
- {"AZURE", 240, 255, 255},
- {"BEIGE", 245, 245, 220},
- {"BISQUE", 255, 228, 196},
- {"BLACK", 0, 0, 0},
- {"BLANCHEDALMOND", 255, 235, 205},
- {"BLUE", 0, 0, 255},
- {"BLUEVIOLET", 138, 43, 226},
- {"BROWN", 165, 42, 42},
- {"BURLYWOOD", 222, 184, 135},
- {"CADETBLUE", 95, 146, 158},
- {"CHARTREUSE", 127, 255, 0},
- {"CHOCOLATE", 210, 105, 30},
- {"CORAL", 255, 114, 86},
- {"CORNFLOWERBLUE", 34, 34, 152},
- {"CORNSILK", 255, 248, 220},
- {"CYAN", 0, 255, 255},
- {"DARKGOLDENROD", 184, 134, 11},
- {"DARKGREEN", 0, 86, 45},
- {"DARKKHAKI", 189, 183, 107},
- {"DARKOLIVEGREEN", 85, 86, 47},
- {"DARKORANGE", 255, 140, 0},
- {"DARKORCHID", 139, 32, 139},
- {"DARKSALMON", 233, 150, 122},
- {"DARKSEAGREEN", 143, 188, 143},
- {"DARKSLATEBLUE", 56, 75, 102},
- {"DARKSLATEGRAY", 47, 79, 79},
- {"DARKTURQUOISE", 0, 166, 166},
- {"DARKVIOLET", 148, 0, 211},
- {"DEEPPINK", 255, 20, 147},
- {"DEEPSKYBLUE", 0, 191, 255},
- {"DIMGRAY", 84, 84, 84},
- {"DODGERBLUE", 30, 144, 255},
- {"FIREBRICK", 142, 35, 35},
- {"FLORALWHITE", 255, 250, 240},
- {"FORESTGREEN", 80, 159, 105},
- {"GAINSBORO", 220, 220, 220},
- {"GHOSTWHITE", 248, 248, 255},
- {"GOLD", 218, 170, 0},
- {"GOLDENROD", 239, 223, 132},
- {"GRAY", 126, 126, 126},
- {"GRAY0", 0, 0, 0},
- {"GRAY1", 3, 3, 3},
- {"GRAY10", 26, 26, 26},
- {"GRAY100", 255, 255, 255},
- {"GRAY11", 28, 28, 28},
- {"GRAY12", 31, 31, 31},
- {"GRAY13", 33, 33, 33},
- {"GRAY14", 36, 36, 36},
- {"GRAY15", 38, 38, 38},
- {"GRAY16", 41, 41, 41},
- {"GRAY17", 43, 43, 43},
- {"GRAY18", 46, 46, 46},
- {"GRAY19", 48, 48, 48},
- {"GRAY2", 5, 5, 5},
- {"GRAY20", 51, 51, 51},
- {"GRAY21", 54, 54, 54},
- {"GRAY22", 56, 56, 56},
- {"GRAY23", 59, 59, 59},
- {"GRAY24", 61, 61, 61},
- {"GRAY25", 64, 64, 64},
- {"GRAY26", 66, 66, 66},
- {"GRAY27", 69, 69, 69},
- {"GRAY28", 71, 71, 71},
- {"GRAY29", 74, 74, 74},
- {"GRAY3", 8, 8, 8},
- {"GRAY30", 77, 77, 77},
- {"GRAY31", 79, 79, 79},
- {"GRAY32", 82, 82, 82},
- {"GRAY33", 84, 84, 84},
- {"GRAY34", 87, 87, 87},
- {"GRAY35", 89, 89, 89},
- {"GRAY36", 92, 92, 92},
- {"GRAY37", 94, 94, 94},
- {"GRAY38", 97, 97, 97},
- {"GRAY39", 99, 99, 99},
- {"GRAY4", 10, 10, 10},
- {"GRAY40", 102, 102, 102},
- {"GRAY41", 105, 105, 105},
- {"GRAY42", 107, 107, 107},
- {"GRAY43", 110, 110, 110},
- {"GRAY44", 112, 112, 112},
- {"GRAY45", 115, 115, 115},
- {"GRAY46", 117, 117, 117},
- {"GRAY47", 120, 120, 120},
- {"GRAY48", 122, 122, 122},
- {"GRAY49", 125, 125, 125},
- {"GRAY5", 13, 13, 13},
- {"GRAY50", 127, 127, 127},
- {"GRAY51", 130, 130, 130},
- {"GRAY52", 133, 133, 133},
- {"GRAY53", 135, 135, 135},
- {"GRAY54", 138, 138, 138},
- {"GRAY55", 140, 140, 140},
- {"GRAY56", 143, 143, 143},
- {"GRAY57", 145, 145, 145},
- {"GRAY58", 148, 148, 148},
- {"GRAY59", 150, 150, 150},
- {"GRAY6", 15, 15, 15},
- {"GRAY60", 153, 153, 153},
- {"GRAY61", 156, 156, 156},
- {"GRAY62", 158, 158, 158},
- {"GRAY63", 161, 161, 161},
- {"GRAY64", 163, 163, 163},
- {"GRAY65", 166, 166, 166},
- {"GRAY66", 168, 168, 168},
- {"GRAY67", 171, 171, 171},
- {"GRAY68", 173, 173, 173},
- {"GRAY69", 176, 176, 176},
- {"GRAY7", 18, 18, 18},
- {"GRAY70", 179, 179, 179},
- {"GRAY71", 181, 181, 181},
- {"GRAY72", 184, 184, 184},
- {"GRAY73", 186, 186, 186},
- {"GRAY74", 189, 189, 189},
- {"GRAY75", 191, 191, 191},
- {"GRAY76", 194, 194, 194},
- {"GRAY77", 196, 196, 196},
- {"GRAY78", 199, 199, 199},
- {"GRAY79", 201, 201, 201},
- {"GRAY8", 20, 20, 20},
- {"GRAY80", 204, 204, 204},
- {"GRAY81", 207, 207, 207},
- {"GRAY82", 209, 209, 209},
- {"GRAY83", 212, 212, 212},
- {"GRAY84", 214, 214, 214},
- {"GRAY85", 217, 217, 217},
- {"GRAY86", 219, 219, 219},
- {"GRAY87", 222, 222, 222},
- {"GRAY88", 224, 224, 224},
- {"GRAY89", 227, 227, 227},
- {"GRAY9", 23, 23, 23},
- {"GRAY90", 229, 229, 229},
- {"GRAY91", 232, 232, 232},
- {"GRAY92", 235, 235, 235},
- {"GRAY93", 237, 237, 237},
- {"GRAY94", 240, 240, 240},
- {"GRAY95", 242, 242, 242},
- {"GRAY96", 245, 245, 245},
- {"GRAY97", 247, 247, 247},
- {"GRAY98", 250, 250, 250},
- {"GRAY99", 252, 252, 252},
- {"GREEN", 0, 255, 0},
- {"GREENYELLOW", 173, 255, 47},
- {"HONEYDEW", 240, 255, 240},
- {"HOTPINK", 255, 105, 180},
- {"INDIANRED", 107, 57, 57},
- {"IVORY", 255, 255, 240},
- {"KHAKI", 179, 179, 126},
- {"LAVENDER", 230, 230, 250},
- {"LAVENDERBLUSH", 255, 240, 245},
- {"LAWNGREEN", 124, 252, 0},
- {"LEMONCHIFFON", 255, 250, 205},
- {"LIGHTBLUE", 176, 226, 255},
- {"LIGHTCORAL", 240, 128, 128},
- {"LIGHTCYAN", 224, 255, 255},
- {"LIGHTGOLDENROD", 238, 221, 130},
- {"LIGHTGOLDENRODYELLOW", 250, 250, 210},
- {"LIGHTGRAY", 168, 168, 168},
- {"LIGHTPINK", 255, 182, 193},
- {"LIGHTSALMON", 255, 160, 122},
- {"LIGHTSEAGREEN", 32, 178, 170},
- {"LIGHTSKYBLUE", 135, 206, 250},
- {"LIGHTSLATEBLUE", 132, 112, 255},
- {"LIGHTSLATEGRAY", 119, 136, 153},
- {"LIGHTSTEELBLUE", 124, 152, 211},
- {"LIGHTYELLOW", 255, 255, 224},
- {"LIMEGREEN", 0, 175, 20},
- {"LINEN", 250, 240, 230},
- {"MAGENTA", 255, 0, 255},
- {"MAROON", 143, 0, 82},
- {"MEDIUMAQUAMARINE", 0, 147, 143},
- {"MEDIUMBLUE", 50, 50, 204},
- {"MEDIUMFORESTGREEN", 50, 129, 75},
- {"MEDIUMGOLDENROD", 209, 193, 102},
- {"MEDIUMORCHID", 189, 82, 189},
- {"MEDIUMPURPLE", 147, 112, 219},
- {"MEDIUMSEAGREEN", 52, 119, 102},
- {"MEDIUMSLATEBLUE", 106, 106, 141},
- {"MEDIUMSPRINGGREEN", 35, 142, 35},
- {"MEDIUMTURQUOISE", 0, 210, 210},
- {"MEDIUMVIOLETRED", 213, 32, 121},
- {"MIDNIGHTBLUE", 47, 47, 100},
- {"MINTCREAM", 245, 255, 250},
- {"MISTYROSE", 255, 228, 225},
- {"MOCCASIN", 255, 228, 181},
- {"NAVAJOWHITE", 255, 222, 173},
- {"NAVY", 35, 35, 117},
- {"NAVYBLUE", 35, 35, 117},
- {"OLDLACE", 253, 245, 230},
- {"OLIVEDRAB", 107, 142, 35},
- {"ORANGE", 255, 135, 0},
- {"ORANGERED", 255, 69, 0},
- {"ORCHID", 239, 132, 239},
- {"PALEGOLDENROD", 238, 232, 170},
- {"PALEGREEN", 115, 222, 120},
- {"PALETURQUOISE", 175, 238, 238},
- {"PALEVIOLETRED", 219, 112, 147},
- {"PAPAYAWHIP", 255, 239, 213},
- {"PEACHPUFF", 255, 218, 185},
- {"PERU", 205, 133, 63},
- {"PINK", 255, 181, 197},
- {"PLUM", 197, 72, 155},
- {"POWDERBLUE", 176, 224, 230},
- {"PURPLE", 160, 32, 240},
- {"RED", 255, 0, 0},
- {"ROSYBROWN", 188, 143, 143},
- {"ROYALBLUE", 65, 105, 225},
- {"SADDLEBROWN", 139, 69, 19},
- {"SALMON", 233, 150, 122},
- {"SANDYBROWN", 244, 164, 96},
- {"SEAGREEN", 82, 149, 132},
- {"SEASHELL", 255, 245, 238},
- {"SIENNA", 150, 82, 45},
- {"SKYBLUE", 114, 159, 255},
- {"SLATEBLUE", 126, 136, 171},
- {"SLATEGRAY", 112, 128, 144},
- {"SNOW", 255, 250, 250},
- {"SPRINGGREEN", 65, 172, 65},
- {"STEELBLUE", 84, 112, 170},
- {"TAN", 222, 184, 135},
- {"THISTLE", 216, 191, 216},
- {"TOMATO", 255, 99, 71},
- {"TRANSPARENT", 0, 0, 1},
- {"TURQUOISE", 25, 204, 223},
- {"VIOLET", 156, 62, 206},
- {"VIOLETRED", 243, 62, 150},
- {"WHEAT", 245, 222, 179},
- {"WHITE", 255, 255, 255},
- {"WHITESMOKE", 245, 245, 245},
- {"YELLOW", 255, 255, 0},
- {"YELLOWGREEN", 50, 216, 56}
-};
-
-
-PXPM2BMP Xpm2bmp_new()
-{
- PXPM2BMP preturn = (PXPM2BMP)calloc( sizeof( XPM2BMP ) , 1 );
- return preturn;
-}
-
-
-int Xpm2bmp_load( PXPM2BMP pXpm2bmp, const char* filename )
-{
- return CreateBitmapFromXpm( filename, pXpm2bmp );
-}
-
-int Xpm2bmp_paint( PXPM2BMP pXpm2bmp, HDC hdc, int x1,int y1 )
-{
- StretchDIBits(hdc,
- x1, y1, pXpm2bmp->size_x, pXpm2bmp->size_y,
- 0, 0, pXpm2bmp->size_x, pXpm2bmp->size_y,
- pXpm2bmp->wimage_data_trans,
- (BITMAPINFO *)pXpm2bmp->bmih_trans,
- DIB_RGB_COLORS,
- SRCAND );
-
- StretchDIBits(hdc,
- x1, y1, pXpm2bmp->size_x, pXpm2bmp->size_y,
- 0, 0, pXpm2bmp->size_x, pXpm2bmp->size_y,
- pXpm2bmp->wimage_data,
- (BITMAPINFO *)pXpm2bmp->bmih,
- DIB_RGB_COLORS,
- SRCPAINT );
-
- return 0;
-}
-
-static int parse_line_values( const char* line, PXPM2BMP pXpm2bmp )
-{
- int return_value = 0;
- char* parse_line = (char*)line;
- char* tok;
- int value_pos = 0;
-
- parse_line = strchr( parse_line, '"' );
- parse_line++;
-
- tok = strtok( parse_line, " \t\n" );
-
- while ( tok != 0 )
- {
- int val = atoi( tok );
- switch ( value_pos )
- {
- case 0: pXpm2bmp->size_x = val; break;
- case 1: pXpm2bmp->size_y = val; break;
- case 2: pXpm2bmp->colors = val; break;
- case 3: pXpm2bmp->chars_per_pixel = val; break;
- case 4: pXpm2bmp->hotspot_x = val; break;
- case 5: pXpm2bmp->hotspot_y = val; break;
- }
- tok = strtok( NULL, " \t" );
- value_pos ++;
-
- }
-
- return return_value;
-}
-
-static int hex2int( char c )
-{
- if ((c >= '0') && (c <='9' )) return c - '0';
- if ((c >= 'A') && (c <= 'F')) return c - 'A' + 10;
- if ((c >= 'a') && (c <= 'f')) return c - 'a' + 10;
- return -1;
-}
-
-static DWORD string2hex16( const char* str )
-{
- int i1 = hex2int( str[0] );
- int i2 = hex2int( str[1] );
- if ( ( i1 >= 0 ) && ( i2 >= 0 ) )
- return i1*16+i2;
- return -1;
-}
-
-static int parse_color_values( const char* line, PXPM2BMP pXpm2bmp )
-{
- int return_value = 0;
- char* cq = strchr( line, '"' );
- char* cchar = strchr( cq+pXpm2bmp->chars_per_pixel+1, 'c' );
- char* chash = strchr( cq+pXpm2bmp->chars_per_pixel+1, '#' );
- char* qe = strchr( cq+pXpm2bmp->chars_per_pixel+1, '"' );
-
- cq++;
-
- if ( cq )
- {
- memcpy( pXpm2bmp->color_entires[ pXpm2bmp-> color_entires_size].color_str, cq, pXpm2bmp->chars_per_pixel + 1 );
- pXpm2bmp->color_entires[ pXpm2bmp-> color_entires_size].color_str[ pXpm2bmp->chars_per_pixel ] = '\0';
-
-
- if ( cchar && chash && qe)
- {
- chash++;
- *qe = 0;
- int len = strlen( chash );
-
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = string2hex16( &chash[0] );
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = string2hex16( &chash[len / 3] );
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = string2hex16( &chash[len * 2 / 3] );
-#ifdef _DBG
-printf( "adding color %s => %d RGB %lx %lx %lx to index %d\n",
- line,
- pXpm2bmp->color_entires_size,
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r,
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g,
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b,
- pXpm2bmp->color_entires_size );
-#endif
- }
- else
- {
- int q;
- char *start = cchar + 1;
- char *end = start;
-
- while ( *start != 0 )
- {
- if ( ( *start != '\t' ) && ( *start != ' ' ) )
- {
- break;
- }
- start++;
- }
-
- end = start;
- while ( *end != 0 )
- {
- if ( ( *end == '\t' ) || ( *end == ' ' ) || ( *end == '"' ))
- {
- *end = 0;
- }
- end++;
- }
-
- start = strupr( start );
-
- for ( q=0; q < sizeof( theRGBRecords ) / sizeof( theRGBRecords[0] ); q++ )
- {
-
- if ( 0 == strcmp( start, theRGBRecords[q].color_str ) )
- {
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = theRGBRecords[q].r;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = theRGBRecords[q].g;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = theRGBRecords[q].b;
- }
- }
- if ( 0 == strcmp( start, "NONE" ) )
- {
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = 255;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = 0;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = 255;
- }
- }
- }
- pXpm2bmp->color_entires_size++;
-
- return return_value;
-}
-
-static int vv = 0;
-
-static int parse_pixel_line_values( const char* line, PXPM2BMP pXpm2bmp, unsigned char* pixel_data, unsigned char* pixel_data_trans )
-{
- int return_value = 0;
- int i,j;
-
-
- char* cq = strchr( line, '"' );
- int pix_idx = 0;
- int size_x = pXpm2bmp->size_x;
- int len = strlen( cq );
-
- cq++;
-
- if ( len > pXpm2bmp->chars_per_pixel * size_x )
- {
- for ( i=0; i< size_x; i++ )
- {
- int found = 0;
- char* cmp = &cq[ i * pXpm2bmp->chars_per_pixel];
-
- for ( j=0; j< pXpm2bmp-> color_entires_size; j++ )
- {
- if ( strncmp( cmp, pXpm2bmp->color_entires[ j ].color_str, pXpm2bmp->chars_per_pixel ) == 0 )
- {
- int r = pXpm2bmp->color_entires[ j ].r;
- int g = pXpm2bmp->color_entires[ j ].g;
- int b = pXpm2bmp->color_entires[ j ].b;
-
- if ( ( r == 255 ) && ( g == 0 ) && ( r == 255 ) )
- {
- r=g=b=0;
- pixel_data_trans[ pix_idx ] = 255;
- pixel_data_trans[ pix_idx+1 ] = 255;
- pixel_data_trans[ pix_idx+2 ] = 255;
- }
- else
- {
- pixel_data_trans[ pix_idx ] = 0;
- pixel_data_trans[ pix_idx+1 ] = 0;
- pixel_data_trans[ pix_idx+2 ] = 0;
- }
-
- // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].r;
- // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].g;
- // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].b;
- pixel_data[ pix_idx++ ] = b;
- pixel_data[ pix_idx++ ] = g;
- pixel_data[ pix_idx++ ] = r;
- found = 1;
- vv++;
- break;
- }
- }
- if ( !found )
- {
- fprintf( stderr, "XPMLIB: error color not found\n" );
- }
-
- }
- }
- else
- {
- return_value = -1;
- fprintf( stderr, "XPMLIB: invalid line length\n" );
- }
- return return_value;
-}
-
-
-static int CreateBitmapFromXpm( const char* filename, PXPM2BMP pXpm2bmp )
-{
- int return_val = 0;
- unsigned char i, row;
- char line[ 1024 ];
- int nbytes ;
- FILE* file_xpm = fopen( filename, "r" );
-
- int phase = 0;
- row = 0;
-
- if ( file_xpm )
- {
- while ( fgets(line, sizeof( line ), file_xpm ) )
- {
-#ifdef _DBG
- printf( "PARSING: %s\n", line );
-#endif
- if ( line[ 0 ] != '"' )
- continue;
-
- switch ( phase )
- {
- case 0:
- parse_line_values( line, pXpm2bmp );
-#ifdef _DBG
- printf( "size_x %d\n", pXpm2bmp->size_x );
- printf( "size_y %d\n", pXpm2bmp->size_y );
-#endif
- phase = 1;
-
- pXpm2bmp->color_entires_size = 0;
- nbytes = ( pXpm2bmp->chars_per_pixel + 1 ) * pXpm2bmp->colors;
-
- pXpm2bmp->color_entires = calloc( sizeof( XPMCOLORENTRY ), pXpm2bmp->colors + 100 );
- pXpm2bmp->color_entires[0].color_str = calloc( nbytes, pXpm2bmp->colors );
- for ( i = 1; i< pXpm2bmp->colors; i++ )
- {
- pXpm2bmp->color_entires[i].color_str = pXpm2bmp->color_entires[0].color_str + ( pXpm2bmp->chars_per_pixel + 1 ) * i;
- }
-
- if (!(pXpm2bmp->dib = (unsigned char *)malloc(sizeof(BITMAPINFOHEADER) + pXpm2bmp->size_x * pXpm2bmp->size_y * 3)))
- {
- return 4;
- }
- if (!(pXpm2bmp->dib_trans = (unsigned char *)calloc(sizeof(BITMAPINFOHEADER) + pXpm2bmp->size_x * pXpm2bmp->size_y * 3,1)))
- {
- return 4;
- }
-
- memset(pXpm2bmp->dib, 0, sizeof(BITMAPINFOHEADER));
- pXpm2bmp->bmih = (BITMAPINFOHEADER *)pXpm2bmp->dib;
- pXpm2bmp->bmih->biSize = sizeof(BITMAPINFOHEADER);
- pXpm2bmp->bmih->biWidth = pXpm2bmp->size_x;
- pXpm2bmp->bmih->biHeight = -((long)pXpm2bmp->size_y);
- pXpm2bmp->bmih->biPlanes = 1;
- pXpm2bmp->bmih->biBitCount = 24;
- pXpm2bmp->bmih->biCompression = 0;
- pXpm2bmp->wimage_data = pXpm2bmp->dib + sizeof(BITMAPINFOHEADER);
-
-
- pXpm2bmp->bmih_trans = (BITMAPINFOHEADER *)pXpm2bmp->dib_trans;
- pXpm2bmp->bmih_trans->biSize = sizeof(BITMAPINFOHEADER);
- pXpm2bmp->bmih_trans->biWidth = pXpm2bmp->size_x;
- pXpm2bmp->bmih_trans->biHeight = -((long)pXpm2bmp->size_y);
- pXpm2bmp->bmih_trans->biPlanes = 1;
- pXpm2bmp->bmih_trans->biBitCount = 24;
- pXpm2bmp->bmih_trans->biCompression = 0;
- pXpm2bmp->wimage_data_trans = pXpm2bmp->dib_trans + sizeof(BITMAPINFOHEADER);
-// memset( pXpm2bmp->wimage_data_trans, 255, 5* 22 * 3 );
-
- break;
- case 1:
- parse_color_values( line, pXpm2bmp );
- if ( pXpm2bmp->color_entires_size >= pXpm2bmp->colors )
- {
- phase = 2;
- }
-
- break;
- case 2:
- parse_pixel_line_values( line, pXpm2bmp,
- pXpm2bmp->wimage_data + row * pXpm2bmp->size_x * 3,
- pXpm2bmp->wimage_data_trans + row * pXpm2bmp->size_x * 3 );
-
- row++;
- if ( row >= pXpm2bmp->size_y )
- {
- phase = 3;
- }
- break;
- }
-
- }
-
- fclose( file_xpm );
- }
- return return_val;
-}
diff --git a/navit/graphics/win32/xpm2bmp.h b/navit/graphics/win32/xpm2bmp.h
deleted file mode 100644
index 2fa028f1..00000000
--- a/navit/graphics/win32/xpm2bmp.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef Xpm2BMP_H_INCLUDED
-#define Xpm2BMP_H_INCLUDED
-
-#include <windows.h>
-#include "wingdi.h"
-
-typedef struct XPMCOLORENTRY_TAG
-{
- char* color_str;
- unsigned long r;
- unsigned long g;
- unsigned long b;
-} XPMCOLORENTRY, *PXPMCOLORENTRY;
-
-typedef struct XPM2BMP_TAG
-{
- unsigned short size_x;
- unsigned short size_y;
- unsigned short colors;
- unsigned short pixels;
- unsigned short chars_per_pixel;
- unsigned short hotspot_x;
- unsigned short hotspot_y;
-
- int color_entires_size;
- PXPMCOLORENTRY color_entires;
-
- unsigned char *dib;
- unsigned char *wimage_data;
- BITMAPINFOHEADER *bmih;
-
- unsigned char *dib_trans;
- unsigned char *wimage_data_trans;
- BITMAPINFOHEADER *bmih_trans;
-
-} XPM2BMP, *PXPM2BMP;
-
-
-PXPM2BMP Xpm2bmp_new();
-int Xpm2bmp_load( PXPM2BMP pXpm2bmp, const char* filename );
-int Xpm2bmp_paint( PXPM2BMP pXpm2bmp, HDC hdc, int x1,int y1 );
-
-
-#endif // Xpm2BMP_H_INCLUDED