summaryrefslogtreecommitdiff
path: root/navit/osd.c
blob: b01215e857d1ef70d7cbd31daf0866cfa7868aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
 * Navit, a modular navigation system.
 * Copyright (C) 2005-2008 Navit Team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */

#if 0
//#include <math.h>
#include <stdio.h>
#include <glib.h>
#include "point.h"
//#include "coord.h"
#include "graphics.h"
//#include "transform.h"
//#include "route.h"
#include "vehicle.h"
#include "container.h"
#include "osd.h"

void
osd_set_next_command(char *new_command,char *new_road){
	extern struct container *co;
	// struct osd *this=co->osd;
	strcpy(co->osd->command,new_command);
	strcpy(co->osd->road_name,new_road);
	osd_draw(co->osd, co);
}

void
osd_draw(struct osd *osd, struct container *co)
{
	double *speed;
	struct point p;

	if (! co->vehicle)
		return;

	speed=vehicle_speed_get(co->vehicle);
	osd->gr->draw_mode(osd->gr, draw_mode_begin);
	p.x=0;
	p.y=0;
	osd->gr->draw_rectangle(osd->gr, osd->bg, &p, 360, 80);
	p.x=10;
	p.y=20;
//	osd->gr->draw_text(osd->gr, osd->green, NULL, osd->font, osd->command, &p, 0x13000, 0);
	char osd_data[256];
	sprintf(osd_data,"%.1f km/h",(*speed));
	osd->gr->draw_text(osd->gr, osd->green, NULL, osd->font, osd_data, &p, 0x13000, 0);
	p.x=10;
	p.y=40;
	osd->gr->draw_text(osd->gr, osd->green, NULL, osd->font, osd->command, &p, 0x13000, 0);
//	osd->gr->draw_text(osd->gr, osd->green, NULL, osd->font, "Overlay", &p, 0x10000, 0);
//	printf("Text %s should appear\n",osd->command);
	osd->gr->draw_mode(osd->gr, draw_mode_end);
}


struct osd *
osd_new(struct container *co)
{	
	printf("Spawning an OSD\n");
	struct osd *this=g_new0(struct osd, 1);
	struct point p;
	p.x=100;
	p.y=10;
	this->gr=co->gra->overlay_new(co->gra, &p, 360, 80);
	this->bg=this->gr->gc_new(this->gr);
	this->gr->gc_set_foreground(this->bg, 0, 0, 0);
	this->white=this->gr->gc_new(this->gr);
	this->gr->gc_set_foreground(this->white, 0xffff, 0xffff, 0xffff);
	this->gr->gc_set_linewidth(this->white, 10);
	this->green=this->gr->gc_new(this->gr);
	this->gr->gc_set_foreground(this->green, 0x0, 0xffff, 0x0);
	this->gr->gc_set_linewidth(this->green, 10);
	
	this->font=this->gr->font_new(this->gr, 200);
	osd_draw(this, co);
	return this;	
}
#endif

#include <glib.h>
#include "debug.h"
#include "plugin.h"
#include "osd.h"


struct osd {
	struct osd_methods meth;
	struct osd_priv *priv;
};

struct osd *
osd_new(struct navit *nav, const char *type, struct attr **attrs)
{
        struct osd *o;
        struct osd_priv *(*new)(struct navit *nav, struct osd_methods *meth, struct attr **attrs);

        new=plugin_get_osd_type(type);
        if (! new)
                return NULL;
        o=g_new0(struct osd, 1);
        o->priv=new(nav, &o->meth, attrs);
        return o;
}