26 |
|
|
27 |
#include "gpxview.h" |
#include "gpxview.h" |
28 |
|
|
29 |
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
30 |
|
#include <hildon/hildon-entry.h> |
31 |
|
#endif |
32 |
|
|
33 |
char strlastchr(char *str) { |
char strlastchr(char *str) { |
34 |
return str[strlen(str)]-1; |
return str[strlen(str)]-1; |
35 |
} |
} |
155 |
|
|
156 |
const char *pos_get_bearing_str(pos_t from, pos_t to) { |
const char *pos_get_bearing_str(pos_t from, pos_t to) { |
157 |
static const char *bear_str[]={ |
static const char *bear_str[]={ |
158 |
"N", "NE", "E", "SE", "S", "SW", "W", "NW" }; |
"N", "NE", "E", "SE", "S", "SW", "W", "NW", "" }; |
159 |
int idx = (gpx_pos_get_bearing(from, to)+22.5)/45.0; |
|
160 |
/* make sure we stay in icon bounds */ |
float bearing = gpx_pos_get_bearing(from, to); |
161 |
while(idx < 0) idx += 8; |
if(!isnan(bearing)) { |
162 |
while(idx > 7) idx -= 8; |
int idx = (bearing+22.5)/45.0; |
163 |
return _(bear_str[idx]); |
/* make sure we stay in icon bounds */ |
164 |
|
while(idx < 0) idx += 8; |
165 |
|
while(idx > 7) idx -= 8; |
166 |
|
return _(bear_str[idx]); |
167 |
|
} |
168 |
|
|
169 |
|
return bear_str[8]; // empty string |
170 |
} |
} |
171 |
|
|
172 |
/* the maemo font size is quite huge, so we adjust some fonts */ |
/* the maemo font size is quite huge, so we adjust some fonts */ |
310 |
/* a entry that is colored red when being "active" */ |
/* a entry that is colored red when being "active" */ |
311 |
GtkWidget *lat_entry_new(float lat) { |
GtkWidget *lat_entry_new(float lat) { |
312 |
GdkColor color; |
GdkColor color; |
313 |
|
|
314 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
315 |
GtkWidget *widget = gtk_entry_new(); |
GtkWidget *widget = gtk_entry_new(); |
316 |
|
#else |
317 |
|
GtkWidget *widget = hildon_entry_new(HILDON_SIZE_AUTO); |
318 |
|
#endif |
319 |
|
|
320 |
gdk_color_parse("#ff0000", &color); |
gdk_color_parse("#ff0000", &color); |
321 |
gtk_widget_modify_text(widget, TAG_STATE, &color); |
gtk_widget_modify_text(widget, TAG_STATE, &color); |
322 |
|
|
338 |
/* a entry that is colored red when filled with invalid coordinate */ |
/* a entry that is colored red when filled with invalid coordinate */ |
339 |
GtkWidget *lon_entry_new(float lon) { |
GtkWidget *lon_entry_new(float lon) { |
340 |
GdkColor color; |
GdkColor color; |
341 |
|
|
342 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
343 |
GtkWidget *widget = gtk_entry_new(); |
GtkWidget *widget = gtk_entry_new(); |
344 |
|
#else |
345 |
|
GtkWidget *widget = hildon_entry_new(HILDON_SIZE_AUTO); |
346 |
|
// gtk_entry_set_width_chars(GTK_ENTRY(widget), 14); |
347 |
|
#endif |
348 |
|
|
349 |
gdk_color_parse("#ff0000", &color); |
gdk_color_parse("#ff0000", &color); |
350 |
gtk_widget_modify_text(widget, TAG_STATE, &color); |
gtk_widget_modify_text(widget, TAG_STATE, &color); |
351 |
|
|