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 |
|
|
380 |
/* a entry that is colored red when filled with invalid distance */ |
/* a entry that is colored red when filled with invalid distance */ |
381 |
GtkWidget *dist_entry_new(float dist, gboolean mil) { |
GtkWidget *dist_entry_new(float dist, gboolean mil) { |
382 |
GdkColor color; |
GdkColor color; |
383 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
384 |
GtkWidget *widget = gtk_entry_new(); |
GtkWidget *widget = gtk_entry_new(); |
385 |
|
#else |
386 |
|
GtkWidget *widget = hildon_entry_new(HILDON_SIZE_AUTO); |
387 |
|
#endif |
388 |
gdk_color_parse("#ff0000", &color); |
gdk_color_parse("#ff0000", &color); |
389 |
gtk_widget_modify_text(widget, TAG_STATE, &color); |
gtk_widget_modify_text(widget, TAG_STATE, &color); |
390 |
|
|
502 |
return gtk_label_new(str); |
return gtk_label_new(str); |
503 |
} |
} |
504 |
|
|
505 |
|
|
506 |
|
GtkWidget *link_icon_button_by_id(appdata_t *appdata, GtkWidget *icon, |
507 |
|
const char *type, int id) { |
508 |
|
|
509 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
510 |
|
if(id) { |
511 |
|
GtkWidget *ref = gtk_button_new(); |
512 |
|
gtk_button_set_image(GTK_BUTTON(ref), icon); |
513 |
|
|
514 |
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5) |
515 |
|
// hildon_gtk_widget_set_theme_size(ref, |
516 |
|
// (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
517 |
|
#endif |
518 |
|
g_object_set_data(G_OBJECT(ref), "id", (gpointer)id); |
519 |
|
g_object_set_data(G_OBJECT(ref), "type", (gpointer)type); |
520 |
|
gtk_signal_connect(GTK_OBJECT(ref), "clicked", |
521 |
|
GTK_SIGNAL_FUNC(on_link_id_clicked), appdata); |
522 |
|
|
523 |
|
return ref; |
524 |
|
} |
525 |
|
#endif |
526 |
|
return icon; |
527 |
|
} |
528 |
|
|
529 |
|
/* left aligned, word wrapped multiline widget */ |
530 |
|
GtkWidget *simple_text_widget(char *text) { |
531 |
|
GtkWidget *label = gtk_label_new(text); |
532 |
|
|
533 |
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
534 |
|
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
535 |
|
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
536 |
|
|
537 |
|
return label; |
538 |
|
} |
539 |
|
|
540 |
|
|
541 |
|
/* a label that is left aligned */ |
542 |
|
GtkWidget *left_label_new(char *str) { |
543 |
|
GtkWidget *widget = gtk_label_new(str); |
544 |
|
gtk_misc_set_alignment(GTK_MISC(widget), 0.0f, 0.5f); |
545 |
|
return widget; |
546 |
|
} |