summaryrefslogtreecommitdiff
path: root/navit/gui
diff options
context:
space:
mode:
Diffstat (limited to 'navit/gui')
-rw-r--r--navit/gui/gtk/CMakeLists.txt3
-rw-r--r--navit/gui/gtk/datawindow.c292
-rw-r--r--navit/gui/gtk/destination.c980
-rw-r--r--navit/gui/gtk/gui_gtk.h51
-rw-r--r--navit/gui/gtk/gui_gtk_action.c790
-rw-r--r--navit/gui/gtk/gui_gtk_poi.c685
-rw-r--r--navit/gui/gtk/gui_gtk_statusbar.c279
-rw-r--r--navit/gui/gtk/gui_gtk_window.c1299
-rw-r--r--navit/gui/internal/CMakeLists.txt4
-rw-r--r--navit/gui/internal/gui_internal.c5634
-rw-r--r--navit/gui/internal/gui_internal.h107
-rw-r--r--navit/gui/internal/gui_internal_bookmark.c486
-rw-r--r--navit/gui/internal/gui_internal_command.c2280
-rw-r--r--navit/gui/internal/gui_internal_gesture.c184
-rw-r--r--navit/gui/internal/gui_internal_html.c843
-rw-r--r--navit/gui/internal/gui_internal_keyboard.c1029
-rw-r--r--navit/gui/internal/gui_internal_keyboard.h30
-rw-r--r--navit/gui/internal/gui_internal_menu.c750
-rw-r--r--navit/gui/internal/gui_internal_menu.h5
-rw-r--r--navit/gui/internal/gui_internal_poi.c1260
-rw-r--r--navit/gui/internal/gui_internal_poi.h69
-rw-r--r--navit/gui/internal/gui_internal_priv.h274
-rw-r--r--navit/gui/internal/gui_internal_search.c1055
-rw-r--r--navit/gui/internal/gui_internal_widget.c2439
-rw-r--r--navit/gui/internal/gui_internal_widget.h242
-rw-r--r--navit/gui/qml/CMakeLists.txt20
-rw-r--r--navit/gui/qml/bookmarksProxy.h6
-rw-r--r--navit/gui/qml/guiProxy.h4
-rw-r--r--navit/gui/qml/gui_qml.cpp739
-rw-r--r--navit/gui/qml/navitProxy.h2
-rw-r--r--navit/gui/qml/ngqpoint.h12
-rw-r--r--navit/gui/qml/proxy.h6
-rw-r--r--navit/gui/qml/routeProxy.h6
-rw-r--r--navit/gui/qml/searchProxy.h16
-rw-r--r--navit/gui/qml/skins/navit/ButtonIcon.qml78
-rw-r--r--navit/gui/qml/skins/navit/Cellar.qml4
-rw-r--r--navit/gui/qml/skins/navit/ListSelector.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageAbout.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageBookmarks.qml12
-rw-r--r--navit/gui/qml/skins/navit/PageBookmarksAdd.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageNavigate.qml6
-rw-r--r--navit/gui/qml/skins/navit/PagePoi.qml8
-rw-r--r--navit/gui/qml/skins/navit/PagePointInfo.qml8
-rw-r--r--navit/gui/qml/skins/navit/PageRoute.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageSearch.qml16
-rw-r--r--navit/gui/qml/skins/navit/PageSearchSelector.qml14
-rw-r--r--navit/gui/qml/skins/navit/PageSettings.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsDisplay.qml10
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsLocale.qml8
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsRules.qml72
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsTools.qml8
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsVehicle.qml10
-rw-r--r--navit/gui/qml/skins/navit/Slider.qml2
-rw-r--r--navit/gui/qml/skins/navit/ToggleButton.qml8
-rw-r--r--navit/gui/qml/skins/navit/ToggleSwitch.qml4
-rw-r--r--navit/gui/qml/skins/navit/command.js12
-rw-r--r--navit/gui/qml/skins/navit/main.qml8
-rw-r--r--navit/gui/qt5_qml/backend.cpp731
-rw-r--r--navit/gui/qt5_qml/editor/main.cpp3
-rw-r--r--navit/gui/qt5_qml/gui_qt5_qml.cpp68
-rw-r--r--navit/gui/qt5_qml/proxy.c11
-rw-r--r--navit/gui/qt5_qml/qml_bookmark.cpp15
-rw-r--r--navit/gui/qt5_qml/qml_map.cpp18
-rw-r--r--navit/gui/qt5_qml/qml_poi.cpp33
-rw-r--r--navit/gui/qt5_qml/qml_search.cpp21
-rw-r--r--navit/gui/qt5_qml/qml_vehicle.cpp24
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.cog.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.cogs.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.layer.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.map.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.power.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.rocket.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg2
-rw-r--r--navit/gui/qt5_qml/skins/menu.qml2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/main.qml2
-rw-r--r--navit/gui/qt5_qml/skins/modern/menu.qml2
-rw-r--r--navit/gui/qt5_qml/skins/pois.qml10
-rw-r--r--navit/gui/win32/CMakeLists.txt2
-rw-r--r--navit/gui/win32/ceglue.c149
-rw-r--r--navit/gui/win32/ceglue.h32
-rw-r--r--navit/gui/win32/gui_win32.c865
-rw-r--r--navit/gui/win32/win32_gui_destination.c142
-rw-r--r--navit/gui/win32/win32_gui_notify.c118
108 files changed, 12244 insertions, 12267 deletions
diff --git a/navit/gui/gtk/CMakeLists.txt b/navit/gui/gtk/CMakeLists.txt
index a1dfa173c..1a1ec2a7a 100644
--- a/navit/gui/gtk/CMakeLists.txt
+++ b/navit/gui/gtk/CMakeLists.txt
@@ -1,2 +1,3 @@
-module_add_library(gui_gtk datawindow.c destination.c gui_gtk_statusbar.c gui_gtk_action.c gui_gtk_window.c gui_gtk_poi.c)
+module_add_library(gui_gtk datawindow.c destination.c gui_gtk_statusbar.c gui_gtk_action.c gui_gtk_window.c
+ gui_gtk_poi.c)
diff --git a/navit/gui/gtk/datawindow.c b/navit/gui/gtk/datawindow.c
index dd71ce999..afe977dbc 100644
--- a/navit/gui/gtk/datawindow.c
+++ b/navit/gui/gtk/datawindow.c
@@ -29,186 +29,172 @@
#include "gui_gtk.h"
struct datawindow_priv {
- GtkWidget *window;
- GtkWidget *scrolled_window;
- GtkWidget *treeview;
- GtkWidget *button;
- GtkListStore *liststore;
- GtkTreeModel *sortmodel;
- struct callback *click, *close;
- struct gui_priv *gui;
+ GtkWidget *window;
+ GtkWidget *scrolled_window;
+ GtkWidget *treeview;
+ GtkWidget *button;
+ GtkListStore *liststore;
+ GtkTreeModel *sortmodel;
+ struct callback *click, *close;
+ struct gui_priv *gui;
};
static GValue value;
-static void
-select_row(GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, struct datawindow_priv *win)
-{
- char *cols[20];
- GtkTreeIter iter;
- GtkTreeModel *model;
- int i;
-
- dbg(lvl_debug,"win=%p\n", win);
-
- model=gtk_tree_view_get_model(tree);
- gtk_tree_model_get_iter(model, &iter, path);
-
- for (i=0;i<gtk_tree_model_get_n_columns(model);i++) {
- gtk_tree_model_get_value(model, &iter, i, &value);
- cols[i]=g_strdup_value_contents(&value)+1;
- cols[i][strlen(cols[i])-1]='\0';
- g_value_unset(&value);
- }
- callback_call_1(win->click, cols);
+static void select_row(GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, struct datawindow_priv *win) {
+ char *cols[20];
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ int i;
+
+ dbg(lvl_debug,"win=%p", win);
+
+ model=gtk_tree_view_get_model(tree);
+ gtk_tree_model_get_iter(model, &iter, path);
+
+ for (i=0; i<gtk_tree_model_get_n_columns(model); i++) {
+ gtk_tree_model_get_value(model, &iter, i, &value);
+ cols[i]=g_strdup_value_contents(&value)+1;
+ cols[i][strlen(cols[i])-1]='\0';
+ g_value_unset(&value);
+ }
+ callback_call_1(win->click, cols);
}
-static void
-gui_gtk_datawindow_add(struct datawindow_priv *win, struct param_list *param, int count)
-{
- int i;
- GtkCellRenderer *cell;
- GtkTreeIter iter;
- GType types[count];
-
- if (! win->treeview) {
- win->treeview=gtk_tree_view_new();
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
- gtk_container_add(GTK_CONTAINER(win->scrolled_window), win->treeview);
- gtk_widget_show_all(GTK_WIDGET(win->window));
- gtk_widget_grab_focus(GTK_WIDGET(win->treeview));
-
- /* add column names to treeview */
- for(i=0;i<count;i++) {
- if (param[i].name) {
- cell=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (win->treeview),-1,param[i].name,
- cell,"text",i, NULL);
- }
- }
+static void gui_gtk_datawindow_add(struct datawindow_priv *win, struct param_list *param, int count) {
+ int i;
+ GtkCellRenderer *cell;
+ GtkTreeIter iter;
+ GType types[count];
+
+ if (! win->treeview) {
+ win->treeview=gtk_tree_view_new();
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
+ gtk_container_add(GTK_CONTAINER(win->scrolled_window), win->treeview);
+ gtk_widget_show_all(GTK_WIDGET(win->window));
+ gtk_widget_grab_focus(GTK_WIDGET(win->treeview));
+
+ /* add column names to treeview */
+ for(i=0; i<count; i++) {
+ if (param[i].name) {
+ cell=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (win->treeview),-1,param[i].name,
+ cell,"text",i, NULL);
+ }
+ }
#if 0
- g_signal_connect(G_OBJECT(win->treeview), "click-column", G_CALLBACK(click_column), NULL);
+ g_signal_connect(G_OBJECT(win->treeview), "click-column", G_CALLBACK(click_column), NULL);
#endif
- g_signal_connect(G_OBJECT(win->treeview), "row-activated", G_CALLBACK(select_row), win);
- }
-
- /* find data storage and create a new one if none is there */
- if (gtk_tree_view_get_model(GTK_TREE_VIEW (win->treeview)) == NULL) {
- for(i=0;i<count;i++) {
- if (param[i].name && !strcmp(param[i].name, "Distance"))
- types[i]=G_TYPE_INT;
- else
- types[i]=G_TYPE_STRING;
- }
- win->liststore=gtk_list_store_newv(count,types);
- if (! strcmp(param[0].name, "Distance")) {
- win->sortmodel=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(win->liststore));
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (win->sortmodel), 0, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->sortmodel));
- } else
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->liststore));
- }
-
- gtk_list_store_append(win->liststore,&iter);
-
- /* add data to data storage */
- for(i=0;i<count;i++) {
- if (param[i].name && !strcmp(param[i].name, "Distance")) {
- gtk_list_store_set(win->liststore,&iter,i,atoi(param[i].value),-1);
- } else {
- gtk_list_store_set(win->liststore,&iter,i,param[i].value,-1);
- }
- }
+ g_signal_connect(G_OBJECT(win->treeview), "row-activated", G_CALLBACK(select_row), win);
+ }
+
+ /* find data storage and create a new one if none is there */
+ if (gtk_tree_view_get_model(GTK_TREE_VIEW (win->treeview)) == NULL) {
+ for(i=0; i<count; i++) {
+ if (param[i].name && !strcmp(param[i].name, "Distance"))
+ types[i]=G_TYPE_INT;
+ else
+ types[i]=G_TYPE_STRING;
+ }
+ win->liststore=gtk_list_store_newv(count,types);
+ if (! strcmp(param[0].name, "Distance")) {
+ win->sortmodel=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(win->liststore));
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (win->sortmodel), 0, GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->sortmodel));
+ } else
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->liststore));
+ }
+
+ gtk_list_store_append(win->liststore,&iter);
+
+ /* add data to data storage */
+ for(i=0; i<count; i++) {
+ if (param[i].name && !strcmp(param[i].name, "Distance")) {
+ gtk_list_store_set(win->liststore,&iter,i,atoi(param[i].value),-1);
+ } else {
+ gtk_list_store_set(win->liststore,&iter,i,param[i].value,-1);
+ }
+ }
}
-static void
-gui_gtk_datawindow_mode(struct datawindow_priv *win, int start)
-{
- if (start) {
- if (win && win->treeview) {
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
- }
- }
+static void gui_gtk_datawindow_mode(struct datawindow_priv *win, int start) {
+ if (start) {
+ if (win && win->treeview) {
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
+ }
+ }
}
-static gboolean
-gui_gtk_datawindow_delete(GtkWidget *widget, GdkEvent *event, struct datawindow_priv *win)
-{
- callback_call_0(win->close);
+static gboolean gui_gtk_datawindow_delete(GtkWidget *widget, GdkEvent *event, struct datawindow_priv *win) {
+ callback_call_0(win->close);
- if (win->button) {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(win->button), FALSE);
- }
+ if (win->button) {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(win->button), FALSE);
+ }
- return FALSE;
+ return FALSE;
}
-void
-gui_gtk_datawindow_destroy(struct datawindow_priv *win)
-{
- if ((!win->gui) || (!win->gui->datawindow)) {
- return;
- }
+void gui_gtk_datawindow_destroy(struct datawindow_priv *win) {
+ if ((!win->gui) || (!win->gui->datawindow)) {
+ return;
+ }
- gui_gtk_datawindow_delete(NULL, NULL, win);
- gtk_widget_destroy(win->window);
- win->gui->datawindow = NULL;
+ gui_gtk_datawindow_delete(NULL, NULL, win);
+ gtk_widget_destroy(win->window);
+ win->gui->datawindow = NULL;
- return;
+ return;
}
-void
-gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn)
-{
- this_->button = btn;
+void gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn) {
+ this_->button = btn;
}
-static gboolean
-keypress(GtkWidget *widget, GdkEventKey *event, struct datawindow_priv *win)
-{
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
- if (event->keyval == GDK_Cancel) {
- gui_gtk_datawindow_delete(widget, (GdkEvent *)event, win);
- gtk_widget_destroy(win->window);
- }
- return FALSE;
+static gboolean keypress(GtkWidget *widget, GdkEventKey *event, struct datawindow_priv *win) {
+ if (event->type != GDK_KEY_PRESS)
+ return FALSE;
+ if (event->keyval == GDK_Cancel) {
+ gui_gtk_datawindow_delete(widget, (GdkEvent *)event, win);
+ gtk_widget_destroy(win->window);
+ }
+ return FALSE;
}
static struct datawindow_methods gui_gtk_datawindow_meth = {
- gui_gtk_datawindow_destroy,
- gui_gtk_datawindow_add,
- gui_gtk_datawindow_mode,
+ gui_gtk_datawindow_destroy,
+ gui_gtk_datawindow_add,
+ gui_gtk_datawindow_mode,
};
struct datawindow_priv *
-gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click, struct callback *close, struct datawindow_methods *meth)
-{
- struct datawindow_priv *win;
-
- if (!gui)
- return NULL;
- *meth=gui_gtk_datawindow_meth;
- win=g_new0(struct datawindow_priv, 1);
- win->window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(win->window), 320, 200);
- gtk_window_set_title(GTK_WINDOW(win->window), name);
- gtk_window_set_wmclass (GTK_WINDOW (win->window), "navit", "Navit");
-
- win->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win->scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(win->window), win->scrolled_window);
- g_signal_connect(G_OBJECT(win->window), "key-press-event", G_CALLBACK(keypress), win);
- win->treeview=NULL;
- win->click=click;
- win->close=close;
- gtk_window_set_transient_for(GTK_WINDOW((GtkWidget *)(win->window)), GTK_WINDOW(gui->win));
- g_signal_connect(G_OBJECT(win->window), "delete-event", G_CALLBACK(gui_gtk_datawindow_delete), win);
- gtk_widget_show_all(win->window);
-
- win->gui = gui;
- gui->datawindow = win;
- return win;
+gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click, struct callback *close,
+ struct datawindow_methods *meth) {
+ struct datawindow_priv *win;
+
+ if (!gui)
+ return NULL;
+ *meth=gui_gtk_datawindow_meth;
+ win=g_new0(struct datawindow_priv, 1);
+ win->window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size(GTK_WINDOW(win->window), 320, 200);
+ gtk_window_set_title(GTK_WINDOW(win->window), name);
+ gtk_window_set_wmclass (GTK_WINDOW (win->window), "navit", "Navit");
+
+ win->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win->scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(win->window), win->scrolled_window);
+ g_signal_connect(G_OBJECT(win->window), "key-press-event", G_CALLBACK(keypress), win);
+ win->treeview=NULL;
+ win->click=click;
+ win->close=close;
+ gtk_window_set_transient_for(GTK_WINDOW((GtkWidget *)(win->window)), GTK_WINDOW(gui->win));
+ g_signal_connect(G_OBJECT(win->window), "delete-event", G_CALLBACK(gui_gtk_datawindow_delete), win);
+ gtk_widget_show_all(win->window);
+
+ win->gui = gui;
+ gui->datawindow = win;
+ return win;
}
diff --git a/navit/gui/gtk/destination.c b/navit/gui/gtk/destination.c
index 18fc58b75..6a0fbb5b7 100644
--- a/navit/gui/gtk/destination.c
+++ b/navit/gui/gtk/destination.c
@@ -37,293 +37,295 @@
#define COL_COUNT 8
static struct search_param {
- struct navit *nav;
- struct mapset *ms;
- struct search_list *sl;
- struct attr attr;
- int partial;
- GtkWidget *entry_country, *entry_postal, *entry_city, *entry_district;
- GtkWidget *entry_street, *entry_number;
- GtkWidget *listbox;
- GtkWidget *treeview;
- GtkListStore *liststore;
- GtkTreeModel *liststore2;
+ struct navit *nav;
+ struct mapset *ms;
+ struct search_list *sl;
+ struct attr attr;
+ int partial;
+ GtkWidget *entry_country, *entry_postal, *entry_city, *entry_district;
+ GtkWidget *entry_street, *entry_number;
+ GtkWidget *listbox;
+ GtkWidget *treeview;
+ GtkListStore *liststore;
+ GtkTreeModel *liststore2;
} search_param;
-static void button_map(GtkWidget *widget, struct search_param *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- struct pcoord *c=NULL;
- GtkTreeIter iter;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
- if(!path)
- return;
- if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
- return;
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
- if (c) {
- navit_set_center(search->nav, c, 1);
- }
-}
-static char *description(struct search_param *search, GtkTreeIter *iter)
-{
- char *desc,*car,*postal,*town,*street;
- char empty='\0';
-
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 0, &car, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 1, &postal, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 2, &town, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 4, &street, -1);
-
- /* protect against nulls */
+static char *description(struct search_param *search, GtkTreeIter *iter) {
+ char *desc,*car,*postal,*town,*street;
+ char empty='\0';
+
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 0, &car, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 1, &postal, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 2, &town, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 4, &street, -1);
+
+ /* protect against nulls */
if (car==0) car=&empty;
- if (postal==0) postal=&empty;
+ if (postal==0) postal=&empty;
if (town==0) town=&empty;
if (street==0) street=&empty;
-
- if (search->attr.type == attr_town_name)
- desc=g_strdup_printf("%s-%s %s", car, postal, town);
- else
- desc=g_strdup_printf("%s-%s %s, %s", car, postal, town, street);
- return desc;
+
+ if (search->attr.type == attr_town_name)
+ desc=g_strdup_printf("%s-%s %s", car, postal, town);
+ else
+ desc=g_strdup_printf("%s-%s %s, %s", car, postal, town, street);
+ return desc;
}
-static void button_destination(GtkWidget *widget, struct search_param *search)
-{
- struct pcoord *c=NULL;
- GtkTreeIter iter;
- char *desc;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
- return;
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
- if (c) {
- desc=description(search, &iter);
- navit_set_destination(search->nav, c, desc, 1);
- g_free(desc);
- }
+static void button_map(GtkWidget *widget, struct search_param *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ struct pcoord *point=NULL; /* A pointer on the geographical position of the selected map point */
+ GtkTreeIter iter;
+ char *label;
+ GList* p;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
+ if(!path)
+ return;
+ if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
+ return;
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &point, -1);
+ if (point) {
+ GList* list = NULL;
+ struct lcoord *result = g_new0(struct lcoord, 1);
+ result->c.x=point->x;
+ result->c.y=point->y;
+ result->label=description(search, &iter); /* Allocated here, freed by invoking g_free() below when parsing the GList */
+ list = g_list_prepend(list, result);
+ navit_populate_search_results_map(search->nav, list, NULL);
+ /* Parse the GList starting at list and free all payloads before freeing the list itself */
+ for(p=list; p; p=g_list_next(p)) {
+ if (((struct lcoord *)(p->data))->label)
+ g_free(((struct lcoord *)(p->data))->label);
+ }
+ g_list_free(list);
+
+ navit_set_center(search->nav, point, 1);
+ }
}
-static void button_bookmark(GtkWidget *widget, struct search_param *search)
-{
- struct pcoord *c=NULL;
- GtkTreeIter iter;
- char *desc;
- struct attr attr;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
- return;
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
- if (c) {
- navit_get_attr(search->nav, attr_bookmarks, &attr, NULL);
- desc=description(search, &iter);
- bookmarks_add_bookmark(attr.u.bookmarks, c, desc);
- g_free(desc);
- }
+static void button_destination(GtkWidget *widget, struct search_param *search) {
+ struct pcoord *c=NULL;
+ GtkTreeIter iter;
+ char *desc;
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
+ return;
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
+ if (c) {
+ desc=description(search, &iter);
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+ navit_set_destination(search->nav, c, desc, 1);
+ g_free(desc);
+ }
+}
+
+static void button_bookmark(GtkWidget *widget, struct search_param *search) {
+ struct pcoord *c=NULL;
+ GtkTreeIter iter;
+ char *desc;
+ struct attr attr;
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
+ return;
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
+ if (c) {
+ navit_get_attr(search->nav, attr_bookmarks, &attr, NULL);
+ desc=description(search, &iter);
+ bookmarks_add_bookmark(attr.u.bookmarks, c, desc);
+ g_free(desc);
+ }
}
char **columns_text[] = {
- (char *[]){_n("Car"),_n("Iso2"),_n("Iso3"),_n("Country"),NULL},
- (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),NULL},
- (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),NULL},
- (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),_n("Number"),NULL},
+ (char *[]){_n("Car"),_n("Iso2"),_n("Iso3"),_n("Country"),NULL},
+ (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),NULL},
+ (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),NULL},
+ (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),_n("Number"),NULL},
};
-static void set_columns(struct search_param *param, int mode)
-{
- GList *columns_list,*columns;
- char **column_text=columns_text[mode];
- int i=0;
-
- columns_list=gtk_tree_view_get_columns(GTK_TREE_VIEW(param->treeview));
- columns=columns_list;
- while (columns) {
- gtk_tree_view_remove_column(GTK_TREE_VIEW(param->treeview), columns->data);
- columns=g_list_next(columns);
- }
- g_list_free(columns_list);
- while (*column_text) {
- GtkCellRenderer *cell=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (param->treeview),-1, navit_nls_gettext(*column_text), cell, "text", i, NULL);
- i++;
- column_text++;
- }
+static void set_columns(struct search_param *param, int mode) {
+ GList *columns_list,*columns;
+ char **column_text=columns_text[mode];
+ int i=0;
+
+ columns_list=gtk_tree_view_get_columns(GTK_TREE_VIEW(param->treeview));
+ columns=columns_list;
+ while (columns) {
+ gtk_tree_view_remove_column(GTK_TREE_VIEW(param->treeview), columns->data);
+ columns=g_list_next(columns);
+ }
+ g_list_free(columns_list);
+ while (*column_text) {
+ GtkCellRenderer *cell=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (param->treeview),-1, navit_nls_gettext(*column_text), cell,
+ "text", i, NULL);
+ i++;
+ column_text++;
+ }
}
-static void row_activated(GtkWidget *widget, GtkTreePath *p1, GtkTreeViewColumn *c, struct search_param *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- GtkWidget *entry_widget;
- char *str;
- int column;
-
- dbg(lvl_debug,"enter\n");
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
- if(!path)
- return;
- if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
- return;
- switch(search->attr.type) {
- case attr_country_all:
- entry_widget=search->entry_country;
- column=3;
- break;
- case attr_town_name:
- entry_widget=search->entry_city;
- column=2;
- break;
- case attr_street_name:
- entry_widget=search->entry_street;
- column=4;
- break;
- default:
- dbg(lvl_debug,"Unknown mode\n");
- return;
- }
- gtk_tree_model_get(search->liststore2, &iter, column, &str, -1);
- dbg(lvl_debug,"str=%s\n", str);
- search->partial=0;
- gtk_entry_set_text(GTK_ENTRY(entry_widget), str);
+static void row_activated(GtkWidget *widget, GtkTreePath *p1, GtkTreeViewColumn *c, struct search_param *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ GtkWidget *entry_widget;
+ char *str;
+ int column;
+
+ dbg(lvl_debug,"enter");
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
+ if(!path)
+ return;
+ if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
+ return;
+ switch(search->attr.type) {
+ case attr_country_all:
+ entry_widget=search->entry_country;
+ column=3;
+ break;
+ case attr_town_name:
+ entry_widget=search->entry_city;
+ column=2;
+ break;
+ case attr_street_name:
+ entry_widget=search->entry_street;
+ column=4;
+ break;
+ default:
+ dbg(lvl_debug,"Unknown mode");
+ return;
+ }
+ gtk_tree_model_get(search->liststore2, &iter, column, &str, -1);
+ dbg(lvl_debug,"str=%s", str);
+ search->partial=0;
+ gtk_entry_set_text(GTK_ENTRY(entry_widget), str);
}
-static void tree_view_button_release(GtkWidget *widget, GdkEventButton *event, struct search_param *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *column;
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &column);
- gtk_tree_view_row_activated(GTK_TREE_VIEW(search->treeview), path, column);
-
+static void tree_view_button_release(GtkWidget *widget, GdkEventButton *event, struct search_param *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &column);
+ gtk_tree_view_row_activated(GTK_TREE_VIEW(search->treeview), path, column);
+
}
-static void
-next_focus(struct search_param *search, GtkWidget *widget)
-{
- if (widget == search->entry_country)
- gtk_widget_grab_focus(search->entry_city);
- if (widget == search->entry_city)
- gtk_widget_grab_focus(search->entry_street);
- if (widget == search->entry_street)
- gtk_widget_grab_focus(search->entry_number);
-
+static void next_focus(struct search_param *search, GtkWidget *widget) {
+ if (widget == search->entry_country)
+ gtk_widget_grab_focus(search->entry_city);
+ if (widget == search->entry_city)
+ gtk_widget_grab_focus(search->entry_street);
+ if (widget == search->entry_street)
+ gtk_widget_grab_focus(search->entry_number);
+
}
-static void changed(GtkWidget *widget, struct search_param *search)
-{
- struct search_list_result *res;
- GtkTreeIter iter;
-
- search->attr.u.str=(char *)gtk_entry_get_text(GTK_ENTRY(widget));
- printf("changed %s partial %d\n", search->attr.u.str, search->partial);
- if (widget == search->entry_country) {
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
- dbg(lvl_debug,"country\n");
- search->attr.type=attr_country_all;
- set_columns(search, 0);
- }
- if (widget == search->entry_postal) {
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 1, GTK_SORT_ASCENDING);
- dbg(lvl_debug,"postal\n");
- search->attr.type=attr_town_postal;
- if (strlen(search->attr.u.str) < 2)
- return;
- set_columns(search, 1);
- }
- if (widget == search->entry_city) {
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 2, GTK_SORT_ASCENDING);
- dbg(lvl_debug,"town\n");
- search->attr.type=attr_town_name;
- if (strlen(search->attr.u.str) < 3)
- return;
- set_columns(search, 1);
- }
- if (widget == search->entry_street) {
- dbg(lvl_debug,"street\n");
- search->attr.type=attr_street_name;
- // Searching for a street by just its first letter generates too many hits to be useful,
- // plus it causes the GUI to become unresponsive because the search is single-threaded.
- // So we only start searching once we have two letters.
- if (strlen(search->attr.u.str) < 2)
- return;
- set_columns(search, 2);
- }
-
- search_list_search(search->sl, &search->attr, search->partial);
- gtk_list_store_clear(search->liststore);
- while((res=search_list_get_result(search->sl))) {
- gtk_list_store_append(search->liststore,&iter);
- gtk_list_store_set(search->liststore,&iter,COL_COUNT,res->c,-1);
- if (widget == search->entry_country) {
- if (res->country) {
- gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
- gtk_list_store_set(search->liststore,&iter,1,res->country->iso3,-1);
- gtk_list_store_set(search->liststore,&iter,2,res->country->iso2,-1);
- gtk_list_store_set(search->liststore,&iter,3,res->country->name,-1);
- }
- } else {
- if (res->country)
- gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
- else
- gtk_list_store_set(search->liststore,&iter,0,"",-1);
- if (res->town) {
- gtk_list_store_set(search->liststore,&iter,1,res->town->common.postal,-1);
- gtk_list_store_set(search->liststore,&iter,2,res->town->common.town_name,-1);
- gtk_list_store_set(search->liststore,&iter,3,res->town->common.district_name,-1);
- } else {
- gtk_list_store_set(search->liststore,&iter,1,"",-1);
- gtk_list_store_set(search->liststore,&iter,2,"",-1);
- gtk_list_store_set(search->liststore,&iter,3,"",-1);
- }
- if (res->street)
- gtk_list_store_set(search->liststore,&iter,4,res->street->name,-1);
- else
- gtk_list_store_set(search->liststore,&iter,4,"",-1);
-
- }
- }
-
- if(! search->partial)
- {
- if( widget == search->entry_country )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
- }
- if( widget == search->entry_city )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
- }
- if( widget == search->entry_street )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), TRUE);
- }
- } else {
- if( widget == search->entry_country )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- }
- if( widget == search->entry_city )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- }
- if( widget == search->entry_street )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- }
- }
- if (! search->partial)
- next_focus(search, widget);
- search->partial=1;
+static void changed(GtkWidget *widget, struct search_param *search) {
+ struct search_list_result *res;
+ GtkTreeIter iter;
+
+ search->attr.u.str=(char *)gtk_entry_get_text(GTK_ENTRY(widget));
+ printf("changed %s partial %d\n", search->attr.u.str, search->partial);
+ if (widget == search->entry_country) {
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
+ dbg(lvl_debug,"country");
+ search->attr.type=attr_country_all;
+ set_columns(search, 0);
+ }
+ if (widget == search->entry_postal) {
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 1, GTK_SORT_ASCENDING);
+ dbg(lvl_debug,"postal");
+ search->attr.type=attr_town_postal;
+ if (strlen(search->attr.u.str) < 2)
+ return;
+ set_columns(search, 1);
+ }
+ if (widget == search->entry_city) {
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 2, GTK_SORT_ASCENDING);
+ dbg(lvl_debug,"town");
+ search->attr.type=attr_town_name;
+ if (strlen(search->attr.u.str) < 3)
+ return;
+ set_columns(search, 1);
+ }
+ if (widget == search->entry_street) {
+ dbg(lvl_debug,"street");
+ search->attr.type=attr_street_name;
+ // Searching for a street by just its first letter generates too many hits to be useful,
+ // plus it causes the GUI to become unresponsive because the search is single-threaded.
+ // So we only start searching once we have two letters.
+ if (strlen(search->attr.u.str) < 2)
+ return;
+ set_columns(search, 2);
+ }
+
+ search_list_search(search->sl, &search->attr, search->partial);
+ gtk_list_store_clear(search->liststore);
+ while((res=search_list_get_result(search->sl))) {
+ gtk_list_store_append(search->liststore,&iter);
+ gtk_list_store_set(search->liststore,&iter,COL_COUNT,res->c,-1);
+ if (widget == search->entry_country) {
+ if (res->country) {
+ gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
+ gtk_list_store_set(search->liststore,&iter,1,res->country->iso3,-1);
+ gtk_list_store_set(search->liststore,&iter,2,res->country->iso2,-1);
+ gtk_list_store_set(search->liststore,&iter,3,res->country->name,-1);
+ }
+ } else {
+ if (res->country)
+ gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
+ else
+ gtk_list_store_set(search->liststore,&iter,0,"",-1);
+ if (res->town) {
+ gtk_list_store_set(search->liststore,&iter,1,res->town->common.postal,-1);
+ gtk_list_store_set(search->liststore,&iter,2,res->town->common.town_name,-1);
+ gtk_list_store_set(search->liststore,&iter,3,res->town->common.district_name,-1);
+ } else {
+ gtk_list_store_set(search->liststore,&iter,1,"",-1);
+ gtk_list_store_set(search->liststore,&iter,2,"",-1);
+ gtk_list_store_set(search->liststore,&iter,3,"",-1);
+ }
+ if (res->street)
+ gtk_list_store_set(search->liststore,&iter,4,res->street->name,-1);
+ else
+ gtk_list_store_set(search->liststore,&iter,4,"",-1);
+
+ }
+ }
+
+ if(! search->partial) {
+ if( widget == search->entry_country ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
+ }
+ if( widget == search->entry_city ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
+ }
+ if( widget == search->entry_street ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), TRUE);
+ }
+ } else {
+ if( widget == search->entry_country ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ }
+ if( widget == search->entry_city ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ }
+ if( widget == search->entry_street ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ }
+ }
+ if (! search->partial)
+ next_focus(search, widget);
+ search->partial=1;
}
/* borrowed from gpe-login */
@@ -331,252 +333,238 @@ static void changed(GtkWidget *widget, struct search_param *search)
#define MAX_ARGS 8
-static void
-parse_xkbd_args (const char *cmd, char **argv)
-{
- const char *p = cmd;
- char buf[strlen (cmd) + 1], *bufp = buf;
- int nargs = 0;
- int escape = 0, squote = 0, dquote = 0;
-
- while (*p)
- {
- if (escape)
- {
- *bufp++ = *p;
- escape = 0;
- }
- else
- {
- switch (*p)
- {
- case '\\':
- escape = 1;
- break;
- case '"':
- if (squote)
- *bufp++ = *p;
- else
- dquote = !dquote;
- break;
- case '\'':
- if (dquote)
- *bufp++ = *p;
- else
- squote = !squote;
- break;
- case ' ':
- if (!squote && !dquote)
- {
- *bufp = 0;
- if (nargs < MAX_ARGS)
- argv[nargs++] = strdup (buf);
- bufp = buf;
- break;
- }
- default:
- *bufp++ = *p;
- break;
- }
- }
- p++;
- }
-
- if (bufp != buf)
- {
- *bufp = 0;
- if (nargs < MAX_ARGS)
- argv[nargs++] = strdup (buf);
- }
- argv[nargs] = NULL;
+static void parse_xkbd_args (const char *cmd, char **argv) {
+ const char *p = cmd;
+ char buf[strlen (cmd) + 1], *bufp = buf;
+ int nargs = 0;
+ int escape = 0, squote = 0, dquote = 0;
+
+ while (*p) {
+ if (escape) {
+ *bufp++ = *p;
+ escape = 0;
+ } else {
+ switch (*p) {
+ case '\\':
+ escape = 1;
+ break;
+ case '"':
+ if (squote)
+ *bufp++ = *p;
+ else
+ dquote = !dquote;
+ break;
+ case '\'':
+ if (dquote)
+ *bufp++ = *p;
+ else
+ squote = !squote;
+ break;
+ case ' ':
+ if (!squote && !dquote) {
+ *bufp = 0;
+ if (nargs < MAX_ARGS)
+ argv[nargs++] = strdup (buf);
+ bufp = buf;
+ break;
+ }
+ default:
+ *bufp++ = *p;
+ break;
+ }
+ }
+ p++;
+ }
+
+ if (bufp != buf) {
+ *bufp = 0;
+ if (nargs < MAX_ARGS)
+ argv[nargs++] = strdup (buf);
+ }
+ argv[nargs] = NULL;
}
int kbd_pid;
-static int
-spawn_xkbd (char *xkbd_path, char *xkbd_str)
-{
+static int spawn_xkbd (char *xkbd_path, char *xkbd_str) {
#ifdef _WIN32 // AF FIXME for WIN32
- #ifndef F_SETFD
- #define F_SETFD 2
- #endif
+#ifndef F_SETFD
+#define F_SETFD 2
+#endif
#else
- char *xkbd_args[MAX_ARGS + 1];
- int fd[2];
- char buf[256];
- char c;
- int a = 0;
- size_t n;
-
- pipe (fd);
- kbd_pid = fork ();
- if (kbd_pid == 0)
- {
- close (fd[0]);
- if (dup2 (fd[1], 1) < 0)
- perror ("dup2");
- close (fd[1]);
- if (fcntl (1, F_SETFD, 0))
- perror ("fcntl");
- xkbd_args[0] = (char *)xkbd_path;
- xkbd_args[1] = "-xid";
- if (xkbd_str)
- parse_xkbd_args (xkbd_str, xkbd_args + 2);
- else
- xkbd_args[2] = NULL;
- execvp (xkbd_path, xkbd_args);
- perror (xkbd_path);
- _exit (1);
- }
- close (fd[1]);
- do {
- n = read (fd[0], &c, 1);
- if (n)
- {
- buf[a++] = c;
- }
- } while (n && (c != 10) && (a < (sizeof (buf) - 1)));
-
- if (a)
- {
- buf[a] = 0;
- return atoi (buf);
- }
+ char *xkbd_args[MAX_ARGS + 1];
+ int fd[2];
+ char buf[256];
+ char c;
+ int a = 0;
+ size_t n;
+
+ pipe (fd);
+ kbd_pid = fork ();
+ if (kbd_pid == 0) {
+ close (fd[0]);
+ if (dup2 (fd[1], 1) < 0)
+ perror ("dup2");
+ close (fd[1]);
+ if (fcntl (1, F_SETFD, 0))
+ perror ("fcntl");
+ xkbd_args[0] = (char *)xkbd_path;
+ xkbd_args[1] = "-xid";
+ if (xkbd_str)
+ parse_xkbd_args (xkbd_str, xkbd_args + 2);
+ else
+ xkbd_args[2] = NULL;
+ execvp (xkbd_path, xkbd_args);
+ perror (xkbd_path);
+ _exit (1);
+ }
+ close (fd[1]);
+ do {
+ n = read (fd[0], &c, 1);
+ if (n) {
+ buf[a++] = c;
+ }
+ } while (n && (c != 10) && (a < (sizeof (buf) - 1)));
+
+ if (a) {
+ buf[a] = 0;
+ return atoi (buf);
+ }
#endif
- return 0;
+ return 0;
}
-int destination_address(struct navit *nav)
-{
-
- GtkWidget *window2, *keyboard, *vbox, *table;
- GtkWidget *label_country;
- GtkWidget *label_postal, *label_city, *label_district;
- GtkWidget *label_street, *label_number;
- GtkWidget *button1,*button2,*button3;
- int i;
- struct search_param *search=&search_param;
- struct attr search_attr, country_name, *country_attr;
- struct tracking *tracking;
- struct country_search *cs;
- struct item *item;
-
-
- search->nav=nav;
- search->ms=navit_get_mapset(nav);
- search->sl=search_list_new(search->ms);
-
- window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window2),_("Enter Destination"));
- gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
- gtk_window_set_default_size (GTK_WINDOW (window2),0,300);
- vbox = gtk_vbox_new(FALSE, 0);
- table = gtk_table_new(3, 8, FALSE);
-
- search->entry_country = gtk_entry_new();
- label_country = gtk_label_new(_("Country"));
- search->entry_postal = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_postal), FALSE);
- label_postal = gtk_label_new(_("Zip Code"));
- search->entry_city = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
- label_city = gtk_label_new(_("City"));
- search->entry_district = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_district), FALSE);
- label_district = gtk_label_new(_("District/Township"));
- search->entry_street = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
- label_street = gtk_label_new(_("Street"));
- search->entry_number = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- label_number = gtk_label_new(_("Number"));
- search->treeview=gtk_tree_view_new();
- search->listbox = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (search->listbox),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), NULL);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(search->listbox),search->treeview);
- {
- GType types[COL_COUNT+1];
- for(i=0;i<COL_COUNT;i++)
- types[i]=G_TYPE_STRING;
- types[i]=G_TYPE_POINTER;
- search->liststore=gtk_list_store_newv(COL_COUNT+1,types);
- search->liststore2=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->liststore));
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), GTK_TREE_MODEL(search->liststore2));
- }
-
-
-
-
- button1 = gtk_button_new_with_label(_("Map"));
- button2 = gtk_button_new_with_label(_("Bookmark"));
- button3 = gtk_button_new_with_label(_("Destination"));
-
- gtk_table_attach(GTK_TABLE(table), label_country, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_postal, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_city, 2, 3, 0, 1, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), search->entry_country, 0, 1, 1, 2, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_postal, 1, 2, 1, 2, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_city, 2, 3, 1, 2, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), label_district, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_street, 1, 2, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_number, 2, 3, 2, 3, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), search->entry_district, 0, 1, 3, 4, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_street, 1, 2, 3, 4, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_number, 2, 3, 3, 4, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), search->listbox, 0, 3, 4, 5, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), button1, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), button2, 1, 2, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), button3, 2, 3, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
-
- g_signal_connect(G_OBJECT(search->entry_country), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_postal), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_city), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_district), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_street), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_number), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(button_map), search);
- g_signal_connect(G_OBJECT(button2), "clicked", G_CALLBACK(button_bookmark), search);
- g_signal_connect(G_OBJECT(button3), "clicked", G_CALLBACK(button_destination), search);
- g_signal_connect(G_OBJECT(search->treeview), "button-release-event", G_CALLBACK(tree_view_button_release), search);
- g_signal_connect(G_OBJECT(search->treeview), "row_activated", G_CALLBACK(row_activated), search);
-
- gtk_widget_grab_focus(search->entry_city);
-
- gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
- keyboard=gtk_socket_new();
- gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(window2), vbox);
+int destination_address(struct navit *nav) {
+
+ GtkWidget *window2, *keyboard, *vbox, *table;
+ GtkWidget *label_country;
+ GtkWidget *label_postal, *label_city, *label_district;
+ GtkWidget *label_street, *label_number;
+ GtkWidget *button1,*button2,*button3;
+ int i;
+ struct search_param *search=&search_param;
+ struct attr search_attr, country_name, *country_attr;
+ struct tracking *tracking;
+ struct country_search *cs;
+ struct item *item;
+
+
+ search->nav=nav;
+ search->ms=navit_get_mapset(nav);
+ search->sl=search_list_new(search->ms);
+
+ window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window2),_("Enter Destination"));
+ gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
+ gtk_window_set_default_size (GTK_WINDOW (window2),0,300);
+ vbox = gtk_vbox_new(FALSE, 0);
+ table = gtk_table_new(3, 8, FALSE);
+
+ search->entry_country = gtk_entry_new();
+ label_country = gtk_label_new(_("Country"));
+ search->entry_postal = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_postal), FALSE);
+ label_postal = gtk_label_new(_("Zip Code"));
+ search->entry_city = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
+ label_city = gtk_label_new(_("City"));
+ search->entry_district = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_district), FALSE);
+ label_district = gtk_label_new(_("District/Township"));
+ search->entry_street = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
+ label_street = gtk_label_new(_("Street"));
+ search->entry_number = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ label_number = gtk_label_new(_("Number"));
+ search->treeview=gtk_tree_view_new();
+ search->listbox = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (search->listbox),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), NULL);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(search->listbox),search->treeview);
+ {
+ GType types[COL_COUNT+1];
+ for(i=0; i<COL_COUNT; i++)
+ types[i]=G_TYPE_STRING;
+ types[i]=G_TYPE_POINTER;
+ search->liststore=gtk_list_store_newv(COL_COUNT+1,types);
+ search->liststore2=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->liststore));
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), GTK_TREE_MODEL(search->liststore2));
+ }
+
+
+
+
+ button1 = gtk_button_new_with_label(_("Map"));
+ button2 = gtk_button_new_with_label(_("Bookmark"));
+ button3 = gtk_button_new_with_label(_("Destination"));
+
+ gtk_table_attach(GTK_TABLE(table), label_country, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_postal, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_city, 2, 3, 0, 1, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), search->entry_country, 0, 1, 1, 2, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_postal, 1, 2, 1, 2, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_city, 2, 3, 1, 2, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), label_district, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_street, 1, 2, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_number, 2, 3, 2, 3, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), search->entry_district, 0, 1, 3, 4, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_street, 1, 2, 3, 4, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_number, 2, 3, 3, 4, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), search->listbox, 0, 3, 4, 5, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0,
+ 0);
+
+ gtk_table_attach(GTK_TABLE(table), button1, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), button2, 1, 2, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), button3, 2, 3, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
+
+ g_signal_connect(G_OBJECT(search->entry_country), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_postal), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_city), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_district), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_street), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_number), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(button_map), search);
+ g_signal_connect(G_OBJECT(button2), "clicked", G_CALLBACK(button_bookmark), search);
+ g_signal_connect(G_OBJECT(button3), "clicked", G_CALLBACK(button_destination), search);
+ g_signal_connect(G_OBJECT(search->treeview), "button-release-event", G_CALLBACK(tree_view_button_release), search);
+ g_signal_connect(G_OBJECT(search->treeview), "row_activated", G_CALLBACK(row_activated), search);
+
+ gtk_widget_grab_focus(search->entry_city);
+
+ gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ keyboard=gtk_socket_new();
+ gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window2), vbox);
#if 0
- g_signal_connect(G_OBJECT(listbox), "select-row", G_CALLBACK(select_row), NULL);
+ g_signal_connect(G_OBJECT(listbox), "select-row", G_CALLBACK(select_row), NULL);
#endif
- gtk_widget_show_all(window2);
+ gtk_widget_show_all(window2);
#ifndef _WIN32
- gtk_socket_steal(GTK_SOCKET(keyboard), spawn_xkbd("xkbd","-geometry 200x100"));
+ gtk_socket_steal(GTK_SOCKET(keyboard), spawn_xkbd("xkbd","-geometry 200x100"));
#endif
- country_attr=country_default();
- tracking=navit_get_tracking(nav);
- if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
- country_attr=&search_attr;
- if (country_attr) {
- cs=country_search_new(country_attr, 0);
- item=country_search_get_item(cs);
- if (item && item_attr_get(item, attr_country_name, &country_name))
- gtk_entry_set_text(GTK_ENTRY(search->entry_country), country_name.u.str);
- country_search_destroy(cs);
- } else {
- dbg(lvl_error,"warning: no default country found\n");
- }
- search->partial=1;
- return 0;
+ country_attr=country_default();
+ tracking=navit_get_tracking(nav);
+ if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
+ country_attr=&search_attr;
+ if (country_attr) {
+ cs=country_search_new(country_attr, 0);
+ item=country_search_get_item(cs);
+ if (item && item_attr_get(item, attr_country_name, &country_name))
+ gtk_entry_set_text(GTK_ENTRY(search->entry_country), country_name.u.str);
+ country_search_destroy(cs);
+ } else {
+ dbg(lvl_error,"warning: no default country found");
+ }
+ search->partial=1;
+ return 0;
}
diff --git a/navit/gui/gtk/gui_gtk.h b/navit/gui/gtk/gui_gtk.h
index 10051beaf..c8c3ca1ec 100644
--- a/navit/gui/gtk/gui_gtk.h
+++ b/navit/gui/gtk/gui_gtk.h
@@ -26,37 +26,38 @@ struct callback;
struct statusbar_priv;
struct gui_priv {
- struct navit *nav;
- GtkWidget *win;
- GtkWidget *dialog_win;
- GtkWidget *dialog_entry;
- struct pcoord dialog_coord;
- GtkWidget *vbox;
- GtkWidget *menubar;
- GtkActionGroup *base_group;
- GtkActionGroup *debug_group;
- GtkActionGroup *dyn_group;
- GtkUIManager *ui_manager;
- GSList *layout_group;
- GSList *projection_group;
- GSList *vehicle_group;
- GList *dest_menuitems;
- GList *bookmarks_menuitems;
- GList *vehicle_menuitems;
- GtkUIManager *menu_manager; // old
- struct statusbar_priv *statusbar;
- int menubar_enable;
- int toolbar_enable;
- int statusbar_enable;
- int dyn_counter;
- struct datawindow_priv *datawindow;
+ struct navit *nav;
+ GtkWidget *win;
+ GtkWidget *dialog_win;
+ GtkWidget *dialog_entry;
+ struct pcoord dialog_coord;
+ GtkWidget *vbox;
+ GtkWidget *menubar;
+ GtkActionGroup *base_group;
+ GtkActionGroup *debug_group;
+ GtkActionGroup *dyn_group;
+ GtkUIManager *ui_manager;
+ GSList *layout_group;
+ GSList *projection_group;
+ GSList *vehicle_group;
+ GList *dest_menuitems;
+ GList *bookmarks_menuitems;
+ GList *vehicle_menuitems;
+ GtkUIManager *menu_manager; // old
+ struct statusbar_priv *statusbar;
+ int menubar_enable;
+ int toolbar_enable;
+ int statusbar_enable;
+ int dyn_counter;
+ struct datawindow_priv *datawindow;
};
void gui_gtk_ui_init(struct gui_priv *this);
struct menu_priv *gui_gtk_menubar_new(struct gui_priv *gui, struct menu_methods *meth);
struct statusbar_priv *gui_gtk_statusbar_new(struct gui_priv *gui);
struct menu_priv *gui_gtk_popup_new(struct gui_priv *gui, struct menu_methods *meth);
-struct datawindow_priv *gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click, struct callback *close, struct datawindow_methods *meth);
+struct datawindow_priv *gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click,
+ struct callback *close, struct datawindow_methods *meth);
void gui_gtk_datawindow_destroy(struct datawindow_priv *win);
void gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn);
diff --git a/navit/gui/gtk/gui_gtk_action.c b/navit/gui/gtk/gui_gtk_action.c
index 0d6acee48..ca5ff9427 100644
--- a/navit/gui/gtk/gui_gtk_action.c
+++ b/navit/gui/gtk/gui_gtk_action.c
@@ -36,94 +36,80 @@
#include "gui_gtk_poi.h"
struct menu_priv {
- char *path;
- GtkAction *action;
- struct gui_priv *gui;
- enum menu_type type;
- struct callback *cb;
- struct menu_priv *child;
- struct menu_priv *sibling;
- gulong handler_id;
- guint merge_id;
- GtkWidget *widget;
+ char *path;
+ GtkAction *action;
+ struct gui_priv *gui;
+ enum menu_type type;
+ struct callback *cb;
+ struct menu_priv *child;
+ struct menu_priv *sibling;
+ gulong handler_id;
+ guint merge_id;
+ GtkWidget *widget;
};
/* Create callbacks that implement our Actions */
-static void
-zoom_in_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_zoom_in(gui->nav, 2, NULL);
+static void zoom_in_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_zoom_in(gui->nav, 2, NULL);
}
-static void
-zoom_out_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_zoom_out(gui->nav, 2, NULL);
+static void zoom_out_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_zoom_out(gui->nav, 2, NULL);
}
-static void
-refresh_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_draw(gui->nav);
+static void refresh_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_draw(gui->nav);
}
-// Forward declarations, these should not be visible outside the GUI, so
+// Forward declarations, these should not be visible outside the GUI, so
// they are not in the header files, but here
void gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn);
void gui_gtk_datawindow_destroy(struct datawindow_priv *win);
-static void
-roadbook_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
-
- if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
- gui_gtk_datawindow_destroy(gui->datawindow);
- } else {
- navit_window_roadbook_new(gui->nav);
- if (gui->datawindow) {
- gui_gtk_datawindow_set_button(gui->datawindow, w);
- }
- }
+static void roadbook_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+
+ if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
+ gui_gtk_datawindow_destroy(gui->datawindow);
+ } else {
+ navit_window_roadbook_new(gui->nav);
+ if (gui->datawindow) {
+ gui_gtk_datawindow_set_button(gui->datawindow, w);
+ }
+ }
}
-static void
-autozoom_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr autozoom_attr;
-
- autozoom_attr.type = attr_autozoom_active;
- if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
- autozoom_attr.u.num = 0;
- } else {
- autozoom_attr.u.num = 1;
- }
-
- navit_set_attr(gui->nav, &autozoom_attr);
+static void autozoom_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr autozoom_attr;
+
+ autozoom_attr.type = attr_autozoom_active;
+ if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
+ autozoom_attr.u.num = 0;
+ } else {
+ autozoom_attr.u.num = 1;
+ }
+
+ navit_set_attr(gui->nav, &autozoom_attr);
}
-static void
-cursor_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void cursor_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_cursor;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_cursor\n");
- }
+ attr.type=attr_cursor;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_cursor");
+ }
}
-static void
-tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_tracking;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_tracking\n");
- }
+ attr.type=attr_tracking;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_tracking");
+ }
}
/** @brief Toggles the ability to follow the vehicle at the
@@ -135,270 +121,251 @@ tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
* @return void
*/
-static void
-follow_vehicle_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void follow_vehicle_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_follow_cursor;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_follow_gps\n");
- }
+ attr.type=attr_follow_cursor;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_follow_gps");
+ }
}
-static void
-orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_orientation;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)) ? 0:-1;
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_orientation\n");
- }
+ attr.type=attr_orientation;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)) ? 0:-1;
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_orientation");
+ }
}
-static void
-window_fullscreen_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- if(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)))
- gtk_window_fullscreen(GTK_WINDOW(gui->win));
- else
- gtk_window_unfullscreen(GTK_WINDOW(gui->win));
+static void window_fullscreen_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ if(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)))
+ gtk_window_fullscreen(GTK_WINDOW(gui->win));
+ else
+ gtk_window_unfullscreen(GTK_WINDOW(gui->win));
}
#include <stdlib.h>
#include "point.h"
#include "transform.h"
-static void
-info_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- char buffer[512];
- int mw,mh;
- struct coord lt, rb;
- struct point p;
- struct transformation *t;
-
- t=navit_get_trans(gui->nav);
- transform_get_size(t, &mw, &mh);
- p.x=0;
- p.y=0;
- transform_reverse(t, &p, &lt);
- p.x=mw;
- p.y=mh;
- transform_reverse(t, &p, &rb);
-
- sprintf(buffer,"./info.sh %d,%d 0x%x,0x%x 0x%x,0x%x", mw, mh, lt.x, lt.y, rb.x, rb.y);
- system(buffer);
+static void info_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ char buffer[512];
+ int mw,mh;
+ struct coord lt, rb;
+ struct point p;
+ struct transformation *t;
+
+ t=navit_get_trans(gui->nav);
+ transform_get_size(t, &mw, &mh);
+ p.x=0;
+ p.y=0;
+ transform_reverse(t, &p, &lt);
+ p.x=mw;
+ p.y=mh;
+ transform_reverse(t, &p, &rb);
+
+ sprintf(buffer,"./info.sh %d,%d 0x%x,0x%x 0x%x,0x%x", mw, mh, lt.x, lt.y, rb.x, rb.y);
+ system(buffer);
}
-static void
-route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_set_destination(gui->nav, NULL, NULL, 0);
+static void route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_set_destination(gui->nav, NULL, NULL, 0);
}
-static void
-poi_search_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- gtk_gui_poi(gui->nav);
+static void poi_search_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ gtk_gui_poi(gui->nav);
}
-static void
-destination_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- destination_address(gui->nav);
+static void destination_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ destination_address(gui->nav);
}
-static void
-quit_action (GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_destroy(gui->nav);
- exit(0);
+static void quit_action (GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_destroy(gui->nav);
+ exit(0);
}
-static GtkActionEntry entries[] =
-{
- /* TRANSLATORS: These texts are for menu items in GTK GUI. The _ indicates the mnemonic key (=underlined character) for this menu item. Please place the _ before a suitable character in the translation (or omit it if no mnemonic key is desired). */
- { "DisplayMenuAction", NULL, _n("_Display") },
- { "RouteMenuAction", NULL, _n("_Route") },
- { "FormerDestinationMenuAction", NULL, _n("_Former Destinations") },
- { "BookmarkMenuAction", NULL, _n("_Bookmarks") },
- { "MapMenuAction", NULL, _n("_Map") },
- { "LayoutMenuAction", NULL, _n("_Layout") },
- { "ProjectionMenuAction", NULL, _n("_Projection") },
- { "VehicleMenuAction", NULL, _n("_Vehicle") },
- { "ZoomOutAction", GTK_STOCK_ZOOM_OUT, _n("Zoom_Out"), "<control>minus", _n("Decrease zoom level"), G_CALLBACK(zoom_out_action) },
- { "ZoomInAction", GTK_STOCK_ZOOM_IN, _n("Zoom_In"), "<control>plus", _n("Increase zoom level"), G_CALLBACK(zoom_in_action) },
- { "RefreshAction", GTK_STOCK_REFRESH, _n("_Recalculate"), "<control>R", _n("Redraw map"), G_CALLBACK(refresh_action) },
+static GtkActionEntry entries[] = {
+ /* TRANSLATORS: These texts are for menu items in GTK GUI. The _ indicates the mnemonic key (=underlined character) for this menu item. Please place the _ before a suitable character in the translation (or omit it if no mnemonic key is desired). */
+ { "DisplayMenuAction", NULL, _n("_Display") },
+ { "RouteMenuAction", NULL, _n("_Route") },
+ { "FormerDestinationMenuAction", NULL, _n("_Former Destinations") },
+ { "BookmarkMenuAction", NULL, _n("_Bookmarks") },
+ { "MapMenuAction", NULL, _n("_Map") },
+ { "LayoutMenuAction", NULL, _n("_Layout") },
+ { "ProjectionMenuAction", NULL, _n("_Projection") },
+ { "VehicleMenuAction", NULL, _n("_Vehicle") },
+ { "ZoomOutAction", GTK_STOCK_ZOOM_OUT, _n("Zoom_Out"), "<control>minus", _n("Decrease zoom level"), G_CALLBACK(zoom_out_action) },
+ { "ZoomInAction", GTK_STOCK_ZOOM_IN, _n("Zoom_In"), "<control>plus", _n("Increase zoom level"), G_CALLBACK(zoom_in_action) },
+ { "RefreshAction", GTK_STOCK_REFRESH, _n("_Recalculate"), "<control>R", _n("Redraw map"), G_CALLBACK(refresh_action) },
#ifdef GTK_STOCK_INFO
- { "InfoAction", GTK_STOCK_INFO, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
+ { "InfoAction", GTK_STOCK_INFO, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
#else
- { "InfoAction", NULL, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
+ { "InfoAction", NULL, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
#endif /*GTK_STOCK_INFO*/
- { "DestinationAction", "flag_icon", _n("Set _destination"), "<control>D", _n("Opens address search dialog"), G_CALLBACK(destination_action) },
- { "POIAction", "flag_icon", _n("_POI search"), "<control>P", _n("Opens POI search dialog"), G_CALLBACK(poi_search_action) },
- { "RouteClearAction", NULL, _n("_Stop Navigation"), "<control>S", NULL, G_CALLBACK(route_clear_action) },
- { "Test", NULL, _n("Test"), NULL, NULL, G_CALLBACK(destination_action) },
- { "QuitAction", GTK_STOCK_QUIT, _n("_Quit"), "<control>Q",_n("Quit the application"), G_CALLBACK (quit_action) }
+ { "DestinationAction", "flag_icon", _n("Set _destination"), "<control>D", _n("Opens address search dialog"), G_CALLBACK(destination_action) },
+ { "POIAction", "flag_icon", _n("_POI search"), "<control>P", _n("Opens POI search dialog"), G_CALLBACK(poi_search_action) },
+ { "RouteClearAction", NULL, _n("_Stop Navigation"), "<control>S", NULL, G_CALLBACK(route_clear_action) },
+ { "Test", NULL, _n("Test"), NULL, NULL, G_CALLBACK(destination_action) },
+ { "QuitAction", GTK_STOCK_QUIT, _n("_Quit"), "<control>Q",_n("Quit the application"), G_CALLBACK (quit_action) }
};
static guint n_entries = G_N_ELEMENTS (entries);
-static GtkToggleActionEntry toggleentries[] =
-{
- { "CursorAction", "cursor_icon",_n("Show position _cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE },
- { "TrackingAction", NULL ,_n("_Lock on Road"), NULL, NULL, G_CALLBACK(tracking_action),TRUE },
- { "FollowVehicleAction", NULL ,_n("_Follow Vehicle"), NULL, NULL, G_CALLBACK(follow_vehicle_action),TRUE },
- { "OrientationAction", "orientation_icon", _n("_Keep orientation to the North"), NULL, _n("Switches map orientation to the north or the vehicle"), G_CALLBACK(orient_north_action),FALSE },
- { "RoadbookAction", GTK_STOCK_JUSTIFY_FILL, _n("_Roadbook"), "<control>B", _n("Show/hide route description"), G_CALLBACK(roadbook_action), FALSE },
- { "AutozoomAction", GTK_STOCK_ZOOM_FIT, _n("_Autozoom"), "<control>A", _n("Enable/disable automatic zoom level changing"), G_CALLBACK(autozoom_action), FALSE },
+static GtkToggleActionEntry toggleentries[] = {
+ { "CursorAction", "cursor_icon",_n("Show position _cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE },
+ { "TrackingAction", NULL,_n("_Lock on Road"), NULL, NULL, G_CALLBACK(tracking_action),TRUE },
+ { "FollowVehicleAction", NULL,_n("_Follow Vehicle"), NULL, NULL, G_CALLBACK(follow_vehicle_action),TRUE },
+ { "OrientationAction", "orientation_icon", _n("_Keep orientation to the North"), NULL, _n("Switches map orientation to the north or the vehicle"), G_CALLBACK(orient_north_action),FALSE },
+ { "RoadbookAction", GTK_STOCK_JUSTIFY_FILL, _n("_Roadbook"), "<control>B", _n("Show/hide route description"), G_CALLBACK(roadbook_action), FALSE },
+ { "AutozoomAction", GTK_STOCK_ZOOM_FIT, _n("_Autozoom"), "<control>A", _n("Enable/disable automatic zoom level changing"), G_CALLBACK(autozoom_action), FALSE },
#ifdef GTK_STOCK_FULLSCREEN
- { "FullscreenAction",GTK_STOCK_FULLSCREEN, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
+ { "FullscreenAction",GTK_STOCK_FULLSCREEN, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
#else
- { "FullscreenAction", NULL, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
+ { "FullscreenAction", NULL, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
#endif /*GTK_STOCK_FULLSCREEN*/
};
static guint n_toggleentries = G_N_ELEMENTS (toggleentries);
-static GtkActionEntry debug_entries[] =
-{
- { "DataMenuAction", NULL, _n("Data") },
+static GtkActionEntry debug_entries[] = {
+ { "DataMenuAction", NULL, _n("Data") },
};
static guint n_debug_entries = G_N_ELEMENTS (debug_entries);
static const char * cursor_xpm[] = {
-"22 22 2 1",
-" c None",
-". c #0000FF",
-" ",
-" ",
-" ",
-" .. ",
-" .. .. ",
-" .. .. ",
-" . . ",
-" . . ",
-" . ... . ",
-" . ... . . ",
-" . ... . . ",
-" . .. . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" .. .. ",
-" .. .. ",
-" .. ",
-" ",
-" ",
-" "};
+ "22 22 2 1",
+ " c None",
+ ". c #0000FF",
+ " ",
+ " ",
+ " ",
+ " .. ",
+ " .. .. ",
+ " .. .. ",
+ " . . ",
+ " . . ",
+ " . ... . ",
+ " . ... . . ",
+ " . ... . . ",
+ " . .. . . ",
+ " . . . ",
+ " . . . ",
+ " . . . ",
+ " . . . ",
+ " .. .. ",
+ " .. .. ",
+ " .. ",
+ " ",
+ " ",
+ " "
+};
static const char * north_xpm[] = {
-"22 22 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" . ",
-" ... ",
-" . . . ",
-" . . . ",
-" . ",
-" .... . .... ",
-" .... . .... ",
-" .... . .. ",
-" .. .. .. ",
-" .. .. .. ",
-" .. .. .. ",
-" .. .. .. ",
-" .. . .... ",
-" .... . .... ",
-" .... . .... ",
-" . ",
-" . ",
-" . ",
-" ",
-" "};
+ "22 22 2 1",
+ " c None",
+ ". c #000000",
+ " ",
+ " ",
+ " . ",
+ " ... ",
+ " . . . ",
+ " . . . ",
+ " . ",
+ " .... . .... ",
+ " .... . .... ",
+ " .... . .. ",
+ " .. .. .. ",
+ " .. .. .. ",
+ " .. .. .. ",
+ " .. .. .. ",
+ " .. . .... ",
+ " .... . .... ",
+ " .... . .... ",
+ " . ",
+ " . ",
+ " . ",
+ " ",
+ " "
+};
static const char * flag_xpm[] = {
-"22 22 2 1",
-" c None",
-"+ c #000000",
-"+++++++ ",
-"+ +++++++++ ",
-"+ +++ +++++++++ ",
-"+ +++ +++ +++ ",
-"++++ +++ +++ ",
-"++++ +++ +++ ",
-"++++ +++ +++ + ",
-"+ ++++++ +++ + ",
-"+ +++ ++++++ + ",
-"+ +++ +++ +++ ",
-"++++ +++ +++ ",
-"++++ +++ +++ ",
-"++++++++++ +++ + ",
-"+ +++++++++ + ",
-"+ ++++++ ",
-"+ ",
-"+ ",
-"+ ",
-"+ ",
-"+ ",
-"+ ",
-"+ "};
+ "22 22 2 1",
+ " c None",
+ "+ c #000000",
+ "+++++++ ",
+ "+ +++++++++ ",
+ "+ +++ +++++++++ ",
+ "+ +++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++ +++ +++ + ",
+ "+ ++++++ +++ + ",
+ "+ +++ ++++++ + ",
+ "+ +++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++++++++ +++ + ",
+ "+ +++++++++ + ",
+ "+ ++++++ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ "
+};
static struct {
- gchar *stockid;
- const char **icon_xpm;
+ gchar *stockid;
+ const char **icon_xpm;
} stock_icons[] = {
- {"cursor_icon", cursor_xpm },
- {"orientation_icon", north_xpm },
- {"flag_icon", flag_xpm }
+ {"cursor_icon", cursor_xpm },
+ {"orientation_icon", north_xpm },
+ {"flag_icon", flag_xpm }
};
static gint n_stock_icons = G_N_ELEMENTS (stock_icons);
-static void
-register_my_stock_icons (void)
-{
- GtkIconFactory *icon_factory;
- GtkIconSet *icon_set;
- GdkPixbuf *pixbuf;
- gint i;
+static void register_my_stock_icons (void) {
+ GtkIconFactory *icon_factory;
+ GtkIconSet *icon_set;
+ GdkPixbuf *pixbuf;
+ gint i;
- icon_factory = gtk_icon_factory_new ();
+ icon_factory = gtk_icon_factory_new ();
- for (i = 0; i < n_stock_icons; i++)
- {
- pixbuf = gdk_pixbuf_new_from_xpm_data(stock_icons[i].icon_xpm);
- icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
- g_object_unref(pixbuf);
- gtk_icon_factory_add (icon_factory, stock_icons[i].stockid, icon_set);
- gtk_icon_set_unref (icon_set);
- }
+ for (i = 0; i < n_stock_icons; i++) {
+ pixbuf = gdk_pixbuf_new_from_xpm_data(stock_icons[i].icon_xpm);
+ icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
+ g_object_unref(pixbuf);
+ gtk_icon_factory_add (icon_factory, stock_icons[i].stockid, icon_set);
+ gtk_icon_set_unref (icon_set);
+ }
- gtk_icon_factory_add_default(icon_factory);
+ gtk_icon_factory_add_default(icon_factory);
- g_object_unref(icon_factory);
+ g_object_unref(icon_factory);
}
static char layout[] =
- "<ui>\
+ "<ui>\
<menubar name=\"MenuBar\">\
<menu name=\"Display\" action=\"DisplayMenuAction\">\
<menuitem name=\"Zoom in\" action=\"ZoomInAction\" />\
@@ -464,200 +431,187 @@ static char layout[] =
</ui>";
-static void
-activate(void *dummy, struct menu_priv *menu)
-{
- if (menu->cb)
- callback_call_0(menu->cb);
+static void activate(void *dummy, struct menu_priv *menu) {
+ if (menu->cb)
+ callback_call_0(menu->cb);
}
static struct menu_methods menu_methods;
-static struct menu_priv *
-add_menu(struct menu_priv *menu, struct menu_methods *meth, char *name, enum menu_type type, struct callback *cb)
-{
- struct menu_priv *ret;
- char *dynname;
-
- ret=g_new0(struct menu_priv, 1);
- *meth=menu_methods;
- if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Route")) {
- dynname=g_strdup("Route");
- } else if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Data")) {
- dynname=g_strdup("Data");
- } else {
- dynname=g_strdup_printf("%d", menu->gui->dyn_counter++);
- if (type == menu_type_toggle)
- ret->action=GTK_ACTION(gtk_toggle_action_new(dynname, name, NULL, NULL));
- else
- ret->action=gtk_action_new(dynname, name, NULL, NULL);
- if (cb)
- ret->handler_id=g_signal_connect(ret->action, "activate", G_CALLBACK(activate), ret);
- gtk_action_group_add_action(menu->gui->dyn_group, ret->action);
- ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->ui_manager);
- gtk_ui_manager_add_ui( menu->gui->ui_manager, ret->merge_id, menu->path, dynname, dynname, type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
- }
- ret->gui=menu->gui;
- ret->path=g_strdup_printf("%s/%s", menu->path, dynname);
- ret->type=type;
- ret->cb=cb;
- ret->sibling=menu->child;
- menu->child=ret;
- g_free(dynname);
- return ret;
+static struct menu_priv *add_menu(struct menu_priv *menu, struct menu_methods *meth, char *name, enum menu_type type,
+ struct callback *cb) {
+ struct menu_priv *ret;
+ char *dynname;
+
+ ret=g_new0(struct menu_priv, 1);
+ *meth=menu_methods;
+ if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Route")) {
+ dynname=g_strdup("Route");
+ } else if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Data")) {
+ dynname=g_strdup("Data");
+ } else {
+ dynname=g_strdup_printf("%d", menu->gui->dyn_counter++);
+ if (type == menu_type_toggle)
+ ret->action=GTK_ACTION(gtk_toggle_action_new(dynname, name, NULL, NULL));
+ else
+ ret->action=gtk_action_new(dynname, name, NULL, NULL);
+ if (cb)
+ ret->handler_id=g_signal_connect(ret->action, "activate", G_CALLBACK(activate), ret);
+ gtk_action_group_add_action(menu->gui->dyn_group, ret->action);
+ ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->ui_manager);
+ gtk_ui_manager_add_ui( menu->gui->ui_manager, ret->merge_id, menu->path, dynname, dynname,
+ type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
+ }
+ ret->gui=menu->gui;
+ ret->path=g_strdup_printf("%s/%s", menu->path, dynname);
+ ret->type=type;
+ ret->cb=cb;
+ ret->sibling=menu->child;
+ menu->child=ret;
+ g_free(dynname);
+ return ret;
}
-static void
-remove_menu(struct menu_priv *item, int recursive)
-{
-
- if (recursive) {
- struct menu_priv *next,*child=item->child;
- while (child) {
- next=child->sibling;
- remove_menu(child, recursive);
- child=next;
- }
- }
- if (item->action) {
- gtk_ui_manager_remove_ui(item->gui->ui_manager, item->merge_id);
- gtk_action_group_remove_action(item->gui->dyn_group, item->action);
+static void remove_menu(struct menu_priv *item, int recursive) {
+
+ if (recursive) {
+ struct menu_priv *next,*child=item->child;
+ while (child) {
+ next=child->sibling;
+ remove_menu(child, recursive);
+ child=next;
+ }
+ }
+ if (item->action) {
+ gtk_ui_manager_remove_ui(item->gui->ui_manager, item->merge_id);
+ gtk_action_group_remove_action(item->gui->dyn_group, item->action);
#if 0
- if (item->callback)
- g_signal_handler_disconnect(item->action, item->handler_id);
+ if (item->callback)
+ g_signal_handler_disconnect(item->action, item->handler_id);
#endif
- g_object_unref(item->action);
- }
- g_free(item->path);
- g_free(item);
+ g_object_unref(item->action);
+ }
+ g_free(item->path);
+ g_free(item);
}
-static void
-set_toggle(struct menu_priv *menu, int active)
-{
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
+static void set_toggle(struct menu_priv *menu, int active) {
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
}
-static int
-get_toggle(struct menu_priv *menu)
-{
- return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
+static int get_toggle(struct menu_priv *menu) {
+ return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
}
static struct menu_methods menu_methods = {
#if 1
- add_menu,
- set_toggle,
- get_toggle,
+ add_menu,
+ set_toggle,
+ get_toggle,
#else
- NULL,
- NULL,
- NULL
+ NULL,
+ NULL,
+ NULL
#endif
};
-static void
-popup_deactivate(GtkWidget *widget, struct menu_priv *menu)
-{
- g_signal_handler_disconnect(widget, menu->handler_id);
- remove_menu(menu, 1);
+static void popup_deactivate(GtkWidget *widget, struct menu_priv *menu) {
+ g_signal_handler_disconnect(widget, menu->handler_id);
+ remove_menu(menu, 1);
}
-static void
-popup_activate(struct menu_priv *menu)
-{
+static void popup_activate(struct menu_priv *menu) {
#ifdef _WIN32
- menu->widget=gtk_ui_manager_get_widget(menu->gui->ui_manager, menu->path );
+ menu->widget=gtk_ui_manager_get_widget(menu->gui->ui_manager, menu->path );
#endif
- gtk_menu_popup(GTK_MENU(menu->widget), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
- menu->handler_id=g_signal_connect(menu->widget, "selection-done", G_CALLBACK(popup_deactivate), menu);
+ gtk_menu_popup(GTK_MENU(menu->widget), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
+ menu->handler_id=g_signal_connect(menu->widget, "selection-done", G_CALLBACK(popup_deactivate), menu);
}
-void
-gui_gtk_ui_init(struct gui_priv *this)
-{
- GError *error = NULL;
- struct attr attr;
- GtkToggleAction *toggle_action;
-
- this->base_group = gtk_action_group_new ("BaseActions");
- this->debug_group = gtk_action_group_new ("DebugActions");
- this->dyn_group = gtk_action_group_new ("DynamicActions");
- register_my_stock_icons();
- this->ui_manager = gtk_ui_manager_new ();
- gtk_action_group_set_translation_domain(this->base_group,"navit");
- gtk_action_group_set_translation_domain(this->debug_group,"navit");
- gtk_action_group_set_translation_domain(this->dyn_group,"navit");
- gtk_action_group_add_actions (this->base_group, entries, n_entries, this);
- gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this);
- gtk_ui_manager_insert_action_group (this->ui_manager, this->base_group, 0);
- gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this);
- gtk_ui_manager_insert_action_group (this->ui_manager, this->debug_group, 0);
- gtk_ui_manager_add_ui_from_string (this->ui_manager, layout, strlen(layout), &error);
- gtk_ui_manager_insert_action_group (this->ui_manager, this->dyn_group, 0);
- if (error) {
- g_message ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- }
- if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
- }
- if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- }
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "RoadbookAction"));
- gtk_toggle_action_set_active(toggle_action, 0);
-
- if (navit_get_attr(this->nav, attr_autozoom_active, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "AutozoomAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- }
+void gui_gtk_ui_init(struct gui_priv *this) {
+ GError *error = NULL;
+ struct attr attr;
+ GtkToggleAction *toggle_action;
+
+ this->base_group = gtk_action_group_new ("BaseActions");
+ this->debug_group = gtk_action_group_new ("DebugActions");
+ this->dyn_group = gtk_action_group_new ("DynamicActions");
+ register_my_stock_icons();
+ this->ui_manager = gtk_ui_manager_new ();
+ gtk_action_group_set_translation_domain(this->base_group,"navit");
+ gtk_action_group_set_translation_domain(this->debug_group,"navit");
+ gtk_action_group_set_translation_domain(this->dyn_group,"navit");
+ gtk_action_group_add_actions (this->base_group, entries, n_entries, this);
+ gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->base_group, 0);
+ gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->debug_group, 0);
+ gtk_ui_manager_add_ui_from_string (this->ui_manager, layout, strlen(layout), &error);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->dyn_group, 0);
+ if (error) {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+ if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ if (navit_get_attr(this->nav, attr_follow_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "FollowVehicleAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
+ }
+ if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "RoadbookAction"));
+ gtk_toggle_action_set_active(toggle_action, 0);
+
+ if (navit_get_attr(this->nav, attr_autozoom_active, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "AutozoomAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
}
-static struct menu_priv *
-gui_gtk_ui_new (struct gui_priv *this, struct menu_methods *meth, char *path, int popup, GtkWidget **widget_ret)
-{
- struct menu_priv *ret;
- GtkWidget *widget;
-
- *meth=menu_methods;
- ret=g_new0(struct menu_priv, 1);
- ret->path=g_strdup(path);
- ret->gui=this;
-
- widget=gtk_ui_manager_get_widget(this->ui_manager, path);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- if (widget_ret)
- *widget_ret=widget;
- if (! popup) {
- gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
- } else {
- ret->widget=widget;
- meth->popup=popup_activate;
- }
- return ret;
+static struct menu_priv *gui_gtk_ui_new (struct gui_priv *this, struct menu_methods *meth, char *path, int popup,
+ GtkWidget **widget_ret) {
+ struct menu_priv *ret;
+ GtkWidget *widget;
+
+ *meth=menu_methods;
+ ret=g_new0(struct menu_priv, 1);
+ ret->path=g_strdup(path);
+ ret->gui=this;
+
+ widget=gtk_ui_manager_get_widget(this->ui_manager, path);
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ if (widget_ret)
+ *widget_ret=widget;
+ if (! popup) {
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ } else {
+ ret->widget=widget;
+ meth->popup=popup_activate;
+ }
+ return ret;
}
#if 0
struct menu_priv *
-gui_gtk_menubar_new(struct gui_priv *this, struct menu_methods *meth)
-{
- return gui_gtk_ui_new(this, meth, "/ui/MenuBar", 0, &this->menubar);
+gui_gtk_menubar_new(struct gui_priv *this, struct menu_methods *meth) {
+ return gui_gtk_ui_new(this, meth, "/ui/MenuBar", 0, &this->menubar);
}
#endif
struct menu_priv *
-gui_gtk_popup_new(struct gui_priv *this, struct menu_methods *meth)
-{
- return gui_gtk_ui_new(this, meth, "/ui/PopUp", 1, NULL);
+gui_gtk_popup_new(struct gui_priv *this, struct menu_methods *meth) {
+ return gui_gtk_ui_new(this, meth, "/ui/PopUp", 1, NULL);
}
diff --git a/navit/gui/gtk/gui_gtk_poi.c b/navit/gui/gtk/gui_gtk_poi.c
index a3578243b..265f1f28e 100644
--- a/navit/gui/gtk/gui_gtk_poi.c
+++ b/navit/gui/gtk/gui_gtk_poi.c
@@ -35,328 +35,413 @@
#include "attr.h"
#include "util.h"
-static struct gtk_poi_search{
- GtkWidget *entry_distance;
- GtkWidget *label_distance;
- GtkWidget *treeview_cat;
- GtkWidget *treeview_poi;
- GtkWidget *button_visit, *button_destination, *button_map;
- GtkListStore *store_poi;
- GtkListStore *store_cat;
- GtkTreeModel *store_poi_sorted;
- GtkTreeModel *store_cat_sorted;
- char *selected_cat;
- struct navit *nav;
+#include "navigation.h" /* for FEET_PER_METER and other conversion factors. */
+
+/**
+ * @brief Context passed around POI search function
+ */
+static struct gtk_poi_search {
+ GtkWidget *entry_distance;
+ GtkWidget *label_distance;
+ GtkWidget *treeview_cat;
+ GtkWidget *treeview_poi;
+ GtkWidget *button_visit, *button_destination, *button_map;
+ GtkListStore *store_poi;
+ GtkListStore *store_cat;
+ GtkTreeModel *store_poi_sorted;
+ GtkTreeModel *store_cat_sorted;
+ char *selected_cat;
+ struct navit *nav;
} gtk_poi_search;
-static GdkPixbuf *
-geticon(const char *name){
- GdkPixbuf *icon=NULL;
- GError *error=NULL;
- icon=gdk_pixbuf_new_from_file(graphics_icon_path(name),&error);
- if (error) {
- dbg(lvl_error, "failed to load icon '%s': %s\n", name, error->message);
- }
- return icon;
+/**
+ * @brief Get a pixbuf representing an icon for the catalog
+ *
+ * @param name The name of the icon to use (eg: "pharmacy.png"
+ * @return A pixbuf containing this icon of NULL if the icon could not be loaded
+ */
+static GdkPixbuf *geticon(const char *name) {
+ GdkPixbuf *icon=NULL;
+ GError *error=NULL;
+ icon=gdk_pixbuf_new_from_file(graphics_icon_path(name),&error);
+ if (error) {
+ dbg(lvl_error, "failed to load icon '%s': %s", name, error->message);
+ }
+ return icon;
}
/** Build the category list model with icons. */
-static GtkTreeModel *
-category_list_model(struct gtk_poi_search *search)
-{
- GtkTreeIter iter;
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter, 0,geticon("pharmacy.png"), 1, _("Pharmacy"), 2, "poi_pharmacy", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter, 0, geticon("restaurant.png"), 1, _("Restaurant"), 2, "poi_restaurant", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("restaurant.png"), 1, _("Restaurant. Fast food"), 2, "poi_fastfood", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("hotel.png"), 1, _("Hotel"), 2, "poi_hotel", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("parking.png"), 1, _("Car parking"), 2, "poi_car_parking", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("fuel.png"), 1, _("Fuel station"), 2, "poi_fuel", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("bank.png"), 1, _("Bank"), 2, "poi_bank", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("hospital.png"), 1, _("Hospital"), 2, "poi_hospital", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("cinema.png"), 1, _("Cinema"), 2, "poi_cinema", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("rail_station.png"), 1, _("Train station"), 2, "poi_rail_station", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("school.png"), 1, _("School"), 2, "poi_school", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("police.png"), 1, _("Police"), 2, "poi_police", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("justice.png"), 1, _("Justice"), 2, "poi_justice", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("taxi.png"), 1, _("Taxi"), 2, "poi_taxi", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("shopping.png"), 1, _("Shopping"), 2, "poi_shopping", -1);
- return GTK_TREE_MODEL (search->store_cat_sorted);
+static GtkTreeModel *category_list_model(struct gtk_poi_search *search) {
+ GtkTreeIter iter;
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter, 0,geticon("pharmacy.png"), 1, _("Pharmacy"), 2, "poi_pharmacy", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter, 0, geticon("restaurant.png"), 1, _("Restaurant"), 2, "poi_restaurant", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("restaurant.png"), 1, _("Restaurant. Fast food"), 2,
+ "poi_fastfood", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("hotel.png"), 1, _("Hotel"), 2, "poi_hotel", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("parking.png"), 1, _("Car parking"), 2, "poi_car_parking", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("fuel.png"), 1, _("Fuel station"), 2, "poi_fuel", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("bank.png"), 1, _("Bank"), 2, "poi_bank", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("hospital.png"), 1, _("Hospital"), 2, "poi_hospital", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("cinema.png"), 1, _("Cinema"), 2, "poi_cinema", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("rail_station.png"), 1, _("Train station"), 2,
+ "poi_rail_station", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("school.png"), 1, _("School"), 2, "poi_school", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("police.png"), 1, _("Police"), 2, "poi_police", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("justice.png"), 1, _("Justice"), 2, "poi_justice", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("taxi.png"), 1, _("Taxi"), 2, "poi_taxi", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("shopping.png"), 1, _("Shopping"), 2, "poi_shopping", -1);
+ return GTK_TREE_MODEL (search->store_cat_sorted);
}
/** Construct model of POIs from map information. */
-static GtkTreeModel *
-model_poi (struct gtk_poi_search *search)
-{
- GtkTreeIter iter;
- struct map_selection *sel,*selm;
- struct coord coord_item,center;
- struct pcoord pc;
- struct mapset_handle *h;
- int search_distance_meters,idist;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct point cursor_position;
- enum item_type selected;
-
- search_distance_meters=1000*atoi((char *) gtk_entry_get_text(GTK_ENTRY(search->entry_distance)));
-
- cursor_position.x=navit_get_width(search->nav)/2;
- cursor_position.y=navit_get_height(search->nav)/2;
- gtk_label_set_text(GTK_LABEL(search->label_distance),_("Distance from screen center (km)"));
-
- transform_reverse(navit_get_trans(search->nav), &cursor_position, &center);
- pc.pro = transform_get_projection(navit_get_trans(search->nav));
- pc.x = center.x;
- pc.y = center.y;
-
- //Search in the map, for pois
- sel=map_selection_rect_new(&pc ,search_distance_meters*transform_scale(abs(center.y)+search_distance_meters*1.5),18);
- gtk_list_store_clear(search->store_poi);
-
- h=mapset_open(navit_get_mapset(search->nav));
-
- selected=item_from_name(search->selected_cat);
- while ((m=mapset_next(h, 1))) {
- selm=map_selection_dup_pro(sel, projection_mg, map_projection(m));
- mr=map_rect_new(m, selm);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- struct attr label_attr;
- item_attr_get(item,attr_label,&label_attr);
- item_coord_get(item,&coord_item,1);
- idist=transform_distance(1,&center,&coord_item);
- if (item->type==selected && idist<=search_distance_meters){
- char direction[5];
- gtk_list_store_append(search->store_poi, &iter);
- get_compass_direction(direction,transform_get_angle_delta(&center,&coord_item,0),1);
- gtk_list_store_set(search->store_poi, &iter, 0,direction, 1,idist,
- 2,g_strdup(label_attr.u.str), 3,coord_item.x, 4,coord_item.y ,-1);
- }
- }
- map_rect_destroy(mr);
- }
- map_selection_destroy(selm);
- }
- map_selection_destroy(sel);
- mapset_close(h);
-
- return GTK_TREE_MODEL (search->store_poi_sorted);
+static GtkTreeModel *model_poi (struct gtk_poi_search *search) {
+ GtkTreeIter iter;
+ struct map_selection *sel,*selm;
+ struct coord coord_item,center;
+ struct pcoord pc;
+ struct mapset_handle *h;
+ int search_distance_meters; /* distance to search the POI database, in meters, from the center of the screen. */
+ int idist; /* idist appears to be the distance in meters from the center of the screen to a POI. */
+ struct map *m;
+ struct map_rect *mr;
+ struct item *item;
+ struct point cursor_position;
+ enum item_type selected;
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ struct attr attr;
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(gtk_poi_search.nav, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ if (imperial == FALSE) {
+ /* Input is in kilometers */
+ search_distance_meters=1000*atoi((char *) gtk_entry_get_text(GTK_ENTRY(search->entry_distance)));
+ gtk_label_set_text(GTK_LABEL(search->label_distance),_("Select a search radius from screen center in km"));
+ } else {
+ /* Input is in miles. */
+ search_distance_meters=atoi((char *) gtk_entry_get_text(GTK_ENTRY(search->entry_distance)))/METERS_TO_MILES;
+ gtk_label_set_text(GTK_LABEL(search->label_distance),_("Select a search radius from screen center in miles"));
+ }
+
+ cursor_position.x=navit_get_width(search->nav)/2;
+ cursor_position.y=navit_get_height(search->nav)/2;
+
+ transform_reverse(navit_get_trans(search->nav), &cursor_position, &center);
+ pc.pro = transform_get_projection(navit_get_trans(search->nav));
+ pc.x = center.x;
+ pc.y = center.y;
+
+ //Search in the map, for pois
+ sel=map_selection_rect_new(&pc,search_distance_meters*transform_scale(abs(center.y)+search_distance_meters*1.5),18);
+ gtk_list_store_clear(search->store_poi);
+
+ h=mapset_open(navit_get_mapset(search->nav));
+
+ selected=item_from_name(search->selected_cat);
+ while ((m=mapset_next(h, 1))) {
+ selm=map_selection_dup_pro(sel, projection_mg, map_projection(m));
+ mr=map_rect_new(m, selm);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ struct attr label_attr;
+ item_attr_get(item,attr_label,&label_attr);
+ item_coord_get(item,&coord_item,1);
+ idist=transform_distance(1,&center,&coord_item);
+ if (item->type==selected && idist<=search_distance_meters) {
+ char direction[5];
+ gtk_list_store_append(search->store_poi, &iter);
+ get_compass_direction(direction,transform_get_angle_delta(&center,&coord_item,0),1);
+
+ /**
+ * If the user has selected imperial, translate idist from meters to
+ * feet. We convert to feet only, and not miles, because the code
+ * sorts on the numeric value of the distance, so it doesn't like two
+ * different units. Currently, the distance is an int. Can it be made
+ * a float? Possible future enhancement?
+ */
+ if (imperial != FALSE) {
+ idist = idist * (FEET_PER_METER); /* convert meters to feet. */
+ }
+
+ gtk_list_store_set(search->store_poi, &iter, 0,direction, 1,idist,
+ 2,g_strdup(label_attr.u.str), 3,coord_item.x, 4,coord_item.y,-1);
+ }
+ }
+ map_rect_destroy(mr);
+ }
+ map_selection_destroy(selm);
+ }
+ map_selection_destroy(sel);
+ mapset_close(h);
+
+ return GTK_TREE_MODEL (search->store_poi_sorted);
}
/** Enable button if there is a selected row. */
-static void
-treeview_poi_changed(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
-
- gtk_widget_set_sensitive(search->button_visit,TRUE);
- gtk_widget_set_sensitive(search->button_map,TRUE);
- gtk_widget_set_sensitive(search->button_destination,TRUE);
+static void treeview_poi_changed(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
+
+ gtk_widget_set_sensitive(search->button_visit,TRUE);
+ gtk_widget_set_sensitive(search->button_map,TRUE);
+ gtk_widget_set_sensitive(search->button_destination,TRUE);
}
/** Reload the POI list and disable buttons. */
-static void
-treeview_poi_reload(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
-
- gtk_widget_set_sensitive(search->button_visit,FALSE);
- gtk_widget_set_sensitive(search->button_map,FALSE);
- gtk_widget_set_sensitive(search->button_destination,FALSE);
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 2, &search->selected_cat, -1);
- gtk_tree_view_set_model(GTK_TREE_VIEW (search->treeview_poi), model_poi(search));
+static void treeview_poi_reload(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+
+ gtk_widget_set_sensitive(search->button_visit,FALSE);
+ gtk_widget_set_sensitive(search->button_map,FALSE);
+ gtk_widget_set_sensitive(search->button_destination,FALSE);
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 2, &search->selected_cat, -1);
+ gtk_tree_view_set_model(GTK_TREE_VIEW (search->treeview_poi), model_poi(search));
}
-/** Set the selected POI as destination. */
-static void
-button_destination_clicked(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- long int lat, lon;
- char *label;
- char *category;
- char buffer[2000];
-
- //Get category
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 1, &category, -1);
-
- //Get label, lat, lon
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 2, &label, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
- sprintf(buffer, _("POI %s. %s"), category, label);
-
- struct pcoord dest;
- dest.x=lat;
- dest.y=lon;
- dest.pro=1;
- navit_set_destination(search->nav, &dest, buffer, 1);
- dbg(lvl_debug,_("Set destination to %ld, %ld \n"),lat,lon);
+/**
+ * @brief Callback invoked when 'Destination' is clicked in a POI contextual window
+ *
+ * Set the selected POI as destination
+ *
+ * @param widget The widget that has been clicked
+ * @param search A pointer to private data containing the POI search context
+ */
+static void button_destination_clicked(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ long int lat, lon;
+ char *label;
+ char *category;
+ char buffer[2000];
+
+ //Get category
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 1, &category, -1);
+
+ //Get label, lat, lon
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 2, &label, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
+ sprintf(buffer, _("POI %s. %s"), category, label);
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+
+ struct pcoord dest;
+ dest.x=lat;
+ dest.y=lon;
+ dest.pro=1;
+ navit_set_destination(search->nav, &dest, buffer, 1);
+ dbg(lvl_debug,_("Set destination to %ld, %ld "),lat,lon);
}
-/* Show the POI's position in the map. */
-static void
-button_map_clicked(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- long int lat,lon;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
-
- struct pcoord dest;
- dest.x=lat;
- dest.y=lon;
- dest.pro=1;
- navit_set_center(search->nav, &dest,1);
- dbg(lvl_debug,_("Set map to %ld, %ld \n"),lat,lon);
+/**
+ * @brief Callback invoked when 'Map' is clicked in a POI contextual window
+ *
+ * Show the POI's position in the map
+ *
+ * @param widget The widget that has been clicked
+ * @param search A pointer to private data containing the POI search context
+ */
+static void button_map_clicked(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ long int lat,lon;
+ char *label;
+ GList* p;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 2, &label, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
+
+ struct pcoord point; /* The geographical position of the selected POI point */
+ point.x=lat;
+ point.y=lon;
+ point.pro=1;
+ GList* list = NULL;
+ struct lcoord *result = g_new0(struct lcoord, 1);
+ result->c.x=lat;
+ result->c.y=lon;
+ result->label=g_strdup(label);
+ list = g_list_prepend(list, result);
+ navit_populate_search_results_map(search->nav, list, NULL);
+ /* Parse the GList starting at list and free all payloads before freeing the list itself */
+ for(p=list; p; p=g_list_next(p)) {
+ if (((struct lcoord *)(p->data))->label)
+ g_free(((struct lcoord *)(p->data))->label);
+ }
+ g_list_free(list);
+ navit_set_center(search->nav, &point,1);
+ dbg(lvl_debug,_("Set map to %ld, %ld "),lat,lon);
}
-/** Set POI as the first "visit before". */
-static void
-button_visit_clicked(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- long int lat,lon;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
- dbg(lvl_debug,_("Set next visit to %ld, %ld \n"),lat,lon);
-
- struct pcoord dest;
- dest.x=lat;
- dest.y=lon;
- dest.pro=1;
- popup_set_visitbefore(search->nav,&dest,0);
+/**
+ * @brief Callback invoked when 'Visit before' is clicked in a POI contextual window
+ *
+ * Set POI as a waypoint to visit before an existing destination
+ *
+ * @param widget The widget that has been clicked
+ * @param search A pointer to private data containing the POI search context
+ */
+static void button_visit_clicked(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ long int lat,lon;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
+ dbg(lvl_debug,_("Set next visit to %ld, %ld "),lat,lon);
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+
+ struct pcoord dest;
+ dest.x=lat;
+ dest.y=lon;
+ dest.pro=1;
+ popup_set_visitbefore(search->nav,&dest,0);
}
-/** Create UI and connect objects to functions. */
-void gtk_gui_poi(struct navit *nav)
-{
- GtkWidget *window2,*vbox, *keyboard, *table;
- GtkWidget *label_category, *label_poi;
- GtkWidget *listbox_cat, *listbox_poi;
- GtkCellRenderer *renderer;
-
- struct gtk_poi_search *search=&gtk_poi_search;
- search->nav=nav;
-
- window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window2),_("POI search"));
- gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
- gtk_window_set_default_size (GTK_WINDOW (window2),700,550);
- vbox = gtk_vbox_new(FALSE, 0);
- table = gtk_table_new(4, 4, FALSE);
-
- label_category = gtk_label_new(_("Select a category"));
- search->label_distance = gtk_label_new(_("Select a distance to look for (km)"));
- label_poi=gtk_label_new(_("Select a POI"));
-
- search->entry_distance=gtk_entry_new_with_max_length(2);
- gtk_entry_set_text(GTK_ENTRY(search->entry_distance),"10");
-
- search->treeview_cat=gtk_tree_view_new();
- listbox_cat = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_cat), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_cat),search->treeview_cat);
- search->store_cat = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
- renderer=gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _(" "), renderer, "pixbuf", 0, NULL);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _("Category"), renderer, "text", 1, NULL);
- search->store_cat_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_cat));
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_cat_sorted),1,GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview_cat), category_list_model(search));
-
- search->treeview_poi=gtk_tree_view_new();
- listbox_poi = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_poi), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_poi),search->treeview_poi);
- search->store_poi = gtk_list_store_new (5, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Direction"), renderer, "text",0,NULL);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Distance(m)"), renderer, "text", 1, NULL);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Name"), renderer, "text", 2, NULL);
- search->store_poi_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_poi));
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_poi_sorted),1,GTK_SORT_ASCENDING);
-
- search->button_visit = gtk_button_new_with_label(_("Visit Before"));
- search->button_destination = gtk_button_new_with_label(_("Destination"));
- search->button_map = gtk_button_new_with_label(_("Map"));
- gtk_widget_set_sensitive(search->button_visit,FALSE);
- gtk_widget_set_sensitive(search->button_map,FALSE);
- gtk_widget_set_sensitive(search->button_destination,FALSE);
-
- gtk_table_attach(GTK_TABLE(table), search->label_distance, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_distance, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_category, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), listbox_cat, 0, 1, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_poi, 1, 4, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), listbox_poi, 1, 4, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->button_map, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->button_visit, 1, 2, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->button_destination, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
- gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
-
- g_signal_connect(G_OBJECT(search->entry_distance), "changed", G_CALLBACK(treeview_poi_reload), search);
- g_signal_connect(G_OBJECT(search->button_visit), "clicked", G_CALLBACK(button_visit_clicked), search);
- g_signal_connect(G_OBJECT(search->button_map), "clicked", G_CALLBACK(button_map_clicked), search);
- g_signal_connect(G_OBJECT(search->button_destination), "clicked", G_CALLBACK(button_destination_clicked), search);
- g_signal_connect(G_OBJECT(search->treeview_cat), "cursor_changed", G_CALLBACK(treeview_poi_reload), search);
- g_signal_connect(G_OBJECT(search->treeview_poi), "cursor_changed", G_CALLBACK(treeview_poi_changed), search);
-
- keyboard=gtk_socket_new();
- gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(window2), vbox);
- gtk_widget_show_all(window2);
+/**
+ * @brief Create the POI search UI window and connect objects to functions
+ *
+ * @param nav The navit instance
+ */
+void gtk_gui_poi(struct navit *nav) {
+ GtkWidget *window2,*vbox, *keyboard, *table;
+ GtkWidget *label_category, *label_poi;
+ GtkWidget *listbox_cat, *listbox_poi;
+ GtkCellRenderer *renderer;
+
+ struct gtk_poi_search *search=&gtk_poi_search;
+ search->nav=nav;
+
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+ window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window2),_("POI search"));
+ gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
+ gtk_window_set_default_size (GTK_WINDOW (window2),700,550);
+ vbox = gtk_vbox_new(FALSE, 0);
+ table = gtk_table_new(4, 4, FALSE);
+
+ label_category = gtk_label_new(_("Select a category"));
+ label_poi=gtk_label_new(_("Select a POI"));
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ struct attr attr;
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(gtk_poi_search.nav, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ if (imperial == FALSE) {
+ /* Input is in kilometers */
+ search->label_distance = gtk_label_new(_("Select a search radius from screen center in km"));
+ } else {
+ /* Input is in miles. */
+ search->label_distance = gtk_label_new(_("Select a search radius from screen center in miles"));
+ }
+
+ search->entry_distance=gtk_entry_new_with_max_length(2);
+ gtk_entry_set_text(GTK_ENTRY(search->entry_distance),"10");
+
+ search->treeview_cat=gtk_tree_view_new();
+ listbox_cat = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_cat), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_cat),search->treeview_cat);
+ search->store_cat = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+ renderer=gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _(" "), renderer, "pixbuf", 0,
+ NULL);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _("Category"), renderer, "text",
+ 1, NULL);
+ search->store_cat_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_cat));
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_cat_sorted),1,GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview_cat), category_list_model(search));
+
+ search->treeview_poi=gtk_tree_view_new();
+ listbox_poi = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_poi), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_poi),search->treeview_poi);
+ search->store_poi = gtk_list_store_new (5, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Direction"), renderer, "text",
+ 0,NULL);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Distance"), renderer, "text",
+ 1, NULL);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Name"), renderer, "text", 2,
+ NULL);
+ search->store_poi_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_poi));
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_poi_sorted),1,GTK_SORT_ASCENDING);
+
+ search->button_visit = gtk_button_new_with_label(_("Visit Before"));
+ search->button_destination = gtk_button_new_with_label(_("Destination"));
+ search->button_map = gtk_button_new_with_label(_("Map"));
+ gtk_widget_set_sensitive(search->button_visit,FALSE);
+ gtk_widget_set_sensitive(search->button_map,FALSE);
+ gtk_widget_set_sensitive(search->button_destination,FALSE);
+
+ gtk_table_attach(GTK_TABLE(table), search->label_distance, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_distance, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_category, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), listbox_cat, 0, 1, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_poi, 1, 4, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), listbox_poi, 1, 4, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->button_map, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->button_visit, 1, 2, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->button_destination, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+
+ g_signal_connect(G_OBJECT(search->entry_distance), "changed", G_CALLBACK(treeview_poi_reload), search);
+ g_signal_connect(G_OBJECT(search->button_visit), "clicked", G_CALLBACK(button_visit_clicked), search);
+ g_signal_connect(G_OBJECT(search->button_map), "clicked", G_CALLBACK(button_map_clicked), search);
+ g_signal_connect(G_OBJECT(search->button_destination), "clicked", G_CALLBACK(button_destination_clicked), search);
+ g_signal_connect(G_OBJECT(search->treeview_cat), "cursor_changed", G_CALLBACK(treeview_poi_reload), search);
+ g_signal_connect(G_OBJECT(search->treeview_poi), "cursor_changed", G_CALLBACK(treeview_poi_changed), search);
+
+ keyboard=gtk_socket_new();
+ gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window2), vbox);
+ gtk_widget_show_all(window2);
}
diff --git a/navit/gui/gtk/gui_gtk_statusbar.c b/navit/gui/gtk/gui_gtk_statusbar.c
index aa70c6332..f245312d1 100644
--- a/navit/gui/gtk/gui_gtk_statusbar.c
+++ b/navit/gui/gtk/gui_gtk_statusbar.c
@@ -36,161 +36,158 @@
#include "navit_nls.h"
struct statusbar_priv {
- struct gui_priv *gui;
- GtkWidget *hbox;
- char gps_text[128];
- GtkWidget *gps;
- char route_text[128];
- GtkWidget *route;
- struct callback *vehicle_cb;
+ struct gui_priv *gui;
+ GtkWidget *hbox;
+ char gps_text[128];
+ GtkWidget *gps;
+ char route_text[128];
+ GtkWidget *route;
+ struct callback *vehicle_cb;
};
#if 0
-static void
-statusbar_destroy(struct statusbar_priv *this)
-{
- g_free(this);
+static void statusbar_destroy(struct statusbar_priv *this) {
+ g_free(this);
}
-static void
-statusbar_gps_update(struct statusbar_priv *this, int sats, int qual, double lng, double lat, double height, double direction, double speed)
-{
- char *dirs[]={_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
- char *dir;
- int dir_idx;
- char pos_text[36];
+static void statusbar_gps_update(struct statusbar_priv *this, int sats, int qual, double lng, double lat, double height,
+ double direction, double speed) {
+ char *dirs[]= {_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
+ char *dir;
+ int dir_idx;
+ char pos_text[36];
- coord_format(lat,lng,DEGREES_MINUTES_SECONDS,pos_text,sizeof(pos_text));
- dir=dirs[dir_idx];
- sprintf(this->gps_text, "GPS %02d/%02d %s %4.0fm %3.0f°%-2s %3.0fkm/h", sats, qual, pos_text, height, direction, dir, speed);
- gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
+ coord_format(lat,lng,DEGREES_MINUTES_SECONDS,pos_text,sizeof(pos_text));
+ dir=dirs[dir_idx];
+ sprintf(this->gps_text, "GPS %02d/%02d %s %4.0fm %3.0f°%-2s %3.0fkm/h", sats, qual, pos_text, height, direction, dir,
+ speed);
+ gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}
#endif
-static const char *status_fix2str(int type)
-{
- switch(type) {
- case 0: return _("No");
- case 1: return _("2D");
- case 3: return _("3D");
- default:
- return _("OT");
- }
+static const char *status_fix2str(int type) {
+ switch(type) {
+ case 0:
+ return _("No");
+ case 1:
+ return _("2D");
+ case 3:
+ return _("3D");
+ default:
+ return _("OT");
+ }
}
-static void
-statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct vehicle *v)
-{
- struct navigation *nav=NULL;
- struct map *map=NULL;
- struct map_rect *mr=NULL;
- struct item *item=NULL;
- struct attr attr;
- double route_len=0;
- time_t eta;
- struct tm *eta_tm=NULL;
- char buffer[128];
- double lng, lat, direction=0, height=0, speed=0, hdop=0;
- int sats=0, qual=0;
- int status=0;
- const char *dirs[]={_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
- const char *dir;
- int dir_idx;
-
- /* Respect the Imperial attribute as we enlighten the user. */
- int imperial = FALSE; /* default to using metric measures. */
- if (navit_get_attr(navit, attr_imperial, &attr, NULL))
- imperial=attr.u.num;
-
- if (navit)
- nav=navit_get_navigation(navit);
- if (nav)
- map=navigation_get_map(nav);
- if (map)
- mr=map_rect_new(map, NULL);
- if (mr)
- item=map_rect_get_item(mr);
- if (item) {
- if (item_attr_get(item, attr_destination_length, &attr))
- route_len=attr.u.num;
- if (item_attr_get(item, attr_destination_time, &attr)) {
- eta=time(NULL)+attr.u.num/10;
- eta_tm=localtime(&eta);
- }
- }
- if (mr)
- map_rect_destroy(mr);
-
- sprintf(buffer,_("Route %4.1f%s %02d:%02d ETA" ),
- imperial == TRUE ? route_len / METERS_PER_MILE : route_len/1000,
- imperial == TRUE ? "mi" : "km",
- eta_tm ? eta_tm->tm_hour : 0 ,
- eta_tm ? eta_tm->tm_min : 0);
-
- if (strcmp(buffer, this->route_text)) {
- strcpy(this->route_text, buffer);
- gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
- }
- if (!vehicle_get_attr(v, attr_position_coord_geo, &attr, NULL))
- return;
- lng=attr.u.coord_geo->lng;
- lat=attr.u.coord_geo->lat;
- if (vehicle_get_attr(v, attr_position_fix_type, &attr, NULL))
- status=attr.u.num;
- if (vehicle_get_attr(v, attr_position_direction, &attr, NULL))
- direction=*(attr.u.numd);
- direction=fmod(direction,360);
- if (direction < 0)
- direction+=360;
- dir_idx=(direction+22.5)/45;
- dir=dirs[dir_idx];
- if (vehicle_get_attr(v, attr_position_height, &attr, NULL))
- height=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_hdop, &attr, NULL))
- hdop=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_speed, &attr, NULL))
- speed=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_sats_used, &attr, NULL))
- sats=attr.u.num;
- if (vehicle_get_attr(v, attr_position_qual, &attr, NULL))
- qual=attr.u.num;
- coord_format(lat,lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
-
- sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
- status_fix2str(status),
- sats, qual, hdop, buffer,
- imperial ? height * FEET_PER_METER : height,
- imperial == TRUE ? "\'" : "m",
- direction, dir,
- imperial == TRUE ? speed / (METERS_PER_MILE / 1000) : speed, /* hard-coded. Ugly */
- imperial == TRUE ? " mph" : "km/h"
- );
-
- gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
+static void statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct vehicle *v) {
+ struct navigation *nav=NULL;
+ struct map *map=NULL;
+ struct map_rect *mr=NULL;
+ struct item *item=NULL;
+ struct attr attr;
+ double route_len=0; /* Distance to destination. We get it in kilometers. */
+ time_t eta;
+ struct tm *eta_tm=NULL;
+ char buffer[128];
+ double lng, lat, direction=0, height=0, speed=0, hdop=0;
+ int sats=0, qual=0;
+ int status=0;
+ const char *dirs[]= {_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
+ const char *dir;
+ int dir_idx;
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(navit, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ if (navit)
+ nav=navit_get_navigation(navit);
+ if (nav)
+ map=navigation_get_map(nav);
+ if (map)
+ mr=map_rect_new(map, NULL);
+ if (mr)
+ item=map_rect_get_item(mr);
+ if (item) {
+ if (item_attr_get(item, attr_destination_length, &attr))
+ route_len=attr.u.num;
+ if (item_attr_get(item, attr_destination_time, &attr)) {
+ eta=time(NULL)+attr.u.num/10;
+ eta_tm=localtime(&eta);
+ }
+ }
+ if (mr)
+ map_rect_destroy(mr);
+
+ sprintf(buffer,_("Route %4.1f%s %02d:%02d ETA" ),
+ imperial == TRUE ? route_len * (KILOMETERS_TO_MILES/1000.00) : route_len/1000,
+ imperial == TRUE ? "mi" : "km",
+ eta_tm ? eta_tm->tm_hour : 0,
+ eta_tm ? eta_tm->tm_min : 0);
+
+ if (strcmp(buffer, this->route_text)) {
+ strcpy(this->route_text, buffer);
+ gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
+ }
+ if (!vehicle_get_attr(v, attr_position_coord_geo, &attr, NULL))
+ return;
+ lng=attr.u.coord_geo->lng;
+ lat=attr.u.coord_geo->lat;
+ if (vehicle_get_attr(v, attr_position_fix_type, &attr, NULL))
+ status=attr.u.num;
+ if (vehicle_get_attr(v, attr_position_direction, &attr, NULL))
+ direction=*(attr.u.numd);
+ direction=fmod(direction,360);
+ if (direction < 0)
+ direction+=360;
+ dir_idx=(direction+22.5)/45;
+ dir=dirs[dir_idx];
+ if (vehicle_get_attr(v, attr_position_height, &attr, NULL))
+ height=*(attr.u.numd);
+ if (vehicle_get_attr(v, attr_position_hdop, &attr, NULL))
+ hdop=*(attr.u.numd);
+ if (vehicle_get_attr(v, attr_position_speed, &attr, NULL))
+ speed=*(attr.u.numd);
+ if (vehicle_get_attr(v, attr_position_sats_used, &attr, NULL))
+ sats=attr.u.num;
+ if (vehicle_get_attr(v, attr_position_qual, &attr, NULL))
+ qual=attr.u.num;
+ coord_format(lat,lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+
+ sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
+ status_fix2str(status),
+ sats, qual, hdop, buffer,
+ imperial ? height * FEET_PER_METER : height,
+ imperial == TRUE ? "\'" : "m",
+ direction, dir,
+ imperial == TRUE ? speed * KILOMETERS_TO_MILES : speed,
+ imperial == TRUE ? " mph" : "km/h"
+ );
+
+ gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}
struct statusbar_priv *
-gui_gtk_statusbar_new(struct gui_priv *gui)
-{
- struct statusbar_priv *this=g_new0(struct statusbar_priv, 1);
-
- this->gui=gui;
- this->hbox=gtk_hbox_new(FALSE, 1);
- this->gps=gtk_label_new( "GPS 00/0 0000.0000N 00000.0000E 0000m 000°NO 000km/h" );
- gtk_label_set_justify(GTK_LABEL(this->gps), GTK_JUSTIFY_LEFT);
- this->route=gtk_label_new( _( "Route 0000km 0+00:00 ETA" ) );
- gtk_label_set_justify(GTK_LABEL(this->route), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(this->hbox), this->gps, TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(this->hbox), gtk_vseparator_new(), TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(this->hbox), this->route, TRUE, TRUE, 2);
- GTK_WIDGET_UNSET_FLAGS (this->hbox, GTK_CAN_FOCUS);
-
- gtk_box_pack_end(GTK_BOX(gui->vbox), this->hbox, FALSE, FALSE, 0);
- gtk_widget_show_all(this->hbox);
- /* add a callback for position updates */
- this->vehicle_cb=callback_new_attr_1(callback_cast(statusbar_route_update), attr_position_coord_geo, this);
- navit_add_callback(gui->nav, this->vehicle_cb);
- return this;
+gui_gtk_statusbar_new(struct gui_priv *gui) {
+ struct statusbar_priv *this=g_new0(struct statusbar_priv, 1);
+
+ this->gui=gui;
+ this->hbox=gtk_hbox_new(FALSE, 1);
+ this->gps=gtk_label_new( "GPS 00/0 0000.0000N 00000.0000E 0000m 000°NO 000km/h" );
+ gtk_label_set_justify(GTK_LABEL(this->gps), GTK_JUSTIFY_LEFT);
+ this->route=gtk_label_new( _( "Route 0000km 0+00:00 ETA" ) );
+ gtk_label_set_justify(GTK_LABEL(this->route), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(this->hbox), this->gps, TRUE, TRUE, 2);
+ gtk_box_pack_start(GTK_BOX(this->hbox), gtk_vseparator_new(), TRUE, TRUE, 2);
+ gtk_box_pack_start(GTK_BOX(this->hbox), this->route, TRUE, TRUE, 2);
+ GTK_WIDGET_UNSET_FLAGS (this->hbox, GTK_CAN_FOCUS);
+
+ gtk_box_pack_end(GTK_BOX(gui->vbox), this->hbox, FALSE, FALSE, 0);
+ gtk_widget_show_all(this->hbox);
+ /* add a callback for position updates */
+ this->vehicle_cb=callback_new_attr_1(callback_cast(statusbar_route_update), attr_position_coord_geo, this);
+ navit_add_callback(gui->nav, this->vehicle_cb);
+ return this;
}
diff --git a/navit/gui/gtk/gui_gtk_window.c b/navit/gui/gtk/gui_gtk_window.c
index 1741a54a0..1e57004d0 100644
--- a/navit/gui/gtk/gui_gtk_window.c
+++ b/navit/gui/gtk/gui_gtk_window.c
@@ -66,747 +66,706 @@
#define GDK_Calendar XF86XK_Calendar
#endif
#define KEY_ZOOM_IN GDK_Book
-#define KEY_ZOOM_OUT GDK_Calendar
+#define KEY_ZOOM_OUT GDK_Calendar
#define KEY_UP GDK_Up
#define KEY_DOWN GDK_Down
#define KEY_LEFT GDK_Left
#define KEY_RIGHT GDK_Right
#endif
-static gboolean
-keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this)
-{
- int w,h;
- struct transformation *t;
- #ifdef USE_HILDON
- GtkToggleAction *action;
- gboolean *fullscreen;
- #endif /*HILDON*/
- struct point p;
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
- dbg(lvl_debug,"keypress 0x%x\n", event->keyval);
- transform_get_size(navit_get_trans(this->nav), &w, &h);
- switch (event->keyval) {
- case GDK_KP_Enter:
- gtk_menu_shell_select_first(GTK_MENU_SHELL(this->menubar), TRUE);
- break;
- case KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_ZOOM_IN:
- navit_zoom_in(this->nav, 2, NULL);
- break;
- case KEY_ZOOM_OUT:
- navit_zoom_out(this->nav, 2, NULL);
- break;
- case 'a':
- t=navit_get_trans(this->nav);
- transform_set_yaw(t, (transform_get_yaw(t)+15)%360);
- navit_draw(this->nav);
- break;
- case 'd':
- t=navit_get_trans(this->nav);
- transform_set_yaw(t, (transform_get_yaw(t)-15)%360);
- navit_draw(this->nav);
- break;
- case 'w':
- t=navit_get_trans(this->nav);
- transform_set_pitch(t, (transform_get_pitch(t)+5)%360);
- navit_draw(this->nav);
- break;
- case 'x':
- t=navit_get_trans(this->nav);
- transform_set_pitch(t, (transform_get_pitch(t)-5)%360);
- navit_draw(this->nav);
- break;
- case 'r':
- t=navit_get_trans(this->nav);
- transform_set_distance(t, (transform_get_distance(t)-5));
- navit_draw(this->nav);
- break;
- case 'f':
- t=navit_get_trans(this->nav);
- transform_set_distance(t, (transform_get_distance(t)+5));
- navit_draw(this->nav);
- break;
- case 'z':
- t=navit_get_trans(this->nav);
- transform_set_hog(t, (transform_get_hog(t)+1));
- navit_draw(this->nav);
- break;
- case 'h':
- t=navit_get_trans(this->nav);
- transform_set_hog(t, (transform_get_hog(t)-1));
- navit_draw(this->nav);
- break;
- case 't':
- {
- struct coord *p;
- struct pcoord pc;
- t=navit_get_trans(this->nav);
- p=transform_center(t);
- pc.pro=projection_mg;
- p->y+=50*cos(transform_get_yaw(t)*M_PI/180);
- p->x+=50*sin(transform_get_yaw(t)*M_PI/180);
- pc.x=p->x;
- pc.y=p->y;
- navit_set_center(this->nav, &pc, 1);
- }
- break;
- case 'g':
- {
- struct coord *p;
- struct pcoord pc;
- t=navit_get_trans(this->nav);
- p=transform_center(t);
- pc.pro=projection_mg;
- p->y-=50*cos(transform_get_yaw(t)*M_PI/180);
- p->x-=50*sin(transform_get_yaw(t)*M_PI/180);
- pc.x=p->x;
- pc.y=p->y;
- navit_set_center(this->nav, &pc, 1);
- }
- break;
- #ifdef USE_HILDON
- case HILDON_HARDKEY_FULLSCREEN:
- action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
-
- if ( gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
- {
- fullscreen = 0;
- } else {
- fullscreen = 1;
- }
- gtk_toggle_action_set_active (action, fullscreen);
- break;
- #endif /*HILDON*/
- default:
- return FALSE;
- }
- return TRUE;
+static gboolean keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this) {
+ int w,h;
+ struct transformation *t;
+#ifdef USE_HILDON
+ GtkToggleAction *action;
+ gboolean *fullscreen;
+#endif /*HILDON*/
+ struct point p;
+ if (event->type != GDK_KEY_PRESS)
+ return FALSE;
+ dbg(lvl_debug,"keypress 0x%x", event->keyval);
+ transform_get_size(navit_get_trans(this->nav), &w, &h);
+ switch (event->keyval) {
+ case GDK_KP_Enter:
+ gtk_menu_shell_select_first(GTK_MENU_SHELL(this->menubar), TRUE);
+ break;
+ case KEY_UP:
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_DOWN:
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_LEFT:
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_RIGHT:
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_ZOOM_IN:
+ navit_zoom_in(this->nav, 2, NULL);
+ break;
+ case KEY_ZOOM_OUT:
+ navit_zoom_out(this->nav, 2, NULL);
+ break;
+ case 'a':
+ t=navit_get_trans(this->nav);
+ transform_set_yaw(t, (transform_get_yaw(t)+15)%360);
+ navit_draw(this->nav);
+ break;
+ case 'd':
+ t=navit_get_trans(this->nav);
+ transform_set_yaw(t, (transform_get_yaw(t)-15)%360);
+ navit_draw(this->nav);
+ break;
+ case 'w':
+ t=navit_get_trans(this->nav);
+ transform_set_pitch(t, (transform_get_pitch(t)+5)%360);
+ navit_draw(this->nav);
+ break;
+ case 'x':
+ t=navit_get_trans(this->nav);
+ transform_set_pitch(t, (transform_get_pitch(t)-5)%360);
+ navit_draw(this->nav);
+ break;
+ case 'r':
+ t=navit_get_trans(this->nav);
+ transform_set_distance(t, (transform_get_distance(t)-5));
+ navit_draw(this->nav);
+ break;
+ case 'f':
+ t=navit_get_trans(this->nav);
+ transform_set_distance(t, (transform_get_distance(t)+5));
+ navit_draw(this->nav);
+ break;
+ case 'z':
+ t=navit_get_trans(this->nav);
+ transform_set_hog(t, (transform_get_hog(t)+1));
+ navit_draw(this->nav);
+ break;
+ case 'h':
+ t=navit_get_trans(this->nav);
+ transform_set_hog(t, (transform_get_hog(t)-1));
+ navit_draw(this->nav);
+ break;
+ case 't': {
+ struct coord *p;
+ struct pcoord pc;
+ t=navit_get_trans(this->nav);
+ p=transform_center(t);
+ pc.pro=projection_mg;
+ p->y+=50*cos(transform_get_yaw(t)*M_PI/180);
+ p->x+=50*sin(transform_get_yaw(t)*M_PI/180);
+ pc.x=p->x;
+ pc.y=p->y;
+ navit_set_center(this->nav, &pc, 1);
+ }
+ break;
+ case 'g': {
+ struct coord *p;
+ struct pcoord pc;
+ t=navit_get_trans(this->nav);
+ p=transform_center(t);
+ pc.pro=projection_mg;
+ p->y-=50*cos(transform_get_yaw(t)*M_PI/180);
+ p->x-=50*sin(transform_get_yaw(t)*M_PI/180);
+ pc.x=p->x;
+ pc.y=p->y;
+ navit_set_center(this->nav, &pc, 1);
+ }
+ break;
+#ifdef USE_HILDON
+ case HILDON_HARDKEY_FULLSCREEN:
+ action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
+
+ if ( gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
+ fullscreen = 0;
+ } else {
+ fullscreen = 1;
+ }
+ gtk_toggle_action_set_active (action, fullscreen);
+ break;
+#endif /*HILDON*/
+ default:
+ return FALSE;
+ }
+ return TRUE;
}
-static int
-gui_gtk_set_graphics(struct gui_priv *this, struct graphics *gra)
-{
- GtkWidget *graphics;
-
- graphics=graphics_get_data(gra, "gtk_widget");
- if (! graphics)
- return 1;
- GTK_WIDGET_SET_FLAGS (graphics, GTK_CAN_FOCUS);
- gtk_widget_set_sensitive(graphics, TRUE);
- g_signal_connect(G_OBJECT(graphics), "key-press-event", G_CALLBACK(keypress), this);
- gtk_box_pack_end(GTK_BOX(this->vbox), graphics, TRUE, TRUE, 0);
- gtk_widget_show_all(graphics);
- gtk_widget_grab_focus(graphics);
-
- return 0;
+static int gui_gtk_set_graphics(struct gui_priv *this, struct graphics *gra) {
+ GtkWidget *graphics;
+
+ graphics=graphics_get_data(gra, "gtk_widget");
+ if (! graphics)
+ return 1;
+ GTK_WIDGET_SET_FLAGS (graphics, GTK_CAN_FOCUS);
+ gtk_widget_set_sensitive(graphics, TRUE);
+ g_signal_connect(G_OBJECT(graphics), "key-press-event", G_CALLBACK(keypress), this);
+ gtk_box_pack_end(GTK_BOX(this->vbox), graphics, TRUE, TRUE, 0);
+ gtk_widget_show_all(graphics);
+ gtk_widget_grab_focus(graphics);
+
+ return 0;
}
-static void
-gui_gtk_route_callback(struct gui_priv *gui) {
- struct attr route_attr;
- GtkAction *roadbookAction=gtk_ui_manager_get_action (gui->ui_manager,"/ui/ToolBar/ToolItems/Roadbook");
- if (roadbookAction) {
- if (navit_get_attr(gui->nav,attr_route,&route_attr,NULL)) {
- struct attr route_status_attr;
- if (route_get_attr(route_attr.u.route, attr_route_status,&route_status_attr,NULL) ) {
- if (route_status_attr.u.num>2) {
- gtk_action_set_sensitive(roadbookAction,1);
- } else {
- gtk_action_set_sensitive(roadbookAction,0);
- }
- }
- }
- }
+static void gui_gtk_route_callback(struct gui_priv *gui) {
+ struct attr route_attr;
+ GtkAction *roadbookAction=gtk_ui_manager_get_action (gui->ui_manager,"/ui/ToolBar/ToolItems/Roadbook");
+ if (roadbookAction) {
+ if (navit_get_attr(gui->nav,attr_route,&route_attr,NULL)) {
+ struct attr route_status_attr;
+ if (route_get_attr(route_attr.u.route, attr_route_status,&route_status_attr,NULL) ) {
+ if (route_status_attr.u.num>2) {
+ gtk_action_set_sensitive(roadbookAction,1);
+ } else {
+ gtk_action_set_sensitive(roadbookAction,0);
+ }
+ }
+ }
+ }
}
-static void
-gui_gtk_add_bookmark_do(struct gui_priv *gui)
-{
- struct attr attr;
- navit_get_attr(gui->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
- gtk_widget_destroy(gui->dialog_win);
+static void gui_gtk_add_bookmark_do(struct gui_priv *gui) {
+ struct attr attr;
+ navit_get_attr(gui->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
+ gtk_widget_destroy(gui->dialog_win);
}
-static int
-gui_gtk_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description)
-{
- GtkWidget *button_ok,*button_cancel,*label,*vbox,*hbox;
-
- gui->dialog_coord=*c;
- gui->dialog_win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- vbox=gtk_vbox_new(FALSE, 0);
- gtk_container_add (GTK_CONTAINER (gui->dialog_win), vbox);
- gtk_window_set_title(GTK_WINDOW(gui->dialog_win),_("Add Bookmark"));
- gtk_window_set_wmclass (GTK_WINDOW (gui->dialog_win), "navit", "Navit");
- gtk_window_set_transient_for(GTK_WINDOW(gui->dialog_win), GTK_WINDOW(gui->win));
- gtk_window_set_modal(GTK_WINDOW(gui->dialog_win), TRUE);
- label=gtk_label_new(_("Name"));
- gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
- gui->dialog_entry=gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(gui->dialog_entry), description);
- gtk_box_pack_start(GTK_BOX(vbox), gui->dialog_entry, TRUE, TRUE, 0);
- hbox=gtk_hbox_new(FALSE, 0);
- button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
- gtk_box_pack_start(GTK_BOX(hbox), button_ok, TRUE, TRUE, 10);
- button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_box_pack_start(GTK_BOX(hbox), button_cancel, TRUE, TRUE, 10);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
- gtk_widget_show_all(gui->dialog_win);
- GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT);
- gtk_widget_grab_default(button_ok);
- g_signal_connect_swapped (G_OBJECT (button_cancel), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT (gui->dialog_win));
- g_signal_connect_swapped (G_OBJECT (gui->dialog_entry), "activate", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
-
- g_signal_connect_swapped(G_OBJECT (button_ok), "clicked", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
-
- return 1;
+static int gui_gtk_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description) {
+ GtkWidget *button_ok,*button_cancel,*label,*vbox,*hbox;
+
+ gui->dialog_coord=*c;
+ gui->dialog_win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ vbox=gtk_vbox_new(FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (gui->dialog_win), vbox);
+ gtk_window_set_title(GTK_WINDOW(gui->dialog_win),_("Add Bookmark"));
+ gtk_window_set_wmclass (GTK_WINDOW (gui->dialog_win), "navit", "Navit");
+ gtk_window_set_transient_for(GTK_WINDOW(gui->dialog_win), GTK_WINDOW(gui->win));
+ gtk_window_set_modal(GTK_WINDOW(gui->dialog_win), TRUE);
+ label=gtk_label_new(_("Name"));
+ gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
+ gui->dialog_entry=gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(gui->dialog_entry), description);
+ gtk_box_pack_start(GTK_BOX(vbox), gui->dialog_entry, TRUE, TRUE, 0);
+ hbox=gtk_hbox_new(FALSE, 0);
+ button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
+ gtk_box_pack_start(GTK_BOX(hbox), button_ok, TRUE, TRUE, 10);
+ button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+ gtk_box_pack_start(GTK_BOX(hbox), button_cancel, TRUE, TRUE, 10);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
+ gtk_widget_show_all(gui->dialog_win);
+ GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(button_ok);
+ g_signal_connect_swapped (G_OBJECT (button_cancel), "clicked", G_CALLBACK (gtk_widget_destroy),
+ G_OBJECT (gui->dialog_win));
+ g_signal_connect_swapped (G_OBJECT (gui->dialog_entry), "activate", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
+
+ g_signal_connect_swapped(G_OBJECT (button_ok), "clicked", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
+
+ return 1;
}
struct gui_methods gui_gtk_methods = {
- NULL,
- gui_gtk_popup_new,
- gui_gtk_set_graphics,
- NULL,
- gui_gtk_datawindow_new,
- gui_gtk_add_bookmark,
+ NULL,
+ gui_gtk_popup_new,
+ gui_gtk_set_graphics,
+ NULL,
+ gui_gtk_datawindow_new,
+ gui_gtk_add_bookmark,
};
-static gboolean
-gui_gtk_delete(GtkWidget *widget, GdkEvent *event, struct navit *nav)
-{
- /* FIXME remove attr_navit callback */
- navit_destroy(nav);
- exit(0);
+static gboolean gui_gtk_delete(GtkWidget *widget, GdkEvent *event, struct navit *nav) {
+ /* FIXME remove attr_navit callback */
+ navit_destroy(nav);
+ exit(0);
- return TRUE;
+ return TRUE;
}
-static void
-gui_gtk_toggle_init(struct gui_priv *this)
-{
- struct attr attr;
- GtkToggleAction *toggle_action;
-
- if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(lvl_warning, "Unable to locate CursorAction\n");
- }
- if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
- } else {
- dbg(lvl_error, "Unable to locate OrientationAction\n");
- }
- if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(lvl_error, "Unable to locate TrackingAction\n");
- }
+static void gui_gtk_toggle_init(struct gui_priv *this) {
+ struct attr attr;
+ GtkToggleAction *toggle_action;
+
+ if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(lvl_warning, "Unable to locate CursorAction");
+ }
+ if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
+ } else {
+ dbg(lvl_error, "Unable to locate OrientationAction");
+ }
+ if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(lvl_error, "Unable to locate TrackingAction");
+ }
}
struct action_cb_data {
- struct gui_priv *gui;
- struct attr attr;
+ struct gui_priv *gui;
+ struct attr attr;
};
-static void
-gui_gtk_action_activate(GtkAction *action, struct action_cb_data *data)
-{
- if(data->attr.type == attr_destination) {
- char * label;
- g_object_get(G_OBJECT(action), "label", &label,NULL);
- navit_set_destination(data->gui->nav, data->attr.u.pcoord, label, 1);
- g_free(label);
- }
+static void gui_gtk_action_activate(GtkAction *action, struct action_cb_data *data) {
+ if(data->attr.type == attr_destination) {
+ char * label;
+ g_object_get(G_OBJECT(action), "label", &label,NULL);
+ navit_populate_search_results_map(data->gui->nav, NULL, NULL); /* Remove any highlighted point on the map */
+ navit_set_destination(data->gui->nav, data->attr.u.pcoord, label, 1);
+ g_free(label);
+ }
}
struct gui_menu_info {
- guint merge_id;
- GtkAction *action;
+ guint merge_id;
+ GtkAction *action;
};
-static void
-gui_gtk_del_menu(struct gui_priv *this, struct gui_menu_info *meninfo)
-{
- gtk_action_group_remove_action(this->dyn_group, meninfo->action);
- gtk_ui_manager_remove_ui(this->ui_manager, meninfo->merge_id);
+static void gui_gtk_del_menu(struct gui_priv *this, struct gui_menu_info *meninfo) {
+ gtk_action_group_remove_action(this->dyn_group, meninfo->action);
+ gtk_ui_manager_remove_ui(this->ui_manager, meninfo->merge_id);
}
-static struct gui_menu_info
-gui_gtk_add_menu(struct gui_priv *this, char *name, char *label, char *path, int submenu, struct action_cb_data *data)
-{
- struct gui_menu_info meninfo;
- GtkAction *action;
- guint merge_id;
-
- action=gtk_action_new(name, label, NULL, NULL);
- meninfo.action = action;
- if (data)
- g_signal_connect(action, "activate", G_CALLBACK(gui_gtk_action_activate), data);
- gtk_action_group_add_action(this->dyn_group, action);
- merge_id =gtk_ui_manager_new_merge_id(this->ui_manager);
- meninfo.merge_id = merge_id;
- gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
-
- return meninfo;
+static struct gui_menu_info gui_gtk_add_menu(struct gui_priv *this, char *name, char *label, char *path, int submenu,
+ struct action_cb_data *data) {
+ struct gui_menu_info meninfo;
+ GtkAction *action;
+ guint merge_id;
+
+ action=gtk_action_new(name, label, NULL, NULL);
+ meninfo.action = action;
+ if (data)
+ g_signal_connect(action, "activate", G_CALLBACK(gui_gtk_action_activate), data);
+ gtk_action_group_add_action(this->dyn_group, action);
+ merge_id =gtk_ui_manager_new_merge_id(this->ui_manager);
+ meninfo.merge_id = merge_id;
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name,
+ submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ return meninfo;
}
-static void
-gui_gtk_action_toggled(GtkToggleAction *action, struct action_cb_data *data)
-{
- struct attr active;
- active.type=attr_active;
- active.u.num=gtk_toggle_action_get_active(action);
- map_set_attr(data->attr.u.map, &active);
- navit_draw(data->gui->nav);
+static void gui_gtk_action_toggled(GtkToggleAction *action, struct action_cb_data *data) {
+ struct attr active;
+ active.type=attr_active;
+ active.u.num=gtk_toggle_action_get_active(action);
+ map_set_attr(data->attr.u.map, &active);
+ navit_draw(data->gui->nav);
}
-static void
-gui_gtk_add_toggle_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data, gboolean active)
-{
- GtkToggleAction *toggle_action;
- guint merge_id;
-
- toggle_action=gtk_toggle_action_new(name, label, NULL, NULL);
- gtk_toggle_action_set_active(toggle_action, active);
- g_signal_connect(GTK_ACTION(toggle_action), "toggled", G_CALLBACK(gui_gtk_action_toggled), data);
- gtk_action_group_add_action(this->dyn_group, GTK_ACTION(toggle_action));
- merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
- gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+static void gui_gtk_add_toggle_menu(struct gui_priv *this, char *name, char *label, char *path,
+ struct action_cb_data *data, gboolean active) {
+ GtkToggleAction *toggle_action;
+ guint merge_id;
+
+ toggle_action=gtk_toggle_action_new(name, label, NULL, NULL);
+ gtk_toggle_action_set_active(toggle_action, active);
+ g_signal_connect(GTK_ACTION(toggle_action), "toggled", G_CALLBACK(gui_gtk_action_toggled), data);
+ gtk_action_group_add_action(this->dyn_group, GTK_ACTION(toggle_action));
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
}
-static void
-gui_gtk_action_changed(GtkRadioAction *action, GtkRadioAction *current, struct action_cb_data *data)
-{
- if (action == current) {
- navit_set_attr(data->gui->nav, &data->attr);
- }
+static void gui_gtk_action_changed(GtkRadioAction *action, GtkRadioAction *current, struct action_cb_data *data) {
+ if (action == current) {
+ navit_set_attr(data->gui->nav, &data->attr);
+ }
}
-static struct gui_menu_info
-gui_gtk_add_radio_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data, GSList **g)
-{
- struct gui_menu_info meninfo;
- GtkRadioAction *radio_action;
- guint merge_id;
-
- radio_action=gtk_radio_action_new(name, label, NULL, NULL, 0);
- meninfo.action = (GtkAction *)radio_action;
- gtk_radio_action_set_group(radio_action, *g);
- *g=gtk_radio_action_get_group(radio_action);
- g_signal_connect(GTK_ACTION(radio_action), "changed", G_CALLBACK(gui_gtk_action_changed), data);
- gtk_action_group_add_action(this->dyn_group, GTK_ACTION(radio_action));
- merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
- meninfo.merge_id = merge_id;
- gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
-
- return meninfo;
+static struct gui_menu_info gui_gtk_add_radio_menu(struct gui_priv *this, char *name, char *label, char *path,
+ struct action_cb_data *data, GSList **g) {
+ struct gui_menu_info meninfo;
+ GtkRadioAction *radio_action;
+ guint merge_id;
+
+ radio_action=gtk_radio_action_new(name, label, NULL, NULL, 0);
+ meninfo.action = (GtkAction *)radio_action;
+ gtk_radio_action_set_group(radio_action, *g);
+ *g=gtk_radio_action_get_group(radio_action);
+ g_signal_connect(GTK_ACTION(radio_action), "changed", G_CALLBACK(gui_gtk_action_changed), data);
+ gtk_action_group_add_action(this->dyn_group, GTK_ACTION(radio_action));
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ meninfo.merge_id = merge_id;
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ return meninfo;
}
-static void
-gui_gtk_layouts_init(struct gui_priv *this)
-{
- struct attr_iter *iter;
- struct attr attr;
- struct action_cb_data *data;
- int count=0;
- char *name;
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
- name=g_strdup_printf("Layout %d", count++);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_layout;
- data->attr.u.layout=attr.u.layout;
- gui_gtk_add_radio_menu(this, name, attr.u.layout->name, "/ui/MenuBar/Map/Layout/LayoutMenuAdditions", data, &this->layout_group);
- g_free(name);
- }
- navit_attr_iter_destroy(iter);
+static void gui_gtk_layouts_init(struct gui_priv *this) {
+ struct attr_iter *iter;
+ struct attr attr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
+ name=g_strdup_printf("Layout %d", count++);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_layout;
+ data->attr.u.layout=attr.u.layout;
+ gui_gtk_add_radio_menu(this, name, attr.u.layout->name, "/ui/MenuBar/Map/Layout/LayoutMenuAdditions", data,
+ &this->layout_group);
+ g_free(name);
+ }
+ navit_attr_iter_destroy(iter);
}
-static void
-gui_gtk_projections_init(struct gui_priv *this)
-{
- struct action_cb_data *data;
-
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_projection;
- data->attr.u.projection=projection_mg;
- gui_gtk_add_radio_menu(this, "Projection mg", "Map & Guide", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data, &this->projection_group);
-
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_projection;
- data->attr.u.projection=projection_garmin;
- gui_gtk_add_radio_menu(this, "Projection garmin", "Garmin", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data, &this->projection_group);
+static void gui_gtk_projections_init(struct gui_priv *this) {
+ struct action_cb_data *data;
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_projection;
+ data->attr.u.projection=projection_mg;
+ gui_gtk_add_radio_menu(this, "Projection mg", "Map & Guide", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data,
+ &this->projection_group);
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_projection;
+ data->attr.u.projection=projection_garmin;
+ gui_gtk_add_radio_menu(this, "Projection garmin", "Garmin", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data,
+ &this->projection_group);
}
-static void
-gui_gtk_vehicles_update(struct gui_priv *this)
-{
- struct attr_iter *iter;
- struct attr attr,vattr;
- struct action_cb_data *data;
- int count=0;
- char *name;
- GList *curr;
- struct gui_menu_info *meninfo;
- dbg(lvl_debug,"enter\n");
-
- curr = g_list_first(this->vehicle_menuitems);
-
- while (curr) {
- gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
- g_free((struct gui_menu_info *)curr->data);
- curr = g_list_next(curr);
- };
-
- g_list_free(this->vehicle_menuitems);
- this->vehicle_menuitems = NULL;
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- name=g_strdup_printf("Vehicle %d", count++);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_vehicle;
- data->attr.u.vehicle=attr.u.vehicle;
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_radio_menu(this, name, vattr.u.str, "/ui/MenuBar/Map/Vehicle/VehicleMenuAdditions", data, &this->vehicle_group);
- this->vehicle_menuitems = g_list_prepend(this->vehicle_menuitems, meninfo);
- g_free(name);
- }
- navit_attr_iter_destroy(iter);
+static void gui_gtk_vehicles_update(struct gui_priv *this) {
+ struct attr_iter *iter;
+ struct attr attr,vattr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name;
+ GList *curr;
+ struct gui_menu_info *meninfo;
+ dbg(lvl_debug,"enter");
+
+ curr = g_list_first(this->vehicle_menuitems);
+
+ while (curr) {
+ gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
+ g_free((struct gui_menu_info *)curr->data);
+ curr = g_list_next(curr);
+ };
+
+ g_list_free(this->vehicle_menuitems);
+ this->vehicle_menuitems = NULL;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ name=g_strdup_printf("Vehicle %d", count++);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_vehicle;
+ data->attr.u.vehicle=attr.u.vehicle;
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_radio_menu(this, name, vattr.u.str, "/ui/MenuBar/Map/Vehicle/VehicleMenuAdditions", data,
+ &this->vehicle_group);
+ this->vehicle_menuitems = g_list_prepend(this->vehicle_menuitems, meninfo);
+ g_free(name);
+ }
+ navit_attr_iter_destroy(iter);
}
-static void
-gui_gtk_vehicles_init(struct gui_priv *this)
-{
- navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_vehicles_update), attr_vehicle, this));
- gui_gtk_vehicles_update(this);
+static void gui_gtk_vehicles_init(struct gui_priv *this) {
+ navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_vehicles_update), attr_vehicle, this));
+ gui_gtk_vehicles_update(this);
}
-static void
-gui_gtk_maps_init(struct gui_priv *this)
-{
- struct attr_iter *iter;
- struct attr attr,active,type,data;
- struct action_cb_data *cb_data;
- int count=0;
- char *name, *label;
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
- name=g_strdup_printf("Map %d", count++);
- if (! map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str="";
- if (! map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str="";
- label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
- cb_data=g_new(struct action_cb_data, 1);
- cb_data->gui=this;
- cb_data->attr.type=attr_map;
- cb_data->attr.u.map=attr.u.map;
- if (! map_get_attr(attr.u.map, attr_active, &active, NULL))
- active.u.num=1;
- gui_gtk_add_toggle_menu(this, name, label, "/ui/MenuBar/Map/MapMenuAdditions", cb_data, active.u.num);
- g_free(name);
- g_free(label);
- }
- navit_attr_iter_destroy(iter);
+static void gui_gtk_maps_init(struct gui_priv *this) {
+ struct attr_iter *iter;
+ struct attr attr,active,type,data;
+ struct action_cb_data *cb_data;
+ int count=0;
+ char *name, *label;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ name=g_strdup_printf("Map %d", count++);
+ if (! map_get_attr(attr.u.map, attr_type, &type, NULL))
+ type.u.str="";
+ if (! map_get_attr(attr.u.map, attr_data, &data, NULL))
+ data.u.str="";
+ label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
+ cb_data=g_new(struct action_cb_data, 1);
+ cb_data->gui=this;
+ cb_data->attr.type=attr_map;
+ cb_data->attr.u.map=attr.u.map;
+ if (! map_get_attr(attr.u.map, attr_active, &active, NULL))
+ active.u.num=1;
+ gui_gtk_add_toggle_menu(this, name, label, "/ui/MenuBar/Map/MapMenuAdditions", cb_data, active.u.num);
+ g_free(name);
+ g_free(label);
+ }
+ navit_attr_iter_destroy(iter);
}
-static void
-gui_gtk_destinations_update(struct gui_priv *this)
-{
- GList *curr;
- struct attr attr;
- struct action_cb_data *data;
- struct map_rect *mr=NULL;
- struct item *item;
- struct gui_menu_info *meninfo;
- struct coord c;
- int count=0;
- char *name, *label;
-
- curr = g_list_first(this->dest_menuitems);
-
- while (curr) {
- gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
- g_free((struct gui_menu_info *)curr->data);
- curr = g_list_next(curr);
- };
-
- g_list_free(this->dest_menuitems);
- this->dest_menuitems = NULL;
-
- if(navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL) && attr.u.map && (mr=map_rect_new(attr.u.map, NULL))) {
- while ((item=map_rect_get_item(mr))) {
- if (item->type != type_former_destination) continue;
- name=g_strdup_printf("Destination %d", count++);
- item_attr_get(item, attr_label, &attr);
- label=attr.u.str;
- item_coord_get(item, &c, 1);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_destination;
- data->attr.u.pcoord=g_new(struct pcoord, 1);
- data->attr.u.pcoord->pro=projection_mg;
- data->attr.u.pcoord->x=c.x;
- data->attr.u.pcoord->y=c.y;
-
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_menu(this, name, label, "/ui/MenuBar/Route/FormerDestinations/FormerDestinationMenuAdditions",0,data);
- this->dest_menuitems = g_list_prepend(this->dest_menuitems, meninfo);
- g_free(name);
- }
- map_rect_destroy(mr);
- }
+static void gui_gtk_destinations_update(struct gui_priv *this) {
+ GList *curr;
+ struct attr attr;
+ struct action_cb_data *data;
+ struct map_rect *mr=NULL;
+ struct item *item;
+ struct gui_menu_info *meninfo;
+ struct coord c;
+ int count=0;
+ char *name, *label;
+
+ curr = g_list_first(this->dest_menuitems);
+
+ while (curr) {
+ gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
+ g_free((struct gui_menu_info *)curr->data);
+ curr = g_list_next(curr);
+ };
+
+ g_list_free(this->dest_menuitems);
+ this->dest_menuitems = NULL;
+
+ if(navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL) && attr.u.map
+ && (mr=map_rect_new(attr.u.map, NULL))) {
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type != type_former_destination) continue;
+ name=g_strdup_printf("Destination %d", count++);
+ item_attr_get(item, attr_label, &attr);
+ label=attr.u.str;
+ item_coord_get(item, &c, 1);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_destination;
+ data->attr.u.pcoord=g_new(struct pcoord, 1);
+ data->attr.u.pcoord->pro=projection_mg;
+ data->attr.u.pcoord->x=c.x;
+ data->attr.u.pcoord->y=c.y;
+
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_menu(this, name, label, "/ui/MenuBar/Route/FormerDestinations/FormerDestinationMenuAdditions",0,
+ data);
+ this->dest_menuitems = g_list_prepend(this->dest_menuitems, meninfo);
+ g_free(name);
+ }
+ map_rect_destroy(mr);
+ }
}
-static void
-gui_gtk_destinations_init(struct gui_priv *this)
-{
- navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_destinations_update), attr_destination, this));
- gui_gtk_destinations_update(this);
+static void gui_gtk_destinations_init(struct gui_priv *this) {
+ navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_destinations_update), attr_destination, this));
+ gui_gtk_destinations_update(this);
}
-static void
-gui_gtk_bookmarks_update(struct gui_priv *this)
-{
- GList *curr;
- struct attr attr;
- struct action_cb_data *data;
- struct map_rect *mr=NULL;
- struct gui_menu_info *meninfo;
- struct item *item;
- struct coord c;
- int count=0;
- char *parent, *name, *label, *label_full, *menu_label, *tmp_parent, *s;
- GHashTable *hash;
-
- curr = g_list_first(this->bookmarks_menuitems);
-
- while (curr) {
- gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
- g_free((struct gui_menu_info *)curr->data);
- curr = g_list_next(curr);
- };
-
- g_list_free(this->bookmarks_menuitems);
- this->bookmarks_menuitems = NULL;
-
- if(navit_get_attr(this->nav, attr_bookmark_map, &attr, NULL) && attr.u.map && (mr=map_rect_new(attr.u.map, NULL))) {
- hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- while ((item=map_rect_get_item(mr))) {
- if (item->type != type_bookmark) continue;
- item_attr_get(item, attr_label, &attr);
- label_full=attr.u.str;
- item_coord_get(item, &c, 1);
- menu_label=g_malloc(strlen(label_full)+1);
- label=label_full;
- parent=g_strdup("/ui/MenuBar/Route/Bookmarks/BookmarkMenuAdditions");
- while ((s=strchr(label, '/'))) {
- strcpy(menu_label, label_full);
- menu_label[s-label_full]='\0';
- if ((tmp_parent=g_hash_table_lookup(hash, menu_label))) {
- tmp_parent=g_strdup(tmp_parent);
- } else {
- name=g_strdup_printf("Bookmark %d", count++);
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_menu(this, name, menu_label+(label-label_full),parent,1,NULL);
- this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
- tmp_parent=g_strdup_printf("%s/%s", parent, name);
- g_hash_table_insert(hash, g_strdup(menu_label), g_strdup(tmp_parent));
- g_free(name);
- }
- g_free(parent);
- parent=tmp_parent;
- label=s+1;
- }
- g_free(menu_label);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_destination;
- data->attr.u.pcoord=g_new(struct pcoord, 1);
- data->attr.u.pcoord->pro=projection_mg;
- data->attr.u.pcoord->x=c.x;
- data->attr.u.pcoord->y=c.y;
- name=g_strdup_printf("Bookmark %d", count++);
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_menu(this, name, label, parent,0,data);
- this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
- g_free(name);
- g_free(parent);
- }
- g_hash_table_destroy(hash);
- }
+static void gui_gtk_bookmarks_update(struct gui_priv *this) {
+ GList *curr;
+ struct attr attr;
+ struct action_cb_data *data;
+ struct map_rect *mr=NULL;
+ struct gui_menu_info *meninfo;
+ struct item *item;
+ struct coord c;
+ int count=0;
+ char *parent, *name, *label, *label_full, *menu_label, *tmp_parent, *s;
+ GHashTable *hash;
+
+ curr = g_list_first(this->bookmarks_menuitems);
+
+ while (curr) {
+ gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
+ g_free((struct gui_menu_info *)curr->data);
+ curr = g_list_next(curr);
+ };
+
+ g_list_free(this->bookmarks_menuitems);
+ this->bookmarks_menuitems = NULL;
+
+ if(navit_get_attr(this->nav, attr_bookmark_map, &attr, NULL) && attr.u.map && (mr=map_rect_new(attr.u.map, NULL))) {
+ hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type != type_bookmark) continue;
+ item_attr_get(item, attr_label, &attr);
+ label_full=attr.u.str;
+ item_coord_get(item, &c, 1);
+ menu_label=g_malloc(strlen(label_full)+1);
+ label=label_full;
+ parent=g_strdup("/ui/MenuBar/Route/Bookmarks/BookmarkMenuAdditions");
+ while ((s=strchr(label, '/'))) {
+ strcpy(menu_label, label_full);
+ menu_label[s-label_full]='\0';
+ if ((tmp_parent=g_hash_table_lookup(hash, menu_label))) {
+ tmp_parent=g_strdup(tmp_parent);
+ } else {
+ name=g_strdup_printf("Bookmark %d", count++);
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_menu(this, name, menu_label+(label-label_full),parent,1,NULL);
+ this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
+ tmp_parent=g_strdup_printf("%s/%s", parent, name);
+ g_hash_table_insert(hash, g_strdup(menu_label), g_strdup(tmp_parent));
+ g_free(name);
+ }
+ g_free(parent);
+ parent=tmp_parent;
+ label=s+1;
+ }
+ g_free(menu_label);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_destination;
+ data->attr.u.pcoord=g_new(struct pcoord, 1);
+ data->attr.u.pcoord->pro=projection_mg;
+ data->attr.u.pcoord->x=c.x;
+ data->attr.u.pcoord->y=c.y;
+ name=g_strdup_printf("Bookmark %d", count++);
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_menu(this, name, label, parent,0,data);
+ this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
+ g_free(name);
+ g_free(parent);
+ }
+ g_hash_table_destroy(hash);
+ }
}
-static void
-gui_gtk_bookmarks_init(struct gui_priv *this)
-{
- struct attr attr;
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_callback(attr.u.bookmarks, callback_new_attr_1(callback_cast(gui_gtk_bookmarks_update), attr_bookmark_map, this));
- gui_gtk_bookmarks_update(this);
+static void gui_gtk_bookmarks_init(struct gui_priv *this) {
+ struct attr attr;
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_callback(attr.u.bookmarks, callback_new_attr_1(callback_cast(gui_gtk_bookmarks_update), attr_bookmark_map,
+ this));
+ gui_gtk_bookmarks_update(this);
}
-static void
-gui_gtk_init(struct gui_priv *this, struct navit *nav)
-{
-
- struct attr route_attr;
-
- gui_gtk_toggle_init(this);
- gui_gtk_layouts_init(this);
- gui_gtk_projections_init(this);
- gui_gtk_vehicles_init(this);
- gui_gtk_maps_init(this);
- gui_gtk_destinations_init(this);
- gui_gtk_bookmarks_init(this);
-
- if (navit_get_attr(nav,attr_route,&route_attr,NULL)) {
- struct attr callback;
- callback.type=attr_callback;
- callback.u.callback=callback_new_attr_1(callback_cast(gui_gtk_route_callback), attr_route_status, this);
- route_add_attr(route_attr.u.route, &callback);
- }
- gui_gtk_route_callback(this); //Set initial state
+static void gui_gtk_init(struct gui_priv *this, struct navit *nav) {
+
+ struct attr route_attr;
+
+ gui_gtk_toggle_init(this);
+ gui_gtk_layouts_init(this);
+ gui_gtk_projections_init(this);
+ gui_gtk_vehicles_init(this);
+ gui_gtk_maps_init(this);
+ gui_gtk_destinations_init(this);
+ gui_gtk_bookmarks_init(this);
+
+ if (navit_get_attr(nav,attr_route,&route_attr,NULL)) {
+ struct attr callback;
+ callback.type=attr_callback;
+ callback.u.callback=callback_new_attr_1(callback_cast(gui_gtk_route_callback), attr_route_status, this);
+ route_add_attr(route_attr.u.route, &callback);
+ }
+ gui_gtk_route_callback(this); //Set initial state
}
-static struct gui_priv *
-gui_gtk_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct gui_priv *this;
- int w=792, h=547;
- char *cp = getenv("NAVIT_XID");
- unsigned xid = 0;
- struct attr *attr;
- GtkWidget *widget;
- int fullscreen = 0;
-
- if (! event_request_system("glib","gui_gtk_new"))
- return NULL;
-
- if (cp) {
- xid = strtol(cp, NULL, 0);
- }
-
- this=g_new0(struct gui_priv, 1);
- this->nav=nav;
-
- attr = attr_search(attrs, NULL, attr_menubar);
- if (attr) {
- this->menubar_enable=attr->u.num;
- } else {
- this->menubar_enable=1;
- }
- attr=attr_search(attrs, NULL, attr_toolbar);
- if (attr) {
- this->toolbar_enable=attr->u.num;
- } else {
- this->toolbar_enable=1;
- }
- attr=attr_search(attrs, NULL, attr_statusbar);
- if (attr) {
- this->statusbar_enable=attr->u.num;
- } else {
- this->statusbar_enable=1;
- }
-
- *meth=gui_gtk_methods;
-
- if (!xid)
- this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- else
- this->win = gtk_plug_new(xid);
-
-
- g_signal_connect(G_OBJECT(this->win), "delete-event", G_CALLBACK(gui_gtk_delete), nav);
- this->vbox = gtk_vbox_new(FALSE, 0);
- gtk_window_set_default_size(GTK_WINDOW(this->win), w, h);
- gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
- gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", "Navit");
- gtk_widget_realize(this->win);
- gui_gtk_ui_init(this);
- if (this->menubar_enable) {
- widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/MenuBar");
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
- this->menubar=widget;
- }
- if (this->toolbar_enable) {
- widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/ToolBar");
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
- }
- if (this->statusbar_enable) {
- this->statusbar=gui_gtk_statusbar_new(this);
- }
- gtk_window_add_accel_group (GTK_WINDOW (this->win),
- gtk_ui_manager_get_accel_group(this->ui_manager));
- gtk_container_add(GTK_CONTAINER(this->win), this->vbox);
- gtk_widget_show_all(this->win);
-
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(gui_gtk_init), attr_navit, this));
-
- if ((attr=attr_search(attrs, NULL, attr_fullscreen)))
- fullscreen=attr->u.num;
-
- if (fullscreen) {
- GtkToggleAction *action;
- action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
- gtk_toggle_action_set_active (action, fullscreen);
- }
-
- return this;
+static struct gui_priv *gui_gtk_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui) {
+ struct gui_priv *this;
+ int w=792, h=547;
+ char *cp = getenv("NAVIT_XID");
+ unsigned xid = 0;
+ struct attr *attr;
+ GtkWidget *widget;
+ int fullscreen = 0;
+
+ if (! event_request_system("glib","gui_gtk_new"))
+ return NULL;
+
+ if (cp) {
+ xid = strtol(cp, NULL, 0);
+ }
+
+ this=g_new0(struct gui_priv, 1);
+ this->nav=nav;
+
+ attr = attr_search(attrs, NULL, attr_menubar);
+ if (attr) {
+ this->menubar_enable=attr->u.num;
+ } else {
+ this->menubar_enable=1;
+ }
+ attr=attr_search(attrs, NULL, attr_toolbar);
+ if (attr) {
+ this->toolbar_enable=attr->u.num;
+ } else {
+ this->toolbar_enable=1;
+ }
+ attr=attr_search(attrs, NULL, attr_statusbar);
+ if (attr) {
+ this->statusbar_enable=attr->u.num;
+ } else {
+ this->statusbar_enable=1;
+ }
+
+ *meth=gui_gtk_methods;
+
+ if (!xid)
+ this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ else
+ this->win = gtk_plug_new(xid);
+
+
+ g_signal_connect(G_OBJECT(this->win), "delete-event", G_CALLBACK(gui_gtk_delete), nav);
+ this->vbox = gtk_vbox_new(FALSE, 0);
+ gtk_window_set_default_size(GTK_WINDOW(this->win), w, h);
+ gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
+ gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", "Navit");
+ gtk_widget_realize(this->win);
+ gui_gtk_ui_init(this);
+ if (this->menubar_enable) {
+ widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/MenuBar");
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ this->menubar=widget;
+ }
+ if (this->toolbar_enable) {
+ widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/ToolBar");
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ }
+ if (this->statusbar_enable) {
+ this->statusbar=gui_gtk_statusbar_new(this);
+ }
+ gtk_window_add_accel_group (GTK_WINDOW (this->win),
+ gtk_ui_manager_get_accel_group(this->ui_manager));
+ gtk_container_add(GTK_CONTAINER(this->win), this->vbox);
+ gtk_widget_show_all(this->win);
+
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(gui_gtk_init), attr_navit, this));
+
+ if ((attr=attr_search(attrs, NULL, attr_fullscreen)))
+ fullscreen=attr->u.num;
+
+ if (fullscreen) {
+ GtkToggleAction *action;
+ action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
+ gtk_toggle_action_set_active (action, fullscreen);
+ }
+
+ return this;
}
static int gtk_argc;
-static char **gtk_argv={NULL};
+static char **gtk_argv= {NULL};
-void
-plugin_init(void)
-{
- gtk_init(&gtk_argc, &gtk_argv);
- gtk_set_locale();
+void plugin_init(void) {
+ gtk_init(&gtk_argc, &gtk_argv);
+ gtk_set_locale();
#ifdef HAVE_API_WIN32
- setlocale(LC_NUMERIC,"C");
+ setlocale(LC_NUMERIC,"C");
#endif
- plugin_register_category_gui("gtk", gui_gtk_new);
+ plugin_register_category_gui("gtk", gui_gtk_new);
}
diff --git a/navit/gui/internal/CMakeLists.txt b/navit/gui/internal/CMakeLists.txt
index 4c853f526..bda2068da 100644
--- a/navit/gui/internal/CMakeLists.txt
+++ b/navit/gui/internal/CMakeLists.txt
@@ -1,3 +1,7 @@
+if (GUI_INTERNAL_VISUAL_DBG)
+ add_definitions ("-DGUI_INTERNAL_VISUAL_DBG")
+endif(GUI_INTERNAL_VISUAL_DBG)
+
if(USE_AUDIO_FRAMEWORK)
set(audio_sources gui_internal_media.c )
endif(USE_AUDIO_FRAMEWORK)
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index 0a62ae010..726a03d17 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -105,13 +105,14 @@ const int SMALL_PROFILE=2;
* [1] => MEDIUM PROFILE (screens larger than 320 in one dimension
* [2] => Small profile (default)
*/
-static struct gui_config_settings config_profiles[]={
- {545,32,48,96,10}
+static struct gui_config_settings config_profiles[]= {
+ {545,32,48,96,10}
, {300,32,48,64,3}
- ,{200,16,32,48,2}
+ ,{200,16,32,48,2}
};
static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data);
+static void gui_internal_prepare_search_results_map(struct gui_priv *this, struct widget *table, struct coord_rect *r);
static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle *vehicle);
@@ -127,29 +128,25 @@ static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
*
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
-static struct graphics_image *
-image_new_scaled(struct gui_priv *this, const char *name, int w, int h)
-{
- struct graphics_image *ret=NULL;
- char *full_path=NULL;
- full_path=graphics_icon_path(name);
- ret=graphics_image_new_scaled(this->gra, full_path, w, h);
- dbg(lvl_debug,"Trying to load image '%s' (w=%d, h=%d): %s\n", name, w, h, ret ? "OK" : "NOT FOUND");
- g_free(full_path);
- if (!ret) {
- dbg(lvl_error,"Failed to load image for '%s' (w=%d, h=%d)\n", name, w, h);
- full_path=graphics_icon_path("unknown");
- ret=graphics_image_new_scaled(this->gra, full_path, w, h);
- g_free(full_path);
- }
- return ret;
+static struct graphics_image *image_new_scaled(struct gui_priv *this, const char *name, int w, int h) {
+ struct graphics_image *ret=NULL;
+ char *full_path=NULL;
+ full_path=graphics_icon_path(name);
+ ret=graphics_image_new_scaled(this->gra, full_path, w, h);
+ dbg(lvl_debug,"Trying to load image '%s' (w=%d, h=%d): %s", name, w, h, ret ? "OK" : "NOT FOUND");
+ g_free(full_path);
+ if (!ret) {
+ dbg(lvl_error,"Failed to load image for '%s' (w=%d, h=%d)", name, w, h);
+ full_path=graphics_icon_path("unknown");
+ ret=graphics_image_new_scaled(this->gra, full_path, w, h);
+ g_free(full_path);
+ }
+ return ret;
}
#if 0
-static struct graphics_image *
-image_new_o(struct gui_priv *this, char *name)
-{
- return image_new_scaled(this, name, -1, -1);
+static struct graphics_image *image_new_o(struct gui_priv *this, char *name) {
+ return image_new_scaled(this, name, -1, -1);
}
#endif
@@ -164,9 +161,8 @@ image_new_o(struct gui_priv *this, char *name)
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
struct graphics_image *
-image_new_xs(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_xs, this->icon_xs);
+image_new_xs(struct gui_priv *this, const char *name) {
+ return image_new_scaled(this, name, this->icon_xs, this->icon_xs);
}
/**
@@ -178,9 +174,8 @@ image_new_xs(struct gui_priv *this, const char *name)
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
struct graphics_image *
-image_new_s(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_s, this->icon_s);
+image_new_s(struct gui_priv *this, const char *name) {
+ return image_new_scaled(this, name, this->icon_s, this->icon_s);
}
/**
@@ -191,108 +186,101 @@ image_new_s(struct gui_priv *this, const char *name)
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
struct graphics_image *
-image_new_l(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_l, this->icon_l);
-}
-
-
-
-static int
-gui_internal_button_attr_update(struct gui_priv *this, struct widget *w)
-{
- struct widget *wi;
- int is_on=0;
- struct attr curr;
- GList *l;
-
- if (w->get_attr(w->instance, w->on.type, &curr, NULL))
- is_on=curr.u.data == w->on.u.data;
- else
- is_on=w->deflt;
- if (is_on != w->is_on) {
- if (w->redraw)
- this->redraw=1;
- w->is_on=is_on;
- l=g_list_first(w->children);
- if (l) {
- wi=l->data;
- if (wi->img)
- graphics_image_free(this->gra, wi->img);
- wi->img=image_new_xs(this, is_on ? "gui_active" : "gui_inactive");
- }
- if (w->is_on && w->off.type == attr_none)
- w->state &= ~STATE_SENSITIVE;
- else
- w->state |= STATE_SENSITIVE;
- return 1;
- }
- return 0;
-}
-
-static void
-gui_internal_button_attr_callback(struct gui_priv *this, struct widget *w)
-{
- if (gui_internal_button_attr_update(this, w))
- gui_internal_widget_render(this, w);
-}
-static void
-gui_internal_button_attr_pressed(struct gui_priv *this, struct widget *w, void *data)
-{
- if (w->is_on)
- w->set_attr(w->instance, &w->off);
- else
- w->set_attr(w->instance, &w->on);
- gui_internal_button_attr_update(this, w);
+image_new_l(struct gui_priv *this, const char *name) {
+ return image_new_scaled(this, name, this->icon_l, this->icon_l);
+}
+
+
+
+static int gui_internal_button_attr_update(struct gui_priv *this, struct widget *w) {
+ struct widget *wi;
+ int is_on=0;
+ struct attr curr;
+ GList *l;
+
+ if (w->get_attr(w->instance, w->on.type, &curr, NULL))
+ is_on=curr.u.data == w->on.u.data;
+ else
+ is_on=w->deflt;
+ if (is_on != w->is_on) {
+ if (w->redraw)
+ this->redraw=1;
+ w->is_on=is_on;
+ l=g_list_first(w->children);
+ if (l) {
+ wi=l->data;
+ if (wi->img)
+ graphics_image_free(this->gra, wi->img);
+ wi->img=image_new_xs(this, is_on ? "gui_active" : "gui_inactive");
+ }
+ if (w->is_on && w->off.type == attr_none)
+ w->state &= ~STATE_SENSITIVE;
+ else
+ w->state |= STATE_SENSITIVE;
+ return 1;
+ }
+ return 0;
+}
+
+static void gui_internal_button_attr_callback(struct gui_priv *this, struct widget *w) {
+ if (gui_internal_button_attr_update(this, w))
+ gui_internal_widget_render(this, w);
+}
+static void gui_internal_button_attr_pressed(struct gui_priv *this, struct widget *w, void *data) {
+ if (w->is_on)
+ w->set_attr(w->instance, &w->off);
+ else
+ w->set_attr(w->instance, &w->on);
+ gui_internal_button_attr_update(this, w);
}
struct widget *
-gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on, struct attr *off)
-{
- struct graphics_image *image=NULL;
- struct widget *ret;
- if (!on && !off)
- return NULL;
- image=image_new_xs(this, "gui_inactive");
- ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
- if (on)
- ret->on=*on;
- if (off)
- ret->off=*off;
- ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr;
- ret->set_attr=(int (*)(void *, struct attr *))navit_set_attr;
- ret->remove_cb=(void (*)(void *, struct callback *))navit_remove_callback;
- ret->instance=this->nav;
- ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
- navit_add_callback(this->nav, ret->cb);
- gui_internal_button_attr_update(this, ret);
- return ret;
+gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on,
+ struct attr *off) {
+ struct graphics_image *image=NULL;
+ struct widget *ret;
+ if (!on && !off)
+ return NULL;
+ image=image_new_xs(this, "gui_inactive");
+ ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
+ if (on)
+ ret->on=*on;
+ if (off)
+ ret->off=*off;
+ ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr;
+ ret->set_attr=(int (*)(void *, struct attr *))navit_set_attr;
+ ret->remove_cb=(void (*)(void *, struct callback *))navit_remove_callback;
+ ret->instance=this->nav;
+ ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
+ navit_add_callback(this->nav, ret->cb);
+ gui_internal_button_attr_update(this, ret);
+ return ret;
}
struct widget *
-gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt)
-{
- struct graphics_image *image=NULL;
- struct widget *ret;
- image=image_new_xs(this, "gui_inactive");
- if (!on && !off)
- return NULL;
- ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
- if (on)
- ret->on=*on;
- if (off)
- ret->off=*off;
- ret->deflt=deflt;
- ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr;
- ret->set_attr=(int (*)(void *, struct attr *))map_set_attr;
- ret->remove_cb=(void (*)(void *, struct callback *))map_remove_callback;
- ret->instance=map;
- ret->redraw=1;
- ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
- map_add_callback(map, ret->cb);
- gui_internal_button_attr_update(this, ret);
- return ret;
+gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map,
+ struct attr *on, struct attr *off, int deflt) {
+ struct graphics_image *image=NULL;
+ struct widget *ret;
+ image=image_new_xs(this, "gui_inactive");
+ if (!on && !off)
+ return NULL;
+ ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
+ if (on)
+ ret->on=*on;
+ if (off)
+ ret->off=*off;
+ ret->deflt=deflt;
+ ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr;
+ ret->set_attr=(int (*)(void *, struct attr *))map_set_attr;
+ ret->remove_cb=(void (*)(void *, struct callback *))map_remove_callback;
+ ret->instance=map;
+ ret->redraw=1;
+ ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
+ map_add_callback(map, ret->cb);
+ gui_internal_button_attr_update(this, ret);
+ return ret;
}
@@ -312,89 +300,90 @@ gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum f
/* FIXME where is the implementation? */
-static void gui_internal_motion_cb(struct gui_priv *this)
-{
- this->motion_timeout_event=NULL;
- gui_internal_gesture_ring_add(this, &(this->current));
-
- /* Check for scrollable table below the highligted item if there's a movement with the button pressed */
- if (this->pressed && this->highlighted) {
- struct widget *wt=NULL;
- struct widget *wr=NULL;
- int dx,dy;
-
- /* Guard against accidental scrolling when user is likely going to swipe */
- gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
- if(abs(dx)>abs(dy) || abs(dy)<this->icon_s)
- return;
-
- if(this->highlighted)
- for(wr=this->highlighted;wr && wr->type!=widget_table_row;wr=wr->parent);
- if(wr)
- wt=wr->parent;
-
- if(wt && wt->type==widget_table && (wt->state & STATE_SCROLLABLE)) {
- struct table_data *td=wt->data;
- GList *top=NULL;
- GList *btm=NULL;
- GList *ttop, *tbtm;
-
-
-
- if(!wr || !wr->h)
- return;
-
- if(this->current.y < wr->p.y && wr!=td->top_row->data ) {
- int n=(wr->p.y-this->current.y)/wr->h+1;
-
- btm=td->bottom_row;
- top=td->top_row;
-
- while(n-->0 && (tbtm=gui_internal_widget_table_next_row(btm))!=NULL && (ttop=gui_internal_widget_table_next_row(top))!=NULL) {
- top=ttop;
- btm=tbtm;
- if(top->data==wr)
- break;
- }
- this->pressed=2;
- } else if (this->current.y > wr->p.y + wr->h ) {
- int y=wt->p.y+wt->h-wr->h;
- int n;
-
- if(td->scroll_buttons.button_box && td->scroll_buttons.button_box->p.y!=0)
- y=td->scroll_buttons.button_box->p.y - td->scroll_buttons.button_box->h;
-
- if(y>this->current.y)
- y=this->current.y;
-
- n=(y - wr->p.y )/wr->h;
-
- btm=td->bottom_row;
- top=td->top_row;
-
- while(n-->0 && (ttop=gui_internal_widget_table_prev_row(top))!=NULL && (tbtm=gui_internal_widget_table_prev_row(btm))!=NULL) {
- btm=tbtm;
- top=ttop;
- if(btm->data==wr)
- break;
- }
- this->pressed=2;
- }
- if( top && btm && (td->top_row!=top || td->bottom_row!=btm) ) {
- gui_internal_table_hide_rows(wt->data);
- td->top_row=top;
- td->bottom_row=btm;
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this,wt);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
-
- return;
- }
- }
-
- /* Else, just move highlight after pointer if there's nothing to scroll */
- gui_internal_highlight(this);
+static void gui_internal_motion_cb(struct gui_priv *this) {
+ this->motion_timeout_event=NULL;
+ gui_internal_gesture_ring_add(this, &(this->current));
+
+ /* Check for scrollable table below the highligted item if there's a movement with the button pressed */
+ if (this->pressed && this->highlighted) {
+ struct widget *wt=NULL;
+ struct widget *wr=NULL;
+ int dx,dy;
+
+ /* Guard against accidental scrolling when user is likely going to swipe */
+ gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
+ if(abs(dx)>abs(dy) || abs(dy)<this->icon_s)
+ return;
+
+ if(this->highlighted)
+ for(wr=this->highlighted; wr && wr->type!=widget_table_row; wr=wr->parent);
+ if(wr)
+ wt=wr->parent;
+
+ if(wt && wt->type==widget_table && (wt->state & STATE_SCROLLABLE)) {
+ struct table_data *td=wt->data;
+ GList *top=NULL;
+ GList *btm=NULL;
+ GList *ttop, *tbtm;
+
+
+
+ if(!wr || !wr->h)
+ return;
+
+ if(this->current.y < wr->p.y && wr!=td->top_row->data ) {
+ int n=(wr->p.y-this->current.y)/wr->h+1;
+
+ btm=td->bottom_row;
+ top=td->top_row;
+
+ while(n-->0 && (tbtm=gui_internal_widget_table_next_row(btm))!=NULL
+ && (ttop=gui_internal_widget_table_next_row(top))!=NULL) {
+ top=ttop;
+ btm=tbtm;
+ if(top->data==wr)
+ break;
+ }
+ this->pressed=2;
+ } else if (this->current.y > wr->p.y + wr->h ) {
+ int y=wt->p.y+wt->h-wr->h;
+ int n;
+
+ if(td->scroll_buttons.button_box && td->scroll_buttons.button_box->p.y!=0)
+ y=td->scroll_buttons.button_box->p.y - td->scroll_buttons.button_box->h;
+
+ if(y>this->current.y)
+ y=this->current.y;
+
+ n=(y - wr->p.y )/wr->h;
+
+ btm=td->bottom_row;
+ top=td->top_row;
+
+ while(n-->0 && (ttop=gui_internal_widget_table_prev_row(top))!=NULL
+ && (tbtm=gui_internal_widget_table_prev_row(btm))!=NULL) {
+ btm=tbtm;
+ top=ttop;
+ if(btm->data==wr)
+ break;
+ }
+ this->pressed=2;
+ }
+ if( top && btm && (td->top_row!=top || td->bottom_row!=btm) ) {
+ gui_internal_table_hide_rows(wt->data);
+ td->top_row=top;
+ td->bottom_row=btm;
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_widget_render(this,wt);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ }
+
+ return;
+ }
+ }
+
+ /* Else, just move highlight after pointer if there's nothing to scroll */
+ gui_internal_highlight(this);
}
//##############################################################################################################
@@ -402,229 +391,196 @@ static void gui_internal_motion_cb(struct gui_priv *this)
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gui_internal_call_highlighted(struct gui_priv *this)
-{
- if (! this->highlighted || ! this->highlighted->func)
- return;
- this->highlighted->reason=gui_internal_reason_click;
- this->highlighted->func(this, this->highlighted, this->highlighted->data);
-}
-
-void
-gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark)
-{
- char *text=w->speech;
- if (! this->speech)
- return;
- if (!text)
- text=w->text;
- if (!text)
- text=w->name;
- if (text) {
- text=g_strdup_printf("%s%c", text, questionmark ? '?':'\0');
- navit_say(this->nav, text);
- g_free(text);
- }
+static void gui_internal_call_highlighted(struct gui_priv *this) {
+ if (! this->highlighted || ! this->highlighted->func)
+ return;
+ this->highlighted->reason=gui_internal_reason_click;
+ this->highlighted->func(this, this->highlighted, this->highlighted->data);
+}
+
+void gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark) {
+ char *text=w->speech;
+ if (! this->speech)
+ return;
+ if (!text)
+ text=w->text;
+ if (!text)
+ text=w->name;
+ if (text) {
+ text=g_strdup_printf("%s%c", text, questionmark ? '?':'\0');
+ navit_say(this->nav, text);
+ g_free(text);
+ }
}
-void
-gui_internal_back(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_prune_menu_count(this, 1, 1);
+void gui_internal_back(struct gui_priv *this, struct widget *w, void *data) {
+ gui_internal_prune_menu_count(this, 1, 1);
}
-void
-gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_prune_menu(this, wm->data);
+void gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_prune_menu(this, wm->data);
}
-void
-gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=this->root.children->data;
- if (w && w->menu_data && w->menu_data->href && !strcmp(w->menu_data->href,"#Main Menu"))
- gui_internal_prune_menu(this, w);
- else
- gui_internal_html_main_menu(this);
+void gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w=this->root.children->data;
+ if (w && w->menu_data && w->menu_data->href && !strcmp(w->menu_data->href,"#Main Menu"))
+ gui_internal_prune_menu(this, w);
+ else
+ gui_internal_html_main_menu(this);
}
struct widget *
-gui_internal_time_help(struct gui_priv *this)
-{
- struct widget *w,*wc,*wcn;
- char timestr[64];
- struct tm *tm;
- time_t timep;
-
- w=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
- w->bl=this->spacing;
- w->spx=this->spacing;
- w->spx=10;
- w->bl=10;
- w->br=10;
- w->bt=6;
- w->bb=6;
- if (this->flags & 64) {
- wc=gui_internal_box_new(this, gravity_right_top|orientation_vertical|flags_fill);
- wc->bl=10;
- wc->br=20;
- wc->bt=6;
- wc->bb=6;
- timep=time(NULL);
- tm=localtime(&timep);
- strftime(timestr, 64, "%H:%M %d.%m.%Y", tm);
- wcn=gui_internal_label_new(this, timestr);
- gui_internal_widget_append(wc, wcn);
- gui_internal_widget_append(w, wc);
- }
- if (this->flags & 128) {
- wcn=gui_internal_button_new_with_callback(this, _("Help"), image_new_l(this, "gui_help"), gravity_center|orientation_vertical|flags_fill, NULL, NULL);
- gui_internal_widget_append(w, wcn);
- }
- return w;
+gui_internal_time_help(struct gui_priv *this) {
+ struct widget *w,*wc,*wcn;
+ char timestr[64];
+ struct tm *tm;
+ time_t timep;
+
+ w=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
+ w->bl=this->spacing;
+ w->spx=this->spacing;
+ w->spx=10;
+ w->bl=10;
+ w->br=10;
+ w->bt=6;
+ w->bb=6;
+ if (this->flags & 64) {
+ wc=gui_internal_box_new(this, gravity_right_top|orientation_vertical|flags_fill);
+ wc->bl=10;
+ wc->br=20;
+ wc->bt=6;
+ wc->bb=6;
+ timep=time(NULL);
+ tm=localtime(&timep);
+ strftime(timestr, 64, "%H:%M %d.%m.%Y", tm);
+ wcn=gui_internal_label_new(this, timestr);
+ gui_internal_widget_append(wc, wcn);
+ gui_internal_widget_append(w, wc);
+ }
+ if (this->flags & 128) {
+ wcn=gui_internal_button_new_with_callback(this, _("Help"), image_new_l(this, "gui_help"),
+ gravity_center|orientation_vertical|flags_fill, NULL, NULL);
+ gui_internal_widget_append(w, wcn);
+ }
+ return w;
}
/**
* Applies the configuration values to this based on the settings
* specified in the configuration file (this->config) and
- * the most approriate default profile based on screen resolution.
+ * the most appropriate default profile based on screen resolution.
*
* This function should be run after this->root is setup and could
* be rerun after the window is resized.
*
* @author Steve Singer <ssinger_pg@sympatico.ca> (09/2008)
*/
-void
-gui_internal_apply_config(struct gui_priv *this)
-{
- struct gui_config_settings * current_config=0;
-
- dbg(lvl_debug,"w=%d h=%d\n", this->root.w, this->root.h);
- /*
- * Select default values from profile based on the screen.
- */
- if((this->root.w > 320 || this->root.h > 320) && this->root.w > 240 && this->root.h > 240)
- {
- if((this->root.w > 640 || this->root.h > 640) && this->root.w > 480 && this->root.h > 480 )
- {
- current_config = &config_profiles[LARGE_PROFILE];
+void gui_internal_apply_config(struct gui_priv *this) {
+ struct gui_config_settings * current_config=0;
+
+ dbg(lvl_debug,"w=%d h=%d", this->root.w, this->root.h);
+ /*
+ * Select default values from profile based on the screen.
+ */
+ if((this->root.w > 320 || this->root.h > 320) && this->root.w > 240 && this->root.h > 240) {
+ if((this->root.w > 640 || this->root.h > 640) && this->root.w > 480 && this->root.h > 480 ) {
+ current_config = &config_profiles[LARGE_PROFILE];
+ } else {
+ current_config = &config_profiles[MEDIUM_PROFILE];
+ }
+ } else {
+ current_config = &config_profiles[SMALL_PROFILE];
}
- else
- {
- current_config = &config_profiles[MEDIUM_PROFILE];
- }
- }
- else
- {
- current_config = &config_profiles[SMALL_PROFILE];
- }
-
- /*
- * Apply override values from config file
- */
- if(this->config.font_size == -1 )
- {
- this->font_size = current_config->font_size;
- }
- else
- {
- this->font_size = this->config.font_size;
- }
-
- if(this->config.icon_xs == -1 )
- {
- this->icon_xs = current_config->icon_xs;
- }
- else
- {
- this->icon_xs = this->config.icon_xs;
- }
-
- if(this->config.icon_s == -1 )
- {
- this->icon_s = current_config->icon_s;
- }
- else
- {
- this->icon_s = this->config.icon_s;
- }
- if(this->config.icon_l == -1 )
- {
- this->icon_l = current_config->icon_l;
- }
- else
- {
- this->icon_l = this->config.icon_l;
- }
- if(this->config.spacing == -1 )
- {
- this->spacing = current_config->spacing;
- }
- else
- {
- this->spacing = current_config->spacing;
- }
- if (!this->fonts[0]) {
- int i,sizes[]={100,66,50};
- for (i = 0 ; i < 3 ; i++) {
- if (this->font_name)
- this->fonts[i]=graphics_named_font_new(this->gra,this->font_name,this->font_size*sizes[i]/100,1);
- else
- this->fonts[i]=graphics_font_new(this->gra,this->font_size*sizes[i]/100,1);
- }
- }
-
-}
-
-
-
-
-
-static void
-gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void *data)
-{
- char *name=data;
- dbg(lvl_info,"c=%d:0x%x,0x%x\n", wm->c.pro, wm->c.x, wm->c.y);
- navit_set_destination(this->nav, &wm->c, name, 1);
- if (this->flags & 512) {
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=180;
- navit_set_attr(this->nav, &this->osd_configuration);
- navit_set_attr(this->nav, &follow);
- navit_zoom_to_route(this->nav, 0);
- }
- gui_internal_prune_menu(this, NULL);
-}
-
-static void
-gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm, void *data) {
- char *name=data;
- int dstcount=navit_get_destination_count(this->nav)+1;
- int pos,i;
- struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
- dstcount=navit_get_destinations(this->nav,dst,dstcount);
-
- pos=dstcount-wm->datai;
- if(pos<0)
- pos=0;
-
- for(i=dstcount;i>pos;i--)
- dst[i]=dst[i-1];
-
- dst[pos]=wm->c;
- navit_add_destination_description(this->nav,&wm->c,(char*)data);
- navit_set_destinations(this->nav,dst,dstcount+1,name,1);
- gui_internal_prune_menu(this, NULL);
+
+ /*
+ * Apply override values from config file
+ */
+ if(this->config.font_size == -1 ) {
+ this->font_size = current_config->font_size;
+ } else {
+ this->font_size = this->config.font_size;
+ }
+
+ if(this->config.icon_xs == -1 ) {
+ this->icon_xs = current_config->icon_xs;
+ } else {
+ this->icon_xs = this->config.icon_xs;
+ }
+
+ if(this->config.icon_s == -1 ) {
+ this->icon_s = current_config->icon_s;
+ } else {
+ this->icon_s = this->config.icon_s;
+ }
+ if(this->config.icon_l == -1 ) {
+ this->icon_l = current_config->icon_l;
+ } else {
+ this->icon_l = this->config.icon_l;
+ }
+ if(this->config.spacing == -1 ) {
+ this->spacing = current_config->spacing;
+ } else {
+ this->spacing = this->config.spacing;
+ dbg(lvl_info, "Overriding default spacing %d with value %d provided in config file", current_config->spacing,
+ this->config.spacing);
+ }
+ if (!this->fonts[0]) {
+ int i,sizes[]= {100,66,50};
+ for (i = 0 ; i < 3 ; i++) {
+ if (this->font_name)
+ this->fonts[i]=graphics_named_font_new(this->gra,this->font_name,this->font_size*sizes[i]/100,1);
+ else
+ this->fonts[i]=graphics_font_new(this->gra,this->font_size*sizes[i]/100,1);
+ }
+ }
+
+}
+
+
+
+
+
+static void gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void *data) {
+ char *name=data;
+ dbg(lvl_info,"c=%d:0x%x,0x%x", wm->c.pro, wm->c.x, wm->c.y);
+ navit_set_destination(this->nav, &wm->c, name, 1);
+ if (this->flags & 512) {
+ struct attr follow;
+ follow.type=attr_follow;
+ follow.u.num=180;
+ navit_set_attr(this->nav, &this->osd_configuration);
+ navit_set_attr(this->nav, &follow);
+ navit_zoom_to_route(this->nav, 0);
+ }
+ gui_internal_prune_menu(this, NULL);
+}
+
+static void gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm, void *data) {
+ char *name=data;
+ int dstcount=navit_get_destination_count(this->nav)+1;
+ int pos,i;
+ struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
+ dstcount=navit_get_destinations(this->nav,dst,dstcount);
+
+ pos=dstcount-wm->datai;
+ if(pos<0)
+ pos=0;
+
+ for(i=dstcount; i>pos; i--)
+ dst[i]=dst[i-1];
+
+ dst[pos]=wm->c;
+ navit_add_destination_description(this->nav,&wm->c,(char*)data);
+ navit_set_destinations(this->nav,dst,dstcount+1,name,1);
+ gui_internal_prune_menu(this, NULL);
}
/*
@@ -634,7 +590,7 @@ gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm,
* function passed as {@code cmd} will be called.
*
* Widget passed as wm parameter of the called cmd function will have item set to user chosen waypoint item. Its data will be set
- * to zero-based choosen waypoint number, counting from the route end. Coordinates to wm->c will be copied from wm_->c if wm_ is not null. Otherwise,
+ * to zero-based chosen waypoint number, counting from the route end. Coordinates to wm->c will be copied from wm_->c if wm_ is not null. Otherwise,
* waypoint coordinates will be copied to wm->c.
*
* @param this gui context
@@ -644,82 +600,79 @@ gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm,
* @param cmd Callback function which will be called on item selection
* @param data data argument to be passed to the callback function
*/
-void
-gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_, void(*cmd)(struct gui_priv *priv, struct widget *widget, void *data),void *data)
-{
- struct widget *wb,*w,*wtable,*row,*wc;
- struct map *map;
- struct map_rect *mr;
- struct item *item;
- char *text;
- int i;
- int dstcount=navit_get_destination_count(this->nav)+1;
-
- map=route_get_map(navit_get_route(this->nav));
- if(!map)
- return;
- mr = map_rect_new(map, NULL);
- if(!mr)
- return;
-
- wb=gui_internal_menu(this, title);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if(hint)
- gui_internal_widget_append(w, gui_internal_label_new(this, hint));
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,wtable);
-
- i=0;
- while((item = map_rect_get_item(mr))!=NULL) {
- struct attr attr;
- if(item->type!=type_waypoint && item->type!=type_route_end)
- continue;
- if (item_attr_get(item, attr_label, &attr)) {
- text=g_strdup_printf(_("Waypoint %s"), map_convert_string_tmp(item->map, attr.u.str));
- } else
- continue;
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- cmd, data));
- wc->item=*item;
- if(wm_)
- wc->c=wm_->c;
- else {
- struct coord c;
- item_coord_get(item,&c,1);
- wc->c.x=c.x;
- wc->c.y=c.y;
- wc->c.pro=map_projection(item->map);
- }
- i++;
- wc->datai=dstcount-i;
- g_free(text);
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_insert_destination(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_select_waypoint(this, data, _("Select waypoint to insert the new one before"), wm, gui_internal_cmd_insert_destination_do, data);
-}
-
-
-
-static void
-gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr v;
- if(data) {
- v.type=attr_vehicle;
- v.u.vehicle=NULL;
- navit_set_attr(this->nav, &v);
- }
- navit_set_position(this->nav, &wm->c);
- gui_internal_prune_menu(this, NULL);
+void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_,
+ void(*cmd)(struct gui_priv *priv, struct widget *widget, void *data),void *data) {
+ struct widget *wb,*w,*wtable,*row,*wc;
+ struct map *map;
+ struct map_rect *mr;
+ struct item *item;
+ char *text;
+ int i;
+ int dstcount=navit_get_destination_count(this->nav)+1;
+
+ map=route_get_map(navit_get_route(this->nav));
+ if(!map)
+ return;
+ mr = map_rect_new(map, NULL);
+ if(!mr)
+ return;
+
+ wb=gui_internal_menu(this, title);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ if(hint)
+ gui_internal_widget_append(w, gui_internal_label_new(this, hint));
+ wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(w,wtable);
+
+ i=0;
+ while((item = map_rect_get_item(mr))!=NULL) {
+ struct attr attr;
+ if(item->type!=type_waypoint && item->type!=type_route_end)
+ continue;
+ if (item_attr_get(item, attr_label, &attr)) {
+ text=g_strdup_printf(_("Waypoint %s"), map_convert_string_tmp(item->map, attr.u.str));
+ } else
+ continue;
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row, wc=gui_internal_button_new_with_callback(this, text,
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ cmd, data));
+ wc->item=*item;
+ if(wm_)
+ wc->c=wm_->c;
+ else {
+ struct coord c;
+ item_coord_get(item,&c,1);
+ wc->c.x=c.x;
+ wc->c.y=c.y;
+ wc->c.pro=map_projection(item->map);
+ }
+ i++;
+ wc->datai=dstcount-i;
+ g_free(text);
+ }
+ map_rect_destroy(mr);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_insert_destination(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_select_waypoint(this, data, _("Select waypoint to insert the new one before"), wm,
+ gui_internal_cmd_insert_destination_do, data);
+}
+
+
+
+static void gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr v;
+ if(data) {
+ v.type=attr_vehicle;
+ v.u.vehicle=NULL;
+ navit_set_attr(this->nav, &v);
+ }
+ navit_set_position(this->nav, &wm->c);
+ gui_internal_prune_menu(this, NULL);
}
@@ -731,14 +684,12 @@ gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *da
* @brief Generic notification function for Editable widgets to call Another widget notification function when Enter is pressed in editable field.
* The Editable widget should have data member pointing to the Another widget.
*/
-void
-gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->reason==gui_internal_reason_keypress_finish && data) {
- struct widget *w=data;
- if(w->func)
- w->func(this, w, w->data);
- }
+void gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data) {
+ if (wm->reason==gui_internal_reason_keypress_finish && data) {
+ struct widget *w=data;
+ if(w->func)
+ w->func(this, w, w->data);
+ }
}
struct widget * gui_internal_keyboard(struct gui_priv *this, int mode);
@@ -747,345 +698,313 @@ struct widget * gui_internal_keyboard(struct gui_priv *this, int mode);
struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang);
-static void
-gui_internal_cmd_delete_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_delete_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_delete_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_delete_bookmark(mattr.u.bookmarks,wm->text);
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
/**
- * Get a utf-8 string, return the same prepared for case insensitive search. Result should be g_free()d after use.
+ * @brief Remove the case in a string
+ *
+ * @warning Result should be g_free()d after use.
+ *
+ * @param s The input utf-8 string
+ * @return An equivalent string prepared for case insensitive search
+ */
+char *removecase(char *s) {
+ char *r;
+ r=linguistics_casefold(s);
+ return r;
+}
+
+/**
+ * @brief Apply the command "View on Map", centers the map on the selected point and highlight this point using
+ * type_found_item style
+ *
+ * @param this The GUI context
+ * @param wm The widget that points to this function as a callback
+ * @param data Private data provided during callback (unused)
*/
-char *
-removecase(char *s)
-{
- char *r;
- r=linguistics_casefold(s);
- return r;
-}
-
-static void
-gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->item.type != type_none) {
- enum item_type type;
- if (wm->item.type < type_line)
- type=type_selected_point;
- else if (wm->item.type < type_area)
- type=type_selected_point;
- else
- type=type_selected_area;
- graphics_clear_selection(this->gra, NULL);
- graphics_add_selection(this->gra, &wm->item, type, NULL);
- }
- navit_set_center(this->nav, &wm->c, 1);
- gui_internal_prune_menu(this, NULL);
-}
-
-
-static void
-gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *text,*url;
- int i;
-
- text=g_strdup_printf("Attribute %s",wm->name);
- wb=gui_internal_menu(this, text);
- g_free(text);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- for (i = 0 ; i < wm->datai ; i++) {
- item_attr_get(item, attr_any, &attr);
- }
- if (item_attr_get(item, attr_any, &attr)) {
- url=NULL;
- switch (attr.type) {
- case attr_osm_nodeid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/node/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- case attr_osm_wayid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/way/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- case attr_osm_relationid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- default:
- break;
- }
- if (url) {
- gui_internal_widget_append(w,
- wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_in_browser, NULL));
- wb->name=url;
- }
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_view_attributes(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *text;
- int count=0;
-
- dbg(lvl_info,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
- wb=gui_internal_menu(this, "Attributes");
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- dbg(lvl_info,"item=%p\n", item);
- if (item) {
- text=g_strdup_printf("%s:%s", _("Item type"), item_to_name(item->type));
- gui_internal_widget_append(w,
- wb=gui_internal_button_new(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill));
- wb->name=g_strdup(text);
- wb->item=wm->item;
- g_free(text);
- while(item_attr_get(item, attr_any, &attr)) {
- char *attrtxt;
- text=g_strdup_printf("%s:%s", attr_to_name(attr.type), attrtxt=attr_to_text(&attr, wm->item.map, 1));
- g_free(attrtxt);
- gui_internal_widget_append(w,
- wb=gui_internal_button_new_with_callback(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_attribute_details, NULL));
- wb->name=g_strdup(text);
- wb->item=wm->item;
- wb->datai=count++;
- g_free(text);
- }
- text=g_strdup_printf("%s:0x%x,0x%x", "ID", item->id_hi, item->id_lo);
- gui_internal_widget_append(w,
- wb=gui_internal_button_new(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill));
- wb->name=text;
- wb->item=wm->item;
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *cmd=NULL;
-
- if (!wm->name) {
- dbg(lvl_info,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- dbg(lvl_info,"item=%p\n", item);
- if (item) {
- while(item_attr_get(item, attr_url_local, &attr)) {
- if (! cmd)
- cmd=g_strdup_printf("navit-browser.sh '%s' &",map_convert_string_tmp(item->map,attr.u.str));
- }
- }
- map_rect_destroy(mr);
- } else {
- cmd=g_strdup_printf("navit-browser.sh '%s' &",wm->name);
- }
- if (cmd) {
+static void gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data) {
+
+ struct widget *w;
+ struct widget *wr;
+ struct widget *wi;
+ char *label;
+
+ if (wm->item.type != type_none) {
+ enum item_type type;
+ if (wm->item.type < type_line)
+ type=type_selected_point;
+ else if (wm->item.type < type_area)
+ type=type_selected_point;
+ else
+ type=type_selected_area;
+ graphics_clear_selection(this->gra, NULL);
+ graphics_add_selection(this->gra, &wm->item, type, NULL);
+ } else {
+ if (wm->item.priv_data)
+ label = wm->item.priv_data; /* Use the label of the point to view on map */
+ else
+ label = g_strdup("");
+ w = gui_internal_widget_table_new(this, 0, 0); /* Create a basic table */
+ gui_internal_widget_append(w,wr=gui_internal_widget_table_row_new(this,0)); /* In this table, add one row */
+ gui_internal_widget_append(wr,wi=gui_internal_box_new_with_label(this,0,
+ label)); /* That row contains a widget of type widget_box */
+ wi->name = label; /* Use the label of the point to view on map */
+ wi->c.x=wm->c.x; /* Use the coordinates of the point to place it on the map */
+ wi->c.y=wm->c.y;
+ gui_internal_prepare_search_results_map(this, w, NULL);
+ g_free(label);
+ wi->name = NULL;
+ gui_internal_widget_destroy(this, w);
+ }
+ navit_set_center(this->nav, &wm->c, 1);
+ gui_internal_prune_menu(this, NULL);
+}
+
+
+static void gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb;
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ char *text,*url;
+ int i;
+
+ text=g_strdup_printf("Attribute %s",wm->name);
+ wb=gui_internal_menu(this, text);
+ g_free(text);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ for (i = 0 ; i < wm->datai ; i++) {
+ item_attr_get(item, attr_any, &attr);
+ }
+ if (item_attr_get(item, attr_any, &attr)) {
+ url=NULL;
+ switch (attr.type) {
+ case attr_osm_nodeid:
+ url=g_strdup_printf("http://www.openstreetmap.org/browse/node/"LONGLONG_FMT"\n",*attr.u.num64);
+ break;
+ case attr_osm_wayid:
+ url=g_strdup_printf("http://www.openstreetmap.org/browse/way/"LONGLONG_FMT"\n",*attr.u.num64);
+ break;
+ case attr_osm_relationid:
+ url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/"LONGLONG_FMT"\n",*attr.u.num64);
+ break;
+ default:
+ break;
+ }
+ if (url) {
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_in_browser, NULL));
+ wb->name=url;
+ }
+ }
+ map_rect_destroy(mr);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_view_attributes(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb;
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ char *text;
+ int count=0;
+
+ dbg(lvl_info,"item=%p 0x%x 0x%x", wm->item.map,wm->item.id_hi, wm->item.id_lo);
+ wb=gui_internal_menu(this, "Attributes");
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ dbg(lvl_info,"item=%p", item);
+ if (item) {
+ text=g_strdup_printf("%s:%s", _("Item type"), item_to_name(item->type));
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new(this, text,
+ NULL, gravity_left_center|orientation_horizontal|flags_fill));
+ wb->name=g_strdup(text);
+ wb->item=wm->item;
+ g_free(text);
+ while(item_attr_get(item, attr_any, &attr)) {
+ char *attrtxt;
+ text=g_strdup_printf("%s:%s", attr_to_name(attr.type), attrtxt=attr_to_text(&attr, wm->item.map, 1));
+ g_free(attrtxt);
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new_with_callback(this, text,
+ NULL, gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_attribute_details, NULL));
+ wb->name=g_strdup(text);
+ wb->item=wm->item;
+ wb->datai=count++;
+ g_free(text);
+ }
+ text=g_strdup_printf("%s:0x%x,0x%x", "ID", item->id_hi, item->id_lo);
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new(this, text,
+ NULL, gravity_left_center|orientation_horizontal|flags_fill));
+ wb->name=text;
+ wb->item=wm->item;
+ }
+ map_rect_destroy(mr);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data) {
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ char *cmd=NULL;
+
+ if (!wm->name) {
+ dbg(lvl_info,"item=%p 0x%x 0x%x", wm->item.map,wm->item.id_hi, wm->item.id_lo);
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ dbg(lvl_info,"item=%p", item);
+ if (item) {
+ while(item_attr_get(item, attr_url_local, &attr)) {
+ if (! cmd)
+ cmd=g_strdup_printf("navit-browser.sh '%s' &",map_convert_string_tmp(item->map,attr.u.str));
+ }
+ }
+ map_rect_destroy(mr);
+ } else {
+ cmd=g_strdup_printf("navit-browser.sh '%s' &",wm->name);
+ }
+ if (cmd) {
#ifdef HAVE_SYSTEM
- system(cmd);
+ system(cmd);
#else
- dbg(lvl_error,"Error: External commands were disabled during compilation, cannot call '%s'.\n",cmd);
+ dbg(lvl_error,"Error: External commands were disabled during compilation, cannot call '%s'.",cmd);
#endif
- g_free(cmd);
- }
+ g_free(cmd);
+ }
}
+/**
+ * @brief Create a map rect highlighting one of multiple points provided in argument @data and displayed using
+ * the style type_found_item (name for each point will also be displayed aside)
+ *
+ * @param this The GUI context
+ * @param table A table widget or any of its descendants. The table contain results to place on the map.
+ * Providing NULL here will remove all previous results from the map.
+ * @param[out] r The minimum rect focused to contain all results placed on the map (or unchanged if r==NULL)
+ */
+static void gui_internal_prepare_search_results_map(struct gui_priv *this, struct widget *table, struct coord_rect *r) {
+ struct widget *w;
+ GList *l; /* Cursor in the list of widgets */
+ GList* list = NULL; /* List we will create to store the points to add to the result map */
+ struct attr a;
+ GList* p;
+
+ this->results_map_population=0;
+
+ /* Find the table to populate the map */
+ for(w=table; w && w->type!=widget_table; w=w->parent);
+
+ if(!w) {
+ dbg(lvl_warning,"Can't find the results table - only map clean up is done.");
+ } else {
+ /* Create a GList containing all search results */
+ for(l=w->children; l; l=g_list_next(l)) {
+ struct widget *wr=l->data;
+ if(wr->type==widget_table_row) {
+ struct widget *wi=wr->children->data;
+ if(wi->name==NULL)
+ continue;
+ struct lcoord *result = g_new0(struct lcoord, 1);
+ result->c.x=wi->c.x;
+ result->c.y=wi->c.y;
+ result->label=g_strdup(wi->name);
+ list = g_list_prepend(list, result);
+ }
+ }
+ }
+ this->results_map_population=navit_populate_search_results_map(this->nav, list, r);
+ /* Parse the GList starting at list and free all payloads before freeing the list itself */
+ if (list) {
+ for(p=list; p; p=g_list_next(p)) {
+ if (((struct lcoord *)(p->data))->label)
+ g_free(((struct lcoord *)(p->data))->label);
+ }
+ }
+ g_list_free(list);
+ if(!this->results_map_population)
+ return;
+ a.type=attr_orientation;
+ a.u.num=0;
+ navit_set_attr(this->nav,&a); /* Set orientation to North */
+ if (r) {
+ navit_zoom_to_rect(this->nav,r);
+ gui_internal_prune_menu(this, NULL);
+ }
+}
-/*
- * @brief Transfers search results to a map.
+/**
+ * @brief Apply the command "Show results on the map", highlighting one of multiple points using
+ * type_found_item style (with their respective name placed aside)
*
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data (pointer to the table widget containing results, or NULL to clean the result map without adding any new data).
+ * @param this The GUI context
+ * @param wm The widget that called us
+ * @param data Private data provided during callback (should be a pointer to the table widget containing results,
+ * or NULL to remove all previous results from the map).
*/
-static void
-gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w;
- struct mapset *ms;
- struct map *map;
- struct map_rect *mr;
- struct item *item;
- GList *l;
- struct coord_rect r;
- struct attr a;
- int count;
-
- ms=navit_get_mapset(this->nav);
-
- if(!ms)
- return;
-
- map=mapset_get_map_by_name(ms, "search_results");
- if(!map) {
- struct attr *attrs[10], attrmap;
- enum attr_type types[]={attr_position_longitude,attr_position_latitude,attr_label,attr_none};
- int i;
-
- attrs[0]=g_new0(struct attr,1);
- attrs[0]->type=attr_type;
- attrs[0]->u.str="csv";
-
- attrs[1]=g_new0(struct attr,1);
- attrs[1]->type=attr_name;
- attrs[1]->u.str="search_results";
-
- attrs[2]=g_new0(struct attr,1);
- attrs[2]->type=attr_charset;
- attrs[2]->u.str="utf-8";
-
- attrs[3]=g_new0(struct attr,1);
- attrs[3]->type=attr_item_type;
- attrs[3]->u.num=type_found_item;
-
- attrs[4]=g_new0(struct attr,1);
- attrs[4]->type=attr_attr_types;
- attrs[4]->u.attr_types=types;
- attrs[5]=NULL;
-
- attrmap.type=attr_map;
- map=attrmap.u.map=map_new(NULL,attrs);
- if(map)
- mapset_add_attr(ms,&attrmap);
-
- for(i=0;attrs[i];i++)
- g_free(attrs[i]);
-
- }
-
- if(!map)
- return;
-
-
- mr = map_rect_new(map, NULL);
-
- if(!mr)
- return;
-
- /* Clean the map */
- while((item = map_rect_get_item(mr))!=NULL) {
- item_type_set(item,type_none);
- }
-
- this->results_map_population=0;
-
- /* Find the table to pupulate the map */
- for(w=data; w && w->type!=widget_table;w=w->parent);
-
- if(!w) {
- map_rect_destroy(mr);
- dbg(lvl_warning,"Can't find the results table - only map clean up is done.\n");
- return;
- }
-
- /* Populate the map with search results*/
- for(l=w->children, count=0;l;l=g_list_next(l)) {
- struct widget *wr=l->data;
- if(wr->type==widget_table_row) {
- struct widget *wi=wr->children->data;
- struct item* it;
- if(wi->name==NULL)
- continue;
- dbg(lvl_info,"%s\n",wi->name);
- it=map_rect_create_item(mr,type_found_item);
- if(it) {
- struct coord c;
- struct attr a;
- c.x=wi->c.x;
- c.y=wi->c.y;
- item_coord_set(it, &c, 1, change_mode_modify);
- a.type=attr_label;
- a.u.str=wi->name;
- item_attr_set(it, &a, change_mode_modify);
- if(!count++)
- r.lu=r.rl=c;
- else
- coord_rect_extend(&r,&c);
- }
- }
- }
- map_rect_destroy(mr);
- if(!count)
- return;
- a.type=attr_orientation;
- a.u.num=0;
- navit_set_attr(this->nav,&a);
- navit_zoom_to_rect(this->nav,&r);
- gui_internal_prune_menu(this, NULL);
- this->results_map_population=count;
+static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data) {
+ struct coord_rect r;
+
+ gui_internal_prepare_search_results_map(this, (struct widget *)data, &r);
}
/*
- * @brief Removes search results from a map.
+ * @brief Removes all existing search results from a map.
*
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data
+ * @param this The GUI context
+ * @param wm The widget that called us
+ * @param data Private data (unused).
*/
-static void
-gui_internal_cmd_results_map_clean(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_cmd_results_to_map(this,wm,NULL);
- gui_internal_prune_menu(this, NULL);
- navit_draw(this->nav);
-}
-
-static void
-gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void *data)
-{
- int dstcount=navit_get_destination_count(this->nav);
- int i;
- struct map_rect *mr;
- struct item *item;
- struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
- dstcount=navit_get_destinations(this->nav,dst,dstcount);
- mr=map_rect_new(wm->item.map, NULL);
- i=0;
- while((item=map_rect_get_item(mr))!=NULL) {
- struct coord c;
- if(item->type!=type_waypoint && item->type!=type_route_end)
- continue;
- if(item_is_equal_id(*item,wm->item))
- continue;
- item_coord_get_pro(item,&c,1,projection_mg);
- dst[i].x=c.x;
- dst[i].y=c.y;
- dst[i].pro=projection_mg;
- i++;
- }
- map_rect_destroy(mr);
- navit_set_destinations(this->nav,dst,i,NULL,1);
- gui_internal_prune_menu(this, NULL);
+static void gui_internal_cmd_results_map_clean(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_cmd_results_to_map(this,wm,NULL);
+ gui_internal_prune_menu(this, NULL);
+ navit_draw(this->nav);
+}
+
+static void gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void *data) {
+ int dstcount=navit_get_destination_count(this->nav);
+ int i;
+ struct map_rect *mr;
+ struct item *item;
+ struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
+ dstcount=navit_get_destinations(this->nav,dst,dstcount);
+ mr=map_rect_new(wm->item.map, NULL);
+ i=0;
+ while((item=map_rect_get_item(mr))!=NULL) {
+ struct coord c;
+ if(item->type!=type_waypoint && item->type!=type_route_end)
+ continue;
+ if(item_is_equal_id(*item,wm->item))
+ continue;
+ item_coord_get_pro(item,&c,1,projection_mg);
+ dst[i].x=c.x;
+ dst[i].y=c.y;
+ dst[i].pro=projection_mg;
+ i++;
+ }
+ map_rect_destroy(mr);
+ navit_set_destinations(this->nav,dst,i,NULL,1);
+ gui_internal_prune_menu(this, NULL);
}
@@ -1097,10 +1016,10 @@ gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void
* argument or in WGS84 coordinates (i.e. latitude and longitude in degrees) via the {@code g_in}
* argument. One of these must be supplied, the other should be {@code NULL}.
*
- * @param this The internal GUI instance
+ * @param this The GUI context
* @param pc_in Projected coordinates of the position
* @param g_in WGS84 coordinates of the position
- * @param wm
+ * @param wm The widget that points to this function as a callback
* @param name The display name for the position
* @param flags Flags specifying the operations available from the GUI
*/
@@ -1119,275 +1038,296 @@ gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void
* 2048: "Show search results on the map"
* TODO define constants for these values
*/
-void
-gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in, struct widget *wm, const char *name, int flags)
-{
- struct widget *wb,*w,*wtable,*row,*wc,*wbc,*wclosest=NULL;
- struct coord_geo g;
- struct pcoord pc;
- struct coord c;
- char *coord;
-
- if (pc_in) {
- pc=*pc_in;
- c.x=pc.x;
- c.y=pc.y;
- dbg(lvl_info,"x=0x%x y=0x%x\n", c.x, c.y);
- transform_to_geo(pc.pro, &c, &g);
- } else if (g_in) {
- struct attr attr;
- if (!navit_get_attr(this->nav, attr_projection, &attr, NULL))
- return;
- g=*g_in;
- pc.pro=attr.u.projection;
- transform_from_geo(pc.pro, &g, &c);
- pc.x=c.x;
- pc.y=c.y;
- } else
- return;
-
- wb=gui_internal_menu(this, name);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- coord=gui_internal_coordinates(&pc, ' ');
- gui_internal_widget_append(w, gui_internal_label_new(this, coord));
- g_free(coord);
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,wtable);
-
- if ((flags & 1) && wm) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wc=gui_internal_button_new_with_callback(this, _("Streets"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_search_street_in_town, wm));
- wc->item=wm->item;
- wc->selection_id=wm->selection_id;
- }
- if ((flags & 2) && wm) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wc=gui_internal_button_new_with_callback(this, _("House numbers"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_search_house_number_in_street, wm));
- wc->item=wm->item;
- wc->selection_id=wm->selection_id;
- }
- if ((flags & 4) && wm) {
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- if (item) {
- if (item_attr_get(item, attr_description, &attr))
- gui_internal_widget_append(w, gui_internal_label_new(this, map_convert_string_tmp(item->map,attr.u.str)));
- if (item_attr_get(item, attr_url_local, &attr)) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_in_browser, NULL));
- wb->item=wm->item;
- }
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wb=gui_internal_button_new_with_callback(this, _("View Attributes"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_attributes, NULL));
- wb->item=wm->item;
- }
- map_rect_destroy(mr);
- }
- if (flags & 8) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Set as destination"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_destination, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- if(navit_get_destination_count(this->nav)>=1) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Visit before..."),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_insert_destination, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- }
- }
- if (flags & 16) {
- const char *text;
- struct attr vehicle, source;
- int deactivate=0;
- if (navit_get_attr(this->nav, attr_vehicle, &vehicle, NULL) && vehicle.u.vehicle &&
- !(vehicle_get_attr(vehicle.u.vehicle, attr_source, &source, NULL) && source.u.str && !strcmp("demo://",source.u.str)))
- deactivate=1;
-
- text=deactivate? _("Set as position (and deactivate vehicle)") : _("Set as position");
-
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_position, (void*)(long)deactivate));
- wbc->c=pc;
- }
- if (flags & 32) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Add as bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_add_bookmark2, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- }
+void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in,
+ struct widget *wm, const char *name, int flags) {
+ struct widget *wb,*w,*wtable,*row,*wc,*wbc,*wclosest=NULL;
+ struct coord_geo g;
+ struct pcoord pc;
+ struct coord c;
+ char *coord;
+
+ if (pc_in) {
+ pc=*pc_in;
+ c.x=pc.x;
+ c.y=pc.y;
+ dbg(lvl_info,"x=0x%x y=0x%x", c.x, c.y);
+ transform_to_geo(pc.pro, &c, &g);
+ } else if (g_in) {
+ struct attr attr;
+ if (!navit_get_attr(this->nav, attr_projection, &attr, NULL))
+ return;
+ g=*g_in;
+ pc.pro=attr.u.projection;
+ transform_from_geo(pc.pro, &g, &c);
+ pc.x=c.x;
+ pc.y=c.y;
+ } else
+ return;
+
+ wb=gui_internal_menu(this, name);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ coord=gui_internal_coordinates(&pc, ' ');
+ gui_internal_widget_append(w, gui_internal_label_new(this, coord));
+ g_free(coord);
+ wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(w,wtable);
+
+ if ((flags & 1) && wm) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wc=gui_internal_button_new_with_callback(this, _("Streets"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_search_street_in_town, wm));
+ wc->item=wm->item;
+ wc->selection_id=wm->selection_id;
+ }
+ if ((flags & 2) && wm) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wc=gui_internal_button_new_with_callback(this, _("House numbers"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_search_house_number_in_street, wm));
+ wc->item=wm->item;
+ wc->selection_id=wm->selection_id;
+ }
+ if ((flags & 4) && wm) {
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ if (item) {
+ if (item_attr_get(item, attr_description, &attr))
+ gui_internal_widget_append(w, gui_internal_label_new(this, map_convert_string_tmp(item->map,attr.u.str)));
+ if (item_attr_get(item, attr_url_local, &attr)) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_in_browser, NULL));
+ wb->item=wm->item;
+ }
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wb=gui_internal_button_new_with_callback(this, _("View Attributes"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_attributes, NULL));
+ wb->item=wm->item;
+ }
+ map_rect_destroy(mr);
+ }
+ if (flags & 8) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Set as destination"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_destination, g_strdup(name)));
+ wbc->data_free=g_free_func;
+ wbc->c=pc;
+ if(navit_get_destination_count(this->nav)>=1) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Visit before..."),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_insert_destination, g_strdup(name)));
+ wbc->data_free=g_free_func;
+ wbc->c=pc;
+ }
+ }
+ if (flags & 16) {
+ const char *text;
+ struct attr vehicle, source;
+ int deactivate=0;
+ if (navit_get_attr(this->nav, attr_vehicle, &vehicle, NULL) && vehicle.u.vehicle &&
+ !(vehicle_get_attr(vehicle.u.vehicle, attr_source, &source, NULL) && source.u.str && !strcmp("demo://",source.u.str)))
+ deactivate=1;
+
+ text=deactivate? _("Set as position (and deactivate vehicle)") : _("Set as position");
+
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, text,
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_position, (void*)(long)deactivate));
+ wbc->c=pc;
+ }
+ if (flags & 32) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Add as bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_add_bookmark2, g_strdup(name)));
+ wbc->data_free=g_free_func;
+ wbc->c=pc;
+ }
#ifndef _MSC_VER
//POIs are not operational under MSVC yet
- if (flags & 64) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("POIs"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_pois, NULL));
- wbc->c=pc;
- }
+ if (flags & 64) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("POIs"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_pois, NULL));
+ wbc->c=pc;
+ }
#endif /* _MSC_VER */
#if 0
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new(this, "Add to tour",
- image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new(this, "Add to tour",
+ image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
#endif
- if (flags & 128) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("View on map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_on_map, NULL));
- wbc->c=pc;
- if ((flags & 4) && wm)
- wbc->item=wm->item;
- else
- wbc->item.type=type_none;
- }
- if(flags & 256 && this->results_map_population) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Remove search results from the map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_results_map_clean, NULL));
- wbc->data=wm;
- }
- if(flags & 2048) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Show results on the map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_results_to_map, NULL));
- wbc->data=wm;
- }
- if ((flags & 256) || (flags & 1024)) {
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct attr attr;
- struct point p;
- struct transformation *trans;
-
- char *text;
- struct map_selection *sel;
- GList *l, *ll;
-
- c.x=pc.x;
- c.y=pc.y;
-
- trans=navit_get_trans(this->nav);
- transform(trans,pc.pro,&c,&p,1,0,0,0);
- display=navit_get_displaylist(this->nav);
- dlh=graphics_displaylist_open(display);
- sel=displaylist_get_selection(display);
- l=displaylist_get_clicked_list(display, &p, this->radius);
- for(ll=l;ll;ll=g_list_next(ll)) {
- struct displayitem *di;
- struct item *item;
- struct map_rect *mr;
- struct item *itemo;
-
- di=(struct displayitem*)ll->data;
- item=graphics_displayitem_get_item(di);
-
- mr=map_rect_new(item->map, sel);
- itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if(!itemo) {
- map_rect_destroy(mr);
- continue;
- }
- if (item_attr_get(itemo, attr_label, &attr)) {
- text=g_strdup(map_convert_string_tmp(itemo->map, attr.u.str));
- } else
- text=g_strdup(item_to_name(item->type));
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wc=gui_internal_cmd_pois_item(this, NULL, itemo, NULL, NULL, -1, text));
- wc->c=pc;
- g_free(wc->name);
- wc->name=g_strdup(text);
- wc->item=*itemo;
- g_free(text);
- map_rect_destroy(mr);
- if(!wclosest)
- wclosest=wc;
-
- }
- g_list_free(l);
- map_selection_destroy(sel);
- graphics_displaylist_close(dlh);
- }
- if (flags & 512) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Cut Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_cut_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Copy Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_copy_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Rename Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_rename_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Paste Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_paste_bookmark, NULL));
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Delete Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- }
-
- if (wm && (wm->item.type==type_waypoint || wm->item.type==type_route_end)) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Delete waypoint"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_waypoint, NULL));
- wbc->item=wm->item;
- }
-
- gui_internal_menu_render(this);
-
- if((flags & 1024) && wclosest)
- gui_internal_cmd_view_attributes(this,wclosest,wclosest->data);
+ if (flags & 128) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("View on map"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_on_map, NULL));
+ wbc->c=pc;
+ if ((flags & 4) && wm) {
+ wbc->item=wm->item;
+ } else {
+ wbc->item.type=type_none;
+ wbc->item.priv_data = g_strdup(name); /* Will be freed up by gui_internal_cmd_view_on_map() */
+ }
+ }
+ if(flags & 256 && this->results_map_population) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Remove search results from the map"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_results_map_clean, NULL));
+ wbc->data=wm;
+ }
+ if(flags & 2048) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Show results on the map"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_results_to_map, NULL));
+ wbc->data=wm;
+ }
+ if ((flags & 256) || (flags & 1024)) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct attr attr;
+ struct point p;
+ struct transformation *trans;
+
+ char *text;
+ struct map_selection *sel;
+ GList *l, *ll;
+
+ c.x=pc.x;
+ c.y=pc.y;
+
+ trans=navit_get_trans(this->nav);
+ transform(trans,pc.pro,&c,&p,1,0,0,0);
+ display=navit_get_displaylist(this->nav);
+ dlh=graphics_displaylist_open(display);
+ sel=displaylist_get_selection(display);
+ l=displaylist_get_clicked_list(display, &p, this->radius);
+ for(ll=l; ll; ll=g_list_next(ll)) {
+ struct displayitem *di;
+ struct item *item;
+ struct map_rect *mr;
+ struct item *itemo;
+
+ di=(struct displayitem*)ll->data;
+ item=graphics_displayitem_get_item(di);
+
+ mr=map_rect_new(item->map, sel);
+ itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ if(!itemo) {
+ map_rect_destroy(mr);
+ continue;
+ }
+ if (item_attr_get(itemo, attr_label, &attr)) {
+ text=g_strdup(map_convert_string_tmp(itemo->map, attr.u.str));
+ } else
+ text=g_strdup(item_to_name(item->type));
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row, wc=gui_internal_cmd_pois_item(this, NULL, itemo, NULL, NULL, -1, text));
+ wc->c=pc;
+ g_free(wc->name);
+ wc->name=g_strdup(text);
+ wc->item=*itemo;
+ g_free(text);
+ map_rect_destroy(mr);
+ if(!wclosest)
+ wclosest=wc;
+
+ }
+ g_list_free(l);
+ map_selection_destroy(sel);
+ graphics_displaylist_close(dlh);
+ }
+ if (flags & 512) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Cut Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_cut_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Copy Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_copy_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Rename Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_rename_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Paste Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_paste_bookmark, NULL));
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Delete Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_delete_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ }
+
+ if (wm && (wm->item.type==type_waypoint || wm->item.type==type_route_end)) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Delete waypoint"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_delete_waypoint, NULL));
+ wbc->item=wm->item;
+ }
+
+ gui_internal_menu_render(this);
+
+ if((flags & 1024) && wclosest)
+ gui_internal_cmd_view_attributes(this,wclosest,wclosest->data);
}
@@ -1403,60 +1343,58 @@ gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct
9 Item from the POI list
*/
-void
-gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data)
-{
- int flags;
-
- if(!data)
- data=wm->data;
-
- switch ((long) data) {
- case 0:
- flags=8|16|32|64|128|256;
- break;
- case 1:
- flags=8|16|32|64|256;
- break;
- case 2:
- flags=4|8|16|32|64|128;
- break;
- case 3:
- flags=1|4|8|16|32|64|128|2048;
- flags &= this->flags_town;
- break;
- case 4:
- gui_internal_search_town_in_country(this, wm);
- return;
- case 5:
- flags=2|8|16|32|64|128|2048;
- flags &= this->flags_street;
- break;
- case 6:
- flags=8|16|32|64|128|2048;
- flags &= this->flags_house_number;
- break;
- case 7:
- flags=8|16|64|128|512;
- break;
- case 8:
- flags=8|16|32|64|128;
- break;
- case 9:
- flags=4|8|16|32|64|128|2048;
- break;
- default:
- return;
- }
- switch (flags) {
- case 2:
- gui_internal_search_house_number_in_street(this, wm, NULL);
- return;
- case 8:
- gui_internal_cmd_set_destination(this, wm, NULL);
- return;
- }
- gui_internal_cmd_position_do(this, &wm->c, NULL, wm, wm->name ? wm->name : wm->text, flags);
+void gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data) {
+ int flags;
+
+ if(!data)
+ data=wm->data;
+
+ switch ((long) data) {
+ case 0:
+ flags=8|16|32|64|128|256;
+ break;
+ case 1:
+ flags=8|16|32|64|256;
+ break;
+ case 2:
+ flags=4|8|16|32|64|128;
+ break;
+ case 3:
+ flags=1|4|8|16|32|64|128|2048;
+ flags &= this->flags_town;
+ break;
+ case 4:
+ gui_internal_search_town_in_country(this, wm);
+ return;
+ case 5:
+ flags=2|8|16|32|64|128|2048;
+ flags &= this->flags_street;
+ break;
+ case 6:
+ flags=8|16|32|64|128|2048;
+ flags &= this->flags_house_number;
+ break;
+ case 7:
+ flags=8|16|64|128|512;
+ break;
+ case 8:
+ flags=8|16|32|64|128;
+ break;
+ case 9:
+ flags=4|8|16|32|64|128|2048;
+ break;
+ default:
+ return;
+ }
+ switch (flags) {
+ case 2:
+ gui_internal_search_house_number_in_street(this, wm, NULL);
+ return;
+ case 8:
+ gui_internal_cmd_set_destination(this, wm, NULL);
+ return;
+ }
+ gui_internal_cmd_position_do(this, &wm->c, NULL, wm, wm->name ? wm->name : wm->text, flags);
}
@@ -1465,515 +1403,490 @@ gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data)
/**
* The "Bookmarks" section of the OSD
- *
+ *
*/
-void
-gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr attr,mattr;
- struct item *item;
- char *label_full,*prefix=0;
- int plen=0,hassub,found=0;
- struct widget *wb,*w,*wbm;
- struct coord c;
- struct widget *tbl, *row;
-
- if (data)
- prefix=g_strdup(data);
- else {
- if (wm && wm->prefix)
- prefix=g_strdup(wm->prefix);
- }
- if ( prefix )
- plen=strlen(prefix);
-
- gui_internal_prune_menu_count(this, 1, 0);
- wb=gui_internal_menu(this, _("Bookmarks"));
- wb->background=this->background;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- //w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- if (!plen) {
- bookmarks_move_root(mattr.u.bookmarks);
- } else {
- if (!strcmp(prefix,"..")) {
- bookmarks_move_up(mattr.u.bookmarks);
- g_free(prefix);
- prefix=g_strdup(bookmarks_item_cwd(mattr.u.bookmarks));
- if (prefix) {
- plen=strlen(prefix);
- } else {
- plen=0;
- }
- } else {
- bookmarks_move_down(mattr.u.bookmarks,prefix);
- }
-
- // "Back" button, when inside a bookmark folder
-
- if (plen) {
- wbm=gui_internal_button_new_with_callback(this, "..",
- image_new_xs(this, "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_bookmarks, NULL);
- wbm->prefix=g_strdup("..");
- gui_internal_widget_append(w, wbm);
-
- // load bookmark folder as Waypoints, if any
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks) > 0){
- wbm=gui_internal_button_new_with_callback(this, _("Bookmarks as waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_load_bookmarks_as_waypoints, NULL);
- wbm->prefix=g_strdup(prefix);
- gui_internal_widget_append(w, wbm);
- }
-
- // save Waypoints in bookmark folder, if route exists
- if (navit_get_destination_count(this->nav) > 0){
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0){
- wbm=gui_internal_button_new_with_callback(this, _("Save waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
- }else{
- wbm=gui_internal_button_new_with_callback(this, _("Replace with waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
- }
- wbm->prefix=g_strdup(prefix);
- gui_internal_widget_append(w, wbm);
- }
-
- // delete empty folder
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0){
- gui_internal_widget_append(w,
- wbm=gui_internal_button_new_with_callback(this, _("Delete Folder"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_bookmark_folder, NULL));
- wbm->prefix=g_strdup(prefix);
- }
-
- }
- }
-
- // Adds the Bookmark folders
- wbm=gui_internal_button_new_with_callback(this, _("Add Bookmark folder"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_add_bookmark_folder2, NULL);
- gui_internal_widget_append(w, wbm);
-
- // Pastes the Bookmark
- wbm=gui_internal_button_new_with_callback(this, _("Paste bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_paste_bookmark, NULL);
- gui_internal_widget_append(w, wbm);
-
- bookmarks_item_rewind(mattr.u.bookmarks);
-
- tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,tbl);
-
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr)) continue;
- label_full=map_convert_string_tmp(item->map,attr.u.str);
- dbg(lvl_info,"full_labled: %s\n",label_full);
-
- // hassub == 1 if the item type is a sub-folder
- if (item->type == type_bookmark_folder) {
- hassub=1;
- } else {
- hassub=0;
- }
-
- row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_horizontal);
- gui_internal_widget_append(tbl, row);
- wbm=gui_internal_button_new_with_callback(this, label_full,
- image_new_xs(this, hassub ? "gui_inactive" : "gui_active" ), gravity_left_center|orientation_horizontal|flags_fill,
- hassub ? gui_internal_cmd_bookmarks : gui_internal_cmd_position, NULL);
-
- gui_internal_widget_append(row,wbm);
- if (item_coord_get(item, &c, 1)) {
- wbm->c.x=c.x;
- wbm->c.y=c.y;
- wbm->c.pro=bookmarks_get_projection(mattr.u.bookmarks);
- wbm->name=g_strdup_printf(_("Bookmark %s"),label_full);
- wbm->text=g_strdup(label_full);
- if (!hassub) {
- wbm->data=(void*)7;//Mark us as a bookmark
- }
- wbm->prefix=g_strdup(label_full);
- } else {
- gui_internal_widget_destroy(this, row);
- }
- }
- }
-
- g_free(prefix);
-
- if (found)
- gui_internal_check_exit(this);
- else
- gui_internal_menu_render(this);
-}
-
-
-
-
-static void
-gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary);
-
-static int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result);
-
-static int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result);
-
-static struct widget*
-gui_internal_keynav_find_next_sensitive_child(struct widget *wi);
-
-void
-gui_internal_keypress_do(struct gui_priv *this, char *key)
-{
- struct widget *wi,*menu,*search_list;
- int len=0;
- char *text=NULL;
-
- menu=g_list_last(this->root.children)->data;
- wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
- if (wi) {
- /* select first item of the searchlist */
- if (*key == NAVIT_KEY_RETURN) {
- search_list=gui_internal_menu_data(this)->search_list;
- if(search_list) {
- GList *l=gui_internal_widget_table_top_row(this, search_list);
- if (l && l->data) {
- struct widget *w=l->data;
- this->current.x=w->p.x+w->w/2;
- this->current.y=w->p.y+w->h/2;
- gui_internal_highlight(this);
- }
- } else {
- wi->reason=gui_internal_reason_keypress_finish;
- wi->func(this, wi, wi->data);
- }
- return;
- } else if (*key == NAVIT_KEY_BACKSPACE) {
- dbg(lvl_debug,"backspace\n");
- if (wi->text && wi->text[0]) {
- len=g_utf8_prev_char(wi->text+strlen(wi->text))-wi->text;
- wi->text[len]='\0';
- text=g_strdup(wi->text);
- }
- } else {
- if (wi->state & STATE_CLEAR) {
- dbg(lvl_info,"wi->state=0x%x\n", wi->state);
- g_free(wi->text);
- wi->text=NULL;
- wi->state &= ~STATE_CLEAR;
- dbg(lvl_info,"wi->state=0x%x\n", wi->state);
- }
- text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key);
-
- gui_internal_keyboard_to_lower_case(this);
- }
- g_free(wi->text);
- wi->text=text;
-
- if(!wi->text || !*wi->text)
- gui_internal_keyboard_to_upper_case(this);
-
- if (wi->func) {
- wi->reason=gui_internal_reason_keypress;
- wi->func(this, wi, wi->data);
- }
- gui_internal_widget_render(this, wi);
- }
-}
-
-
-
-
-char *
-gui_internal_cmd_match_expand(char *pattern, struct attr **in)
-{
- char p,*ret=g_strdup(pattern),*r=ret,*a;
- int len;
- while ((p=*pattern++)) {
- switch (p) {
- case '*':
- *r='\0';
- a=attr_to_text(*in++,NULL,0);
- len=strlen(ret)+strlen(a)+strlen(pattern)+1;
- r=g_malloc(len);
- strcpy(r, ret);
- strcat(r, a);
- g_free(ret);
- g_free(a);
- ret=r;
- r=ret+strlen(ret);
- break;
- case '\\':
- p=*pattern++;
- default:
- *r++=p;
- }
- }
- *r++='\0';
- return ret;
-}
-
-static int
-gui_internal_match(const char *pattern, const char *string)
-{
- char p,s;
- while ((p=*pattern++)) {
- switch (p) {
- case '*':
- while ((s=*string)) {
- if (gui_internal_match(pattern,string))
- return 1;
- string++;
- }
- break;
- case '\\':
- p=*pattern++;
- default:
- if (*string++ != p)
- return 0;
- }
- }
- return 1;
-}
-
-int
-gui_internal_set(char *remove, char *add)
-{
- char *gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
- char *gui_file_new=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal_new.txt", NULL);
- FILE *fo=fopen(gui_file_new,"w");
- FILE *fi=fopen(gui_file,"r");
- char *line=NULL;
- int ret;
- size_t size=0;
- if (fi != NULL){
- while (getline(&line,&size,fi) > 0) {
- int len=strlen(line);
- if (len > 0 && line[len-1] == '\n')
- line[len-1]='\0';
- dbg(lvl_debug,"line=%s\n",line);
- if (!gui_internal_match(remove, line))
- fprintf(fo,"%s\n",line);
- }
- if (line)
- free(line);
- fclose(fi);
- }
- if (add)
- fprintf(fo,"%s;\n",add);
- fclose(fo);
- unlink(gui_file);
- ret=(rename(gui_file_new, gui_file)==0);
- g_free(gui_file_new);
- g_free(gui_file);
-
- return ret;
-}
-
-
-
-static void
-gui_internal_window_closed(struct gui_priv *this)
-{
- gui_internal_cmd2_quit(this, NULL, NULL, NULL, NULL);
-}
-
-
-static void
-gui_internal_cmd_map_download_do(struct gui_priv *this, struct widget *wm, void *data)
-{
- char *text=g_strdup_printf(_("Download %s"),wm->name);
- struct widget *w, *wb;
- struct map *map=data;
- double bllon,bllat,trlon,trlat;
-
- wb=gui_internal_menu(this, text);
- g_free(text);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (sscanf(wm->prefix,"%lf,%lf,%lf,%lf",&bllon,&bllat,&trlon,&trlat) == 4) {
- struct coord_geo g;
- struct map_selection sel;
- struct map_rect *mr;
- struct item *item;
-
- sel.next=NULL;
- sel.order=255;
- g.lng=bllon;
- g.lat=trlat;
- transform_from_geo(projection_mg, &g, &sel.u.c_rect.lu);
- g.lng=trlon;
- g.lat=bllat;
- transform_from_geo(projection_mg, &g, &sel.u.c_rect.rl);
- sel.range.min=type_none;
- sel.range.max=type_last;
- mr=map_rect_new(map, &sel);
- while ((item=map_rect_get_item(mr))) {
- dbg(lvl_info,"item\n");
- }
- map_rect_destroy(mr);
- }
-
- dbg(lvl_info,"bbox=%s\n",wm->prefix);
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr on, off, download_enabled, download_disabled;
- struct widget *w,*wb,*wma;
- struct map *map=data;
- FILE *f;
- char *search,buffer[256];
- int found,sp_match=0;
-
- dbg(lvl_debug,"wm=%p prefix=%s\n",wm,wm->prefix);
-
- search=wm->prefix;
- if (search) {
- found=0;
- while(search[sp_match] == ' ')
- sp_match++;
- sp_match++;
- } else {
- found=1;
- }
- on.type=off.type=attr_active;
- on.u.num=1;
- off.u.num=0;
- wb=gui_internal_menu(this, wm->name?wm->name:_("Map Download"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (!search) {
- wma=gui_internal_button_map_attr_new(this, _("Active"), gravity_left_center|orientation_horizontal|flags_fill, map, &on, &off, 1);
- gui_internal_widget_append(w, wma);
- }
-
- download_enabled.type=download_disabled.type=attr_update;
- download_enabled.u.num=1;
- download_disabled.u.num=0;
- wma=gui_internal_button_map_attr_new(this
- , _("Download Enabled")
- , gravity_left_center|orientation_horizontal|flags_fill
- , map
- , &download_enabled
- , &download_disabled
- , 0);
- gui_internal_widget_append(w, wma);
-
-
- f=fopen("maps/areas.tsv","r");
- while (f && fgets(buffer, sizeof(buffer), f)) {
- char *nl,*description,*description_size,*bbox,*size=NULL;
- int sp=0;
- if ((nl=strchr(buffer,'\n')))
- *nl='\0';
- if ((nl=strchr(buffer,'\r')))
- *nl='\0';
- while(buffer[sp] == ' ')
- sp++;
- if ((bbox=strchr(buffer,'\t')))
- *bbox++='\0';
- if (bbox && (size=strchr(bbox,'\t')))
- *size++='\0';
- if (search && !strcmp(buffer, search)) {
- wma=gui_internal_button_new_with_callback(this, _("Download completely"), NULL,
- gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, map);
- wma->name=g_strdup(buffer+sp);
- wma->prefix=g_strdup(bbox);
- gui_internal_widget_append(w, wma);
- found=1;
- } else if (sp < sp_match)
- found=0;
- if (sp == sp_match && found && buffer[sp]) {
- description=g_strdup(buffer+sp);
- if (size)
- description_size=g_strdup_printf("%s (%s)",description,size);
- else
- description_size=g_strdup(description);
- wma=gui_internal_button_new_with_callback(this, description_size, NULL,
- gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download, map);
- g_free(description_size);
- wma->prefix=g_strdup(buffer);
- wma->name=description;
- gui_internal_widget_append(w, wma);
- }
- }
-
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_set_active_vehicle(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr vehicle = {attr_vehicle,{wm->data}};
- navit_set_attr(this->nav, &vehicle);
-}
-
-static void
-gui_internal_cmd_show_satellite_status(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*row;
- struct attr attr,sat_attr;
- struct vehicle *v=wm->data;
- char *str;
- int i;
- enum attr_type types[]={attr_sat_prn, attr_sat_elevation, attr_sat_azimuth, attr_sat_snr};
-
- wb=gui_internal_menu(this, _("Show Satellite Status"));
- gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_satellite_status;
- gui_internal_menu_data(this)->redisplay_widget=wm;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- w = gui_internal_widget_table_new(this,gravity_center | orientation_vertical | flags_expand | flags_fill, 0);
- row = gui_internal_widget_table_row_new(this,gravity_left_top);
- gui_internal_widget_append(row, gui_internal_label_new(this, " PRN "));
- gui_internal_widget_append(row, gui_internal_label_new(this, _(" Elevation ")));
- gui_internal_widget_append(row, gui_internal_label_new(this, _(" Azimuth ")));
- gui_internal_widget_append(row, gui_internal_label_new(this, " SNR "));
- gui_internal_widget_append(w,row);
- while (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
- row = gui_internal_widget_table_row_new(this,gravity_left_top);
- for (i = 0 ; i < sizeof(types)/sizeof(enum attr_type) ; i++) {
- if (item_attr_get(attr.u.item, types[i], &sat_attr))
- str=g_strdup_printf("%ld", sat_attr.u.num);
- else
- str=g_strdup("");
- gui_internal_widget_append(row, gui_internal_label_new(this, str));
- g_free(str);
- }
- gui_internal_widget_append(w,row);
- }
- gui_internal_widget_append(wb, w);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct attr attr;
- struct vehicle *v=wm->data;
- wb=gui_internal_menu(this, _("Show NMEA Data"));
- gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_nmea_data;
- gui_internal_menu_data(this)->redisplay_widget=wm;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL))
- gui_internal_widget_append(w, gui_internal_text_new(this, attr.u.str, gravity_left_center|orientation_vertical));
- gui_internal_menu_render(this);
+void gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr attr,mattr;
+ struct item *item;
+ char *label_full,*prefix=0;
+ int plen=0,hassub,found=0;
+ struct widget *wb,*w,*wbm;
+ struct coord c;
+ struct widget *tbl, *row;
+
+ if (data)
+ prefix=g_strdup(data);
+ else {
+ if (wm && wm->prefix)
+ prefix=g_strdup(wm->prefix);
+ }
+ if ( prefix )
+ plen=strlen(prefix);
+
+ gui_internal_prune_menu_count(this, 1, 0);
+ wb=gui_internal_menu(this, _("Bookmarks"));
+ wb->background=this->background;
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ //w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ if (!plen) {
+ bookmarks_move_root(mattr.u.bookmarks);
+ } else {
+ if (!strcmp(prefix,"..")) {
+ bookmarks_move_up(mattr.u.bookmarks);
+ g_free(prefix);
+ prefix=g_strdup(bookmarks_item_cwd(mattr.u.bookmarks));
+ if (prefix) {
+ plen=strlen(prefix);
+ } else {
+ plen=0;
+ }
+ } else {
+ bookmarks_move_down(mattr.u.bookmarks,prefix);
+ }
+
+ // "Back" button, when inside a bookmark folder
+
+ if (plen) {
+ wbm=gui_internal_button_new_with_callback(this, "..",
+ image_new_xs(this, "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_bookmarks, NULL);
+ wbm->prefix=g_strdup("..");
+ gui_internal_widget_append(w, wbm);
+
+ // load bookmark folder as Waypoints, if any
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks) > 0) {
+ wbm=gui_internal_button_new_with_callback(this, _("Bookmarks as waypoints"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_load_bookmarks_as_waypoints, NULL);
+ wbm->prefix=g_strdup(prefix);
+ gui_internal_widget_append(w, wbm);
+ }
+
+ // save Waypoints in bookmark folder, if route exists
+ if (navit_get_destination_count(this->nav) > 0) {
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0) {
+ wbm=gui_internal_button_new_with_callback(this, _("Save waypoints"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
+ } else {
+ wbm=gui_internal_button_new_with_callback(this, _("Replace with waypoints"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
+ }
+ wbm->prefix=g_strdup(prefix);
+ gui_internal_widget_append(w, wbm);
+ }
+
+ // delete empty folder
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0) {
+ gui_internal_widget_append(w,
+ wbm=gui_internal_button_new_with_callback(this, _("Delete Folder"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_delete_bookmark_folder, NULL));
+ wbm->prefix=g_strdup(prefix);
+ }
+
+ }
+ }
+
+ // Adds the Bookmark folders
+ wbm=gui_internal_button_new_with_callback(this, _("Add Bookmark folder"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_add_bookmark_folder2, NULL);
+ gui_internal_widget_append(w, wbm);
+
+ // Pastes the Bookmark
+ wbm=gui_internal_button_new_with_callback(this, _("Paste bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_paste_bookmark, NULL);
+ gui_internal_widget_append(w, wbm);
+
+ bookmarks_item_rewind(mattr.u.bookmarks);
+
+ tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(w,tbl);
+
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ if (!item_attr_get(item, attr_label, &attr)) continue;
+ label_full=map_convert_string_tmp(item->map,attr.u.str);
+ dbg(lvl_info,"full_labled: %s",label_full);
+
+ // hassub == 1 if the item type is a sub-folder
+ if (item->type == type_bookmark_folder) {
+ hassub=1;
+ } else {
+ hassub=0;
+ }
+
+ row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_horizontal);
+ gui_internal_widget_append(tbl, row);
+ wbm=gui_internal_button_new_with_callback(this, label_full,
+ image_new_xs(this, hassub ? "gui_inactive" : "gui_active" ), gravity_left_center|orientation_horizontal|flags_fill,
+ hassub ? gui_internal_cmd_bookmarks : gui_internal_cmd_position, NULL);
+
+ gui_internal_widget_append(row,wbm);
+ if (item_coord_get(item, &c, 1)) {
+ wbm->c.x=c.x;
+ wbm->c.y=c.y;
+ wbm->c.pro=bookmarks_get_projection(mattr.u.bookmarks);
+ wbm->name=g_strdup_printf(_("Bookmark %s"),label_full);
+ wbm->text=g_strdup(label_full);
+ if (!hassub) {
+ wbm->data=(void*)7;//Mark us as a bookmark
+ }
+ wbm->prefix=g_strdup(label_full);
+ } else {
+ gui_internal_widget_destroy(this, row);
+ }
+ }
+ }
+
+ g_free(prefix);
+
+ if (found)
+ gui_internal_check_exit(this);
+ else
+ gui_internal_menu_render(this);
+}
+
+
+
+
+static void gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary);
+
+static int gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result);
+
+static int gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result);
+
+static struct widget* gui_internal_keynav_find_next_sensitive_child(struct widget *wi);
+
+void gui_internal_keypress_do(struct gui_priv *this, char *key) {
+ struct widget *wi,*menu,*search_list;
+ int len=0;
+ char *text=NULL;
+
+ menu=g_list_last(this->root.children)->data;
+ wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
+ if (wi) {
+ /* select first item of the searchlist */
+ if (*key == NAVIT_KEY_RETURN) {
+ search_list=gui_internal_menu_data(this)->search_list;
+ if(search_list) {
+ GList *l=gui_internal_widget_table_top_row(this, search_list);
+ if (l && l->data) {
+ struct widget *w=l->data;
+ this->current.x=w->p.x+w->w/2;
+ this->current.y=w->p.y+w->h/2;
+ gui_internal_highlight(this);
+ }
+ } else {
+ wi->reason=gui_internal_reason_keypress_finish;
+ wi->func(this, wi, wi->data);
+ }
+ return;
+ } else if (*key == NAVIT_KEY_BACKSPACE) {
+ dbg(lvl_debug,"backspace");
+ if (wi->text && wi->text[0]) {
+ len=g_utf8_prev_char(wi->text+strlen(wi->text))-wi->text;
+ wi->text[len]='\0';
+ text=g_strdup(wi->text);
+ }
+ } else {
+ if (wi->state & STATE_CLEAR) {
+ dbg(lvl_info,"wi->state=0x%x", wi->state);
+ g_free(wi->text);
+ wi->text=NULL;
+ wi->state &= ~STATE_CLEAR;
+ dbg(lvl_info,"wi->state=0x%x", wi->state);
+ }
+ text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key);
+
+ gui_internal_keyboard_to_lower_case(this);
+ }
+ g_free(wi->text);
+ wi->text=text;
+
+ if(!wi->text || !*wi->text)
+ gui_internal_keyboard_to_upper_case(this);
+
+ if (wi->func) {
+ wi->reason=gui_internal_reason_keypress;
+ wi->func(this, wi, wi->data);
+ }
+ gui_internal_widget_render(this, wi);
+ }
+}
+
+
+
+
+char *gui_internal_cmd_match_expand(char *pattern, struct attr **in) {
+ char p,*ret=g_strdup(pattern),*r=ret,*a;
+ int len;
+ while ((p=*pattern++)) {
+ switch (p) {
+ case '*':
+ *r='\0';
+ a=attr_to_text(*in++,NULL,0);
+ len=strlen(ret)+strlen(a)+strlen(pattern)+1;
+ r=g_malloc(len);
+ strcpy(r, ret);
+ strcat(r, a);
+ g_free(ret);
+ g_free(a);
+ ret=r;
+ r=ret+strlen(ret);
+ break;
+ case '\\':
+ p=*pattern++;
+ default:
+ *r++=p;
+ }
+ }
+ *r++='\0';
+ return ret;
+}
+
+static int gui_internal_match(const char *pattern, const char *string) {
+ char p,s;
+ while ((p=*pattern++)) {
+ switch (p) {
+ case '*':
+ while ((s=*string)) {
+ if (gui_internal_match(pattern,string))
+ return 1;
+ string++;
+ }
+ break;
+ case '\\':
+ p=*pattern++;
+ default:
+ if (*string++ != p)
+ return 0;
+ }
+ }
+ return 1;
+}
+
+int gui_internal_set(char *remove, char *add) {
+ char *gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
+ char *gui_file_new=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal_new.txt", NULL);
+ FILE *fo=fopen(gui_file_new,"w");
+ FILE *fi=fopen(gui_file,"r");
+ char *line=NULL;
+ int ret;
+ size_t size=0;
+ if (fi != NULL) {
+ while (getline(&line,&size,fi) > 0) {
+ int len=strlen(line);
+ if (len > 0 && line[len-1] == '\n')
+ line[len-1]='\0';
+ dbg(lvl_debug,"line=%s",line);
+ if (!gui_internal_match(remove, line))
+ fprintf(fo,"%s\n",line);
+ }
+ if (line)
+ free(line);
+ fclose(fi);
+ }
+ if (add)
+ fprintf(fo,"%s;\n",add);
+ fclose(fo);
+ unlink(gui_file);
+ ret=(rename(gui_file_new, gui_file)==0);
+ g_free(gui_file_new);
+ g_free(gui_file);
+
+ return ret;
+}
+
+
+
+static void gui_internal_window_closed(struct gui_priv *this) {
+ gui_internal_cmd2_quit(this, NULL, NULL, NULL, NULL);
+}
+
+
+static void gui_internal_cmd_map_download_do(struct gui_priv *this, struct widget *wm, void *data) {
+ char *text=g_strdup_printf(_("Download %s"),wm->name);
+ struct widget *w, *wb;
+ struct map *map=data;
+ double bllon,bllat,trlon,trlat;
+
+ wb=gui_internal_menu(this, text);
+ g_free(text);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ if (sscanf(wm->prefix,"%lf,%lf,%lf,%lf",&bllon,&bllat,&trlon,&trlat) == 4) {
+ struct coord_geo g;
+ struct map_selection sel;
+ struct map_rect *mr;
+ struct item *item;
+
+ sel.next=NULL;
+ sel.order=255;
+ g.lng=bllon;
+ g.lat=trlat;
+ transform_from_geo(projection_mg, &g, &sel.u.c_rect.lu);
+ g.lng=trlon;
+ g.lat=bllat;
+ transform_from_geo(projection_mg, &g, &sel.u.c_rect.rl);
+ sel.range.min=type_none;
+ sel.range.max=type_last;
+ mr=map_rect_new(map, &sel);
+ while ((item=map_rect_get_item(mr))) {
+ dbg(lvl_info,"item");
+ }
+ map_rect_destroy(mr);
+ }
+
+ dbg(lvl_info,"bbox=%s",wm->prefix);
+ gui_internal_menu_render(this);
+}
+
+void gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr on, off, download_enabled, download_disabled;
+ struct widget *w,*wb,*wma;
+ struct map *map=data;
+ FILE *f;
+ char *search,buffer[256];
+ int found,sp_match=0;
+
+ dbg(lvl_debug,"wm=%p prefix=%s",wm,wm->prefix);
+
+ search=wm->prefix;
+ if (search) {
+ found=0;
+ while(search[sp_match] == ' ')
+ sp_match++;
+ sp_match++;
+ } else {
+ found=1;
+ }
+ on.type=off.type=attr_active;
+ on.u.num=1;
+ off.u.num=0;
+ wb=gui_internal_menu(this, wm->name?wm->name:_("Map Download"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ if (!search) {
+ wma=gui_internal_button_map_attr_new(this, _("Active"), gravity_left_center|orientation_horizontal|flags_fill, map, &on,
+ &off, 1);
+ gui_internal_widget_append(w, wma);
+ }
+
+ download_enabled.type=download_disabled.type=attr_update;
+ download_enabled.u.num=1;
+ download_disabled.u.num=0;
+ wma=gui_internal_button_map_attr_new(this
+ , _("Download Enabled")
+ , gravity_left_center|orientation_horizontal|flags_fill
+ , map
+ , &download_enabled
+ , &download_disabled
+ , 0);
+ gui_internal_widget_append(w, wma);
+
+
+ f=fopen("maps/areas.tsv","r");
+ while (f && fgets(buffer, sizeof(buffer), f)) {
+ char *nl,*description,*description_size,*bbox,*size=NULL;
+ int sp=0;
+ if ((nl=strchr(buffer,'\n')))
+ *nl='\0';
+ if ((nl=strchr(buffer,'\r')))
+ *nl='\0';
+ while(buffer[sp] == ' ')
+ sp++;
+ if ((bbox=strchr(buffer,'\t')))
+ *bbox++='\0';
+ if (bbox && (size=strchr(bbox,'\t')))
+ *size++='\0';
+ if (search && !strcmp(buffer, search)) {
+ wma=gui_internal_button_new_with_callback(this, _("Download completely"), NULL,
+ gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, map);
+ wma->name=g_strdup(buffer+sp);
+ wma->prefix=g_strdup(bbox);
+ gui_internal_widget_append(w, wma);
+ found=1;
+ } else if (sp < sp_match)
+ found=0;
+ if (sp == sp_match && found && buffer[sp]) {
+ description=g_strdup(buffer+sp);
+ if (size)
+ description_size=g_strdup_printf("%s (%s)",description,size);
+ else
+ description_size=g_strdup(description);
+ wma=gui_internal_button_new_with_callback(this, description_size, NULL,
+ gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download, map);
+ g_free(description_size);
+ wma->prefix=g_strdup(buffer);
+ wma->name=description;
+ gui_internal_widget_append(w, wma);
+ }
+ }
+
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_set_active_vehicle(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr vehicle = {attr_vehicle,{wm->data}};
+ navit_set_attr(this->nav, &vehicle);
+}
+
+static void gui_internal_cmd_show_satellite_status(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*row;
+ struct attr attr,sat_attr;
+ struct vehicle *v=wm->data;
+ char *str;
+ int i;
+ enum attr_type types[]= {attr_sat_prn, attr_sat_elevation, attr_sat_azimuth, attr_sat_snr};
+
+ wb=gui_internal_menu(this, _("Show Satellite Status"));
+ gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_satellite_status;
+ gui_internal_menu_data(this)->redisplay_widget=wm;
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ w = gui_internal_widget_table_new(this,gravity_center | orientation_vertical | flags_expand | flags_fill, 0);
+ row = gui_internal_widget_table_row_new(this,gravity_left_top);
+ gui_internal_widget_append(row, gui_internal_label_new(this, " PRN "));
+ gui_internal_widget_append(row, gui_internal_label_new(this, _(" Elevation ")));
+ gui_internal_widget_append(row, gui_internal_label_new(this, _(" Azimuth ")));
+ gui_internal_widget_append(row, gui_internal_label_new(this, " SNR "));
+ gui_internal_widget_append(w,row);
+ while (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
+ row = gui_internal_widget_table_row_new(this,gravity_left_top);
+ for (i = 0 ; i < sizeof(types)/sizeof(enum attr_type) ; i++) {
+ if (item_attr_get(attr.u.item, types[i], &sat_attr))
+ str=g_strdup_printf("%ld", sat_attr.u.num);
+ else
+ str=g_strdup("");
+ gui_internal_widget_append(row, gui_internal_label_new(this, str));
+ g_free(str);
+ }
+ gui_internal_widget_append(w,row);
+ }
+ gui_internal_widget_append(wb, w);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb;
+ struct attr attr;
+ struct vehicle *v=wm->data;
+ wb=gui_internal_menu(this, _("Show NMEA Data"));
+ gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_nmea_data;
+ gui_internal_menu_data(this)->redisplay_widget=wm;
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL))
+ gui_internal_widget_append(w, gui_internal_text_new(this, attr.u.str, gravity_left_center|orientation_vertical));
+ gui_internal_menu_render(this);
}
/**
@@ -1981,8 +1894,8 @@ gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *
* one data item.
*/
struct vehicle_and_profilename {
- struct vehicle *vehicle;
- char *profilename;
+ struct vehicle *vehicle;
+ char *profilename;
};
/**
@@ -1990,40 +1903,36 @@ struct vehicle_and_profilename {
*
* @return true if the vehicle is active, false otherwise.
*/
-static int
-gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
- *vehicle)
-{
- struct attr active_vehicle;
+static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
+ *vehicle) {
+ struct attr active_vehicle;
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
+ if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
active_vehicle.u.vehicle=NULL;
- return active_vehicle.u.vehicle == vehicle;
-}
-
-static void
-save_vehicle_xml(struct vehicle *v)
-{
- struct attr attr;
- struct attr_iter *iter=vehicle_attr_iter_new();
- int childs=0;
- printf("<vehicle");
- while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
- if (ATTR_IS_OBJECT(attr.type))
- childs=1;
- else {
- char *attrtxt;
- printf(" %s=\"%s\"",attr_to_name(attr.type),attrtxt=attr_to_text(&attr, NULL, 1));
- g_free(attrtxt);
- }
- }
- if (childs) {
- printf(">\n");
- printf("</vehicle>\n");
- } else
- printf(" />\n");
- vehicle_attr_iter_destroy(iter);
+ return active_vehicle.u.vehicle == vehicle;
+}
+
+static void save_vehicle_xml(struct vehicle *v) {
+ struct attr attr;
+ struct attr_iter *iter=vehicle_attr_iter_new();
+ int childs=0;
+ printf("<vehicle");
+ while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
+ if (ATTR_IS_OBJECT(attr.type))
+ childs=1;
+ else {
+ char *attrtxt;
+ printf(" %s=\"%s\"",attr_to_name(attr.type),attrtxt=attr_to_text(&attr, NULL, 1));
+ g_free(attrtxt);
+ }
+ }
+ if (childs) {
+ printf(">\n");
+ printf("</vehicle>\n");
+ } else
+ printf(" />\n");
+ vehicle_attr_iter_destroy(iter);
}
@@ -2032,169 +1941,162 @@ save_vehicle_xml(struct vehicle *v)
*
* @see gui_internal_add_vehicle_profile
*/
-static void
-gui_internal_cmd_set_active_profile(struct gui_priv *this, struct
- widget *wm, void *data)
-{
- struct vehicle_and_profilename *vapn = data;
- struct vehicle *v = vapn->vehicle;
- char *profilename = vapn->profilename;
- struct attr vehicle_name_attr;
- char *vehicle_name = NULL;
- struct attr profilename_attr;
- struct attr vehicle;
-
- // Get the vehicle name
- vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL);
- vehicle_name = vehicle_name_attr.u.str;
-
- dbg(lvl_debug, "Changing vehicle %s to profile %s\n", vehicle_name,
- profilename);
-
- // Change the profile name
- profilename_attr.type = attr_profilename;
- profilename_attr.u.str = profilename;
- if(!vehicle_set_attr(v, &profilename_attr)) {
- dbg(lvl_error, "Unable to set the vehicle's profile name\n");
- }
-
- navit_set_vehicleprofile_name(this->nav,profilename);
-
- save_vehicle_xml(v);
+static void gui_internal_cmd_set_active_profile(struct gui_priv *this, struct
+ widget *wm, void *data) {
+ struct vehicle_and_profilename *vapn = data;
+ struct vehicle *v = vapn->vehicle;
+ char *profilename = vapn->profilename;
+ struct attr vehicle_name_attr;
+ char *vehicle_name = NULL;
+ struct attr profilename_attr;
+ struct attr vehicle;
+
+ // Get the vehicle name
+ vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL);
+ vehicle_name = vehicle_name_attr.u.str;
+
+ dbg(lvl_debug, "Changing vehicle %s to profile %s", vehicle_name, profilename);
+
+ // Change the profile name
+ profilename_attr.type = attr_profilename;
+ profilename_attr.u.str = profilename;
+ if(!vehicle_set_attr(v, &profilename_attr)) {
+ dbg(lvl_error, "Unable to set the vehicle's profile name");
+ }
+
+ navit_set_vehicleprofile_name(this->nav,profilename);
+
+ save_vehicle_xml(v);
// Notify Navit that the routing should be re-done if this is the
// active vehicle.
- if (gui_internal_is_active_vehicle(this, v)) {
- vehicle.u.vehicle=v;
- }
- else {
+ if (gui_internal_is_active_vehicle(this, v)) {
+ vehicle.u.vehicle=v;
+ } else {
+
+ vehicle.u.vehicle=NULL;
+ }
- vehicle.u.vehicle=NULL;
- }
-
- vehicle.type=attr_vehicle;
- navit_set_attr(this->nav, &vehicle);
+ vehicle.type=attr_vehicle;
+ navit_set_attr(this->nav, &vehicle);
-
- gui_internal_prune_menu_count(this, 1, 0);
- gui_internal_menu_vehicle_settings(this, v, vehicle_name);
+
+ gui_internal_prune_menu_count(this, 1, 0);
+ gui_internal_menu_vehicle_settings(this, v, vehicle_name);
}
/**
* Adds the vehicle profile to the GUI, allowing the user to pick a
* profile for the currently selected vehicle.
*/
-static void
-gui_internal_add_vehicle_profile(struct gui_priv *this, struct widget
- *parent, struct vehicle *v, struct vehicleprofile *profile)
-{
- // Just here to show up in the translation file, nice and close to
- // where the translations are actually used.
- struct attr profile_attr;
- struct attr *attr = NULL;
- char *name = NULL;
- char *active_profile = NULL;
- char *label = NULL;
- int active;
- struct vehicle_and_profilename *context = NULL;
+static void gui_internal_add_vehicle_profile(struct gui_priv *this, struct widget
+ *parent, struct vehicle *v, struct vehicleprofile *profile) {
+ // Just here to show up in the translation file, nice and close to
+ // where the translations are actually used.
+ struct attr profile_attr;
+ struct attr *attr = NULL;
+ char *name = NULL;
+ char *active_profile = NULL;
+ char *label = NULL;
+ int active;
+ struct vehicle_and_profilename *context = NULL;
#ifdef ONLY_FOR_TRANSLATION
- char *translations[] = {_n("car"), _n("bike"), _n("pedestrian")};
+ char *translations[] = {_n("car"), _n("bike"), _n("pedestrian")};
#endif
- // Figure out the profile name
- attr = attr_search(profile->attrs, NULL, attr_name);
- if (!attr) {
- dbg(lvl_error, "Adding vehicle profile failed. attr==NULL");
- return;
- }
- name = attr->u.str;
-
- // Determine whether the profile is the active one
- if (vehicle_get_attr(v, attr_profilename, &profile_attr, NULL))
- active_profile = profile_attr.u.str;
- active = active_profile != NULL && !strcmp(name, active_profile);
-
- dbg(lvl_debug, "Adding vehicle profile %s, active=%s/%i\n", name,
- active_profile, active);
-
- // Build a translatable label.
- if(active) {
- label = g_strdup_printf(_("Current profile: %s"), _(name));
- } else {
- label = g_strdup_printf(_("Change profile to: %s"), _(name));
- }
-
- // Create the context object (the vehicle and the desired profile)
- context = g_new0(struct vehicle_and_profilename, 1);
- context->vehicle = v;
- context->profilename = name;
-
- // Add the button
- gui_internal_widget_append(parent,
- gui_internal_button_new_with_callback(
- this, label,
- image_new_xs(this, active ? "gui_active" : "gui_inactive"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_active_profile, context));
-
- free(label);
-}
-
-void
-gui_internal_menu_vehicle_settings(struct gui_priv *this, struct vehicle *v, char *name)
-{
- struct widget *w,*wb,*row;
- struct attr attr;
+ // Figure out the profile name
+ attr = attr_search(profile->attrs, NULL, attr_name);
+ if (!attr) {
+ dbg(lvl_error, "Adding vehicle profile failed. attr==NULL");
+ return;
+ }
+ name = attr->u.str;
+
+ // Determine whether the profile is the active one
+ if (vehicle_get_attr(v, attr_profilename, &profile_attr, NULL))
+ active_profile = profile_attr.u.str;
+ active = active_profile != NULL && !strcmp(name, active_profile);
+
+ dbg(lvl_debug, "Adding vehicle profile %s, active=%s/%i", name, active_profile, active);
+
+ // Build a translatable label.
+ if(active) {
+ label = g_strdup_printf(_("Current profile: %s"), _(name));
+ } else {
+ label = g_strdup_printf(_("Change profile to: %s"), _(name));
+ }
+
+ // Create the context object (the vehicle and the desired profile)
+ context = g_new0(struct vehicle_and_profilename, 1);
+ context->vehicle = v;
+ context->profilename = name;
+
+ // Add the button
+ gui_internal_widget_append(parent,
+ gui_internal_button_new_with_callback(
+ this, label,
+ image_new_xs(this, active ? "gui_active" : "gui_inactive"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_active_profile, context));
+
+ free(label);
+}
+
+void gui_internal_menu_vehicle_settings(struct gui_priv *this, struct vehicle *v, char *name) {
+ struct widget *w,*wb,*row;
+ struct attr attr;
struct vehicleprofile *profile = NULL;
- GList *profiles;
+ GList *profiles;
- wb=gui_internal_menu(this, name);
- w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
- gui_internal_widget_append(wb, w);
+ wb=gui_internal_menu(this, name);
+ w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
+ gui_internal_widget_append(wb, w);
// Add the "Set as active" button if this isn't the active
// vehicle.
- if (!gui_internal_is_active_vehicle(this, v)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Set as active"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_active_vehicle, v));
- }
-
- if (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Show Satellite status"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_show_satellite_status, v));
- }
- if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Show NMEA data"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_show_nmea_data, v));
- }
+ if (!gui_internal_is_active_vehicle(this, v)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new_with_callback(this, _("Set as active"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_active_vehicle, v));
+ }
+
+ if (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new_with_callback(this, _("Show Satellite status"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_show_satellite_status, v));
+ }
+ if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new_with_callback(this, _("Show NMEA data"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_show_nmea_data, v));
+ }
// Add all the possible vehicle profiles to the menu
- profiles = navit_get_vehicleprofiles(this->nav);
+ profiles = navit_get_vehicleprofiles(this->nav);
while(profiles) {
profile = (struct vehicleprofile *)profiles->data;
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
gui_internal_add_vehicle_profile(this, row, v, profile);
- profiles = g_list_next(profiles);
+ profiles = g_list_next(profiles);
}
- callback_list_call_attr_2(this->cbl, attr_vehicle, w, v);
- gui_internal_menu_render(this);
+ callback_list_call_attr_2(this->cbl, attr_vehicle, w, v);
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_menu_vehicle_settings(this, wm->data, wm->text);
+void gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_menu_vehicle_settings(this, wm->data, wm->text);
}
@@ -2205,255 +2107,227 @@ gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gui_internal_motion(void *data, struct point *p)
-{
-
- struct gui_priv *this=data;
- if (!this->root.children) {
- navit_handle_motion(this->nav, p);
- return;
- }
- if (!this->pressed)
- return;
- this->current=*p;
- if(!this->motion_timeout_callback)
- this->motion_timeout_callback=callback_new_1(callback_cast(gui_internal_motion_cb), this);
- if(!this->motion_timeout_event)
- this->motion_timeout_event=event_add_timeout(30,0, this->motion_timeout_callback);
-}
-
-void
-gui_internal_evaluate(struct gui_priv *this, const char *command)
-{
- if (command)
- command_evaluate(&this->self, command);
-}
-
-
-void
-gui_internal_enter(struct gui_priv *this, int ignore)
-{
- struct graphics *gra=this->gra;
- if (ignore != -1)
- this->ignore_button=ignore;
-
- navit_block(this->nav, 1);
- graphics_overlay_disable(gra, 1);
- this->root.p.x=0;
- this->root.p.y=0;
- this->root.background=this->background;
-}
-
-void
-gui_internal_leave(struct gui_priv *this)
-{
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
-void
-gui_internal_set_click_coord(struct gui_priv *this, struct point *p)
-{
- struct coord c;
- struct coord_geo g;
- struct attr attr;
- struct transformation *trans;
- attr_free(this->click_coord_geo);
- this->click_coord_geo=NULL;
- if (p) {
- trans=navit_get_trans(this->nav);
- transform_reverse(trans, p, &c);
- dbg(lvl_debug,"x=0x%x y=0x%x\n", c.x, c.y);
- this->clickp.pro=transform_get_projection(trans);
- this->clickp.x=c.x;
- this->clickp.y=c.y;
- transform_to_geo(this->clickp.pro, &c, &g);
- attr.u.coord_geo=&g;
- attr.type=attr_click_coord_geo;
- this->click_coord_geo=attr_dup(&attr);
- }
-}
-
-static void
-gui_internal_set_position_coord(struct gui_priv *this)
-{
- struct transformation *trans;
- struct attr attr,attrp;
- struct coord c;
-
- attr_free(this->position_coord_geo);
- this->position_coord_geo=NULL;
- if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
- && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
- trans=navit_get_trans(this->nav);
- this->position_coord_geo=attr_dup(&attrp);
- this->vehiclep.pro=transform_get_projection(trans);
- transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
- this->vehiclep.x=c.x;
- this->vehiclep.y=c.y;
- }
-}
-
-void
-gui_internal_enter_setup(struct gui_priv *this)
-{
- if (!this->mouse_button_clicked_on_map)
- gui_internal_set_position_coord(this);
-}
-
-void
-gui_internal_cmd_menu(struct gui_priv *this, int ignore, char *href)
-{
- dbg(lvl_debug,"enter\n");
- gui_internal_enter(this, ignore);
- gui_internal_enter_setup(this);
- // draw menu
- if (href)
- gui_internal_html_load_href(this, href, 0);
- else
- gui_internal_html_main_menu(this);
-}
-
-
-
-static void
-gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget)
-{
- if (widget->text && strlen(widget->text)) {
- if (this->position_coord_geo)
- navit_textfile_debug_log_at(this->nav, &this->vehiclep, "type=log_entry label=\"%s\"",widget->text);
- else
- navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- gui_internal_prune_menu(this, NULL);
- gui_internal_check_exit(this);
-}
-
-void
-gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_log_do(this, widget->data);
-}
-
-
-void
-gui_internal_check_exit(struct gui_priv *this)
-{
- struct graphics *gra=this->gra;
- if (! this->root.children) {
- gui_internal_search_idle_end(this);
- gui_internal_search_list_destroy(this);
- graphics_overlay_disable(gra, 0);
- if (!navit_block(this->nav, 0)) {
- if (this->redraw)
- navit_draw(this->nav);
- else
- navit_draw_displaylist(this->nav);
- }
- }
-}
-
-static int
-gui_internal_get_attr(struct gui_priv *this, enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_active:
- attr->u.num=this->root.children != NULL;
- break;
- case attr_click_coord_geo:
- if (!this->click_coord_geo)
- return 0;
- *attr=*this->click_coord_geo;
- break;
- case attr_position_coord_geo:
- if (!this->position_coord_geo)
- return 0;
- *attr=*this->position_coord_geo;
- break;
- case attr_pitch:
- attr->u.num=this->pitch;
- break;
- case attr_button:
- attr->u.num=this->mouse_button_clicked_on_map;
- break;
- case attr_navit:
- attr->u.navit=this->nav;
- break;
- case attr_fullscreen:
- attr->u.num=(this->fullscreen > 0);
- break;
- default:
- return 0;
- }
- attr->type=type;
- return 1;
-}
-
-static int
-gui_internal_add_attr(struct gui_priv *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_xml_text:
- g_free(this->html_text);
- this->html_text=g_strdup(attr->u.str);
- return 1;
- default:
- return 0;
- }
-}
-
-static int
-gui_internal_set_attr(struct gui_priv *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_fullscreen:
- if ((this->fullscreen > 0) != (attr->u.num > 0)) {
- graphics_draw_mode(this->gra, draw_mode_end);
- this->win->fullscreen(this->win, attr->u.num > 0);
- graphics_draw_mode(this->gra, draw_mode_begin);
- }
- this->fullscreen=attr->u.num;
- return 1;
- case attr_menu_on_map_click:
- this->menu_on_map_click=attr->u.num;
- return 1;
- case attr_on_map_click:
- g_free(this->on_map_click);
- this->on_map_click=g_strdup(attr->u.str);
- return 1;
- default:
- dbg(lvl_error,"Unknown attribute: %s\n",attr_to_name(attr->type));
- return 1;
- }
-}
-
-static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p)
-{
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct displayitem *di;
- struct attr cb,**attr_list=NULL;
- int valid=0;
-
- display=navit_get_displaylist(this->nav);
- dlh=graphics_displaylist_open(display);
- while ((di=graphics_displaylist_next(dlh))) {
- struct item *item=graphics_displayitem_get_item(di);
- if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
- graphics_displayitem_within_dist(display, di, p, this->radius)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- struct attr attr;
- if (itemo && item_attr_get(itemo, attr_data, &attr))
- attr_list=attr_generic_add_attr(attr_list, &attr);
- map_rect_destroy(mr);
- }
- }
- graphics_displaylist_close(dlh);
- if (attr_list && navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
- attr_list_free(attr_list);
+static void gui_internal_motion(void *data, struct point *p) {
+
+ struct gui_priv *this=data;
+ if (!this->root.children) {
+ navit_handle_motion(this->nav, p);
+ return;
+ }
+ if (!this->pressed)
+ return;
+ this->current=*p;
+ if(!this->motion_timeout_callback)
+ this->motion_timeout_callback=callback_new_1(callback_cast(gui_internal_motion_cb), this);
+ if(!this->motion_timeout_event)
+ this->motion_timeout_event=event_add_timeout(30,0, this->motion_timeout_callback);
+}
+
+void gui_internal_evaluate(struct gui_priv *this, const char *command) {
+ if (command)
+ command_evaluate(&this->self, command);
+}
+
+
+void gui_internal_enter(struct gui_priv *this, int ignore) {
+ struct graphics *gra=this->gra;
+ if (ignore != -1)
+ this->ignore_button=ignore;
+
+ navit_block(this->nav, 1);
+ graphics_overlay_disable(gra, 1);
+ this->root.p.x=0;
+ this->root.p.y=0;
+ this->root.background=this->background;
+}
+
+void gui_internal_leave(struct gui_priv *this) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+}
+
+void gui_internal_set_click_coord(struct gui_priv *this, struct point *p) {
+ struct coord c;
+ struct coord_geo g;
+ struct attr attr;
+ struct transformation *trans;
+ attr_free(this->click_coord_geo);
+ this->click_coord_geo=NULL;
+ if (p) {
+ trans=navit_get_trans(this->nav);
+ transform_reverse(trans, p, &c);
+ dbg(lvl_debug,"x=0x%x y=0x%x", c.x, c.y);
+ this->clickp.pro=transform_get_projection(trans);
+ this->clickp.x=c.x;
+ this->clickp.y=c.y;
+ transform_to_geo(this->clickp.pro, &c, &g);
+ attr.u.coord_geo=&g;
+ attr.type=attr_click_coord_geo;
+ this->click_coord_geo=attr_dup(&attr);
+ }
+}
+
+static void gui_internal_set_position_coord(struct gui_priv *this) {
+ struct transformation *trans;
+ struct attr attr,attrp;
+ struct coord c;
+
+ attr_free(this->position_coord_geo);
+ this->position_coord_geo=NULL;
+ if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
+ && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
+ trans=navit_get_trans(this->nav);
+ this->position_coord_geo=attr_dup(&attrp);
+ this->vehiclep.pro=transform_get_projection(trans);
+ transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
+ this->vehiclep.x=c.x;
+ this->vehiclep.y=c.y;
+ }
+}
+
+void gui_internal_enter_setup(struct gui_priv *this) {
+ if (!this->mouse_button_clicked_on_map)
+ gui_internal_set_position_coord(this);
+}
+
+void gui_internal_cmd_menu(struct gui_priv *this, int ignore, char *href) {
+ dbg(lvl_debug,"enter");
+ gui_internal_enter(this, ignore);
+ gui_internal_enter_setup(this);
+ // draw menu
+ if (href)
+ gui_internal_html_load_href(this, href, 0);
+ else
+ gui_internal_html_main_menu(this);
+}
+
+
+
+static void gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget) {
+ if (widget->text && strlen(widget->text)) {
+ if (this->position_coord_geo)
+ navit_textfile_debug_log_at(this->nav, &this->vehiclep, "type=log_entry label=\"%s\"",widget->text);
+ else
+ navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text);
+ }
+ g_free(widget->text);
+ widget->text=NULL;
+ gui_internal_prune_menu(this, NULL);
+ gui_internal_check_exit(this);
+}
+
+void gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_cmd_log_do(this, widget->data);
+}
+
+
+void gui_internal_check_exit(struct gui_priv *this) {
+ struct graphics *gra=this->gra;
+ if (! this->root.children) {
+ gui_internal_search_idle_end(this);
+ gui_internal_search_list_destroy(this);
+ graphics_overlay_disable(gra, 0);
+ if (!navit_block(this->nav, 0)) {
+ if (this->redraw)
+ navit_draw(this->nav);
+ else
+ navit_draw_displaylist(this->nav);
+ }
+ }
+}
+
+static int gui_internal_get_attr(struct gui_priv *this, enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_active:
+ attr->u.num=this->root.children != NULL;
+ break;
+ case attr_click_coord_geo:
+ if (!this->click_coord_geo)
+ return 0;
+ *attr=*this->click_coord_geo;
+ break;
+ case attr_position_coord_geo:
+ if (!this->position_coord_geo)
+ return 0;
+ *attr=*this->position_coord_geo;
+ break;
+ case attr_pitch:
+ attr->u.num=this->pitch;
+ break;
+ case attr_button:
+ attr->u.num=this->mouse_button_clicked_on_map;
+ break;
+ case attr_navit:
+ attr->u.navit=this->nav;
+ break;
+ case attr_fullscreen:
+ attr->u.num=(this->fullscreen > 0);
+ break;
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return 1;
+}
+
+static int gui_internal_add_attr(struct gui_priv *this, struct attr *attr) {
+ switch (attr->type) {
+ case attr_xml_text:
+ g_free(this->html_text);
+ this->html_text=g_strdup(attr->u.str);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static int gui_internal_set_attr(struct gui_priv *this, struct attr *attr) {
+ switch (attr->type) {
+ case attr_fullscreen:
+ if ((this->fullscreen > 0) != (attr->u.num > 0)) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+ this->win->fullscreen(this->win, attr->u.num > 0);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ }
+ this->fullscreen=attr->u.num;
+ return 1;
+ case attr_menu_on_map_click:
+ this->menu_on_map_click=attr->u.num;
+ return 1;
+ case attr_on_map_click:
+ g_free(this->on_map_click);
+ this->on_map_click=g_strdup(attr->u.str);
+ return 1;
+ default:
+ dbg(lvl_error,"Unknown attribute: %s",attr_to_name(attr->type));
+ return 1;
+ }
+}
+
+static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct displayitem *di;
+ struct attr cb,**attr_list=NULL;
+ int valid=0;
+
+ display=navit_get_displaylist(this->nav);
+ dlh=graphics_displaylist_open(display);
+ while ((di=graphics_displaylist_next(dlh))) {
+ struct item *item=graphics_displayitem_get_item(di);
+ if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
+ graphics_displayitem_within_dist(display, di, p, this->radius)) {
+ struct map_rect *mr=map_rect_new(item->map, NULL);
+ struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ struct attr attr;
+ if (itemo && item_attr_get(itemo, attr_data, &attr))
+ attr_list=attr_generic_add_attr(attr_list, &attr);
+ map_rect_destroy(mr);
+ }
+ }
+ graphics_displaylist_close(dlh);
+ if (attr_list && navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
+ callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+ attr_list_free(attr_list);
}
/**
@@ -2461,55 +2335,53 @@ static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p)
*
* @author Martin Bruns (05/2012), mdankov
*/
-static int
-gui_internal_coordinate_parse(char *s, char plus, char minus, double *x)
-{
- int sign=0;
- char *degree, *minute, *second;
- double tmp;
-
- if(!s)
- return 0;
-
- if (strchr(s, minus)!=NULL)
- sign=-1;
- else if (strchr(s, plus)!=NULL)
- sign=1;
-
- if(!sign)
- return 0;
-
-
- /* Can't just use strtok here because ° is multibyte sequence in utf8 */
- degree=s;
- minute=strstr(s,"°");
- if(minute) {
- *minute=0;
- minute+=strlen("°");
- }
-
- sscanf(degree, "%lf", x);
-
- if(strchr(degree, plus) || strchr(degree, minus)) {
- dbg(lvl_debug,"degree %c/%c found\n",plus,minus);
- } else {/* DEGREES_MINUTES */
- if(!minute)
- return 0;
- minute = strtok(minute,"'");
- sscanf(minute, "%lf", &tmp);
- *x+=tmp/60;
- if(strchr(minute, plus) || strchr(minute, minus)) {
- dbg(lvl_debug,"minute %c/%c found\n",plus,minus);
- } else { /* DEGREES_MINUTES_SECONDS */
- second=strtok(NULL,"");
- if(!second)
- return 0;
- sscanf(second, "%lf", &tmp);
- *x+=tmp/3600;
- }
- }
- *x *= sign;
- return 1;
+static int gui_internal_coordinate_parse(char *s, char plus, char minus, double *x) {
+ int sign=0;
+ char *degree, *minute, *second;
+ double tmp;
+
+ if(!s)
+ return 0;
+
+ if (strchr(s, minus)!=NULL)
+ sign=-1;
+ else if (strchr(s, plus)!=NULL)
+ sign=1;
+
+ if(!sign)
+ return 0;
+
+
+ /* Can't just use strtok here because ° is multibyte sequence in utf8 */
+ degree=s;
+ minute=strstr(s,"°");
+ if(minute) {
+ *minute=0;
+ minute+=strlen("°");
+ }
+
+ sscanf(degree, "%lf", x);
+
+ if(strchr(degree, plus) || strchr(degree, minus)) {
+ dbg(lvl_debug,"degree %c/%c found",plus,minus);
+ } else {/* DEGREES_MINUTES */
+ if(!minute)
+ return 0;
+ minute = strtok(minute,"'");
+ sscanf(minute, "%lf", &tmp);
+ *x+=tmp/60;
+ if(strchr(minute, plus) || strchr(minute, minus)) {
+ dbg(lvl_debug,"minute %c/%c found",plus,minus);
+ } else { /* DEGREES_MINUTES_SECONDS */
+ second=strtok(NULL,"");
+ if(!second)
+ return 0;
+ sscanf(second, "%lf", &tmp);
+ *x+=tmp/3600;
+ }
+ }
+ *x *= sign;
+ return 1;
}
//##############################################################################################################
@@ -2517,35 +2389,34 @@ gui_internal_coordinate_parse(char *s, char plus, char minus, double *x)
//# Comment:
//# Authors: Martin Bruns (05/2012)
//##############################################################################################################
-static void
-gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget)
-{
- char *lat, *lng;
- char *widgettext;
- double latitude, longitude;
- dbg(lvl_debug,"text entered:%s\n", widget->text);
-
- /* possible entry can be identical to coord_format output but only space between lat and lng is allowed */
- widgettext=g_ascii_strup(widget->text,-1);
-
- lat=strtok(widgettext," ");
- lng=strtok(NULL,"");
-
- if(!lat || !lng){
- g_free(widgettext);
- return;
- }
- if( gui_internal_coordinate_parse(lat, 'N', 'S', &latitude) && gui_internal_coordinate_parse(lng, 'E', 'W', &longitude) ) {
- g_free(widgettext);
- widgettext=g_strdup_printf("%lf %lf", longitude, latitude);
- pcoord_parse(widgettext, projection_mg, &widget->c );
- } else if(!pcoord_parse(widget->text, projection_mg, &widget->c )) {
- g_free(widgettext);
- return;
- }
- g_free(widgettext);
-
- gui_internal_cmd_position(this, widget, (void*)8);
+static void gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget) {
+ char *lat, *lng;
+ char *widgettext;
+ double latitude, longitude;
+ dbg(lvl_debug,"text entered:%s", widget->text);
+
+ /* possible entry can be identical to coord_format output but only space between lat and lng is allowed */
+ widgettext=g_ascii_strup(widget->text,-1);
+
+ lat=strtok(widgettext," ");
+ lng=strtok(NULL,"");
+
+ if(!lat || !lng) {
+ g_free(widgettext);
+ return;
+ }
+ if( gui_internal_coordinate_parse(lat, 'N', 'S', &latitude)
+ && gui_internal_coordinate_parse(lng, 'E', 'W', &longitude) ) {
+ g_free(widgettext);
+ widgettext=g_strdup_printf("%lf %lf", longitude, latitude);
+ pcoord_parse(widgettext, projection_mg, &widget->c );
+ } else if(!pcoord_parse(widget->text, projection_mg, &widget->c )) {
+ g_free(widgettext);
+ return;
+ }
+ g_free(widgettext);
+
+ gui_internal_cmd_position(this, widget, (void*)8);
}
//##############################################################################################################
@@ -2553,11 +2424,9 @@ gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget)
//# Comment:
//# Authors: Martin Bruns (05/2012)
//##############################################################################################################
-void
-gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_debug,"entered\n");
- gui_internal_cmd_enter_coord_do(this, widget->data);
+void gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ dbg(lvl_debug,"entered");
+ gui_internal_cmd_enter_coord_do(this, widget->data);
}
/**
@@ -2565,263 +2434,271 @@ gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widge
*
* @author Martin Schaller (04/2008), Stefan Klumpp (04/2008)
*/
-static void gui_internal_button(void *data, int pressed, int button, struct point *p)
-{
- struct gui_priv *this=data;
- struct graphics *gra=this->gra;
-
- dbg(lvl_debug,"enter %d %d\n", pressed, button);
- // if still on the map (not in the menu, yet):
- dbg(lvl_debug,"children=%p ignore_button=%d\n",this->root.children,this->ignore_button);
- if (!this->root.children || this->ignore_button) {
-
- this->ignore_button=0;
- // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
- if (!navit_handle_button(this->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug,"navit has handled button\n");
- return;
- }
- dbg(lvl_debug,"menu_on_map_click=%d\n",this->menu_on_map_click);
- if (button != 1)
- return;
- if (this->on_map_click || this->menu_on_map_click) {
- this->mouse_button_clicked_on_map=1;
- gui_internal_set_click_coord(this, p);
- gui_internal_set_position_coord(this);
- if (this->on_map_click)
- command_evaluate(&this->self, this->on_map_click);
- else
- gui_internal_cmd_menu(this, 0, NULL);
- this->mouse_button_clicked_on_map=0;
- } else if (this->signal_on_map_click) {
- gui_internal_dbus_signal(this, p);
- return;
- }
- return;
- }
-
-
- /*
- * If already in the menu:
- */
-
- if (pressed) {
- this->pressed=1;
- this->current=*p;
- gui_internal_gesture_ring_clear(this);
- gui_internal_gesture_ring_add(this, p);
- gui_internal_highlight(this);
- } else {
- int dx,dy;
- gui_internal_gesture_ring_add(this, p);
- gui_internal_gesture_get_vector(this, 300, NULL, &dx, &dy);
- this->current.x=-1;
- this->current.y=-1;
- graphics_draw_mode(gra, draw_mode_begin);
- if(!gui_internal_gesture_do(this) && this->pressed!=2 && abs(dx)<this->icon_s && abs(dy)<this->icon_s)
- gui_internal_call_highlighted(this);
- this->pressed=0;
- if (!event_main_loop_has_quit()) {
- gui_internal_highlight(this);
- graphics_draw_mode(gra, draw_mode_end);
- gui_internal_check_exit(this);
- }
- }
-}
-
-static void
-gui_internal_setup(struct gui_priv *this)
-{
- struct color cbh={0x9fff,0x9fff,0x9fff,0xffff};
- struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
- struct graphics *gra=this->gra;
- unsigned char *buffer;
- char *gui_file;
- int size;
-
- if (this->background)
- return;
- this->background=graphics_gc_new(gra);
- this->background2=graphics_gc_new(gra);
- this->highlight_background=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->highlight_background, &cbh);
- this->foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->foreground, &cf);
- this->text_background=graphics_gc_new(gra);
- this->text_foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->background, &this->background_color);
- graphics_gc_set_foreground(this->background2, &this->background2_color);
- graphics_gc_set_foreground(this->text_background, &this->text_background_color);
- graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
- gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
- if (file_get_contents(gui_file,&buffer,&size)) {
- char *command=g_malloc(size+1);
- strncpy(command,(const char *)buffer,size);
- command[size]=0;
- command_evaluate(&this->self, command);
- g_free(command);
- g_free(buffer);
- }
- g_free(gui_file);
+static void gui_internal_button(void *data, int pressed, int button, struct point *p) {
+ struct gui_priv *this=data;
+ struct graphics *gra=this->gra;
+
+ dbg(lvl_debug,"enter %d %d", pressed, button);
+ // if still on the map (not in the menu, yet):
+ dbg(lvl_debug,"children=%p ignore_button=%d",this->root.children,this->ignore_button);
+ if (!this->root.children || this->ignore_button) {
+
+ this->ignore_button=0;
+ // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
+ if (!navit_handle_button(this->nav, pressed, button, p, NULL)) {
+ dbg(lvl_debug,"navit has handled button");
+ return;
+ }
+ dbg(lvl_debug,"menu_on_map_click=%d",this->menu_on_map_click);
+ if (button != 1)
+ return;
+ if (this->on_map_click || this->menu_on_map_click) {
+ this->mouse_button_clicked_on_map=1;
+ gui_internal_set_click_coord(this, p);
+ gui_internal_set_position_coord(this);
+ if (this->on_map_click)
+ command_evaluate(&this->self, this->on_map_click);
+ else
+ gui_internal_cmd_menu(this, 0, NULL);
+ this->mouse_button_clicked_on_map=0;
+ } else if (this->signal_on_map_click) {
+ gui_internal_dbus_signal(this, p);
+ return;
+ }
+ return;
+ }
+
+
+ /*
+ * If already in the menu:
+ */
+
+ if (pressed) {
+ this->pressed=1;
+ this->current=*p;
+ gui_internal_gesture_ring_clear(this);
+ gui_internal_gesture_ring_add(this, p);
+ gui_internal_highlight(this);
+ } else {
+ int dx,dy;
+ gui_internal_gesture_ring_add(this, p);
+ gui_internal_gesture_get_vector(this, 300, NULL, &dx, &dy);
+ this->current.x=-1;
+ this->current.y=-1;
+ graphics_draw_mode(gra, draw_mode_begin);
+ if(!gui_internal_gesture_do(this) && this->pressed!=2 && abs(dx)<this->icon_s && abs(dy)<this->icon_s)
+ gui_internal_call_highlighted(this);
+ this->pressed=0;
+ if (!event_main_loop_has_quit()) {
+ gui_internal_highlight(this);
+ graphics_draw_mode(gra, draw_mode_end);
+ gui_internal_check_exit(this);
+ }
+ }
+}
+
+static void gui_internal_setup(struct gui_priv *this) {
+ struct color cbh= {0x9fff,0x9fff,0x9fff,0xffff};
+ struct color cf= {0xbfff,0xbfff,0xbfff,0xffff};
+ struct graphics *gra=this->gra;
+ unsigned char *buffer;
+ char *gui_file;
+ int size;
+
+ if (this->background)
+ return;
+ this->background=graphics_gc_new(gra);
+ this->background2=graphics_gc_new(gra);
+ this->highlight_background=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->highlight_background, &cbh);
+ this->foreground=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->foreground, &cf);
+ this->text_background=graphics_gc_new(gra);
+ this->text_foreground=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->background, &this->background_color);
+ graphics_gc_set_foreground(this->background2, &this->background2_color);
+ graphics_gc_set_foreground(this->text_background, &this->text_background_color);
+ graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
+ gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
+ if (file_get_contents(gui_file,&buffer,&size)) {
+ char *command=g_malloc(size+1);
+ strncpy(command,(const char *)buffer,size);
+ command[size]=0;
+ command_evaluate(&this->self, command);
+ g_free(command);
+ g_free(buffer);
+ }
+ g_free(gui_file);
+}
+
+/**
+ * @brief Callback function invoked when display area is resized
+ *
+ * @param data A generic argument structure pointer, here we use it to store the the internal GUI context (this)
+ * @param wnew The new width of the display area
+ * @param hnew The new height of the display area
+ *
+ * @author Martin Schaller
+ * @date 2008/04
+ */
+static void gui_internal_resize(void *data, int wnew, int hnew) {
+ GList *l;
+ struct widget *w;
+
+ struct gui_priv *this=data;
+ int changed=0;
+
+ gui_internal_setup(this);
+
+ changed=gui_internal_menu_needs_resizing(this, &(this->root), wnew, hnew);
+
+ /*
+ * If we're drawing behind system bars on Android, watching for actual size changes will not catch
+ * fullscreen toggle events. As a workaround, always assume a size change if padding is supplied.
+ */
+ if (!changed && this->gra && graphics_get_data(this->gra, "padding"))
+ changed = 1;
+ navit_handle_resize(this->nav, wnew, hnew);
+ if (this->root.children) {
+ if (changed) {
+ l = g_list_last(this->root.children);
+ if (l) {
+ w=l->data;
+ if (!gui_internal_widget_reload_href(this,
+ w)) { /* If the foremost widget is a HTML menu, reload & redraw it from its href */
+ /* If not, resize the foremost widget */
+ dbg(lvl_debug, "Current GUI displayed is not a menu");
+ dbg(lvl_debug, "Will call resize with w=%d, h=%d", wnew, hnew)
+ gui_internal_menu_resize(this, wnew, hnew);
+ gui_internal_menu_render(this);
+ } else {
+ dbg(lvl_debug,"Current GUI displayed is a menu");
+ }
+ }
+ } else {
+ gui_internal_menu_render(this);
+ }
+ }
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gui_internal_resize(void *data, int w, int h)
-{
- struct gui_priv *this=data;
- int changed=0;
-
- gui_internal_setup(this);
-
- if (this->root.w != w || this->root.h != h) {
- this->root.w=w;
- this->root.h=h;
- changed=1;
- }
- /*
- * If we're drawing behind system bars on Android, watching for actual size changes will not catch
- * fullscreen toggle events. As a workaround, always assume a size change if padding is supplied.
- */
- if (!changed && this->gra && graphics_get_data(this->gra, "padding"))
- changed = 1;
- dbg(lvl_debug,"w=%d h=%d children=%p\n", w, h, this->root.children);
- navit_handle_resize(this->nav, w, h);
- if (this->root.children) {
- if (changed) {
- gui_internal_html_main_menu(this);
- } else {
- gui_internal_menu_render(this);
- }
- }
-}
-
-static void
-gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p)
-{
- p->x=w->p.x+w->w/2;
- p->y=w->p.y+w->h/2;
- if (dx < 0)
- p->x=w->p.x;
- if (dx > 0)
- p->x=w->p.x+w->w;
- if (dy < 0)
- p->y=w->p.y;
- if (dy > 0)
- p->y=w->p.y+w->h;
-}
-
-static struct widget*
-gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
- GList *l=wi->children;
- if (wi->state & STATE_OFFSCREEN)
- return NULL;
- if (wi->state & STATE_SENSITIVE)
- return wi;
- while (l) {
- struct widget* tmp = gui_internal_keynav_find_next_sensitive_child(l->data);
- if (tmp)
- return tmp;
- l=g_list_next(l);
- }
- return NULL;
-}
-
-static int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result) {
- GList *l=wi->children;
- if (wi == current_highlight)
- return 1;
- while (l) {
- struct widget *child=l->data;
- l=g_list_next(l);
- if (gui_internal_keynav_find_next(child, current_highlight, result)) {
- while (l) {
- struct widget *new = gui_internal_keynav_find_next_sensitive_child(l->data);
- if (new) {
- *result = new;
- /* Found one! */
- return 0;
- }
- l=g_list_next(l);
- }
- /* Try parent */
- return 1;
- }
- }
- return 0;
+static void gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p) {
+ p->x=w->p.x+w->w/2;
+ p->y=w->p.y+w->h/2;
+ if (dx < 0)
+ p->x=w->p.x;
+ if (dx > 0)
+ p->x=w->p.x+w->w;
+ if (dy < 0)
+ p->y=w->p.y;
+ if (dy > 0)
+ p->y=w->p.y+w->h;
+}
+
+static struct widget* gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
+ GList *l=wi->children;
+ if (wi->state & STATE_OFFSCREEN)
+ return NULL;
+ if (wi->state & STATE_SENSITIVE)
+ return wi;
+ while (l) {
+ struct widget* tmp = gui_internal_keynav_find_next_sensitive_child(l->data);
+ if (tmp)
+ return tmp;
+ l=g_list_next(l);
+ }
+ return NULL;
+}
+
+static int gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result) {
+ GList *l=wi->children;
+ if (wi == current_highlight)
+ return 1;
+ while (l) {
+ struct widget *child=l->data;
+ l=g_list_next(l);
+ if (gui_internal_keynav_find_next(child, current_highlight, result)) {
+ while (l) {
+ struct widget *new = gui_internal_keynav_find_next_sensitive_child(l->data);
+ if (new) {
+ *result = new;
+ /* Found one! */
+ return 0;
+ }
+ l=g_list_next(l);
+ }
+ /* Try parent */
+ return 1;
+ }
+ }
+ return 0;
}
#define RESULT_FOUND 1
#define NO_RESULT_YET 0
-static int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result) {
- if (wi == current_highlight && *result) {
- // Reached current widget; last widget found is the result.
- return RESULT_FOUND;
- }
- // If widget is off-screen, do not recurse into it.
- if (wi->state & STATE_OFFSCREEN)
- return NO_RESULT_YET;
- if (wi->state & STATE_SENSITIVE)
- *result= wi;
- GList *l=wi->children;
- while (l) {
- struct widget *child=l->data;
- if (gui_internal_keynav_find_prev(child, current_highlight, result) == RESULT_FOUND) {
- return RESULT_FOUND;
- }
- l=g_list_next(l);
- }
- // If no sensitive widget is found before "current_highlight", return the last sensitive widget when
- // recursion terminates.
- return NO_RESULT_YET;
-}
-
-static void
-gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int dy, int *distance, struct widget **result)
-{
- GList *l=wi->children;
- // Skip hidden elements
- if (wi->p.x==0 && wi->p.y==0 && wi->w==0 && wi->h==0)
- return;
- if ((wi->state & STATE_SENSITIVE) ) {
- int dist1,dist2;
- struct point wp;
- gui_internal_keynav_point(wi, -dx, -dy, &wp);
- if (dx) {
- dist1=(wp.x-p->x)*dx;
- dist2=wp.y-p->y;
- } else if (dy) {
- dist1=(wp.y-p->y)*dy;
- dist2=wp.x-p->x;
- } else {
- dist2=wp.x-p->x;
- dist1=wp.y-p->y;
- if (dist1 < 0)
- dist1=-dist1;
- }
- dbg(lvl_debug,"checking %d,%d %d %d against %d,%d-%d,%d result %d,%d\n", p->x, p->y, dx, dy, wi->p.x, wi->p.y, wi->p.x+wi->w, wi->p.y+wi->h, dist1, dist2);
- if (dist1 >= 0) {
- if (dist2 < 0)
- dist1-=dist2;
- else
- dist1+=dist2;
- if (dist1 < *distance) {
- *result=wi;
- *distance=dist1;
- }
- }
- }
- while (l) {
- struct widget *child=l->data;
- gui_internal_keynav_find_closest(child, p, dx, dy, distance, result);
- l=g_list_next(l);
- }
+static int gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result) {
+ if (wi == current_highlight && *result) {
+ // Reached current widget; last widget found is the result.
+ return RESULT_FOUND;
+ }
+ // If widget is off-screen, do not recurse into it.
+ if (wi->state & STATE_OFFSCREEN)
+ return NO_RESULT_YET;
+ if (wi->state & STATE_SENSITIVE)
+ *result= wi;
+ GList *l=wi->children;
+ while (l) {
+ struct widget *child=l->data;
+ if (gui_internal_keynav_find_prev(child, current_highlight, result) == RESULT_FOUND) {
+ return RESULT_FOUND;
+ }
+ l=g_list_next(l);
+ }
+ // If no sensitive widget is found before "current_highlight", return the last sensitive widget when
+ // recursion terminates.
+ return NO_RESULT_YET;
+}
+
+static void gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int dy, int *distance,
+ struct widget **result) {
+ GList *l=wi->children;
+ // Skip hidden elements
+ if (wi->p.x==0 && wi->p.y==0 && wi->w==0 && wi->h==0)
+ return;
+ if ((wi->state & STATE_SENSITIVE) ) {
+ int dist1,dist2;
+ struct point wp;
+ gui_internal_keynav_point(wi, -dx, -dy, &wp);
+ if (dx) {
+ dist1=(wp.x-p->x)*dx;
+ dist2=wp.y-p->y;
+ } else if (dy) {
+ dist1=(wp.y-p->y)*dy;
+ dist2=wp.x-p->x;
+ } else {
+ dist2=wp.x-p->x;
+ dist1=wp.y-p->y;
+ if (dist1 < 0)
+ dist1=-dist1;
+ }
+ dbg(lvl_debug,"checking %d,%d %d %d against %d,%d-%d,%d result %d,%d", p->x, p->y, dx, dy, wi->p.x, wi->p.y,
+ wi->p.x+wi->w, wi->p.y+wi->h, dist1, dist2);
+ if (dist1 >= 0) {
+ if (dist2 < 0)
+ dist1-=dist2;
+ else
+ dist1+=dist2;
+ if (dist1 < *distance) {
+ *result=wi;
+ *distance=dist1;
+ }
+ }
+ }
+ while (l) {
+ struct widget *child=l->data;
+ gui_internal_keynav_find_closest(child, p, dx, dy, distance, result);
+ l=g_list_next(l);
+ }
}
/**
@@ -2836,59 +2713,56 @@ gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int
* @param rotary (0/1) input from rotary encoder - dx indicates forwards/backwards movement
* through all widgets
*/
-static void
-gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary)
-{
- struct widget *result,*menu=g_list_last(this->root.children)->data;
- struct widget *current_highlight = NULL;
- struct point p;
- int distance;
- if (this->highlighted && this->highlighted_menu == menu) {
- gui_internal_keynav_point(this->highlighted, dx, dy, &p);
- current_highlight = this->highlighted;
- }
- else {
- p.x=0;
- p.y=0;
- distance=INT_MAX;
- result=NULL;
- gui_internal_keynav_find_closest(menu, &p, 0, 0, &distance, &result);
- if (result) {
- gui_internal_keynav_point(result, dx, dy, &p);
- dbg(lvl_debug,"result origin=%p p=%d,%d\n", result, p.x, p.y);
- current_highlight = result;
- }
- }
- result=NULL;
- distance=INT_MAX;
- if (rotary && dx > 0)
- gui_internal_keynav_find_next(menu, current_highlight, &result);
- else if (rotary && dx < 0)
- gui_internal_keynav_find_prev(menu, current_highlight, &result);
- else
- gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
- dbg(lvl_debug,"result=%p\n", result);
- if (! result) {
- if (dx < 0) {
- p.x=this->root.w;
- if (rotary) p.y = this->root.h;
- }
- if (dx > 0) {
- p.x=0;
- if (rotary) p.y = 0;
- }
- if (dy < 0)
- p.y=this->root.h;
- if (dy > 0)
- p.y=0;
- result=NULL;
- distance=INT_MAX;
- gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
- dbg(lvl_debug,"wraparound result=%p\n", result);
- }
- gui_internal_highlight_do(this, result);
- if (result)
- gui_internal_say(this, result, 1);
+static void gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary) {
+ struct widget *result,*menu=g_list_last(this->root.children)->data;
+ struct widget *current_highlight = NULL;
+ struct point p;
+ int distance;
+ if (this->highlighted && this->highlighted_menu == menu) {
+ gui_internal_keynav_point(this->highlighted, dx, dy, &p);
+ current_highlight = this->highlighted;
+ } else {
+ p.x=0;
+ p.y=0;
+ distance=INT_MAX;
+ result=NULL;
+ gui_internal_keynav_find_closest(menu, &p, 0, 0, &distance, &result);
+ if (result) {
+ gui_internal_keynav_point(result, dx, dy, &p);
+ dbg(lvl_debug,"result origin=%p p=%d,%d", result, p.x, p.y);
+ current_highlight = result;
+ }
+ }
+ result=NULL;
+ distance=INT_MAX;
+ if (rotary && dx > 0)
+ gui_internal_keynav_find_next(menu, current_highlight, &result);
+ else if (rotary && dx < 0)
+ gui_internal_keynav_find_prev(menu, current_highlight, &result);
+ else
+ gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
+ dbg(lvl_debug,"result=%p", result);
+ if (! result) {
+ if (dx < 0) {
+ p.x=this->root.w;
+ if (rotary) p.y = this->root.h;
+ }
+ if (dx > 0) {
+ p.x=0;
+ if (rotary) p.y = 0;
+ }
+ if (dy < 0)
+ p.y=this->root.h;
+ if (dy > 0)
+ p.y=0;
+ result=NULL;
+ distance=INT_MAX;
+ gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
+ dbg(lvl_debug,"wraparound result=%p", result);
+ }
+ gui_internal_highlight_do(this, result);
+ if (result)
+ gui_internal_say(this, result, 1);
}
//##############################################################################################################
@@ -2896,87 +2770,86 @@ gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int ro
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gui_internal_keypress(void *data, char *key)
-{
- struct gui_priv *this=data;
- int w,h;
- struct point p;
- if (!this->root.children) {
- transform_get_size(navit_get_trans(this->nav), &w, &h);
- switch (*key) {
- case NAVIT_KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_ZOOM_IN:
- navit_zoom_in(this->nav, 2, NULL);
- break;
- case NAVIT_KEY_ZOOM_OUT:
- navit_zoom_out(this->nav, 2, NULL);
- break;
- case NAVIT_KEY_RETURN:
- case NAVIT_KEY_MENU:
- gui_internal_set_click_coord(this, NULL);
- gui_internal_cmd_menu(this, 0, NULL);
- break;
- }
- return;
- }
- graphics_draw_mode(this->gra, draw_mode_begin);
- switch (*key) {
- case NAVIT_KEY_PAGE_DOWN:
- gui_internal_keynav_highlight_next(this,1,0,1);
- break;
- case NAVIT_KEY_PAGE_UP:
- gui_internal_keynav_highlight_next(this,-1,0,1);
- break;
- case NAVIT_KEY_LEFT:
- gui_internal_keynav_highlight_next(this,-1,0,0);
- break;
- case NAVIT_KEY_RIGHT:
- gui_internal_keynav_highlight_next(this,1,0,0);
- break;
- case NAVIT_KEY_UP:
- gui_internal_keynav_highlight_next(this,0,-1,0);
- break;
- case NAVIT_KEY_DOWN:
- gui_internal_keynav_highlight_next(this,0,1,0);
- break;
- case NAVIT_KEY_BACK:
- if (g_list_length(this->root.children) > 1)
- gui_internal_back(this, NULL, NULL);
- else
- gui_internal_prune_menu(this, NULL);
- break;
- case NAVIT_KEY_RETURN:
- if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
- gui_internal_call_highlighted(this);
- else
- gui_internal_keypress_do(this, key);
- break;
- default:
- gui_internal_keypress_do(this, key);
- }
- if (!event_main_loop_has_quit()) {
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_check_exit(this);
- }
+static void gui_internal_keypress(void *data, char *key) {
+ struct gui_priv *this=data;
+ int w,h;
+ struct point p;
+ if (!this->root.children) {
+ transform_get_size(navit_get_trans(this->nav), &w, &h);
+ switch (*key) {
+ case NAVIT_KEY_UP:
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_DOWN:
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_LEFT:
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_RIGHT:
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_ZOOM_IN:
+ navit_zoom_in(this->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_ZOOM_OUT:
+ navit_zoom_out(this->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_RETURN:
+ case NAVIT_KEY_MENU:
+ gui_internal_set_click_coord(this, NULL);
+ gui_internal_cmd_menu(this, 0, NULL);
+ break;
+ }
+ return;
+ }
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ switch (*key) {
+ case NAVIT_KEY_PAGE_DOWN:
+ gui_internal_keynav_highlight_next(this,1,0,1);
+ break;
+ case NAVIT_KEY_PAGE_UP:
+ gui_internal_keynav_highlight_next(this,-1,0,1);
+ break;
+ case NAVIT_KEY_LEFT:
+ gui_internal_keynav_highlight_next(this,-1,0,0);
+ break;
+ case NAVIT_KEY_RIGHT:
+ gui_internal_keynav_highlight_next(this,1,0,0);
+ break;
+ case NAVIT_KEY_UP:
+ gui_internal_keynav_highlight_next(this,0,-1,0);
+ break;
+ case NAVIT_KEY_DOWN:
+ gui_internal_keynav_highlight_next(this,0,1,0);
+ break;
+ case NAVIT_KEY_BACK:
+ if (g_list_length(this->root.children) > 1)
+ gui_internal_back(this, NULL, NULL);
+ else
+ gui_internal_prune_menu(this, NULL);
+ break;
+ case NAVIT_KEY_RETURN:
+ if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
+ gui_internal_call_highlighted(this);
+ else
+ gui_internal_keypress_do(this, key);
+ break;
+ default:
+ gui_internal_keypress_do(this, key);
+ }
+ if (!event_main_loop_has_quit()) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_check_exit(this);
+ }
}
@@ -2985,45 +2858,43 @@ static void gui_internal_keypress(void *data, char *key)
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra)
-{
- struct window *win;
- struct transformation *trans=navit_get_trans(this->nav);
-
- win=graphics_get_data(gra, "window");
- if (! win) {
- dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics\n");
- return 1;
- }
- navit_ignore_graphics_events(this->nav, 1);
- this->gra=gra;
- this->win=win;
- navit_ignore_graphics_events(this->nav, 1);
- transform_get_size(trans, &this->root.w, &this->root.h);
- this->resize_cb=callback_new_attr_1(callback_cast(gui_internal_resize), attr_resize, this);
- graphics_add_callback(gra, this->resize_cb);
- this->button_cb=callback_new_attr_1(callback_cast(gui_internal_button), attr_button, this);
- graphics_add_callback(gra, this->button_cb);
- this->motion_cb=callback_new_attr_1(callback_cast(gui_internal_motion), attr_motion, this);
- graphics_add_callback(gra, this->motion_cb);
- this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
- graphics_add_callback(gra, this->keypress_cb);
- this->window_closed_cb=callback_new_attr_1(callback_cast(gui_internal_window_closed), attr_window_closed, this);
- graphics_add_callback(gra, this->window_closed_cb);
-
- // set fullscreen if needed
- if (this->fullscreen)
- this->win->fullscreen(this->win, this->fullscreen != 0);
- /* Was resize callback already issued? */
- if (navit_get_ready(this->nav) & 2)
- gui_internal_setup(this);
- return 0;
-}
-
-static void gui_internal_disable_suspend(struct gui_priv *this)
-{
- if (this->win->disable_suspend)
- this->win->disable_suspend(this->win);
+static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra) {
+ struct window *win;
+ struct transformation *trans=navit_get_trans(this->nav);
+
+ win=graphics_get_data(gra, "window");
+ if (! win) {
+ dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics");
+ return 1;
+ }
+ navit_ignore_graphics_events(this->nav, 1);
+ this->gra=gra;
+ this->win=win;
+ navit_ignore_graphics_events(this->nav, 1);
+ transform_get_size(trans, &this->root.w, &this->root.h);
+ this->resize_cb=callback_new_attr_1(callback_cast(gui_internal_resize), attr_resize, this);
+ graphics_add_callback(gra, this->resize_cb);
+ this->button_cb=callback_new_attr_1(callback_cast(gui_internal_button), attr_button, this);
+ graphics_add_callback(gra, this->button_cb);
+ this->motion_cb=callback_new_attr_1(callback_cast(gui_internal_motion), attr_motion, this);
+ graphics_add_callback(gra, this->motion_cb);
+ this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
+ graphics_add_callback(gra, this->keypress_cb);
+ this->window_closed_cb=callback_new_attr_1(callback_cast(gui_internal_window_closed), attr_window_closed, this);
+ graphics_add_callback(gra, this->window_closed_cb);
+
+ // set fullscreen if needed
+ if (this->fullscreen)
+ this->win->fullscreen(this->win, this->fullscreen != 0);
+ /* Was resize callback already issued? */
+ if (navit_get_ready(this->nav) & 2)
+ gui_internal_setup(this);
+ return 0;
+}
+
+static void gui_internal_disable_suspend(struct gui_priv *this) {
+ if (this->win->disable_suspend)
+ this->win->disable_suspend(this->win);
}
//##############################################################################################################
@@ -3032,181 +2903,159 @@ static void gui_internal_disable_suspend(struct gui_priv *this)
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct gui_methods gui_internal_methods = {
- NULL,
- NULL,
- gui_internal_set_graphics,
- NULL,
- NULL,
- NULL,
- gui_internal_disable_suspend,
- gui_internal_get_attr,
- gui_internal_add_attr,
- gui_internal_set_attr,
+ NULL,
+ NULL,
+ gui_internal_set_graphics,
+ NULL,
+ NULL,
+ NULL,
+ gui_internal_disable_suspend,
+ gui_internal_get_attr,
+ gui_internal_add_attr,
+ gui_internal_set_attr,
};
-static void
-gui_internal_add_callback(struct gui_priv *priv, struct callback *cb)
-{
- callback_list_add(priv->cbl, cb);
+static void gui_internal_add_callback(struct gui_priv *priv, struct callback *cb) {
+ callback_list_add(priv->cbl, cb);
}
-static void
-gui_internal_remove_callback(struct gui_priv *priv, struct callback *cb)
-{
- callback_list_remove(priv->cbl, cb);
+static void gui_internal_remove_callback(struct gui_priv *priv, struct callback *cb) {
+ callback_list_remove(priv->cbl, cb);
}
static struct gui_internal_methods gui_internal_methods_ext = {
- gui_internal_add_callback,
- gui_internal_remove_callback,
- gui_internal_menu_render,
- image_new_xs,
- image_new_l,
+ gui_internal_add_callback,
+ gui_internal_remove_callback,
+ gui_internal_menu_render,
+ image_new_xs,
+ image_new_l,
};
-static enum flags
-gui_internal_get_flags(struct widget *widget)
-{
- return widget->flags;
+static enum flags gui_internal_get_flags(struct widget *widget) {
+ return widget->flags;
}
-static void
-gui_internal_set_flags(struct widget *widget, enum flags flags)
-{
- widget->flags=flags;
+static void gui_internal_set_flags(struct widget *widget, enum flags flags) {
+ widget->flags=flags;
}
-static int
-gui_internal_get_state(struct widget *widget)
-{
- return widget->state;
+static int gui_internal_get_state(struct widget *widget) {
+ return widget->state;
}
-static void
-gui_internal_set_state(struct widget *widget, int state)
-{
- widget->state=state;
+static void gui_internal_set_state(struct widget *widget, int state) {
+ widget->state=state;
}
-static void
-gui_internal_set_func(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data))
-{
- widget->func=func;
+static void gui_internal_set_func(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget,
+ void *data)) {
+ widget->func=func;
}
-static void
-gui_internal_set_data(struct widget *widget, void *data)
-{
- widget->data=data;
+static void gui_internal_set_data(struct widget *widget, void *data) {
+ widget->data=data;
}
-static void
-gui_internal_set_default_background(struct gui_priv *this, struct widget *widget)
-{
- widget->background=this->background;
+static void gui_internal_set_default_background(struct gui_priv *this, struct widget *widget) {
+ widget->background=this->background;
}
static struct gui_internal_widget_methods gui_internal_widget_methods = {
- gui_internal_widget_append,
- gui_internal_button_new,
- gui_internal_button_new_with_callback,
- gui_internal_box_new,
- gui_internal_label_new,
- gui_internal_image_new,
- gui_internal_keyboard,
- gui_internal_menu,
- gui_internal_get_flags,
- gui_internal_set_flags,
- gui_internal_get_state,
- gui_internal_set_state,
- gui_internal_set_func,
- gui_internal_set_data,
- gui_internal_set_default_background,
+ gui_internal_widget_append,
+ gui_internal_button_new,
+ gui_internal_button_new_with_callback,
+ gui_internal_box_new,
+ gui_internal_label_new,
+ gui_internal_image_new,
+ gui_internal_keyboard,
+ gui_internal_menu,
+ gui_internal_get_flags,
+ gui_internal_set_flags,
+ gui_internal_get_state,
+ gui_internal_set_state,
+ gui_internal_set_func,
+ gui_internal_set_data,
+ gui_internal_set_default_background,
};
/**
* @brief finds the intersection point of 2 lines
*
- * @param coord a1, a2, b1, b2 : coords of the start and
+ * @param coord a1, a2, b1, b2 : coords of the start and
* end of the first and the second line
* @param coord res, will become the coords of the intersection if found
* @return : TRUE if intersection found, otherwise FALSE
*/
-int
-line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res)
-{
- int n, a, b;
- int adx=a2->x-a1->x;
- int ady=a2->y-a1->y;
- int bdx=b2->x-b1->x;
- int bdy=b2->y-b1->y;
- n = bdy * adx - bdx * ady;
- a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
- b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
- if (n < 0) {
- n = -n;
- a = -a;
- b = -b;
- }
- if (a < 0 || b < 0)
- return FALSE;
- if (a > n || b > n)
- return FALSE;
- if (n == 0) {
- dbg(lvl_info,"a=%d b=%d n=%d\n", a, b, n);
- dbg(lvl_info,"a1=0x%x,0x%x ad %d,%d\n", a1->x, a1->y, adx, ady);
- dbg(lvl_info,"b1=0x%x,0x%x bd %d,%d\n", b1->x, b1->y, bdx, bdy);
- dbg(lvl_info,"No intersection found, lines assumed parallel ?\n");
- return FALSE;
- }
- res->x = a1->x + a * adx / n;
- res->y = a1->y + a * ady / n;
- return TRUE;
+int line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res) {
+ int n, a, b;
+ int adx=a2->x-a1->x;
+ int ady=a2->y-a1->y;
+ int bdx=b2->x-b1->x;
+ int bdy=b2->y-b1->y;
+ n = bdy * adx - bdx * ady;
+ a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
+ b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
+ if (n < 0) {
+ n = -n;
+ a = -a;
+ b = -b;
+ }
+ if (a < 0 || b < 0)
+ return FALSE;
+ if (a > n || b > n)
+ return FALSE;
+ if (n == 0) {
+ dbg(lvl_info,"a=%d b=%d n=%d", a, b, n);
+ dbg(lvl_info,"a1=0x%x,0x%x ad %d,%d", a1->x, a1->y, adx, ady);
+ dbg(lvl_info,"b1=0x%x,0x%x bd %d,%d", b1->x, b1->y, bdx, bdy);
+ dbg(lvl_info,"No intersection found, lines assumed parallel ?");
+ return FALSE;
+ }
+ res->x = a1->x + a * adx / n;
+ res->y = a1->y + a * ady / n;
+ return TRUE;
}
struct heightline *
-item_get_heightline(struct item *item)
-{
- struct heightline *ret=NULL;
- struct street_data *sd;
- struct attr attr;
- int i,height;
-
- if (item_attr_get(item, attr_label, &attr)) {
- height=atoi(attr.u.str);
- sd=street_get_data(item);
- if (sd && sd->count > 1) {
- ret=g_malloc(sizeof(struct heightline)+sd->count*sizeof(struct coord));
- ret->bbox.lu=sd->c[0];
- ret->bbox.rl=sd->c[0];
- ret->count=sd->count;
- ret->height=height;
- for (i = 0 ; i < sd->count ; i++) {
- ret->c[i]=sd->c[i];
- coord_rect_extend(&ret->bbox, sd->c+i);
- }
- }
- street_data_free(sd);
- }
- return ret;
+item_get_heightline(struct item *item) {
+ struct heightline *ret=NULL;
+ struct street_data *sd;
+ struct attr attr;
+ int i,height;
+
+ if (item_attr_get(item, attr_label, &attr)) {
+ height=atoi(attr.u.str);
+ sd=street_get_data(item);
+ if (sd && sd->count > 1) {
+ ret=g_malloc(sizeof(struct heightline)+sd->count*sizeof(struct coord));
+ ret->bbox.lu=sd->c[0];
+ ret->bbox.rl=sd->c[0];
+ ret->count=sd->count;
+ ret->height=height;
+ for (i = 0 ; i < sd->count ; i++) {
+ ret->c[i]=sd->c[i];
+ coord_rect_extend(&ret->bbox, sd->c+i);
+ }
+ }
+ street_data_free(sd);
+ }
+ return ret;
}
/**
* @brief Called when the route is updated.
*/
-void
-gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct vehicle *v)
-{
+void gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct vehicle *v) {
- if(this->route_data.route_showing) {
- gui_internal_populate_route_table(this,navit);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
+ if(this->route_data.route_showing) {
+ gui_internal_populate_route_table(this,navit);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ }
}
@@ -3218,14 +3067,12 @@ gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct v
* The main purpose of this function is to remove the widgets from
* references route_data because those widgets are about to be freed.
*/
-void
-gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w)
-{
- if(this_) {
- this_->route_data.route_showing=0;
- this_->route_data.route_table=NULL;
- g_free(w);
- }
+void gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w) {
+ if(this_) {
+ this_->route_data.route_showing=0;
+ this_->route_data.route_table=NULL;
+ g_free(w);
+ }
}
@@ -3235,85 +3082,83 @@ gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w)
* @param this The gui context
* @param navit The navit object
*/
-void
-gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit)
-{
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct navigation * nav = NULL;
- struct item * item =NULL;
- struct attr attr,route;
- struct widget * label = NULL;
- struct widget * row = NULL;
- struct coord c;
- nav = navit_get_navigation(navit);
- if(!nav) {
- return;
- }
- map = navigation_get_map(nav);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr) {
- GList *toprow;
- struct item topitem={0};
- toprow=gui_internal_widget_table_top_row(this, this->route_data.route_table);
- if(toprow && toprow->data)
- topitem=((struct widget*)toprow->data)->item;
- gui_internal_widget_table_clear(this,this->route_data.route_table);
- if (navit_get_attr(navit, attr_route, &route, NULL)) {
- struct attr destination_length, destination_time;
- char *length=NULL,*time=NULL,*length_time;
- if (route_get_attr(route.u.route, attr_destination_length, &destination_length, NULL))
- length=attr_to_text_ext(&destination_length, NULL, attr_format_with_units, attr_format_default, NULL);
- if (route_get_attr(route.u.route, attr_destination_time, &destination_time, NULL))
- time=attr_to_text_ext(&destination_time, NULL, attr_format_with_units, attr_format_default, NULL);
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(this->route_data.route_table,row);
- length_time=g_strdup_printf("%s %s",length,time);
- label = gui_internal_label_new(this,length_time);
- g_free(length_time);
- g_free(length);
- g_free(time);
- gui_internal_widget_append(row,label);
- }
- while((item = map_rect_get_item(mr))) {
- if(item_attr_get(item,attr_navigation_long,&attr)) {
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(this->route_data.route_table,row);
-
- label = gui_internal_label_new(this,map_convert_string_tmp(item->map,attr.u.str));
- gui_internal_widget_append(row,label);
-
- label->item=*item;
- row->item=*item;
- item_coord_get(item, &c, 1);
- label->c.x=c.x;
- label->c.y=c.y;
- label->c.pro=map_projection(map);
- label->func=gui_internal_cmd_position;
- label->state|=STATE_SENSITIVE;
- label->data=(void*)2;
- if(toprow && item->id_hi==topitem.id_hi && item->id_lo==topitem.id_lo && item->map==topitem.map)
- gui_internal_widget_table_set_top_row(this, this->route_data.route_table, row);
- }
-
- }
- map_rect_destroy(mr);
- }
+void gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit) {
+ struct map * map=NULL;
+ struct map_rect * mr=NULL;
+ struct navigation * nav = NULL;
+ struct item * item =NULL;
+ struct attr attr,route;
+ struct widget * label = NULL;
+ struct widget * row = NULL;
+ struct coord c;
+ nav = navit_get_navigation(navit);
+ if(!nav) {
+ return;
+ }
+ map = navigation_get_map(nav);
+ if(map)
+ mr = map_rect_new(map,NULL);
+ if(mr) {
+ GList *toprow;
+ struct item topitem= {0};
+ toprow=gui_internal_widget_table_top_row(this, this->route_data.route_table);
+ if(toprow && toprow->data)
+ topitem=((struct widget*)toprow->data)->item;
+ gui_internal_widget_table_clear(this,this->route_data.route_table);
+ if (navit_get_attr(navit, attr_route, &route, NULL)) {
+ struct attr destination_length, destination_time;
+ char *length=NULL,*time=NULL,*length_time;
+ if (route_get_attr(route.u.route, attr_destination_length, &destination_length, NULL))
+ length=attr_to_text_ext(&destination_length, NULL, attr_format_with_units, attr_format_default, NULL);
+ if (route_get_attr(route.u.route, attr_destination_time, &destination_time, NULL))
+ time=attr_to_text_ext(&destination_time, NULL, attr_format_with_units, attr_format_default, NULL);
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ gui_internal_widget_append(this->route_data.route_table,row);
+ length_time=g_strdup_printf("%s %s",length,time);
+ label = gui_internal_label_new(this,length_time);
+ g_free(length_time);
+ g_free(length);
+ g_free(time);
+ gui_internal_widget_append(row,label);
+ }
+ while((item = map_rect_get_item(mr))) {
+ if(item_attr_get(item,attr_navigation_long,&attr)) {
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ gui_internal_widget_append(this->route_data.route_table,row);
+
+ label = gui_internal_label_new(this,map_convert_string_tmp(item->map,attr.u.str));
+ gui_internal_widget_append(row,label);
+
+ label->item=*item;
+ row->item=*item;
+ item_coord_get(item, &c, 1);
+ label->c.x=c.x;
+ label->c.y=c.y;
+ label->c.pro=map_projection(map);
+ label->func=gui_internal_cmd_position;
+ label->state|=STATE_SENSITIVE;
+ label->data=(void*)2;
+ if(toprow && item->id_hi==topitem.id_hi && item->id_lo==topitem.id_lo && item->map==topitem.map)
+ gui_internal_widget_table_set_top_row(this, this->route_data.route_table, row);
+ }
+
+ }
+ map_rect_destroy(mr);
+ }
}
/*
- * Command interface wrapper for commands which can be used both from gui html and to enter internal gui (for example, from osd or dbus).
+ * Command interface wrapper for commands which can be used both from gui html and to enter internal gui (for example, from osd or dbus).
* Set first command argument to integer 1, if this command was called by mouse click from oustside of gui (default). Set it to 0
* if command is called by some other means (dbus signal, for example). If first argument is non integer, it's passed on
* to actual handler.
- *
+ *
*/
@@ -3322,142 +3167,126 @@ gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit)
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct color color_white={0xffff,0xffff,0xffff,0xffff};
- struct color color_black={0x0,0x0,0x0,0xffff};
- struct color back2_color={0x4141,0x4141,0x4141,0xffff};
-
- struct gui_priv *this;
- struct attr *attr;
- *meth=gui_internal_methods;
- this=g_new0(struct gui_priv, 1);
- this->nav=nav;
-
- this->self.type=attr_gui;
- this->self.u.gui=gui;
-
- if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click)))
- this->menu_on_map_click=attr->u.num;
- else
- this->menu_on_map_click=1;
-
- if ((attr=attr_search(attrs, NULL, attr_on_map_click)))
- this->on_map_click=g_strdup(attr->u.str);
-
- if ((attr=attr_search(attrs, NULL, attr_signal_on_map_click)))
- this->signal_on_map_click=attr->u.num;
- gui_internal_command_init(this, attrs);
-
- if( (attr=attr_search(attrs,NULL,attr_font_size)))
- {
- this->config.font_size=attr->u.num;
- }
- else
- {
- this->config.font_size=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_xs)))
- {
- this->config.icon_xs=attr->u.num;
- }
- else
- {
- this->config.icon_xs=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_l)))
- {
- this->config.icon_l=attr->u.num;
- }
- else
- {
- this->config.icon_l=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_s)))
- {
- this->config.icon_s=attr->u.num;
- }
- else
- {
- this->config.icon_s=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_spacing)))
- {
- this->config.spacing=attr->u.num;
- }
- else
- {
- this->config.spacing=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_gui_speech)))
- {
- this->speech=attr->u.num;
- }
- if( (attr=attr_search(attrs,NULL,attr_keyboard)))
- this->keyboard=attr->u.num;
- else
- this->keyboard=1;
+static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs,
+ struct gui *gui) {
+ struct color color_white= {0xffff,0xffff,0xffff,0xffff};
+ struct color color_black= {0x0,0x0,0x0,0xffff};
+ struct color back2_color= {0x4141,0x4141,0x4141,0xffff};
+
+ struct gui_priv *this;
+ struct attr *attr;
+ *meth=gui_internal_methods;
+ this=g_new0(struct gui_priv, 1);
+ this->nav=nav;
+
+ this->self.type=attr_gui;
+ this->self.u.gui=gui;
+
+ if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click)))
+ this->menu_on_map_click=attr->u.num;
+ else
+ this->menu_on_map_click=1;
+
+ if ((attr=attr_search(attrs, NULL, attr_on_map_click)))
+ this->on_map_click=g_strdup(attr->u.str);
+
+ if ((attr=attr_search(attrs, NULL, attr_signal_on_map_click)))
+ this->signal_on_map_click=attr->u.num;
+ gui_internal_command_init(this, attrs);
+
+ if( (attr=attr_search(attrs,NULL,attr_font_size))) {
+ this->config.font_size=attr->u.num;
+ } else {
+ this->config.font_size=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_icon_xs))) {
+ this->config.icon_xs=attr->u.num;
+ } else {
+ this->config.icon_xs=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_icon_l))) {
+ this->config.icon_l=attr->u.num;
+ } else {
+ this->config.icon_l=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_icon_s))) {
+ this->config.icon_s=attr->u.num;
+ } else {
+ this->config.icon_s=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_spacing))) {
+ this->config.spacing=attr->u.num;
+ } else {
+ this->config.spacing=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_gui_speech))) {
+ this->speech=attr->u.num;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_keyboard)))
+ this->keyboard=attr->u.num;
+ else
+ this->keyboard=1;
if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
- this->fullscreen=attr->u.num;
-
- if( (attr=attr_search(attrs,NULL,attr_flags)))
- this->flags=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_background_color)))
- this->background_color=*attr->u.color;
- else
- this->background_color=color_black;
- if( (attr=attr_search(attrs,NULL,attr_background_color2)))
- this->background2_color=*attr->u.color;
- else
- this->background2_color=back2_color;
- if( (attr=attr_search(attrs,NULL,attr_text_color)))
- this->text_foreground_color=*attr->u.color;
- else
- this->text_foreground_color=color_white;
- if( (attr=attr_search(attrs,NULL,attr_text_background)))
- this->text_background_color=*attr->u.color;
- else
- this->text_background_color=color_black;
- if( (attr=attr_search(attrs,NULL,attr_columns)))
- this->cols=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
- this->osd_configuration=*attr;
-
- if( (attr=attr_search(attrs,NULL,attr_pitch)))
- this->pitch=attr->u.num;
- else
- this->pitch=20;
- if( (attr=attr_search(attrs,NULL,attr_flags_town)))
- this->flags_town=attr->u.num;
- else
- this->flags_town=-1;
- if( (attr=attr_search(attrs,NULL,attr_flags_street)))
- this->flags_street=attr->u.num;
- else
- this->flags_street=-1;
- if( (attr=attr_search(attrs,NULL,attr_flags_house_number)))
- this->flags_house_number=attr->u.num;
- else
- this->flags_house_number=-1;
- if( (attr=attr_search(attrs,NULL,attr_radius)))
- this->radius=attr->u.num;
- else
- this->radius=10;
- if( (attr=attr_search(attrs,NULL,attr_font)))
- this->font_name=g_strdup(attr->u.str);
-
- if((attr=attr_search(attrs, NULL, attr_hide_impossible_next_keys)))
- this->hide_keys = attr->u.num;
- else
- this->hide_keys = 0;
-
- this->data.priv=this;
- this->data.gui=&gui_internal_methods_ext;
- this->data.widget=&gui_internal_widget_methods;
- this->cbl=callback_list_new();
-
- return this;
+ this->fullscreen=attr->u.num;
+
+ if( (attr=attr_search(attrs,NULL,attr_flags)))
+ this->flags=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_background_color)))
+ this->background_color=*attr->u.color;
+ else
+ this->background_color=color_black;
+ if( (attr=attr_search(attrs,NULL,attr_background_color2)))
+ this->background2_color=*attr->u.color;
+ else
+ this->background2_color=back2_color;
+ if( (attr=attr_search(attrs,NULL,attr_text_color)))
+ this->text_foreground_color=*attr->u.color;
+ else
+ this->text_foreground_color=color_white;
+ if( (attr=attr_search(attrs,NULL,attr_text_background)))
+ this->text_background_color=*attr->u.color;
+ else
+ this->text_background_color=color_black;
+ if( (attr=attr_search(attrs,NULL,attr_columns)))
+ this->cols=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
+ this->osd_configuration=*attr;
+
+ if( (attr=attr_search(attrs,NULL,attr_pitch)))
+ this->pitch=attr->u.num;
+ else
+ this->pitch=20;
+ if( (attr=attr_search(attrs,NULL,attr_flags_town)))
+ this->flags_town=attr->u.num;
+ else
+ this->flags_town=-1;
+ if( (attr=attr_search(attrs,NULL,attr_flags_street)))
+ this->flags_street=attr->u.num;
+ else
+ this->flags_street=-1;
+ if( (attr=attr_search(attrs,NULL,attr_flags_house_number)))
+ this->flags_house_number=attr->u.num;
+ else
+ this->flags_house_number=-1;
+ if( (attr=attr_search(attrs,NULL,attr_radius)))
+ this->radius=attr->u.num;
+ else
+ this->radius=10;
+ if( (attr=attr_search(attrs,NULL,attr_font)))
+ this->font_name=g_strdup(attr->u.str);
+
+ if((attr=attr_search(attrs, NULL, attr_hide_impossible_next_keys)))
+ this->hide_keys = attr->u.num;
+ else
+ this->hide_keys = 0;
+
+ this->data.priv=this;
+ this->data.gui=&gui_internal_methods_ext;
+ this->data.widget=&gui_internal_widget_methods;
+ this->cbl=callback_list_new();
+
+ return this;
}
//##############################################################################################################
@@ -3465,7 +3294,6 @@ static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void plugin_init(void)
-{
- plugin_register_category_gui("internal", gui_internal_new);
+void plugin_init(void) {
+ plugin_register_category_gui("internal", gui_internal_new);
}
diff --git a/navit/gui/internal/gui_internal.h b/navit/gui/internal/gui_internal.h
index 1a5cd13d3..734d31d38 100644
--- a/navit/gui/internal/gui_internal.h
+++ b/navit/gui/internal/gui_internal.h
@@ -15,71 +15,72 @@ struct gui_priv;
#define GESTURE_RINGSIZE 100
enum widget_type {
- widget_box=1,
- widget_button,
- widget_label,
- widget_image,
- widget_table,
- widget_table_row
+ widget_box=1,
+ widget_button,
+ widget_label,
+ widget_image,
+ widget_table,
+ widget_table_row
};
enum flags {
- gravity_none=0x00,
- gravity_left=1,
- gravity_xcenter=2,
- gravity_right=4,
- gravity_top=8,
- gravity_ycenter=16,
- gravity_bottom=32,
- gravity_left_top=gravity_left|gravity_top,
- gravity_top_center=gravity_xcenter|gravity_top,
- gravity_right_top=gravity_right|gravity_top,
- gravity_left_center=gravity_left|gravity_ycenter,
- gravity_center=gravity_xcenter|gravity_ycenter,
- gravity_right_center=gravity_right|gravity_ycenter,
- gravity_left_bottom=gravity_left|gravity_bottom,
- gravity_bottom_center=gravity_xcenter|gravity_bottom,
- gravity_right_bottom=gravity_right|gravity_bottom,
- flags_expand=0x100,
- flags_fill=0x200,
- flags_swap=0x400,
- flags_scrollx=0x800,
- flags_scrolly=0x1000,
- orientation_horizontal=0x10000,
- orientation_vertical=0x20000,
- orientation_horizontal_vertical=0x40000,
+ gravity_none=0x00,
+ gravity_left=1,
+ gravity_xcenter=2,
+ gravity_right=4,
+ gravity_top=8,
+ gravity_ycenter=16,
+ gravity_bottom=32,
+ gravity_left_top=gravity_left|gravity_top,
+ gravity_top_center=gravity_xcenter|gravity_top,
+ gravity_right_top=gravity_right|gravity_top,
+ gravity_left_center=gravity_left|gravity_ycenter,
+ gravity_center=gravity_xcenter|gravity_ycenter,
+ gravity_right_center=gravity_right|gravity_ycenter,
+ gravity_left_bottom=gravity_left|gravity_bottom,
+ gravity_bottom_center=gravity_xcenter|gravity_bottom,
+ gravity_right_bottom=gravity_right|gravity_bottom,
+ flags_expand=0x100,
+ flags_fill=0x200,
+ flags_swap=0x400,
+ flags_scrollx=0x800,
+ flags_scrolly=0x1000,
+ orientation_horizontal=0x10000,
+ orientation_vertical=0x20000,
+ orientation_horizontal_vertical=0x40000,
};
struct gui_internal_methods {
- void (*add_callback)(struct gui_priv *priv, struct callback *cb);
- void (*remove_callback)(struct gui_priv *priv, struct callback *cb);
- void (*menu_render)(struct gui_priv *this);
- struct graphics_image * (*image_new_xs)(struct gui_priv *this, const char *name);
- struct graphics_image * (*image_new_l)(struct gui_priv *this, const char *name);
+ void (*add_callback)(struct gui_priv *priv, struct callback *cb);
+ void (*remove_callback)(struct gui_priv *priv, struct callback *cb);
+ void (*menu_render)(struct gui_priv *this);
+ struct graphics_image * (*image_new_xs)(struct gui_priv *this, const char *name);
+ struct graphics_image * (*image_new_l)(struct gui_priv *this, const char *name);
};
struct gui_internal_widget_methods {
- void (*append)(struct widget *parent, struct widget *child);
- struct widget * (*button_new)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
- struct widget * (*button_new_with_callback)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
- struct widget * (*box_new)(struct gui_priv *this, enum flags flags);
- struct widget * (*label_new)(struct gui_priv *this, const char *text);
- struct widget * (*image_new)(struct gui_priv *this, struct graphics_image *image);
- struct widget * (*keyboard)(struct gui_priv *this, int mode);
- struct widget * (*menu)(struct gui_priv *this, const char *label);
- enum flags (*get_flags)(struct widget *widget);
- void (*set_flags)(struct widget *widget, enum flags flags);
- int (*get_state)(struct widget *widget);
- void (*set_state)(struct widget *widget, int state);
- void (*set_func)(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data));
- void (*set_data)(struct widget *widget, void *data);
- void (*set_default_background)(struct gui_priv *this, struct widget *widget);
+ void (*append)(struct widget *parent, struct widget *child);
+ struct widget * (*button_new)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
+ struct widget * (*button_new_with_callback)(struct gui_priv *this, const char *text, struct graphics_image *image,
+ enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
+ struct widget * (*box_new)(struct gui_priv *this, enum flags flags);
+ struct widget * (*label_new)(struct gui_priv *this, const char *text);
+ struct widget * (*image_new)(struct gui_priv *this, struct graphics_image *image);
+ struct widget * (*keyboard)(struct gui_priv *this, int mode);
+ struct widget * (*menu)(struct gui_priv *this, const char *label);
+ enum flags (*get_flags)(struct widget *widget);
+ void (*set_flags)(struct widget *widget, enum flags flags);
+ int (*get_state)(struct widget *widget);
+ void (*set_state)(struct widget *widget, int state);
+ void (*set_func)(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data));
+ void (*set_data)(struct widget *widget, void *data);
+ void (*set_default_background)(struct gui_priv *this, struct widget *widget);
};
struct gui_internal_data {
- struct gui_priv *priv;
- struct gui_internal_methods *gui;
- struct gui_internal_widget_methods *widget;
+ struct gui_priv *priv;
+ struct gui_internal_methods *gui;
+ struct gui_internal_widget_methods *widget;
};
diff --git a/navit/gui/internal/gui_internal_bookmark.c b/navit/gui/internal/gui_internal_bookmark.c
index eed0de123..bedad9173 100644
--- a/navit/gui/internal/gui_internal_bookmark.c
+++ b/navit/gui/internal/gui_internal_bookmark.c
@@ -16,298 +16,276 @@
#include "gui_internal_keyboard.h"
#include "gui_internal_bookmark.h"
-static void
-gui_internal_cmd_add_bookmark_do(struct gui_priv *this, struct widget *widget)
-{
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", widget->text);
- if (widget->text && strlen(widget->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &widget->c, widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- l=g_list_previous(g_list_last(this->root.children));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_add_bookmark_do(struct gui_priv *this, struct widget *widget) {
+ GList *l;
+ struct attr attr;
+ dbg(lvl_debug,"text='%s'", widget->text);
+ if (widget->text && strlen(widget->text)) {
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, &widget->c, widget->text);
+ }
+ g_free(widget->text);
+ widget->text=NULL;
+ l=g_list_previous(g_list_last(this->root.children));
+ gui_internal_prune_menu(this, l->data);
}
-static void
-gui_internal_cmd_add_bookmark_folder_do(struct gui_priv *this, struct widget *widget)
-{
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", widget->text);
- if (widget->text && strlen(widget->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, NULL, widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_add_bookmark_folder_do(struct gui_priv *this, struct widget *widget) {
+ GList *l;
+ struct attr attr;
+ dbg(lvl_debug,"text='%s'", widget->text);
+ if (widget->text && strlen(widget->text)) {
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, NULL, widget->text);
+ }
+ g_free(widget->text);
+ widget->text=NULL;
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
-static void
-gui_internal_cmd_add_bookmark_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_add_bookmark_do(this, widget->data);
+static void gui_internal_cmd_add_bookmark_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_cmd_add_bookmark_do(this, widget->data);
}
-static void
-gui_internal_cmd_add_bookmark_folder_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_add_bookmark_folder_do(this, widget->data);
+static void gui_internal_cmd_add_bookmark_folder_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_cmd_add_bookmark_folder_do(this, widget->data);
}
-static void
-gui_internal_cmd_rename_bookmark_clicked(struct gui_priv *this, struct widget *widget,void *data)
-{
- struct widget *w=(struct widget*)widget->data;
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", w->text);
- if (w->text && strlen(w->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_rename_bookmark(attr.u.bookmarks, w->name, w->text);
- }
- g_free(w->text);
- g_free(w->name);
- w->text=NULL;
- w->name=NULL;
- l=g_list_previous(g_list_previous(g_list_previous(g_list_last(this->root.children))));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_rename_bookmark_clicked(struct gui_priv *this, struct widget *widget,void *data) {
+ struct widget *w=(struct widget*)widget->data;
+ GList *l;
+ struct attr attr;
+ dbg(lvl_debug,"text='%s'", w->text);
+ if (w->text && strlen(w->text)) {
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_rename_bookmark(attr.u.bookmarks, w->name, w->text);
+ }
+ g_free(w->text);
+ g_free(w->name);
+ w->text=NULL;
+ w->name=NULL;
+ l=g_list_previous(g_list_previous(g_list_previous(g_list_last(this->root.children))));
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_add_bookmark2(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=data;
- wb=gui_internal_menu(this,_("Add Bookmark"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_add_bookmark_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_add_bookmark2(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ char *name=data;
+ wb=gui_internal_menu(this,_("Add Bookmark"));
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ wk->c=wm->c;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_add_bookmark_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_add_bookmark_folder2(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=data;
- wb=gui_internal_menu(this,_("Add Bookmark folder"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_add_bookmark_folder_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_add_bookmark_folder2(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ char *name=data;
+ wb=gui_internal_menu(this,_("Add Bookmark folder"));
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ wk->c=wm->c;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_add_bookmark_folder_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_rename_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=wm->text;
- wb=gui_internal_menu(this,_("Rename"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- wk->name=g_strdup(name);
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_rename_bookmark_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_rename_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ char *name=wm->text;
+ wb=gui_internal_menu(this,_("Rename"));
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ wk->c=wm->c;
+ wk->name=g_strdup(name);
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_rename_bookmark_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_cut_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_cut_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_cut_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_cut_bookmark(mattr.u.bookmarks,wm->text);
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_copy_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_copy_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_copy_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_copy_bookmark(mattr.u.bookmarks,wm->text);
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_paste_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_paste_bookmark(mattr.u.bookmarks);
- l=g_list_previous(g_list_last(this->root.children));
- if(l)
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_paste_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_paste_bookmark(mattr.u.bookmarks);
+ l=g_list_previous(g_list_last(this->root.children));
+ if(l)
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_delete_bookmark_folder(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_move_up(mattr.u.bookmarks);
- bookmarks_delete_bookmark(mattr.u.bookmarks,wm->prefix);
- l=g_list_first(this->root.children);
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_delete_bookmark_folder(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_move_up(mattr.u.bookmarks);
+ bookmarks_delete_bookmark(mattr.u.bookmarks,wm->prefix);
+ l=g_list_first(this->root.children);
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_load_bookmarks_as_waypoints(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
+void gui_internal_cmd_load_bookmarks_as_waypoints(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- struct attr attr;
- struct item *item;
- struct coord c;
- struct pcoord *pc;
- enum projection pro=bookmarks_get_projection(mattr.u.bookmarks);
- int i, bm_count;
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ struct attr attr;
+ struct item *item;
+ struct coord c;
+ struct pcoord *pc;
+ enum projection pro=bookmarks_get_projection(mattr.u.bookmarks);
+ int i, bm_count;
- navit_set_destination(this->nav, NULL, NULL, 0);
+ navit_set_destination(this->nav, NULL, NULL, 0);
- bm_count=bookmarks_get_bookmark_count(mattr.u.bookmarks);
- pc=g_alloca(bm_count*sizeof(struct pcoord));
- bookmarks_item_rewind(mattr.u.bookmarks);
- i=0;
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr))
- continue;
- if (item->type == type_bookmark) {
- if (item_coord_get(item, &c, 1)) {
- pc[i].x=c.x;
- pc[i].y=c.y;
- pc[i].pro=pro;
- navit_add_destination_description(this->nav,&pc[i],attr.u.str);
- i++;
- }
- }
- }
- bm_count=i;
+ bm_count=bookmarks_get_bookmark_count(mattr.u.bookmarks);
+ pc=g_alloca(bm_count*sizeof(struct pcoord));
+ bookmarks_item_rewind(mattr.u.bookmarks);
+ i=0;
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ if (!item_attr_get(item, attr_label, &attr))
+ continue;
+ if (item->type == type_bookmark) {
+ if (item_coord_get(item, &c, 1)) {
+ pc[i].x=c.x;
+ pc[i].y=c.y;
+ pc[i].pro=pro;
+ navit_add_destination_description(this->nav,&pc[i],attr.u.str);
+ i++;
+ }
+ }
+ }
+ bm_count=i;
- if (bm_count>0){
- navit_set_destinations(this->nav, pc, bm_count, wm->prefix, 1);
- if (this->flags & 512) {
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=180;
- navit_set_attr(this->nav, &this->osd_configuration);
- navit_set_attr(this->nav, &follow);
- navit_zoom_to_route(this->nav, 0);
- }
- }
- }
+ if (bm_count>0) {
+ navit_set_destinations(this->nav, pc, bm_count, wm->prefix, 1);
+ if (this->flags & 512) {
+ struct attr follow;
+ follow.type=attr_follow;
+ follow.u.num=180;
+ navit_set_attr(this->nav, &this->osd_configuration);
+ navit_set_attr(this->nav, &follow);
+ navit_zoom_to_route(this->nav, 0);
+ }
+ }
+ }
- gui_internal_prune_menu(this, NULL);
+ gui_internal_prune_menu(this, NULL);
}
-void
-gui_internal_cmd_replace_bookmarks_from_waypoints(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
+void gui_internal_cmd_replace_bookmarks_from_waypoints(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- struct attr attr;
- char *desc=NULL;
- struct pcoord *pc;
- int i, bm_count;
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ struct attr attr;
+ char *desc=NULL;
+ struct pcoord *pc;
+ int i, bm_count;
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)>0){
- struct item *item;
- bookmarks_item_rewind(mattr.u.bookmarks);
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks)>0) {
+ struct item *item;
+ bookmarks_item_rewind(mattr.u.bookmarks);
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr))
- continue;
+ if (!item_attr_get(item, attr_label, &attr))
+ continue;
- if (item->type == type_bookmark)
- bookmarks_delete_bookmark(mattr.u.bookmarks, attr.u.str);
+ if (item->type == type_bookmark)
+ bookmarks_delete_bookmark(mattr.u.bookmarks, attr.u.str);
- bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
- }
- }
- bookmarks_item_rewind(mattr.u.bookmarks);
+ bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
+ }
+ }
+ bookmarks_item_rewind(mattr.u.bookmarks);
- bm_count=navit_get_destination_count(this->nav);
- pc=g_alloca(bm_count*sizeof(struct pcoord));
- navit_get_destinations(this->nav, pc, bm_count);
+ bm_count=navit_get_destination_count(this->nav);
+ pc=g_alloca(bm_count*sizeof(struct pcoord));
+ navit_get_destinations(this->nav, pc, bm_count);
- for (i=0; i<bm_count; i++){
- char *tmp=navit_get_destination_description(this->nav, i);
- desc=g_strdup_printf("%s WP%d", tmp, i+1);
- g_free(tmp);
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &pc[i], desc);
- bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
- g_free(desc);
- }
- }
+ for (i=0; i<bm_count; i++) {
+ char *tmp=navit_get_destination_description(this->nav, i);
+ desc=g_strdup_printf("%s WP%d", tmp, i+1);
+ g_free(tmp);
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, &pc[i], desc);
+ bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
+ g_free(desc);
+ }
+ }
- gui_internal_prune_menu(this, NULL);
+ gui_internal_prune_menu(this, NULL);
}
diff --git a/navit/gui/internal/gui_internal_command.c b/navit/gui/internal/gui_internal_command.c
index 6249b3047..fce70e7db 100644
--- a/navit/gui/internal/gui_internal_command.c
+++ b/navit/gui/internal/gui_internal_command.c
@@ -44,8 +44,6 @@
#include <arpa/inet.h>
#endif
-extern char *version;
-
/**
* @brief Converts a WGS84 coordinate pair to its string representation.
*
@@ -57,30 +55,28 @@ extern char *version;
*
* @return The coordinates as a formatted string
*/
-static char *
-coordinates_geo(const struct coord_geo *gc, char sep)
-{
- char latc='N',lngc='E';
- int lat_deg,lat_min,lat_sec;
- int lng_deg,lng_min,lng_sec;
- struct coord_geo g=*gc;
-
- if (g.lat < 0) {
- g.lat=-g.lat;
- latc='S';
- }
- if (g.lng < 0) {
- g.lng=-g.lng;
- lngc='W';
- }
- lat_sec=fmod(g.lat*3600+0.5,60);
- lat_min=fmod(g.lat*60-lat_sec/60.0+0.5,60);
- lat_deg=g.lat-lat_min/60.0-lat_sec/3600.0+0.5;
- lng_sec=fmod(g.lng*3600+0.5,60);
- lng_min=fmod(g.lng*60-lng_sec/60.0+0.5,60);
- lng_deg=g.lng-lng_min/60.0-lng_sec/3600.0+0.5;;
-
- return g_strdup_printf("%d°%d'%d\" %c%c%d°%d'%d\" %c",lat_deg,lat_min,lat_sec,latc,sep,lng_deg,lng_min,lng_sec,lngc);
+static char *coordinates_geo(const struct coord_geo *gc, char sep) {
+ char latc='N',lngc='E';
+ int lat_deg,lat_min,lat_sec;
+ int lng_deg,lng_min,lng_sec;
+ struct coord_geo g=*gc;
+
+ if (g.lat < 0) {
+ g.lat=-g.lat;
+ latc='S';
+ }
+ if (g.lng < 0) {
+ g.lng=-g.lng;
+ lngc='W';
+ }
+ lat_sec=fmod(g.lat*3600+0.5,60);
+ lat_min=fmod(g.lat*60-lat_sec/60.0+0.5,60);
+ lat_deg=g.lat-lat_min/60.0-lat_sec/3600.0+0.5;
+ lng_sec=fmod(g.lng*3600+0.5,60);
+ lng_min=fmod(g.lng*60-lng_sec/60.0+0.5,60);
+ lng_deg=g.lng-lng_min/60.0-lng_sec/3600.0+0.5;;
+
+ return g_strdup_printf("%d°%d'%d\" %c%c%d°%d'%d\" %c",lat_deg,lat_min,lat_sec,latc,sep,lng_deg,lng_min,lng_sec,lngc);
}
/**
@@ -94,693 +90,702 @@ coordinates_geo(const struct coord_geo *gc, char sep)
*
* @return The coordinates as a formatted string
*/
-char *
-gui_internal_coordinates(struct pcoord *pc, char sep)
-{
- struct coord_geo g;
- struct coord c;
- c.x=pc->x;
- c.y=pc->y;
- transform_to_geo(pc->pro, &c, &g);
- return coordinates_geo(&g, sep);
+char *gui_internal_coordinates(struct pcoord *pc, char sep) {
+ struct coord_geo g;
+ struct coord c;
+ c.x=pc->x;
+ c.y=pc->y;
+ transform_to_geo(pc->pro, &c, &g);
+ return coordinates_geo(&g, sep);
}
enum escape_mode {
- escape_mode_none=0,
- escape_mode_string=1,
- escape_mode_quote=2,
- escape_mode_html=4,
- escape_mode_html_quote=8,
- escape_mode_html_apos=16,
+ escape_mode_none=0,
+ escape_mode_string=1,
+ escape_mode_quote=2,
+ escape_mode_html=4,
+ escape_mode_html_quote=8,
+ escape_mode_html_apos=16,
};
/* todo &=&amp;, < = &lt; */
-static char *
-gui_internal_escape(enum escape_mode mode, char *in)
-{
- int len=mode & escape_mode_string ? 3:1;
- char *dst,*out,*src=in;
- char *quot="&quot;";
- char *apos="&apos;";
- while (*src) {
- if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
- len++;
- if (*src == '"' && mode == escape_mode_html_quote)
- len+=strlen(quot);
- else if (*src == '\'' && mode == escape_mode_html_apos)
- len+=strlen(apos);
- else
- len++;
- src++;
- }
- src=in;
- out=dst=g_malloc(len);
- if (mode & escape_mode_string)
- *dst++='"';
- while (*src) {
- if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
- *dst++='\\';
- if (*src == '"' && mode == escape_mode_html_quote) {
- strcpy(dst,quot);
- src++;
- dst+=strlen(quot);
- } else if (*src == '\'' && mode == escape_mode_html_apos) {
- strcpy(dst,apos);
- src++;
- dst+=strlen(apos);
- } else
- *dst++=*src++;
- }
- if (mode & escape_mode_string)
- *dst++='"';
- *dst++='\0';
- return out;
+static char *gui_internal_escape(enum escape_mode mode, char *in) {
+ int len=mode & escape_mode_string ? 3:1;
+ char *dst,*out,*src=in;
+ char *quot="&quot;";
+ char *apos="&apos;";
+ while (*src) {
+ if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
+ len++;
+ if (*src == '"' && mode == escape_mode_html_quote)
+ len+=strlen(quot);
+ else if (*src == '\'' && mode == escape_mode_html_apos)
+ len+=strlen(apos);
+ else
+ len++;
+ src++;
+ }
+ src=in;
+ out=dst=g_malloc(len);
+ if (mode & escape_mode_string)
+ *dst++='"';
+ while (*src) {
+ if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
+ *dst++='\\';
+ if (*src == '"' && mode == escape_mode_html_quote) {
+ strcpy(dst,quot);
+ src++;
+ dst+=strlen(quot);
+ } else if (*src == '\'' && mode == escape_mode_html_apos) {
+ strcpy(dst,apos);
+ src++;
+ dst+=strlen(apos);
+ } else
+ *dst++=*src++;
+ }
+ if (mode & escape_mode_string)
+ *dst++='"';
+ *dst++='\0';
+ return out;
}
-static void
-gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr escaped;
- if (!in || !in[0]) {
- dbg(lvl_error,"first parameter missing or wrong type\n");
- return;
- }
- if (!out) {
- dbg(lvl_error,"output missing\n");
- return;
- }
- if (ATTR_IS_STRING(in[0]->type)) {
- escaped.type=in[0]->type;
- escaped.u.str=gui_internal_escape(escape_mode_string,in[0]->u.str);
- } else if (ATTR_IS_INT(in[0]->type)) {
- escaped.type=attr_type_string_begin;
- escaped.u.str=g_strdup_printf("%ld",in[0]->u.num);
- } else {
- dbg(lvl_error,"first parameter wrong type\n");
- return;
- }
- dbg(lvl_debug,"in %s result %s\n",in[0]->u.str,escaped.u.str);
- *out=attr_generic_add_attr(*out, attr_dup(&escaped));
- g_free(escaped.u.str);
+static void gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr escaped;
+ if (!in || !in[0]) {
+ dbg(lvl_error,"first parameter missing or wrong type");
+ return;
+ }
+ if (!out) {
+ dbg(lvl_error,"output missing");
+ return;
+ }
+ if (ATTR_IS_STRING(in[0]->type)) {
+ escaped.type=in[0]->type;
+ escaped.u.str=gui_internal_escape(escape_mode_string,in[0]->u.str);
+ } else if (ATTR_IS_INT(in[0]->type)) {
+ escaped.type=attr_type_string_begin;
+ escaped.u.str=g_strdup_printf("%ld",in[0]->u.num);
+ } else {
+ dbg(lvl_error,"first parameter wrong type");
+ return;
+ }
+ dbg(lvl_debug,"in %s result %s",in[0]->u.str,escaped.u.str);
+ *out=attr_generic_add_attr(*out, attr_dup(&escaped));
+ g_free(escaped.u.str);
}
-static void
-gui_internal_cmd2_about(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("About Navit"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand);
- gui_internal_widget_append(menu, wb);
-
- //Icon
- gui_internal_widget_append(wb, w=gui_internal_image_new(this, image_new_xs(this, "navit")));
- w->flags=gravity_top_center|orientation_horizontal|flags_fill;
-
- //app name
- text=g_strdup_printf("%s",PACKAGE_NAME);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Version
- text=g_strdup_printf("%s",version);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Site
- text=g_strdup_printf("http://www.navit-project.org/");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Authors
- text=g_strdup_printf("%s:",_("By"));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Martin Schaller");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Michael Farmbauer");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Alexander Atanasov");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Pierre Grandin");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
-
- //Contributors
- text=g_strdup_printf("%s",_("And all the Navit Team"));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("%s",_("members and contributors."));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+static void gui_internal_cmd2_about(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *menu,*wb,*w;
+ char *text;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ menu=gui_internal_menu(this, _("About Navit"));
+ menu->spx=this->spacing*10;
+ wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand);
+ gui_internal_widget_append(menu, wb);
+
+ //Icon
+ gui_internal_widget_append(wb, w=gui_internal_image_new(this, image_new_xs(this, "navit")));
+ w->flags=gravity_top_center|orientation_horizontal|flags_fill;
+
+ //app name
+ text=g_strdup_printf("%s",PACKAGE_NAME);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_top_center|orientation_horizontal|flags_expand;
+ g_free(text);
+
+ //Version
+ text=g_strdup_printf("%s",NAVIT_VERSION);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_top_center|orientation_horizontal|flags_expand;
+ g_free(text);
+
+ //Site
+ text=g_strdup_printf("http://www.navit-project.org/");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_top_center|orientation_horizontal|flags_expand;
+ g_free(text);
+
+ //Authors
+ text=g_strdup_printf("%s:",_("By"));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Martin Schaller");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Michael Farmbauer");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Alexander Atanasov");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Pierre Grandin");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+
+ //Contributors
+ text=g_strdup_printf("%s",_("And all the Navit Team"));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("%s",_("members and contributors."));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
}
-static void
-gui_internal_cmd2_waypoints(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- gui_internal_select_waypoint(this, _("Waypoints"), NULL, NULL, gui_internal_cmd_position, (void*)2);
+static void gui_internal_cmd2_waypoints(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ gui_internal_select_waypoint(this, _("Waypoints"), NULL, NULL, gui_internal_cmd_position, (void*)2);
}
-static void
-gui_internal_cmd_enter_coord(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w, *wb, *wk, *wr, *we, *wnext, *row;
- wb=gui_internal_menu(this, _("Enter Coordinates"));
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
-
-/*
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
-
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);*/
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Latitude Longitude")));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_enter_coord_clicked;
- wnext->data=wk;
- wk->data=wnext;
- row=gui_internal_text_new(this, _("Enter coordinates, for example:"), gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52.5219N 19.4127E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52°31.3167N 19°24.7667E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52°31'19N 19°24'46E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
-
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_DEGREE));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_DEGREE, NULL);
- gui_internal_menu_render(this);
+static void gui_internal_cmd_enter_coord(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *w, *wb, *wk, *wr, *we, *wnext, *row;
+ wb=gui_internal_menu(this, _("Enter Coordinates"));
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wr);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, we);
+
+ /*
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);*/
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Latitude Longitude")));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_enter_coord_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ row=gui_internal_text_new(this, _("Enter coordinates, for example:"),
+ gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+ row=gui_internal_text_new(this, "52.5219N 19.4127E", gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+ row=gui_internal_text_new(this, "52°31.3167N 19°24.7667E", gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+ row=gui_internal_text_new(this, "52°31'19N 19°24'46E", gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_DEGREE));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_DEGREE, NULL);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_town(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (this->sl)
- search_list_select(this->sl, attr_country_all, 0, 0);
- gui_internal_search(this,_("Town"),"Town",1);
+static void gui_internal_cmd2_town(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ if (this->sl)
+ search_list_select(this->sl, attr_country_all, 0, 0);
+ gui_internal_search(this,_("Town"),"Town",1);
}
-static void
-gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr,attr2,vattr;
- struct widget *w,*wb,*wl;
- struct attr_iter *iter;
- struct attr active_vehicle;
-
- iter=navit_attr_iter_new();
- if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- navit_attr_iter_destroy(iter);
- gui_internal_menu_vehicle_settings(this, attr.u.vehicle, vattr.u.str);
- return;
- }
- navit_attr_iter_destroy(iter);
-
- wb=gui_internal_menu(this, _("Vehicle"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
- active_vehicle.u.vehicle=NULL;
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- wl=gui_internal_button_new_with_callback(this, vattr.u.str,
- image_new_xs(this, attr.u.vehicle == active_vehicle.u.vehicle ? "gui_active" : "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_vehicle_settings, attr.u.vehicle);
- wl->text=g_strdup(vattr.u.str);
- gui_internal_widget_append(w, wl);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ struct attr attr,attr2,vattr;
+ struct widget *w,*wb,*wl;
+ struct attr_iter *iter;
+ struct attr active_vehicle;
+
+ iter=navit_attr_iter_new();
+ if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_vehicle_settings(this, attr.u.vehicle, vattr.u.str);
+ return;
+ }
+ navit_attr_iter_destroy(iter);
+
+ wb=gui_internal_menu(this, _("Vehicle"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
+ active_vehicle.u.vehicle=NULL;
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ wl=gui_internal_button_new_with_callback(this, vattr.u.str,
+ image_new_xs(this, attr.u.vehicle == active_vehicle.u.vehicle ? "gui_active" : "gui_inactive"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_vehicle_settings, attr.u.vehicle);
+ wl->text=g_strdup(vattr.u.str);
+ gui_internal_widget_append(w, wl);
+ }
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_setting_rules(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *wb,*w;
- struct attr on,off;
- wb=gui_internal_menu(this, _("Rules"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_tracking;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Lock on road"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=0;
- off.u.num=-1;
- on.type=off.type=attr_orientation;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Northing"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_follow_cursor;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Map follows Vehicle"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_waypoints_flag;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Plan with Waypoints"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_rules(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *wb,*w;
+ struct attr on,off;
+ wb=gui_internal_menu(this, _("Rules"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ on.u.num=1;
+ off.u.num=0;
+ on.type=off.type=attr_tracking;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Lock on road"), gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ on.u.num=0;
+ off.u.num=-1;
+ on.type=off.type=attr_orientation;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Northing"), gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ on.u.num=1;
+ off.u.num=0;
+ on.type=off.type=attr_follow_cursor;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Map follows Vehicle"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ on.u.num=1;
+ off.u.num=0;
+ on.type=off.type=attr_waypoints_flag;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Plan with Waypoints"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_setting_maps(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr, on, off, description, type, data, url, active;
- struct widget *w,*wb,*row,*wma;
- char *label;
- struct attr_iter *iter;
-
- wb=gui_internal_menu(this, _("Maps"));
- //w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- //w->spy=this->spacing*3;
- w = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(wb, w);
- iter=navit_attr_iter_new();
- on.type=off.type=attr_active;
- on.u.num=1;
- off.u.num=0;
- while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
- if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
- label=g_strdup(description.u.str);
- } else {
- if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str="";
- if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str="";
- label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
- }
- if (map_get_attr(attr.u.map, attr_url, &url, NULL)) {
- if (!map_get_attr(attr.u.map, attr_active, &active, NULL))
- active.u.num=1;
- wma=gui_internal_button_new_with_callback(this, label, image_new_xs(this, active.u.num ? "gui_active" : "gui_inactive"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_map_download, attr.u.map);
- } else {
- wma=gui_internal_button_map_attr_new(this, label, gravity_left_center|orientation_horizontal|flags_fill,
- attr.u.map, &on, &off, 1);
- }
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wma);
- g_free(label);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_maps(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr attr, on, off, description, type, data, url, active;
+ struct widget *w,*wb,*row,*wma;
+ char *label;
+ struct attr_iter *iter;
+
+ wb=gui_internal_menu(this, _("Maps"));
+ //w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ //w->spy=this->spacing*3;
+ w = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(wb, w);
+ iter=navit_attr_iter_new();
+ on.type=off.type=attr_active;
+ on.u.num=1;
+ off.u.num=0;
+ while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
+ label=g_strdup(description.u.str);
+ } else {
+ if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
+ type.u.str="";
+ if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
+ data.u.str="";
+ label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
+ }
+ if (map_get_attr(attr.u.map, attr_url, &url, NULL)) {
+ if (!map_get_attr(attr.u.map, attr_active, &active, NULL))
+ active.u.num=1;
+ wma=gui_internal_button_new_with_callback(this, label, image_new_xs(this, active.u.num ? "gui_active" : "gui_inactive"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_map_download, attr.u.map);
+ } else {
+ wma=gui_internal_button_map_attr_new(this, label, gravity_left_center|orientation_horizontal|flags_fill,
+ attr.u.map, &on, &off, 1);
+ }
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row, wma);
+ g_free(label);
+ }
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr;
- struct widget *w,*wb,*wl,*row;
- struct attr_iter *iter;
-
-
- wb=gui_internal_menu(this, _("Layout"));
- w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
- gui_internal_widget_append(wb, w);
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- wl=gui_internal_button_navit_attr_new(this, attr.u.layout->name, gravity_left_center|orientation_horizontal|flags_fill,
- &attr, NULL);
- gui_internal_widget_append(row, wl);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ struct attr attr;
+ struct widget *w,*wb,*wl,*row;
+ struct attr_iter *iter;
+
+
+ wb=gui_internal_menu(this, _("Layout"));
+ w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
+ gui_internal_widget_append(wb, w);
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ wl=gui_internal_button_navit_attr_new(this, attr.u.layout->name, gravity_left_center|orientation_horizontal|flags_fill,
+ &attr, NULL);
+ gui_internal_widget_append(row, wl);
+ }
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_render(this);
}
/*
* @brief Displays Route Height Profile
*
- * displays a heightprofile if a route is active and
+ * displays a heightprofile if a route is active and
* some heightinfo is provided by means of a map
*
* the name of the file providing the heightlines must
* comply with *.heightlines.bin
- *
+ *
*/
-static void
-gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget * menu, *box;
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct route * route;
- struct item * item =NULL;
- struct mapset *ms;
- struct mapset_handle *msh;
- int x,i,first=1,dist=0;
- int diagram_points_count = 0;
- struct coord c,last,res;
- struct coord_rect rbbox,dbbox;
- struct map_selection sel;
- struct heightline *heightline,*heightlines=NULL;
- struct diagram_point *min,*diagram_point,*diagram_points=NULL;
- struct point p[2];
- sel.next=NULL;
- sel.order=18;
- sel.range.min=type_height_line_1;
- sel.range.max=type_height_line_3;
-
- menu=gui_internal_menu(this,_("Height Profile"));
- box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
- gui_internal_widget_append(menu, box);
- route = navit_get_route(this->nav);
- if (route)
- map = route_get_map(route);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr) {
- while((item = map_rect_get_item(mr))) {
- while (item_coord_get(item, &c, 1)) {
- if (first) {
- first=0;
- sel.u.c_rect.lu=c;
- sel.u.c_rect.rl=c;
- } else
- coord_rect_extend(&sel.u.c_rect, &c);
- }
- }
- map_rect_destroy(mr);
- mr = NULL;
- ms=navit_get_mapset(this->nav);
- if (!first && ms) {
- int heightmap_installed = FALSE;
- msh=mapset_open(ms);
- while ((map=mapset_next(msh, 1))) {
- struct attr data_attr;
- if (map_get_attr(map, attr_data, &data_attr, NULL)){
- dbg(lvl_debug,"map name = %s\n",data_attr.u.str);
- if (strstr(data_attr.u.str,".heightlines.bin")){
- dbg(lvl_info,"reading heightlines from map %s\n",data_attr.u.str);
- mr=map_rect_new(map, &sel);
- heightmap_installed = TRUE;
- }
- else {
- dbg(lvl_debug,"ignoring map %s\n",data_attr.u.str);
- }
- }
- if (mr) {
- while((item = map_rect_get_item(mr))) {
- if (item->type >= sel.range.min && item->type <= sel.range.max) {
- heightline=item_get_heightline(item);
- if (heightline) {
- heightline->next=heightlines;
- heightlines=heightline;
- }
- }
- }
- map_rect_destroy(mr);
- mr = NULL;
- }
- }
- mapset_close(msh);
- if (!heightmap_installed){
- char *text;
- struct widget *w;
- text=g_strdup_printf("%s",_("please install a map *.heightlines.bin to provide elevationdata"));
- gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- gui_internal_menu_render(this);
- return;
- }
- }
- }
- map=NULL;
- mr=NULL;
- if (route)
- map = route_get_map(route);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr && heightlines) {
- while((item = map_rect_get_item(mr))) {
- first=1;
- while (item_coord_get(item, &c, 1)) {
- if (first)
- first=0;
- else {
- heightline=heightlines;
- rbbox.lu=last;
- rbbox.rl=last;
- coord_rect_extend(&rbbox, &c);
- while (heightline) {
- if (coord_rect_overlap(&rbbox, &heightline->bbox)) {
- for (i = 0 ; i < heightline->count - 1; i++) {
- if (heightline->c[i].x != heightline->c[i+1].x || heightline->c[i].y != heightline->c[i+1].y) {
- if (line_intersection(heightline->c+i, heightline->c+i+1, &last, &c, &res)) {
- diagram_point=g_new(struct diagram_point, 1);
- diagram_point->c.x=dist+transform_distance(projection_mg, &last, &res);
- diagram_point->c.y=heightline->height;
- diagram_point->next=diagram_points;
- diagram_points=diagram_point;
- diagram_points_count ++;
- dbg(lvl_debug,"%d %d\n", diagram_point->c.x, diagram_point->c.y);
- }
- }
- }
- }
- heightline=heightline->next;
- }
- dist+=transform_distance(projection_mg, &last, &c);
- }
- last=c;
- }
- }
- }
- while (heightlines){
- heightline=heightlines;
- heightlines=heightlines->next;
- g_free(heightline);
- }
- if(mr)
- map_rect_destroy(mr);
-
- if(diagram_points_count < 2){
- char *text;
- struct widget *w;
- text=g_strdup_printf("%s",_("The route must cross at least 2 heightlines"));
- gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- gui_internal_menu_render(this);
- if(diagram_points)
- g_free(diagram_points);
- return;
- }
-
- gui_internal_menu_render(this);
- first=1;
- diagram_point=diagram_points;
- while (diagram_point) {
- if (first) {
- dbbox.lu=diagram_point->c;
- dbbox.rl=diagram_point->c;
- first=0;
- } else
- coord_rect_extend(&dbbox, &diagram_point->c);
- diagram_point=diagram_point->next;
- }
- dbg(lvl_debug,"%d %d %d %d\n", dbbox.lu.x, dbbox.lu.y, dbbox.rl.x, dbbox.rl.y);
- if (dbbox.rl.x > dbbox.lu.x && dbbox.lu.x*100/(dbbox.rl.x-dbbox.lu.x) <= 25)
- dbbox.lu.x=0;
- if (dbbox.lu.y > dbbox.rl.y && dbbox.rl.y*100/(dbbox.lu.y-dbbox.rl.y) <= 25)
- dbbox.rl.y=0;
- dbg(lvl_debug,"%d,%d %dx%d\n", box->p.x, box->p.y, box->w, box->h);
- x=dbbox.lu.x;
- first=1;
- if (diagram_points_count > 1 && dbbox.rl.x != dbbox.lu.x && dbbox.lu.y != dbbox.rl.y){
- for (;;) {
- min=NULL;
- diagram_point=diagram_points;
- while (diagram_point) {
- if (diagram_point->c.x >= x && (!min || min->c.x > diagram_point->c.x))
- min=diagram_point;
- diagram_point=diagram_point->next;
- }
- if (! min)
- break;
- p[1].x=(min->c.x-dbbox.lu.x)*(box->w-10)/(dbbox.rl.x-dbbox.lu.x)+box->p.x+5;
- p[1].y=(box->h)-5-(min->c.y-dbbox.rl.y)*(box->h-10)/(dbbox.lu.y-dbbox.rl.y)+box->p.y;
- dbg(lvl_debug,"%d,%d=%d,%d\n",min->c.x, min->c.y, p[1].x,p[1].y);
- graphics_draw_circle(this->gra, this->foreground, &p[1], 2);
- if (first)
- first=0;
- else
- graphics_draw_lines(this->gra, this->foreground, p, 2);
- p[0]=p[1];
- x=min->c.x+1;
- }
- }
- while (diagram_points){
- diagram_point=diagram_points;
- diagram_points=diagram_points->next;
- g_free(diagram_point);
- }
+static void gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ struct widget * menu, *box;
+ struct map * map=NULL;
+ struct map_rect * mr=NULL;
+ struct route * route;
+ struct item * item =NULL;
+ struct mapset *ms;
+ struct mapset_handle *msh;
+ int x,i,first=1,dist=0;
+ int diagram_points_count = 0;
+ struct coord c,last,res;
+ struct coord_rect rbbox,dbbox;
+ struct map_selection sel;
+ struct heightline *heightline,*heightlines=NULL;
+ struct diagram_point *min,*diagram_point,*diagram_points=NULL;
+ struct point p[2];
+ int min_ele=INT_MAX;
+ int max_ele=INT_MIN;
+ int distance=0;
+ sel.next=NULL;
+ sel.order=18;
+ sel.range.min=type_height_line_1;
+ sel.range.max=type_height_line_3;
+
+ menu=gui_internal_menu(this,_("Height Profile"));
+ box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
+ gui_internal_widget_append(menu, box);
+ route = navit_get_route(this->nav);
+ if (route)
+ map = route_get_map(route);
+ if(map)
+ mr = map_rect_new(map,NULL);
+ if(mr) {
+ while((item = map_rect_get_item(mr))) {
+ while (item_coord_get(item, &c, 1)) {
+ if (first) {
+ first=0;
+ sel.u.c_rect.lu=c;
+ sel.u.c_rect.rl=c;
+ } else
+ coord_rect_extend(&sel.u.c_rect, &c);
+ }
+ }
+ map_rect_destroy(mr);
+ mr = NULL;
+ ms=navit_get_mapset(this->nav);
+ if (!first && ms) {
+ int heightmap_installed = FALSE;
+ msh=mapset_open(ms);
+ while ((map=mapset_next(msh, 1))) {
+ struct attr data_attr;
+ if (map_get_attr(map, attr_data, &data_attr, NULL)) {
+ dbg(lvl_debug,"map name = %s",data_attr.u.str);
+ if (strstr(data_attr.u.str,".heightlines.bin")) {
+ dbg(lvl_info,"reading heightlines from map %s",data_attr.u.str);
+ mr=map_rect_new(map, &sel);
+ heightmap_installed = TRUE;
+ } else {
+ dbg(lvl_debug,"ignoring map %s",data_attr.u.str);
+ }
+ }
+ if (mr) {
+ while((item = map_rect_get_item(mr))) {
+ if (item->type >= sel.range.min && item->type <= sel.range.max) {
+ heightline=item_get_heightline(item);
+ if (heightline) {
+ heightline->next=heightlines;
+ heightlines=heightline;
+ }
+ }
+ }
+ map_rect_destroy(mr);
+ mr = NULL;
+ }
+ }
+ mapset_close(msh);
+ if (!heightmap_installed) {
+ char *text;
+ struct widget *w;
+ text=g_strdup_printf("%s",_("please install a map *.heightlines.bin to provide elevationdata"));
+ gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ gui_internal_menu_render(this);
+ return;
+ }
+ }
+ }
+ map=NULL;
+ mr=NULL;
+ if (route)
+ map = route_get_map(route);
+ if(map)
+ mr = map_rect_new(map,NULL);
+ if(mr && heightlines) {
+ while((item = map_rect_get_item(mr))) {
+ first=1;
+ while (item_coord_get(item, &c, 1)) {
+ if (first)
+ first=0;
+ else {
+ heightline=heightlines;
+ rbbox.lu=last;
+ rbbox.rl=last;
+ coord_rect_extend(&rbbox, &c);
+ while (heightline) {
+ if (coord_rect_overlap(&rbbox, &heightline->bbox)) {
+ for (i = 0 ; i < heightline->count - 1; i++) {
+ if (heightline->c[i].x != heightline->c[i+1].x || heightline->c[i].y != heightline->c[i+1].y) {
+ if (line_intersection(heightline->c+i, heightline->c+i+1, &last, &c, &res)) {
+ diagram_point=g_new(struct diagram_point, 1);
+ diagram_point->c.x=dist+transform_distance(projection_mg, &last, &res);
+ diagram_point->c.y=heightline->height;
+ diagram_point->next=diagram_points;
+ diagram_points=diagram_point;
+ diagram_points_count ++;
+ dbg(lvl_debug,"%d %d", diagram_point->c.x, diagram_point->c.y);
+ max_ele=MAX(max_ele, diagram_point->c.y);
+ min_ele=MIN(min_ele, diagram_point->c.y);
+ distance=diagram_point->c.x;
+ }
+ }
+ }
+ }
+ heightline=heightline->next;
+ }
+ dist+=transform_distance(projection_mg, &last, &c);
+ }
+ last=c;
+ }
+ }
+ }
+ while (heightlines) {
+ heightline=heightlines;
+ heightlines=heightlines->next;
+ g_free(heightline);
+ }
+ if(mr)
+ map_rect_destroy(mr);
+
+ if(diagram_points_count < 2) {
+ char *text;
+ struct widget *w;
+ text=g_strdup_printf("%s",_("The route must cross at least 2 heightlines"));
+ gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ gui_internal_menu_render(this);
+ if(diagram_points)
+ g_free(diagram_points);
+ return;
+ }
+
+ gui_internal_menu_render(this);
+ first=1;
+ diagram_point=diagram_points;
+ while (diagram_point) {
+ if (first) {
+ dbbox.lu=diagram_point->c;
+ dbbox.rl=diagram_point->c;
+ first=0;
+ } else
+ coord_rect_extend(&dbbox, &diagram_point->c);
+ diagram_point=diagram_point->next;
+ }
+ dbg(lvl_debug,"%d %d %d %d", dbbox.lu.x, dbbox.lu.y, dbbox.rl.x, dbbox.rl.y);
+ if (dbbox.rl.x > dbbox.lu.x && dbbox.lu.x*100/(dbbox.rl.x-dbbox.lu.x) <= 25)
+ dbbox.lu.x=0;
+ if (dbbox.lu.y > dbbox.rl.y && dbbox.rl.y*100/(dbbox.lu.y-dbbox.rl.y) <= 25)
+ dbbox.rl.y=0;
+ dbg(lvl_debug,"%d,%d %dx%d", box->p.x, box->p.y, box->w, box->h);
+ x=dbbox.lu.x;
+ first=1;
+ if (diagram_points_count > 1 && dbbox.rl.x != dbbox.lu.x && dbbox.lu.y != dbbox.rl.y) {
+ for (;;) {
+ min=NULL;
+ diagram_point=diagram_points;
+ while (diagram_point) {
+ if (diagram_point->c.x >= x && (!min || min->c.x > diagram_point->c.x))
+ min=diagram_point;
+ diagram_point=diagram_point->next;
+ }
+ if (! min)
+ break;
+ p[1].x=(min->c.x-dbbox.lu.x)*(box->w-10)/(dbbox.rl.x-dbbox.lu.x)+box->p.x+5;
+ p[1].y=(box->h)-5-(min->c.y-dbbox.rl.y)*(box->h-10)/(dbbox.lu.y-dbbox.rl.y)+box->p.y;
+ dbg(lvl_debug,"%d,%d=%d,%d",min->c.x, min->c.y, p[1].x,p[1].y);
+ graphics_draw_circle(this->gra, this->foreground, &p[1], 2);
+ if (first)
+ first=0;
+ else
+ graphics_draw_lines(this->gra, this->foreground, p, 2);
+ p[0]=p[1];
+ x=min->c.x+1;
+ }
+ }
+
+ struct point pTopLeft= {0, box->p.y + 10};
+ struct point pBottomLeft= {0, box->h + box->p.y - 2};
+ struct point pBottomRight= {box->w - 100, box->h + box->p.y - 2};
+ char* minele_text=g_strdup_printf("%d m", min_ele);
+ char* maxele_text=g_strdup_printf("%d m", max_ele);
+ char* distance_text=g_strdup_printf("%.3f km", distance/1000.0);
+ graphics_draw_text_std(this->gra, 10, maxele_text, &pTopLeft);
+ graphics_draw_text_std(this->gra, 10, minele_text, &pBottomLeft);
+ graphics_draw_text_std(this->gra, 10, distance_text, &pBottomRight);
+
+ while (diagram_points) {
+ diagram_point=diagram_points;
+ diagram_points=diagram_points->next;
+ g_free(diagram_point);
+ }
}
-static void
-gui_internal_cmd2_route_description(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
+static void gui_internal_cmd2_route_description(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
- struct widget * menu;
- struct widget * box;
+ struct widget * menu;
+ struct widget * box;
- if(! this->vehicle_cb)
- {
- /**
- * Register the callback on vehicle updates.
- */
- this->vehicle_cb = callback_new_attr_1(callback_cast(gui_internal_route_update),
- attr_position_coord_geo,this);
- navit_add_callback(this->nav,this->vehicle_cb);
- }
+ if(! this->vehicle_cb) {
+ /**
+ * Register the callback on vehicle updates.
+ */
+ this->vehicle_cb = callback_new_attr_1(callback_cast(gui_internal_route_update),
+ attr_position_coord_geo,this);
+ navit_add_callback(this->nav,this->vehicle_cb);
+ }
- this->route_data.route_table = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ this->route_data.route_table = gui_internal_widget_table_new(this,
+ gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- menu=gui_internal_menu(this,_("Route Description"));
+ menu=gui_internal_menu(this,_("Route Description"));
- menu->wfree=gui_internal_route_screen_free;
- this->route_data.route_showing=1;
- this->route_data.route_table->spx = this->spacing;
+ menu->wfree=gui_internal_route_screen_free;
+ this->route_data.route_showing=1;
+ this->route_data.route_table->spx = this->spacing;
- box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
+ box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
- gui_internal_widget_append(box,this->route_data.route_table);
- box->w=menu->w;
- box->spx = this->spacing;
- this->route_data.route_table->w=box->w;
- gui_internal_widget_append(menu,box);
- gui_internal_populate_route_table(this,this->nav);
- gui_internal_menu_render(this);
+ gui_internal_widget_append(box,this->route_data.route_table);
+ box->w=menu->w;
+ box->spx = this->spacing;
+ this->route_data.route_table->w=box->w;
+ gui_internal_widget_append(menu,box);
+ gui_internal_populate_route_table(this,this->nav);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_pois(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w;
- struct poi_param *param;
- struct attr pro;
- struct coord c;
-
- dbg(lvl_debug,"enter\n");
- if (!in || !in[0])
- return;
- if (!ATTR_IS_COORD_GEO(in[0]->type))
- return;
- if (!navit_get_attr(this->nav, attr_projection, &pro, NULL))
- return;
- w=g_new0(struct widget,1);
- param=g_new0(struct poi_param,1);
- if (in[1] && ATTR_IS_STRING(in[1]->type)) {
- gui_internal_poi_param_set_filter(param, in[1]->u.str);
- if (in[2] && ATTR_IS_INT(in[2]->type))
- param->AddressFilterType=in[2]->u.num;
- }
-
- transform_from_geo(pro.u.projection,in[0]->u.coord_geo,&c);
- w->c.x=c.x;
- w->c.y=c.y;
- w->c.pro=pro.u.projection;
- gui_internal_cmd_pois(this, w, param);
- g_free(w);
- gui_internal_poi_param_free(param);
+static void gui_internal_cmd2_pois(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *w;
+ struct poi_param *param;
+ struct attr pro;
+ struct coord c;
+
+ dbg(lvl_debug,"enter");
+ if (!in || !in[0])
+ return;
+ if (!ATTR_IS_COORD_GEO(in[0]->type))
+ return;
+ if (!navit_get_attr(this->nav, attr_projection, &pro, NULL))
+ return;
+ w=g_new0(struct widget,1);
+ param=g_new0(struct poi_param,1);
+ if (in[1] && ATTR_IS_STRING(in[1]->type)) {
+ gui_internal_poi_param_set_filter(param, in[1]->u.str);
+ if (in[2] && ATTR_IS_INT(in[2]->type))
+ param->AddressFilterType=in[2]->u.num;
+ }
+
+ transform_from_geo(pro.u.projection,in[0]->u.coord_geo,&c);
+ w->c.x=c.x;
+ w->c.y=c.y;
+ w->c.pro=pro.u.projection;
+ gui_internal_cmd_pois(this, w, param);
+ g_free(w);
+ gui_internal_poi_param_free(param);
}
-static void
-gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("Show Locale"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, wb);
- text=g_strdup_printf("LANG=%1$s (1=%3$s 2=%2$s)",getenv("LANG"),"2","1");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
+static void gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *menu,*wb,*w;
+ char *text;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ menu=gui_internal_menu(this, _("Show Locale"));
+ menu->spx=this->spacing*10;
+ wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(menu, wb);
+ text=g_strdup_printf("LANG=%1$s (1=%3$s 2=%2$s)",getenv("LANG"),"2","1");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_left_center|orientation_horizontal|flags_fill;
+ g_free(text);
#ifdef HAVE_API_WIN32_BASE
- {
- char country[32],lang[32];
+ {
+ char country[32],lang[32];
#ifdef HAVE_API_WIN32_CE
- wchar_t wcountry[32],wlang[32];
+ wchar_t wcountry[32],wlang[32];
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
- WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
+ WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
#endif
- text=g_strdup_printf("LOCALE_SABBREVLANGNAME=%s",lang);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
+ text=g_strdup_printf("LOCALE_SABBREVLANGNAME=%s",lang);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_left_center|orientation_horizontal|flags_fill;
+ g_free(text);
#ifdef HAVE_API_WIN32_CE
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
- WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
+ WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
#endif
- text=g_strdup_printf("LOCALE_SABBREVCTRYNAME=%s",country);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
- }
+ text=g_strdup_printf("LOCALE_SABBREVCTRYNAME=%s",country);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_left_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ }
#endif
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
}
/**
@@ -793,553 +798,528 @@ gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in
* Currently only works on non Windows systems.
*
*/
-static void
-gui_internal_cmd2_network_info(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
+static void gui_internal_cmd2_network_info(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
#if HAS_IFADDRS
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("Network info"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, wb);
-
- struct ifaddrs *addrs, *tmp;
- getifaddrs(&addrs);
- tmp = addrs;
-
- while (tmp)
- {
- if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET)
- {
- struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
- if(g_ascii_strncasecmp(tmp->ifa_name,"lo",2 ) ) {
- text=g_strdup_printf("%s: %s", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- }
- }
- tmp = tmp->ifa_next;
- }
- freeifaddrs(addrs);
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+ struct widget *menu,*wb,*w;
+ char *text;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ menu=gui_internal_menu(this, _("Network info"));
+ menu->spx=this->spacing*10;
+ wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(menu, wb);
+
+ struct ifaddrs *addrs, *tmp;
+ getifaddrs(&addrs);
+ tmp = addrs;
+
+ while (tmp) {
+ if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET) {
+ struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
+ if(g_ascii_strncasecmp(tmp->ifa_name,"lo",2 ) ) {
+ text=g_strdup_printf("%s: %s", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ }
+ }
+ tmp = tmp->ifa_next;
+ }
+ freeifaddrs(addrs);
+
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
#else
- dbg(lvl_error, "Cannot show network info: ifaddr.h not found\n");
+ dbg(lvl_error, "Cannot show network info: ifaddr.h not found");
#endif
}
-static void
-gui_internal_cmd_formerdests(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *wb,*w,*wbm,*tbl=NULL;
- struct map *formerdests;
- struct map_rect *mr_formerdests;
- struct item *item;
- struct attr attr;
- char *label_full;
- enum projection projection;
-
- if(!navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL))
- return;
-
- formerdests=attr.u.map;
- if(!formerdests)
- return;
-
- mr_formerdests=map_rect_new(formerdests, NULL);
- if(!mr_formerdests)
- return;
-
- projection = map_projection(formerdests);
-
- gui_internal_prune_menu_count(this, 1, 0);
- wb=gui_internal_menu(this, _("Former Destinations"));
- wb->background=this->background;
-
- w=gui_internal_box_new(this,
- gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*2;
- gui_internal_widget_append(wb, w);
- while ((item=map_rect_get_item(mr_formerdests))) {
- struct coord c;
- struct widget *row;
- if (item->type!=type_former_destination) continue;
- if (!item_attr_get(item, attr_label, &attr)) continue;
- if(!tbl) {
- tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand | orientation_vertical,1);
- gui_internal_widget_append(w,tbl);
- }
- row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_vertical);
- gui_internal_widget_prepend(tbl, row);
- label_full=attr.u.str;
- wbm=gui_internal_button_new_with_callback(this, label_full,
- image_new_xs(this, "gui_active"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, NULL);
- gui_internal_widget_append(row,wbm);
- if (item_coord_get(item, &c, 1)) {
- wbm->c.x=c.x;
- wbm->c.y=c.y;
- wbm->c.pro=projection;
- wbm->name=g_strdup(label_full);
- wbm->text=g_strdup(label_full);
- wbm->data=(void*)8; //Mark us as a former destination
- wbm->prefix=g_strdup(label_full);
- }
- }
- if (!tbl){
- wbm=gui_internal_text_new(this, _("- No former destinations available -"),
- gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, wbm);
- }
- gui_internal_menu_render(this);
- map_rect_destroy(mr_formerdests);
+static void gui_internal_cmd_formerdests(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *wb,*w,*wbm,*tbl=NULL;
+ struct map *formerdests;
+ struct map_rect *mr_formerdests;
+ struct item *item;
+ struct attr attr;
+ char *label_full;
+ enum projection projection;
+
+ if(!navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL))
+ return;
+
+ formerdests=attr.u.map;
+ if(!formerdests)
+ return;
+
+ mr_formerdests=map_rect_new(formerdests, NULL);
+ if(!mr_formerdests)
+ return;
+
+ projection = map_projection(formerdests);
+
+ gui_internal_prune_menu_count(this, 1, 0);
+ wb=gui_internal_menu(this, _("Former Destinations"));
+ wb->background=this->background;
+
+ w=gui_internal_box_new(this,
+ gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*2;
+ gui_internal_widget_append(wb, w);
+ while ((item=map_rect_get_item(mr_formerdests))) {
+ struct coord c;
+ struct widget *row;
+ if (item->type!=type_former_destination) continue;
+ if (!item_attr_get(item, attr_label, &attr)) continue;
+ if(!tbl) {
+ tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand | orientation_vertical,1);
+ gui_internal_widget_append(w,tbl);
+ }
+ row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_vertical);
+ gui_internal_widget_prepend(tbl, row);
+ label_full=attr.u.str;
+ wbm=gui_internal_button_new_with_callback(this, label_full,
+ image_new_xs(this, "gui_active"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_position, NULL);
+ gui_internal_widget_append(row,wbm);
+ if (item_coord_get(item, &c, 1)) {
+ wbm->c.x=c.x;
+ wbm->c.y=c.y;
+ wbm->c.pro=projection;
+ wbm->name=g_strdup(label_full);
+ wbm->text=g_strdup(label_full);
+ wbm->data=(void*)8; //Mark us as a former destination
+ wbm->prefix=g_strdup(label_full);
+ }
+ }
+ if (!tbl) {
+ wbm=gui_internal_text_new(this, _("- No former destinations available -"),
+ gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, wbm);
+ }
+ gui_internal_menu_render(this);
+ map_rect_destroy(mr_formerdests);
}
-static void
-gui_internal_cmd2_bookmarks(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=NULL;
- if (in && in[0] && ATTR_IS_STRING(in[0]->type)) {
- str=in[0]->u.str;
- }
+static void gui_internal_cmd2_bookmarks(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str=NULL;
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type)) {
+ str=in[0]->u.str;
+ }
- gui_internal_cmd_bookmarks(this, NULL, str);
+ gui_internal_cmd_bookmarks(this, NULL, str);
}
-static void
-gui_internal_cmd2_abort_navigation(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- navit_set_destination(this->nav, NULL, NULL, 0);
+static void gui_internal_cmd2_abort_navigation(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ navit_set_destination(this->nav, NULL, NULL, 0);
}
-static void
-gui_internal_cmd2_back(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_back(this, NULL, NULL);
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_check_exit(this);
+static void gui_internal_cmd2_back(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_back(this, NULL, NULL);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_check_exit(this);
}
-static void
-gui_internal_cmd2_back_to_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- gui_internal_prune_menu(this, NULL);
- gui_internal_check_exit(this);
+static void gui_internal_cmd2_back_to_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ gui_internal_prune_menu(this, NULL);
+ gui_internal_check_exit(this);
}
-static void
-gui_internal_get_data(struct gui_priv *priv, char *command, struct attr **in, struct attr ***out)
-{
- struct attr private_data = { attr_private_data, {(void *)&priv->data}};
- if (out)
- *out=attr_generic_add_attr(*out, &private_data);
+static void gui_internal_get_data(struct gui_priv *priv, char *command, struct attr **in, struct attr ***out) {
+ struct attr private_data = { attr_private_data, {(void *)&priv->data}};
+ if (out)
+ *out=attr_generic_add_attr(*out, &private_data);
}
-static void
-gui_internal_cmd_log(struct gui_priv *this)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- gui_internal_enter(this, 1);
- gui_internal_set_click_coord(this, NULL);
- gui_internal_enter_setup(this);
- wb=gui_internal_menu(this, "Log Message");
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message")));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_log_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
- gui_internal_leave(this);
+static void gui_internal_cmd_log(struct gui_priv *this) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ gui_internal_enter(this, 1);
+ gui_internal_set_click_coord(this, NULL);
+ gui_internal_enter_setup(this);
+ wb=gui_internal_menu(this, "Log Message");
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message")));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_log_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
+ gui_internal_leave(this);
}
-static void
-gui_internal_cmd_menu2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *href=NULL;
- int i=0, ignore=0, replace=0;
-
- if (in && in[i] && ATTR_IS_INT(in[i]->type))
- ignore=in[i++]->u.num;
-
- if (in && in[i] && ATTR_IS_STRING(in[i]->type)) {
- href=in[i++]->u.str;
- if (in[i] && ATTR_IS_INT(in[i]->type))
- replace=in[i++]->u.num;
- }
-
- if (this->root.children) {
- if (!href)
- return;
- gui_internal_html_load_href(this, href, replace);
- return;
- }
- gui_internal_cmd_menu(this, ignore, href);
+static void gui_internal_cmd_menu2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *href=NULL;
+ int i=0, ignore=0, replace=0;
+
+ if (in && in[i] && ATTR_IS_INT(in[i]->type))
+ ignore=in[i++]->u.num;
+
+ if (in && in[i] && ATTR_IS_STRING(in[i]->type)) {
+ href=in[i++]->u.str;
+ if (in[i] && ATTR_IS_INT(in[i]->type))
+ replace=in[i++]->u.num;
+ }
+
+ if (this->root.children) {
+ if (!href)
+ return;
+ gui_internal_html_load_href(this, href, replace);
+ return;
+ }
+ gui_internal_cmd_menu(this, ignore, href);
}
-static void
-gui_internal_cmd2_position(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- const char *name=_("Position");
- int flags=-1;
-
- dbg(lvl_debug,"enter\n");
- if (!in || !in[0])
- return;
- if (!ATTR_IS_COORD_GEO(in[0]->type))
- return;
- if (in[1] && ATTR_IS_STRING(in[1]->type)) {
- name=in[1]->u.str;
- if (in[2] && ATTR_IS_INT(in[2]->type))
- flags=in[2]->u.num;
- }
- dbg(lvl_debug,"flags=0x%x\n",flags);
- gui_internal_cmd_position_do(this, NULL, in[0]->u.coord_geo, NULL, name, flags);
+static void gui_internal_cmd2_position(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ const char *name=_("Position");
+ int flags=-1;
+
+ dbg(lvl_debug,"enter");
+ if (!in || !in[0])
+ return;
+ if (!ATTR_IS_COORD_GEO(in[0]->type))
+ return;
+ if (in[1] && ATTR_IS_STRING(in[1]->type)) {
+ name=in[1]->u.str;
+ if (in[2] && ATTR_IS_INT(in[2]->type))
+ flags=in[2]->u.num;
+ }
+ dbg(lvl_debug,"flags=0x%x",flags);
+ gui_internal_cmd_position_do(this, NULL, in[0]->u.coord_geo, NULL, name, flags);
}
-static void
-gui_internal_cmd_redraw_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- this->redraw=1;
+static void gui_internal_cmd_redraw_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ this->redraw=1;
}
-static void
-gui_internal_cmd2_refresh(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *href=g_strdup(this->href);
- gui_internal_html_load_href(this, href, 1);
- g_free(href);
+static void gui_internal_cmd2_refresh(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *href=g_strdup(this->href);
+ gui_internal_html_load_href(this, href, 1);
+ g_free(href);
}
-static void
-gui_internal_cmd2_set(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *pattern,*command=NULL;
- if (!in || !in[0] || !ATTR_IS_STRING(in[0]->type)) {
- dbg(lvl_error,"first parameter missing or wrong type\n");
- return;
- }
- pattern=in[0]->u.str;
- dbg(lvl_debug,"pattern %s\n",pattern);
- if (in[1]) {
- command=gui_internal_cmd_match_expand(pattern, in+1);
- dbg(lvl_debug,"expand %s\n",command);
- gui_internal_set(pattern, command);
- command_evaluate(&this->self, command);
- g_free(command);
- } else {
- gui_internal_set(pattern, NULL);
- }
+static void gui_internal_cmd2_set(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *pattern,*command=NULL;
+ if (!in || !in[0] || !ATTR_IS_STRING(in[0]->type)) {
+ dbg(lvl_error,"first parameter missing or wrong type");
+ return;
+ }
+ pattern=in[0]->u.str;
+ dbg(lvl_debug,"pattern %s",pattern);
+ if (in[1]) {
+ command=gui_internal_cmd_match_expand(pattern, in+1);
+ dbg(lvl_debug,"expand %s",command);
+ gui_internal_set(pattern, command);
+ command_evaluate(&this->self, command);
+ g_free(command);
+ } else {
+ gui_internal_set(pattern, NULL);
+ }
}
-void
-gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr navit;
- gui_internal_prune_menu(this, NULL);
- navit.type=attr_navit;
- navit.u.navit=this->nav;
- config_remove_attr(config, &navit);
- event_main_loop_quit();
+void gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ struct attr navit;
+ gui_internal_prune_menu(this, NULL);
+ navit.type=attr_navit;
+ navit.u.navit=this->nav;
+ config_remove_attr(config, &navit);
+ event_main_loop_quit();
}
-static char *
-gui_internal_append_attr(char *str, enum escape_mode mode, char *pre, struct attr *attr, char *post)
-{
- char *astr=NULL;
- if (ATTR_IS_STRING(attr->type))
- astr=gui_internal_escape(mode, attr->u.str);
- else if (ATTR_IS_COORD_GEO(attr->type)) {
- char *str2=coordinates_geo(attr->u.coord_geo, '\n');
- astr=gui_internal_escape(mode, str2);
- g_free(str2);
- } else if (ATTR_IS_INT(attr->type))
- astr=g_strdup_printf("%ld",attr->u.num);
- else
- astr=g_strdup_printf("Unsupported type %s",attr_to_name(attr->type));
- str=g_strconcat_printf(str,"%s%s%s",pre,astr,post);
- g_free(astr);
- return str;
+static char *gui_internal_append_attr(char *str, enum escape_mode mode, char *pre, struct attr *attr, char *post) {
+ char *astr=NULL;
+ if (ATTR_IS_STRING(attr->type))
+ astr=gui_internal_escape(mode, attr->u.str);
+ else if (ATTR_IS_COORD_GEO(attr->type)) {
+ char *str2=coordinates_geo(attr->u.coord_geo, '\n');
+ astr=gui_internal_escape(mode, str2);
+ g_free(str2);
+ } else if (ATTR_IS_INT(attr->type))
+ astr=g_strdup_printf("%ld",attr->u.num);
+ else
+ astr=g_strdup_printf("Unsupported type %s",attr_to_name(attr->type));
+ str=g_strconcat_printf(str,"%s%s%s",pre,astr,post);
+ g_free(astr);
+ return str;
}
-static void
-gui_internal_cmd_write(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=NULL;
- dbg(lvl_debug,"enter %s %p %p %p\n",function,in,out,valid);
- if (!in)
- return;
- while (*in) {
- str=gui_internal_append_attr(str, escape_mode_none, "", *in, "");
- in++;
- }
- if (str) {
- str=g_strdup_printf("<html>%s</html>\n",str);
+static void gui_internal_cmd_write(struct gui_priv * this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str=NULL;
+ dbg(lvl_debug,"enter %s %p %p %p",function,in,out,valid);
+ if (!in)
+ return;
+ while (*in) {
+ str=gui_internal_append_attr(str, escape_mode_none, "", *in, "");
+ in++;
+ }
+ if (str) {
+ str=g_strdup_printf("<html>%s</html>\n",str);
#if 0
- dbg(lvl_debug,"%s\n",str);
+ dbg(lvl_debug,"%s",str);
#endif
- gui_internal_html_parse_text(this, str);
- }
- g_free(str);
+ gui_internal_html_parse_text(this, str);
+ }
+ g_free(str);
}
-static void
-gui_internal_onclick(struct attr ***in, char **onclick, char *set)
-{
- struct attr **i=*in;
- char *c,*str=NULL,*args=NULL,*sep="";
-
- if (!*i || !ATTR_IS_STRING((*i)->type) || !(*i)->u.str)
- goto error;
- str=g_strdup((*i)->u.str);
- i++;
- c=str;
- while (*c) {
- if (c[0] == '%' && c[1] == '{') {
- char format[4],*end=strchr(c+2,'}'),*replacement=NULL,*new_str;
- int is_arg;
- if (!end) {
- dbg(lvl_error,"Missing closing brace in format string %s\n",c);
- goto error;
- }
- if (end-c > sizeof(format)) {
- dbg(lvl_error,"Invalid format string %s\n",c);
- goto error;
- }
- strncpy(format, c+2, end-c-2);
- format[end-c-2]='\0';
- is_arg=end[1] == '*';
- c[0]='\0';
- if (!strcmp(format,"d")) {
- replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
- if (is_arg) {
- args=g_strconcat_printf(args, "%s%s", args ? "," : "", replacement);
- g_free(replacement);
- replacement=g_strdup("");
- }
-
- }
- if (!strcmp(format,"se")) {
- replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
- if (is_arg) {
- char *arg=gui_internal_escape(escape_mode_string, replacement);
- args=g_strconcat_printf(args, "%s%s", args ? "," : "", arg);
- g_free(replacement);
- g_free(arg);
- replacement=g_strdup("");
- }
- }
- if (!replacement) {
- dbg(lvl_error,"Unsupported format string %s\n",format);
- goto error;
- }
- new_str=g_strconcat(str, replacement, end+1, NULL);
- c=new_str+strlen(str)+strlen(replacement);
- g_free(str);
- g_free(replacement);
- str=new_str;
- }
- c++;
- }
- *in=i;
- if (*onclick && strlen(*onclick))
- sep=";";
- if (str && strlen(str)) {
- char *old=*onclick;
- if (set) {
- char *setstr=gui_internal_escape(escape_mode_string,str);
- char *argssep="";
- if (args && strlen(args))
- argssep=",";
- *onclick=g_strconcat(old,sep,set,"(",setstr,argssep,args,")",NULL);
- } else {
- *onclick=g_strconcat(old,sep,str,NULL);
- }
- g_free(old);
- }
+static void gui_internal_onclick(struct attr ***in, char **onclick, char *set) {
+ struct attr **i=*in;
+ char *c,*str=NULL,*args=NULL,*sep="";
+
+ if (!*i || !ATTR_IS_STRING((*i)->type) || !(*i)->u.str)
+ goto error;
+ str=g_strdup((*i)->u.str);
+ i++;
+ c=str;
+ while (*c) {
+ if (c[0] == '%' && c[1] == '{') {
+ char format[4],*end=strchr(c+2,'}'),*replacement=NULL,*new_str;
+ int is_arg;
+ if (!end) {
+ dbg(lvl_error,"Missing closing brace in format string %s",c);
+ goto error;
+ }
+ if (end-c > sizeof(format)) {
+ dbg(lvl_error,"Invalid format string %s",c);
+ goto error;
+ }
+ strncpy(format, c+2, end-c-2);
+ format[end-c-2]='\0';
+ is_arg=end[1] == '*';
+ c[0]='\0';
+ if (!strcmp(format,"d")) {
+ replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
+ if (is_arg) {
+ args=g_strconcat_printf(args, "%s%s", args ? "," : "", replacement);
+ g_free(replacement);
+ replacement=g_strdup("");
+ }
+
+ }
+ if (!strcmp(format,"se")) {
+ replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
+ if (is_arg) {
+ char *arg=gui_internal_escape(escape_mode_string, replacement);
+ args=g_strconcat_printf(args, "%s%s", args ? "," : "", arg);
+ g_free(replacement);
+ g_free(arg);
+ replacement=g_strdup("");
+ }
+ }
+ if (!replacement) {
+ dbg(lvl_error,"Unsupported format string %s",format);
+ goto error;
+ }
+ new_str=g_strconcat(str, replacement, end+1, NULL);
+ c=new_str+strlen(str)+strlen(replacement);
+ g_free(str);
+ g_free(replacement);
+ str=new_str;
+ }
+ c++;
+ }
+ *in=i;
+ if (*onclick && strlen(*onclick))
+ sep=";";
+ if (str && strlen(str)) {
+ char *old=*onclick;
+ if (set) {
+ char *setstr=gui_internal_escape(escape_mode_string,str);
+ char *argssep="";
+ if (args && strlen(args))
+ argssep=",";
+ *onclick=g_strconcat(old,sep,set,"(",setstr,argssep,args,")",NULL);
+ } else {
+ *onclick=g_strconcat(old,sep,str,NULL);
+ }
+ g_free(old);
+ }
error:
- g_free(str);
- g_free(args);
- return;
+ g_free(str);
+ g_free(args);
+ return;
}
-static void
-gui_internal_cmd_img(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=g_strdup("<img"),*suffix=NULL,*onclick=g_strdup(""),*html;
-
- if (ATTR_IS_STRING((*in)->type)) {
- if ((*in)->u.str && strlen((*in)->u.str))
- str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " class=", *in, "");
- in++;
- } else {
- dbg(lvl_error,"argument error: class argument not string\n");
- goto error;
- }
- if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
- if ((*in)->u.str && strlen((*in)->u.str)) {
- str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " src=", *in, "");
- }
- in++;
- } else {
- dbg(lvl_error,"argument error: image argument not string\n");
- goto error;
- }
- if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
- if ((*in)->u.str && strlen((*in)->u.str)) {
- suffix=gui_internal_append_attr(NULL, escape_mode_html, ">", *in, "</img>");
- } else {
- suffix=g_strdup("/>");
- }
- in++;
- } else {
- dbg(lvl_error,"argument error: text argument not string\n");
- goto error;
- }
- gui_internal_onclick(&in,&onclick,NULL);
- gui_internal_onclick(&in,&onclick,"set");
- gui_internal_onclick(&in,&onclick,NULL);
- if (strlen(onclick)) {
- char *tmp=gui_internal_escape(escape_mode_html_apos, onclick);
- str=g_strconcat_printf(str," onclick='%s'",tmp);
- g_free(tmp);
- }
- g_free(onclick);
- html=g_strdup_printf("<html>%s%s</html>\n",str,suffix);
- dbg(lvl_debug,"return %s",html);
- gui_internal_html_parse_text(this, html);
- g_free(html);
+static void gui_internal_cmd_img(struct gui_priv * this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str=g_strdup("<img"),*suffix=NULL,*onclick=g_strdup(""),*html;
+
+ if (ATTR_IS_STRING((*in)->type)) {
+ if ((*in)->u.str && strlen((*in)->u.str))
+ str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " class=", *in, "");
+ in++;
+ } else {
+ dbg(lvl_error,"argument error: class argument not string");
+ goto error;
+ }
+ if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
+ if ((*in)->u.str && strlen((*in)->u.str)) {
+ str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " src=", *in, "");
+ }
+ in++;
+ } else {
+ dbg(lvl_error,"argument error: image argument not string");
+ goto error;
+ }
+ if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
+ if ((*in)->u.str && strlen((*in)->u.str)) {
+ suffix=gui_internal_append_attr(NULL, escape_mode_html, ">", *in, "</img>");
+ } else {
+ suffix=g_strdup("/>");
+ }
+ in++;
+ } else {
+ dbg(lvl_error,"argument error: text argument not string");
+ goto error;
+ }
+ gui_internal_onclick(&in,&onclick,NULL);
+ gui_internal_onclick(&in,&onclick,"set");
+ gui_internal_onclick(&in,&onclick,NULL);
+ if (strlen(onclick)) {
+ char *tmp=gui_internal_escape(escape_mode_html_apos, onclick);
+ str=g_strconcat_printf(str," onclick='%s'",tmp);
+ g_free(tmp);
+ }
+ g_free(onclick);
+ html=g_strdup_printf("<html>%s%s</html>\n",str,suffix);
+ dbg(lvl_debug,"return %s",html);
+ gui_internal_html_parse_text(this, html);
+ g_free(html);
error:
- g_free(suffix);
- g_free(str);
- return;
+ g_free(suffix);
+ g_free(str);
+ return;
}
-static void
-gui_internal_cmd_debug(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str;
- dbg(lvl_debug,"begin\n");
- if (in) {
- while (*in) {
- str=attr_to_text(*in, NULL, 0);
- dbg(lvl_debug,"%s:%s\n",attr_to_name((*in)->type),str);
- in++;
- g_free(str);
- }
- }
- dbg(lvl_debug,"done\n");
+static void gui_internal_cmd_debug(struct gui_priv * this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str;
+ dbg(lvl_debug,"begin");
+ if (in) {
+ while (*in) {
+ str=attr_to_text(*in, NULL, 0);
+ dbg(lvl_debug,"%s:%s",attr_to_name((*in)->type),str);
+ in++;
+ g_free(str);
+ }
+ }
+ dbg(lvl_debug,"done");
}
-static void
-gui_internal_cmd2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- int entering=0;
- int ignore=1;
- if (in && in[0] && ATTR_IS_INT(in[0]->type)) {
- ignore=in[0]->u.num;
- in++;
- }
-
- if(!this->root.children) {
- entering=1;
- gui_internal_apply_config(this);
- gui_internal_enter(this, ignore);
- gui_internal_enter_setup(this);
- }
-
- if(!strcmp(function, "bookmarks"))
- gui_internal_cmd2_bookmarks(this, function, in, out, valid);
- else if(!strcmp(function, "formerdests"))
- gui_internal_cmd_formerdests(this, function, in, out, valid);
- else if(!strcmp(function, "locale"))
- gui_internal_cmd2_locale(this, function, in, out, valid);
- else if(!strcmp(function, "network_info"))
- gui_internal_cmd2_network_info(this, function, in, out, valid);
- else if(!strcmp(function, "position"))
- gui_internal_cmd2_position(this, function, in, out, valid);
- else if(!strcmp(function, "pois"))
- gui_internal_cmd2_pois(this, function, in, out, valid);
- else if(!strcmp(function, "route_description"))
- gui_internal_cmd2_route_description(this, function, in, out, valid);
- else if(!strcmp(function, "route_height_profile"))
- gui_internal_cmd2_route_height_profile(this, function, in, out, valid);
- else if(!strcmp(function, "setting_layout"))
- gui_internal_cmd2_setting_layout(this, function, in, out, valid);
- else if(!strcmp(function, "setting_maps"))
- gui_internal_cmd2_setting_maps(this, function, in, out, valid);
- else if(!strcmp(function, "setting_rules"))
- gui_internal_cmd2_setting_rules(this, function, in, out, valid);
- else if(!strcmp(function, "setting_vehicle"))
- gui_internal_cmd2_setting_vehicle(this, function, in, out, valid);
- else if(!strcmp(function, "town"))
- gui_internal_cmd2_town(this, function, in, out, valid);
- else if(!strcmp(function, "enter_coord"))
- gui_internal_cmd_enter_coord(this, function, in, out, valid);
- else if(!strcmp(function, "waypoints"))
- gui_internal_cmd2_waypoints(this, function, in, out, valid);
- else if(!strcmp(function, "about"))
- gui_internal_cmd2_about(this, function, in, out, valid);
-
- if(entering)
- graphics_draw_mode(this->gra, draw_mode_end);
+static void gui_internal_cmd2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ int entering=0;
+ int ignore=1;
+ if (in && in[0] && ATTR_IS_INT(in[0]->type)) {
+ ignore=in[0]->u.num;
+ in++;
+ }
+
+ if(!this->root.children) {
+ entering=1;
+ gui_internal_apply_config(this);
+ gui_internal_enter(this, ignore);
+ gui_internal_enter_setup(this);
+ }
+
+ if(!strcmp(function, "bookmarks"))
+ gui_internal_cmd2_bookmarks(this, function, in, out, valid);
+ else if(!strcmp(function, "formerdests"))
+ gui_internal_cmd_formerdests(this, function, in, out, valid);
+ else if(!strcmp(function, "locale"))
+ gui_internal_cmd2_locale(this, function, in, out, valid);
+ else if(!strcmp(function, "network_info"))
+ gui_internal_cmd2_network_info(this, function, in, out, valid);
+ else if(!strcmp(function, "position"))
+ gui_internal_cmd2_position(this, function, in, out, valid);
+ else if(!strcmp(function, "pois"))
+ gui_internal_cmd2_pois(this, function, in, out, valid);
+ else if(!strcmp(function, "route_description"))
+ gui_internal_cmd2_route_description(this, function, in, out, valid);
+ else if(!strcmp(function, "route_height_profile"))
+ gui_internal_cmd2_route_height_profile(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_layout"))
+ gui_internal_cmd2_setting_layout(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_maps"))
+ gui_internal_cmd2_setting_maps(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_rules"))
+ gui_internal_cmd2_setting_rules(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_vehicle"))
+ gui_internal_cmd2_setting_vehicle(this, function, in, out, valid);
+ else if(!strcmp(function, "town"))
+ gui_internal_cmd2_town(this, function, in, out, valid);
+ else if(!strcmp(function, "enter_coord"))
+ gui_internal_cmd_enter_coord(this, function, in, out, valid);
+ else if(!strcmp(function, "waypoints"))
+ gui_internal_cmd2_waypoints(this, function, in, out, valid);
+ else if(!strcmp(function, "about"))
+ gui_internal_cmd2_about(this, function, in, out, valid);
+
+ if(entering)
+ graphics_draw_mode(this->gra, draw_mode_end);
}
static struct command_table commands[] = {
- {"E",command_cast(gui_internal_cmd_escape)},
- {"abort_navigation",command_cast(gui_internal_cmd2_abort_navigation)},
- {"back",command_cast(gui_internal_cmd2_back)},
- {"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
- {"bookmarks",command_cast(gui_internal_cmd2)},
- {"debug",command_cast(gui_internal_cmd_debug)},
- {"formerdests",command_cast(gui_internal_cmd2)},
- {"get_data",command_cast(gui_internal_get_data)},
- {"img",command_cast(gui_internal_cmd_img)},
- {"locale",command_cast(gui_internal_cmd2)},
- {"log",command_cast(gui_internal_cmd_log)},
- {"menu",command_cast(gui_internal_cmd_menu2)},
- {"position",command_cast(gui_internal_cmd2_position)},
- {"pois",command_cast(gui_internal_cmd2)},
- {"redraw_map",command_cast(gui_internal_cmd_redraw_map)},
- {"refresh",command_cast(gui_internal_cmd2_refresh)},
- {"route_description",command_cast(gui_internal_cmd2)},
- {"route_height_profile",command_cast(gui_internal_cmd2)},
- {"set",command_cast(gui_internal_cmd2_set)},
- {"setting_layout",command_cast(gui_internal_cmd2)},
- {"setting_maps",command_cast(gui_internal_cmd2)},
- {"setting_rules",command_cast(gui_internal_cmd2)},
- {"setting_vehicle",command_cast(gui_internal_cmd2)},
- {"town",command_cast(gui_internal_cmd2)},
- {"enter_coord",command_cast(gui_internal_cmd2)},
- {"quit",command_cast(gui_internal_cmd2_quit)},
- {"waypoints",command_cast(gui_internal_cmd2)},
- {"write",command_cast(gui_internal_cmd_write)},
- {"about",command_cast(gui_internal_cmd2)},
+ {"E",command_cast(gui_internal_cmd_escape)},
+ {"abort_navigation",command_cast(gui_internal_cmd2_abort_navigation)},
+ {"back",command_cast(gui_internal_cmd2_back)},
+ {"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
+ {"bookmarks",command_cast(gui_internal_cmd2)},
+ {"debug",command_cast(gui_internal_cmd_debug)},
+ {"formerdests",command_cast(gui_internal_cmd2)},
+ {"get_data",command_cast(gui_internal_get_data)},
+ {"img",command_cast(gui_internal_cmd_img)},
+ {"locale",command_cast(gui_internal_cmd2)},
+ {"log",command_cast(gui_internal_cmd_log)},
+ {"menu",command_cast(gui_internal_cmd_menu2)},
+ {"position",command_cast(gui_internal_cmd2_position)},
+ {"pois",command_cast(gui_internal_cmd2)},
+ {"redraw_map",command_cast(gui_internal_cmd_redraw_map)},
+ {"refresh",command_cast(gui_internal_cmd2_refresh)},
+ {"route_description",command_cast(gui_internal_cmd2)},
+ {"route_height_profile",command_cast(gui_internal_cmd2)},
+ {"set",command_cast(gui_internal_cmd2_set)},
+ {"setting_layout",command_cast(gui_internal_cmd2)},
+ {"setting_maps",command_cast(gui_internal_cmd2)},
+ {"setting_rules",command_cast(gui_internal_cmd2)},
+ {"setting_vehicle",command_cast(gui_internal_cmd2)},
+ {"town",command_cast(gui_internal_cmd2)},
+ {"enter_coord",command_cast(gui_internal_cmd2)},
+ {"quit",command_cast(gui_internal_cmd2_quit)},
+ {"waypoints",command_cast(gui_internal_cmd2)},
+ {"write",command_cast(gui_internal_cmd_write)},
+ {"about",command_cast(gui_internal_cmd2)},
#if HAS_IFADDRS
- {"network_info",command_cast(gui_internal_cmd2)},
+ {"network_info",command_cast(gui_internal_cmd2)},
#endif
#ifdef USE_AUDIO_FRAMEWORK
{"media_show_playlist", command_cast (gui_internal_media_show_playlist)},
@@ -1347,13 +1327,11 @@ static struct command_table commands[] = {
};
-void
-gui_internal_command_init(struct gui_priv *this, struct attr **attrs)
-{
- struct attr *attr;
- if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
- command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this);
- }
+void gui_internal_command_init(struct gui_priv *this, struct attr **attrs) {
+ struct attr *attr;
+ if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
+ command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this);
+ }
}
diff --git a/navit/gui/internal/gui_internal_gesture.c b/navit/gui/internal/gui_internal_gesture.c
index d01a80f1d..0ed2805cc 100644
--- a/navit/gui/internal/gui_internal_gesture.c
+++ b/navit/gui/internal/gui_internal_gesture.c
@@ -27,119 +27,109 @@
#include "gui_internal_menu.h"
#include "gui_internal_gesture.h"
-void
-gui_internal_gesture_ring_clear(struct gui_priv *this)
-{
- this->gesture_ring_last=this->gesture_ring_first=0;
+void gui_internal_gesture_ring_clear(struct gui_priv *this) {
+ this->gesture_ring_last=this->gesture_ring_first=0;
};
-static struct gesture_elem *
-gui_internal_gesture_ring_get(struct gui_priv *this, int i)
-{
- int n=(this->gesture_ring_last-i+GESTURE_RINGSIZE)%GESTURE_RINGSIZE;
- if(n==this->gesture_ring_first)
- return NULL;
- return this->gesture_ring+n;
+static struct gesture_elem *gui_internal_gesture_ring_get(struct gui_priv *this, int i) {
+ int n=(this->gesture_ring_last-i+GESTURE_RINGSIZE)%GESTURE_RINGSIZE;
+ if(n==this->gesture_ring_first)
+ return NULL;
+ return this->gesture_ring+n;
};
-void
-gui_internal_gesture_ring_add(struct gui_priv *this, struct point *p)
-{
- long long msec;
+void gui_internal_gesture_ring_add(struct gui_priv *this, struct point *p) {
+ long long msec;
#ifndef HAVE_API_WIN32_CE
- struct timeval tv;
- gettimeofday(&tv,NULL);
- msec=((long long)tv.tv_sec)*1000+tv.tv_usec/1000;
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ msec=((long long)tv.tv_sec)*1000+tv.tv_usec/1000;
#else
- msec=GetTickCount();
+ msec=GetTickCount();
#endif
- this->gesture_ring_last++;
- this->gesture_ring_last%=GESTURE_RINGSIZE;
- if(this->gesture_ring_last==this->gesture_ring_first) {
- this->gesture_ring_first++;
- this->gesture_ring_first%=GESTURE_RINGSIZE;
- }
- this->gesture_ring[this->gesture_ring_last].p=*p;
- this->gesture_ring[this->gesture_ring_last].msec=msec;
- dbg(lvl_info,"msec="LONGLONG_FMT" x=%d y=%d\n",msec,p->x,p->y);
+ this->gesture_ring_last++;
+ this->gesture_ring_last%=GESTURE_RINGSIZE;
+ if(this->gesture_ring_last==this->gesture_ring_first) {
+ this->gesture_ring_first++;
+ this->gesture_ring_first%=GESTURE_RINGSIZE;
+ }
+ this->gesture_ring[this->gesture_ring_last].p=*p;
+ this->gesture_ring[this->gesture_ring_last].msec=msec;
+ dbg(lvl_info,"msec="LONGLONG_FMT" x=%d y=%d",msec,p->x,p->y);
};
-int
-gui_internal_gesture_get_vector(struct gui_priv *this, long long msec, struct point *p0, int *dx, int *dy)
-{
- struct gesture_elem *g;
- int x,y,dt;
- int i;
+int gui_internal_gesture_get_vector(struct gui_priv *this, long long msec, struct point *p0, int *dx, int *dy) {
+ struct gesture_elem *g;
+ int x,y,dt;
+ int i;
- dt=0;
+ dt=0;
- if(dx) *dx=0;
- if(dy) *dy=0;
- if(p0) {
- p0->x=-1;
- p0->y=-1;
- }
+ if(dx) *dx=0;
+ if(dy) *dy=0;
+ if(p0) {
+ p0->x=-1;
+ p0->y=-1;
+ }
- g=gui_internal_gesture_ring_get(this,0);
- if(!g)
- return 0;
- x=g->p.x;
- y=g->p.y;
- if(p0) {
- *p0=g->p;
- }
- msec=g->msec;
- dbg(lvl_info,LONGLONG_FMT" %d %d\n",g->msec, g->p.x, g->p.y);
- for(i=1;(g=gui_internal_gesture_ring_get(this,i))!=NULL;i++) {
- if( msec-g->msec > 1000 )
- break;
- dt=msec-g->msec;
- if(dx) *dx=x-g->p.x;
- if(dy) *dy=y-g->p.y;
- if(p0) {
- *p0=g->p;
- }
- dbg(lvl_info,LONGLONG_FMT" %d %d\n",g->msec, g->p.x, g->p.y);
- }
- return dt;
+ g=gui_internal_gesture_ring_get(this,0);
+ if(!g)
+ return 0;
+ x=g->p.x;
+ y=g->p.y;
+ if(p0) {
+ *p0=g->p;
+ }
+ msec=g->msec;
+ dbg(lvl_info,LONGLONG_FMT" %d %d",g->msec, g->p.x, g->p.y);
+ for(i=1; (g=gui_internal_gesture_ring_get(this,i))!=NULL; i++) {
+ if( msec-g->msec > 1000 )
+ break;
+ dt=msec-g->msec;
+ if(dx) *dx=x-g->p.x;
+ if(dy) *dy=y-g->p.y;
+ if(p0) {
+ *p0=g->p;
+ }
+ dbg(lvl_info,LONGLONG_FMT" %d %d",g->msec, g->p.x, g->p.y);
+ }
+ return dt;
}
-int
-gui_internal_gesture_do(struct gui_priv *this)
-{
- int dt;
- int dx,dy;
-
- dt=gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
+int gui_internal_gesture_do(struct gui_priv *this) {
+ int dt;
+ int dx,dy;
- if( abs(dx) > this->icon_s*3 && abs(dy) < this->icon_s ) {
- struct widget *wt;
- dbg(lvl_debug,"horizontal dx=%d dy=%d\n",dx,dy);
+ dt=gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
- /* Prevent swiping if widget was scrolled beforehand */
- if(this->pressed==2)
- return 0;
+ if( abs(dx) > this->icon_s*3 && abs(dy) < this->icon_s ) {
+ struct widget *wt;
+ dbg(lvl_debug,"horizontal dx=%d dy=%d",dx,dy);
- for(wt=this->highlighted;wt && wt->type!=widget_table;wt=wt->parent);
- if(!wt || wt->type!=widget_table || !wt->data)
- return 0;
- if(this->highlighted) {
- this->highlighted->state &= ~STATE_HIGHLIGHTED;
- this->highlighted=NULL;
- }
- if(dx<0)
- gui_internal_table_button_next(this,NULL,wt);
- else
- gui_internal_table_button_prev(this,NULL,wt);
- return 1;
- } else if( abs(dy) > this->icon_s*3 && abs(dx) < this->icon_s ) {
- dbg(lvl_debug,"vertical dx=%d dy=%d\n",dx,dy);
- } else if (dt>300 && abs(dx) <this->icon_s && abs(dy) <this->icon_s ) {
- dbg(lvl_debug,"longtap dx=%d dy=%d\n",dx,dy);
- } else {
- dbg(lvl_debug,"none dx=%d dy=%d\n",dx,dy);
- }
-
- return 0;
+ /* Prevent swiping if widget was scrolled beforehand */
+ if(this->pressed==2)
+ return 0;
+
+ for(wt=this->highlighted; wt && wt->type!=widget_table; wt=wt->parent);
+ if(!wt || wt->type!=widget_table || !wt->data)
+ return 0;
+ if(this->highlighted) {
+ this->highlighted->state &= ~STATE_HIGHLIGHTED;
+ this->highlighted=NULL;
+ }
+ if(dx<0)
+ gui_internal_table_button_next(this,NULL,wt);
+ else
+ gui_internal_table_button_prev(this,NULL,wt);
+ return 1;
+ } else if( abs(dy) > this->icon_s*3 && abs(dx) < this->icon_s ) {
+ dbg(lvl_debug,"vertical dx=%d dy=%d",dx,dy);
+ } else if (dt>300 && abs(dx) <this->icon_s && abs(dy) <this->icon_s ) {
+ dbg(lvl_debug,"longtap dx=%d dy=%d",dx,dy);
+ } else {
+ dbg(lvl_debug,"none dx=%d dy=%d",dx,dy);
+ }
+
+ return 0;
};
diff --git a/navit/gui/internal/gui_internal_html.c b/navit/gui/internal/gui_internal_html.c
index 9b42fbdec..41dab9f50 100644
--- a/navit/gui/internal/gui_internal_html.c
+++ b/navit/gui/internal/gui_internal_html.c
@@ -22,483 +22,462 @@ struct gui_priv;
struct form {
- char *onsubmit;
+ char *onsubmit;
};
struct html_tag_map {
- char *tag_name;
- enum html_tag tag;
+ char *tag_name;
+ enum html_tag tag;
} html_tag_map[] = {
- {"a",html_tag_a},
- {"h1",html_tag_h1},
- {"html",html_tag_html},
- {"img",html_tag_img},
- {"script",html_tag_script},
- {"form",html_tag_form},
- {"input",html_tag_input},
- {"div",html_tag_div},
+ {"a",html_tag_a},
+ {"h1",html_tag_h1},
+ {"html",html_tag_html},
+ {"img",html_tag_img},
+ {"script",html_tag_script},
+ {"form",html_tag_form},
+ {"input",html_tag_input},
+ {"div",html_tag_div},
};
-static const char *
-find_attr(const char **names, const char **values, const char *name)
-{
- while (*names) {
- if (!g_ascii_strcasecmp(*names, name))
- return *values;
- names+=XML_ATTR_DISTANCE;
- values+=XML_ATTR_DISTANCE;
- }
- return NULL;
+static const char *find_attr(const char **names, const char **values, const char *name) {
+ while (*names) {
+ if (!g_ascii_strcasecmp(*names, name))
+ return *values;
+ names+=XML_ATTR_DISTANCE;
+ values+=XML_ATTR_DISTANCE;
+ }
+ return NULL;
}
-static char *
-find_attr_dup(const char **names, const char **values, const char *name)
-{
- return g_strdup(find_attr(names, values, name));
+static char *find_attr_dup(const char **names, const char **values, const char *name) {
+ return g_strdup(find_attr(names, values, name));
}
-void
-gui_internal_html_main_menu(struct gui_priv *this)
-{
- gui_internal_prune_menu(this, NULL);
- gui_internal_html_load_href(this, "#Main Menu", 0);
+void gui_internal_html_main_menu(struct gui_priv *this) {
+ gui_internal_prune_menu(this, NULL);
+ gui_internal_html_load_href(this, "#Main Menu", 0);
}
-static void
-gui_internal_html_command(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_evaluate(this,w->command);
+static void gui_internal_html_command(struct gui_priv *this, struct widget *w, void *data) {
+ gui_internal_evaluate(this,w->command);
}
-static void
-gui_internal_html_submit_set(struct gui_priv *this, struct widget *w, struct form *form)
-{
- GList *l;
- if (w->form == form && w->name) {
- struct attr *attr=attr_new_from_text(w->name, w->text?w->text:"");
- if (attr)
- gui_set_attr(this->self.u.gui, attr);
- attr_free(attr);
- }
- l=w->children;
- while (l) {
- w=l->data;
- gui_internal_html_submit_set(this, w, form);
- l=g_list_next(l);
- }
+static void gui_internal_html_submit_set(struct gui_priv *this, struct widget *w, struct form *form) {
+ GList *l;
+ if (w->form == form && w->name) {
+ struct attr *attr=attr_new_from_text(w->name, w->text?w->text:"");
+ if (attr)
+ gui_set_attr(this->self.u.gui, attr);
+ attr_free(attr);
+ }
+ l=w->children;
+ while (l) {
+ w=l->data;
+ gui_internal_html_submit_set(this, w, form);
+ l=g_list_next(l);
+ }
}
-static void
-gui_internal_html_submit(struct gui_priv *this, struct widget *w, void *data)
-{
- struct widget *menu;
- GList *l;
-
- dbg(lvl_debug,"enter form %p %s\n",w->form,w->form->onsubmit);
- l=g_list_last(this->root.children);
- menu=l->data;
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_highlight_do(this, NULL);
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_html_submit_set(this, menu, w->form);
- gui_internal_evaluate(this,w->form->onsubmit);
+static void gui_internal_html_submit(struct gui_priv *this, struct widget *w, void *data) {
+ struct widget *menu;
+ GList *l;
+
+ dbg(lvl_debug,"enter form %p %s",w->form,w->form->onsubmit);
+ l=g_list_last(this->root.children);
+ menu=l->data;
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_highlight_do(this, NULL);
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_html_submit_set(this, menu, w->form);
+ gui_internal_evaluate(this,w->form->onsubmit);
}
-void
-gui_internal_html_load_href(struct gui_priv *this, char *href, int replace)
-{
- if (replace)
- gui_internal_prune_menu_count(this, 1, 0);
- if (href && href[0] == '#') {
- dbg(lvl_debug,"href=%s\n",href);
- g_free(this->href);
- this->href=g_strdup(href);
- gui_internal_html_menu(this, this->html_text, href+1);
- }
+void gui_internal_html_load_href(struct gui_priv *this, char *href, int replace) {
+ if (replace)
+ gui_internal_prune_menu_count(this, 1, 0);
+ if (href && href[0] == '#') {
+ dbg(lvl_debug,"href=%s",href);
+ g_free(this->href);
+ this->href=g_strdup(href);
+ gui_internal_html_menu(this, this->html_text, href+1);
+ }
}
-void
-gui_internal_html_href(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_html_load_href(this, w->command, 0);
+void gui_internal_html_href(struct gui_priv *this, struct widget *w, void *data) {
+ gui_internal_html_load_href(this, w->command, 0);
}
struct div_flags_map {
- char *attr;
- char *val;
- enum flags flags;
+ char *attr;
+ char *val;
+ enum flags flags;
} div_flags_map[] = {
- {"gravity","none",gravity_none},
- {"gravity","left",gravity_left},
- {"gravity","xcenter",gravity_xcenter},
- {"gravity","right",gravity_right},
- {"gravity","top",gravity_top},
- {"gravity","ycenter",gravity_ycenter},
- {"gravity","bottom",gravity_bottom},
- {"gravity","left_top",gravity_left_top},
- {"gravity","top_center",gravity_top_center},
- {"gravity","right_top",gravity_right_top},
- {"gravity","left_center",gravity_left_center},
- {"gravity","center",gravity_center},
- {"gravity","right_center",gravity_right_center},
- {"gravity","left_bottom",gravity_left_bottom},
- {"gravity","bottom_center",gravity_bottom_center},
- {"gravity","right_bottom",gravity_right_bottom},
- {"expand","1",flags_expand},
- {"fill","1",flags_fill},
- {"orientation","horizontal",orientation_horizontal},
- {"orientation","vertical",orientation_vertical},
- {"orientation","horizontal_vertical",orientation_horizontal_vertical},
+ {"gravity","none",gravity_none},
+ {"gravity","left",gravity_left},
+ {"gravity","xcenter",gravity_xcenter},
+ {"gravity","right",gravity_right},
+ {"gravity","top",gravity_top},
+ {"gravity","ycenter",gravity_ycenter},
+ {"gravity","bottom",gravity_bottom},
+ {"gravity","left_top",gravity_left_top},
+ {"gravity","top_center",gravity_top_center},
+ {"gravity","right_top",gravity_right_top},
+ {"gravity","left_center",gravity_left_center},
+ {"gravity","center",gravity_center},
+ {"gravity","right_center",gravity_right_center},
+ {"gravity","left_bottom",gravity_left_bottom},
+ {"gravity","bottom_center",gravity_bottom_center},
+ {"gravity","right_bottom",gravity_right_bottom},
+ {"expand","1",flags_expand},
+ {"fill","1",flags_fill},
+ {"orientation","horizontal",orientation_horizontal},
+ {"orientation","vertical",orientation_vertical},
+ {"orientation","horizontal_vertical",orientation_horizontal_vertical},
};
-static enum flags
-div_flag(const char **names, const char **values, char *name)
-{
- int i;
- enum flags ret=0;
- const char *value=find_attr(names, values, name);
- if (!value)
- return ret;
- for (i = 0 ; i < sizeof(div_flags_map)/sizeof(struct div_flags_map); i++) {
- if (!strcmp(div_flags_map[i].attr,name) && !strcmp(div_flags_map[i].val,value))
- ret|=div_flags_map[i].flags;
- }
- return ret;
+static enum flags div_flag(const char **names, const char **values, char *name) {
+ int i;
+ enum flags ret=0;
+ const char *value=find_attr(names, values, name);
+ if (!value)
+ return ret;
+ for (i = 0 ; i < sizeof(div_flags_map)/sizeof(struct div_flags_map); i++) {
+ if (!strcmp(div_flags_map[i].attr,name) && !strcmp(div_flags_map[i].val,value))
+ ret|=div_flags_map[i].flags;
+ }
+ return ret;
}
-static enum flags
-div_flags(const char **names, const char **values)
-{
- enum flags flags;
- flags = div_flag(names, values, "gravity");
- flags |= div_flag(names, values, "orientation");
- flags |= div_flag(names, values, "expand");
- flags |= div_flag(names, values, "fill");
- return flags;
+static enum flags div_flags(const char **names, const char **values) {
+ enum flags flags;
+ flags = div_flag(names, values, "gravity");
+ flags |= div_flag(names, values, "orientation");
+ flags |= div_flag(names, values, "expand");
+ flags |= div_flag(names, values, "fill");
+ return flags;
}
-static struct widget *
-html_image(struct gui_priv *this, const char **names, const char **values)
-{
- const char *src, *size;
- struct graphics_image *img=NULL;
-
- src=find_attr(names, values, "src");
- if (!src)
- return NULL;
- size=find_attr(names, values, "size");
- if (!size) {
- const char *class=find_attr(names, values, "class");
- if (class && !strcasecmp(class,"centry"))
- size="xs";
- else
- size="l";
- }
- if (!strcmp(size,"l"))
- img=image_new_l(this, src);
- else if (!strcmp(size,"s"))
- img=image_new_s(this, src);
- else if (!strcmp(size,"xs"))
- img=image_new_xs(this, src);
- if (!img)
- return NULL;
- return gui_internal_image_new(this, img);
+static struct widget *html_image(struct gui_priv *this, const char **names, const char **values) {
+ const char *src, *size;
+ struct graphics_image *img=NULL;
+
+ src=find_attr(names, values, "src");
+ if (!src)
+ return NULL;
+ size=find_attr(names, values, "size");
+ if (!size) {
+ const char *class=find_attr(names, values, "class");
+ if (class && !strcasecmp(class,"centry"))
+ size="xs";
+ else
+ size="l";
+ }
+ if (!strcmp(size,"l"))
+ img=image_new_l(this, src);
+ else if (!strcmp(size,"s"))
+ img=image_new_s(this, src);
+ else if (!strcmp(size,"xs"))
+ img=image_new_xs(this, src);
+ if (!img)
+ return NULL;
+ return gui_internal_image_new(this, img);
}
-static void
-gui_internal_html_start(xml_context *dummy, const char *tag_name, const char **names, const char **values, void *data, GError **error)
-{
- struct gui_priv *this=data;
- int i;
- enum html_tag tag=html_tag_none;
- struct html *html=&this->html[this->html_depth];
- const char *cond, *type, *font_size;
-
- if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
- return;
- html->skip=0;
- html->command=NULL;
- html->name=NULL;
- html->href=NULL;
- html->refresh_cond=NULL;
- html->w=NULL;
- html->container=NULL;
- html->font_size=0;
- cond=find_attr(names, values, "cond");
-
- if (cond && !this->html_skip) {
- if (!command_evaluate_to_boolean(&this->self, cond, NULL))
- html->skip=1;
- }
-
- for (i=0 ; i < sizeof(html_tag_map)/sizeof(struct html_tag_map); i++) {
- if (!g_ascii_strcasecmp(html_tag_map[i].tag_name, tag_name)) {
- tag=html_tag_map[i].tag;
- break;
- }
- }
- html->tag=tag;
- html->class=find_attr_dup(names, values, "class");
- if (!this->html_skip && !html->skip) {
- switch (tag) {
- case html_tag_a:
- html->name=find_attr_dup(names, values, "name");
- if (html->name) {
- html->skip=this->html_anchor ? strcmp(html->name,this->html_anchor) : 0;
- if (!html->skip)
- this->html_anchor_found=1;
- }
- html->command=find_attr_dup(names, values, "onclick");
- html->href=find_attr_dup(names, values, "href");
- html->refresh_cond=find_attr_dup(names, values, "refresh_cond");
- break;
- case html_tag_img:
- html->command=find_attr_dup(names, values, "onclick");
- html->w=html_image(this, names, values);
- break;
- case html_tag_form:
- this->form=g_new0(struct form, 1);
- this->form->onsubmit=find_attr_dup(names, values, "onsubmit");
- break;
- case html_tag_input:
- type=find_attr_dup(names, values, "type");
- if (!type)
- break;
- if (!strcmp(type,"image")) {
- html->w=html_image(this, names, values);
- if (html->w) {
- html->w->state|=STATE_SENSITIVE;
- html->w->func=gui_internal_html_submit;
- }
- }
- if (!strcmp(type,"text") || !strcmp(type,"password")) {
- const char *value=find_attr(names, values, "value");
- html->w=gui_internal_label_new(this, value);
- html->w->background=this->background;
- html->w->flags |= div_flags(names, values);
- html->w->state|=STATE_EDITABLE;
- if (!this->editable) {
- this->editable=html->w;
- html->w->state|=STATE_EDIT;
- }
- this->keyboard_required=1;
- if (!strcmp(type,"password"))
- html->w->flags2 |= 1;
- }
- if (html->w) {
- html->w->form=this->form;
- html->w->name=find_attr_dup(names, values, "name");
- }
- break;
- case html_tag_div:
- html->w=gui_internal_box_new(this, div_flags(names, values));
- font_size=find_attr(names, values, "font");
- if (font_size)
- html->font_size=atoi(font_size);
- html->container=this->html_container;
- this->html_container=html->w;
- break;
- default:
- break;
- }
- }
- this->html_skip+=html->skip;
- this->html_depth++;
+static void gui_internal_html_start(xml_context *dummy, const char *tag_name, const char **names, const char **values,
+ void *data,
+ GError **error) {
+ struct gui_priv *this=data;
+ int i;
+ enum html_tag tag=html_tag_none;
+ struct html *html=&this->html[this->html_depth];
+ const char *cond, *type, *font_size;
+
+ if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
+ return;
+ html->skip=0;
+ html->command=NULL;
+ html->name=NULL;
+ html->href=NULL;
+ html->refresh_cond=NULL;
+ html->w=NULL;
+ html->container=NULL;
+ html->font_size=0;
+ cond=find_attr(names, values, "cond");
+
+ if (cond && !this->html_skip) {
+ if (!command_evaluate_to_boolean(&this->self, cond, NULL))
+ html->skip=1;
+ }
+
+ for (i=0 ; i < sizeof(html_tag_map)/sizeof(struct html_tag_map); i++) {
+ if (!g_ascii_strcasecmp(html_tag_map[i].tag_name, tag_name)) {
+ tag=html_tag_map[i].tag;
+ break;
+ }
+ }
+ html->tag=tag;
+ html->class=find_attr_dup(names, values, "class");
+ if (!this->html_skip && !html->skip) {
+ switch (tag) {
+ case html_tag_a:
+ html->name=find_attr_dup(names, values, "name");
+ if (html->name) {
+ html->skip=this->html_anchor ? strcmp(html->name,this->html_anchor) : 0;
+ if (!html->skip)
+ this->html_anchor_found=1;
+ }
+ html->command=find_attr_dup(names, values, "onclick");
+ html->href=find_attr_dup(names, values, "href");
+ html->refresh_cond=find_attr_dup(names, values, "refresh_cond");
+ break;
+ case html_tag_img:
+ html->command=find_attr_dup(names, values, "onclick");
+ html->w=html_image(this, names, values);
+ break;
+ case html_tag_form:
+ this->form=g_new0(struct form, 1);
+ this->form->onsubmit=find_attr_dup(names, values, "onsubmit");
+ break;
+ case html_tag_input:
+ type=find_attr_dup(names, values, "type");
+ if (!type)
+ break;
+ if (!strcmp(type,"image")) {
+ html->w=html_image(this, names, values);
+ if (html->w) {
+ html->w->state|=STATE_SENSITIVE;
+ html->w->func=gui_internal_html_submit;
+ }
+ }
+ if (!strcmp(type,"text") || !strcmp(type,"password")) {
+ const char *value=find_attr(names, values, "value");
+ html->w=gui_internal_label_new(this, value);
+ html->w->background=this->background;
+ html->w->flags |= div_flags(names, values);
+ html->w->state|=STATE_EDITABLE;
+ if (!this->editable) {
+ this->editable=html->w;
+ html->w->state|=STATE_EDIT;
+ }
+ this->keyboard_required=1;
+ if (!strcmp(type,"password"))
+ html->w->flags2 |= 1;
+ }
+ if (html->w) {
+ html->w->form=this->form;
+ html->w->name=find_attr_dup(names, values, "name");
+ }
+ break;
+ case html_tag_div:
+ html->w=gui_internal_box_new(this, div_flags(names, values));
+ font_size=find_attr(names, values, "font");
+ if (font_size)
+ html->font_size=atoi(font_size);
+ html->container=this->html_container;
+ this->html_container=html->w;
+ break;
+ default:
+ break;
+ }
+ }
+ this->html_skip+=html->skip;
+ this->html_depth++;
}
-static void
-gui_internal_html_end(xml_context *dummy, const char *tag_name, void *data, GError **error)
-{
- struct gui_priv *this=data;
- struct html *html;
- struct html *parent=NULL;
-
- if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
- return;
- this->html_depth--;
- html=&this->html[this->html_depth];
- if (this->html_depth > 0)
- parent=&this->html[this->html_depth-1];
-
-
- if (!this->html_skip) {
- if (html->command && html->w) {
- html->w->state |= STATE_SENSITIVE;
- html->w->command=html->command;
- html->w->func=gui_internal_html_command;
- html->command=NULL;
- }
- if (parent && (parent->href || parent->command) && html->w) {
- html->w->state |= STATE_SENSITIVE;
- if (parent->command) {
- html->w->command=g_strdup(parent->command);
- html->w->func=gui_internal_html_command;
- } else {
- html->w->command=g_strdup(parent->href);
- html->w->func=gui_internal_html_href;
- }
- }
- switch (html->tag) {
- case html_tag_div:
- this->html_container=html->container;
- case html_tag_img:
- case html_tag_input:
- gui_internal_widget_append(this->html_container, html->w);
- break;
- case html_tag_form:
- this->form=NULL;
- break;
- default:
- break;
- }
- }
- this->html_skip-=html->skip;
- g_free(html->command);
- g_free(html->name);
- g_free(html->href);
- g_free(html->class);
- g_free(html->refresh_cond);
+static void gui_internal_html_end(xml_context *dummy, const char *tag_name, void *data, GError **error) {
+ struct gui_priv *this=data;
+ struct html *html;
+ struct html *parent=NULL;
+
+ if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
+ return;
+ this->html_depth--;
+ html=&this->html[this->html_depth];
+ if (this->html_depth > 0)
+ parent=&this->html[this->html_depth-1];
+
+
+ if (!this->html_skip) {
+ if (html->command && html->w) {
+ html->w->state |= STATE_SENSITIVE;
+ html->w->command=html->command;
+ html->w->func=gui_internal_html_command;
+ html->command=NULL;
+ }
+ if (parent && (parent->href || parent->command) && html->w) {
+ html->w->state |= STATE_SENSITIVE;
+ if (parent->command) {
+ html->w->command=g_strdup(parent->command);
+ html->w->func=gui_internal_html_command;
+ } else {
+ html->w->command=g_strdup(parent->href);
+ html->w->func=gui_internal_html_href;
+ }
+ }
+ switch (html->tag) {
+ case html_tag_div:
+ this->html_container=html->container;
+ case html_tag_img:
+ case html_tag_input:
+ gui_internal_widget_append(this->html_container, html->w);
+ break;
+ case html_tag_form:
+ this->form=NULL;
+ break;
+ default:
+ break;
+ }
+ }
+ this->html_skip-=html->skip;
+ g_free(html->command);
+ g_free(html->name);
+ g_free(html->href);
+ g_free(html->class);
+ g_free(html->refresh_cond);
}
-static void
-gui_internal_refresh_callback_called(struct gui_priv *this, struct menu_data *menu_data)
-{
- if (gui_internal_menu_data(this) == menu_data) {
- char *href=g_strdup(menu_data->href);
- gui_internal_html_load_href(this, href, 1);
- g_free(href);
- }
+static void gui_internal_refresh_callback_called(struct gui_priv *this, struct menu_data *menu_data) {
+ if (gui_internal_menu_data(this) == menu_data) {
+ char *href=g_strdup(menu_data->href);
+ gui_internal_html_load_href(this, href, 1);
+ g_free(href);
+ }
}
-static void
-gui_internal_set_refresh_callback(struct gui_priv *this, char *cond)
-{
- dbg(lvl_info,"cond=%s\n",cond);
- if (cond) {
- enum attr_type type;
- struct object_func *func;
- struct menu_data *menu_data=gui_internal_menu_data(this);
- dbg(lvl_info,"navit=%p\n",this->nav);
- type=command_evaluate_to_attr(&this->self, cond, NULL, &menu_data->refresh_callback_obj);
- if (type == attr_none) {
- dbg(lvl_error,"can't get type of '%s'\n",cond);
- return;
- }
- func=object_func_lookup(menu_data->refresh_callback_obj.type);
- if (!func)
- dbg(lvl_error,"'%s' has no functions\n",cond);
- if (func && !func->add_attr)
- dbg(lvl_error,"'%s' has no add_attr function\n",cond);
- if (!func || !func->add_attr)
- return;
- menu_data->refresh_callback.type=attr_callback;
- menu_data->refresh_callback.u.callback=callback_new_attr_2(callback_cast(gui_internal_refresh_callback_called),type,this,menu_data);
- func->add_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
- }
+static void gui_internal_set_refresh_callback(struct gui_priv *this, char *cond) {
+ dbg(lvl_info,"cond=%s",cond);
+ if (cond) {
+ enum attr_type type;
+ struct object_func *func;
+ struct menu_data *menu_data=gui_internal_menu_data(this);
+ dbg(lvl_info,"navit=%p",this->nav);
+ type=command_evaluate_to_attr(&this->self, cond, NULL, &menu_data->refresh_callback_obj);
+ if (type == attr_none) {
+ dbg(lvl_error,"can't get type of '%s'",cond);
+ return;
+ }
+ func=object_func_lookup(menu_data->refresh_callback_obj.type);
+ if (!func)
+ dbg(lvl_error,"'%s' has no functions",cond);
+ if (func && !func->add_attr)
+ dbg(lvl_error,"'%s' has no add_attr function",cond);
+ if (!func || !func->add_attr)
+ return;
+ menu_data->refresh_callback.type=attr_callback;
+ menu_data->refresh_callback.u.callback=callback_new_attr_2(callback_cast(gui_internal_refresh_callback_called),type,
+ this,menu_data);
+ func->add_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
+ }
}
-static void
-gui_internal_html_text(xml_context *dummy, const char *text, gsize len, void *data, GError **error)
-{
- struct gui_priv *this=data;
- struct widget *w;
- int depth=this->html_depth-1;
- struct html *html=&this->html[depth];
- gchar *text_stripped;
-
- if (this->html_skip)
- return;
- while (isspace(text[0])) {
- text++;
- len--;
- }
- while (len > 0 && isspace(text[len-1]))
- len--;
-
- text_stripped = g_strndup(text, len);
- if (html->tag == html_tag_html && depth > 2) {
- if (this->html[depth-1].tag == html_tag_script) {
- html=&this->html[depth-2];
- }
- }
- switch (html->tag) {
- case html_tag_a:
- if (html->name && len) {
- if (html->class && !strcasecmp(html->class,"clist"))
- this->html_container=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill /* |flags_scrolly */);
- else
- this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
- gui_internal_menu_data(this)->href=g_strdup(this->href);
- gui_internal_set_refresh_callback(this, html->refresh_cond);
- this->html_container->spx=this->spacing*10;
- }
- break;
- case html_tag_h1:
- if (!this->html_container) {
- this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
- this->html_container->spx=this->spacing*10;
- }
- break;
- case html_tag_img:
- if (len) {
- if (html->class && !strcasecmp(html->class, "centry"))
- w=gui_internal_box_new(this, gravity_left_top|orientation_horizontal|flags_fill);
- else
- w=gui_internal_box_new(this, gravity_center|orientation_vertical);
- gui_internal_widget_append(w, html->w);
- gui_internal_widget_append(w, gui_internal_text_new(this, _(text_stripped), gravity_left_top|orientation_vertical|flags_fill));
- html->w=w;
- }
- break;
- case html_tag_div:
- if (len) {
- gui_internal_widget_append(html->w, gui_internal_text_font_new(this, _(text_stripped), html->font_size, gravity_center|orientation_vertical));
- }
- break;
- case html_tag_script:
- dbg(lvl_debug,"execute %s\n",text_stripped);
- gui_internal_evaluate(this,text_stripped);
- break;
- default:
- break;
- }
- g_free(text_stripped);
+static void gui_internal_html_text(xml_context *dummy, const char *text, gsize len, void *data, GError **error) {
+ struct gui_priv *this=data;
+ struct widget *w;
+ int depth=this->html_depth-1;
+ struct html *html=&this->html[depth];
+ gchar *text_stripped;
+
+ if (this->html_skip)
+ return;
+ while (isspace(text[0])) {
+ text++;
+ len--;
+ }
+ while (len > 0 && isspace(text[len-1]))
+ len--;
+
+ text_stripped = g_strndup(text, len);
+ if (html->tag == html_tag_html && depth > 2) {
+ if (this->html[depth-1].tag == html_tag_script) {
+ html=&this->html[depth-2];
+ }
+ }
+ switch (html->tag) {
+ case html_tag_a:
+ if (html->name && len) {
+ if (html->class && !strcasecmp(html->class,"clist"))
+ this->html_container=gui_internal_box_new(this,
+ gravity_left_top|orientation_vertical|flags_expand|flags_fill /* |flags_scrolly */);
+ else
+ this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
+ gui_internal_menu_data(this)->href=g_strdup(this->href);
+ gui_internal_set_refresh_callback(this, html->refresh_cond);
+ this->html_container->spx=this->spacing*10;
+ }
+ break;
+ case html_tag_h1:
+ if (!this->html_container) {
+ this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
+ this->html_container->spx=this->spacing*10;
+ }
+ break;
+ case html_tag_img:
+ if (len) {
+ if (html->class && !strcasecmp(html->class, "centry"))
+ w=gui_internal_box_new(this, gravity_left_top|orientation_horizontal|flags_fill);
+ else
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical);
+ gui_internal_widget_append(w, html->w);
+ gui_internal_widget_append(w, gui_internal_text_new(this, _(text_stripped),
+ gravity_left_top|orientation_vertical|flags_fill));
+ html->w=w;
+ }
+ break;
+ case html_tag_div:
+ if (len) {
+ gui_internal_widget_append(html->w, gui_internal_text_font_new(this, _(text_stripped), html->font_size,
+ gravity_center|orientation_vertical));
+ }
+ break;
+ case html_tag_script:
+ dbg(lvl_debug,"execute %s",text_stripped);
+ gui_internal_evaluate(this,text_stripped);
+ break;
+ default:
+ break;
+ }
+ g_free(text_stripped);
}
-void
-gui_internal_html_parse_text(struct gui_priv *this, char *doc)
-{
- xml_parse_text(doc, this, gui_internal_html_start, gui_internal_html_end, gui_internal_html_text);
+void gui_internal_html_parse_text(struct gui_priv *this, char *doc) {
+ int res;
+
+ res = xml_parse_text(doc, this, gui_internal_html_start, gui_internal_html_end, gui_internal_html_text);
+
+ if (!res) {
+ dbg(lvl_error, "FATAL: Failed to parse XML data (looks like incorrect configuration for internal GUI).\n");
+ exit(1);
+ }
}
-void
-gui_internal_html_menu(struct gui_priv *this, const char *document, char *anchor)
-{
- char *doc=g_strdup(document);
- graphics_draw_mode(this->gra, draw_mode_begin);
- this->html_container=NULL;
- this->html_depth=0;
- this->html_anchor=anchor;
- this->html_anchor_found=0;
- this->form=NULL;
- this->keyboard_required=0;
- this->editable=NULL;
- callback_list_call_attr_2(this->cbl,attr_gui,anchor,&doc);
- gui_internal_html_parse_text(this, doc);
- g_free(doc);
- if (this->keyboard_required) {
- this->html_container->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
- if (this->keyboard)
- gui_internal_widget_append(this->html_container, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, this->html_container, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- }
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+void gui_internal_html_menu(struct gui_priv *this, const char *document, char *anchor) {
+ char *doc=g_strdup(document);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ this->html_container=NULL;
+ this->html_depth=0;
+ this->html_anchor=anchor;
+ this->html_anchor_found=0;
+ this->form=NULL;
+ this->keyboard_required=0;
+ this->editable=NULL;
+ callback_list_call_attr_2(this->cbl,attr_gui,anchor,&doc);
+ gui_internal_html_parse_text(this, doc);
+ g_free(doc);
+ if (this->keyboard_required) {
+ this->html_container->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
+ if (this->keyboard)
+ gui_internal_widget_append(this->html_container, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, this->html_container,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
+ }
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
}
diff --git a/navit/gui/internal/gui_internal_keyboard.c b/navit/gui/internal/gui_internal_keyboard.c
index 7ef1c3d36..19e48c468 100644
--- a/navit/gui/internal/gui_internal_keyboard.c
+++ b/navit/gui/internal/gui_internal_keyboard.c
@@ -19,22 +19,22 @@
*
* @param this The internal GUI instance
*/
-void
-gui_internal_keyboard_to_upper_case(struct gui_priv *this)
-{
- struct menu_data *md;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
-
- if (md->keyboard_mode == (VKBD_LATIN_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_UPPER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_UMLAUT_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_UPPER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_CYRILLIC_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_UPPER | VKBD_FLAG_2);
+void gui_internal_keyboard_to_upper_case(struct gui_priv *this) {
+ struct menu_data *md;
+
+ if (!this->keyboard)
+ return;
+
+ md=gui_internal_menu_data(this);
+
+ if (md->keyboard_mode == (VKBD_LATIN_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_UPPER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_UMLAUT_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_UPPER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_CYRILLIC_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_UPPER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_GREEK_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_GREEK_UPPER | VKBD_FLAG_2);
}
/**
@@ -44,22 +44,22 @@ gui_internal_keyboard_to_upper_case(struct gui_priv *this)
*
* @param this The internal GUI instance
*/
-void
-gui_internal_keyboard_to_lower_case(struct gui_priv *this)
-{
- struct menu_data *md;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
-
- if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2);
+void gui_internal_keyboard_to_lower_case(struct gui_priv *this) {
+ struct menu_data *md;
+
+ if (!this->keyboard)
+ return;
+
+ md=gui_internal_menu_data(this);
+
+ if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_GREEK_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_GREEK_LOWER | VKBD_FLAG_2);
}
/**
@@ -72,33 +72,30 @@ gui_internal_keyboard_to_lower_case(struct gui_priv *this)
* @param wm
* @param data Not used
*/
-static void
-gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_keypress_do(this, (char *) wm->data);
+static void gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_keypress_do(this, (char *) wm->data);
}
-
-static struct widget *
-gui_internal_keyboard_key_data(struct gui_priv *this, struct widget *wkbd, char *text, int font, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void (*data_free)(void *data), int w, int h)
-{
- struct widget *wk;
- gui_internal_widget_append(wkbd, wk=gui_internal_button_font_new_with_callback(this, text, font,
- NULL, gravity_center|orientation_vertical, func, data));
- wk->data_free=data_free;
- wk->background=this->background;
- wk->bl=0;
- wk->br=0;
- wk->bt=0;
- wk->bb=0;
- wk->w=w;
- wk->h=h;
- return wk;
+
+static struct widget *gui_internal_keyboard_key_data(struct gui_priv *this, struct widget *wkbd, char *text, int font,
+ void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void (*data_free)(void *data), int w,
+ int h) {
+ struct widget *wk;
+ gui_internal_widget_append(wkbd, wk=gui_internal_button_font_new_with_callback(this, text, font,
+ NULL, gravity_center|orientation_vertical, func, data));
+ wk->data_free=data_free;
+ wk->background=this->background;
+ wk->bl=0;
+ wk->br=0;
+ wk->bt=0;
+ wk->bb=0;
+ wk->w=w;
+ wk->h=h;
+ return wk;
}
-static struct widget *
-gui_internal_keyboard_key(struct gui_priv *this, struct widget *wkbd, char *text, char *key, int w, int h)
-{
- return gui_internal_keyboard_key_data(this, wkbd, text, 0, gui_internal_cmd_keypress, g_strdup(key), g_free_func,w,h);
+static struct widget *gui_internal_keyboard_key(struct gui_priv *this, struct widget *wkbd, char *text, char *key,
+ int w, int h) {
+ return gui_internal_keyboard_key_data(this, wkbd, text, 0, gui_internal_cmd_keypress, g_strdup(key), g_free_func,w,h);
}
static void gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data);
@@ -118,14 +115,16 @@ struct gui_internal_keyb_mode {
int case_mode; /**< Mode to switch to when case CHANGE() key is pressed. */
int umlaut_mode; /**< Mode to switch to when UMLAUT() key is pressed. */
} gui_internal_keyb_modes[]= {
- /* 0: VKBD_LATIN_UPPER */ {"ABC", 2, VKBD_LATIN_LOWER, VKBD_UMLAUT_UPPER},
- /* 8: VKBD_LATIN_LOWER */ {"abc", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER},
- /*16: VKBD_NUMERIC */ {"123", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_UPPER},
- /*24: VKBD_UMLAUT_UPPER */ {"ÄÖÜ", 2, VKBD_UMLAUT_LOWER, VKBD_LATIN_UPPER},
- /*32: VKBD_UMLAUT_LOWER */ {"äöü", 2, VKBD_UMLAUT_UPPER, VKBD_LATIN_LOWER},
- /*40: VKBD_CYRILLIC_UPPER*/ {"АБВ", 2, VKBD_CYRILLIC_LOWER, VKBD_LATIN_UPPER},
- /*48: VKBD_CYRILLIC_LOWER*/ {"абв", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_LOWER},
- /*56: VKBD_DEGREE */ {"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2}
+ /* 0: VKBD_LATIN_UPPER */ {"ABC", 2, VKBD_LATIN_LOWER, VKBD_UMLAUT_UPPER},
+ /* 8: VKBD_LATIN_LOWER */ {"abc", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER},
+ /*16: VKBD_NUMERIC */ {"123", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_UPPER},
+ /*24: VKBD_UMLAUT_UPPER */ {"ÄÖÜ", 2, VKBD_UMLAUT_LOWER, VKBD_LATIN_UPPER},
+ /*32: VKBD_UMLAUT_LOWER */ {"äöü", 2, VKBD_UMLAUT_UPPER, VKBD_LATIN_LOWER},
+ /*40: VKBD_CYRILLIC_UPPER*/ {"АБВ", 2, VKBD_CYRILLIC_LOWER, VKBD_LATIN_UPPER},
+ /*48: VKBD_CYRILLIC_LOWER*/ {"абв", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_LOWER},
+ /*56: VKBD_DEGREE */ {"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2},
+ /*64: VKBD_GREEK_UPPER */ {"ABΓ", 2, VKBD_GREEK_LOWER, VKBD_LATIN_UPPER},
+ /*72: VKBD_GREEK_LOWER */ {"abγ", 2, VKBD_GREEK_UPPER, VKBD_LATIN_LOWER}
};
@@ -140,6 +139,17 @@ struct gui_internal_keyb_mode {
-> datai = (mode & VKBD_MASK_7) | ((x) & VKBD_LAYOUT_MASK)
#define SWCASE() MODE(gui_internal_keyb_modes[mode/8].case_mode)
#define UMLAUT() MODE(gui_internal_keyb_modes[mode/8].umlaut_mode)
+
+
+static void gui_internal_keyboard_topbox_resize(struct gui_priv *this, struct widget *w, void *data,
+ int neww, int newh) {
+ struct menu_data *md=gui_internal_menu_data(this);
+ struct widget *old_wkbdb = md->keyboard;
+
+ dbg(lvl_debug, "resize called for keyboard widget %p with w=%d, h=%d", w, neww, newh);
+ gui_internal_keyboard_do(this, old_wkbdb, md->keyboard_mode);
+}
+
/**
* @brief Creates a new keyboard widget or switches the layout of an existing widget
*
@@ -155,231 +165,493 @@ struct gui_internal_keyb_mode {
* @return {@code wkbdb} if a non-NULL value was passed, else a new keyboard widget will be returned.
*/
struct widget *
-gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
-{
- struct widget *wkbd,*wk;
- struct menu_data *md=gui_internal_menu_data(this);
- int i, max_w=this->root.w, max_h=this->root.h;
- int render=0;
- char *space="_";
- char *backspace="←";
- char *hide="▼";
- char *unhide="▲";
-
- if (wkbdb) {
- this->current.x=-1;
- this->current.y=-1;
- gui_internal_highlight(this);
- if (md->keyboard_mode & VKBD_FLAG_1024)
- render=2;
- else
- render=1;
- gui_internal_widget_children_destroy(this, wkbdb);
- } else
- wkbdb=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- md->keyboard=wkbdb;
- md->keyboard_mode=mode;
- wkbd=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- wkbd->background=this->background;
- wkbd->cols=8;
- wkbd->spx=0;
- wkbd->spy=0;
- max_w=max_w/8;
- max_h=max_h/8; // Allows 3 results in the list when searching for Towns
- wkbd->p.y=max_h*2;
- if (((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) || ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER)) { // Russian/Ukrainian/Belarussian layout needs more space...
- max_h=max_h*4/5;
- max_w=max_w*8/9;
- wkbd->cols=9;
- }
-
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) {
- for (i = 0 ; i < 26 ; i++) {
- char text[]={'A'+i,'\0'};
- KEY(text);
- }
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- if (!(mode & VKBD_MASK_7)) {
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- } else {
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SWCASE();
- MODE(VKBD_NUMERIC);
-
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_LOWER) {
- for (i = 0 ; i < 26 ; i++) {
- char text[]={'a'+i,'\0'};
- KEY(text);
- }
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- if (!(mode & VKBD_MASK_7)) {
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- } else {
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SWCASE();
-
- MODE(VKBD_NUMERIC);
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_NUMERIC) {
- for (i = 0 ; i < 10 ; i++) {
- char text[]={'0'+i,'\0'};
- KEY(text);
- }
- /* ("8") ("9")*/KEY("."); KEY("°"); KEY("'"); KEY("\"");KEY("-"); KEY("+");
- KEY("*"); KEY("/"); KEY("("); KEY(")"); KEY("="); KEY("?"); KEY(":"); SPACER();
-
-
-
- if (!(mode & VKBD_MASK_7)) {
- SPACER();
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SPACER();
- SPACER();
- } else {
- SPACER();
- MODE(VKBD_CYRILLIC_UPPER);
- MODE(VKBD_CYRILLIC_LOWER);
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- MODE(VKBD_LATIN_UPPER);
- MODE(VKBD_LATIN_LOWER);
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_UPPER) {
- KEY("Ä"); KEY("Ë"); KEY("Ï"); KEY("Ö"); KEY("Ü"); KEY("Æ"); KEY("Ø"); KEY("Å");
- KEY("Á"); KEY("É"); KEY("Í"); KEY("Ó"); KEY("Ú"); KEY("Š"); KEY("Č"); KEY("Ž");
- KEY("À"); KEY("È"); KEY("Ì"); KEY("Ò"); KEY("Ù"); KEY("Ś"); KEY("Ć"); KEY("Ź");
- KEY("Â"); KEY("Ê"); KEY("Î"); KEY("Ô"); KEY("Û"); SPACER();
-
- UMLAUT();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_LOWER) {
- KEY("ä"); KEY("ë"); KEY("ï"); KEY("ö"); KEY("ü"); KEY("æ"); KEY("ø"); KEY("å");
- KEY("á"); KEY("é"); KEY("í"); KEY("ó"); KEY("ú"); KEY("š"); KEY("č"); KEY("ž");
- KEY("à"); KEY("è"); KEY("ì"); KEY("ò"); KEY("ù"); KEY("ś"); KEY("ć"); KEY("ź");
- KEY("â"); KEY("ê"); KEY("î"); KEY("ô"); KEY("û"); KEY("ß");
-
- UMLAUT();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) {
- KEY("А"); KEY("Б"); KEY("В"); KEY("Г"); KEY("Д"); KEY("Е"); KEY("Ж"); KEY("З"); KEY("И");
- KEY("Й"); KEY("К"); KEY("Л"); KEY("М"); KEY("Н"); KEY("О"); KEY("П"); KEY("Р"); KEY("С");
- KEY("Т"); KEY("У"); KEY("Ф"); KEY("Х"); KEY("Ц"); KEY("Ч"); KEY("Ш"); KEY("Щ"); KEY("Ъ");
- KEY("Ы"); KEY("Ь"); KEY("Э"); KEY("Ю"); KEY("Я"); KEY("Ё"); KEY("І"); KEY("Ї"); KEY("Ў");
- SPACER(); SPACER(); SPACER();
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SWCASE();
-
- MODE(VKBD_NUMERIC);
-
- SPACER();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER) {
- KEY("а"); KEY("б"); KEY("в"); KEY("г"); KEY("д"); KEY("е"); KEY("ж"); KEY("з"); KEY("и");
- KEY("й"); KEY("к"); KEY("л"); KEY("м"); KEY("н"); KEY("о"); KEY("п"); KEY("р"); KEY("с");
- KEY("т"); KEY("у"); KEY("ф"); KEY("х"); KEY("ц"); KEY("ч"); KEY("ш"); KEY("щ"); KEY("ъ");
- KEY("ы"); KEY("ь"); KEY("э"); KEY("ю"); KEY("я"); KEY("ё"); KEY("і"); KEY("ї"); KEY("ў");
- SPACER(); SPACER(); SPACER();
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SWCASE();
-
- MODE(VKBD_NUMERIC);
-
- SPACER();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
-
- if(md->search_list && md->search_list->type==widget_table) {
- struct table_data *td=(struct table_data*)(md->search_list->data);
- td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024);
- }
-
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */
- KEY("0"); KEY("1"); KEY("2"); KEY("3"); KEY("4"); SPACER(); KEY("N"); KEY("S");
- KEY("5"); KEY("6"); KEY("7"); KEY("8"); KEY("9"); SPACER(); KEY("E"); KEY("W");
- KEY("°"); KEY("."); KEY("'");
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- SPACER();
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SPACER();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
- if (mode & VKBD_FLAG_1024) {
- char *text=NULL;
- int font=0;
- struct widget *wkl;
- mode &= ~VKBD_FLAG_1024;
- text=gui_internal_keyb_modes[mode/8].title;
- font=gui_internal_keyb_modes[mode/8].font;
- wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill);
- wk->func=gui_internal_keyboard_change;
- wk->data=wkbdb;
- wk->background=this->background;
- wk->bl=0;
- wk->br=0;
- wk->bt=0;
- wk->bb=0;
- wk->w=max_w;
- wk->h=max_h;
- wk->datai=mode;
- wk->state |= STATE_SENSITIVE;
- gui_internal_widget_append(wk, wkl=gui_internal_label_new(this, unhide));
- wkl->background=NULL;
- gui_internal_widget_append(wk, wkl=gui_internal_label_font_new(this, text, font));
- wkl->background=NULL;
- gui_internal_widget_append(wkbd, wk);
- if (render)
- render=2;
- }
- gui_internal_widget_append(wkbdb, wkbd);
- if (render == 1) {
- gui_internal_widget_pack(this, wkbdb);
- gui_internal_widget_render(this, wkbdb);
- } else if (render == 2) {
- gui_internal_menu_reset_pack(this);
- gui_internal_menu_render(this);
- }
- return wkbdb;
+gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) {
+ struct widget *wkbd,*wk;
+ struct menu_data *md=gui_internal_menu_data(this);
+ int i, max_w=this->root.w, max_h=this->root.h;
+ int render=0;
+ char *space="_";
+ char *backspace="←";
+ char *hide="▼";
+ char *unhide="▲";
+
+ if (wkbdb) {
+ this->current.x=-1;
+ this->current.y=-1;
+ gui_internal_highlight(this);
+ if (md->keyboard_mode & VKBD_FLAG_1024)
+ render=2;
+ else
+ render=1;
+ gui_internal_widget_children_destroy(this, wkbdb);
+ gui_internal_widget_reset_pack(this, wkbdb);
+ gui_internal_widget_pack(this, wkbdb);
+ } else
+ wkbdb=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
+ md->keyboard=wkbdb;
+ md->keyboard_mode=mode;
+ wkbd=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
+ wkbd->background=this->background;
+ wkbd->cols=8;
+ wkbd->spx=0;
+ wkbd->spy=0;
+ wkbd->on_resize=gui_internal_keyboard_topbox_resize;
+ max_w=max_w/8;
+ max_h=max_h/8; // Allows 3 results in the list when searching for Towns
+ wkbd->p.y=max_h*2;
+ if (((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER)
+ || ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER)
+ || ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_UPPER)
+ || ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_LOWER)) { // Russian/Ukrainian/Belarussian/Greek layout needs more space...
+ max_h=max_h*4/5;
+ max_w=max_w*8/9;
+ wkbd->cols=9;
+ }
+
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) {
+ for (i = 0 ; i < 26 ; i++) {
+ char text[]= {'A'+i,'\0'};
+ KEY(text);
+ }
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+ if (!(mode & VKBD_MASK_7)) {
+ KEY("-");
+ KEY("'");
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ } else {
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ SWCASE();
+ MODE(VKBD_NUMERIC);
+
+ }
+ UMLAUT();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_LOWER) {
+ for (i = 0 ; i < 26 ; i++) {
+ char text[]= {'a'+i,'\0'};
+ KEY(text);
+ }
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+ if (!(mode & VKBD_MASK_7)) {
+ KEY("-");
+ KEY("'");
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ } else {
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+ }
+ UMLAUT();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_NUMERIC) {
+ for (i = 0 ; i < 10 ; i++) {
+ char text[]= {'0'+i,'\0'};
+ KEY(text);
+ }
+ /* ("8") ("9")*/KEY(".");
+ KEY("°");
+ KEY("'");
+ KEY("\"");
+ KEY("-");
+ KEY("+");
+ KEY("*");
+ KEY("/");
+ KEY("(");
+ KEY(")");
+ KEY("=");
+ KEY("?");
+ KEY(":");
+ KEY("_");
+
+
+
+ if (!(mode & VKBD_MASK_7)) {
+ MODE(VKBD_GREEK_UPPER);
+ KEY("-");
+ KEY("'");
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ SPACER();
+ SPACER();
+ } else {
+ if (mode == VKBD_GREEK_UPPER)
+ MODE(VKBD_GREEK_LOWER);
+ else
+ MODE(VKBD_GREEK_UPPER);
+ MODE(VKBD_CYRILLIC_UPPER);
+ MODE(VKBD_CYRILLIC_LOWER);
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ MODE(VKBD_LATIN_UPPER);
+ MODE(VKBD_LATIN_LOWER);
+ }
+ UMLAUT();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_UPPER) {
+ KEY("Ä");
+ KEY("Ë");
+ KEY("Ï");
+ KEY("Ö");
+ KEY("Ü");
+ KEY("Æ");
+ KEY("Ø");
+ KEY("Å");
+ KEY("Á");
+ KEY("É");
+ KEY("Í");
+ KEY("Ó");
+ KEY("Ú");
+ KEY("Š");
+ KEY("Č");
+ KEY("Ž");
+ KEY("À");
+ KEY("È");
+ KEY("Ì");
+ KEY("Ò");
+ KEY("Ù");
+ KEY("Ś");
+ KEY("Ć");
+ KEY("Ź");
+ KEY("Â");
+ KEY("Ê");
+ KEY("Î");
+ KEY("Ô");
+ KEY("Û");
+ SPACER();
+
+ UMLAUT();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_LOWER) {
+ KEY("ä");
+ KEY("ë");
+ KEY("ï");
+ KEY("ö");
+ KEY("ü");
+ KEY("æ");
+ KEY("ø");
+ KEY("å");
+ KEY("á");
+ KEY("é");
+ KEY("í");
+ KEY("ó");
+ KEY("ú");
+ KEY("š");
+ KEY("č");
+ KEY("ž");
+ KEY("à");
+ KEY("è");
+ KEY("ì");
+ KEY("ò");
+ KEY("ù");
+ KEY("ś");
+ KEY("ć");
+ KEY("ź");
+ KEY("â");
+ KEY("ê");
+ KEY("î");
+ KEY("ô");
+ KEY("û");
+ KEY("ß");
+
+ UMLAUT();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) {
+ KEY("А");
+ KEY("Б");
+ KEY("В");
+ KEY("Г");
+ KEY("Д");
+ KEY("Е");
+ KEY("Ж");
+ KEY("З");
+ KEY("И");
+ KEY("Й");
+ KEY("К");
+ KEY("Л");
+ KEY("М");
+ KEY("Н");
+ KEY("О");
+ KEY("П");
+ KEY("Р");
+ KEY("С");
+ KEY("Т");
+ KEY("У");
+ KEY("Ф");
+ KEY("Х");
+ KEY("Ц");
+ KEY("Ч");
+ KEY("Ш");
+ KEY("Щ");
+ KEY("Ъ");
+ KEY("Ы");
+ KEY("Ь");
+ KEY("Э");
+ KEY("Ю");
+ KEY("Я");
+ KEY("Ё");
+ KEY("І");
+ KEY("Ї");
+ KEY("Ў");
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER) {
+ KEY("а");
+ KEY("б");
+ KEY("в");
+ KEY("г");
+ KEY("д");
+ KEY("е");
+ KEY("ж");
+ KEY("з");
+ KEY("и");
+ KEY("й");
+ KEY("к");
+ KEY("л");
+ KEY("м");
+ KEY("н");
+ KEY("о");
+ KEY("п");
+ KEY("р");
+ KEY("с");
+ KEY("т");
+ KEY("у");
+ KEY("ф");
+ KEY("х");
+ KEY("ц");
+ KEY("ч");
+ KEY("ш");
+ KEY("щ");
+ KEY("ъ");
+ KEY("ы");
+ KEY("ь");
+ KEY("э");
+ KEY("ю");
+ KEY("я");
+ KEY("ё");
+ KEY("і");
+ KEY("ї");
+ KEY("ў");
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_UPPER) {
+ KEY("Α");
+ KEY("Β");
+ KEY("Γ");
+ KEY("Δ");
+ KEY("Ε");
+ KEY("Ζ");
+ KEY("Η");
+ KEY("Θ");
+ KEY("Ι");
+ KEY("Κ");
+ KEY("Λ");
+ KEY("Μ");
+ KEY("Ν");
+ KEY("Ξ");
+ KEY("Ο");
+ KEY("Π");
+ KEY("Ρ");
+ KEY("Σ");
+ KEY("Τ");
+ KEY("Υ");
+ KEY("Φ");
+ KEY("Χ");
+ KEY("Ψ");
+ KEY("Ω");
+ KEY("Ή");
+ KEY("Ά");
+ KEY("Ό");
+ KEY("Ί");
+ KEY("Ώ");
+ KEY("Έ");
+ KEY("Ύ");
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_LOWER) {
+ KEY("α");
+ KEY("β");
+ KEY("γ");
+ KEY("δ");
+ KEY("ε");
+ KEY("ζ");
+ KEY("η");
+ KEY("θ");
+ KEY("ι");
+ KEY("κ");
+ KEY("λ");
+ KEY("μ");
+ KEY("ν");
+ KEY("ξ");
+ KEY("ο");
+ KEY("π");
+ KEY("ρ");
+ KEY("σ");
+ KEY("τ");
+ KEY("υ");
+ KEY("φ");
+ KEY("χ");
+ KEY("ψ");
+ KEY("ω");
+ KEY("ή");
+ KEY("ά");
+ KEY("ό");
+ KEY("ί");
+ KEY("ώ");
+ KEY("έ");
+ KEY("ύ");
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+
+
+ if(md->search_list && md->search_list->type==widget_table) {
+ struct table_data *td=(struct table_data*)(md->search_list->data);
+ td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024);
+ }
+
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */
+ KEY("0");
+ KEY("1");
+ KEY("2");
+ KEY("3");
+ KEY("4");
+ SPACER();
+ KEY("N");
+ KEY("S");
+ KEY("5");
+ KEY("6");
+ KEY("7");
+ KEY("8");
+ KEY("9");
+ SPACER();
+ KEY("E");
+ KEY("W");
+ KEY("°");
+ KEY(".");
+ KEY("'");
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+ SPACER();
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+
+ if (mode & VKBD_FLAG_1024) {
+ char *text=NULL;
+ int font=0;
+ struct widget *wkl;
+ mode &= ~VKBD_FLAG_1024;
+ text=gui_internal_keyb_modes[mode/8].title;
+ font=gui_internal_keyb_modes[mode/8].font;
+ wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill);
+ wk->func=gui_internal_keyboard_change;
+ wk->data=wkbdb;
+ wk->background=this->background;
+ wk->bl=0;
+ wk->br=0;
+ wk->bt=0;
+ wk->bb=0;
+ wk->w=max_w;
+ wk->h=max_h;
+ wk->datai=mode;
+ wk->state |= STATE_SENSITIVE;
+ gui_internal_widget_append(wk, wkl=gui_internal_label_new(this, unhide));
+ wkl->background=NULL;
+ gui_internal_widget_append(wk, wkl=gui_internal_label_font_new(this, text, font));
+ wkl->background=NULL;
+ gui_internal_widget_append(wkbd, wk);
+ if (render)
+ render=2;
+ }
+ gui_internal_widget_append(wkbdb, wkbd);
+ if (render == 1) {
+ gui_internal_widget_pack(this, wkbdb);
+ gui_internal_widget_render(this, wkbdb);
+ } else if (render == 2) {
+ gui_internal_menu_reset_pack(this);
+ gui_internal_menu_render(this);
+ }
+ return wkbdb;
}
#undef KEY
#undef SPACER
@@ -401,17 +673,14 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
* @return A new keyboard widget
*/
struct widget *
-gui_internal_keyboard(struct gui_priv *this, int mode)
-{
- if (! this->keyboard)
- return NULL;
- return gui_internal_keyboard_do(this, NULL, mode);
+gui_internal_keyboard(struct gui_priv *this, int mode) {
+ if (! this->keyboard)
+ return NULL;
+ return gui_internal_keyboard_do(this, NULL, mode);
}
-static void
-gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data)
-{
- gui_internal_keyboard_do(this, key->data, key->datai);
+static void gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data) {
+ gui_internal_keyboard_do(this, key->data, key->datai);
}
/**
@@ -425,41 +694,41 @@ gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *da
* @return {@code VKBD_CYRILLIC_UPPER} for countries using the Cyrillic alphabet,
* {@code VKBD_LATIN_UPPER} otherwise
*/
-int
-gui_internal_keyboard_init_mode(char *lang)
-{
- int ret=0;
- /* do not crash if lang is NULL, which may be returned by getenv*/
- if(lang == NULL)
- return VKBD_LATIN_UPPER;
-
- /* Converting to upper case here is required for Android */
- lang=g_ascii_strup(lang,-1);
- /*
- * Set cyrillic keyboard for countries using Cyrillic alphabet
- */
- if (strstr(lang,"RU"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"UA"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"BY"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"RS"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"BG"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"MK"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"KZ"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"KG"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"TJ"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"MN"))
- ret = VKBD_CYRILLIC_UPPER;
- g_free(lang);
- return ret;
+int gui_internal_keyboard_init_mode(char *lang) {
+ int ret=0;
+ /* do not crash if lang is NULL, which may be returned by getenv*/
+ if(lang == NULL)
+ return VKBD_LATIN_UPPER;
+
+ /* Converting to upper case here is required for Android */
+ lang=g_ascii_strup(lang,-1);
+ /*
+ * Set cyrillic keyboard for countries using Cyrillic alphabet
+ */
+ if (strstr(lang,"RU"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"UA"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"BY"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"RS"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"BG"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"MK"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"KZ"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"KG"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"TJ"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"MN"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"GR"))
+ ret = VKBD_GREEK_UPPER;
+ g_free(lang);
+ return ret;
}
@@ -481,15 +750,15 @@ gui_internal_keyboard_init_mode(char *lang)
* @param w The placeholder widget
*/
static void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct widget *w) {
- struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
-
- if (kbd) {
- graphics_hide_native_keyboard(this_->gra, kbd);
- g_free(kbd->lang);
- g_free(kbd->gui_priv);
- } else
- dbg(lvl_warning, "no graphics_keyboard found, cleanup failed\n");
- g_free(w);
+ struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
+
+ if (kbd) {
+ graphics_hide_native_keyboard(this_->gra, kbd);
+ g_free(kbd->lang);
+ g_free(kbd->gui_priv);
+ } else
+ dbg(lvl_warning, "no graphics_keyboard found, cleanup failed");
+ g_free(w);
}
@@ -519,42 +788,42 @@ static void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct wid
* @return The placeholder widget for the on-screen keyboard, may be {@code NULL}
*/
struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang) {
- struct widget *ret = NULL;
- struct menu_data *md = gui_internal_menu_data(this);
- struct graphics_keyboard *kbd = g_new0(struct graphics_keyboard, 1);
- int res;
-
- kbd->mode = mode;
- if (lang)
- kbd->lang = g_strdup(lang);
- res = graphics_show_native_keyboard(this->gra, kbd);
-
- switch(res) {
- case -1:
- dbg(lvl_error, "graphics has no show_native_keyboard method, cannot display keyboard\n");
- /* no break */
- case 0:
- g_free(kbd);
- return NULL;
- }
-
- ret = gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- md->keyboard = ret;
- md->keyboard_mode=mode;
- ret->wfree = gui_internal_keyboard_hide_native;
- if (kbd->h < 0) {
- ret->h = w->h;
- ret->hmin = w->hmin;
- } else
- ret->h = kbd->h;
- if (kbd->w < 0) {
- ret->w = w->w;
- ret->wmin = w->wmin;
- } else
- ret->w = kbd->w;
- dbg(lvl_error, "ret->w=%d, ret->h=%d\n", ret->w, ret->h);
- ret->data = (void *) kbd;
- gui_internal_widget_append(w, ret);
- dbg(lvl_error, "return\n");
- return ret;
+ struct widget *ret = NULL;
+ struct menu_data *md = gui_internal_menu_data(this);
+ struct graphics_keyboard *kbd = g_new0(struct graphics_keyboard, 1);
+ int res;
+
+ kbd->mode = mode;
+ if (lang)
+ kbd->lang = g_strdup(lang);
+ res = graphics_show_native_keyboard(this->gra, kbd);
+
+ switch(res) {
+ case -1:
+ dbg(lvl_error, "graphics has no show_native_keyboard method, cannot display keyboard");
+ /* no break */
+ case 0:
+ g_free(kbd);
+ return NULL;
+ }
+
+ ret = gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
+ md->keyboard = ret;
+ md->keyboard_mode=mode;
+ ret->wfree = gui_internal_keyboard_hide_native;
+ if (kbd->h < 0) {
+ ret->h = w->h;
+ ret->hmin = w->hmin;
+ } else
+ ret->h = kbd->h;
+ if (kbd->w < 0) {
+ ret->w = w->w;
+ ret->wmin = w->wmin;
+ } else
+ ret->w = kbd->w;
+ dbg(lvl_error, "ret->w=%d, ret->h=%d", ret->w, ret->h);
+ ret->data = (void *) kbd;
+ gui_internal_widget_append(w, ret);
+ dbg(lvl_error, "return");
+ return ret;
}
diff --git a/navit/gui/internal/gui_internal_keyboard.h b/navit/gui/internal/gui_internal_keyboard.h
index 9b9039224..945d2c5cb 100644
--- a/navit/gui/internal/gui_internal_keyboard.h
+++ b/navit/gui/internal/gui_internal_keyboard.h
@@ -2,21 +2,23 @@
* Modes for the on-screen keyboard
*/
enum vkbd_mode {
- /* layouts */
- VKBD_LATIN_UPPER = 0, /*!< Latin uppercase characters */
- VKBD_LATIN_LOWER = 8, /*!< Latin lowercase characters */
- VKBD_NUMERIC = 16, /*!< Numeric keyboard */
- VKBD_UMLAUT_UPPER = 24, /*!< Extended Latin uppercase characters */
- VKBD_UMLAUT_LOWER = 32, /*!< Extended Latin lowercase characters */
- VKBD_CYRILLIC_UPPER = 40, /*!< Cyrillic uppercase characters */
- VKBD_CYRILLIC_LOWER = 48, /*!< Cyrillic lowercase characters */
- VKBD_DEGREE = 56, /*!< Numeric keyboard with extra characters (NESW, degree, minute) for coordinate input */
+ /* layouts */
+ VKBD_LATIN_UPPER = 0, /*!< Latin uppercase characters */
+ VKBD_LATIN_LOWER = 8, /*!< Latin lowercase characters */
+ VKBD_NUMERIC = 16, /*!< Numeric keyboard */
+ VKBD_UMLAUT_UPPER = 24, /*!< Extended Latin uppercase characters */
+ VKBD_UMLAUT_LOWER = 32, /*!< Extended Latin lowercase characters */
+ VKBD_CYRILLIC_UPPER = 40, /*!< Cyrillic uppercase characters */
+ VKBD_CYRILLIC_LOWER = 48, /*!< Cyrillic lowercase characters */
+ VKBD_DEGREE = 56, /*!< Numeric keyboard with extra characters (NESW, degree, minute) for coordinate input */
+ VKBD_GREEK_UPPER = 64, /*!< Greek uppercase letters */
+ VKBD_GREEK_LOWER = 72, /*!< Greek lowercase letters */
- /* modifiers and masks */
- VKBD_FLAG_2 = 2, /* FIXME seems to show alpha/num switch (VKBD_NUMERIC and VKBD_LATIN_* only) and switches to lowercase after first character */
- VKBD_MASK_7 = 7, /* FIXME modifiers for layout? */
- VKBD_FLAG_1024 = 1024, /* FIXME what is this for? Seems to have to do something with scroll box visibility */
- VKBD_LAYOUT_MASK = ~7, /* when XORed with the mode, preserves only the layout FIXME document properly */
+ /* modifiers and masks */
+ VKBD_FLAG_2 = 2, /* FIXME seems to show alpha/num switch (VKBD_NUMERIC and VKBD_LATIN_* only) and switches to lowercase after first character */
+ VKBD_MASK_7 = 7, /* FIXME modifiers for layout? */
+ VKBD_FLAG_1024 = 1024, /* FIXME what is this for? Seems to have to do something with scroll box visibility */
+ VKBD_LAYOUT_MASK = ~7, /* when XORed with the mode, preserves only the layout FIXME document properly */
};
/* prototypes */
diff --git a/navit/gui/internal/gui_internal_menu.c b/navit/gui/internal/gui_internal_menu.c
index 33def9983..3caae2800 100644
--- a/navit/gui/internal/gui_internal_menu.c
+++ b/navit/gui/internal/gui_internal_menu.c
@@ -15,85 +15,198 @@
#include "gui_internal_search.h"
#include "gui_internal_menu.h"
-extern char *version;
-static void
-gui_internal_menu_destroy(struct gui_priv *this, struct widget *w)
-{
- struct menu_data *menu_data=w->menu_data;
- if (menu_data) {
- if (menu_data->refresh_callback_obj.type) {
- struct object_func *func;
- func=object_func_lookup(menu_data->refresh_callback_obj.type);
- if (func && func->remove_attr)
- func->remove_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
- }
- if (menu_data->refresh_callback.u.callback)
- callback_destroy(menu_data->refresh_callback.u.callback);
+/**
+ * @brief Utility function to check if a menu widget is adapted to the display size or needs resizing (if so, the widget dimensions will be set to match those of the display
+ *
+ * @param this The GUI instance
+ * @param w The menu widget (top widget that should spawn over the entire display)
+ * @param wdisp The width of the display to check the widget against
+ * @param hdisp The width of the display to check the widget against
+ *
+ * @return true if widget w has the same size as the provided display dimensions
+ */
+
+int gui_internal_menu_needs_resizing(struct gui_priv *this, struct widget *w, int wdisp, int hdisp) {
+ if (w->w != wdisp || w->h != hdisp) {
+ w->w=wdisp;
+ w->h=hdisp;
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * @brief destroy a menu widget and perform the associated cleanup in the menu & submenu list
+ *
+ * @param this The GUI instance
+ * @param w The menu widget to destroy
+ */
+void gui_internal_menu_destroy(struct gui_priv *this, struct widget *w) {
+ struct menu_data *menu_data=w->menu_data;
+ if (menu_data) {
+ if (menu_data->refresh_callback_obj.type) {
+ struct object_func *func;
+ func=object_func_lookup(menu_data->refresh_callback_obj.type);
+ if (func && func->remove_attr)
+ func->remove_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
+ }
+ if (menu_data->refresh_callback.u.callback)
+ callback_destroy(menu_data->refresh_callback.u.callback);
+
+ g_free(menu_data->href);
+ g_free(menu_data);
+ }
+ gui_internal_widget_destroy(this, w);
+ this->root.children=g_list_remove(this->root.children, w);
+}
+
+/**
+ * @brief Retrieve then html anchor (href) from a menu widger
+ *
+ * @param w A widget corresponding to a menu (this widget should be an html menu)
+ *
+ * @return the string for the href, or NULL if this menu has no href (or the widget is not a menu)
+ */
+static char *gui_internal_widget_get_href(struct widget *w) {
+ if (w && w->menu_data)
+ return w->menu_data->href;
+ else
+ return NULL;
+}
- g_free(menu_data->href);
- g_free(menu_data);
- }
- gui_internal_widget_destroy(this, w);
- this->root.children=g_list_remove(this->root.children, w);
+/**
+ * @brief Reload a menu from its anchor (href)
+ *
+ * @param this The internal GUI context
+ * @param w A widget corresponding to the menu to redraw (this widget should be an html menu, thus it should have a href)
+ *
+ * @return 1 in case of success, 0 if no menu could be reloaded
+ * @note If the widget provided in @p w has no href, we will return 0
+ */
+int gui_internal_widget_reload_href(struct gui_priv *this, struct widget *w) {
+ char *ohref = gui_internal_widget_get_href(w);
+ if (ohref) {
+ char *href=g_strdup(ohref);
+ gui_internal_menu_destroy(this, w);
+ gui_internal_html_load_href(this, href, 0);
+ g_free(href);
+ return 1;
+ }
+ return 0;
}
-static void
-gui_internal_prune_menu_do(struct gui_priv *this, struct widget *w, int render)
-{
- GList *l;
- struct widget *wr,*wd;
- gui_internal_search_idle_end(this);
- while ((l = g_list_last(this->root.children))) {
- wd=l->data;
- if (wd == w) {
- void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
- if (!render)
- return;
- gui_internal_say(this, w, 0);
- redisplay=w->menu_data->redisplay;
- wr=w->menu_data->redisplay_widget;
- if (!w->menu_data->redisplay && !w->menu_data->href) {
- gui_internal_widget_render(this, w);
- return;
- }
- if (redisplay) {
- gui_internal_menu_destroy(this, w);
- redisplay(this, wr, wr->data);
- } else {
- char *href=g_strdup(w->menu_data->href);
- gui_internal_menu_destroy(this, w);
- gui_internal_html_load_href(this, href, 0);
- g_free(href);
- }
- return;
- }
- gui_internal_menu_destroy(this, wd);
- }
+/**
+ * @brief Destroy (discard) all menu screens that have been placed after widget @p w
+ *
+ * @param this The internal GUI instance
+ * @param w A widget corresponding to the last menu to keep (all subsequent menus in the list will be destroyed). NULL if all menus should be destroyed.
+ * @param render whether we should render the menu indicated by widget w (render!=0) or not (render==0)
+ */
+static void gui_internal_prune_menu_do(struct gui_priv *this, struct widget *w, int render) {
+ GList *l;
+ struct widget *wr,*wd;
+ gui_internal_search_idle_end(this);
+ /* Destroy all menus, backwards, starting from the end until we reach widget w, and redraw widget w */
+ while ((l = g_list_last(this->root.children))) {
+ wd=l->data;
+ if (wd == w) { /* This is the widget we want to bring back to display (all subsequent widgets will be destroyed in the loop) */
+ void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
+ if (!render)
+ return;
+ gui_internal_say(this, w, 0);
+ redisplay=w->menu_data->redisplay;
+ if (redisplay) {
+ gui_internal_menu_destroy(this, w);
+ wr=w->menu_data->redisplay_widget;
+ redisplay(this, wr, wr->data);
+ } else {
+ /* Make sure the new menu we are going to display spawns the whole display (in case there was a resize while a submenu was being displayed) */
+ w->w=this->root.w;
+ w->h=this->root.h;
+ /* If the foremost widget is a HTML menu, reload & redraw it from its href using gui_internal_widget_reload_href() */
+ if (!gui_internal_widget_reload_href(this,w)) {
+ /* If not, resize the foremost widget */
+ gui_internal_menu_resize(this, this->root.w, this->root.h);
+ }
+ gui_internal_menu_render(this);
+ }
+ return;
+ } else
+ gui_internal_menu_destroy(this, wd);
+ }
}
-void
-gui_internal_prune_menu(struct gui_priv *this, struct widget *w)
-{
- gui_internal_prune_menu_do(this, w, 1);
+/**
+ * @brief Destroy (discard) all menu screens that have been placed after widget @p w and redraw the display, showing widget @w
+ *
+ * @param this The internal GUI instance
+ * @param w A widget corresponding to the last menu to keep, and to draw (all subsequent menus in the list will be destroyed). NULL if all menus should be destroyed.
+ */
+void gui_internal_prune_menu(struct gui_priv *this, struct widget *w) {
+ gui_internal_prune_menu_do(this, w, 1);
}
-void
-gui_internal_prune_menu_count(struct gui_priv *this, int count, int render)
-{
- GList *l=g_list_last(this->root.children);
- struct widget *w=NULL;
- while (l && count-- > 0)
- l=g_list_previous(l);
- if (l) {
- w=l->data;
- gui_internal_prune_menu_do(this, w, render);
- }
+/**
+ * @brief Destroy (discard) the last @p count menu screens
+ *
+ * @param this The internal GUI instance
+ * @param count The number of menus to destroy at the tail of the menu/submenu stack (if <=0, no menu will be destroyed)
+ * @param render whether we should render the new last menu in the stack (render!=0) or not (render==0)
+ */
+void gui_internal_prune_menu_count(struct gui_priv *this, int count, int render) {
+ GList *l=g_list_last(this->root.children);
+ struct widget *w=NULL;
+ while (l && count-- > 0)
+ l=g_list_previous(l);
+ if (l) {
+ w=l->data;
+ gui_internal_prune_menu_do(this, w, render);
+ }
}
+/**
+ * @brief Resize the box widget (and its children) corresponding to a menu
+ *
+ * Menus are stored in a main box (topbox) that spawn the entire screen, thus, once the topbox has been resized, it will in turn resize its children,
+ * effectively resizing the whole menu display size
+ *
+ * Note: once this function has been run, widget @p w and its children have been resized, a call to gui_internal_box_render() needs to be done by the caller
+ *
+ * @param this The internal GUI instance
+ * @param w A box widget corresponding to the menu widget
+ * @param data Some data to pass to the box resize handler
+ * @param neww The new width of the display
+ * @param newh The new height of the display
+ */
+void gui_internal_menu_menu_resize(struct gui_priv *this, struct widget *w, void *data, int neww, int newh) {
+ struct padding *padding = NULL;
+
+ if (w->type != widget_box) {
+ dbg(lvl_warning, "Called on a non-box widget, ignoring");
+ return;
+ }
+ if (this->gra) {
+ padding = graphics_get_data(this->gra, "padding");
+ } else
+ dbg(lvl_warning, "cannot get padding: this->gra is NULL");
+ if (padding) {
+ w->p.x = padding->left;
+ w->p.y = padding->top;
+ w->w = neww - padding->left - padding->right;
+ w->h = newh - padding->top - padding->bottom;
+ } else {
+ w->p.x = 0;
+ w->p.y = 0;
+ w->w = neww;
+ w->h = newh;
+ }
+ gui_internal_box_resize(this, w, data, w->w, w->h);
+}
/**
- * @brief Initializes a GUI screen
+ * @brief Initializes a GUI menu screen
*
* This method initializes the internal GUI's screen on which all other elements (such as HTML menus,
* dialogs or others) are displayed.
@@ -107,267 +220,280 @@ gui_internal_prune_menu_count(struct gui_priv *this, int count, int render)
* @return The container for caller-defined widgets
*/
struct widget *
-gui_internal_menu(struct gui_priv *this, const char *label)
-{
- struct widget *menu,*w,*w1,*topbox;
- struct padding *padding = NULL;
+gui_internal_menu(struct gui_priv *this, const char *label) {
+ struct widget *menu,*w,*w1,*topbox;
- if (this->gra) {
- padding = graphics_get_data(this->gra, "padding");
- } else
- dbg(lvl_warning, "cannot get padding: this->gra is NULL\n");
+ gui_internal_search_idle_end(this);
+ topbox=gui_internal_box_new_with_label(this, 0, label);
+ gui_internal_widget_append(&this->root, topbox);
+ menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
+ menu->on_resize=gui_internal_menu_menu_resize;
+ topbox->on_resize(this, topbox, NULL, this->root.w, this->root.h);
+ /* We also have to invoke onresize() handler on menu because it is not (yet) set as a child of topbox */
+ menu->on_resize(this, menu, NULL, topbox->w, topbox->h);
+ menu->background=this->background;
+ gui_internal_apply_config(this);
+ topbox->menu_data=g_new0(struct menu_data, 1);
+ gui_internal_widget_append(topbox, menu);
+ w=gui_internal_top_bar(this);
+ gui_internal_widget_append(menu, w);
+ w=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ w->spx=4*this->spacing;
+ w->w=menu->w;
+ gui_internal_widget_append(menu, w);
+ if (this->flags & 16 && !(this->flags & 1024)) {
+ struct widget *wlb,*wb,*wm=w;
+ wm->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
+ w=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_expand|flags_fill);
+ dbg(lvl_info,"topbox->menu_data=%p", topbox->menu_data);
+ gui_internal_widget_append(wm, w);
+ wb=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
+ wb->bl=6;
+ wb->br=6;
+ wb->bb=6;
+ wb->bt=6;
+ wb->spx=6;
+ topbox->menu_data->button_bar=wb;
+ gui_internal_widget_append(wm, wb);
+ wlb=gui_internal_button_label(this,_("Back"),1);
+ wlb->func=gui_internal_back;
+ wlb->state |= STATE_SENSITIVE;
+ }
+ if (this->flags & 192) {
+ menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
+ menu->on_resize=gui_internal_menu_menu_resize;
+ menu->on_resize(this, menu, NULL, topbox->w, topbox->h);
+ w1=gui_internal_time_help(this);
+ gui_internal_widget_append(menu, w1);
+ w1=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(menu, w1);
+ gui_internal_widget_append(topbox, menu);
+ menu->background=NULL;
+ }
+ gui_internal_widget_pack(this, topbox);
+ gui_internal_widget_reset_pack(this, topbox);
+ if (topbox->on_resize)
+ topbox->on_resize(this, topbox, NULL, this->root.w, this->root.h);
+ return w;
+}
- gui_internal_search_idle_end(this);
- topbox=gui_internal_box_new_with_label(this, 0, label);
- topbox->w=this->root.w;
- topbox->h=this->root.h;
- gui_internal_widget_append(&this->root, topbox);
- menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
+struct menu_data *
+gui_internal_menu_data(struct gui_priv *this) {
+ GList *l;
+ struct widget *menu;
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- menu->background=this->background;
- gui_internal_apply_config(this);
- topbox->menu_data=g_new0(struct menu_data, 1);
- gui_internal_widget_append(topbox, menu);
- w=gui_internal_top_bar(this);
- gui_internal_widget_append(menu, w);
- w=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- w->spx=4*this->spacing;
- w->w=menu->w;
- gui_internal_widget_append(menu, w);
- if (this->flags & 16 && !(this->flags & 1024)) {
- struct widget *wlb,*wb,*wm=w;
- wm->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
- w=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_expand|flags_fill);
- dbg(lvl_info,"topbox->menu_data=%p\n", topbox->menu_data);
- gui_internal_widget_append(wm, w);
- wb=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
- wb->bl=6;
- wb->br=6;
- wb->bb=6;
- wb->bt=6;
- wb->spx=6;
- topbox->menu_data->button_bar=wb;
- gui_internal_widget_append(wm, wb);
- wlb=gui_internal_button_label(this,_("Back"),1);
- wlb->func=gui_internal_back;
- wlb->state |= STATE_SENSITIVE;
- }
- if (this->flags & 192) {
- menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- w1=gui_internal_time_help(this);
- gui_internal_widget_append(menu, w1);
- w1=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, w1);
- gui_internal_widget_append(topbox, menu);
- menu->background=NULL;
- }
- gui_internal_widget_pack(this, topbox);
- gui_internal_widget_reset_pack(this, topbox);
- topbox->w=this->root.w;
- topbox->h=this->root.h;
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- return w;
+ l=g_list_last(this->root.children);
+ menu=l->data;
+ return menu->menu_data;
}
-struct menu_data *
-gui_internal_menu_data(struct gui_priv *this)
-{
- GList *l;
- struct widget *menu;
+void gui_internal_menu_reset_pack(struct gui_priv *this) {
+ GList *l;
+ struct widget *top_box;
+
+ l=g_list_last(this->root.children);
+ top_box=l->data;
+ gui_internal_widget_reset_pack(this, top_box);
+}
- l=g_list_last(this->root.children);
- menu=l->data;
- return menu->menu_data;
+/**
+ * @brief Renders a menu GUI on the display
+ *
+ * @note The whole sequence of menus is kept in this->root.children (when going back one page, we just move to the previous child in the list)
+ * Thus, only the last child of this->root.children is actually displayed
+ *
+ * @param this The internal GUI instance
+ */
+void gui_internal_menu_render(struct gui_priv *this) {
+ GList *l;
+ struct widget *menu;
+
+ l=g_list_last(this->root.children);
+ menu=l->data;
+ gui_internal_say(this, menu, 0);
+ gui_internal_widget_pack(this, menu);
+ gui_internal_widget_render(this, menu);
}
-void
-gui_internal_menu_reset_pack(struct gui_priv *this)
-{
- GList *l;
- struct widget *top_box;
+/**
+ * @brief Resize the currently displayed menu
+ *
+ * @param this The internal GUI instance
+ * @param w The new width of the display
+ * @param h the new height of the display
+ */
+void gui_internal_menu_resize(struct gui_priv *this, int w, int h) {
+ GList *l;
+ struct widget *menu_topwidget;
- l=g_list_last(this->root.children);
- top_box=l->data;
- gui_internal_widget_reset_pack(this, top_box);
+ gui_internal_apply_config(this);
+ l=g_list_last(this->root.children);
+ menu_topwidget=l->data;
+ if (menu_topwidget->on_resize) {
+ dbg(lvl_debug, "Invoking resize handler for menu_topwidget at %p", menu_topwidget);
+ menu_topwidget->on_resize(this, menu_topwidget, NULL, this->root.w, this->root.h);
+ }
}
-void
-gui_internal_menu_render(struct gui_priv *this)
-{
- GList *l;
- struct widget *menu;
+/**
+ * @brief Resize a top bar created using gui_internal_top_bar()
+ *
+ * @param this The internal GUI instance
+ * @param data Some data to pass to the box resize handler
+ * @param neww The new width of the display
+ * @param newh The new height of the display
+ */
+static void gui_internal_top_bar_resize(struct gui_priv *this, struct widget *w, void *data, int neww, int newh) {
+ struct widget *new_top_bar;
- l=g_list_last(this->root.children);
- menu=l->data;
- gui_internal_say(this, menu, 0);
- gui_internal_widget_pack(this, menu);
- gui_internal_widget_render(this, menu);
+ if (w->type != widget_box) {
+ dbg(lvl_warning, "Called on a non-box widget, ignoring");
+ return;
+ }
+ new_top_bar=gui_internal_top_bar(this);
+ gui_internal_widget_move(this, w, new_top_bar);
}
+/**
+ * @brief Create an GUI top bar (containing the history of GUI menus and submenus)
+ *
+ * @param this The internal GUI instance
+ *
+ * @return The newly created top bar widget
+ */
struct widget *
-gui_internal_top_bar(struct gui_priv *this)
-{
- struct widget *w,*wm,*wh,*wc,*wcn;
- int dots_len, sep_len;
- GList *res=NULL,*l;
- int width,width_used=0,use_sep=0,incomplete=0;
- struct graphics_gc *foreground=(this->flags & 256 ? this->background : this->text_foreground);
-/* flags
- 1:Don't expand bar to screen width
- 2:Don't show Map Icon
- 4:Don't show Home Icon
- 8:Show only current menu
- 16:Don't use menu titles as button
- 32:Show navit version
- 64:Show time
- 128:Show help
- 256:Use background for menu headline
- 512:Set osd_configuration and zoom to route when setting position
- 1024:Don't show back button
- 2048:No highlighting of keyboard
- 4096:Center menu title
-*/
+gui_internal_top_bar(struct gui_priv *this) {
+ struct widget *w,*wm,*wh,*wc,*wcn;
+ int dots_len, sep_len;
+ GList *res=NULL,*l;
+ int width,width_used=0,use_sep=0,incomplete=0;
+ struct graphics_gc *foreground=(this->flags & 256 ? this->background : this->text_foreground);
+ /* flags
+ 1:Don't expand bar to screen width
+ 2:Don't show Map Icon
+ 4:Don't show Home Icon
+ 8:Show only current menu
+ 16:Don't use menu titles as button
+ 32:Show navit version
+ 64:Show time
+ 128:Show help
+ 256:Use background for menu headline
+ 512:Set osd_configuration and zoom to route when setting position
+ 1024:Don't show back button
+ 2048:No highlighting of keyboard
+ 4096:Center menu title
+ */
- w=gui_internal_box_new(this, (this->flags & 4096 ? gravity_center : gravity_left_center)|orientation_horizontal|(this->flags & 1 ? 0:flags_fill));
- w->bl=this->spacing;
- w->spx=this->spacing;
- w->background=this->background2;
- if ((this->flags & 6) == 6) {
- w->bl=10;
- w->br=10;
- w->bt=6;
- w->bb=6;
- }
- width=this->root.w-w->bl;
- if (! (this->flags & 2)) {
- wm=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_map"), gravity_center|orientation_vertical,
- gui_internal_cmd_return, NULL);
- wm->speech=g_strdup(_("Back to map"));
- gui_internal_widget_pack(this, wm);
- gui_internal_widget_append(w, wm);
- width-=wm->w;
- }
- if (! (this->flags & 4)) {
- wh=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_home"), gravity_center|orientation_vertical,
- gui_internal_cmd_main_menu, NULL);
- wh->speech=g_strdup(_("Main Menu"));
- gui_internal_widget_pack(this, wh);
- gui_internal_widget_append(w, wh);
- width-=wh->w;
- }
- if (!(this->flags & 6))
- width-=w->spx;
- l=g_list_last(this->root.children);
- wcn=gui_internal_label_new(this,".. »");
- wcn->foreground=foreground;
- dots_len=wcn->w;
- gui_internal_widget_destroy(this, wcn);
- wcn=gui_internal_label_new(this,"»");
- wcn->foreground=foreground;
- sep_len=wcn->w;
- gui_internal_widget_destroy(this, wcn);
- while (l) {
- if (g_list_previous(l) || !g_list_next(l)) {
- wc=l->data;
- wcn=gui_internal_label_new(this, wc->text);
- wcn->foreground=foreground;
- if (g_list_next(l))
- use_sep=1;
- else
- use_sep=0;
- dbg(lvl_debug,"%d (%s) + %d + %d + %d > %d\n", wcn->w, wc->text, width_used, w->spx, use_sep ? sep_len : 0, width);
- if (wcn->w + width_used + w->spx + (use_sep ? sep_len : 0) + (g_list_previous(l) ? dots_len : 0) > width) {
- incomplete=1;
- gui_internal_widget_destroy(this, wcn);
- break;
- }
- if (use_sep) {
- struct widget *wct=gui_internal_label_new(this, "»");
- wct->foreground=foreground;
- res=g_list_prepend(res, wct);
- width_used+=sep_len+w->spx;
- }
- width_used+=wcn->w;
- if (!(this->flags & 16)) {
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- }
- res=g_list_prepend(res, wcn);
- if (this->flags & 8)
- break;
- }
- l=g_list_previous(l);
- }
- if (incomplete) {
- if (! res) {
- wcn=gui_internal_label_new_abbrev(this, wc->text, width-width_used-w->spx-dots_len);
- wcn->foreground=foreground;
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- res=g_list_prepend(res, wcn);
- l=g_list_previous(l);
- wc=l?l->data:NULL;
- }
- if(wc) {
- wcn=gui_internal_label_new(this, ".. »");
- wcn->foreground=foreground;
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- res=g_list_prepend(res, wcn);
- }
- }
- l=res;
- while (l) {
- gui_internal_widget_append(w, l->data);
- l=g_list_next(l);
- }
- if (this->flags & 32) {
- char *version_text=g_strdup_printf("Navit %s",version);
- wcn=gui_internal_label_new(this, version_text);
- g_free(version_text);
- wcn->flags=gravity_right_center|flags_expand;
- gui_internal_widget_append(w, wcn);
- }
+ w=gui_internal_box_new(this, (this->flags & 4096 ? gravity_center : gravity_left_center)|orientation_horizontal|
+ (this->flags & 1 ? 0:flags_fill));
+ w->bl=this->spacing;
+ w->spx=this->spacing;
+ w->background=this->background2;
+ if ((this->flags & 6) == 6) {
+ w->bl=10;
+ w->br=10;
+ w->bt=6;
+ w->bb=6;
+ }
+ w->on_resize=gui_internal_top_bar_resize;
+ width=this->root.w-w->bl;
+ if (! (this->flags & 2)) {
+ wm=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, "gui_map"), gravity_center|orientation_vertical,
+ gui_internal_cmd_return, NULL);
+ wm->speech=g_strdup(_("Back to map"));
+ gui_internal_widget_pack(this, wm);
+ gui_internal_widget_append(w, wm);
+ width-=wm->w;
+ }
+ if (! (this->flags & 4)) {
+ wh=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, "gui_home"), gravity_center|orientation_vertical,
+ gui_internal_cmd_main_menu, NULL);
+ wh->speech=g_strdup(_("Main Menu"));
+ gui_internal_widget_pack(this, wh);
+ gui_internal_widget_append(w, wh);
+ width-=wh->w;
+ }
+ if (!(this->flags & 6))
+ width-=w->spx;
+ l=g_list_last(this->root.children);
+ wcn=gui_internal_label_new(this,".. »");
+ wcn->foreground=foreground;
+ dots_len=wcn->w;
+ gui_internal_widget_destroy(this, wcn);
+ wcn=gui_internal_label_new(this,"»");
+ wcn->foreground=foreground;
+ sep_len=wcn->w;
+ gui_internal_widget_destroy(this, wcn);
+ while (l) {
+ if (g_list_previous(l) || !g_list_next(l)) {
+ wc=l->data;
+ wcn=gui_internal_label_new(this, wc->text);
+ wcn->foreground=foreground;
+ if (g_list_next(l))
+ use_sep=1;
+ else
+ use_sep=0;
+ dbg(lvl_debug,"%d (%s) + %d + %d + %d > %d", wcn->w, wc->text, width_used, w->spx, use_sep ? sep_len : 0, width);
+ if (wcn->w + width_used + w->spx + (use_sep ? sep_len : 0) + (g_list_previous(l) ? dots_len : 0) > width) {
+ incomplete=1;
+ gui_internal_widget_destroy(this, wcn);
+ break;
+ }
+ if (use_sep) {
+ struct widget *wct=gui_internal_label_new(this, "»");
+ wct->foreground=foreground;
+ res=g_list_prepend(res, wct);
+ width_used+=sep_len+w->spx;
+ }
+ width_used+=wcn->w;
+ if (!(this->flags & 16)) {
+ wcn->func=gui_internal_cmd_return;
+ wcn->data=wc;
+ wcn->state |= STATE_SENSITIVE;
+ }
+ res=g_list_prepend(res, wcn);
+ if (this->flags & 8)
+ break;
+ }
+ l=g_list_previous(l);
+ }
+ if (incomplete) {
+ if (! res) {
+ wcn=gui_internal_label_new_abbrev(this, wc->text, width-width_used-w->spx-dots_len);
+ wcn->foreground=foreground;
+ wcn->func=gui_internal_cmd_return;
+ wcn->data=wc;
+ wcn->state |= STATE_SENSITIVE;
+ res=g_list_prepend(res, wcn);
+ l=g_list_previous(l);
+ wc=l?l->data:NULL;
+ }
+ if(wc) {
+ wcn=gui_internal_label_new(this, ".. »");
+ wcn->foreground=foreground;
+ wcn->func=gui_internal_cmd_return;
+ wcn->data=wc;
+ wcn->state |= STATE_SENSITIVE;
+ res=g_list_prepend(res, wcn);
+ }
+ }
+ l=res;
+ while (l) {
+ gui_internal_widget_append(w, l->data);
+ l=g_list_next(l);
+ }
+ if (this->flags & 32) {
+ char *version_text=g_strdup_printf("Navit %s",NAVIT_VERSION);
+ wcn=gui_internal_label_new(this, version_text);
+ g_free(version_text);
+ wcn->flags=gravity_right_center|flags_expand;
+ gui_internal_widget_append(w, wcn);
+ }
#if 0
- if (dots)
- gui_internal_widget_destroy(this, dots);
+ if (dots)
+ gui_internal_widget_destroy(this, dots);
#endif
- return w;
+ return w;
}
diff --git a/navit/gui/internal/gui_internal_menu.h b/navit/gui/internal/gui_internal_menu.h
index 57e37d91c..3906ed23c 100644
--- a/navit/gui/internal/gui_internal_menu.h
+++ b/navit/gui/internal/gui_internal_menu.h
@@ -2,11 +2,16 @@
struct gui_priv;
struct menu_data;
struct widget;
+int gui_internal_menu_needs_resizing(struct gui_priv *this, struct widget *w, int wdisp, int hdisp);
+void gui_internal_menu_destroy(struct gui_priv *this, struct widget *w);
+int gui_internal_widget_reload_href(struct gui_priv *this, struct widget *w);
void gui_internal_prune_menu(struct gui_priv *this, struct widget *w);
void gui_internal_prune_menu_count(struct gui_priv *this, int count, int render);
+void gui_internal_menu_menu_resize(struct gui_priv *this, struct widget *w, void *data, int neww, int newh);
struct widget *gui_internal_menu(struct gui_priv *this, const char *label);
struct menu_data *gui_internal_menu_data(struct gui_priv *this);
void gui_internal_menu_reset_pack(struct gui_priv *this);
void gui_internal_menu_render(struct gui_priv *this);
+void gui_internal_menu_resize(struct gui_priv *this, int w, int h);
struct widget *gui_internal_top_bar(struct gui_priv *this);
/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_poi.c b/navit/gui/internal/gui_internal_poi.c
index cb31ecc95..839a5d061 100644
--- a/navit/gui/internal/gui_internal_poi.c
+++ b/navit/gui/internal/gui_internal_poi.c
@@ -28,121 +28,124 @@
struct item_data {
- int dist;
- char *label;
- struct item item;
- struct coord c;
+ int dist;
+ char *label;
+ struct item item;
+ struct coord c;
};
struct selector {
- char *icon;
- char *name;
- enum item_type *types;
+ char *icon;
+ char *name;
+ enum item_type *types;
};
-static enum item_type selectors_BankTypes[]={type_poi_bank,type_poi_bank, type_poi_atm,type_poi_atm, type_none};
-static enum item_type selectors_FuelTypes[]={type_poi_fuel,type_poi_fuel,type_none};
-static enum item_type selectors_BusTrainTypes[]={type_poi_rail_station,type_poi_rail_station,
- type_poi_rail_halt,type_poi_rail_tram_stop,type_poi_bus_station,type_poi_bus_stop,type_none};
-static enum item_type selectors_HotelTypes[]={type_poi_hotel,type_poi_camp_rv,type_poi_camping,type_poi_camping,
- type_poi_resort,type_poi_resort,type_poi_motel,type_poi_hostel,type_none};
-static enum item_type selectors_RestaurantTypes[]={type_poi_bar,type_poi_picnic,type_poi_burgerking,type_poi_fastfood,
- type_poi_restaurant,type_poi_restaurant,type_poi_cafe,type_poi_cafe,type_poi_pub,type_poi_pub,type_none};
-static enum item_type selectors_ShoppingTypes[]={type_poi_mall,type_poi_mall,type_poi_shop_grocery,type_poi_shop_grocery,
- type_poi_shopping,type_poi_shopping,type_poi_shop_butcher,type_poi_shop_baker,type_poi_shop_fruit,
- type_poi_shop_fruit,type_poi_shop_beverages,type_poi_shop_beverages,type_none};
-static enum item_type selectors_ServiceTypes[]={type_poi_marina,type_poi_marina,type_poi_hospital,type_poi_hospital,
- type_poi_public_utilities,type_poi_public_utilities,type_poi_police,type_poi_autoservice,type_poi_information,
- type_poi_information,type_poi_pharmacy,type_poi_pharmacy,type_poi_personal_service,type_poi_repair_service,
- type_poi_restroom,type_poi_restroom,type_none};
-static enum item_type selectors_ParkingTypes[]={type_poi_car_parking,type_poi_car_parking,type_none};
-static enum item_type selectors_LandFeaturesTypes[]={type_poi_land_feature,type_poi_rock,type_poi_dam,type_poi_dam,
- type_poi_peak,type_poi_peak,type_none};
-static enum item_type selectors_OtherTypes[]={type_point_unspecified,type_poi_land_feature-1,type_poi_rock+1,type_poi_fuel-1,
- type_poi_marina+1,type_poi_shopping-1,type_poi_shopping+1,type_poi_car_parking-1,type_poi_car_parking+1,
- type_poi_bar-1,type_poi_bank+1,type_poi_dam-1,type_poi_dam+1,type_poi_information-1,type_poi_information+1,
- type_poi_mall-1,type_poi_mall+1,type_poi_personal_service-1,type_poi_pharmacy+1,type_poi_repair_service-1,
- type_poi_repair_service+1,type_poi_restaurant-1,type_poi_restaurant+1,type_poi_restroom-1,type_poi_restroom+1,
- type_poi_shop_grocery-1,type_poi_shop_grocery+1,type_poi_peak-1,type_poi_peak+1,type_poi_motel-1,type_poi_hostel+1,
- type_poi_shop_butcher-1,type_poi_shop_baker+1,type_poi_shop_fruit-1,type_poi_shop_fruit+1,type_poi_shop_beverages-1,
- type_poi_shop_beverages+1,type_poi_pub-1,type_poi_atm+1,type_line-1,type_none};
+static enum item_type selectors_BankTypes[]= {type_poi_bank,type_poi_bank, type_poi_atm,type_poi_atm, type_none};
+static enum item_type selectors_FuelTypes[]= {type_poi_fuel,type_poi_fuel,type_none};
+static enum item_type selectors_BusTrainTypes[]= {type_poi_rail_station,type_poi_rail_station,
+ type_poi_rail_halt,type_poi_rail_tram_stop,type_poi_bus_station,type_poi_bus_stop,type_none
+ };
+static enum item_type selectors_HotelTypes[]= {type_poi_hotel,type_poi_camp_rv,type_poi_camping,type_poi_camping,
+ type_poi_resort,type_poi_resort,type_poi_motel,type_poi_hostel,type_none
+ };
+static enum item_type selectors_RestaurantTypes[]= {type_poi_bar,type_poi_picnic,type_poi_burgerking,type_poi_fastfood,
+ type_poi_restaurant,type_poi_restaurant,type_poi_cafe,type_poi_cafe,type_poi_pub,type_poi_pub,type_none
+ };
+static enum item_type selectors_ShoppingTypes[]= {type_poi_mall,type_poi_mall,type_poi_shop_grocery,type_poi_shop_grocery,
+ type_poi_shopping,type_poi_shopping,type_poi_shop_butcher,type_poi_shop_baker,type_poi_shop_fruit,
+ type_poi_shop_fruit,type_poi_shop_beverages,type_poi_shop_beverages,type_none
+ };
+static enum item_type selectors_ServiceTypes[]= {type_poi_marina,type_poi_marina,type_poi_hospital,type_poi_hospital,
+ type_poi_public_utilities,type_poi_public_utilities,type_poi_police,type_poi_autoservice,type_poi_information,
+ type_poi_information,type_poi_pharmacy,type_poi_pharmacy,type_poi_personal_service,type_poi_repair_service,
+ type_poi_restroom,type_poi_restroom,type_none
+ };
+static enum item_type selectors_ParkingTypes[]= {type_poi_car_parking,type_poi_car_parking,type_none};
+static enum item_type selectors_LandFeaturesTypes[]= {type_poi_land_feature,type_poi_rock,type_poi_dam,type_poi_dam,
+ type_poi_peak,type_poi_peak,type_none
+ };
+static enum item_type selectors_OtherTypes[]= {type_point_unspecified,type_poi_land_feature-1,type_poi_rock+1,type_poi_fuel-1,
+ type_poi_marina+1,type_poi_shopping-1,type_poi_shopping+1,type_poi_car_parking-1,type_poi_car_parking+1,
+ type_poi_bar-1,type_poi_bank+1,type_poi_dam-1,type_poi_dam+1,type_poi_information-1,type_poi_information+1,
+ type_poi_mall-1,type_poi_mall+1,type_poi_personal_service-1,type_poi_pharmacy+1,type_poi_repair_service-1,
+ type_poi_repair_service+1,type_poi_restaurant-1,type_poi_restaurant+1,type_poi_restroom-1,type_poi_restroom+1,
+ type_poi_shop_grocery-1,type_poi_shop_grocery+1,type_poi_peak-1,type_poi_peak+1,type_poi_motel-1,type_poi_hostel+1,
+ type_poi_shop_butcher-1,type_poi_shop_baker+1,type_poi_shop_fruit-1,type_poi_shop_fruit+1,type_poi_shop_beverages-1,
+ type_poi_shop_beverages+1,type_poi_pub-1,type_poi_atm+1,type_line-1,type_none
+ };
/*static enum item_type selectors_UnknownTypes[]={type_point_unkn,type_point_unkn,type_none};*/
-struct selector selectors[]={
- {"bank","Bank",selectors_BankTypes},
- {"fuel","Fuel",selectors_FuelTypes},
- {"bus_stop","Bus&Train",selectors_BusTrainTypes},
- {"hotel","Hotel",selectors_HotelTypes},
- {"restaurant","Restaurant",selectors_RestaurantTypes},
- {"shopping","Shopping",selectors_ShoppingTypes},
- {"hospital","Service",selectors_ServiceTypes},
- {"parking","Parking",selectors_ParkingTypes},
- {"peak","Land Features",selectors_LandFeaturesTypes},
- {"unknown","Other",selectors_OtherTypes},
-/* {"unknown","Unknown",selectors_UnknownTypes},*/
+struct selector selectors[]= {
+ {"bank","Bank",selectors_BankTypes},
+ {"fuel","Fuel",selectors_FuelTypes},
+ {"bus_stop","Bus&Train",selectors_BusTrainTypes},
+ {"hotel","Hotel",selectors_HotelTypes},
+ {"restaurant","Restaurant",selectors_RestaurantTypes},
+ {"shopping","Shopping",selectors_ShoppingTypes},
+ {"hospital","Service",selectors_ServiceTypes},
+ {"parking","Parking",selectors_ParkingTypes},
+ {"peak","Land Features",selectors_LandFeaturesTypes},
+ {"unknown","Other",selectors_OtherTypes},
+ /* {"unknown","Unknown",selectors_UnknownTypes},*/
};
/**
* @brief Get icon for given POI type.
*
* @param this pointer to gui context
* @param type POI type
- * @return Pointer to graphics_image object, or NULL if no picture available.
+ * @return Pointer to graphics_image object, or NULL if no picture available.
*/
-static struct graphics_image *
-gui_internal_poi_icon(struct gui_priv *this, struct item *item)
-{
- struct attr layout;
- struct attr icon_src;
- GList *layer;
- navit_get_attr(this->nav, attr_layout, &layout, NULL);
- layer=layout.u.layout->layers;
- while(layer) {
- GList *itemgra=((struct layer *)layer->data)->itemgras;
- while(itemgra) {
- GList *types=((struct itemgra *)itemgra->data)->type;
- while(types) {
- if((long)types->data==item->type) {
- GList *element=((struct itemgra *)itemgra->data)->elements;
- while(element) {
- struct element * el=element->data;
- if(el->type==element_icon) {
- char *src;
- char *icon;
- struct graphics_image *img;
- if(item_is_custom_poi(*item)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if(item_attr_get(item, attr_icon_src, &icon_src)) {
- src=el->u.icon.src;
- if(!src || !src[0])
- src="%s";
- icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
- }
- else {
- icon=g_strdup(el->u.icon.src);
- }
- }
- else {
- icon=g_strdup(el->u.icon.src);
- }
- char *dot=g_strrstr(icon,".");
- dbg(lvl_debug,"%s %s\n", item_to_name(item->type),icon);
- if(dot)
- *dot=0;
- img=image_new_xs(this,icon);
- g_free(icon);
- if(img)
- return img;
- }
- element=g_list_next(element);
- }
- }
- types=g_list_next(types);
- }
- itemgra=g_list_next(itemgra);
- }
- layer=g_list_next(layer);
- }
- return NULL;
+static struct graphics_image *gui_internal_poi_icon(struct gui_priv *this, struct item *item) {
+ struct attr layout;
+ struct attr icon_src;
+ GList *layer;
+ navit_get_attr(this->nav, attr_layout, &layout, NULL);
+ layer=layout.u.layout->layers;
+ while(layer) {
+ GList *itemgra=((struct layer *)layer->data)->itemgras;
+ while(itemgra) {
+ GList *types=((struct itemgra *)itemgra->data)->type;
+ while(types) {
+ if((long)types->data==item->type) {
+ GList *element=((struct itemgra *)itemgra->data)->elements;
+ while(element) {
+ struct element * el=element->data;
+ if(el->type==element_icon) {
+ char *src;
+ char *icon;
+ struct graphics_image *img;
+ if(item_is_custom_poi(*item)) {
+ struct map_rect *mr=map_rect_new(item->map, NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ if(item_attr_get(item, attr_icon_src, &icon_src)) {
+ src=el->u.icon.src;
+ if(!src || !src[0])
+ src="%s";
+ icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
+ } else {
+ icon=g_strdup(el->u.icon.src);
+ }
+ } else {
+ icon=g_strdup(el->u.icon.src);
+ }
+ char *dot=g_strrstr(icon,".");
+ dbg(lvl_debug,"%s %s", item_to_name(item->type),icon);
+ if(dot)
+ *dot=0;
+ img=image_new_xs(this,icon);
+ g_free(icon);
+ if(img)
+ return img;
+ }
+ element=g_list_next(element);
+ }
+ }
+ types=g_list_next(types);
+ }
+ itemgra=g_list_next(itemgra);
+ }
+ layer=g_list_next(layer);
+ }
+ return NULL;
}
/**
@@ -151,14 +154,12 @@ gui_internal_poi_icon(struct gui_priv *this, struct item *item)
* @param p reference to the object to be freed.
*/
-void
-gui_internal_poi_param_free(void *p)
-{
- if(((struct poi_param *)p)->filterstr)
- g_free(((struct poi_param *)p)->filterstr);
- if(((struct poi_param *)p)->filter)
- g_list_free(((struct poi_param *)p)->filter);
- g_free(p);
+void gui_internal_poi_param_free(void *p) {
+ if(((struct poi_param *)p)->filterstr)
+ g_free(((struct poi_param *)p)->filterstr);
+ if(((struct poi_param *)p)->filter)
+ g_list_free(((struct poi_param *)p)->filter);
+ g_free(p);
};
/**
@@ -168,24 +169,22 @@ gui_internal_poi_param_free(void *p)
* @return Cloned object reference.
*/
-static struct poi_param *
-gui_internal_poi_param_clone(struct poi_param *p)
-{
- struct poi_param *r=g_new(struct poi_param,1);
- GList *l=p->filter;
- memcpy(r,p,sizeof(struct poi_param));
- r->filter=NULL;
- r->filterstr=NULL;
- if(p->filterstr) {
- char *last=g_list_last(l)->data;
- int len=(last - p->filterstr) + strlen(last)+1;
- r->filterstr=g_memdup(p->filterstr,len);
- }
- while(l) {
- r->filter=g_list_append(r->filter, r->filterstr + ((char*)(l->data) - p->filterstr) );
- l=g_list_next(l);
- }
- return r;
+static struct poi_param *gui_internal_poi_param_clone(struct poi_param *p) {
+ struct poi_param *r=g_new(struct poi_param,1);
+ GList *l=p->filter;
+ memcpy(r,p,sizeof(struct poi_param));
+ r->filter=NULL;
+ r->filterstr=NULL;
+ if(p->filterstr) {
+ char *last=g_list_last(l)->data;
+ int len=(last - p->filterstr) + strlen(last)+1;
+ r->filterstr=g_memdup(p->filterstr,len);
+ }
+ while(l) {
+ r->filter=g_list_append(r->filter, r->filterstr + ((char*)(l->data) - p->filterstr) );
+ l=g_list_next(l);
+ }
+ return r;
};
/**
@@ -194,64 +193,60 @@ gui_internal_poi_param_clone(struct poi_param *p)
* @param text filter text.
*/
-void
-gui_internal_poi_param_set_filter(struct poi_param *param, char *text)
-{
- char *s1, *s2;
-
- param->filterstr=removecase(text);
- s1=param->filterstr;
- do {
- s2=g_utf8_strchr(s1,-1,' ');
- if(s2)
- *s2++=0;
- param->filter=g_list_append(param->filter,s1);
- if(s2) {
- while(*s2==' ')
- s2++;
- }
- s1=s2;
- } while(s2 && *s2);
+void gui_internal_poi_param_set_filter(struct poi_param *param, char *text) {
+ char *s1, *s2;
+
+ param->filterstr=removecase(text);
+ s1=param->filterstr;
+ do {
+ s2=g_utf8_strchr(s1,-1,' ');
+ if(s2)
+ *s2++=0;
+ param->filter=g_list_append(param->filter,s1);
+ if(s2) {
+ while(*s2==' ')
+ s2++;
+ }
+ s1=s2;
+ } while(s2 && *s2);
}
-static struct widget *
-gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb)
-{
- struct widget *wl,*wb;
- int nitems,nrows;
- int i;
- //wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal_vertical|flags_fill);
- wl->background=this->background;
- wl->w=this->root.w;
- wl->cols=this->root.w/this->icon_s;
- nitems=sizeof(selectors)/sizeof(struct selector);
- nrows=nitems/wl->cols + (nitems%wl->cols>0);
- wl->h=this->icon_l*nrows;
- for (i = 0 ; i < nitems ; i++) {
- struct poi_param *p=g_new0(struct poi_param,1);
- p->sel = 1;
- p->selnb = i;
- p->pagenb = pagenb;
- p->dist = 0;
- p->filter=NULL;
- p->filterstr=NULL;
- gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, selectors[i].icon), gravity_left_center|orientation_vertical,
- gui_internal_cmd_pois, p));
- wb->c=*c;
- wb->data_free=gui_internal_poi_param_free;
- wb->bt=10;
- }
-
- gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_search"), gravity_left_center|orientation_vertical,
- gui_internal_cmd_pois_filter, NULL));
- wb->c=*c;
- wb->bt=10;
-
- gui_internal_widget_pack(this,wl);
- return wl;
+static struct widget *gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb) {
+ struct widget *wl,*wb;
+ int nitems,nrows;
+ int i;
+ //wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal_vertical|flags_fill);
+ wl->background=this->background;
+ wl->w=this->root.w;
+ wl->cols=this->root.w/this->icon_s;
+ nitems=sizeof(selectors)/sizeof(struct selector);
+ nrows=nitems/wl->cols + (nitems%wl->cols>0);
+ wl->h=this->icon_l*nrows;
+ for (i = 0 ; i < nitems ; i++) {
+ struct poi_param *p=g_new0(struct poi_param,1);
+ p->sel = 1;
+ p->selnb = i;
+ p->pagenb = pagenb;
+ p->dist = 0;
+ p->filter=NULL;
+ p->filterstr=NULL;
+ gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, selectors[i].icon), gravity_left_center|orientation_vertical,
+ gui_internal_cmd_pois, p));
+ wb->c=*c;
+ wb->data_free=gui_internal_poi_param_free;
+ wb->bt=10;
+ }
+
+ gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, "gui_search"), gravity_left_center|orientation_vertical,
+ gui_internal_cmd_pois_filter, NULL));
+ wb->c=*c;
+ wb->bt=10;
+
+ gui_internal_widget_pack(this,wl);
+ return wl;
}
/**
@@ -266,67 +261,66 @@ gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int page
* @return Pointer to new widget.
*/
-static void
-format_dist(int dist, char *distbuf)
-{
- if (dist > 10000)
- sprintf(distbuf,"%d ", dist/1000);
- else if (dist>0)
- sprintf(distbuf,"%d.%d ", dist/1000, (dist%1000)/100);
+static void format_dist(int dist, char *distbuf) {
+ if (dist > 10000)
+ sprintf(distbuf,"%d ", dist/1000);
+ else if (dist>0)
+ sprintf(distbuf,"%d.%d ", dist/1000, (dist%1000)/100);
}
struct widget *
-gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char* name)
-{
- char distbuf[32]="";
- char dirbuf[32]="";
- char routedistbuf[32]="";
- char *type;
- struct widget *wl;
- char *text;
- struct graphics_image *icon;
-
- format_dist(dist,distbuf);
- if(c) {
- int len;
- get_compass_direction(dirbuf, transform_get_angle_delta(center, c, 0), 1);
- len=strlen(dirbuf);
- dirbuf[len]=' ';
- dirbuf[len+1]=0;
- if (route) {
- route_get_distances(route, c, 1, &dist);
- if (dist != INT_MAX)
- format_dist(dist, routedistbuf);
- }
- }
-
-
- type=item_to_name(item->type);
-
- icon=gui_internal_poi_icon(this,item);
- if(!icon && item->type==type_house_number)
- icon=image_new_xs(this,"post");
- if(!icon) {
- icon=image_new_xs(this,"gui_inactive");
- text=g_strdup_printf("%s%s%s%s %s", distbuf, dirbuf, routedistbuf, type, name);
- } else if(strlen(name)>0)
- text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, name);
- else
- text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, type);
-
- wl=gui_internal_button_new_with_callback(this, text, icon, gravity_left_center|orientation_horizontal|flags_fill, NULL, NULL);
- wl->datai=dist;
- g_free(text);
- if (name[0]) {
- wl->name=g_strdup_printf("%s %s",type,name);
- } else {
- wl->name=g_strdup(type);
- }
- wl->func=gui_internal_cmd_position;
- wl->data=(void *)9;
- wl->item=*item;
- wl->state|= STATE_SENSITIVE;
- return wl;
+gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c,
+ struct route *route, int dist, char* name) {
+ char distbuf[32]="";
+ char dirbuf[32]="";
+ char routedistbuf[32]="";
+ char *type;
+ struct widget *wl;
+ char *text;
+ struct graphics_image *icon;
+
+ format_dist(dist,distbuf);
+ if(c) {
+ int len;
+ get_compass_direction(dirbuf, transform_get_angle_delta(center, c, 0), 1);
+ len=strlen(dirbuf);
+ dirbuf[len]=' ';
+ dirbuf[len+1]=0;
+ if (route) {
+ route_get_distances(route, c, 1, &dist);
+ if (dist != INT_MAX)
+ format_dist(dist, routedistbuf);
+ }
+ }
+
+
+ type=item_to_name(item->type);
+
+ icon=gui_internal_poi_icon(this,item);
+ if(!icon && item->type==type_house_number)
+ icon=image_new_xs(this,"post");
+ if(!icon) {
+ icon=image_new_xs(this,"gui_inactive");
+ text=g_strdup_printf("%s%s%s%s %s", distbuf, dirbuf, routedistbuf, type, name);
+ } else if(strlen(name)>0)
+ text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, name);
+ else
+ text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, type);
+
+ wl=gui_internal_button_new_with_callback(this, text, icon, gravity_left_center|orientation_horizontal|flags_fill, NULL,
+ NULL);
+ wl->datai=dist;
+ g_free(text);
+ if (name[0]) {
+ wl->name=g_strdup_printf("%s %s",type,name);
+ } else {
+ wl->name=g_strdup(type);
+ }
+ wl->func=gui_internal_cmd_position;
+ wl->data=(void *)9;
+ wl->item=*item;
+ wl->state|= STATE_SENSITIVE;
+ return wl;
}
/**
@@ -336,87 +330,83 @@ gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct i
* @return Pointer to string representation of address. To be g_free()d after use.
*/
-char *
-gui_internal_compose_item_address_string(struct item *item, int prependPostal)
-{
- char *s=g_strdup("");
- struct attr attr;
- if(prependPostal && item_attr_get(item, attr_postal, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_house_number, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_street_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_street_name_systematic, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_district_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_town_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_county_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_country_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
-
- if(item_attr_get(item, attr_address, &attr))
- s=g_strjoin(" ",s,"|",map_convert_string_tmp(item->map,attr.u.str),NULL);
- return s;
+char *gui_internal_compose_item_address_string(struct item *item, int prependPostal) {
+ char *s=g_strdup("");
+ struct attr attr;
+ if(prependPostal && item_attr_get(item, attr_postal, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_house_number, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_street_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_street_name_systematic, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_district_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_town_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_county_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_country_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+
+ if(item_attr_get(item, attr_address, &attr))
+ s=g_strjoin(" ",s,"|",map_convert_string_tmp(item->map,attr.u.str),NULL);
+ return s;
}
-static int
-gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item)
-{
- enum item_type *types;
- struct selector *sel = param->sel? &selectors[param->selnb]: NULL;
- enum item_type type=item->type;
- struct attr attr;
- int match=0;
- if (type >= type_line && param->filter==NULL)
- return 0;
- if (! sel || !sel->types) {
- match=1;
- } else {
- types=sel->types;
- while (*types != type_none) {
- if (item->type >= types[0] && item->type <= types[1]) {
- return 1;
- }
- types+=2;
- }
- }
- if(type == type_house_number && !param->filter)
- return 0;
- if (param->filter) {
- char *long_name, *s;
- GList *f;
- int i;
- if (param->AddressFilterType>0) {
- s=gui_internal_compose_item_address_string(item,param->AddressFilterType==2?1:0);
- } else if (item_attr_get(item, attr_label, &attr)) {
- s=g_strdup_printf("%s %s", item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
- } else {
- s=g_strdup(item_to_name(item->type));
- }
- long_name=removecase(s);
- g_free(s);
-
- match=0;
- for(i=0;i<3 && !match;i++) {
- char *long_name_exp=linguistics_expand_special(long_name, i);
- for(s=long_name_exp,f=param->filter;f && s;f=g_list_next(f)) {
- s=strstr(s,f->data);
- if(!s) {
- break;
- }
- s=g_utf8_strchr(s,-1,' ');
- }
- g_free(long_name_exp);
- if(!f)
- match=1;
- }
- g_free(long_name);
- }
- return match;
+static int gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item) {
+ enum item_type *types;
+ struct selector *sel = param->sel? &selectors[param->selnb]: NULL;
+ enum item_type type=item->type;
+ struct attr attr;
+ int match=0;
+ if (type >= type_line && param->filter==NULL)
+ return 0;
+ if (! sel || !sel->types) {
+ match=1;
+ } else {
+ types=sel->types;
+ while (*types != type_none) {
+ if (item->type >= types[0] && item->type <= types[1]) {
+ return 1;
+ }
+ types+=2;
+ }
+ }
+ if(type == type_house_number && !param->filter)
+ return 0;
+ if (param->filter) {
+ char *long_name, *s;
+ GList *f;
+ int i;
+ if (param->AddressFilterType>0) {
+ s=gui_internal_compose_item_address_string(item,param->AddressFilterType==2?1:0);
+ } else if (item_attr_get(item, attr_label, &attr)) {
+ s=g_strdup_printf("%s %s", item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
+ } else {
+ s=g_strdup(item_to_name(item->type));
+ }
+ long_name=removecase(s);
+ g_free(s);
+
+ match=0;
+ for(i=0; i<3 && !match; i++) {
+ char *long_name_exp=linguistics_expand_special(long_name, i);
+ for(s=long_name_exp,f=param->filter; f && s; f=g_list_next(f)) {
+ s=strstr(s,f->data);
+ if(!s) {
+ break;
+ }
+ s=g_utf8_strchr(s,-1,' ');
+ }
+ g_free(long_name_exp);
+ if(!f)
+ match=1;
+ }
+ g_free(long_name);
+ }
+ return match;
}
/**
@@ -426,17 +416,15 @@ gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item)
* @param wm called widget.
* @param data event data.
*/
-static void
-gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=g_new0(struct widget,1);
- w->data=wm->data;
- w->c=wm->c;
- w->w=wm->w;
- wm->data_free=NULL;
- gui_internal_back(this, NULL, NULL);
- gui_internal_cmd_pois(this, w, w->data);
- free(w);
+static void gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w=g_new0(struct widget,1);
+ w->data=wm->data;
+ w->c=wm->c;
+ w->w=wm->w;
+ wm->data_free=NULL;
+ gui_internal_back(this, NULL, NULL);
+ gui_internal_cmd_pois(this, w, w->data);
+ free(w);
}
@@ -447,46 +435,42 @@ gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data)
* @param wm called widget.
* @param data event data (pointer to editor widget containg filter text).
*/
-static void
-gui_internal_cmd_pois_filter_do(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=data;
- struct poi_param *param;
-
- if(!w->text)
- return;
-
- if(w->data) {
- param=gui_internal_poi_param_clone(w->data);
- param->pagenb=0;
- } else {
- param=g_new0(struct poi_param,1);
- }
- if(!strcmp(wm->name,"AddressFilter"))
- param->AddressFilterType=1;
- else if(!strcmp(wm->name,"AddressFilterZip"))
- param->AddressFilterType=2;
- else
- param->AddressFilterType=0;
-
- gui_internal_poi_param_set_filter(param, w->text);
-
- gui_internal_cmd_pois(this,w,param);
- gui_internal_poi_param_free(param);
+static void gui_internal_cmd_pois_filter_do(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w=data;
+ struct poi_param *param;
+
+ if(!w->text)
+ return;
+
+ if(w->data) {
+ param=gui_internal_poi_param_clone(w->data);
+ param->pagenb=0;
+ } else {
+ param=g_new0(struct poi_param,1);
+ }
+ if(!strcmp(wm->name,"AddressFilter"))
+ param->AddressFilterType=1;
+ else if(!strcmp(wm->name,"AddressFilterZip"))
+ param->AddressFilterType=2;
+ else
+ param->AddressFilterType=0;
+
+ gui_internal_poi_param_set_filter(param, w->text);
+
+ gui_internal_cmd_pois(this,w,param);
+ gui_internal_poi_param_free(param);
}
/**
* @brief POIs filter dialog.
* Event to handle '\r' '\n' keys pressed.
- *
+ *
*/
-static void
-gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->text && wm->reason==gui_internal_reason_keypress_finish) {
- gui_internal_cmd_pois_filter_do(this, wm, wm);
- }
+static void gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, void *data) {
+ if (wm->text && wm->reason==gui_internal_reason_keypress_finish) {
+ gui_internal_cmd_pois_filter_do(this, wm, wm);
+ }
}
@@ -497,48 +481,46 @@ gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, v
* @param wm called widget.
* @param data event data.
*/
-void
-gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *wb, *w, *wr, *wk, *we;
- int keyboard_mode;
- keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"));
- wb=gui_internal_menu(this,"Filter");
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
-
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
- wk->state |= STATE_EDIT|STATE_EDITABLE;
- wk->func=gui_internal_cmd_pois_filter_changed;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->name=g_strdup("POIsFilter");
- wk->c=wm->c;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->name=g_strdup("NameFilter");
- wb->data=wk;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "post")));
- wb->state |= STATE_SENSITIVE;
- wb->name=g_strdup("AddressFilter");
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->data=wk;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "zipcode")));
- wb->state |= STATE_SENSITIVE;
- wb->name=g_strdup("AddressFilterZip");
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->data=wk;
-
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
- else
- gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *wb, *w, *wr, *wk, *we;
+ int keyboard_mode;
+ keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"));
+ wb=gui_internal_menu(this,"Filter");
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wr);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, we);
+
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
+ wk->state |= STATE_EDIT|STATE_EDITABLE;
+ wk->func=gui_internal_cmd_pois_filter_changed;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->name=g_strdup("POIsFilter");
+ wk->c=wm->c;
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wb->state |= STATE_SENSITIVE;
+ wb->func = gui_internal_cmd_pois_filter_do;
+ wb->name=g_strdup("NameFilter");
+ wb->data=wk;
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "post")));
+ wb->state |= STATE_SENSITIVE;
+ wb->name=g_strdup("AddressFilter");
+ wb->func = gui_internal_cmd_pois_filter_do;
+ wb->data=wk;
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "zipcode")));
+ wb->state |= STATE_SENSITIVE;
+ wb->name=g_strdup("AddressFilterZip");
+ wb->func = gui_internal_cmd_pois_filter_do;
+ wb->data=wk;
+
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
+ else
+ gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
+ gui_internal_menu_render(this);
}
@@ -550,243 +532,237 @@ gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *dat
* @param wm called widget.
* @param data event data, reference to poi_param or NULL.
*/
-void
-gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct map_selection *sel,*selm;
- struct coord c,center;
- struct mapset_handle *h;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct widget *wi,*w,*w2,*wb, *wtable, *row;
- enum projection pro=wm->c.pro;
- struct poi_param *param;
- int param_free=0;
- int idist,dist;
- struct selector *isel;
- int pagenb;
- int prevdist;
- // Starting value and increment of count of items to be extracted
- const int pagesize = 50;
- int maxitem, it = 0, i;
- struct item_data *items;
- struct fibheap* fh = fh_makekeyheap();
- int cnt = 0;
- struct table_data *td;
- struct widget *wl,*wt;
- char buffer[32];
- struct poi_param *paramnew;
- struct attr route;
-dbg(lvl_debug,"POIs...");
- if(data) {
- param = data;
- } else {
- param = g_new0(struct poi_param,1);
- param_free=1;
- }
- if (navit_get_attr(this->nav, attr_route, &route, NULL)) {
- struct attr route_status;
- if (!route_get_attr(route.u.route, attr_route_status, &route_status, NULL) ||
- (route_status.u.num != route_status_path_done_new &&
- route_status.u.num != route_status_path_done_incremental))
- route.u.route=NULL;
- } else
- route.u.route=NULL;
- dist=10000*(param->dist+1);
- isel = param->sel? &selectors[param->selnb]: NULL;
- pagenb = param->pagenb;
- prevdist=param->dist*10000;
- maxitem = pagesize*(pagenb+1);
- items= g_new0( struct item_data, maxitem);
-
-
- dbg(lvl_debug, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, AddressFilterType= %d\n",
- param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->AddressFilterType);
-
- wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if (!isel && !param->filter)
- gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb));
- w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, w2);
-
- sel=map_selection_rect_new(&wm->c,dist*transform_scale(abs(wm->c.y)+dist*1.5),18);
- center.x=wm->c.x;
- center.y=wm->c.y;
- h=mapset_open(navit_get_mapset(this->nav));
- while ((m=mapset_next(h, 1))) {
- selm=map_selection_dup_pro(sel, pro, map_projection(m));
- mr=map_rect_new(m, selm);
- dbg(lvl_debug,"mr=%p\n", mr);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- if (gui_internal_cmd_pois_item_selected(param, item) &&
- item_coord_get_pro(item, &c, 1, pro) &&
- coord_rect_contains(&sel->u.c_rect, &c) &&
- (idist=transform_distance(pro, &center, &c)) < dist) {
- struct item_data *data;
- struct attr attr;
- char *label;
- item_attr_rewind(item);
- if (item->type==type_house_number) {
- label=gui_internal_compose_item_address_string(item,1);
- } else if (item_attr_get(item, attr_label, &attr)) {
- label=map_convert_string(item->map,attr.u.str);
- // Buildings which label is equal to addr:housenumber value
- // are duplicated by item_house_number. Don't include such
- // buildings into the list. This is true for OSM maps created with
- // maptool patched with #859 latest patch.
- // FIXME: For non-OSM maps, we probably would better don't skip these items.
- if(item->type==type_poly_building && item_attr_get(item, attr_house_number, &attr) ) {
- if(strcmp(label,map_convert_string_tmp(item->map,attr.u.str))==0) {
- g_free(label);
- continue;
- }
- }
-
- } else {
- label=g_strdup("");
- }
-
- if(it>=maxitem) {
- data = fh_extractmin(fh);
- g_free(data->label);
- data->label=NULL;
- } else {
- data = &items[it++];
- }
- data->label=label;
- data->item = *item;
- data->c = c;
- data->dist = idist;
- // Key expression is a workaround to fight
- // probable heap collisions when two objects
- // are at the same distance. But it destroys
- // right order of POIs 2048 km away from cener
- // and if table grows more than 1024 rows.
- fh_insertkey(fh, -((idist<<10) + cnt++), data);
- if (it == maxitem)
- dist = (-fh_minkey(fh))>>10;
- }
- }
- map_rect_destroy(mr);
- }
- map_selection_destroy(selm);
- }
- map_selection_destroy(sel);
- mapset_close(h);
-
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- td=wtable->data;
-
- gui_internal_widget_append(w2,wtable);
-
- // Move items from heap to the table
- for(i=0;;i++)
- {
- int key = fh_minkey(fh);
- struct item_data *data = fh_extractmin(fh);
- if (data == NULL)
- {
- dbg(lvl_debug, "Empty heap: maxitem = %i, it = %i, dist = %i\n", maxitem, it, dist);
- break;
- }
- dbg(lvl_debug, "dist1: %i, dist2: %i\n", data->dist, (-key)>>10);
- if(i==(it-pagesize*pagenb) && data->dist>prevdist)
- prevdist=data->dist;
- wi=gui_internal_cmd_pois_item(this, &center, &data->item, &data->c, route.u.route, data->dist, data->label);
- wi->c.x=data->c.x;
- wi->c.y=data->c.y;
- wi->c.pro=pro;
- wi->background=this->background;
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(row,wi);
- row->datai=data->dist;
- gui_internal_widget_prepend(wtable,row);
- g_free(data->label);
- }
-
- fh_deleteheap(fh);
- free(items);
-
- // Add an entry for more POI
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- row->datai=100000000; // Really far away for Earth, but won't work for bigger planets.
- gui_internal_widget_append(wtable,row);
- wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(row,wl);
- if (it == maxitem) {
- paramnew=gui_internal_poi_param_clone(param);
- paramnew->pagenb++;
- paramnew->count=it;
- snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (paramnew->pagenb+1)*pagesize);
- wt=gui_internal_label_new(this, buffer);
- gui_internal_widget_append(wl, wt);
- wt->func=gui_internal_cmd_pois_more;
- wt->data=paramnew;
- wt->data_free=gui_internal_poi_param_free;
- wt->state |= STATE_SENSITIVE;
- wt->c = wm->c;
- } else {
- static int dist[]={1,5,10,0};
- wt=gui_internal_label_new(this, "Set distance to");
- gui_internal_widget_append(wl, wt);
- for(i=0;dist[i];i++) {
- paramnew=gui_internal_poi_param_clone(param);
- paramnew->dist+=dist[i];
- paramnew->count=it;
- snprintf(buffer, sizeof(buffer), " %i ", 10*(paramnew->dist+1));
- wt=gui_internal_label_new(this, buffer);
- gui_internal_widget_append(wl, wt);
- wt->func=gui_internal_cmd_pois_more;
- wt->data=paramnew;
- wt->data_free=gui_internal_poi_param_free;
- wt->state |= STATE_SENSITIVE;
- wt->c = wm->c;
- }
- wt=gui_internal_label_new(this, "km.");
- gui_internal_widget_append(wl, wt);
-
- }
- // Rendering now is needed to have table_data->bottomrow filled in.
- gui_internal_menu_render(this);
- td=wtable->data;
- if(td->bottom_row!=NULL)
- {
+void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data) {
+ struct map_selection *sel,*selm;
+ struct coord c,center;
+ struct mapset_handle *h;
+ struct map *m;
+ struct map_rect *mr;
+ struct item *item;
+ struct widget *wi,*w,*w2,*wb, *wtable, *row;
+ enum projection pro=wm->c.pro;
+ struct poi_param *param;
+ int param_free=0;
+ int idist,dist;
+ struct selector *isel;
+ int pagenb;
+ int prevdist;
+ // Starting value and increment of count of items to be extracted
+ const int pagesize = 50;
+ int maxitem, it = 0, i;
+ struct item_data *items;
+ struct fibheap* fh = fh_makekeyheap();
+ int cnt = 0;
+ struct table_data *td;
+ struct widget *wl,*wt;
+ char buffer[32];
+ struct poi_param *paramnew;
+ struct attr route;
+ dbg(lvl_debug,"POIs...");
+ if(data) {
+ param = data;
+ } else {
+ param = g_new0(struct poi_param,1);
+ param_free=1;
+ }
+ if (navit_get_attr(this->nav, attr_route, &route, NULL)) {
+ struct attr route_status;
+ if (!route_get_attr(route.u.route, attr_route_status, &route_status, NULL) ||
+ (route_status.u.num != route_status_path_done_new &&
+ route_status.u.num != route_status_path_done_incremental))
+ route.u.route=NULL;
+ } else
+ route.u.route=NULL;
+ dist=10000*(param->dist+1);
+ isel = param->sel? &selectors[param->selnb]: NULL;
+ pagenb = param->pagenb;
+ prevdist=param->dist*10000;
+ maxitem = pagesize*(pagenb+1);
+ items= g_new0( struct item_data, maxitem);
+
+
+ dbg(lvl_debug, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, AddressFilterType= %d",
+ param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->AddressFilterType);
+
+ wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ if (!isel && !param->filter)
+ gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb));
+ w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, w2);
+
+ sel=map_selection_rect_new(&wm->c,dist*transform_scale(abs(wm->c.y)+dist*1.5),18);
+ center.x=wm->c.x;
+ center.y=wm->c.y;
+ h=mapset_open(navit_get_mapset(this->nav));
+ while ((m=mapset_next(h, 1))) {
+ selm=map_selection_dup_pro(sel, pro, map_projection(m));
+ mr=map_rect_new(m, selm);
+ dbg(lvl_debug,"mr=%p", mr);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ if (gui_internal_cmd_pois_item_selected(param, item) &&
+ item_coord_get_pro(item, &c, 1, pro) &&
+ coord_rect_contains(&sel->u.c_rect, &c) &&
+ (idist=transform_distance(pro, &center, &c)) < dist) {
+ struct item_data *data;
+ struct attr attr;
+ char *label;
+ item_attr_rewind(item);
+ if (item->type==type_house_number) {
+ label=gui_internal_compose_item_address_string(item,1);
+ } else if (item_attr_get(item, attr_label, &attr)) {
+ label=map_convert_string(item->map,attr.u.str);
+ // Buildings which label is equal to addr:housenumber value
+ // are duplicated by item_house_number. Don't include such
+ // buildings into the list. This is true for OSM maps created with
+ // maptool patched with #859 latest patch.
+ // FIXME: For non-OSM maps, we probably would better don't skip these items.
+ if(item->type==type_poly_building && item_attr_get(item, attr_house_number, &attr) ) {
+ if(strcmp(label,map_convert_string_tmp(item->map,attr.u.str))==0) {
+ g_free(label);
+ continue;
+ }
+ }
+
+ } else {
+ label=g_strdup("");
+ }
+
+ if(it>=maxitem) {
+ data = fh_extractmin(fh);
+ g_free(data->label);
+ data->label=NULL;
+ } else {
+ data = &items[it++];
+ }
+ data->label=label;
+ data->item = *item;
+ data->c = c;
+ data->dist = idist;
+ // Key expression is a workaround to fight
+ // probable heap collisions when two objects
+ // are at the same distance. But it destroys
+ // right order of POIs 2048 km away from cener
+ // and if table grows more than 1024 rows.
+ fh_insertkey(fh, -((idist<<10) + cnt++), data);
+ if (it == maxitem)
+ dist = (-fh_minkey(fh))>>10;
+ }
+ }
+ map_rect_destroy(mr);
+ }
+ map_selection_destroy(selm);
+ }
+ map_selection_destroy(sel);
+ mapset_close(h);
+
+ wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ td=wtable->data;
+
+ gui_internal_widget_append(w2,wtable);
+
+ // Move items from heap to the table
+ for(i=0;; i++) {
+ int key = fh_minkey(fh);
+ struct item_data *data = fh_extractmin(fh);
+ if (data == NULL) {
+ dbg(lvl_debug, "Empty heap: maxitem = %i, it = %i, dist = %i", maxitem, it, dist);
+ break;
+ }
+ dbg(lvl_debug, "dist1: %i, dist2: %i", data->dist, (-key)>>10);
+ if(i==(it-pagesize*pagenb) && data->dist>prevdist)
+ prevdist=data->dist;
+ wi=gui_internal_cmd_pois_item(this, &center, &data->item, &data->c, route.u.route, data->dist, data->label);
+ wi->c.x=data->c.x;
+ wi->c.y=data->c.y;
+ wi->c.pro=pro;
+ wi->background=this->background;
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ gui_internal_widget_append(row,wi);
+ row->datai=data->dist;
+ gui_internal_widget_prepend(wtable,row);
+ g_free(data->label);
+ }
+
+ fh_deleteheap(fh);
+ free(items);
+
+ // Add an entry for more POI
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ row->datai=100000000; // Really far away for Earth, but won't work for bigger planets.
+ gui_internal_widget_append(wtable,row);
+ wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(row,wl);
+ if (it == maxitem) {
+ paramnew=gui_internal_poi_param_clone(param);
+ paramnew->pagenb++;
+ paramnew->count=it;
+ snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (paramnew->pagenb+1)*pagesize);
+ wt=gui_internal_label_new(this, buffer);
+ gui_internal_widget_append(wl, wt);
+ wt->func=gui_internal_cmd_pois_more;
+ wt->data=paramnew;
+ wt->data_free=gui_internal_poi_param_free;
+ wt->state |= STATE_SENSITIVE;
+ wt->c = wm->c;
+ } else {
+ static int dist[]= {1,5,10,0};
+ wt=gui_internal_label_new(this, "Set distance to");
+ gui_internal_widget_append(wl, wt);
+ for(i=0; dist[i]; i++) {
+ paramnew=gui_internal_poi_param_clone(param);
+ paramnew->dist+=dist[i];
+ paramnew->count=it;
+ snprintf(buffer, sizeof(buffer), " %i ", 10*(paramnew->dist+1));
+ wt=gui_internal_label_new(this, buffer);
+ gui_internal_widget_append(wl, wt);
+ wt->func=gui_internal_cmd_pois_more;
+ wt->data=paramnew;
+ wt->data_free=gui_internal_poi_param_free;
+ wt->state |= STATE_SENSITIVE;
+ wt->c = wm->c;
+ }
+ wt=gui_internal_label_new(this, "km.");
+ gui_internal_widget_append(wl, wt);
+
+ }
+ // Rendering now is needed to have table_data->bottomrow filled in.
+ gui_internal_menu_render(this);
+ td=wtable->data;
+ if(td->bottom_row!=NULL) {
#if 0
- while(((struct widget*)td->bottom_row->data)->datai<=prevdist
- && (td->next_button->state & STATE_SENSITIVE))
- {
- gui_internal_table_button_next(this, td->next_button, NULL);
- }
+ while(((struct widget*)td->bottom_row->data)->datai<=prevdist
+ && (td->next_button->state & STATE_SENSITIVE)) {
+ gui_internal_table_button_next(this, td->next_button, NULL);
+ }
#else
- int firstrow=g_list_index(wtable->children, td->top_row->data);
- while(firstrow>=0) {
- int currow=g_list_index(wtable->children, td->bottom_row->data) - firstrow;
- if(currow<0) {
- dbg(lvl_debug,"Can't find bottom row in children list. Stop paging.\n");
- break;
- }
- if(currow>=param->count)
- break;
- if(!(td->scroll_buttons.next_button->state & STATE_SENSITIVE)) {
- dbg(lvl_debug,"Reached last page but item %i not found. Stop paging.\n",param->count);
- break;
- }
- gui_internal_table_button_next(this, td->scroll_buttons.next_button, NULL);
- }
+ int firstrow=g_list_index(wtable->children, td->top_row->data);
+ while(firstrow>=0) {
+ int currow=g_list_index(wtable->children, td->bottom_row->data) - firstrow;
+ if(currow<0) {
+ dbg(lvl_debug,"Can't find bottom row in children list. Stop paging.");
+ break;
+ }
+ if(currow>=param->count)
+ break;
+ if(!(td->scroll_buttons.next_button->state & STATE_SENSITIVE)) {
+ dbg(lvl_debug,"Reached last page but item %i not found. Stop paging.",param->count);
+ break;
+ }
+ gui_internal_table_button_next(this, td->scroll_buttons.next_button, NULL);
+ }
#endif
- }
- gui_internal_menu_render(this);
- if(param_free)
- g_free(param);
+ }
+ gui_internal_menu_render(this);
+ if(param_free)
+ g_free(param);
}
diff --git a/navit/gui/internal/gui_internal_poi.h b/navit/gui/internal/gui_internal_poi.h
index 665f44a70..c2515a1c6 100644
--- a/navit/gui/internal/gui_internal_poi.h
+++ b/navit/gui/internal/gui_internal_poi.h
@@ -6,40 +6,40 @@
struct poi_param {
- /**
- * =1 if selnb is defined, 0 otherwize.
- */
- unsigned char sel;
+ /**
+ * =1 if selnb is defined, 0 otherwize.
+ */
+ unsigned char sel;
- /**
- * Index to struct selector selectors[], shows what type of POIs is defined.
- */
- unsigned char selnb;
- /**
- * Page number to display.
- */
- unsigned char pagenb;
- /**
- * Radius (number of 10-kilometer intervals) to search for POIs.
- */
- unsigned char dist;
- /**
- * Should filter phrase be compared to postal address of the POI.
- * =0 - name filter, =1 - address filter, =2 - address filter, including postal code
- */
- unsigned char AddressFilterType;
- /**
- * Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*.
- */
- char *filterstr;
- /**
- * list of pointers to individual substrings of filterstr.
- */
- GList *filter;
- /**
- * Number of POIs in this list
- */
- int count;
+ /**
+ * Index to struct selector selectors[], shows what type of POIs is defined.
+ */
+ unsigned char selnb;
+ /**
+ * Page number to display.
+ */
+ unsigned char pagenb;
+ /**
+ * Radius (number of 10-kilometer intervals) to search for POIs.
+ */
+ unsigned char dist;
+ /**
+ * Should filter phrase be compared to postal address of the POI.
+ * =0 - name filter, =1 - address filter, =2 - address filter, including postal code
+ */
+ unsigned char AddressFilterType;
+ /**
+ * Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*.
+ */
+ char *filterstr;
+ /**
+ * list of pointers to individual substrings of filterstr.
+ */
+ GList *filter;
+ /**
+ * Number of POIs in this list
+ */
+ int count;
};
/* prototypes */
@@ -50,7 +50,8 @@ struct poi_param;
struct widget;
void gui_internal_poi_param_free(void *p);
void gui_internal_poi_param_set_filter(struct poi_param *param, char *text);
-struct widget *gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char *name);
+struct widget *gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item,
+ struct coord *c, struct route *route, int dist, char *name);
char *gui_internal_compose_item_address_string(struct item *item, int prependPostal);
void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data);
diff --git a/navit/gui/internal/gui_internal_priv.h b/navit/gui/internal/gui_internal_priv.h
index 37b09d62a..d28cac649 100644
--- a/navit/gui/internal/gui_internal_priv.h
+++ b/navit/gui/internal/gui_internal_priv.h
@@ -6,33 +6,33 @@
*/
struct gui_config_settings {
- /**
- * The base size (in fractions of a point) to use for text.
- */
- int font_size;
- /**
- * The size (in pixels) that xs style icons should be scaled to.
- * This icon size is typically used in various lists and should be set to value which allows a list row to be easily cliked or dragged.
- */
- int icon_xs;
- /**
- * The size (in pixels) that s style icons (small) should be scaled to, used for the menu top row icons
- */
- int icon_s;
- /**
- * The size (in pixels) that l style icons should be scaled to, used for icons defined in the menu html
- */
- int icon_l;
- /**
- * The default amount of spacing (in pixels) to place between GUI elements.
- */
- int spacing;
+ /**
+ * The base size (in fractions of a point) to use for text.
+ */
+ int font_size;
+ /**
+ * The size (in pixels) that xs style icons should be scaled to.
+ * This icon size is typically used in various lists and should be set to value which allows a list row to be easily cliked or dragged.
+ */
+ int icon_xs;
+ /**
+ * The size (in pixels) that s style icons (small) should be scaled to, used for the menu top row icons
+ */
+ int icon_s;
+ /**
+ * The size (in pixels) that l style icons should be scaled to, used for icons defined in the menu html
+ */
+ int icon_l;
+ /**
+ * The default amount of spacing (in pixels) to place between GUI elements.
+ */
+ int spacing;
};
struct route_data {
- struct widget * route_table;
- int route_showing;
+ struct widget * route_table;
+ int route_showing;
};
/**
@@ -41,136 +41,136 @@ struct route_data {
* @author Martin Schaller (04/2008)
*/
struct gui_priv {
- struct navit *nav;
- struct attr self;
- struct window *win;
- struct graphics *gra;
- struct graphics_gc *background;
- struct graphics_gc *background2;
- struct graphics_gc *highlight_background;
- struct graphics_gc *foreground;
- struct graphics_gc *text_foreground;
- struct graphics_gc *text_background;
- struct color background_color, background2_color, text_foreground_color, text_background_color;
- int spacing;
- int font_size;
- char *font_name;
- int fullscreen;
- struct graphics_font *fonts[3];
- int icon_xs; /**< The size (in pixels) that xs style icons should be scaled to.
+ struct navit *nav;
+ struct attr self;
+ struct window *win;
+ struct graphics *gra;
+ struct graphics_gc *background;
+ struct graphics_gc *background2;
+ struct graphics_gc *highlight_background;
+ struct graphics_gc *foreground;
+ struct graphics_gc *text_foreground;
+ struct graphics_gc *text_background;
+ struct color background_color, background2_color, text_foreground_color, text_background_color;
+ int spacing;
+ int font_size;
+ char *font_name;
+ int fullscreen;
+ struct graphics_font *fonts[3];
+ int icon_xs; /**< The size (in pixels) that xs style icons should be scaled to.
* This icon size can be too small to click it on some devices.
*/
- int icon_s; /**< The size (in pixels) that s style icons (small) should be scaled to */
- int icon_l; /**< The size (in pixels) that l style icons should be scaled to */
- int pressed;
- struct widget *widgets;
- int widgets_count;
- int redraw;
- struct widget root;
- struct widget *highlighted,*editable;
- struct widget *highlighted_menu;
- struct pcoord clickp, vehiclep;
- struct attr *click_coord_geo, *position_coord_geo;
- struct search_list *sl;
- int ignore_button;
- int menu_on_map_click;
- char *on_map_click;
- int signal_on_map_click;
- char *country_iso2;
- int speech;
- int keyboard; /**< Whether the internal GUI keyboard is enabled */
- int keyboard_required; /**< Whether keyboard input is needed. This is only used by the
+ int icon_s; /**< The size (in pixels) that s style icons (small) should be scaled to */
+ int icon_l; /**< The size (in pixels) that l style icons should be scaled to */
+ int pressed;
+ struct widget *widgets;
+ int widgets_count;
+ int redraw;
+ struct widget root;
+ struct widget *highlighted,*editable;
+ struct widget *highlighted_menu;
+ struct pcoord clickp, vehiclep;
+ struct attr *click_coord_geo, *position_coord_geo;
+ struct search_list *sl;
+ int ignore_button;
+ int menu_on_map_click;
+ char *on_map_click;
+ int signal_on_map_click;
+ char *country_iso2;
+ int speech;
+ int keyboard; /**< Whether the internal GUI keyboard is enabled */
+ int keyboard_required; /**< Whether keyboard input is needed. This is only used by the
* HTML menu, text entry dialogs do not use this member.
*/
- struct gui_config_settings config; /**< The setting information read from the configuration file.
+ struct gui_config_settings config; /**< The setting information read from the configuration file.
* values of -1 indicate no value was specified in the config file.
*/
- struct event_idle *idle;
- struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback;
- struct event_timeout *motion_timeout_event;
- struct point current;
+ struct event_idle *idle;
+ struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback;
+ struct event_timeout *motion_timeout_event;
+ struct point current;
- struct callback * vehicle_cb;
- struct route_data route_data; /**< Stores information about the route. */
+ struct callback * vehicle_cb;
+ struct route_data route_data; /**< Stores information about the route. */
- struct gui_internal_data data;
- struct callback_list *cbl;
- int flags;
- int cols;
- struct attr osd_configuration; /**< The OSD configuration, a set of flags controlling which OSD
+ struct gui_internal_data data;
+ struct callback_list *cbl;
+ int flags;
+ int cols;
+ struct attr osd_configuration; /**< The OSD configuration, a set of flags controlling which OSD
* items will be visible.
*/
- int pitch; /**< The pitch for the 3D map view. */
- int flags_town,flags_street,flags_house_number;
- int radius;
- int mouse_button_clicked_on_map;
-/* html */
- char *html_text;
- int html_depth;
- struct widget *html_container;
- int html_skip;
- char *html_anchor;
- char *href;
- int html_anchor_found;
- struct form *form;
- struct html {
- int skip;
- enum html_tag {
- html_tag_none,
- html_tag_a,
- html_tag_h1,
- html_tag_html,
- html_tag_img,
- html_tag_script,
- html_tag_form,
- html_tag_input,
- html_tag_div,
- } tag;
- char *command;
- char *name;
- char *href;
- char *refresh_cond;
- char *class;
- int font_size;
- struct widget *w;
- struct widget *container;
- } html[10];
+ int pitch; /**< The pitch for the 3D map view. */
+ int flags_town,flags_street,flags_house_number;
+ int radius;
+ int mouse_button_clicked_on_map;
+ /* html */
+ char *html_text;
+ int html_depth;
+ struct widget *html_container;
+ int html_skip;
+ char *html_anchor;
+ char *href;
+ int html_anchor_found;
+ struct form *form;
+ struct html {
+ int skip;
+ enum html_tag {
+ html_tag_none,
+ html_tag_a,
+ html_tag_h1,
+ html_tag_html,
+ html_tag_img,
+ html_tag_script,
+ html_tag_form,
+ html_tag_input,
+ html_tag_div,
+ } tag;
+ char *command;
+ char *name;
+ char *href;
+ char *refresh_cond;
+ char *class;
+ int font_size;
+ struct widget *w;
+ struct widget *container;
+ } html[10];
-/* gestures */
+ /* gestures */
- struct gesture_elem {
- long long msec;
- struct point p;
- } gesture_ring[GESTURE_RINGSIZE];
- int gesture_ring_last, gesture_ring_first;
+ struct gesture_elem {
+ long long msec;
+ struct point p;
+ } gesture_ring[GESTURE_RINGSIZE];
+ int gesture_ring_last, gesture_ring_first;
- int hide_keys; //Flag to set the keyboard mode 1: hide impossible keys on search; 0: highlight them.
- int results_map_population;
+ int hide_keys; //Flag to set the keyboard mode 1: hide impossible keys on search; 0: highlight them.
+ int results_map_population;
};
struct menu_data {
- struct widget *search_list;
- struct widget *keyboard;
- struct widget *button_bar;
- struct widget *menu;
- int keyboard_mode;
- void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
- struct widget *redisplay_widget;
- char *href;
- struct attr refresh_callback_obj,refresh_callback;
+ struct widget *search_list;
+ struct widget *keyboard;
+ struct widget *button_bar;
+ struct widget *menu;
+ int keyboard_mode;
+ void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
+ struct widget *redisplay_widget;
+ char *href;
+ struct attr refresh_callback_obj,refresh_callback;
};
struct heightline {
- struct heightline *next;
- int height;
- struct coord_rect bbox;
- int count;
- struct coord c[0];
+ struct heightline *next;
+ int height;
+ struct coord_rect bbox;
+ int count;
+ struct coord c[0];
};
struct diagram_point {
- struct diagram_point *next;
- struct coord c;
+ struct diagram_point *next;
+ struct coord c;
};
/* prototypes */
enum flags;
@@ -190,18 +190,22 @@ struct widget;
struct graphics_image *image_new_xs(struct gui_priv *this, const char *name);
struct graphics_image *image_new_s(struct gui_priv *this, const char *name);
struct graphics_image *image_new_l(struct gui_priv *this, const char *name);
-struct widget *gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on, struct attr *off);
-struct widget *gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt);
+struct widget *gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags,
+ struct attr *on, struct attr *off);
+struct widget *gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags,
+ struct map *map, struct attr *on, struct attr *off, int deflt);
void gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark);
void gui_internal_back(struct gui_priv *this, struct widget *w, void *data);
void gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data);
struct widget *gui_internal_time_help(struct gui_priv *this);
void gui_internal_apply_config(struct gui_priv *this);
-void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_, void (*cmd)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
+void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_,
+ void (*cmd)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
void gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data);
char *removecase(char *s);
-void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in, struct widget *wm, const char *name, int flags);
+void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in,
+ struct widget *wm, const char *name, int flags);
void gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_keypress_do(struct gui_priv *this, char *key);
diff --git a/navit/gui/internal/gui_internal_search.c b/navit/gui/internal/gui_internal_search.c
index ceeeb7438..c90d4b22d 100644
--- a/navit/gui/internal/gui_internal_search.c
+++ b/navit/gui/internal/gui_internal_search.c
@@ -22,325 +22,302 @@
#include "gui_internal_keyboard.h"
#include "gui_internal_search.h"
-static void
-gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_prune_menu_count(this, 1, 0);
- gui_internal_search(this,_("Country"),"Country",0);
+static void gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_prune_menu_count(this, 1, 0);
+ gui_internal_search(this,_("Country"),"Country",0);
}
-static void
-gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (this->sl)
- search_list_select(this->sl, attr_country_all, 0, 0);
- g_free(this->country_iso2);
- this->country_iso2=NULL;
- gui_internal_search(this,_("Town"),"Town",0);
+static void gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data) {
+ if (this->sl)
+ search_list_select(this->sl, attr_country_all, 0, 0);
+ g_free(this->country_iso2);
+ this->country_iso2=NULL;
+ gui_internal_search(this,_("Town"),"Town",0);
}
-static void
-gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data)
-{
- search_list_select(this->sl, attr_town_or_district_name, 0, 0);
- gui_internal_search(this,_("Street"),"Street",0);
+static void gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data) {
+ search_list_select(this->sl, attr_town_or_district_name, 0, 0);
+ gui_internal_search(this,_("Street"),"Street",0);
}
-static void
-gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data)
-{
- search_list_select(this->sl, attr_street_name, 0, 0);
- gui_internal_search(this,_("House number"),"House number",0);
+static void gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data) {
+ search_list_select(this->sl, attr_street_name, 0, 0);
+ gui_internal_search(this,_("House number"),"House number",0);
}
-void
-gui_internal_search_idle_end(struct gui_priv *this)
-{
- if (this->idle) {
- event_remove_idle(this->idle);
- this->idle=NULL;
- }
- if (this->idle_cb) {
- callback_destroy(this->idle_cb);
- this->idle_cb=NULL;
- }
+void gui_internal_search_idle_end(struct gui_priv *this) {
+ if (this->idle) {
+ event_remove_idle(this->idle);
+ this->idle=NULL;
+ }
+ if (this->idle_cb) {
+ callback_destroy(this->idle_cb);
+ this->idle_cb=NULL;
+ }
}
-static int
-gui_internal_search_cmp(gconstpointer _a, gconstpointer _b)
-{
- struct widget *a=(struct widget *)_a, *b=(struct widget *)_b;
- char *sa,*sb;
- int r;
- if(!b)
- if((!a || a->type!=widget_table_row || !a->text) && (!b || b->type!=widget_table_row || !b->text))
- return 0;
- if(!a || a->type!=widget_table_row || !a->text)
- return -1;
- if(!b || b->type!=widget_table_row || !b->text)
- return 1;
- r=a->datai-b->datai;
- if(r<0)
- return -1;
- if(r>0)
- return 1;
- sa=removecase(a->text);
- sb=removecase(b->text);
- r=strcmp(sa,sb);
- dbg(lvl_debug,"%s %s %d\n",sa,sb,r);
- g_free(sa);
- g_free(sb);
- return r;
+static int gui_internal_search_cmp(gconstpointer _a, gconstpointer _b) {
+ struct widget *a=(struct widget *)_a, *b=(struct widget *)_b;
+ char *sa,*sb;
+ int r;
+ if(!b)
+ if((!a || a->type!=widget_table_row || !a->text) && (!b || b->type!=widget_table_row || !b->text))
+ return 0;
+ if(!a || a->type!=widget_table_row || !a->text)
+ return -1;
+ if(!b || b->type!=widget_table_row || !b->text)
+ return 1;
+ r=a->datai-b->datai;
+ if(r<0)
+ return -1;
+ if(r>0)
+ return 1;
+ sa=removecase(a->text);
+ sb=removecase(b->text);
+ r=strcmp(sa,sb);
+ dbg(lvl_debug,"%s %s %d",sa,sb,r);
+ g_free(sa);
+ g_free(sb);
+ return r;
}
-static char *
-postal_str(struct search_list_result *res, int level)
-{
- char *ret=NULL;
- if (res->town->common.postal)
- ret=res->town->common.postal;
- if (res->town->common.postal_mask)
- ret=res->town->common.postal_mask;
- if (level == 1)
- return ret;
- if (res->street->common.postal)
- ret=res->street->common.postal;
- if (res->street->common.postal_mask)
- ret=res->street->common.postal_mask;
- if (level == 2)
- return ret;
- if (res->house_number->common.postal)
- ret=res->house_number->common.postal;
- if (res->house_number->common.postal_mask)
- ret=res->house_number->common.postal_mask;
- return ret;
+static char *postal_str(struct search_list_result *res, int level) {
+ char *ret=NULL;
+ if (res->town->common.postal)
+ ret=res->town->common.postal;
+ if (res->town->common.postal_mask)
+ ret=res->town->common.postal_mask;
+ if (level == 1)
+ return ret;
+ if (res->street->common.postal)
+ ret=res->street->common.postal;
+ if (res->street->common.postal_mask)
+ ret=res->street->common.postal_mask;
+ if (level == 2)
+ return ret;
+ if (res->house_number->common.postal)
+ ret=res->house_number->common.postal;
+ if (res->house_number->common.postal_mask)
+ ret=res->house_number->common.postal_mask;
+ return ret;
}
-static char *
-get_string_from_attr_list(struct attr **attrs, enum attr_type type, char *dflt)
-{
- struct attr attr;
- if(attr_generic_get_attr(attrs,NULL,type,&attr,NULL))
- return attr.u.str;
- else
- return dflt;
+static char *get_string_from_attr_list(struct attr **attrs, enum attr_type type, char *dflt) {
+ struct attr attr;
+ if(attr_generic_get_attr(attrs,NULL,type,&attr,NULL))
+ return attr.u.str;
+ else
+ return dflt;
}
-static char *
-district_str(struct search_list_result *res, int level, enum attr_type district, char *dflt)
-{
- char *ret=dflt;
+static char *district_str(struct search_list_result *res, int level, enum attr_type district, char *dflt) {
+ char *ret=dflt;
- ret=get_string_from_attr_list(res->town->common.attrs, district, ret);
- if (level == 1)
- return ret;
+ ret=get_string_from_attr_list(res->town->common.attrs, district, ret);
+ if (level == 1)
+ return ret;
- ret=get_string_from_attr_list(res->street->common.attrs, district, ret);
+ ret=get_string_from_attr_list(res->street->common.attrs, district, ret);
- if (level == 2)
- return ret;
+ if (level == 2)
+ return ret;
- ret=get_string_from_attr_list(res->house_number->common.attrs, district, ret);
-
- return ret;
+ ret=get_string_from_attr_list(res->house_number->common.attrs, district, ret);
+
+ return ret;
}
-static char *
-town_display_label(struct search_list_result *res, int level, int flags)
-{
- char *town=district_str(res, level,attr_town_name,"");
- char *district=district_str(res, level,attr_district_name,NULL);
- char *postal=postal_str(res, level);
- char *postal_sep=" ";
- char *district_begin=" (";
- char *district_end=")";
- char *county_sep = ", ";
- char *county = res->town->common.county_name;
-
- if (!postal)
- postal_sep=postal="";
- if (!district || (flags & 1))
- district_begin=district_end=district="";
- if (!county || !strcmp(county, town))
- county_sep=county="";
-
- if(level==1 ) {
- if(flags & 2) {
- int n=0;
- char *s[10]={NULL};
-
- s[n]=district_str(res, level, attr_state_name, NULL);
- if(s[n])
- n++;
- s[n]=district_str(res, level, attr_county_name, NULL);
- if(s[n])
- n++;
- s[n]=district_str(res, level, attr_municipality_name, NULL);
- if(s[n])
- n++;
-
- return g_strjoinv(", ",s);
- }
- county=county_sep="";
- }
-
- return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep, county);
+static char *town_display_label(struct search_list_result *res, int level, int flags) {
+ char *town=district_str(res, level,attr_town_name,"");
+ char *district=district_str(res, level,attr_district_name,NULL);
+ char *postal=postal_str(res, level);
+ char *postal_sep=" ";
+ char *district_begin=" (";
+ char *district_end=")";
+ char *county_sep = ", ";
+ char *county = res->town->common.county_name;
+
+ if (!postal)
+ postal_sep=postal="";
+ if (!district || (flags & 1))
+ district_begin=district_end=district="";
+ if (!county || !strcmp(county, town))
+ county_sep=county="";
+
+ if(level==1 ) {
+ if(flags & 2) {
+ int n=0;
+ char *s[10]= {NULL};
+
+ s[n]=district_str(res, level, attr_state_name, NULL);
+ if(s[n])
+ n++;
+ s[n]=district_str(res, level, attr_county_name, NULL);
+ if(s[n])
+ n++;
+ s[n]=district_str(res, level, attr_municipality_name, NULL);
+ if(s[n])
+ n++;
+
+ return g_strjoinv(", ",s);
+ }
+ county=county_sep="";
+ }
+
+ return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep,
+ county);
}
-static void
-gui_internal_find_next_possible_key(char *search_text, char *wm_name, char *possible_keys, char *item_name)
-{
- gchar* trunk_name;
- if (item_name) {
-
- trunk_name = linguistics_expand_special(item_name,1);
- if(!trunk_name){
- trunk_name = g_strrstr(item_name, search_text);
- }
-
- if (trunk_name) {
- int next_char_pos = strlen(search_text);
- char next_char = trunk_name[next_char_pos];
- int i;
- int len = strlen(possible_keys);
-
- for(i = 0; (i<len) && (possible_keys[i] != next_char) ;i++) ;
-
- if ((i==len || !len) && !strncmp(trunk_name, search_text, next_char_pos)) {
- possible_keys[len]=trunk_name[next_char_pos];
- possible_keys[len+1]='\0';
- }
- dbg(lvl_info,"searching for %s, found: %s, currently possible_keys: %s \n", search_text, item_name, possible_keys);
- }
- }
+static void gui_internal_find_next_possible_key(char *search_text, char *wm_name, char *possible_keys,
+ char *item_name) {
+ gchar* trunk_name;
+ if (item_name) {
+
+ trunk_name = linguistics_expand_special(item_name,1);
+ if(!trunk_name) {
+ trunk_name = g_strrstr(item_name, search_text);
+ }
+
+ if (trunk_name) {
+ int next_char_pos = strlen(search_text);
+ char next_char = trunk_name[next_char_pos];
+ int i;
+ int len = strlen(possible_keys);
+
+ for(i = 0; (i<len) && (possible_keys[i] != next_char) ; i++) ;
+
+ if ((i==len || !len) && !strncmp(trunk_name, search_text, next_char_pos)) {
+ possible_keys[len]=trunk_name[next_char_pos];
+ possible_keys[len+1]='\0';
+ }
+ dbg(lvl_info,"searching for %s, found: %s, currently possible_keys: %s ", search_text, item_name, possible_keys);
+ }
+ }
}
-static void
-gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys)
-{
- struct menu_data *md;
- int first_available_key_found = 0;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
- if (md && md->keyboard && !(this->flags & 2048)) {
- GList *lk=md->keyboard->children;
- graphics_draw_mode(this->gra, draw_mode_begin);
- while (lk) {
- struct widget *child=lk->data;
- GList *lk2=child->children;
- while (lk2) {
- struct widget *child_=lk2->data;
- lk2=g_list_next(lk2);
- // The data_free part is an evil hack based on the observation that
- // regular keys have set it to non-NULL whereas special keys appear
- // to have it set to NULL.
- if (child_->data && strcmp("\b", child_->data) && child_->data_free) {
- if ( (strlen(possible_keys) == 0) ||
- (g_strrstr(possible_keys, child_->data)!=NULL ) ) {
- if(this->hide_keys){
- child_->state|= STATE_SENSITIVE|STATE_CLEAR ;
- child_->state&= ~(STATE_INVISIBLE);
- }else{
- child_->state|= STATE_SENSITIVE|STATE_CLEAR|STATE_HIGHLIGHTED ;
- }
- // Select and highlight the first possible button.
- if (!first_available_key_found) {
- gui_internal_highlight_do(this, child_);
- first_available_key_found=1;
- }
- } else {
- if(this->hide_keys){
- child_->state&= ~(STATE_SELECTED|STATE_SENSITIVE) ;
- child_->state|= STATE_INVISIBLE;
- }else{
- child_->state&= ~(STATE_HIGHLIGHTED);
- }
- }
- gui_internal_widget_render(this,child_);
- }
- }
- lk=g_list_next(lk);
- }
- gui_internal_widget_render(this,md->keyboard);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
+static void gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys) {
+ struct menu_data *md;
+ int first_available_key_found = 0;
+
+ if (!this->keyboard)
+ return;
+
+ md=gui_internal_menu_data(this);
+ if (md && md->keyboard && !(this->flags & 2048)) {
+ GList *lk=md->keyboard->children;
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ while (lk) {
+ struct widget *child=lk->data;
+ GList *lk2=child->children;
+ while (lk2) {
+ struct widget *child_=lk2->data;
+ lk2=g_list_next(lk2);
+ // The data_free part is an evil hack based on the observation that
+ // regular keys have set it to non-NULL whereas special keys appear
+ // to have it set to NULL.
+ if (child_->data && strcmp("\b", child_->data) && child_->data_free) {
+ if ( (strlen(possible_keys) == 0) ||
+ (g_strrstr(possible_keys, child_->data)!=NULL ) ) {
+ if(this->hide_keys) {
+ child_->state|= STATE_SENSITIVE|STATE_CLEAR ;
+ child_->state&= ~(STATE_INVISIBLE);
+ } else {
+ child_->state|= STATE_SENSITIVE|STATE_CLEAR|STATE_HIGHLIGHTED ;
+ }
+ // Select and highlight the first possible button.
+ if (!first_available_key_found) {
+ gui_internal_highlight_do(this, child_);
+ first_available_key_found=1;
+ }
+ } else {
+ if(this->hide_keys) {
+ child_->state&= ~(STATE_SELECTED|STATE_SENSITIVE) ;
+ child_->state|= STATE_INVISIBLE;
+ } else {
+ child_->state&= ~(STATE_HIGHLIGHTED);
+ }
+ }
+ gui_internal_widget_render(this,child_);
+ }
+ }
+ lk=g_list_next(lk);
+ }
+ gui_internal_widget_render(this,md->keyboard);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ }
}
-static int
-gui_internal_get_match_quality(char *item_name, char* search_text, int is_house_number_without_street)
-{
- enum match_quality {
- full_string_match, word_match, substring_match, housenum_but_no_street_match }
- match_quality;
- if (is_house_number_without_street) {
- match_quality=housenum_but_no_street_match;
- } else if(item_name) {
- int i;
- char *folded_name=linguistics_casefold(item_name);
- char *folded_query=linguistics_casefold(search_text);
- match_quality=substring_match;
-
- for(i=0; i<3 ;i++) {
- char *exp=linguistics_expand_special(folded_name,i);
- char *p;
- if(!exp)
- continue;
- if(!strcmp(exp,folded_query)) {
- dbg(lvl_debug,"exact match for the whole string %s\n", exp);
- match_quality=full_string_match;
- g_free(exp);
- break;
- }
- if((p=strstr(exp,folded_query))!=NULL) {
- p+=strlen(folded_query);
- if(!*p||strchr(LINGUISTICS_WORD_SEPARATORS_ASCII,*p)) {
- dbg(lvl_debug,"exact matching word found inside string %s\n",exp);
- match_quality=word_match;
- }
- }
- g_free(exp);
- }
- g_free(folded_name);
- g_free(folded_query);
- }
- return match_quality;
+static int gui_internal_get_match_quality(char *item_name, char* search_text, int is_house_number_without_street) {
+ enum match_quality {
+ full_string_match, word_match, substring_match, housenum_but_no_street_match
+ }
+ match_quality;
+ if (is_house_number_without_street) {
+ match_quality=housenum_but_no_street_match;
+ } else if(item_name) {
+ int i;
+ char *folded_name=linguistics_casefold(item_name);
+ char *folded_query=linguistics_casefold(search_text);
+ match_quality=substring_match;
+
+ for(i=0; i<3 ; i++) {
+ char *exp=linguistics_expand_special(folded_name,i);
+ char *p;
+ if(!exp)
+ continue;
+ if(!strcmp(exp,folded_query)) {
+ dbg(lvl_debug,"exact match for the whole string %s", exp);
+ match_quality=full_string_match;
+ g_free(exp);
+ break;
+ }
+ if((p=strstr(exp,folded_query))!=NULL) {
+ p+=strlen(folded_query);
+ if(!*p||strchr(LINGUISTICS_WORD_SEPARATORS_ASCII,*p)) {
+ dbg(lvl_debug,"exact matching word found inside string %s",exp);
+ match_quality=word_match;
+ }
+ }
+ g_free(exp);
+ }
+ g_free(folded_name);
+ g_free(folded_query);
+ }
+ return match_quality;
}
-static struct widget*
-gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_result *res, char *result_main_label, char *result_sublabel, void *param, char *widget_name, struct item *item)
-{
- struct widget *resultlist_entry;
- if(result_sublabel) {
- struct widget *entry_sublabel;
- resultlist_entry=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(resultlist_entry,
- gui_internal_image_new(this, image_new_xs(this, res->country->flag)));
- entry_sublabel=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
- gui_internal_widget_append(resultlist_entry, entry_sublabel);
- gui_internal_widget_append(entry_sublabel, gui_internal_label_new(this, result_main_label));
- gui_internal_widget_append(entry_sublabel, gui_internal_label_font_new(this, result_sublabel, 1));
- resultlist_entry->func=gui_internal_cmd_position;
- resultlist_entry->data=param;
- resultlist_entry->state |= STATE_SENSITIVE;
- resultlist_entry->speech=g_strdup(result_main_label);
- } else {
- resultlist_entry=gui_internal_button_new_with_callback(this, result_main_label,
- image_new_xs(this, res->country->flag),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, param);
- }
- resultlist_entry->name=widget_name;
- if (res->c)
- resultlist_entry->c=*res->c;
- resultlist_entry->selection_id=res->id;
- if (item)
- resultlist_entry->item=*item;
-
- return resultlist_entry;
+static struct widget* gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_result *res,
+ char *result_main_label,
+ char *result_sublabel, void *param, char *widget_name, struct item *item) {
+ struct widget *resultlist_entry;
+ if(result_sublabel) {
+ struct widget *entry_sublabel;
+ resultlist_entry=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(resultlist_entry,
+ gui_internal_image_new(this, image_new_xs(this, res->country->flag)));
+ entry_sublabel=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
+ gui_internal_widget_append(resultlist_entry, entry_sublabel);
+ gui_internal_widget_append(entry_sublabel, gui_internal_label_new(this, result_main_label));
+ gui_internal_widget_append(entry_sublabel, gui_internal_label_font_new(this, result_sublabel, 1));
+ resultlist_entry->func=gui_internal_cmd_position;
+ resultlist_entry->data=param;
+ resultlist_entry->state |= STATE_SENSITIVE;
+ resultlist_entry->speech=g_strdup(result_main_label);
+ } else {
+ resultlist_entry=gui_internal_button_new_with_callback(this, result_main_label,
+ image_new_xs(this, res->country->flag),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_position, param);
+ }
+ resultlist_entry->name=widget_name;
+ if (res->c)
+ resultlist_entry->c=*res->c;
+ resultlist_entry->selection_id=res->id;
+ if (item)
+ resultlist_entry->item=*item;
+
+ return resultlist_entry;
}
/**
@@ -348,288 +325,270 @@ gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_r
*/
char possible_keys_incremental_search[256]="";
-static void
-gui_internal_search_idle(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
-{
- char *result_main_label=NULL,*result_sublabel=NULL,*item_name=NULL, *widget_name=NULL, *search_text;
- struct search_list_result *res;
- struct item *item=NULL;
- struct widget *search_input=NULL;
- struct widget *menu, *resultlist_row, *resultlist_entry;
-
- res=search_list_get_result(this->sl);
- if (!res) {
- gui_internal_search_idle_end(this);
- gui_internal_highlight_possible_keys(this, possible_keys_incremental_search);
- return;
- }
-
- if (! strcmp(wm_name,"Country")) {
- item_name=res->country->name;
- item=&res->country->common.item;
- result_main_label=g_strdup_printf("%s", res->country->name);
- } else if (! strcmp(wm_name,"Town")) {
- item=&res->town->common.item;
- item_name=res->town->common.town_name;
- result_main_label=town_display_label(res, 1, 0);
- result_sublabel=town_display_label(res, 1, 2);
- } else if (! strcmp(wm_name,"Street")) {
- item_name=res->street->name;
- item=&res->street->common.item;
- result_main_label=g_strdup(res->street->name);
- result_sublabel=town_display_label(res, 2, 1);
- } else if (! strcmp(wm_name,"House number")) {
- item_name=res->house_number->house_number;
- result_main_label=g_strdup_printf("%s, %s", item_name, res->street->name);
- result_sublabel=town_display_label(res, 3, 0);
- widget_name=g_strdup(result_main_label);
- }
- if(!item_name) {
- dbg(lvl_error, "Skipping nameless item in search (search type: %s). Please report this as a bug.\n", wm_name);
- return;
- }
-
- if(!widget_name)
- widget_name=g_strdup(item_name);
-
- menu=g_list_last(this->root.children)->data;
- search_input=gui_internal_find_widget(menu, NULL, STATE_EDIT);
- dbg_assert(search_input);
- search_text=search_input->text;
-
- gui_internal_find_next_possible_key(search_text, wm_name, possible_keys_incremental_search, item_name);
-
- resultlist_row=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill);
- if (!result_sublabel)
- resultlist_row->text=g_strdup(result_main_label);
- else
- resultlist_row->text=g_strdup_printf("%s %s",item_name,result_sublabel);
- int is_house_number_without_street=!strcmp(wm_name,"House number") && !res->street->name;
- resultlist_row->datai=gui_internal_get_match_quality(item_name, search_text, is_house_number_without_street);
- gui_internal_widget_insert_sorted(search_list, resultlist_row, gui_internal_search_cmp);
-
- resultlist_entry=gui_internal_create_resultlist_entry(
- this, res, result_main_label, result_sublabel, param, widget_name, item);
- gui_internal_widget_append(resultlist_row, resultlist_entry);
- gui_internal_widget_pack(this, search_list);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this, menu);
- graphics_draw_mode(this->gra, draw_mode_end);
-
- g_free(result_main_label);
- g_free(result_sublabel);
+static void gui_internal_search_idle(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param) {
+ char *result_main_label=NULL,*result_sublabel=NULL,*item_name=NULL, *widget_name=NULL, *search_text;
+ struct search_list_result *res;
+ struct item *item=NULL;
+ struct widget *search_input=NULL;
+ struct widget *menu, *resultlist_row, *resultlist_entry;
+
+ res=search_list_get_result(this->sl);
+ if (!res) {
+ gui_internal_search_idle_end(this);
+ gui_internal_highlight_possible_keys(this, possible_keys_incremental_search);
+ return;
+ }
+
+ if (! strcmp(wm_name,"Country")) {
+ item_name=res->country->name;
+ item=&res->country->common.item;
+ result_main_label=g_strdup_printf("%s", res->country->name);
+ } else if (! strcmp(wm_name,"Town")) {
+ item=&res->town->common.item;
+ item_name=res->town->common.town_name;
+ result_main_label=town_display_label(res, 1, 0);
+ result_sublabel=town_display_label(res, 1, 2);
+ } else if (! strcmp(wm_name,"Street")) {
+ item_name=res->street->name;
+ item=&res->street->common.item;
+ result_main_label=g_strdup(res->street->name);
+ result_sublabel=town_display_label(res, 2, 1);
+ } else if (! strcmp(wm_name,"House number")) {
+ item_name=res->house_number->house_number;
+ result_main_label=g_strdup_printf("%s, %s", item_name, res->street->name);
+ result_sublabel=town_display_label(res, 3, 0);
+ widget_name=g_strdup(result_main_label);
+ }
+ if(!item_name) {
+ dbg(lvl_error, "Skipping nameless item in search (search type: %s). Please report this as a bug.", wm_name);
+ return;
+ }
+
+ if(!widget_name)
+ widget_name=g_strdup(item_name);
+
+ menu=g_list_last(this->root.children)->data;
+ search_input=gui_internal_find_widget(menu, NULL, STATE_EDIT);
+ dbg_assert(search_input);
+ search_text=search_input->text;
+
+ gui_internal_find_next_possible_key(search_text, wm_name, possible_keys_incremental_search, item_name);
+
+ resultlist_row=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill);
+ if (!result_sublabel)
+ resultlist_row->text=g_strdup(result_main_label);
+ else
+ resultlist_row->text=g_strdup_printf("%s %s",item_name,result_sublabel);
+ int is_house_number_without_street=!strcmp(wm_name,"House number") && !res->street->name;
+ resultlist_row->datai=gui_internal_get_match_quality(item_name, search_text, is_house_number_without_street);
+ gui_internal_widget_insert_sorted(search_list, resultlist_row, gui_internal_search_cmp);
+
+ resultlist_entry=gui_internal_create_resultlist_entry(
+ this, res, result_main_label, result_sublabel, param, widget_name, item);
+ gui_internal_widget_append(resultlist_row, resultlist_entry);
+ gui_internal_widget_pack(this, search_list);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_widget_render(this, menu);
+ graphics_draw_mode(this->gra, draw_mode_end);
+
+ g_free(result_main_label);
+ g_free(result_sublabel);
}
-static void
-gui_internal_search_idle_start(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
-{
- this->idle_cb=callback_new_4(callback_cast(gui_internal_search_idle), this, wm_name, search_list, param);
- this->idle=event_add_idle(50,this->idle_cb);
- callback_call_0(this->idle_cb);
+static void gui_internal_search_idle_start(struct gui_priv *this, char *wm_name, struct widget *search_list,
+ void *param) {
+ this->idle_cb=callback_new_4(callback_cast(gui_internal_search_idle), this, wm_name, search_list, param);
+ this->idle=event_add_idle(50,this->idle_cb);
+ callback_call_0(this->idle_cb);
}
-static void
-gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data)
-{
- GList *l;
- struct widget *search_list=gui_internal_menu_data(this)->search_list;
- void *param=(void *)3;
-
- gui_internal_widget_table_clear(this, search_list);
- possible_keys_incremental_search[0]='\0';
-
- if (! strcmp(wm->name,"Country"))
- param=(void *)4;
- if (! strcmp(wm->name,"Street"))
- param=(void *)5;
- if (! strcmp(wm->name,"House number"))
- param=(void *)6;
- dbg(lvl_debug,"%s now '%s'\n", wm->name, wm->text);
-
- gui_internal_search_idle_end(this);
- if (wm->text && g_utf8_strlen(wm->text, -1) > 0) {
- struct attr search_attr;
-
- dbg(lvl_debug,"process\n");
- if (! strcmp(wm->name,"Country"))
- search_attr.type=attr_country_all;
- if (! strcmp(wm->name,"Town"))
- search_attr.type=attr_town_or_district_name;
- if (! strcmp(wm->name,"Street"))
- search_attr.type=attr_street_name;
- if (! strcmp(wm->name,"House number"))
- search_attr.type=attr_house_number;
- search_attr.u.str=wm->text;
- search_list_search(this->sl, &search_attr, 1);
- gui_internal_search_idle_start(this, wm->name, search_list, param);
- } else {
- // If not enough content is entered, we highlight all keys.
- gui_internal_highlight_possible_keys(this, "");
- }
- l=g_list_last(this->root.children);
- gui_internal_widget_render(this, l->data);
+static void gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data) {
+ GList *l;
+ struct widget *search_list=gui_internal_menu_data(this)->search_list;
+ void *param=(void *)3;
+
+ gui_internal_widget_table_clear(this, search_list);
+ possible_keys_incremental_search[0]='\0';
+
+ if (! strcmp(wm->name,"Country"))
+ param=(void *)4;
+ if (! strcmp(wm->name,"Street"))
+ param=(void *)5;
+ if (! strcmp(wm->name,"House number"))
+ param=(void *)6;
+ dbg(lvl_debug,"%s now '%s'", wm->name, wm->text);
+
+ gui_internal_search_idle_end(this);
+ if (wm->text && g_utf8_strlen(wm->text, -1) > 0) {
+ struct attr search_attr;
+
+ dbg(lvl_debug,"process");
+ if (! strcmp(wm->name,"Country"))
+ search_attr.type=attr_country_all;
+ if (! strcmp(wm->name,"Town"))
+ search_attr.type=attr_town_or_district_name;
+ if (! strcmp(wm->name,"Street"))
+ search_attr.type=attr_street_name;
+ if (! strcmp(wm->name,"House number"))
+ search_attr.type=attr_house_number;
+ search_attr.u.str=wm->text;
+ search_list_search(this->sl, &search_attr, 1);
+ gui_internal_search_idle_start(this, wm->name, search_list, param);
+ } else {
+ // If not enough content is entered, we highlight all keys.
+ gui_internal_highlight_possible_keys(this, "");
+ }
+ l=g_list_last(this->root.children);
+ gui_internal_widget_render(this, l->data);
}
-static void
-gui_internal_search_list_set_default_country(struct gui_priv *this)
-{
- struct attr search_attr, country_name, country_iso2, *country_attr;
- struct item *item;
- struct country_search *cs;
- struct tracking *tracking;
- struct search_list_result *res;
-
- country_attr=country_default();
- tracking=navit_get_tracking(this->nav);
- if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
- country_attr=&search_attr;
- if (country_attr) {
- cs=country_search_new(country_attr, 0);
- item=country_search_get_item(cs);
- if (item && item_attr_get(item, attr_country_name, &country_name)) {
- search_attr.type=attr_country_all;
- dbg(lvl_debug,"country %s\n", country_name.u.str);
- search_attr.u.str=country_name.u.str;
- search_list_search(this->sl, &search_attr, 0);
- while((res=search_list_get_result(this->sl)));
- if(this->country_iso2) {
- g_free(this->country_iso2);
- this->country_iso2=NULL;
- }
- if (item_attr_get(item, attr_country_iso2, &country_iso2))
- this->country_iso2=g_strdup(country_iso2.u.str);
- }
- country_search_destroy(cs);
- } else {
- dbg(lvl_error,"warning: no default country found\n");
- if (this->country_iso2) {
- dbg(lvl_debug,"attempting to use country '%s'\n",this->country_iso2);
- search_attr.type=attr_country_iso2;
- search_attr.u.str=this->country_iso2;
+static void gui_internal_search_list_set_default_country(struct gui_priv *this) {
+ struct attr search_attr, country_name, country_iso2, *country_attr;
+ struct item *item;
+ struct country_search *cs;
+ struct tracking *tracking;
+ struct search_list_result *res;
+
+ country_attr=country_default();
+ tracking=navit_get_tracking(this->nav);
+ if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
+ country_attr=&search_attr;
+ if (country_attr) {
+ cs=country_search_new(country_attr, 0);
+ item=country_search_get_item(cs);
+ if (item && item_attr_get(item, attr_country_name, &country_name)) {
+ search_attr.type=attr_country_all;
+ dbg(lvl_debug,"country %s", country_name.u.str);
+ search_attr.u.str=country_name.u.str;
+ search_list_search(this->sl, &search_attr, 0);
+ while((res=search_list_get_result(this->sl)));
+ if(this->country_iso2) {
+ g_free(this->country_iso2);
+ this->country_iso2=NULL;
+ }
+ if (item_attr_get(item, attr_country_iso2, &country_iso2))
+ this->country_iso2=g_strdup(country_iso2.u.str);
+ }
+ country_search_destroy(cs);
+ } else {
+ dbg(lvl_error,"warning: no default country found");
+ if (this->country_iso2) {
+ dbg(lvl_debug,"attempting to use country '%s'",this->country_iso2);
+ search_attr.type=attr_country_iso2;
+ search_attr.u.str=this->country_iso2;
search_list_search(this->sl, &search_attr, 0);
while((res=search_list_get_result(this->sl)));
- }
- }
+ }
+ }
}
-static void
-gui_internal_search_list_new(struct gui_priv *this)
-{
- struct mapset *ms=navit_get_mapset(this->nav);
- if (! this->sl) {
- this->sl=search_list_new(ms);
- gui_internal_search_list_set_default_country(this);
- }
+static void gui_internal_search_list_new(struct gui_priv *this) {
+ struct mapset *ms=navit_get_mapset(this->nav);
+ if (! this->sl) {
+ this->sl=search_list_new(ms);
+ gui_internal_search_list_set_default_country(this);
+ }
}
-void
-gui_internal_search_list_destroy(struct gui_priv *this)
-{
- if (this->sl) {
- search_list_destroy(this->sl);
- this->sl=NULL;
- }
+void gui_internal_search_list_destroy(struct gui_priv *this) {
+ if (this->sl) {
+ search_list_destroy(this->sl);
+ this->sl=NULL;
+ }
}
-void
-gui_internal_search(struct gui_priv *this, const char *what, const char *type, int flags)
-{
- struct widget *wb,*wk,*w,*wr,*we,*wl,*wnext=NULL;
- char *country;
- int keyboard_mode;
- gui_internal_search_list_new(this);
- keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(this->country_iso2 ? this->country_iso2 : getenv("LANG"));
- wb=gui_internal_menu(this, what);
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
- if (!strcmp(type,"Country")) {
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_town"));
- wnext->func=gui_internal_search_town;
- } else if (!strcmp(type,"Town")) {
- if (this->country_iso2) {
+void gui_internal_search(struct gui_priv *this, const char *what, const char *type, int flags) {
+ struct widget *wb,*wk,*w,*wr,*we,*wl,*wnext=NULL;
+ char *country;
+ int keyboard_mode;
+ gui_internal_search_list_new(this);
+ keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(this->country_iso2 ? this->country_iso2 : getenv("LANG"));
+ wb=gui_internal_menu(this, what);
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wr);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, we);
+ if (!strcmp(type,"Country")) {
+ wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_town"));
+ wnext->func=gui_internal_search_town;
+ } else if (!strcmp(type,"Town")) {
+ if (this->country_iso2) {
#ifdef HAVE_API_ANDROID
- char country_iso2[strlen(this->country_iso2)+1];
- strtolower(country_iso2, this->country_iso2);
- country=g_strdup_printf("country_%s", country_iso2);
+ char country_iso2[strlen(this->country_iso2)+1];
+ strtolower(country_iso2, this->country_iso2);
+ country=g_strdup_printf("country_%s", country_iso2);
#else
- country=g_strdup_printf("country_%s", this->country_iso2);
+ country=g_strdup_printf("country_%s", this->country_iso2);
#endif
- } else
- country=g_strdup("gui_select_country");
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, country)));
- wb->state |= STATE_SENSITIVE;
- if (flags)
- wb->func = gui_internal_search_country;
- else
- wb->func = gui_internal_back;
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_street"));
- wnext->func=gui_internal_search_street;
- g_free(country);
- } else if (!strcmp(type,"Street")) {
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_town")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_back;
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_house_number"));
- wnext->func=gui_internal_search_house_number;
- } else if (!strcmp(type,"House number")) {
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_street")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_back;
- keyboard_mode = VKBD_NUMERIC | VKBD_FLAG_2;
- }
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
- if (wnext) {
- gui_internal_widget_append(we, wnext);
- wnext->state |= STATE_SENSITIVE;
- }
- wl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);//gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wr, wl);
- gui_internal_menu_data(this)->search_list=wl;
- wk->state |= STATE_EDIT|STATE_EDITABLE;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_search_changed;
- wk->name=g_strdup(type);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
- else
- gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
- gui_internal_menu_render(this);
+ } else
+ country=g_strdup("gui_select_country");
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, country)));
+ wb->state |= STATE_SENSITIVE;
+ if (flags)
+ wb->func = gui_internal_search_country;
+ else
+ wb->func = gui_internal_back;
+ wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_street"));
+ wnext->func=gui_internal_search_street;
+ g_free(country);
+ } else if (!strcmp(type,"Street")) {
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_town")));
+ wb->state |= STATE_SENSITIVE;
+ wb->func = gui_internal_back;
+ wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_house_number"));
+ wnext->func=gui_internal_search_house_number;
+ } else if (!strcmp(type,"House number")) {
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_street")));
+ wb->state |= STATE_SENSITIVE;
+ wb->func = gui_internal_back;
+ keyboard_mode = VKBD_NUMERIC | VKBD_FLAG_2;
+ }
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
+ if (wnext) {
+ gui_internal_widget_append(we, wnext);
+ wnext->state |= STATE_SENSITIVE;
+ }
+ wl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,
+ 1);//gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wr, wl);
+ gui_internal_menu_data(this)->search_list=wl;
+ wk->state |= STATE_EDIT|STATE_EDITABLE;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_search_changed;
+ wk->name=g_strdup(type);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
+ else
+ gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_street_name, 0, 0);
- search_list_select(this->sl, attr_street_name, widget->selection_id, 1);
- gui_internal_search(this,_("House number"),"House number",0);
+void gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data) {
+ dbg(lvl_info,"id %d", widget->selection_id);
+ search_list_select(this->sl, attr_street_name, 0, 0);
+ search_list_select(this->sl, attr_street_name, widget->selection_id, 1);
+ gui_internal_search(this,_("House number"),"House number",0);
}
-void
-gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_town_or_district_name, 0, 0);
- search_list_select(this->sl, attr_town_or_district_name, widget->selection_id, 1);
- gui_internal_search(this,_("Street"),"Street",0);
+void gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data) {
+ dbg(lvl_info,"id %d", widget->selection_id);
+ search_list_select(this->sl, attr_town_or_district_name, 0, 0);
+ search_list_select(this->sl, attr_town_or_district_name, widget->selection_id, 1);
+ gui_internal_search(this,_("Street"),"Street",0);
}
-void
-gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget)
-{
- struct search_list_common *slc;
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_country_all, 0, 0);
- slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
- if (slc) {
- g_free(this->country_iso2);
- this->country_iso2=g_strdup(((struct search_list_country *)slc)->iso2);
- }
- gui_internal_search(this,widget->name,"Town",0);
+void gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget) {
+ struct search_list_common *slc;
+ dbg(lvl_info,"id %d", widget->selection_id);
+ search_list_select(this->sl, attr_country_all, 0, 0);
+ slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
+ if (slc) {
+ g_free(this->country_iso2);
+ this->country_iso2=g_strdup(((struct search_list_country *)slc)->iso2);
+ }
+ gui_internal_search(this,widget->name,"Town",0);
}
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
index 3e1993025..3b979f011 100644
--- a/navit/gui/internal/gui_internal_widget.c
+++ b/navit/gui/internal/gui_internal_widget.c
@@ -12,135 +12,188 @@
#include "gui_internal_menu.h"
static void gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb);
+void gui_internal_box_pack(struct gui_priv *this, struct widget *w);
-static void
-gui_internal_background_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt=w->p;
- if (w->state & STATE_HIGHLIGHTED)
- graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
- else {
- if (w->background)
- graphics_draw_rectangle(this->gra, w->background, &pnt, w->w, w->h);
- }
+/**
+ * @brief Transfer the content of one widget into another one (and optionally vice-versa)
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] first The first widget
+ * @param[in,out] second The second widget
+ * @param move_only If non nul, transfer only the second widget into the first widget. The second widget is then deallocated and should be be used anymore (this is a move operation)
+ */
+static void gui_internal_widget_transfer_content(struct gui_priv *this, struct widget *first, struct widget *second,
+ int move_only) {
+ struct widget *temp;
+
+ if (!first) {
+ dbg(lvl_error, "Refusing copy: first argument is NULL");
+ return;
+ }
+ if (!second) {
+ dbg(lvl_error, "Refusing copy: second argument is NULL");
+ return;
+ }
+ temp=g_new0(struct widget, 1);
+ memcpy(temp, first, sizeof(struct widget));
+ memcpy(first, second, sizeof(struct widget));
+ if (move_only) {
+ gui_internal_widget_destroy(this, temp);
+ /* gui_internal_widget_destroy() will do a g_free(temp), but will also deallocate all children widgets */
+ /* Now, we also free the struct widget pointed to by second, so variable second should not be used anymore from this point */
+ g_free(second);
+ } else {
+ memcpy(second, temp, sizeof(struct widget));
+ g_free(temp);
+ }
+}
+
+/**
+ * @brief Swap two widgets
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] first The first widget
+ * @param[in,out] second The second widget
+ */
+void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second) {
+ gui_internal_widget_transfer_content(this, first, second, 0);
+}
+
+/**
+ * @brief Move the content of one widget into another one (the @p src widget is then deallocated and should be be used anymore)
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] dst The destination widget
+ * @param[in,out] src The source widget
+ */
+void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src) {
+ gui_internal_widget_transfer_content(this, dst, src, 1);
+}
+
+static void gui_internal_background_render(struct gui_priv *this, struct widget *w) {
+ struct point pnt=w->p;
+ if (w->state & STATE_HIGHLIGHTED)
+ graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
+ else {
+ if (w->background)
+ graphics_draw_rectangle(this->gra, w->background, &pnt, w->w, w->h);
+ }
}
struct widget *
-gui_internal_label_font_new(struct gui_priv *this, const char *text, int font)
-{
- struct point p[4];
- int w=0;
- int h=0;
-
- struct widget *widget=g_new0(struct widget, 1);
- widget->type=widget_label;
- widget->font_idx=font;
- if (text) {
- widget->text=g_strdup(text);
- graphics_get_text_bbox(this->gra, this->fonts[font], widget->text, 0x10000, 0x0, p, 0);
- w=p[2].x-p[0].x;
- h=p[0].y-p[2].y;
- }
- widget->h=h+this->spacing;
- widget->texth=h;
- widget->w=w+this->spacing;
- widget->textw=w;
- widget->flags=gravity_center;
- widget->foreground=this->text_foreground;
- widget->text_background=this->text_background;
-
- return widget;
+gui_internal_label_font_new(struct gui_priv *this, const char *text, int font) {
+ struct point p[4];
+ int w=0;
+ int h=0;
+
+ struct widget *widget=g_new0(struct widget, 1);
+ widget->type=widget_label;
+ widget->font_idx=font;
+ if (text) {
+ widget->text=g_strdup(text);
+ graphics_get_text_bbox(this->gra, this->fonts[font], widget->text, 0x10000, 0x0, p, 0);
+ w=p[2].x-p[0].x;
+ h=p[0].y-p[2].y;
+ }
+ widget->h=h+this->spacing;
+ widget->texth=h;
+ widget->w=w+this->spacing;
+ widget->textw=w;
+ widget->flags=gravity_center;
+ widget->foreground=this->text_foreground;
+ widget->text_background=this->text_background;
+
+ return widget;
}
-
+
struct widget *
-gui_internal_label_new(struct gui_priv *this, const char *text)
-{
- return gui_internal_label_font_new(this, text, 0);
+gui_internal_label_new(struct gui_priv *this, const char *text) {
+ return gui_internal_label_font_new(this, text, 0);
}
struct widget *
-gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth)
-{
- struct widget *ret=NULL;
- char *tmp=g_malloc(strlen(text)+3);
- const char *p;
- p=text+strlen(text);
- while ((p=g_utf8_find_prev_char(text, p)) >= text) {
- int i=p-text;
- strcpy(tmp, text);
- strcpy(tmp+i,"..");
- ret=gui_internal_label_new(this, tmp);
- if (ret->w < maxwidth)
- break;
- gui_internal_widget_destroy(this, ret);
- ret=NULL;
- }
- if(!ret)
- ret=gui_internal_label_new(this, "");
- g_free(tmp);
- return ret;
+gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth) {
+ struct widget *ret=NULL;
+ char *tmp=g_malloc(strlen(text)+3);
+ const char *p;
+ p=text+strlen(text);
+ while ((p=g_utf8_find_prev_char(text, p)) >= text) {
+ int i=p-text;
+ strcpy(tmp, text);
+ strcpy(tmp+i,"..");
+ ret=gui_internal_label_new(this, tmp);
+ if (ret->w < maxwidth)
+ break;
+ gui_internal_widget_destroy(this, ret);
+ ret=NULL;
+ }
+ if(!ret)
+ ret=gui_internal_label_new(this, "");
+ g_free(tmp);
+ return ret;
}
struct widget *
-gui_internal_image_new(struct gui_priv *this, struct graphics_image *image)
-{
- struct widget *widget=g_new0(struct widget, 1);
- widget->type=widget_image;
- widget->img=image;
- if (image) {
- widget->w=image->width;
- widget->h=image->height;
- }
- return widget;
+gui_internal_image_new(struct gui_priv *this, struct graphics_image *image) {
+ struct widget *widget=g_new0(struct widget, 1);
+ widget->type=widget_image;
+ widget->img=image;
+ if (image) {
+ widget->w=image->width;
+ widget->h=image->height;
+ }
+ return widget;
}
-static void
-gui_internal_image_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt;
-
- gui_internal_background_render(this, w);
- if (w->img) {
- pnt=w->p;
- pnt.x+=w->w/2-w->img->hot.x;
- pnt.y+=w->h/2-w->img->hot.y;
- graphics_draw_image(this->gra, this->foreground, &pnt, w->img);
- }
+/**
+ * @brief Renders an image or icon, preparing it for drawing on the display
+ *
+ * @param this The internal GUI instance
+ * @param w The widget to render
+ */
+static void gui_internal_image_render(struct gui_priv *this, struct widget *w) {
+ struct point pnt;
+
+ gui_internal_background_render(this, w);
+ if (w->img) {
+ pnt=w->p;
+ pnt.x+=w->w/2-w->img->hot.x;
+ pnt.y+=w->h/2-w->img->hot.y;
+ graphics_draw_image(this->gra, this->foreground, &pnt, w->img);
+ }
}
/**
- * @brief Renders a label.
+ * @brief Renders a label, preparing it for drawing on the display
*
* @param this The internal GUI instance
* @param w The widget to render
*/
-static void
-gui_internal_label_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt=w->p;
- gui_internal_background_render(this, w);
- if (w->state & STATE_EDIT)
- graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
- if (w->text) {
- char *text;
- char *startext=(char*)g_alloca(strlen(w->text)+1);
- text=w->text;
- if (w->flags2 & 1) {
- int i;
- for (i = 0 ; i < strlen(text); i++)
- startext[i]='*';
- startext[i]='\0';
- text=startext;
- }
- if (w->flags & gravity_right) {
- pnt.y+=w->h-this->spacing;
- pnt.x+=w->w-w->textw-this->spacing;
- graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
- } else {
- pnt.y+=w->h-this->spacing;
- graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
- }
- }
+static void gui_internal_label_render(struct gui_priv *this, struct widget *w) {
+ struct point pnt=w->p;
+ gui_internal_background_render(this, w);
+ if (w->state & STATE_EDIT)
+ graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
+ if (w->text) {
+ char *text;
+ char *startext=(char*)g_alloca(strlen(w->text)+1);
+ text=w->text;
+ if (w->flags2 & 1) {
+ int i;
+ for (i = 0 ; i < strlen(text); i++)
+ startext[i]='*';
+ startext[i]='\0';
+ text=startext;
+ }
+ if (w->flags & gravity_right) {
+ pnt.y+=w->h-this->spacing;
+ pnt.x+=w->w-w->textw-this->spacing;
+ graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
+ } else {
+ pnt.y+=w->h-this->spacing;
+ graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
+ }
+ }
}
/**
@@ -155,487 +208,544 @@ gui_internal_label_render(struct gui_priv *this, struct widget *w)
* @param flags
*/
struct widget *
-gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags)
-{
- char *s=g_strdup(text),*s2,*tok;
- struct widget *ret=gui_internal_box_new(this, flags);
- s2=s;
- while ((tok=strtok(s2,"\n"))) {
- gui_internal_widget_append(ret, gui_internal_label_font_new(this, tok, font));
- s2=NULL;
- }
- gui_internal_widget_pack(this,ret);
- g_free(s);
- return ret;
+gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags) {
+ char *s=g_strdup(text),*s2,*tok;
+ struct widget *ret=gui_internal_box_new(this, flags);
+ s2=s;
+ while ((tok=strtok(s2,"\n"))) {
+ gui_internal_widget_append(ret, gui_internal_label_font_new(this, tok, font));
+ s2=NULL;
+ }
+ gui_internal_widget_pack(this,ret);
+ g_free(s);
+ return ret;
}
struct widget *
-gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags)
-{
- return gui_internal_text_font_new(this, text, 0, flags);
+gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags) {
+ return gui_internal_text_font_new(this, text, 0, flags);
}
struct widget *
-gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
-{
- struct widget *ret=NULL;
- ret=gui_internal_box_new(this, flags);
- if (ret) {
- if (image && !(flags & flags_swap))
- gui_internal_widget_append(ret, gui_internal_image_new(this, image));
- if (text)
- gui_internal_widget_append(ret, gui_internal_text_font_new(this, text, font, gravity_center|orientation_vertical));
- if (image && (flags & flags_swap))
- gui_internal_widget_append(ret, gui_internal_image_new(this, image));
- ret->func=func;
- ret->data=data;
- if (func) {
- ret->state |= STATE_SENSITIVE;
- ret->speech=g_strdup(text);
- }
- }
- return ret;
+gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font,
+ struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data),
+ void *data) {
+ struct widget *ret=NULL;
+ ret=gui_internal_box_new(this, flags);
+ if (ret) {
+ if (image && !(flags & flags_swap))
+ gui_internal_widget_append(ret, gui_internal_image_new(this, image));
+ if (text)
+ gui_internal_widget_append(ret, gui_internal_text_font_new(this, text, font, gravity_center|orientation_vertical));
+ if (image && (flags & flags_swap))
+ gui_internal_widget_append(ret, gui_internal_image_new(this, image));
+ ret->func=func;
+ ret->data=data;
+ if (func) {
+ ret->state |= STATE_SENSITIVE;
+ ret->speech=g_strdup(text);
+ }
+ }
+ return ret;
}
struct widget *
-gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
-{
- return gui_internal_button_font_new_with_callback(this, text, 0, image, flags, func, data);
+gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image,
+ enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data) {
+ return gui_internal_button_font_new_with_callback(this, text, 0, image, flags, func, data);
}
struct widget *
-gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags)
-{
- return gui_internal_button_new_with_callback(this, text, image, flags, NULL, NULL);
+gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags) {
+ return gui_internal_button_new_with_callback(this, text, image, flags, NULL, NULL);
}
struct widget *
-gui_internal_find_widget(struct widget *wi, struct point *p, int flags)
-{
- struct widget *ret,*child;
- GList *l=wi->children;
-
- if (p) {
- if (wi->p.x > p->x )
- return NULL;
- if (wi->p.y > p->y )
- return NULL;
- if ( wi->p.x + wi->w < p->x)
- return NULL;
- if ( wi->p.y + wi->h < p->y)
- return NULL;
- }
- if (wi->state & flags)
- return wi;
- while (l) {
- child=l->data;
- ret=gui_internal_find_widget(child, p, flags);
- if (ret) {
- return ret;
- }
- l=g_list_next(l);
- }
- return NULL;
+gui_internal_find_widget(struct widget *wi, struct point *p, int flags) {
+ struct widget *ret,*child;
+ GList *l=wi->children;
+
+ if (p) {
+ if (wi->p.x > p->x )
+ return NULL;
+ if (wi->p.y > p->y )
+ return NULL;
+ if ( wi->p.x + wi->w < p->x)
+ return NULL;
+ if ( wi->p.y + wi->h < p->y)
+ return NULL;
+ }
+ if (wi->state & flags)
+ return wi;
+ while (l) {
+ child=l->data;
+ ret=gui_internal_find_widget(child, p, flags);
+ if (ret) {
+ return ret;
+ }
+ l=g_list_next(l);
+ }
+ return NULL;
}
-void
-gui_internal_highlight_do(struct gui_priv *this, struct widget *found)
-{
- if (found == this->highlighted)
- return;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- if (this->highlighted) {
- this->highlighted->state &= ~STATE_HIGHLIGHTED;
- if (this->root.children && this->highlighted_menu == g_list_last(this->root.children)->data)
- gui_internal_widget_render(this, this->highlighted);
- this->highlighted=NULL;
- this->highlighted_menu=NULL;
- }
- if (found) {
- this->highlighted=found;
- this->highlighted_menu=g_list_last(this->root.children)->data;
- this->highlighted->state |= STATE_HIGHLIGHTED;
- gui_internal_widget_render(this, this->highlighted);
- dbg(lvl_debug,"%d,%d %dx%d\n", found->p.x, found->p.y, found->w, found->h);
- }
- graphics_draw_mode(this->gra, draw_mode_end);
+void gui_internal_highlight_do(struct gui_priv *this, struct widget *found) {
+ if (found == this->highlighted)
+ return;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ if (this->highlighted) {
+ this->highlighted->state &= ~STATE_HIGHLIGHTED;
+ if (this->root.children && this->highlighted_menu == g_list_last(this->root.children)->data)
+ gui_internal_widget_render(this, this->highlighted);
+ this->highlighted=NULL;
+ this->highlighted_menu=NULL;
+ }
+ if (found) {
+ this->highlighted=found;
+ this->highlighted_menu=g_list_last(this->root.children)->data;
+ this->highlighted->state |= STATE_HIGHLIGHTED;
+ gui_internal_widget_render(this, this->highlighted);
+ dbg(lvl_debug,"%d,%d %dx%d", found->p.x, found->p.y, found->w, found->h);
+ }
+ graphics_draw_mode(this->gra, draw_mode_end);
}
//##############################################################################################################
//# Description:
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void
-gui_internal_highlight(struct gui_priv *this)
-{
- struct widget *menu,*found=NULL;
- if (this->current.x > -1 && this->current.y > -1) {
- menu=g_list_last(this->root.children)->data;
- found=gui_internal_find_widget(menu, &this->current, STATE_SENSITIVE);
- if (!found) {
- found=gui_internal_find_widget(menu, &this->current, STATE_EDITABLE);
- if (found) {
- if (this->editable && this->editable != found) {
- this->editable->state &= ~ STATE_EDIT;
- gui_internal_widget_render(this, this->editable);
- }
- found->state |= STATE_EDIT;
- gui_internal_widget_render(this, found);
- this->editable=found;
- found=NULL;
- }
- }
- }
- gui_internal_highlight_do(this, found);
- this->motion_timeout_event=NULL;
+void gui_internal_highlight(struct gui_priv *this) {
+ struct widget *menu,*found=NULL;
+ if (this->current.x > -1 && this->current.y > -1) {
+ menu=g_list_last(this->root.children)->data;
+ found=gui_internal_find_widget(menu, &this->current, STATE_SENSITIVE);
+ if (!found) {
+ found=gui_internal_find_widget(menu, &this->current, STATE_EDITABLE);
+ if (found) {
+ if (this->editable && this->editable != found) {
+ this->editable->state &= ~ STATE_EDIT;
+ gui_internal_widget_render(this, this->editable);
+ }
+ found->state |= STATE_EDIT;
+ gui_internal_widget_render(this, found);
+ this->editable=found;
+ found=NULL;
+ }
+ }
+ }
+ gui_internal_highlight_do(this, found);
+ this->motion_timeout_event=NULL;
}
struct widget *
-gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label)
-{
- struct widget *widget=g_new0(struct widget, 1);
-
- if (label)
- widget->text=g_strdup(label);
- widget->type=widget_box;
- widget->flags=flags;
- return widget;
+gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label) {
+ struct widget *widget=g_new0(struct widget, 1);
+
+ if (label)
+ widget->text=g_strdup(label);
+ widget->type=widget_box;
+ widget->flags=flags;
+ widget->on_resize=gui_internal_box_resize;
+ return widget;
}
struct widget *
-gui_internal_box_new(struct gui_priv *this, enum flags flags)
-{
- return gui_internal_box_new_with_label(this, flags, NULL);
+gui_internal_box_new(struct gui_priv *this, enum flags flags) {
+ return gui_internal_box_new_with_label(this, flags, NULL);
}
+/**
+ * @brief Renders a box widget, preparing it for drawing on the display
+ *
+ * @param this The internal GUI instance
+ * @param w The box widget to render
+ */
+static void gui_internal_box_render(struct gui_priv *this, struct widget *w) {
+ struct widget *wc;
+ GList *l;
-static void gui_internal_box_render(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- GList *l;
-
- gui_internal_background_render(this, w);
- if (w->foreground && w->border) {
- struct point pnt[5];
- pnt[0]=w->p;
- pnt[1].x=pnt[0].x+w->w;
- pnt[1].y=pnt[0].y;
- pnt[2].x=pnt[0].x+w->w;
- pnt[2].y=pnt[0].y+w->h;
- pnt[3].x=pnt[0].x;
- pnt[3].y=pnt[0].y+w->h;
- pnt[4]=pnt[0];
- graphics_gc_set_linewidth(w->foreground, w->border ? w->border : 1);
- graphics_draw_lines(this->gra, w->foreground, pnt, 5);
- graphics_gc_set_linewidth(w->foreground, 1);
- }
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_render(this, wc);
- l=g_list_next(l);
- }
- if (w->scroll_buttons)
- gui_internal_widget_render(this, w->scroll_buttons->button_box);
-}
+ int visual_debug = 0;
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ static struct graphics_gc *debug_gc=NULL;
+ static struct color gui_box_debug_color= {0xffff,0x0400,0x0400,0xffff}; /* Red */
+ visual_debug = (debug_level_get("gui_internal_visual_layout") >= lvl_debug);
+#endif
+
+ if (visual_debug)
+ dbg(lvl_debug, "Internal layout visual debugging is enabled");
+
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ if (visual_debug && !debug_gc) {
+ debug_gc = graphics_gc_new(this->gra);
+ graphics_gc_set_foreground(debug_gc, &gui_box_debug_color);
+ graphics_gc_set_linewidth(debug_gc, 1);
+ }
+#endif
+
+ gui_internal_background_render(this, w);
+ if ((w->foreground && w->border) || visual_debug) {
+ struct point pnt[5];
+ pnt[0]=w->p;
+ pnt[1].x=pnt[0].x+w->w;
+ pnt[1].y=pnt[0].y;
+ pnt[2].x=pnt[0].x+w->w;
+ pnt[2].y=pnt[0].y+w->h;
+ pnt[3].x=pnt[0].x;
+ pnt[3].y=pnt[0].y+w->h;
+ pnt[4]=pnt[0];
+ if (!visual_debug) {
+ graphics_gc_set_linewidth(w->foreground, w->border ? w->border : 1);
+ graphics_draw_lines(this->gra, w->foreground, pnt, 5);
+ graphics_gc_set_linewidth(w->foreground, 1);
+ }
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ else
+ graphics_draw_lines(this->gra, debug_gc, pnt, 5); /* Force highlighting box borders in debug more */
+#endif
+ }
+
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_render(this, wc);
+ l=g_list_next(l);
+ }
+ if (w->scroll_buttons)
+ gui_internal_widget_render(this, w->scroll_buttons->button_box);
+}
/**
- * @brief Computes the size and location for the widget.
+ * @brief Computes the size and location for a box widget
*
* @param this The internal GUI instance
- * @param w The widget to render
+ * @param w The widget to pack
*/
-static void gui_internal_box_pack(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- int x0,x=0,y=0,width=0,height=0,owidth=0,oheight=0,expand=0,expandd=1,count=0,rows=0,cols=w->cols ? w->cols : 0;
- int hb=w->scroll_buttons?w->scroll_buttons->button_box->h:0;
- GList *l;
- int orientation=w->flags & 0xffff0000;
-
- if (!cols)
- cols=this->cols;
- if (!cols) {
- if ( this->root.w > this->root.h )
- cols=3;
- else
- cols=2;
- width=0;
- height=0;
- }
-
-
- /*
- * count the number of children
- */
- l=w->children;
- while (l) {
- count++;
- l=g_list_next(l);
- }
- if (orientation == orientation_horizontal_vertical && count <= cols)
- orientation=orientation_horizontal;
- switch (orientation) {
- case orientation_horizontal:
- /*
- * For horizontal orientation:
- * pack each child and find the largest height and
- * compute the total width. x spacing (spx) is considered
- *
- * If any children want to be expanded
- * we keep track of this
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (height < wc->h)
- height=wc->h;
- width+=wc->w;
- if (wc->flags & flags_expand)
- expand+=wc->w ? wc->w : 1;
- l=g_list_next(l);
- if (l)
- width+=w->spx;
- }
- owidth=width;
- if (expand && w->w) {
- expandd=w->w-width+expand;
- owidth=w->w;
- } else
- expandd=expand=1;
- break;
- case orientation_vertical:
- /*
- * For vertical layouts:
- * We pack each child and compute the largest width and
- * the total height. y spacing (spy) is considered
- *
- * If the expand flag is set then teh expansion amount
- * is computed.
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (width < wc->w)
- width=wc->w;
- height+=wc->h;
- if (wc->flags & flags_expand)
- expand+=wc->h ? wc->h : 1;
- l=g_list_next(l);
- if (l)
- height+=w->spy;
- }
- oheight=height;
- if (expand && w->h) {
- expandd=w->h-hb-height+expand;
- oheight=w->h-hb;
- } else
- expandd=expand=1;
- break;
- case orientation_horizontal_vertical:
- /*
- * For horizontal_vertical orientation
- * pack the children.
- * Compute the largest height and largest width.
- * Layout the widgets based on having the
- * number of columns specified by (cols)
- */
- count=0;
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (height < wc->h)
- height=wc->h;
- if (width < wc->w)
- width=wc->w;
- l=g_list_next(l);
- count++;
- }
- if (count < cols)
- cols=count;
- rows=(count+cols-1)/cols;
- width*=cols;
- height*=rows;
- width+=w->spx*(cols-1);
- height+=w->spy*(rows-1);
- owidth=width;
- oheight=height;
- expandd=expand=1;
- break;
- default:
- /*
- * No orientation was specified.
- * width and height are both 0.
- * The width & height of this widget
- * will be used.
- */
- if(!w->w && !w->h)
- dbg(lvl_error,"Warning width and height of a widget are 0");
- break;
- }
- if (! w->w && ! w->h) {
- w->w=w->bl+w->br+width;
- w->h=w->bt+w->bb+height+hb;
- w->packed=1;
- }
+void gui_internal_box_pack(struct gui_priv *this, struct widget *w) {
+ struct widget *wc;
+ int x0,x=0,y=0,width=0,height=0,owidth=0,oheight=0,expand=0,expandd=1,count=0,rows=0,cols=w->cols ? w->cols : 0;
+ int hb=w->scroll_buttons?w->scroll_buttons->button_box->h:0;
+ GList *l;
+ int orientation=w->flags & 0xffff0000;
+
+ if (!cols)
+ cols=this->cols;
+ if (!cols) {
+ if ( this->root.w > this->root.h )
+ cols=3;
+ else
+ cols=2;
+ width=0;
+ height=0;
+ }
+
+
+ /*
+ * count the number of children
+ */
+ l=w->children;
+ while (l) {
+ count++;
+ l=g_list_next(l);
+ }
+ if (orientation == orientation_horizontal_vertical && count <= cols)
+ orientation=orientation_horizontal;
+ switch (orientation) {
+ case orientation_horizontal:
+ /*
+ * For horizontal orientation:
+ * pack each child and find the largest height and
+ * compute the total width. x spacing (spx) is considered
+ *
+ * If any children want to be expanded
+ * we keep track of this
+ */
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ if (height < wc->h)
+ height=wc->h;
+ width+=wc->w;
+ if (wc->flags & flags_expand)
+ expand+=wc->w ? wc->w : 1;
+ l=g_list_next(l);
+ if (l)
+ width+=w->spx;
+ }
+ owidth=width;
+ if (expand && w->w) {
+ expandd=w->w-width+expand;
+ owidth=w->w;
+ } else
+ expandd=expand=1;
+ break;
+ case orientation_vertical:
+ /*
+ * For vertical layouts:
+ * We pack each child and compute the largest width and
+ * the total height. y spacing (spy) is considered
+ *
+ * If the expand flag is set then teh expansion amount
+ * is computed.
+ */
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ if (width < wc->w)
+ width=wc->w;
+ height+=wc->h;
+ if (wc->flags & flags_expand)
+ expand+=wc->h ? wc->h : 1;
+ l=g_list_next(l);
+ if (l)
+ height+=w->spy;
+ }
+ oheight=height;
+ if (expand && w->h) {
+ expandd=w->h-hb-height+expand;
+ oheight=w->h-hb;
+ } else
+ expandd=expand=1;
+ break;
+ case orientation_horizontal_vertical:
+ /*
+ * For horizontal_vertical orientation
+ * pack the children.
+ * Compute the largest height and largest width.
+ * Layout the widgets based on having the
+ * number of columns specified by (cols)
+ */
+ count=0;
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ if (height < wc->h)
+ height=wc->h;
+ if (width < wc->w)
+ width=wc->w;
+ l=g_list_next(l);
+ count++;
+ }
+ if (count < cols)
+ cols=count;
+ rows=(count+cols-1)/cols;
+ width*=cols;
+ height*=rows;
+ width+=w->spx*(cols-1);
+ height+=w->spy*(rows-1);
+ owidth=width;
+ oheight=height;
+ expandd=expand=1;
+ break;
+ default:
+ /*
+ * No orientation was specified.
+ * width and height are both 0.
+ * The width & height of this widget
+ * will be used.
+ */
+ if(!w->w && !w->h)
+ dbg(lvl_error,"Warning width and height of a widget are 0");
+ break;
+ }
+ if (! w->w && ! w->h) {
+ w->w=w->bl+w->br+width;
+ w->h=w->bt+w->bb+height+hb;
+ w->packed=1;
+ }
#if 0
- if (expand < 100)
- expand=100;
+ if (expand < 100)
+ expand=100;
#endif
- /*
- * At this stage the width and height of this
- * widget has been computed.
- * We now make a second pass assigning heights,
- * widths and coordinates to each child widget.
- */
-
- if (w->flags & gravity_left)
- x=w->p.x+w->bl;
- if (w->flags & gravity_xcenter)
- x=w->p.x+w->w/2-owidth/2;
- if (w->flags & gravity_right)
- x=w->p.x+w->w-w->br-owidth;
- if (w->flags & gravity_top)
- y=w->p.y+w->bt;
- if (w->flags & gravity_ycenter)
- y=w->p.y+(w->h-hb)/2-oheight/2;
- if (w->flags & gravity_bottom)
- y=w->p.y+(w->h-hb)-w->bb-oheight;
- l=w->children;
- switch (orientation) {
- case orientation_horizontal:
- l=w->children;
- while (l) {
- wc=l->data;
- wc->p.x=x;
- if (wc->flags & flags_fill)
- wc->h=w->h-hb;
- if (wc->flags & flags_expand) {
- if (! wc->w)
- wc->w=1;
- wc->w=wc->w*expandd/expand;
- }
- if (w->flags & gravity_top)
- wc->p.y=y;
- if (w->flags & gravity_ycenter)
- wc->p.y=y-wc->h/2;
- if (w->flags & gravity_bottom)
- wc->p.y=y-wc->h;
- x+=wc->w+w->spx;
- l=g_list_next(l);
- }
- break;
- case orientation_vertical:
- l=w->children;
- while (l) {
- wc=l->data;
- wc->p.y=y;
- if (wc->flags & flags_fill)
- wc->w=w->w;
- if (wc->flags & flags_expand) {
- if (! wc->h)
- wc->h=1;
- wc->h=wc->h*expandd/expand;
- }
- if (w->flags & gravity_left)
- wc->p.x=x;
- if (w->flags & gravity_xcenter)
- wc->p.x=x-wc->w/2;
- if (w->flags & gravity_right)
- wc->p.x=x-wc->w;
- y+=wc->h+w->spy;
- l=g_list_next(l);
- }
- break;
- case orientation_horizontal_vertical:
- l=w->children;
- x0=x;
- count=0;
- width/=cols;
- height/=rows;
- while (l) {
- wc=l->data;
- wc->p.x=x;
- wc->p.y=y;
- if (wc->flags & flags_fill) {
- wc->w=width;
- wc->h=height;
- }
- if (w->flags & gravity_left)
- wc->p.x=x;
- if (w->flags & gravity_xcenter)
- wc->p.x=x+(width-wc->w)/2;
- if (w->flags & gravity_right)
- wc->p.x=x+width-wc->w;
- if (w->flags & gravity_top)
- wc->p.y=y;
- if (w->flags & gravity_ycenter)
- wc->p.y=y+(height-wc->h)/2;
- if (w->flags & gravity_bottom)
- wc->p.y=y-height-wc->h;
- x+=width;
- if (++count == cols) {
- count=0;
- x=x0;
- y+=height;
- }
- l=g_list_next(l);
- }
- break;
- default:
- break;
- }
- if ((w->flags & flags_scrolly) && y > w->h+w->p.y && !w->scroll_buttons) {
- w->scroll_buttons=g_new0(struct scroll_buttons, 1);
- gui_internal_scroll_buttons_init(this, w, w->scroll_buttons);
- w->scroll_buttons->button_box->w=w->w;
- w->scroll_buttons->button_box->p.x=w->p.x;
- w->scroll_buttons->button_box->p.y=w->p.y+w->h-w->scroll_buttons->button_box->h;
- gui_internal_widget_pack(this, w->scroll_buttons->button_box);
- dbg(lvl_debug,"needs buttons %d vs %d\n",y,w->h);
- gui_internal_box_pack(this, w);
- return;
- }
- /*
- * Call pack again on each child,
- * the child has now had its size and coordinates
- * set so they can repack their children.
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- l=g_list_next(l);
- }
+ /*
+ * At this stage the width and height of this
+ * widget has been computed.
+ * We now make a second pass assigning heights,
+ * widths and coordinates to each child widget.
+ */
+
+ if (w->flags & gravity_left)
+ x=w->p.x+w->bl;
+ if (w->flags & gravity_xcenter)
+ x=w->p.x+w->w/2-owidth/2;
+ if (w->flags & gravity_right)
+ x=w->p.x+w->w-w->br-owidth;
+ if (w->flags & gravity_top)
+ y=w->p.y+w->bt;
+ if (w->flags & gravity_ycenter)
+ y=w->p.y+(w->h-hb)/2-oheight/2;
+ if (w->flags & gravity_bottom)
+ y=w->p.y+(w->h-hb)-w->bb-oheight;
+ l=w->children;
+ switch (orientation) {
+ case orientation_horizontal:
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ wc->p.x=x;
+ if (wc->flags & flags_fill)
+ wc->h=w->h-hb;
+ if (wc->flags & flags_expand) {
+ if (! wc->w)
+ wc->w=1;
+ wc->w=wc->w*expandd/expand;
+ }
+ if (w->flags & gravity_top)
+ wc->p.y=y;
+ if (w->flags & gravity_ycenter)
+ wc->p.y=y-wc->h/2;
+ if (w->flags & gravity_bottom)
+ wc->p.y=y-wc->h;
+ x+=wc->w+w->spx;
+ l=g_list_next(l);
+ }
+ break;
+ case orientation_vertical:
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ wc->p.y=y;
+ if (wc->flags & flags_fill)
+ wc->w=w->w;
+ if (wc->flags & flags_expand) {
+ if (! wc->h)
+ wc->h=1;
+ wc->h=wc->h*expandd/expand;
+ }
+ if (w->flags & gravity_left)
+ wc->p.x=x;
+ if (w->flags & gravity_xcenter)
+ wc->p.x=x-wc->w/2;
+ if (w->flags & gravity_right)
+ wc->p.x=x-wc->w;
+ y+=wc->h+w->spy;
+ l=g_list_next(l);
+ }
+ break;
+ case orientation_horizontal_vertical:
+ l=w->children;
+ x0=x;
+ count=0;
+ width/=cols;
+ height/=rows;
+ while (l) {
+ wc=l->data;
+ wc->p.x=x;
+ wc->p.y=y;
+ if (wc->flags & flags_fill) {
+ wc->w=width;
+ wc->h=height;
+ }
+ if (w->flags & gravity_left)
+ wc->p.x=x;
+ if (w->flags & gravity_xcenter)
+ wc->p.x=x+(width-wc->w)/2;
+ if (w->flags & gravity_right)
+ wc->p.x=x+width-wc->w;
+ if (w->flags & gravity_top)
+ wc->p.y=y;
+ if (w->flags & gravity_ycenter)
+ wc->p.y=y+(height-wc->h)/2;
+ if (w->flags & gravity_bottom)
+ wc->p.y=y-height-wc->h;
+ x+=width;
+ if (++count == cols) {
+ count=0;
+ x=x0;
+ y+=height;
+ }
+ l=g_list_next(l);
+ }
+ break;
+ default:
+ break;
+ }
+ if ((w->flags & flags_scrolly) && y > w->h+w->p.y && !w->scroll_buttons) {
+ w->scroll_buttons=g_new0(struct scroll_buttons, 1);
+ gui_internal_scroll_buttons_init(this, w, w->scroll_buttons);
+ w->scroll_buttons->button_box->w=w->w;
+ w->scroll_buttons->button_box->p.x=w->p.x;
+ w->scroll_buttons->button_box->p.y=w->p.y+w->h-w->scroll_buttons->button_box->h;
+ gui_internal_widget_pack(this, w->scroll_buttons->button_box);
+ dbg(lvl_debug,"needs buttons %d vs %d",y,w->h);
+ gui_internal_box_pack(this, w);
+ return;
+ }
+ /*
+ * Call pack again on each child,
+ * the child has now had its size and coordinates
+ * set so they can repack their children.
+ */
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ l=g_list_next(l);
+ }
}
-void
-gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- GList *l;
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_reset_pack(this, wc);
- l=g_list_next(l);
- }
- if (w->packed) {
- w->w=0;
- w->h=0;
- }
+/**
+ * @brief Resize a box widget.
+ *
+ * @param this The internal GUI instance
+ * @param w The widget to resize
+ * @param wnew The new width of the widget
+ * @param hnew THe new height of the widget
+ */
+void gui_internal_box_resize(struct gui_priv *this, struct widget *w, void *data, int wnew, int hnew) {
+ GList *l;
+ struct widget *wb;
+
+ w->w = wnew;
+ w->h = hnew;
+
+ l=w->children;
+ while (l) {
+ wb=l->data;
+ if (wb->on_resize) {
+ int orientation=w->flags & 0xffff0000;
+ switch(orientation) {
+ case orientation_horizontal:
+ case orientation_vertical:
+ case orientation_horizontal_vertical:
+ wb->h = 0;
+ wb->w = 0;
+ gui_internal_widget_pack(this, wb);
+ break;
+ default:
+ wb->w = w->w;
+ wb->h = w->h;
+ }
+ wb->on_resize(this, wb, NULL, wb->w, wb->h);
+ }
+ l=g_list_next(l);
+ }
+
+ /* Note: this widget and its children have been resized, a call to gui_internal_box_render() needs to be done by the caller */
+}
+
+void gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w) {
+ struct widget *wc;
+ GList *l;
+
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_reset_pack(this, wc);
+ l=g_list_next(l);
+ }
+ if (w->packed) {
+ w->w=0;
+ w->h=0;
+ }
}
/**
@@ -644,15 +754,13 @@ gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w)
* @param parent The parent widget
* @param child The child widget
*/
-void
-gui_internal_widget_append(struct widget *parent, struct widget *child)
-{
- if (! child)
- return;
- if (! child->background)
- child->background=parent->background;
- parent->children=g_list_append(parent->children, child);
- child->parent=parent;
+void gui_internal_widget_append(struct widget *parent, struct widget *child) {
+ if (! child)
+ return;
+ if (! child->background)
+ child->background=parent->background;
+ parent->children=g_list_append(parent->children, child);
+ child->parent=parent;
}
/**
@@ -661,13 +769,11 @@ gui_internal_widget_append(struct widget *parent, struct widget *child)
* @param parent The parent widget
* @param child The child widget
*/
-void
-gui_internal_widget_prepend(struct widget *parent, struct widget *child)
-{
- if (! child->background)
- child->background=parent->background;
- parent->children=g_list_prepend(parent->children, child);
- child->parent=parent;
+void gui_internal_widget_prepend(struct widget *parent, struct widget *child) {
+ if (! child->background)
+ child->background=parent->background;
+ parent->children=g_list_prepend(parent->children, child);
+ child->parent=parent;
}
/**
@@ -679,14 +785,12 @@ gui_internal_widget_prepend(struct widget *parent, struct widget *child)
* @param child The child widget
* @param func The comparison function
*/
-void
-gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, GCompareFunc func)
-{
- if (! child->background)
- child->background=parent->background;
-
- parent->children=g_list_insert_sorted(parent->children, child, func);
- child->parent=parent;
+void gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, GCompareFunc func) {
+ if (! child->background)
+ child->background=parent->background;
+
+ parent->children=g_list_insert_sorted(parent->children, child, func);
+ child->parent=parent;
}
@@ -698,20 +802,18 @@ gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, G
* @param this The internal GUI instance
* @param w The widget whose children are to be destroyed
*/
-void
-gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w)
-{
- GList *l;
- struct widget *wc;
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_destroy(this, wc);
- l=g_list_next(l);
- }
- g_list_free(w->children);
- w->children=NULL;
+void gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w) {
+ GList *l;
+ struct widget *wc;
+
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_destroy(this, wc);
+ l=g_list_next(l);
+ }
+ g_list_free(w->children);
+ w->children=NULL;
}
@@ -724,113 +826,112 @@ gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w)
* @param this The internal GUI instance
* @param w The widget to destroy
*/
-void
-gui_internal_widget_destroy(struct gui_priv *this, struct widget *w)
-{
- gui_internal_widget_children_destroy(this, w);
- g_free(w->command);
- g_free(w->speech);
- g_free(w->text);
- if (w->img)
- graphics_image_free(this->gra, w->img);
- if (w->prefix)
- g_free(w->prefix);
- if (w->name)
- g_free(w->name);
- if (w->data_free)
- w->data_free(w->data);
- if (w->cb && w->remove_cb)
- w->remove_cb(w->instance, w->cb);
- if (w==this->highlighted)
- this->highlighted=NULL;
- if(w->wfree)
- w->wfree(this,w);
- else
- g_free(w);
+void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w) {
+ gui_internal_widget_children_destroy(this, w);
+ g_free(w->command);
+ g_free(w->speech);
+ g_free(w->text);
+ if (w->img)
+ graphics_image_free(this->gra, w->img);
+ if (w->prefix)
+ g_free(w->prefix);
+ if (w->name)
+ g_free(w->name);
+ if (w->data_free)
+ w->data_free(w->data);
+ if (w->cb && w->remove_cb)
+ w->remove_cb(w->instance, w->cb);
+ if (w==this->highlighted)
+ this->highlighted=NULL;
+ if(w->wfree)
+ w->wfree(this,w);
+ else
+ g_free(w);
}
-void
-gui_internal_widget_render(struct gui_priv *this, struct widget *w)
-{
- if(w->p.x > this->root.w || w->p.y > this->root.h || w->state & STATE_INVISIBLE)
- return;
-
- switch (w->type) {
- case widget_box:
- gui_internal_box_render(this, w);
- break;
- case widget_label:
- gui_internal_label_render(this, w);
- break;
- case widget_image:
- gui_internal_image_render(this, w);
- break;
- case widget_table:
- gui_internal_table_render(this,w);
- break;
- default:
- break;
- }
+/**
+ * @brief Renders widgets, preparing it for drawing on the display
+ *
+ * The appropriate render function will be called, depending on the type of widget
+ *
+ * @param this The internal GUI instance
+ * @param w The widget to render
+ */
+void gui_internal_widget_render(struct gui_priv *this, struct widget *w) {
+ if(w->p.x > this->root.w || w->p.y > this->root.h || w->state & STATE_INVISIBLE)
+ return;
+
+ switch (w->type) {
+ case widget_box:
+ gui_internal_box_render(this, w);
+ break;
+ case widget_label:
+ gui_internal_label_render(this, w);
+ break;
+ case widget_image:
+ gui_internal_image_render(this, w);
+ break;
+ case widget_table:
+ gui_internal_table_render(this,w);
+ break;
+ default:
+ break;
+ }
}
-void
-gui_internal_widget_pack(struct gui_priv *this, struct widget *w)
-{
- switch (w->type) {
- case widget_box:
- gui_internal_box_pack(this, w);
- break;
- case widget_table:
- gui_internal_table_pack(this,w);
- default:
- break;
- }
+void gui_internal_widget_pack(struct gui_priv *this, struct widget *w) {
+ switch (w->type) {
+ case widget_box:
+ gui_internal_box_pack(this, w);
+ break;
+ case widget_table:
+ gui_internal_table_pack(this,w);
+ default:
+ break;
+ }
}
struct widget *
-gui_internal_button_label(struct gui_priv *this, const char *label, int mode)
-{
- struct widget *wl,*wlb;
- struct widget *wb=gui_internal_menu_data(this)->button_bar;
- wlb=gui_internal_box_new(this, gravity_right_center|orientation_vertical);
- wl=gui_internal_label_new(this, label);
- wlb->border=1;
- wlb->foreground=this->text_foreground;
- wlb->bl=20;
- wlb->br=20;
- wlb->bb=6;
- wlb->bt=6;
- gui_internal_widget_append(wlb, wl);
- if (mode == 1)
- gui_internal_widget_prepend(wb, wlb);
- if (mode == -1)
- gui_internal_widget_append(wb, wlb);
-
- return wlb;
+gui_internal_button_label(struct gui_priv *this, const char *label, int mode) {
+ struct widget *wl,*wlb;
+ struct widget *wb=gui_internal_menu_data(this)->button_bar;
+ wlb=gui_internal_box_new(this, gravity_right_center|orientation_vertical);
+ wl=gui_internal_label_new(this, label);
+ wlb->border=1;
+ wlb->foreground=this->text_foreground;
+ wlb->bl=20;
+ wlb->br=20;
+ wlb->bb=6;
+ wlb->bt=6;
+ gui_internal_widget_append(wlb, wl);
+ if (mode == 1)
+ gui_internal_widget_prepend(wb, wlb);
+ if (mode == -1)
+ gui_internal_widget_append(wb, wlb);
+
+ return wlb;
}
-static void
-gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb)
-{
- sb->next_button = gui_internal_button_new_with_callback(this, _("Next"), image_new_xs(this, "gui_arrow_right"),
- gravity_center|orientation_horizontal|flags_swap, gui_internal_table_button_next, widget);
- sb->prev_button = gui_internal_button_new_with_callback(this, _("Prev"), image_new_xs(this, "gui_arrow_left"),
- gravity_center|orientation_horizontal, gui_internal_table_button_prev, widget);
-
- sb->button_box=gui_internal_box_new(this, gravity_center|orientation_horizontal);
- sb->button_box->background=this->background;
- if(this->hide_keys){
- sb->prev_button->state |= STATE_INVISIBLE;
- sb->next_button->state |= STATE_INVISIBLE;
- }
- sb->prev_button->state &= ~STATE_SENSITIVE;
- sb->next_button->state &= ~STATE_SENSITIVE;
- gui_internal_widget_append(sb->button_box, sb->prev_button);
- gui_internal_widget_append(sb->button_box, sb->next_button);
-
- sb->button_box->bl=this->spacing;
- gui_internal_widget_pack(this,sb->button_box);
+static void gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb) {
+ sb->next_button = gui_internal_button_new_with_callback(this, _("Next"), image_new_xs(this, "gui_arrow_right"),
+ gravity_center|orientation_horizontal|flags_swap, gui_internal_table_button_next, widget);
+ sb->prev_button = gui_internal_button_new_with_callback(this, _("Prev"), image_new_xs(this, "gui_arrow_left"),
+ gravity_center|orientation_horizontal, gui_internal_table_button_prev, widget);
+
+ sb->button_box=gui_internal_box_new(this, gravity_center|orientation_horizontal);
+ sb->button_box->background=this->background;
+ if(this->hide_keys) {
+ sb->prev_button->state |= STATE_INVISIBLE;
+ sb->next_button->state |= STATE_INVISIBLE;
+ }
+ sb->prev_button->state &= ~STATE_SENSITIVE;
+ sb->next_button->state &= ~STATE_SENSITIVE;
+ gui_internal_widget_append(sb->button_box, sb->prev_button);
+ gui_internal_widget_append(sb->button_box, sb->next_button);
+
+ sb->button_box->bl=this->spacing;
+ gui_internal_widget_pack(this,sb->button_box);
}
/**
@@ -843,29 +944,28 @@ gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, s
* @param flags widget sizing flags.
* @return The newly created widget
*/
-struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons)
-{
- struct widget * widget = g_new0(struct widget,1);
- struct table_data * data = NULL;
- widget->type=widget_table;
- widget->flags=flags;
- widget->state=STATE_SCROLLABLE;
- widget->data=g_new0(struct table_data,1);
- widget->data_free=gui_internal_table_data_free;
-
- // We have to set background here explicitly
- // because it will be used by inner elements created later in this
- // function (navigation buttons). Else that elements won't have
- // any background.
- widget->background=this->background;
- data = (struct table_data*)widget->data;
-
- if (buttons) {
- gui_internal_scroll_buttons_init(this, widget, &data->scroll_buttons);
- gui_internal_widget_append(widget, data->scroll_buttons.button_box);
- }
-
- return widget;
+struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons) {
+ struct widget * widget = g_new0(struct widget,1);
+ struct table_data * data = NULL;
+ widget->type=widget_table;
+ widget->flags=flags;
+ widget->state=STATE_SCROLLABLE;
+ widget->data=g_new0(struct table_data,1);
+ widget->data_free=gui_internal_table_data_free;
+
+ // We have to set background here explicitly
+ // because it will be used by inner elements created later in this
+ // function (navigation buttons). Else that elements won't have
+ // any background.
+ widget->background=this->background;
+ data = (struct table_data*)widget->data;
+
+ if (buttons) {
+ gui_internal_scroll_buttons_init(this, widget, &data->scroll_buttons);
+ gui_internal_widget_append(widget, data->scroll_buttons.button_box);
+ }
+
+ return widget;
}
@@ -878,30 +978,27 @@ struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags
* @param this The internal GUI instance
* @param table The table widget
*/
-void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table)
-{
- GList * iter;
- struct table_data * table_data = (struct table_data* ) table->data;
-
- iter = table->children;
- while(iter ) {
- if(iter->data != table_data->scroll_buttons.button_box) {
- struct widget * child = (struct widget*)iter->data;
- gui_internal_widget_destroy(this,child);
- if(table->children == iter) {
- table->children = g_list_remove(iter,iter->data);
- iter=table->children;
- }
- else
- iter = g_list_remove(iter,iter->data);
- }
- else {
- iter = g_list_next(iter);
- }
-
- }
- table_data->top_row=NULL;
- table_data->bottom_row=NULL;
+void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table) {
+ GList * iter;
+ struct table_data * table_data = (struct table_data* ) table->data;
+
+ iter = table->children;
+ while(iter ) {
+ if(iter->data != table_data->scroll_buttons.button_box) {
+ struct widget * child = (struct widget*)iter->data;
+ gui_internal_widget_destroy(this,child);
+ if(table->children == iter) {
+ table->children = g_list_remove(iter,iter->data);
+ iter=table->children;
+ } else
+ iter = g_list_remove(iter,iter->data);
+ } else {
+ iter = g_list_next(iter);
+ }
+
+ }
+ table_data->top_row=NULL;
+ table_data->bottom_row=NULL;
}
/**
@@ -911,14 +1008,12 @@ void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * tabl
*
* @return GList pointer to the next row in the children list, or NULL if there are no any rows left.
*/
-GList *
-gui_internal_widget_table_next_row(GList * row)
-{
- while((row=g_list_next(row))!=NULL) {
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- break;
- }
- return row;
+GList *gui_internal_widget_table_next_row(GList * row) {
+ while((row=g_list_next(row))!=NULL) {
+ if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
+ break;
+ }
+ return row;
}
/**
@@ -928,14 +1023,12 @@ gui_internal_widget_table_next_row(GList * row)
*
* @return GList pointer to the previous row in the children list, or NULL if there are no any rows left.
*/
-GList *
-gui_internal_widget_table_prev_row(GList * row)
-{
- while((row=g_list_previous(row))!=NULL) {
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- break;
- }
- return row;
+GList *gui_internal_widget_table_prev_row(GList * row) {
+ while((row=g_list_previous(row))!=NULL) {
+ if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
+ break;
+ }
+ return row;
}
/**
@@ -945,16 +1038,14 @@ gui_internal_widget_table_prev_row(GList * row)
*
* @return GList pointer to the first row in the children list, or NULL if table is empty.
*/
-GList *
-gui_internal_widget_table_first_row(GList * row)
-{
- if(!row)
- return NULL;
+GList *gui_internal_widget_table_first_row(GList * row) {
+ if(!row)
+ return NULL;
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- return row;
+ if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
+ return row;
- return gui_internal_widget_table_next_row(row);
+ return gui_internal_widget_table_next_row(row);
}
/**
@@ -962,14 +1053,12 @@ gui_internal_widget_table_first_row(GList * row)
*
* @return GList pointer to the top row in the children list, or NULL.
*/
-GList *
-gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table)
-{
- if(table && table->type==widget_table) {
- struct table_data *d=table->data;
- return gui_internal_widget_table_first_row(d->top_row);
- }
- return NULL;
+GList *gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table) {
+ if(table && table->type==widget_table) {
+ struct table_data *d=table->data;
+ return gui_internal_widget_table_first_row(d->top_row);
+ }
+ return NULL;
}
/**
@@ -977,19 +1066,17 @@ gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table)
*
* @return GList pointer to the top row in the children list of the table.
*/
-GList *
-gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * table, struct widget *row)
-{
- if(table && table->type==widget_table) {
- struct table_data *d=table->data;
- d->top_row=table->children;
- while(d->top_row && d->top_row->data!=row)
- d->top_row=g_list_next(d->top_row);
- if(!d->top_row)
- d->top_row=gui_internal_widget_table_first_row(table->children);
- return d->top_row;
- }
- return NULL;
+GList *gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * table, struct widget *row) {
+ if(table && table->type==widget_table) {
+ struct table_data *d=table->data;
+ d->top_row=table->children;
+ while(d->top_row && d->top_row->data!=row)
+ d->top_row=g_list_next(d->top_row);
+ if(!d->top_row)
+ d->top_row=gui_internal_widget_table_first_row(table->children);
+ return d->top_row;
+ }
+ return NULL;
}
@@ -1002,12 +1089,11 @@ gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * tab
* @return The new table_row widget.
*/
struct widget *
-gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags)
-{
- struct widget * widget = g_new0(struct widget,1);
- widget->type=widget_table_row;
- widget->flags=flags;
- return widget;
+gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags) {
+ struct widget * widget = g_new0(struct widget,1);
+ widget->type=widget_table_row;
+ widget->flags=flags;
+ return widget;
}
@@ -1024,91 +1110,81 @@ gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags)
*
* The caller is responsible for freeing the returned list.
*/
-static GList *
-gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w)
-{
-
- GList * column_desc = NULL;
- GList * current_desc=NULL;
- GList * cur_row = w->children;
- struct widget * cur_row_widget=NULL;
- GList * cur_column=NULL;
- struct widget * cell_w=NULL;
- struct table_column_desc * current_cell=NULL;
- struct table_data * table_data=NULL;
- int height=0;
- int width=0;
- int total_width=0;
- int column_count=0;
-
- /*
- * Scroll through the the table and
- * 1. Compute the maximum width + height of each column across all rows.
- */
- table_data = (struct table_data*) w->data;
- for(cur_row=w->children; cur_row ; cur_row = g_list_next(cur_row) )
- {
- cur_row_widget = (struct widget*) cur_row->data;
- current_desc = column_desc;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- continue;
- }
- column_count=0;
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- cell_w = (struct widget*) cur_column->data;
- gui_internal_widget_pack(this,cell_w);
- if(current_desc == 0)
- {
- current_cell = g_new0(struct table_column_desc,1);
- column_desc = g_list_append(column_desc,current_cell);
- current_desc = g_list_last(column_desc);
- current_cell->height=cell_w->h;
- current_cell->width=cell_w->w;
- total_width+=cell_w->w;
-
- }
- else
- {
- current_cell = current_desc->data;
- height = cell_w->h;
- width = cell_w->w;
- if(current_cell->height < height )
- {
- current_cell->height = height;
- }
- if(current_cell->width < width)
- {
- total_width += (width-current_cell->width);
- current_cell->width = width;
-
-
-
- }
- current_desc = g_list_next(current_desc);
- }
- column_count++;
-
- }/* column loop */
-
- } /*row loop */
-
-
- /*
- * If the width of all columns is less than the width off
- * the table expand each cell proportionally.
- *
- */
- if(total_width+(this->spacing*column_count) < w->w ) {
- for(current_desc=column_desc; current_desc; current_desc=g_list_next(current_desc)) {
- current_cell = (struct table_column_desc*) current_desc->data;
- current_cell->width= ( (current_cell->width+this->spacing)/(float)total_width) * w->w ;
- }
- }
-
- return column_desc;
+static GList *gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w) {
+
+ GList * column_desc = NULL;
+ GList * current_desc=NULL;
+ GList * cur_row = w->children;
+ struct widget * cur_row_widget=NULL;
+ GList * cur_column=NULL;
+ struct widget * cell_w=NULL;
+ struct table_column_desc * current_cell=NULL;
+ struct table_data * table_data=NULL;
+ int height=0;
+ int width=0;
+ int total_width=0;
+ int column_count=0;
+
+ /*
+ * Scroll through the the table and
+ * 1. Compute the maximum width + height of each column across all rows.
+ */
+ table_data = (struct table_data*) w->data;
+ for(cur_row=w->children; cur_row ; cur_row = g_list_next(cur_row) ) {
+ cur_row_widget = (struct widget*) cur_row->data;
+ current_desc = column_desc;
+ if(cur_row_widget == table_data->scroll_buttons.button_box) {
+ continue;
+ }
+ column_count=0;
+ for(cur_column = cur_row_widget->children; cur_column;
+ cur_column=g_list_next(cur_column)) {
+ cell_w = (struct widget*) cur_column->data;
+ gui_internal_widget_pack(this,cell_w);
+ if(current_desc == 0) {
+ current_cell = g_new0(struct table_column_desc,1);
+ column_desc = g_list_append(column_desc,current_cell);
+ current_desc = g_list_last(column_desc);
+ current_cell->height=cell_w->h;
+ current_cell->width=cell_w->w;
+ total_width+=cell_w->w;
+
+ } else {
+ current_cell = current_desc->data;
+ height = cell_w->h;
+ width = cell_w->w;
+ if(current_cell->height < height ) {
+ current_cell->height = height;
+ }
+ if(current_cell->width < width) {
+ total_width += (width-current_cell->width);
+ current_cell->width = width;
+
+
+
+ }
+ current_desc = g_list_next(current_desc);
+ }
+ column_count++;
+
+ }/* column loop */
+
+ } /*row loop */
+
+
+ /*
+ * If the width of all columns is less than the width off
+ * the table expand each cell proportionally.
+ *
+ */
+ if(total_width+(this->spacing*column_count) < w->w ) {
+ for(current_desc=column_desc; current_desc; current_desc=g_list_next(current_desc)) {
+ current_cell = (struct table_column_desc*) current_desc->data;
+ current_cell->width= ( (current_cell->width+this->spacing)/(float)total_width) * w->w ;
+ }
+ }
+
+ return column_desc;
}
@@ -1121,69 +1197,59 @@ gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w)
* @param this The graphics context
* @param w The widget to pack.
*/
-void
-gui_internal_table_pack(struct gui_priv * this, struct widget * w)
-{
-
- int height=0;
- int width=0;
- int count=0;
- GList * column_data = gui_internal_compute_table_dimensions(this,w);
- GList * current=0;
- struct table_column_desc * cell_desc=0;
- struct table_data * table_data = (struct table_data*)w->data;
-
- for(current = column_data; current; current=g_list_next(current))
- {
- if(table_data->scroll_buttons.button_box == current->data )
- {
- continue;
- }
- cell_desc = (struct table_column_desc *) current->data;
- width = width + cell_desc->width + this->spacing;
- if(height < cell_desc->height)
- {
- height = cell_desc->height ;
- }
- }
-
-
-
- for(current=w->children; current; current=g_list_next(current))
- {
- if(current->data!= table_data->scroll_buttons.button_box)
- {
- count++;
- }
- }
-
- w->w = width;
- if(w->w + w->c.x > this->root.w)
- {
- w->w = this->root.w - w->c.x;
- }
-
-
- if(w->h + w->c.y > this->root.h )
- {
- /*
- * Do not allow the widget to exceed the screen.
- *
- */
- w->h = this->root.h- w->c.y - height;
- }
-
- if (table_data->scroll_buttons.button_box)
- {
- gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
- }
-
-
- /*
- * Deallocate column descriptions.
- */
- g_list_foreach(column_data,(GFunc)g_free,NULL);
- g_list_free(column_data);
+void gui_internal_table_pack(struct gui_priv * this, struct widget * w) {
+
+ int height=0;
+ int width=0;
+ int count=0;
+ GList * column_data = gui_internal_compute_table_dimensions(this,w);
+ GList * current=0;
+ struct table_column_desc * cell_desc=0;
+ struct table_data * table_data = (struct table_data*)w->data;
+
+ for(current = column_data; current; current=g_list_next(current)) {
+ if(table_data->scroll_buttons.button_box == current->data ) {
+ continue;
+ }
+ cell_desc = (struct table_column_desc *) current->data;
+ width = width + cell_desc->width + this->spacing;
+ if(height < cell_desc->height) {
+ height = cell_desc->height ;
+ }
+ }
+
+
+
+ for(current=w->children; current; current=g_list_next(current)) {
+ if(current->data!= table_data->scroll_buttons.button_box) {
+ count++;
+ }
+ }
+
+ w->w = width;
+ if(w->w + w->c.x > this->root.w) {
+ w->w = this->root.w - w->c.x;
+ }
+
+
+ if(w->h + w->c.y > this->root.h ) {
+ /*
+ * Do not allow the widget to exceed the screen.
+ *
+ */
+ w->h = this->root.h- w->c.y - height;
+ }
+
+ if (table_data->scroll_buttons.button_box) {
+ gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
+ }
+
+
+ /*
+ * Deallocate column descriptions.
+ */
+ g_list_foreach(column_data,(GFunc)g_free,NULL);
+ g_list_free(column_data);
}
@@ -1194,210 +1260,225 @@ gui_internal_table_pack(struct gui_priv * this, struct widget * w)
*
* @param table_data Data from the table object.
*/
-void
-gui_internal_table_hide_rows(struct table_data * table_data)
-{
- GList*cur_row;
- for(cur_row=table_data->top_row; cur_row ; cur_row = g_list_next(cur_row))
- {
- struct widget * cur_row_widget = (struct widget*)cur_row->data;
- if (cur_row_widget->type!=widget_table_row)
- continue;
- cur_row_widget->p.x=0;
- cur_row_widget->p.y=0;
- cur_row_widget->w=0;
- cur_row_widget->h=0;
- if(cur_row==table_data->bottom_row)
- break;
- }
+void gui_internal_table_hide_rows(struct table_data * table_data) {
+ GList*cur_row;
+ for(cur_row=table_data->top_row; cur_row ; cur_row = g_list_next(cur_row)) {
+ struct widget * cur_row_widget = (struct widget*)cur_row->data;
+ if (cur_row_widget->type!=widget_table_row)
+ continue;
+ cur_row_widget->p.x=0;
+ cur_row_widget->p.y=0;
+ cur_row_widget->w=0;
+ cur_row_widget->h=0;
+ if(cur_row==table_data->bottom_row)
+ break;
+ }
}
/**
- * @brief Renders a table widget.
+ * @brief Renders a table widget, preparing it for drawing on the display
*
- * @param this The graphics context
- * @param w The table widget to render.
+ * @param this The internal GUI instance
+ * @param w The widget to render
*/
-void
-gui_internal_table_render(struct gui_priv * this, struct widget * w)
-{
-
- int x;
- int y;
- GList * column_desc=NULL;
- GList * cur_row = NULL;
- GList * current_desc=NULL;
- struct table_data * table_data = (struct table_data*)w->data;
- int drawing_space_left=1;
- int is_first_page;
- struct table_column_desc * dim=NULL;
-
- dbg_assert(table_data);
- column_desc = gui_internal_compute_table_dimensions(this,w);
- if(!column_desc)
- return;
- y=w->p.y;
- gui_internal_table_hide_rows(table_data);
- /*
- * Skip rows that are on previous pages.
- */
- if(table_data->top_row && table_data->top_row != w->children && !table_data->scroll_buttons.button_box_hide)
- {
- cur_row = table_data->top_row;
- is_first_page=0;
- } else {
- cur_row = w->children;
- table_data->top_row=NULL;
- is_first_page=1;
- }
-
- /* First, let's mark all columns as off-screen that are in rows which are *before*
- * our current page.
- * */
- GList *row = w->children;
- while (row != cur_row) {
- struct widget * cur_row_widget = (struct widget*)row->data;
- GList * cur_column=NULL;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- row = g_list_next(row);
- continue;
- }
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- struct widget * cur_widget = (struct widget*) cur_column->data;
- if(this->hide_keys){
- cur_widget->state |= STATE_INVISIBLE;
- cur_widget->state &= ~STATE_SENSITIVE;
- }else{
- cur_widget->state |= STATE_OFFSCREEN;
- }
- }
- row = g_list_next(row);
- }
-
- /*
- * Loop through each row. Drawing each cell with the proper sizes,
- * at the proper positions.
- */
- for(table_data->top_row=cur_row; cur_row; cur_row = g_list_next(cur_row))
- {
- int max_height=0, bbox_height=0;
- struct widget * cur_row_widget;
- GList * cur_column=NULL;
- current_desc = column_desc;
- cur_row_widget = (struct widget*)cur_row->data;
- x =w->p.x+this->spacing;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- continue;
- }
- dim = (struct table_column_desc*)current_desc->data;
-
- if (table_data->scroll_buttons.button_box && !table_data->scroll_buttons.button_box_hide)
- bbox_height=table_data->scroll_buttons.button_box->h;
-
- if( y + dim->height + bbox_height + this->spacing >= w->p.y + w->h )
- {
- drawing_space_left=0;
- }
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- struct widget * cur_widget = (struct widget*) cur_column->data;
- if (drawing_space_left) {
- cur_widget->p.x=x;
- cur_widget->w=dim->width;
- cur_widget->p.y=y;
- cur_widget->h=dim->height;
- x=x+cur_widget->w;
- max_height = dim->height;
- /* We pack the widget before rendering to ensure that the x and y
- * coordinates get pushed down.
- */
- if(this->hide_keys){
- cur_widget->state &= ~STATE_INVISIBLE;
- cur_widget->state |= STATE_SENSITIVE;
- }else{
- cur_widget->state &= ~STATE_OFFSCREEN;
- }
- gui_internal_widget_pack(this,cur_widget);
- gui_internal_widget_render(this,cur_widget);
-
- if(dim->height > max_height)
- {
- max_height = dim->height;
- }
- } else {
- /* Deactivate contents that we don't have space for. */
- if(this->hide_keys){
- cur_widget->state |= STATE_INVISIBLE;
- cur_widget->state &= ~STATE_SENSITIVE;
- }else{
- cur_widget->state |= STATE_OFFSCREEN;
- }
- }
- }
-
- if (drawing_space_left) {
- /* Row object should have its coordinates in actual
- * state to be able to pass mouse clicks to Column objects
- */
- cur_row_widget->p.x=w->p.x;
- cur_row_widget->w=w->w;
- cur_row_widget->p.y=y;
- cur_row_widget->h=max_height;
- y = y + max_height;
- table_data->bottom_row=cur_row;
- current_desc = g_list_next(current_desc);
- }
- }
-
- /* By default, hide all scroll buttons. */
- if(this->hide_keys){
- table_data->scroll_buttons.next_button->state|= STATE_INVISIBLE;
- table_data->scroll_buttons.prev_button->state|= STATE_INVISIBLE;
- }
- table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
- table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
-
- if(table_data->scroll_buttons.button_box && (!drawing_space_left || !is_first_page) && !table_data->scroll_buttons.button_box_hide )
- {
- table_data->scroll_buttons.button_box->p.y =w->p.y+w->h-table_data->scroll_buttons.button_box->h -
- this->spacing;
- if(table_data->scroll_buttons.button_box->p.y < y )
- {
- table_data->scroll_buttons.button_box->p.y=y;
- }
- table_data->scroll_buttons.button_box->p.x = w->p.x;
- table_data->scroll_buttons.button_box->w = w->w;
- gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
- if(table_data->scroll_buttons.next_button->p.y > w->p.y + w->h + table_data->scroll_buttons.next_button->h)
- {
- table_data->scroll_buttons.button_box->p.y = w->p.y + w->h -
- table_data->scroll_buttons.button_box->h;
- }
- if(!drawing_space_left)
- {
- table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
- table_data->scroll_buttons.next_button->state&= ~STATE_INVISIBLE;
- }
-
- if(table_data->top_row != w->children)
- {
- table_data->scroll_buttons.prev_button->state|= STATE_SENSITIVE;
- table_data->scroll_buttons.prev_button->state&= ~STATE_INVISIBLE;
- }
- gui_internal_widget_render(this,table_data->scroll_buttons.button_box);
- }
-
- /*
- * Deallocate column descriptions.
- */
- g_list_foreach(column_desc,(GFunc)g_free,NULL);
- g_list_free(column_desc);
+void gui_internal_table_render(struct gui_priv * this, struct widget * w) {
+
+ int x;
+ int y;
+ GList * column_desc=NULL;
+ GList * cur_row = NULL;
+ GList * current_desc=NULL;
+ struct table_data * table_data = (struct table_data*)w->data;
+ int drawing_space_left=1;
+ int is_first_page;
+ struct table_column_desc * dim=NULL;
+
+ dbg_assert(table_data);
+ column_desc = gui_internal_compute_table_dimensions(this,w);
+ if(!column_desc)
+ return;
+ y=w->p.y;
+ gui_internal_table_hide_rows(table_data);
+ /*
+ * Skip rows that are on previous pages.
+ */
+ if(table_data->top_row && table_data->top_row != w->children && !table_data->scroll_buttons.button_box_hide) {
+ cur_row = table_data->top_row;
+ is_first_page=0;
+ } else {
+ cur_row = w->children;
+ table_data->top_row=NULL;
+ is_first_page=1;
+ }
+
+ /* First, let's mark all columns as off-screen that are in rows which are *before*
+ * our current page.
+ * */
+ GList *row = w->children;
+ while (row != cur_row) {
+ struct widget * cur_row_widget = (struct widget*)row->data;
+ GList * cur_column=NULL;
+ if(cur_row_widget == table_data->scroll_buttons.button_box) {
+ row = g_list_next(row);
+ continue;
+ }
+ for(cur_column = cur_row_widget->children; cur_column;
+ cur_column=g_list_next(cur_column)) {
+ struct widget * cur_widget = (struct widget*) cur_column->data;
+ if(this->hide_keys) {
+ cur_widget->state |= STATE_INVISIBLE;
+ cur_widget->state &= ~STATE_SENSITIVE;
+ } else {
+ cur_widget->state |= STATE_OFFSCREEN;
+ }
+ }
+ row = g_list_next(row);
+ }
+
+ /*
+ * Loop through each row. Drawing each cell with the proper sizes,
+ * at the proper positions.
+ */
+ for(table_data->top_row=cur_row; cur_row; cur_row = g_list_next(cur_row)) {
+ int max_height=0, bbox_height=0;
+ struct widget * cur_row_widget;
+ GList * cur_column=NULL;
+ current_desc = column_desc;
+ cur_row_widget = (struct widget*)cur_row->data;
+ x =w->p.x+this->spacing;
+ if(cur_row_widget == table_data->scroll_buttons.button_box) {
+ continue;
+ }
+ dim = (struct table_column_desc*)current_desc->data;
+
+ if (table_data->scroll_buttons.button_box && !table_data->scroll_buttons.button_box_hide)
+ bbox_height=table_data->scroll_buttons.button_box->h;
+
+ if( y + dim->height + bbox_height + this->spacing >= w->p.y + w->h ) {
+ drawing_space_left=0;
+ }
+ for(cur_column = cur_row_widget->children; cur_column;
+ cur_column=g_list_next(cur_column)) {
+ struct widget * cur_widget = (struct widget*) cur_column->data;
+ if (drawing_space_left) {
+ cur_widget->p.x=x;
+ cur_widget->w=dim->width;
+ cur_widget->p.y=y;
+ cur_widget->h=dim->height;
+ x=x+cur_widget->w;
+ max_height = dim->height;
+ /* We pack the widget before rendering to ensure that the x and y
+ * coordinates get pushed down.
+ */
+ if(this->hide_keys) {
+ cur_widget->state &= ~STATE_INVISIBLE;
+ cur_widget->state |= STATE_SENSITIVE;
+ } else {
+ cur_widget->state &= ~STATE_OFFSCREEN;
+ }
+
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+
+ static struct graphics_gc *debug_gc=NULL;
+ static struct color gui_table_debug_color= {0x0000,0xffff,0x0400,0xffff}; /* Green */
+ int visual_debug = (debug_level_get("gui_internal_visual_layout") >= lvl_debug);
+
+ if (visual_debug)
+ dbg(lvl_debug, "Internal layout visual debugging is enabled");
+
+ if (visual_debug && !debug_gc) {
+ debug_gc = graphics_gc_new(this->gra);
+ graphics_gc_set_foreground(debug_gc, &gui_table_debug_color);
+ graphics_gc_set_linewidth(debug_gc, 1);
+ }
+#endif
+
+ gui_internal_widget_pack(this,cur_widget);
+ gui_internal_widget_render(this,cur_widget);
+
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ if (visual_debug) {
+ struct point pnt[5];
+ pnt[0]=cur_widget->p;
+ pnt[1].x=pnt[0].x+cur_widget->w;
+ pnt[1].y=pnt[0].y;
+ pnt[2].x=pnt[0].x+cur_widget->w;
+ pnt[2].y=pnt[0].y+cur_widget->h;
+ pnt[3].x=pnt[0].x;
+ pnt[3].y=pnt[0].y+cur_widget->h;
+ pnt[4]=pnt[0];
+ graphics_draw_lines(this->gra, debug_gc, pnt, 5); /* Force highlighting table borders in debug more */
+ }
+#endif
+
+ if(dim->height > max_height) {
+ max_height = dim->height;
+ }
+ } else {
+ /* Deactivate contents that we don't have space for. */
+ if(this->hide_keys) {
+ cur_widget->state |= STATE_INVISIBLE;
+ cur_widget->state &= ~STATE_SENSITIVE;
+ } else {
+ cur_widget->state |= STATE_OFFSCREEN;
+ }
+ }
+ }
+
+ if (drawing_space_left) {
+ /* Row object should have its coordinates in actual
+ * state to be able to pass mouse clicks to Column objects
+ */
+ cur_row_widget->p.x=w->p.x;
+ cur_row_widget->w=w->w;
+ cur_row_widget->p.y=y;
+ cur_row_widget->h=max_height;
+ y = y + max_height;
+ table_data->bottom_row=cur_row;
+ current_desc = g_list_next(current_desc);
+ }
+ }
+
+ /* By default, hide all scroll buttons. */
+ if(this->hide_keys) {
+ table_data->scroll_buttons.next_button->state|= STATE_INVISIBLE;
+ table_data->scroll_buttons.prev_button->state|= STATE_INVISIBLE;
+ }
+ table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
+ table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
+
+ if(table_data->scroll_buttons.button_box && (!drawing_space_left || !is_first_page)
+ && !table_data->scroll_buttons.button_box_hide ) {
+ table_data->scroll_buttons.button_box->p.y =w->p.y+w->h-table_data->scroll_buttons.button_box->h -
+ this->spacing;
+ if(table_data->scroll_buttons.button_box->p.y < y ) {
+ table_data->scroll_buttons.button_box->p.y=y;
+ }
+ table_data->scroll_buttons.button_box->p.x = w->p.x;
+ table_data->scroll_buttons.button_box->w = w->w;
+ gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
+ if(table_data->scroll_buttons.next_button->p.y > w->p.y + w->h + table_data->scroll_buttons.next_button->h) {
+ table_data->scroll_buttons.button_box->p.y = w->p.y + w->h -
+ table_data->scroll_buttons.button_box->h;
+ }
+ if(!drawing_space_left) {
+ table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
+ table_data->scroll_buttons.next_button->state&= ~STATE_INVISIBLE;
+ }
+
+ if(table_data->top_row != w->children) {
+ table_data->scroll_buttons.prev_button->state|= STATE_SENSITIVE;
+ table_data->scroll_buttons.prev_button->state&= ~STATE_INVISIBLE;
+ }
+ gui_internal_widget_render(this,table_data->scroll_buttons.button_box);
+ }
+
+ /*
+ * Deallocate column descriptions.
+ */
+ g_list_foreach(column_desc,(GFunc)g_free,NULL);
+ g_list_free(column_desc);
}
/**
@@ -1410,37 +1491,32 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
* @param wm The button widget that was pressed.
* @param data
*/
-void
-gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data)
-{
- struct widget * table_widget=NULL;
- struct table_data * table_data = NULL;
-
- if(wm)
- table_widget = (struct widget * ) wm->data;
- else
- table_widget = data;
-
- if(table_widget && table_widget->type==widget_table)
- table_data = (struct table_data*) table_widget->data;
-
- if(table_data)
- {
- GList *l=g_list_next(table_data->bottom_row);
- if(l) {
- gui_internal_table_hide_rows(table_data);
- table_data->top_row=l;
- }
- }
-
- if(wm)
- wm->state&= ~STATE_HIGHLIGHTED;
-
- gui_internal_menu_render(this);
+void gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data) {
+ struct widget * table_widget=NULL;
+ struct table_data * table_data = NULL;
+
+ if(wm)
+ table_widget = (struct widget * ) wm->data;
+ else
+ table_widget = data;
+
+ if(table_widget && table_widget->type==widget_table)
+ table_data = (struct table_data*) table_widget->data;
+
+ if(table_data) {
+ GList *l=g_list_next(table_data->bottom_row);
+ if(l) {
+ gui_internal_table_hide_rows(table_data);
+ table_data->top_row=l;
+ }
+ }
+
+ if(wm)
+ wm->state&= ~STATE_HIGHLIGHTED;
+
+ gui_internal_menu_render(this);
}
-
-
/**
* @brief Handles the 'previous page' table event.
*
@@ -1450,36 +1526,34 @@ gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void
* @param this The graphics context.
* @param wm The button widget that was pressed.
*/
-void
-gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data)
-{
- struct widget * table_widget = NULL;
- struct table_data * table_data = NULL;
-
- if(wm)
- table_widget=(struct widget * ) wm->data;
- else
- table_widget=(struct widget * ) data;
-
- if(table_widget && table_widget->type==widget_table)
- table_data = (struct table_data*) table_widget->data;
-
- if(table_data) {
- int bottomy=table_widget->p.y+table_widget->h;
- int n;
- GList *top=table_data->top_row;
- struct widget *w=(struct widget*)top->data;
- if(table_data->scroll_buttons.button_box->p.y!=0) {
- bottomy=table_data->scroll_buttons.button_box->p.y;
- }
- n=(bottomy-w->p.y)/w->h;
- while(n-- > 0 && (top=g_list_previous(top))!=NULL);
- gui_internal_table_hide_rows(table_data);
- table_data->top_row=top;
- }
- if(wm)
- wm->state&= ~STATE_HIGHLIGHTED;
- gui_internal_menu_render(this);
+void gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data) {
+ struct widget * table_widget = NULL;
+ struct table_data * table_data = NULL;
+
+ if(wm)
+ table_widget=(struct widget * ) wm->data;
+ else
+ table_widget=(struct widget * ) data;
+
+ if(table_widget && table_widget->type==widget_table)
+ table_data = (struct table_data*) table_widget->data;
+
+ if(table_data) {
+ int bottomy=table_widget->p.y+table_widget->h;
+ int n;
+ GList *top=table_data->top_row;
+ struct widget *w=(struct widget*)top->data;
+ if(table_data->scroll_buttons.button_box->p.y!=0) {
+ bottomy=table_data->scroll_buttons.button_box->p.y;
+ }
+ n=(bottomy-w->p.y)/w->h;
+ while(n-- > 0 && (top=g_list_previous(top))!=NULL);
+ gui_internal_table_hide_rows(table_data);
+ table_data->top_row=top;
+ }
+ if(wm)
+ wm->state&= ~STATE_HIGHLIGHTED;
+ gui_internal_menu_render(this);
}
@@ -1491,7 +1565,6 @@ gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void
*
* @param p The table_data structure
*/
-void gui_internal_table_data_free(void * p)
-{
- g_free(p);
+void gui_internal_table_data_free(void * p) {
+ g_free(p);
}
diff --git a/navit/gui/internal/gui_internal_widget.h b/navit/gui/internal/gui_internal_widget.h
index 33f03e478..cc24cb44e 100644
--- a/navit/gui/internal/gui_internal_widget.h
+++ b/navit/gui/internal/gui_internal_widget.h
@@ -1,7 +1,7 @@
enum gui_internal_reason {
- gui_internal_reason_click=1,
- gui_internal_reason_keypress,
- gui_internal_reason_keypress_finish
+ gui_internal_reason_click=1,
+ gui_internal_reason_keypress,
+ gui_internal_reason_keypress_finish
};
//##############################################################################################################
@@ -10,96 +10,101 @@ enum gui_internal_reason {
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct widget {
- enum widget_type type;
- struct graphics_gc *background,*text_background;
- struct graphics_gc *foreground_frame;
- struct graphics_gc *foreground;
- char *text;
- struct graphics_image *img;
- /**
- * A function to be invoked on actions.
- * @li widget The widget that is receiving the button press.
- *
- */
- void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
- enum gui_internal_reason reason;
- int datai;
- void *data;
- /**
- * @brief A function to deallocate data
- */
- void (*data_free)(void *data);
+ enum widget_type type;
+ struct graphics_gc *background,*text_background;
+ struct graphics_gc *foreground_frame;
+ struct graphics_gc *foreground;
+ char *text;
+ struct graphics_image *img;
+ /**
+ * A function to be invoked on actions.
+ * @param widget The widget that is receiving the button press.
+ *
+ */
+ void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
+ /**
+ * A function to be invoked on resize or move
+ * @param widget The widget that is resized
+ */
+ void (*on_resize)(struct gui_priv *priv, struct widget *widget, void *data, int neww, int newh);
+ enum gui_internal_reason reason;
+ int datai;
+ void *data;
+ /**
+ * @brief A function to deallocate data
+ */
+ void (*data_free)(void *data);
- /**
- * @brief a function that will be called as the widget is being destroyed.
- * This function can act as a destructor for the widget. It allows for
- * on deallocation actions to be specified on a per widget basis.
- * This function will call g_free on the widget (if required).
- */
- void (*wfree) (struct gui_priv *this_, struct widget * w);
- char *prefix;
- char *name;
- char *speech;
- char *command;
- struct pcoord c;
- struct item item;
- int selection_id;
- int state;
- struct point p;
- int wmin,hmin;
- int w,h;
- int textw,texth;
- int font_idx;
- int bl,br,bt,bb,spx,spy;
- int border;
- int packed;
- /**
- * The number of widgets to layout horizontally when doing
- * a orientation_horizontal_vertical layout
- */
- int cols;
- enum flags flags;
- int flags2;
- void *instance;
- int (*set_attr)(void *, struct attr *);
- int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
- void (*remove_cb)(void *, struct callback *cb);
- struct callback *cb;
- struct attr on;
- struct attr off;
- int deflt;
- int is_on;
- int redraw;
- struct menu_data *menu_data;
- struct form *form;
- GList *children;
- struct widget *parent;
- struct scroll_buttons *scroll_buttons;
+ /**
+ * @brief a function that will be called as the widget is being destroyed.
+ * This function can act as a destructor for the widget. It allows for
+ * on deallocation actions to be specified on a per widget basis.
+ * This function will call g_free on the widget (if required).
+ */
+ void (*wfree) (struct gui_priv *this_, struct widget * w);
+ char *prefix;
+ char *name;
+ char *speech;
+ char *command;
+ struct pcoord c;
+ struct item item;
+ int selection_id;
+ int state;
+ struct point p;
+ int wmin,hmin;
+ int w,h;
+ int textw,texth;
+ int font_idx;
+ int bl,br,bt,bb,spx,spy;
+ int border;
+ int packed;
+ /**
+ * The number of widgets to layout horizontally when doing
+ * a orientation_horizontal_vertical layout
+ */
+ int cols;
+ enum flags flags;
+ int flags2;
+ void *instance;
+ int (*set_attr)(void *, struct attr *);
+ int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
+ void (*remove_cb)(void *, struct callback *cb);
+ struct callback *cb;
+ struct attr on;
+ struct attr off;
+ int deflt;
+ int is_on;
+ int redraw;
+ struct menu_data *menu_data;
+ struct form *form;
+ GList *children;
+ struct widget *parent;
+ struct scroll_buttons *scroll_buttons;
};
struct scroll_buttons {
- /**
- * Button box should not be displayed if button_box_hide is not zero.
- */
- int button_box_hide;
- /**
- * A container box that is the child of the table widget that contains+groups
- * the next and previous button.
- */
- struct widget * button_box;
- /**
- * A button widget to handle 'next page' requests
- */
- struct widget * next_button;
- /**
- * A button widget to handle 'previous page' requests.
- */
- struct widget * prev_button;
- /**
- * a pointer to the gui context.
- * This is needed by the free function to destroy the buttons.
- */
- struct gui_priv * this;
+ /**
+ * Button box should not be displayed if button_box_hide is not zero.
+ */
+ int button_box_hide;
+ /**
+ * A container box that is the child of the table widget that contains+groups
+ * the next and previous button.
+ */
+ struct widget * button_box;
+ /**
+ * A button widget to handle 'next page' requests
+ */
+ struct widget * next_button;
+ /**
+ * A button widget to handle 'previous page' requests.
+ */
+ struct widget * prev_button;
+ /**
+ * a pointer to the gui context.
+ * This is needed by the free function to destroy the buttons.
+ */
+ struct gui_priv * this;
};
/**
@@ -111,20 +116,19 @@ struct scroll_buttons {
* The table_data structure needs to be freed with data_free along with the widget.
*
*/
-struct table_data
-{
- /**
- * A GList pointer into a widget->children list that indicates the row
- * currently being rendered at the top of the table.
- */
- GList * top_row;
- /**
- * A Glist pointer into a widget->children list that indicates the row
- * currently being rendered at the bottom of the table.
- */
- GList * bottom_row;
+struct table_data {
+ /**
+ * A GList pointer into a widget->children list that indicates the row
+ * currently being rendered at the top of the table.
+ */
+ GList * top_row;
+ /**
+ * A Glist pointer into a widget->children list that indicates the row
+ * currently being rendered at the bottom of the table.
+ */
+ GList * bottom_row;
- struct scroll_buttons scroll_buttons;
+ struct scroll_buttons scroll_buttons;
};
@@ -133,18 +137,17 @@ struct table_data
*
*
*/
-struct table_column_desc
-{
+struct table_column_desc {
- /**
- * The computed height of a cell in the table.
- */
- int height;
+ /**
+ * The computed height of a cell in the table.
+ */
+ int height;
- /**
- * The computed width of a cell in the table.
- */
- int width;
+ /**
+ * The computed width of a cell in the table.
+ */
+ int width;
};
/* prototypes */
enum flags;
@@ -153,20 +156,28 @@ struct gui_priv;
struct point;
struct table_data;
struct widget;
+void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second);
+void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src);
struct widget *gui_internal_label_font_new(struct gui_priv *this, const char *text, int font);
struct widget *gui_internal_label_new(struct gui_priv *this, const char *text);
struct widget *gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth);
struct widget *gui_internal_image_new(struct gui_priv *this, struct graphics_image *image);
struct widget *gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags);
struct widget *gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags);
-struct widget *gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-struct widget *gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-struct widget *gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
+struct widget *gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font,
+ struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data),
+ void *data);
+struct widget *gui_internal_button_new_with_callback(struct gui_priv *this, const char *text,
+ struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data),
+ void *data);
+struct widget *gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image,
+ enum flags flags);
struct widget *gui_internal_find_widget(struct widget *wi, struct point *p, int flags);
void gui_internal_highlight_do(struct gui_priv *this, struct widget *found);
void gui_internal_highlight(struct gui_priv *this);
struct widget *gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label);
struct widget *gui_internal_box_new(struct gui_priv *this, enum flags flags);
+void gui_internal_box_resize(struct gui_priv *this, struct widget *w, void *data, int wnew, int hnew);
void gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w);
void gui_internal_widget_append(struct widget *parent, struct widget *child);
void gui_internal_widget_prepend(struct widget *parent, struct widget *child);
@@ -174,6 +185,7 @@ void gui_internal_widget_insert_sorted(struct widget *parent, struct widget *chi
void gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w);
void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w);
void gui_internal_widget_render(struct gui_priv *this, struct widget *w);
+void gui_internal_widget_resize(struct gui_priv *this, struct widget *w, int wnew, int hnew);
void gui_internal_widget_pack(struct gui_priv *this, struct widget *w);
struct widget *gui_internal_button_label(struct gui_priv *this, const char *label, int mode);
struct widget *gui_internal_widget_table_new(struct gui_priv *this, enum flags flags, int buttons);
diff --git a/navit/gui/qml/CMakeLists.txt b/navit/gui/qml/CMakeLists.txt
index 05456d9bd..4f2f4a8ce 100644
--- a/navit/gui/qml/CMakeLists.txt
+++ b/navit/gui/qml/CMakeLists.txt
@@ -11,13 +11,13 @@ QT4_GENERATE_MOC(guiProxy.h ${CMAKE_CURRENT_BINARY_DIR}/guiProxy.moc)
QT4_GENERATE_MOC(routeProxy.h ${CMAKE_CURRENT_BINARY_DIR}/routeProxy.moc)
QT4_GENERATE_MOC(gui_qml.cpp ${CMAKE_CURRENT_BINARY_DIR}/gui_qml.moc)
module_add_library(gui_qml gui_qml.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/proxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/ngqpoint.moc
- ${CMAKE_CURRENT_BINARY_DIR}/searchProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/bookmarksProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/vehicleProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/navitProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/guiProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/routeProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/gui_qml.moc
-)
+ ${CMAKE_CURRENT_BINARY_DIR}/proxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/ngqpoint.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/searchProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/bookmarksProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/vehicleProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/navitProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/guiProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/routeProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/gui_qml.moc
+ )
diff --git a/navit/gui/qml/bookmarksProxy.h b/navit/gui/qml/bookmarksProxy.h
index 03cbcbc88..8063a2058 100644
--- a/navit/gui/qml/bookmarksProxy.h
+++ b/navit/gui/qml/bookmarksProxy.h
@@ -51,7 +51,7 @@ public slots:
while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
QString label;
QString path;
-
+
if (item->type != type_bookmark && item->type != type_bookmark_folder) continue;
if (!item_attr_get(item, attr_label, &attr)) continue;
label=QString::fromLocal8Bit(attr.u.str);
@@ -72,7 +72,7 @@ public slots:
entries.appendChild(entry);
}
- dbg(lvl_info,"%s\n",retDoc.toString().toLocal8Bit().constData());
+ dbg(lvl_info,"%s",retDoc.toString().toLocal8Bit().constData());
return retDoc.toString();
}
QString AddFolder(QString description) {
@@ -144,7 +144,7 @@ public slots:
if (!item_attr_get(item, attr_label, &attr)) continue;
label=QString::fromLocal8Bit(attr.u.str);
- dbg(lvl_debug,"Bookmark is %s\n",bookmark.toStdString().c_str());
+ dbg(lvl_debug,"Bookmark is %s",bookmark.toStdString().c_str());
if (label.compare(bookmark)) continue;
item_coord_get(item, &c, 1);
if (this->object->currentPoint!=NULL) {
diff --git a/navit/gui/qml/guiProxy.h b/navit/gui/qml/guiProxy.h
index 7648eb5b3..ca46af09e 100644
--- a/navit/gui/qml/guiProxy.h
+++ b/navit/gui/qml/guiProxy.h
@@ -48,7 +48,7 @@ public:
//QDeclarativeExpression commandJS(this->object->guiWidget->rootContext(),QString(),qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
//commandJS.setSourceLocation("command.js",0);
//this->function=function;
- //commandJS.eval(qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
+ //commandJS.eval(qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
}
signals:
void widthSignal(int);
@@ -57,7 +57,7 @@ public slots:
void pushPage(QString page) {
returnPath.push_front(page);
}
- QString popPage() {
+ QString popPage() {
if (!returnPath.empty()) {
if (returnPath.length()>1) {
returnPath.pop_front();
diff --git a/navit/gui/qml/gui_qml.cpp b/navit/gui/qml/gui_qml.cpp
index 3efc719dd..8c6f232f8 100644
--- a/navit/gui/qml/gui_qml.cpp
+++ b/navit/gui/qml/gui_qml.cpp
@@ -36,48 +36,48 @@
#include "layout.h"
struct gui_priv {
- struct navit *nav;
- struct gui *gui;
- struct attr self;
- struct vehicle* currVehicle;
-
- //configuration items
- int fullscreen;
- int menu_on_map_click;
- int signal_on_map_click;
- int w;
- int h;
- char *source;
- char *skin;
- char* icon_src;
- int radius;
- int pitch;
- int lazy; //When TRUE - menu state will not be changed during map/menu switches, FALSE - menu will be always reset to main.qml
-
- //Interface stuff
- struct callback_list *cbl;
- QCoreApplication *app;
- struct window *win;
- struct graphics *gra;
- QWidget *mainWindow;
- QWidget *graphicsWidget;
- QDeclarativeView *guiWidget;
- QDeclarativeView *prevGuiWidget;
- QStackedLayout *switcherWidget;
- struct callback *button_cb;
- struct callback *motion_cb;
- struct callback *resize_cb;
- struct callback *keypress_cb;
- struct callback *window_closed_cb;
-
- //Proxy objects
- class NGQProxyGui* guiProxy;
- class NGQProxyNavit* navitProxy;
- class NGQProxyVehicle* vehicleProxy;
- class NGQProxySearch* searchProxy;
- class NGQProxyBookmarks* bookmarksProxy;
- class NGQProxyRoute* routeProxy;
- class NGQPoint* currentPoint;
+ struct navit *nav;
+ struct gui *gui;
+ struct attr self;
+ struct vehicle* currVehicle;
+
+ //configuration items
+ int fullscreen;
+ int menu_on_map_click;
+ int signal_on_map_click;
+ int w;
+ int h;
+ char *source;
+ char *skin;
+ char* icon_src;
+ int radius;
+ int pitch;
+ int lazy; //When TRUE - menu state will not be changed during map/menu switches, FALSE - menu will be always reset to main.qml
+
+ //Interface stuff
+ struct callback_list *cbl;
+ QCoreApplication *app;
+ struct window *win;
+ struct graphics *gra;
+ QWidget *mainWindow;
+ QWidget *graphicsWidget;
+ QDeclarativeView *guiWidget;
+ QDeclarativeView *prevGuiWidget;
+ QStackedLayout *switcherWidget;
+ struct callback *button_cb;
+ struct callback *motion_cb;
+ struct callback *resize_cb;
+ struct callback *keypress_cb;
+ struct callback *window_closed_cb;
+
+ //Proxy objects
+ class NGQProxyGui* guiProxy;
+ class NGQProxyNavit* navitProxy;
+ class NGQProxyVehicle* vehicleProxy;
+ class NGQProxySearch* searchProxy;
+ class NGQProxyBookmarks* bookmarksProxy;
+ class NGQProxyRoute* routeProxy;
+ class NGQPoint* currentPoint;
};
#include "proxy.h"
@@ -90,386 +90,371 @@ struct gui_priv {
#include "guiProxy.h"
//Main window class for resizeEvent handling
-#ifdef Q_WS_X11
+#ifdef Q_WS_X11
#include <QX11EmbedWidget>
-class NGQMainWindow : public QX11EmbedWidget
-{
+class NGQMainWindow : public QX11EmbedWidget {
#else
-class NGQMainWindow : public QWidget
-{
+class NGQMainWindow : public QWidget {
#endif /* Q_WS_X11 */
public:
-#ifdef Q_WS_X11
- NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QX11EmbedWidget(parent) {
+#ifdef Q_WS_X11
+ NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QX11EmbedWidget(parent) {
#else
- NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QWidget(parent) {
+ NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QWidget(parent) {
#endif /* Q_WS_X11 */
- this->object=this_;
- }
+ this->object=this_;
+ }
protected:
- void resizeEvent(QResizeEvent *) {
- this->object->w=this->width();
- this->object->h=this->height();
- //YES, i KNOW about signal/slot thing
- this->object->guiProxy->setWidth(this->width());
- this->object->guiProxy->setHeight(this->height());
- }
- void closeEvent(QCloseEvent* event) {
- this->object->graphicsWidget->close();
- }
+ void resizeEvent(QResizeEvent *) {
+ this->object->w=this->width();
+ this->object->h=this->height();
+ //YES, i KNOW about signal/slot thing
+ this->object->guiProxy->setWidth(this->width());
+ this->object->guiProxy->setHeight(this->height());
+ }
+ void closeEvent(QCloseEvent* event) {
+ this->object->graphicsWidget->close();
+ }
private:
- struct gui_priv* object;
+ struct gui_priv* object;
};
//Meta object
#include "gui_qml.moc"
-static void gui_qml_dbus_signal(struct gui_priv *this_, struct point *p)
-{
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct displayitem *di;
-
- display=navit_get_displaylist(this_->nav);
- dlh=graphics_displaylist_open(display);
- while ((di=graphics_displaylist_next(dlh))) {
- struct item *item=graphics_displayitem_get_item(di);
- if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
- graphics_displayitem_within_dist(display, di, p, 10)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- struct attr attr;
- if (item_attr_get(itemo, attr_data, &attr)) {
- struct attr cb,*attr_list[2];
- int valid=0;
- attr.type=attr_data;
- attr_list[0]=&attr;
- attr_list[1]=NULL;
- if (navit_get_attr(this_->nav, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
- }
- map_rect_destroy(mr);
- }
- }
- graphics_displaylist_close(dlh);
+static void gui_qml_dbus_signal(struct gui_priv *this_, struct point *p) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct displayitem *di;
+
+ display=navit_get_displaylist(this_->nav);
+ dlh=graphics_displaylist_open(display);
+ while ((di=graphics_displaylist_next(dlh))) {
+ struct item *item=graphics_displayitem_get_item(di);
+ if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
+ graphics_displayitem_within_dist(display, di, p, 10)) {
+ struct map_rect *mr=map_rect_new(item->map, NULL);
+ struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ struct attr attr;
+ if (item_attr_get(itemo, attr_data, &attr)) {
+ struct attr cb,*attr_list[2];
+ int valid=0;
+ attr.type=attr_data;
+ attr_list[0]=&attr;
+ attr_list[1]=NULL;
+ if (navit_get_attr(this_->nav, attr_callback_list, &cb, NULL))
+ callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+ }
+ map_rect_destroy(mr);
+ }
+ }
+ graphics_displaylist_close(dlh);
}
-static void gui_qml_button(void *data, int pressed, int button, struct point *p)
-{
- struct gui_priv *this_=(struct gui_priv*)data;
-
- // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
- if (!navit_handle_button(this_->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug,"navit has handled button\n");
- return;
- }
-
- dbg(lvl_debug,"enter %d %d\n", pressed, button);
- if (this_->signal_on_map_click) {
- gui_qml_dbus_signal(this_, p);
- return;
- }
-
- if ( button == 1 && this_->menu_on_map_click ) {
- this_->guiProxy->switchToMenu(p);
- }
+static void gui_qml_button(void *data, int pressed, int button, struct point *p) {
+ struct gui_priv *this_=(struct gui_priv*)data;
+
+ // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
+ if (!navit_handle_button(this_->nav, pressed, button, p, NULL)) {
+ dbg(lvl_debug,"navit has handled button");
+ return;
+ }
+
+ dbg(lvl_debug,"enter %d %d", pressed, button);
+ if (this_->signal_on_map_click) {
+ gui_qml_dbus_signal(this_, p);
+ return;
+ }
+
+ if ( button == 1 && this_->menu_on_map_click ) {
+ this_->guiProxy->switchToMenu(p);
+ }
}
-static void gui_qml_motion(void *data, struct point *p)
-{
- struct gui_priv *this_=(struct gui_priv*)data;
- navit_handle_motion(this_->nav, p);
- return;
+static void gui_qml_motion(void *data, struct point *p) {
+ struct gui_priv *this_=(struct gui_priv*)data;
+ navit_handle_motion(this_->nav, p);
+ return;
}
-static void gui_qml_resize(void *data, int w, int h)
-{
- struct gui_priv *this_=(struct gui_priv*)data;
- navit_handle_resize(this_->nav, w, h);
+static void gui_qml_resize(void *data, int w, int h) {
+ struct gui_priv *this_=(struct gui_priv*)data;
+ navit_handle_resize(this_->nav, w, h);
}
-static void gui_qml_keypress(void *data, char *key)
-{
- struct gui_priv *this_=(struct gui_priv*) data;
- int w,h;
- struct point p;
- transform_get_size(navit_get_trans(this_->nav), &w, &h);
- switch (*key) {
- case NAVIT_KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_ZOOM_IN:
- navit_zoom_in(this_->nav, 2, NULL);
- break;
- case NAVIT_KEY_ZOOM_OUT:
- navit_zoom_out(this_->nav, 2, NULL);
- break;
- case NAVIT_KEY_RETURN:
- case NAVIT_KEY_MENU:
- p.x=w/2;
- p.y=h/2;
- this_->guiProxy->switchToMenu(&p);
- break;
- }
- return;
+static void gui_qml_keypress(void *data, char *key) {
+ struct gui_priv *this_=(struct gui_priv*) data;
+ int w,h;
+ struct point p;
+ transform_get_size(navit_get_trans(this_->nav), &w, &h);
+ switch (*key) {
+ case NAVIT_KEY_UP:
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_DOWN:
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_LEFT:
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_RIGHT:
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_ZOOM_IN:
+ navit_zoom_in(this_->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_ZOOM_OUT:
+ navit_zoom_out(this_->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_RETURN:
+ case NAVIT_KEY_MENU:
+ p.x=w/2;
+ p.y=h/2;
+ this_->guiProxy->switchToMenu(&p);
+ break;
+ }
+ return;
}
-static void
-gui_qml_window_closed(struct gui_priv *data)
-{
- struct gui_priv *this_=(struct gui_priv*) data;
- this_->navitProxy->quit();
+static void gui_qml_window_closed(struct gui_priv *data) {
+ struct gui_priv *this_=(struct gui_priv*) data;
+ this_->navitProxy->quit();
}
//GUI interface calls
static int argc=1;
-static char *argv[]={(char *)"navit",NULL};
-
-static int gui_qml_set_graphics(struct gui_priv *this_, struct graphics *gra)
-{
- QString xid;
- NGQMainWindow* _mainWindow;
- bool ok;
-
- this_->gra=gra;
-
- //Check if we are already in Qt environment
- if (QApplication::instance()==NULL) {
- //Not yet
- this_->app=new QApplication(argc,argv);
- } else {
- this_->app=QApplication::instance();
- }
-
- //Link graphics events
- this_->button_cb=callback_new_attr_1(callback_cast(gui_qml_button), attr_button, this_);
- graphics_add_callback(gra, this_->button_cb);
- this_->motion_cb=callback_new_attr_1(callback_cast(gui_qml_motion), attr_motion, this_);
- graphics_add_callback(gra, this_->motion_cb);
- this_->resize_cb=callback_new_attr_1(callback_cast(gui_qml_resize), attr_resize, this_);
- graphics_add_callback(gra, this_->resize_cb);
- this_->keypress_cb=callback_new_attr_1(callback_cast(gui_qml_keypress), attr_keypress, this_);
- graphics_add_callback(gra, this_->keypress_cb);
- this_->window_closed_cb=callback_new_attr_1(callback_cast(gui_qml_window_closed), attr_window_closed, this_);
- graphics_add_callback(gra, this_->window_closed_cb);
-
-
- //Create main window
- this_->switcherWidget = new QStackedLayout();
- _mainWindow = new NGQMainWindow(this_, NULL);
+static char *argv[]= {(char *)"navit",NULL};
+
+static int gui_qml_set_graphics(struct gui_priv *this_, struct graphics *gra) {
+ QString xid;
+ NGQMainWindow* _mainWindow;
+ bool ok;
+
+ this_->gra=gra;
+
+ //Check if we are already in Qt environment
+ if (QApplication::instance()==NULL) {
+ //Not yet
+ this_->app=new QApplication(argc,argv);
+ } else {
+ this_->app=QApplication::instance();
+ }
+
+ //Link graphics events
+ this_->button_cb=callback_new_attr_1(callback_cast(gui_qml_button), attr_button, this_);
+ graphics_add_callback(gra, this_->button_cb);
+ this_->motion_cb=callback_new_attr_1(callback_cast(gui_qml_motion), attr_motion, this_);
+ graphics_add_callback(gra, this_->motion_cb);
+ this_->resize_cb=callback_new_attr_1(callback_cast(gui_qml_resize), attr_resize, this_);
+ graphics_add_callback(gra, this_->resize_cb);
+ this_->keypress_cb=callback_new_attr_1(callback_cast(gui_qml_keypress), attr_keypress, this_);
+ graphics_add_callback(gra, this_->keypress_cb);
+ this_->window_closed_cb=callback_new_attr_1(callback_cast(gui_qml_window_closed), attr_window_closed, this_);
+ graphics_add_callback(gra, this_->window_closed_cb);
+
+
+ //Create main window
+ this_->switcherWidget = new QStackedLayout();
+ _mainWindow = new NGQMainWindow(this_, NULL);
#ifdef Q_WS_X11
- xid=getenv("NAVIT_XID");
- if (xid.length()>0) {
- _mainWindow->embedInto(xid.toULong(&ok,0));
- }else{
- dbg(lvl_error, "\nFATAL: Environment variable NAVIT_XID not set.\n"
- " Please set NAVIT_XID to the window ID of the window to embed into.\n");
- exit(1);
- }
+ xid=getenv("NAVIT_XID");
+ if (xid.length()>0) {
+ _mainWindow->embedInto(xid.toULong(&ok,0));
+ } else {
+ dbg(lvl_error, "FATAL: Environment variable NAVIT_XID not set."
+ " Please set NAVIT_XID to the window ID of the window to embed into.\n");
+ exit(1);
+ }
#endif /* Q_WS_X11 */
- this_->mainWindow=_mainWindow;
- if ( this_->w && this_->h ) {
- this_->mainWindow->resize(this_->w,this_->h);
- }
- if ( this_->fullscreen ) {
- this_->mainWindow->showFullScreen();
- }
-
- this_->mainWindow->setLayout(this_->switcherWidget);
-
- //Create proxy object and bind them to gui widget
- this_->guiProxy = new NGQProxyGui(this_,this_->mainWindow);
- this_->navitProxy = new NGQProxyNavit(this_,this_->mainWindow);
- this_->vehicleProxy = new NGQProxyVehicle(this_,this_->mainWindow);
- this_->searchProxy = new NGQProxySearch(this_,this_->mainWindow);
- this_->bookmarksProxy = new NGQProxyBookmarks(this_,this_->mainWindow);
- this_->routeProxy = new NGQProxyRoute(this_,this_->mainWindow);
-
- //Check, if we have compatible graphics
- this_->graphicsWidget = (QWidget*)graphics_get_data(gra,"qt_widget");
- if (this_->graphicsWidget == NULL ) {
- this_->graphicsWidget = new QLabel(QString("Sorry, current graphics type is incompatible with this gui."));
- }
+ this_->mainWindow=_mainWindow;
+ if ( this_->w && this_->h ) {
+ this_->mainWindow->resize(this_->w,this_->h);
+ }
+ if ( this_->fullscreen ) {
+ this_->mainWindow->showFullScreen();
+ }
+
+ this_->mainWindow->setLayout(this_->switcherWidget);
+
+ //Create proxy object and bind them to gui widget
+ this_->guiProxy = new NGQProxyGui(this_,this_->mainWindow);
+ this_->navitProxy = new NGQProxyNavit(this_,this_->mainWindow);
+ this_->vehicleProxy = new NGQProxyVehicle(this_,this_->mainWindow);
+ this_->searchProxy = new NGQProxySearch(this_,this_->mainWindow);
+ this_->bookmarksProxy = new NGQProxyBookmarks(this_,this_->mainWindow);
+ this_->routeProxy = new NGQProxyRoute(this_,this_->mainWindow);
+
+ //Check, if we have compatible graphics
+ this_->graphicsWidget = (QWidget*)graphics_get_data(gra,"qt_widget");
+ if (this_->graphicsWidget == NULL ) {
+ this_->graphicsWidget = new QLabel(QString("Sorry, current graphics type is incompatible with this gui."));
+ }
this_->switcherWidget->addWidget(this_->graphicsWidget);
-
- //Instantiate qml components
+
+ //Instantiate qml components
this_->guiWidget = new QDeclarativeView(NULL);
- this_->guiWidget->setResizeMode(QDeclarativeView::SizeRootObjectToView);
-
- this_->guiWidget->rootContext()->setContextProperty("gui",this_->guiProxy);
- this_->guiWidget->rootContext()->setContextProperty("navit",this_->navitProxy);
- this_->guiWidget->rootContext()->setContextProperty("vehicle",this_->vehicleProxy);
- this_->guiWidget->rootContext()->setContextProperty("search",this_->searchProxy);
- this_->guiWidget->rootContext()->setContextProperty("bookmarks",this_->bookmarksProxy);
- this_->guiWidget->rootContext()->setContextProperty("route",this_->routeProxy);
- this_->guiWidget->rootContext()->setContextProperty("point",this_->currentPoint);
-
- QString mainQml = QString(this_->source)+"/"+this_->skin+"/main.qml";
- if (!QFile(mainQml).exists()){
- dbg(lvl_error, "FATAL: QML file %s not found. Navit is not installed correctly.\n", mainQml.toAscii().constData());
- exit(1);
- }
- this_->guiWidget->setSource(QUrl::fromLocalFile(mainQml));
- this_->switcherWidget->addWidget(this_->guiWidget);
-
- //Switch to graphics
- navit_draw(this_->nav);
- this_->switcherWidget->setCurrentWidget(this_->graphicsWidget);
-
- this_->mainWindow->show();
-
- return 0;
+ this_->guiWidget->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+
+ this_->guiWidget->rootContext()->setContextProperty("gui",this_->guiProxy);
+ this_->guiWidget->rootContext()->setContextProperty("navit",this_->navitProxy);
+ this_->guiWidget->rootContext()->setContextProperty("vehicle",this_->vehicleProxy);
+ this_->guiWidget->rootContext()->setContextProperty("search",this_->searchProxy);
+ this_->guiWidget->rootContext()->setContextProperty("bookmarks",this_->bookmarksProxy);
+ this_->guiWidget->rootContext()->setContextProperty("route",this_->routeProxy);
+ this_->guiWidget->rootContext()->setContextProperty("point",this_->currentPoint);
+
+ QString mainQml = QString(this_->source)+"/"+this_->skin+"/main.qml";
+ if (!QFile(mainQml).exists()) {
+ dbg(lvl_error, "FATAL: QML file %s not found. Navit is not installed correctly.", mainQml.toAscii().constData());
+ exit(1);
+ }
+ this_->guiWidget->setSource(QUrl::fromLocalFile(mainQml));
+ this_->switcherWidget->addWidget(this_->guiWidget);
+
+ //Switch to graphics
+ navit_draw(this_->nav);
+ this_->switcherWidget->setCurrentWidget(this_->graphicsWidget);
+
+ this_->mainWindow->show();
+
+ return 0;
}
-static int
-gui_qml_get_attr(struct gui_priv *this_, enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_fullscreen:
- attr->u.num=this_->fullscreen;
- break;
- case attr_skin:
- attr->u.str=this_->skin;
- break;
- case attr_pitch:
- attr->u.num=this_->pitch;
- break;
- case attr_radius:
- attr->u.num=this_->radius;
- break;
- default:
- return 0;
- }
- attr->type=type;
- return 1;
+static int gui_qml_get_attr(struct gui_priv *this_, enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_fullscreen:
+ attr->u.num=this_->fullscreen;
+ break;
+ case attr_skin:
+ attr->u.str=this_->skin;
+ break;
+ case attr_pitch:
+ attr->u.num=this_->pitch;
+ break;
+ case attr_radius:
+ attr->u.num=this_->radius;
+ break;
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return 1;
}
-static int
-gui_qml_set_attr(struct gui_priv *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_fullscreen:
- if (!(this_->fullscreen) && (attr->u.num)) {
- this_->mainWindow->showFullScreen();
- }
- if ((this_->fullscreen) && !(attr->u.num)) {
- this_->mainWindow->showNormal();
- }
- this_->fullscreen=attr->u.num;
- return 1;
- case attr_pitch:
- this_->pitch=attr->u.num;
- return 1;
- case attr_radius:
- this_->radius=attr->u.num;
- return 1;
- default:
- dbg(lvl_error,"unknown attr: %s\n",attr_to_name(attr->type));
- return 1;
- }
+static int gui_qml_set_attr(struct gui_priv *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_fullscreen:
+ if (!(this_->fullscreen) && (attr->u.num)) {
+ this_->mainWindow->showFullScreen();
+ }
+ if ((this_->fullscreen) && !(attr->u.num)) {
+ this_->mainWindow->showNormal();
+ }
+ this_->fullscreen=attr->u.num;
+ return 1;
+ case attr_pitch:
+ this_->pitch=attr->u.num;
+ return 1;
+ case attr_radius:
+ this_->radius=attr->u.num;
+ return 1;
+ default:
+ dbg(lvl_error,"unknown attr: %s",attr_to_name(attr->type));
+ return 1;
+ }
}
struct gui_methods gui_qml_methods = {
- NULL,
- NULL,
+ NULL,
+ NULL,
gui_qml_set_graphics,
- NULL,
- NULL,
- NULL,
- NULL,
- gui_qml_get_attr,
- NULL,
- gui_qml_set_attr,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ gui_qml_get_attr,
+ NULL,
+ gui_qml_set_attr,
};
-static void
-gui_qml_command(struct gui_priv *this_, char *function, struct attr **in, struct attr ***out, int *valid) {
- this_->guiProxy->processCommand(function);
+static void gui_qml_command(struct gui_priv *this_, char *function, struct attr **in, struct attr ***out, int *valid) {
+ this_->guiProxy->processCommand(function);
}
static struct command_table commands[] = {
- {"*",command_cast(gui_qml_command)},
+ {"*",command_cast(gui_qml_command)},
};
-static struct gui_priv * gui_qml_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct gui_priv *this_;
- struct attr *attr;
- *meth=gui_qml_methods;
- this_=g_new0(struct gui_priv, 1);
-
- this_->nav=nav;
- this_->gui=gui;
-
- this_->self.type=attr_gui;
- this_->self.u.gui=gui;
-
- navit_ignore_graphics_events(this_->nav, 1);
-
- this_->fullscreen = 0; //NO by default
- if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
- this_->fullscreen=attr->u.num;
- this_->menu_on_map_click = 1; //YES by default;
- if( (attr=attr_search(attrs,NULL,attr_menu_on_map_click)))
- this_->menu_on_map_click=attr->u.num;
- this_->signal_on_map_click = 0; //YES by default;
- if( (attr=attr_search(attrs,NULL,attr_signal_on_map_click)))
- this_->signal_on_map_click=attr->u.num;
- this_->radius = 10; //Default value
- if( (attr=attr_search(attrs,NULL,attr_radius)))
- this_->radius=attr->u.num;
- this_->pitch = 20; //Default value
- if( (attr=attr_search(attrs,NULL,attr_pitch)))
- this_->pitch=attr->u.num;
- this_->lazy = 1; //YES by default
- if( (attr=attr_search(attrs,NULL,attr_lazy)))
- this_->lazy=attr->u.num;
- this_->w=800; //Default value
- if( (attr=attr_search(attrs,NULL,attr_width)))
- this_->w=attr->u.num;
- this_->h=600; //Default value
- if( (attr=attr_search(attrs,NULL,attr_height)))
- this_->h=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_source)))
- this_->source=attr->u.str;
- if( (attr=attr_search(attrs,NULL,attr_skin)))
- this_->skin=attr->u.str;
- if( (attr=attr_search(attrs,NULL,attr_icon_src)))
- this_->icon_src=attr->u.str;
-
- if ( this_->source==NULL ) {
- this_->source=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/gui/qml/skins",NULL);
- }
- if ( this_->skin==NULL ) {
- this_->skin=g_strdup("navit");
- }
- if ( this_->icon_src==NULL ) {
- this_->icon_src=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/icons/",NULL);
- }
-
- if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
- command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this_);
- }
-
- this_->cbl=callback_list_new();
-
- return this_;
+static struct gui_priv * gui_qml_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs,
+ struct gui *gui) {
+ struct gui_priv *this_;
+ struct attr *attr;
+ *meth=gui_qml_methods;
+ this_=g_new0(struct gui_priv, 1);
+
+ this_->nav=nav;
+ this_->gui=gui;
+
+ this_->self.type=attr_gui;
+ this_->self.u.gui=gui;
+
+ navit_ignore_graphics_events(this_->nav, 1);
+
+ this_->fullscreen = 0; //NO by default
+ if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
+ this_->fullscreen=attr->u.num;
+ this_->menu_on_map_click = 1; //YES by default;
+ if( (attr=attr_search(attrs,NULL,attr_menu_on_map_click)))
+ this_->menu_on_map_click=attr->u.num;
+ this_->signal_on_map_click = 0; //YES by default;
+ if( (attr=attr_search(attrs,NULL,attr_signal_on_map_click)))
+ this_->signal_on_map_click=attr->u.num;
+ this_->radius = 10; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_radius)))
+ this_->radius=attr->u.num;
+ this_->pitch = 20; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_pitch)))
+ this_->pitch=attr->u.num;
+ this_->lazy = 1; //YES by default
+ if( (attr=attr_search(attrs,NULL,attr_lazy)))
+ this_->lazy=attr->u.num;
+ this_->w=800; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_width)))
+ this_->w=attr->u.num;
+ this_->h=600; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_height)))
+ this_->h=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_source)))
+ this_->source=attr->u.str;
+ if( (attr=attr_search(attrs,NULL,attr_skin)))
+ this_->skin=attr->u.str;
+ if( (attr=attr_search(attrs,NULL,attr_icon_src)))
+ this_->icon_src=attr->u.str;
+
+ if ( this_->source==NULL ) {
+ this_->source=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/gui/qml/skins",NULL);
+ }
+ if ( this_->skin==NULL ) {
+ this_->skin=g_strdup("navit");
+ }
+ if ( this_->icon_src==NULL ) {
+ this_->icon_src=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/icons/",NULL);
+ }
+
+ if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
+ command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this_);
+ }
+
+ this_->cbl=callback_list_new();
+
+ return this_;
}
void plugin_init(void) {
diff --git a/navit/gui/qml/navitProxy.h b/navit/gui/qml/navitProxy.h
index 423863b0e..d3f8a0e86 100644
--- a/navit/gui/qml/navitProxy.h
+++ b/navit/gui/qml/navitProxy.h
@@ -51,7 +51,7 @@ public slots:
while (getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr, iter) ) {
QStandardItem* curItem=new QStandardItem();
- //Listed attributes are usualy have very complex structure
+ //Listed attributes are usualy have very complex structure
if (attr.type==attr_layout) {
curItem->setData(QVariant(counter),NGQStandardItemModel::ItemId);
curItem->setData(QVariant(attr.u.layout->name),NGQStandardItemModel::ItemName);
diff --git a/navit/gui/qml/ngqpoint.h b/navit/gui/qml/ngqpoint.h
index 05142e5bf..14aaddc61 100644
--- a/navit/gui/qml/ngqpoint.h
+++ b/navit/gui/qml/ngqpoint.h
@@ -94,7 +94,7 @@ public:
this->c.x = c->x;
this->c.y = c->y;
this->type=type;
-
+
this->name=name;
this->coord=this->_coordString();
}
@@ -116,7 +116,7 @@ public slots:
this->coord=this->_coordString();
}
QString pointName() {
- return this->name;
+ return this->name;
}
QString coordString() {
return this->coord;
@@ -248,7 +248,7 @@ public slots:
}
map_selection_destroy(sel);
mapset_close(h);
- dbg(lvl_info,"%s\n",retDoc.toString().toLocal8Bit().constData());
+ dbg(lvl_info,"%s",retDoc.toString().toLocal8Bit().constData());
return retDoc.toString();
}
protected:
@@ -311,12 +311,12 @@ protected:
mr=map_rect_new(m, &sel);
if (! mr)
continue;
- while ((item=map_rect_get_item(mr))) {
+ while ((item=map_rect_get_item(mr))) {
data=street_get_data(item);
- if (transform_within_dist_item(&co, item->type, data->c, data->count, dist)) {
+ if (transform_within_dist_item(&co, item->type, data->c, data->count, dist)) {
if (item_attr_get(item, attr_label, &attr)) {
label=map_convert_string(m, attr.u.str);
- this->item=*item;
+ this->item=*item;
this->_setUrl(item);
if (QString(item_to_name(item->type)).startsWith(QString("poi_"))) {
ret=QString::fromLocal8Bit(item_to_name(item->type));
diff --git a/navit/gui/qml/proxy.h b/navit/gui/qml/proxy.h
index 3243dc8cb..ebdb0667a 100644
--- a/navit/gui/qml/proxy.h
+++ b/navit/gui/qml/proxy.h
@@ -35,7 +35,7 @@ public slots:
QString getAttr(const QString &attr_name) {
QString ret;
struct attr attr;
-
+
getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr, NULL);
if (ATTR_IS_INT(attr.type)) {
ret.setNum(attr.u.num);
@@ -55,7 +55,7 @@ public slots:
struct attr attr_value;
double *helper;
- dbg(lvl_debug,"Setting %s to %s\n",attr_name.toStdString().c_str(),attr_string.toStdString().c_str());
+ dbg(lvl_debug,"Setting %s to %s",attr_name.toStdString().c_str(),attr_string.toStdString().c_str());
getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr_value, NULL);
if (ATTR_IS_INT(attr_value.type)) {
@@ -81,7 +81,7 @@ public slots:
return;
}
-
+
int itemId() {
return _itemId;
}
diff --git a/navit/gui/qml/routeProxy.h b/navit/gui/qml/routeProxy.h
index a2fb4c793..fb76c492c 100644
--- a/navit/gui/qml/routeProxy.h
+++ b/navit/gui/qml/routeProxy.h
@@ -14,13 +14,13 @@ public slots:
QList<struct attr> destinations=this->_routeDestinations();
struct pcoord *coords=(struct pcoord*)malloc(sizeof(struct pcoord)*(destinations.size()+1)); //Additional destination included
- for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
+ for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
coords[counter]=*(iter->u.pcoord);
counter++;
}
//Add new one
- coords[counter]=*(this->object->currentPoint->pc());
+ coords[counter]=*(this->object->currentPoint->pc());
//Propagate to route engine
route_set_destinations(navit_get_route(this->object->nav),coords,counter+1,1);
@@ -30,7 +30,7 @@ public slots:
QList<struct attr> destinations=this->_routeDestinations();
for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
NGQPoint helperPoint(this->object,iter->u.pcoord,MapPoint);
- dbg(lvl_debug,"Added destination %s\n",helperPoint.coordString().toLocal8Bit().constData());
+ dbg(lvl_debug,"Added destination %s",helperPoint.coordString().toLocal8Bit().constData());
}
//dbg(lvl_debug,QString::number(_itemId).toStdString().c_str());
diff --git a/navit/gui/qml/searchProxy.h b/navit/gui/qml/searchProxy.h
index 579ac3dac..3d76dc0dd 100644
--- a/navit/gui/qml/searchProxy.h
+++ b/navit/gui/qml/searchProxy.h
@@ -33,7 +33,7 @@ public:
item=country_search_get_item(cs);
if (item && item_attr_get(item, attr_country_name, &country_name)) {
search_attr.type=attr_country_all;
- dbg(lvl_debug,"country %s\n", country_name.u.str);
+ dbg(lvl_debug,"country %s", country_name.u.str);
this->country_name=QString::fromLocal8Bit(country_name.u.str);
search_attr.u.str=country_name.u.str;
search_list_search(this->sl, &search_attr, 0);
@@ -44,15 +44,15 @@ public:
}
country_search_destroy(cs);
} else {
- dbg(lvl_error,"warning: no default country found\n");
+ dbg(lvl_error,"warning: no default country found");
if (!this->country_iso2.isEmpty()) {
- dbg(lvl_debug,"attempting to use country '%s'\n",this->country_iso2.toStdString().c_str());
+ dbg(lvl_debug,"attempting to use country '%s'",this->country_iso2.toStdString().c_str());
search_attr.type=attr_country_iso2;
search_attr.u.str=(char*)this->country_iso2.toStdString().c_str();
search_list_search(this->sl, &search_attr, 0);
while((res=search_list_get_result(this->sl)));
}
- }
+ }
}
~NGQProxySearch() {
search_list_destroy(this->sl);
@@ -131,7 +131,7 @@ public slots:
}
if (res->town->common.district_name) {
entry.appendChild(this->_fieldValueHelper(retDoc,QString("name"), QString::fromLocal8Bit(res->town->common.district_name)));
- }
+ }
}
if (this->search_context=="street") {
entry.appendChild(this->_fieldValueHelper(retDoc,QString("id"), QString::number(counter)));
@@ -150,8 +150,8 @@ public slots:
this->country_name=countryName;
struct attr attr;
struct search_list_result *res;
-
- //We need to update ISO2
+
+ //We need to update ISO2
attr.type=attr_country_name;
attr.u.str=countryName.toLocal8Bit().data();
search_list_search(this->sl,&attr,0);
@@ -183,7 +183,7 @@ public slots:
attr.type=attr_town_or_district_name;
attr.u.str=townName.toLocal8Bit().data();
search_list_search(this->sl,&attr,0);
-
+
//...and street
this->street_name="";
diff --git a/navit/gui/qml/skins/navit/ButtonIcon.qml b/navit/gui/qml/skins/navit/ButtonIcon.qml
index f969ebb5a..6e0f8f032 100644
--- a/navit/gui/qml/skins/navit/ButtonIcon.qml
+++ b/navit/gui/qml/skins/navit/ButtonIcon.qml
@@ -1,40 +1,40 @@
-import Qt 4.7
-
-Rectangle {
+import Qt 4.7
+
+Rectangle {
id: container
-
- signal clicked
- property string text: "Button"
- property string icon: "Icon.png"
-
- color: "black"; smooth: true; opacity: 0.75
- width: imgItem.width+20; height: txtItem.height + 6 + imgItem.height;
- transformOrigin: Rectangle.Center;
-
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
-
- Image {
- id: imgItem; source: gui.iconPath+container.icon; anchors.top: container.top; anchors.horizontalCenter: container.horizontalCenter;
- width: gui.height/4; height: gui.height/4
- }
-
- Text {
- id: txtItem; text: container.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: container.horizontalCenter;
- color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
- }
-
- states: [
- State {
- name: "Pressed"; when: mr.pressed == true
- PropertyChanges { target: container; scale: 2.0 }
- PropertyChanges { target: container; opacity: 1 }
-
- }
- ]
-
- transitions: Transition {
- NumberAnimation { properties: "scale"; easing.type: "OutExpo"; duration: 200 }
- NumberAnimation { properties: "opacity"; easing.type: "InQuad"; duration: 200 }
- }
-
-}
+
+ signal clicked
+ property string text: "Button"
+ property string icon: "Icon.png"
+
+ color: "black"; smooth: true; opacity: 0.75
+ width: imgItem.width+20; height: txtItem.height + 6 + imgItem.height;
+ transformOrigin: Rectangle.Center;
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Image {
+ id: imgItem; source: gui.iconPath+container.icon; anchors.top: container.top; anchors.horizontalCenter: container.horizontalCenter;
+ width: gui.height/4; height: gui.height/4
+ }
+
+ Text {
+ id: txtItem; text: container.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: container.horizontalCenter;
+ color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
+ }
+
+ states: [
+ State {
+ name: "Pressed"; when: mr.pressed == true
+ PropertyChanges { target: container; scale: 2.0 }
+ PropertyChanges { target: container; opacity: 1 }
+
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; easing.type: "OutExpo"; duration: 200 }
+ NumberAnimation { properties: "opacity"; easing.type: "InQuad"; duration: 200 }
+ }
+
+}
diff --git a/navit/gui/qml/skins/navit/Cellar.qml b/navit/gui/qml/skins/navit/Cellar.qml
index de4d3c146..89ecfc899 100644
--- a/navit/gui/qml/skins/navit/Cellar.qml
+++ b/navit/gui/qml/skins/navit/Cellar.qml
@@ -3,14 +3,14 @@ import "pagenavigation.js" as Navit
Rectangle {
- function onStartup(currentPage) {
+ function onStartup(currentPage) {
btnBack.opacity=0;
btnQuit.opacity=0;
if ( gui.lengthPage() > 1 ) {
btnBack.opacity=1;
}
if ( gui.lengthPage() == 1 && currentPage == "PageMain.qml" ) {
- btnQuit.opacity=1;
+ btnQuit.opacity=1;
}
}
diff --git a/navit/gui/qml/skins/navit/ListSelector.qml b/navit/gui/qml/skins/navit/ListSelector.qml
index 09c927cf1..9480275be 100644
--- a/navit/gui/qml/skins/navit/ListSelector.qml
+++ b/navit/gui/qml/skins/navit/ListSelector.qml
@@ -17,8 +17,8 @@ Rectangle {
listScroller.opacity=0.5;
}
}
-
- Component.onCompleted: startup();
+
+ Component.onCompleted: startup();
Text {
id: labelTxt; text: listselector.text; color: "White"; font.pointSize: 22;
@@ -37,7 +37,7 @@ Rectangle {
clip: true
highlightFollowsCurrentItem: true
keyNavigationWraps: true
-
+
Component.onCompleted: { list.currentIndex=listselector.itemId; }
}
Rectangle {
diff --git a/navit/gui/qml/skins/navit/PageAbout.qml b/navit/gui/qml/skins/navit/PageAbout.qml
index a96baabca..b026e73be 100644
--- a/navit/gui/qml/skins/navit/PageAbout.qml
+++ b/navit/gui/qml/skins/navit/PageAbout.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageBookmarks.qml b/navit/gui/qml/skins/navit/PageBookmarks.qml
index 15a5982b6..46da8d865 100644
--- a/navit/gui/qml/skins/navit/PageBookmarks.qml
+++ b/navit/gui/qml/skins/navit/PageBookmarks.qml
@@ -11,7 +11,7 @@ Rectangle {
function bookmarkReload() {
listModel.xml=bookmarks.getBookmarks();
listModel.query="/bookmarks/bookmark";
- listModel.reload();
+ listModel.reload();
}
function bookmarkClick(itemName,itemType,itemCoord) {
@@ -31,9 +31,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -41,7 +41,7 @@ Rectangle {
ButtonIcon { id: folderBtn; text: "New folder"; icon: "gui_active.svg"; onClicked: folderDialog.opacity=1
anchors.top: parent.top; anchors.topMargin: page.height/16; anchors.left: parent.left; anchors.leftMargin: page.width/16
}
- ButtonIcon { id: pasteBtn; text: "Paste"; icon: "gui_active.svg"; onClicked: { bookmarks.Paste(); bookmarkReload(); }
+ ButtonIcon { id: pasteBtn; text: "Paste"; icon: "gui_active.svg"; onClicked: { bookmarks.Paste(); bookmarkReload(); }
anchors.top: parent.top; anchors.topMargin: page.height/16; anchors.left: folderBtn.right; anchors.leftMargin: page.width/16
}
@@ -109,7 +109,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: ""
anchors.top: pasteBtn.bottom;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PageBookmarksAdd.qml b/navit/gui/qml/skins/navit/PageBookmarksAdd.qml
index 39694d2af..c02aea7c3 100644
--- a/navit/gui/qml/skins/navit/PageBookmarksAdd.qml
+++ b/navit/gui/qml/skins/navit/PageBookmarksAdd.qml
@@ -25,9 +25,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageNavigate.qml b/navit/gui/qml/skins/navit/PageNavigate.qml
index 3d4e04bc2..32e43841f 100644
--- a/navit/gui/qml/skins/navit/PageNavigate.qml
+++ b/navit/gui/qml/skins/navit/PageNavigate.qml
@@ -23,9 +23,9 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PagePoi.qml b/navit/gui/qml/skins/navit/PagePoi.qml
index 4ab9f5c0f..71f21bb2f 100644
--- a/navit/gui/qml/skins/navit/PagePoi.qml
+++ b/navit/gui/qml/skins/navit/PagePoi.qml
@@ -64,9 +64,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -138,7 +138,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: ""
anchors.top: distanceSlider.bottom;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PagePointInfo.qml b/navit/gui/qml/skins/navit/PagePointInfo.qml
index 1014c63df..c33027e26 100644
--- a/navit/gui/qml/skins/navit/PagePointInfo.qml
+++ b/navit/gui/qml/skins/navit/PagePointInfo.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -68,7 +68,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: "Attributes";
anchors.top: urlTxt.bottom;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PageRoute.qml b/navit/gui/qml/skins/navit/PageRoute.qml
index a340eaa1b..ea71569b3 100644
--- a/navit/gui/qml/skins/navit/PageRoute.qml
+++ b/navit/gui/qml/skins/navit/PageRoute.qml
@@ -20,9 +20,9 @@ Rectangle {
}
route.getDestinations();
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageSearch.qml b/navit/gui/qml/skins/navit/PageSearch.qml
index 3d9419920..bc93dce52 100644
--- a/navit/gui/qml/skins/navit/PageSearch.qml
+++ b/navit/gui/qml/skins/navit/PageSearch.qml
@@ -20,9 +20,9 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -36,19 +36,19 @@ Rectangle {
columns: 1;rows: 2;
id: gridCountry;
Text {
- id: txtItemCountry; text: "Country";
+ id: txtItemCountry; text: "Country";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
id: btnCountry; text: search.countryName; icon: "country_"+search.countryISO2+".svgz"; onClicked: { search.searchContext="country"; Navit.load("PageSearchSelector.qml"); }
- }
+ }
}
Grid {
columns: 1; rows: 2;
id: gridCity
opacity: 0;
Text {
- id: txtItemCity; text: "Town";
+ id: txtItemCity; text: "Town";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
@@ -67,7 +67,7 @@ Rectangle {
id: gridStreet
opacity: 0;
Text {
- id: txtItemStreet; text: "Street";
+ id: txtItemStreet; text: "Street";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
@@ -79,7 +79,7 @@ Rectangle {
id: gridAddress;
opacity: 0;
Text {
- id: txtItemAddress; text: "Address";
+ id: txtItemAddress; text: "Address";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
diff --git a/navit/gui/qml/skins/navit/PageSearchSelector.qml b/navit/gui/qml/skins/navit/PageSearchSelector.qml
index ec1ca73dd..d47fcbc71 100644
--- a/navit/gui/qml/skins/navit/PageSearchSelector.qml
+++ b/navit/gui/qml/skins/navit/PageSearchSelector.qml
@@ -40,15 +40,15 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
TextInput{
- id: searchTxt;
+ id: searchTxt;
anchors.top: parent.top; anchors.left: parent.left; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
width: page.width; font.pointSize: 14; color: "White";focus: true; readOnly: false; cursorVisible: true;
}
@@ -78,8 +78,8 @@ Rectangle {
id: imgIcon; source: gui.iconPath+itemIcon
width: 20; height: 20;
}
- Text {
- id: txtItemName; text: itemName; color: "White";
+ Text {
+ id: txtItemName; text: itemName; color: "White";
anchors.left: imgIcon.right;anchors.leftMargin: 5
width: list.width-imgIcon.width
}
@@ -98,7 +98,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: search.searchContext; onChanged: setSearchResult()
anchors.top: searchTxt.bottom; anchors.left: parent.left; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
width: page.width; height: page.height/2-cellar.height
diff --git a/navit/gui/qml/skins/navit/PageSettings.qml b/navit/gui/qml/skins/navit/PageSettings.qml
index f7efcacd5..2030fe56f 100644
--- a/navit/gui/qml/skins/navit/PageSettings.qml
+++ b/navit/gui/qml/skins/navit/PageSettings.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageSettingsDisplay.qml b/navit/gui/qml/skins/navit/PageSettingsDisplay.qml
index 61db6a385..9d0002d9d 100644
--- a/navit/gui/qml/skins/navit/PageSettingsDisplay.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsDisplay.qml
@@ -34,9 +34,9 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -60,9 +60,9 @@ Rectangle {
}
}
- CommonHighlight { id: listHighlight}
+ CommonHighlight { id: listHighlight}
- ListSelector {
+ ListSelector {
id:layoutList; text: "Current layout"; itemId: navit.getAttrList("layout"); onChanged: navit.setObjectByName("layout",layoutList.value)
anchors.top: parent.top;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PageSettingsLocale.qml b/navit/gui/qml/skins/navit/PageSettingsLocale.qml
index 441248484..ab4afa20d 100644
--- a/navit/gui/qml/skins/navit/PageSettingsLocale.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsLocale.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -22,7 +22,7 @@ Rectangle {
Grid {
columns: 1;rows: 3
anchors.horizontalCenter: parent.horizontalCenter;
- anchors.verticalCenter: parent.verticalCenter;
+ anchors.verticalCenter: parent.verticalCenter;
Text { id: lang; text: gui.localeName; color: "White";font.pointSize: gui.height/24 }
Text { id: langname; text: gui.langName; color: "White";font.pointSize: gui.height/24 }
diff --git a/navit/gui/qml/skins/navit/PageSettingsRules.qml b/navit/gui/qml/skins/navit/PageSettingsRules.qml
index e5238f584..007f36c84 100644
--- a/navit/gui/qml/skins/navit/PageSettingsRules.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsRules.qml
@@ -1,38 +1,38 @@
import Qt 4.7
import "pagenavigation.js" as Navit
-
-Rectangle {
- id: page
-
- width: gui.width; height: gui.height
- border.width: 1
- color: "Black"
- opacity: 0
-
- function pageOpen() {
- page.opacity = 1;
- }
-
- Component.onCompleted: pageOpen();
-
- Behavior on opacity {
- NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
- }
-
- VisualItemModel {
- id: selectorsModel
-
- ToggleSwitch { id: trackingSw; stOn: navit.getAttr("tracking"); text: "Lock on road"; onChanged: navit.setAttr("tracking",trackingSw.stOn) }
- ToggleSwitch { id: orientationSw; stOn: navit.getAttr("orientation"); text: "Northing"; onChanged: navit.setAttr("orientation",orientationSw.stOn) }
- ToggleSwitch { id: followcursorSw; stOn: navit.getAttr("follow_cursor"); text: "Map follows Vehicle"; onChanged: navit.setAttr("follow_cursor",followcursorSw.stOn) }
- ToggleSwitch { id: autozoomSw; stOn: navit.getAttr("autozoom_active"); text: "Auto zoom"; onChanged: navit.setAttr("autozoom_active",autozoomSw.stOn) }
- }
-
- ListView {
- id: selectorsList; model: selectorsModel
- focus: true; clip: true; orientation: Qt.Vertical
- anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
- width: trackingSw.width*1.5; height: trackingSw.height*4
- }
- Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
-}
+
+Rectangle {
+ id: page
+
+ width: gui.width; height: gui.height
+ border.width: 1
+ color: "Black"
+ opacity: 0
+
+ function pageOpen() {
+ page.opacity = 1;
+ }
+
+ Component.onCompleted: pageOpen();
+
+ Behavior on opacity {
+ NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
+ }
+
+ VisualItemModel {
+ id: selectorsModel
+
+ ToggleSwitch { id: trackingSw; stOn: navit.getAttr("tracking"); text: "Lock on road"; onChanged: navit.setAttr("tracking",trackingSw.stOn) }
+ ToggleSwitch { id: orientationSw; stOn: navit.getAttr("orientation"); text: "Northing"; onChanged: navit.setAttr("orientation",orientationSw.stOn) }
+ ToggleSwitch { id: followcursorSw; stOn: navit.getAttr("follow_cursor"); text: "Map follows Vehicle"; onChanged: navit.setAttr("follow_cursor",followcursorSw.stOn) }
+ ToggleSwitch { id: autozoomSw; stOn: navit.getAttr("autozoom_active"); text: "Auto zoom"; onChanged: navit.setAttr("autozoom_active",autozoomSw.stOn) }
+ }
+
+ ListView {
+ id: selectorsList; model: selectorsModel
+ focus: true; clip: true; orientation: Qt.Vertical
+ anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
+ width: trackingSw.width*1.5; height: trackingSw.height*4
+ }
+ Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
+}
diff --git a/navit/gui/qml/skins/navit/PageSettingsTools.qml b/navit/gui/qml/skins/navit/PageSettingsTools.qml
index a4af1222e..717bdc9fd 100644
--- a/navit/gui/qml/skins/navit/PageSettingsTools.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsTools.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -22,7 +22,7 @@ Rectangle {
Grid {
columns: 1;rows: 1
anchors.horizontalCenter: parent.horizontalCenter;
- anchors.verticalCenter: parent.verticalCenter;
+ anchors.verticalCenter: parent.verticalCenter;
ButtonIcon {
id: btnDisplay; text: "Locale"; icon: "gui_actions.svg"; onClicked: Navit.load("PageSettingsLocale.qml");
}
diff --git a/navit/gui/qml/skins/navit/PageSettingsVehicle.qml b/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
index 157afcb00..189b8fd1f 100644
--- a/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -43,9 +43,9 @@ Rectangle {
}
}
}
- CommonHighlight { id: listHighlight}
+ CommonHighlight { id: listHighlight}
- ListSelector {
+ ListSelector {
id:vehicleList; text: "Current vehicle profile"; itemId: navit.itemId; onChanged: {navit.setObjectByName("vehicle",vehicleList.value) }
anchors.top: parent.top; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
anchors.left: parent.left; width: page.width/2;height: page.height/2
diff --git a/navit/gui/qml/skins/navit/Slider.qml b/navit/gui/qml/skins/navit/Slider.qml
index e4d56e031..698a9f6e1 100644
--- a/navit/gui/qml/skins/navit/Slider.qml
+++ b/navit/gui/qml/skins/navit/Slider.qml
@@ -39,7 +39,7 @@ Rectangle {
}
MouseArea {
anchors.fill: parent
- onReleased: { knob.x=mouse.x-15; slider.value=Math.round(fromSlider(knob.x)); slider.changed(); }
+ onReleased: { knob.x=mouse.x-15; slider.value=Math.round(fromSlider(knob.x)); slider.changed(); }
}
radius: 8; opacity: 0.7
diff --git a/navit/gui/qml/skins/navit/ToggleButton.qml b/navit/gui/qml/skins/navit/ToggleButton.qml
index 29d986601..30617644b 100644
--- a/navit/gui/qml/skins/navit/ToggleButton.qml
+++ b/navit/gui/qml/skins/navit/ToggleButton.qml
@@ -13,14 +13,14 @@ import Qt 4.7
function toggle() {
if (togglebutton.state == "on")
togglebutton.state = "off";
- else
+ else
togglebutton.state = "on";
}
function startup () {
- if (togglebutton.stOn == "1" )
+ if (togglebutton.stOn == "1" )
togglebutton.stOn = "true";
- else if (togglebutton.stOn == "0" )
+ else if (togglebutton.stOn == "0" )
togglebutton.stOn = "false";
if (togglebutton.stOn == "true")
togglebutton.state = "on";
@@ -38,7 +38,7 @@ import Qt 4.7
}
Text {
- id: txtItem; text: togglebutton.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: togglebutton.horizontalCenter;
+ id: txtItem; text: togglebutton.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: togglebutton.horizontalCenter;
color: "White"; font.pointSize: gui.height/64; horizontalAlignment: Qt.AlignHCenter
}
diff --git a/navit/gui/qml/skins/navit/ToggleSwitch.qml b/navit/gui/qml/skins/navit/ToggleSwitch.qml
index b1b262461..14bc7b0ba 100644
--- a/navit/gui/qml/skins/navit/ToggleSwitch.qml
+++ b/navit/gui/qml/skins/navit/ToggleSwitch.qml
@@ -15,9 +15,9 @@ import Qt 4.7
}
function startup () {
- if (toggleswitch.stOn == "1" )
+ if (toggleswitch.stOn == "1" )
toggleswitch.stOn = "true";
- else if (toggleswitch.stOn == "0" )
+ else if (toggleswitch.stOn == "0" )
toggleswitch.stOn = "false";
if (toggleswitch.stOn == "true")
toggleswitch.state = "on";
diff --git a/navit/gui/qml/skins/navit/command.js b/navit/gui/qml/skins/navit/command.js
index 071653acf..bcf0cf746 100644
--- a/navit/gui/qml/skins/navit/command.js
+++ b/navit/gui/qml/skins/navit/command.js
@@ -1,7 +1,7 @@
import Qt 4.7
Rectangle {
- id: page
+ id: page
function pageOpen(command) {
if ( command=="menu") {
@@ -11,10 +11,10 @@ Rectangle {
if (command=="quit") {
navit.quit();
}
-
+
}
-
- Component.onCompleted: pageOpen(gui.commandFunction);
-
- Text { id: myText; anchors.centerIn: parent; text: "Hi, i'm Navit!"; color: "Black"; font.pointSize: gui.height/32 }
+
+ Component.onCompleted: pageOpen(gui.commandFunction);
+
+ Text { id: myText; anchors.centerIn: parent; text: "Hi, i'm Navit!"; color: "Black"; font.pointSize: gui.height/32 }
}
diff --git a/navit/gui/qml/skins/navit/main.qml b/navit/gui/qml/skins/navit/main.qml
index 20b93d113..344dd182d 100644
--- a/navit/gui/qml/skins/navit/main.qml
+++ b/navit/gui/qml/skins/navit/main.qml
@@ -11,9 +11,9 @@ Rectangle {
function pageOpen() {
Navit.load("PageMain.qml");
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -25,7 +25,7 @@ Rectangle {
height: gui.height-cellar.height;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
- }
+ }
Cellar {id: cellar;anchors.bottom: main.bottom; anchors.horizontalCenter: main.horizontalCenter; width: main.width }
}
diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp
index 395fff425..4b83bad32 100644
--- a/navit/gui/qt5_qml/backend.cpp
+++ b/navit/gui/qt5_qml/backend.cpp
@@ -25,12 +25,11 @@ extern "C" {
#include "proxy.h"
}
-Backend::Backend(QObject * parent):QObject(parent)
-{
- set_default_country();
- this->search = NULL;
- _current_town = NULL;
- _current_street = NULL;
+Backend::Backend(QObject * parent):QObject(parent) {
+ set_default_country();
+ this->search = NULL;
+ _current_town = NULL;
+ _current_street = NULL;
}
/**
@@ -38,63 +37,61 @@ Backend::Backend(QObject * parent):QObject(parent)
* @param struct point *p the point coordinate where we clicked on the screen
* @returns nothing
*/
-void Backend::showMenu(struct point *p)
-{
- struct coord co;
-
- transform_reverse(navit_get_trans(nav), p, &co);
- dbg(lvl_debug, "Point 0x%x 0x%x\n", co.x, co.y);
- dbg(lvl_debug, "Screen coord : %d %d\n", p->x, p->y);
- transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &(this->g));
- dbg(lvl_debug, "%f %f\n", this->g.lat, this->g.lng);
- dbg(lvl_debug, "%p %p\n", nav, &c);
- this->c.pro = transform_get_projection(navit_get_trans(nav));
- this->c.x = co.x;
- this->c.y = co.y;
- dbg(lvl_debug, "c : %x %x\n", this->c.x, this->c.y);
-
- // As a test, set the Demo vehicle position to wherever we just clicked
- navit_set_position(this->nav, &c);
- navit_block(this->nav, 1);
- emit displayMenu("MainMenu.qml");
+void Backend::showMenu(struct point *p) {
+ struct coord co;
+
+ transform_reverse(navit_get_trans(nav), p, &co);
+ dbg(lvl_debug, "Point 0x%x 0x%x", co.x, co.y);
+ dbg(lvl_debug, "Screen coord : %d %d", p->x, p->y);
+ transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &(this->g));
+ dbg(lvl_debug, "%f %f", this->g.lat, this->g.lng);
+ dbg(lvl_debug, "%p %p", nav, &c);
+ this->c.pro = transform_get_projection(navit_get_trans(nav));
+ this->c.x = co.x;
+ this->c.y = co.y;
+ dbg(lvl_debug, "c : %x %x", this->c.x, this->c.y);
+
+ // As a test, set the Demo vehicle position to wherever we just clicked
+ navit_set_position(this->nav, &c);
+ navit_block(this->nav, 1);
+ emit displayMenu("MainMenu.qml");
}
/**
* @brief update the private m_maps list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_maps()
-{
- struct attr attr, on, off, description, type, data, active;
- char * label;
- bool is_active;
- struct attr_iter * iter;
- _maps.clear();
-
- iter = navit_attr_iter_new();
- on.type = off.type = attr_active;
- on.u.num = 1;
- off.u.num = 0;
- while (navit_get_attr(this->nav, attr_map, &attr, iter)) {
- if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
- label = g_strdup(description.u.str);
- } else {
- if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str = "";
- if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str = "";
- label = g_strdup_printf("%s:%s", type.u.str, data.u.str);
- }
- is_active = false;
- if (map_get_attr(attr.u.map, attr_active, &active, NULL)) {
- if (active.u.num == 1) {
- is_active = true;
- }
- }
- _maps.append(new MapObject(label, is_active));
+ */
+void Backend::get_maps() {
+ struct attr attr, on, off, description, type, data, active;
+ char * label;
+ bool is_active;
+ struct attr_iter * iter;
+ _maps.clear();
+
+ iter = navit_attr_iter_new();
+ on.type = off.type = attr_active;
+ on.u.num = 1;
+ off.u.num = 0;
+ while (navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
+ label = g_strdup(description.u.str);
+ } else {
+ if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
+ type.u.str = "";
+ if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
+ data.u.str = "";
+ label = g_strdup_printf("%s:%s", type.u.str, data.u.str);
+ }
+ is_active = false;
+ if (map_get_attr(attr.u.map, attr_active, &active, NULL)) {
+ if (active.u.num == 1) {
+ is_active = true;
+ }
}
- emit mapsChanged();
+ _maps.append(new MapObject(label, is_active));
+ }
+ emit mapsChanged();
}
@@ -102,196 +99,190 @@ void Backend::get_maps()
* @brief update the private m_vehicles list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_vehicles()
-{
- struct attr attr,attr2,vattr;
- struct attr_iter *iter;
- struct attr active_vehicle;
- _vehicles.clear();
-
- iter=navit_attr_iter_new();
- if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- navit_attr_iter_destroy(iter);
- _vehicles.append(new VehicleObject(g_strdup(vattr.u.str), active_vehicle.u.vehicle, attr.u.vehicle));
- dbg(lvl_debug, "done\n");
- emit vehiclesChanged();
- return;
- }
- navit_attr_iter_destroy(iter);
-
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
- active_vehicle.u.vehicle=NULL;
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- dbg(lvl_debug, "adding vehicle %s\n", vattr.u.str);
- _vehicles.append(
- new VehicleObject(
- g_strdup(vattr.u.str),
- attr.u.vehicle == active_vehicle.u.vehicle,
- attr.u.vehicle
- )
- );
- }
+ */
+void Backend::get_vehicles() {
+ struct attr attr,attr2,vattr;
+ struct attr_iter *iter;
+ struct attr active_vehicle;
+ _vehicles.clear();
+
+ iter=navit_attr_iter_new();
+ if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
navit_attr_iter_destroy(iter);
- emit vehiclesChanged();
+ _vehicles.append(new VehicleObject(g_strdup(vattr.u.str), active_vehicle.u.vehicle, attr.u.vehicle));
+ dbg(lvl_debug, "done");
+ emit vehiclesChanged();
+ return;
+ }
+ navit_attr_iter_destroy(iter);
+
+ if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
+ active_vehicle.u.vehicle=NULL;
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ dbg(lvl_debug, "adding vehicle %s", vattr.u.str);
+ _vehicles.append(
+ new VehicleObject(
+ g_strdup(vattr.u.str),
+ attr.u.vehicle == active_vehicle.u.vehicle,
+ attr.u.vehicle
+ )
+ );
+ }
+ navit_attr_iter_destroy(iter);
+ emit vehiclesChanged();
}
/**
* @brief set a pointer to the struct navit * for local use
* @param none
* @returns nothing
- */
-void Backend::set_navit(struct navit *nav)
-{
- this->nav = nav;
+ */
+void Backend::set_navit(struct navit *nav) {
+ this->nav = nav;
}
/**
* @brief set a pointer to the QQmlApplicationEngine * for local use
* @param none
* @returns nothing
- */
-void Backend::set_engine(QQmlApplicationEngine * engine)
-{
- this->engine = engine;
+ */
+void Backend::set_engine(QQmlApplicationEngine * engine) {
+ this->engine = engine;
}
/**
* @brief apply search filters on one specific item
* @param struct item * the item to filter
* @returns 0 if the item should be discarded, 1 otherwise
- */
-int Backend::filter_pois(struct item *item)
-{
- enum item_type *types;
- enum item_type type=item->type;
- if (type >= type_line)
- return 0;
- return 1;
+ */
+int Backend::filter_pois(struct item *item) {
+ enum item_type *types;
+ enum item_type type=item->type;
+ if (type >= type_line)
+ return 0;
+ return 1;
}
/**
* @brief update the private m_bookmarks list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_bookmarks()
-{
- struct attr attr,mattr;
- struct navigation * nav = NULL;
- struct item *item;
- struct coord c;
- struct pcoord pc;
-
- _bookmarks.clear();
-
- pc.pro = transform_get_projection(navit_get_trans(this->nav));
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- bookmarks_item_rewind(mattr.u.bookmarks);
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr)) continue;
- dbg(lvl_debug,"full_label: %s\n", attr.u.str);
- if (item_coord_get(item, &c, 1)) {
- pc.x = c.x;
- pc.y = c.y;
- dbg(lvl_debug, "coords : %i x %i\n", pc.x, pc.y);
- _bookmarks.append(new BookmarkObject(attr.u.str, pc));
- }
- }
+ */
+void Backend::get_bookmarks() {
+ struct attr attr,mattr;
+ struct navigation * nav = NULL;
+ struct item *item;
+ struct coord c;
+ struct pcoord pc;
+
+ _bookmarks.clear();
+
+ pc.pro = transform_get_projection(navit_get_trans(this->nav));
+
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ bookmarks_item_rewind(mattr.u.bookmarks);
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ if (!item_attr_get(item, attr_label, &attr)) continue;
+ dbg(lvl_debug,"full_label: %s", attr.u.str);
+ if (item_coord_get(item, &c, 1)) {
+ pc.x = c.x;
+ pc.y = c.y;
+ dbg(lvl_debug, "coords : %i x %i", pc.x, pc.y);
+ _bookmarks.append(new BookmarkObject(attr.u.str, pc));
+ }
}
- emit bookmarksChanged();
+ }
+ emit bookmarksChanged();
}
/**
* @brief update the private m_pois list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_pois()
-{
- struct map_selection * sel, * selm;
- struct coord c, center;
- struct mapset_handle * h;
- struct map * m;
- struct map_rect * mr;
- struct item * item;
- enum projection pro = this->c.pro;
- int idist, dist;
- _pois.clear();
- dist = 10000;
- sel = map_selection_rect_new(&(this->c), dist * transform_scale(abs(this->c.y) + dist * 1.5), 18);
- center.x = this->c.x;
- center.y = this->c.y;
-
- dbg(lvl_debug, "center is at %x, %x\n", center.x, center.y);
-
- h = mapset_open(navit_get_mapset(this->nav));
- while ((m = mapset_next(h, 1))) {
- selm = map_selection_dup_pro(sel, pro, map_projection(m));
- mr = map_rect_new(m, selm);
- dbg(lvl_debug, "mr=%p\n", mr);
- if (mr) {
- while ((item = map_rect_get_item(mr))) {
- if ( filter_pois(item) &&
- item_coord_get_pro(item, &c, 1, pro) &&
- coord_rect_contains(&sel->u.c_rect, &c) &&
- (idist=transform_distance(pro, &center, &c)) < dist) {
-
- struct attr attr;
- char * label;
- char * icon = get_icon(this->nav, item);
- struct pcoord item_coord;
- item_coord.pro = transform_get_projection(navit_get_trans(nav));
- item_coord.x = c.x;
- item_coord.y = c.y;
-
- idist = transform_distance(pro, &center, &c);
- if (item_attr_get(item, attr_label, &attr)) {
- label = map_convert_string(item->map, attr.u.str);
- if (icon) {
- _pois.append(new PoiObject(label, item_to_name(item->type), idist, icon, item_coord));
- }
- }
- }
+ */
+void Backend::get_pois() {
+ struct map_selection * sel, * selm;
+ struct coord c, center;
+ struct mapset_handle * h;
+ struct map * m;
+ struct map_rect * mr;
+ struct item * item;
+ enum projection pro = this->c.pro;
+ int idist, dist;
+ _pois.clear();
+ dist = 10000;
+ sel = map_selection_rect_new(&(this->c), dist * transform_scale(abs(this->c.y) + dist * 1.5), 18);
+ center.x = this->c.x;
+ center.y = this->c.y;
+
+ dbg(lvl_debug, "center is at %x, %x", center.x, center.y);
+
+ h = mapset_open(navit_get_mapset(this->nav));
+ while ((m = mapset_next(h, 1))) {
+ selm = map_selection_dup_pro(sel, pro, map_projection(m));
+ mr = map_rect_new(m, selm);
+ dbg(lvl_debug, "mr=%p", mr);
+ if (mr) {
+ while ((item = map_rect_get_item(mr))) {
+ if ( filter_pois(item) &&
+ item_coord_get_pro(item, &c, 1, pro) &&
+ coord_rect_contains(&sel->u.c_rect, &c) &&
+ (idist=transform_distance(pro, &center, &c)) < dist) {
+
+ struct attr attr;
+ char * label;
+ char * icon = get_icon(this->nav, item);
+ struct pcoord item_coord;
+ item_coord.pro = transform_get_projection(navit_get_trans(nav));
+ item_coord.x = c.x;
+ item_coord.y = c.y;
+
+ idist = transform_distance(pro, &center, &c);
+ if (item_attr_get(item, attr_label, &attr)) {
+ label = map_convert_string(item->map, attr.u.str);
+ if (icon) {
+ _pois.append(new PoiObject(label, item_to_name(item->type), idist, icon, item_coord));
}
- map_rect_destroy(mr);
+ }
}
- map_selection_destroy(selm);
+ }
+ map_rect_destroy(mr);
}
- map_selection_destroy(sel);
- mapset_close(h);
- emit poisChanged();
+ map_selection_destroy(selm);
+ }
+ map_selection_destroy(sel);
+ mapset_close(h);
+ emit poisChanged();
}
/**
* @brief get the POIs as a QList
* @param none
* @returns the pois QList
- */
-QQmlListProperty<QObject> Backend::getPois(){
- return QQmlListProperty<QObject>(this, _pois);
+ */
+QQmlListProperty<QObject> Backend::getPois() {
+ return QQmlListProperty<QObject>(this, _pois);
}
/**
* @brief get the Bookmarks as a QList
* @param none
* @returns the bookmarks QList
- */
-QQmlListProperty<QObject> Backend::getBookmarks(){
- return QQmlListProperty<QObject>(this, _bookmarks);
+ */
+QQmlListProperty<QObject> Backend::getBookmarks() {
+ return QQmlListProperty<QObject>(this, _bookmarks);
}
/**
* @brief get the maps as a QList
* @param none
* @returns the maps QList
- */
-QQmlListProperty<QObject> Backend::getMaps(){
- return QQmlListProperty<QObject>(this, _maps);
+ */
+QQmlListProperty<QObject> Backend::getMaps() {
+ return QQmlListProperty<QObject>(this, _maps);
}
@@ -299,62 +290,62 @@ QQmlListProperty<QObject> Backend::getMaps(){
* @brief get the vehicles as a QList
* @param none
* @returns the vehicles QList
- */
-QQmlListProperty<QObject> Backend::getVehicles(){
- return QQmlListProperty<QObject>(this, _vehicles);
+ */
+QQmlListProperty<QObject> Backend::getVehicles() {
+ return QQmlListProperty<QObject>(this, _vehicles);
}
/**
* @brief get the search results as a QList
* @param none
* @returns the search results QList
- */
-QQmlListProperty<QObject> Backend::getSearchResults(){
- return QQmlListProperty<QObject>(this, _search_results);
+ */
+QQmlListProperty<QObject> Backend::getSearchResults() {
+ return QQmlListProperty<QObject>(this, _search_results);
}
/**
* @brief get the active POI. Used when displaying the relevant menu
* @param none
* @returns the active POI
- */
+ */
PoiObject * Backend::activePoi() {
- dbg(lvl_debug, "name : %s\n", m_activePoi->name().toUtf8().data());
- dbg(lvl_debug, "type : %s\n", m_activePoi->type().toLatin1().data());
- return m_activePoi;
+ dbg(lvl_debug, "name : %s", m_activePoi->name().toUtf8().data());
+ dbg(lvl_debug, "type : %s", m_activePoi->type().toLatin1().data());
+ return m_activePoi;
}
/**
* @brief get the current bookmark. Used when displaying the relevant menu
* @param none
* @returns the current bookmark
- */
+ */
BookmarkObject * Backend::currentBookmark() {
- return m_currentBookmark;
+ return m_currentBookmark;
}
/**
* @brief get the currently selected vehicle. Used when displaying the relevant menu
* @param none
* @returns the active POI
- */
+ */
VehicleObject * Backend::currentVehicle() {
- struct attr attr;
- dbg(lvl_debug, "name : %s\n", m_currentVehicle->name().toUtf8().data());
- if (m_currentVehicle->vehicle()) {
- if (vehicle_get_attr(m_currentVehicle->vehicle(), attr_position_nmea, &attr, NULL))
- dbg(lvl_debug, "NMEA : %s\n", attr.u.str);
- } else {
- dbg(lvl_debug, "m_currentVehicle->v is null\n");
- }
+ struct attr attr;
+ dbg(lvl_debug, "name : %s", m_currentVehicle->name().toUtf8().data());
+ if (m_currentVehicle->vehicle()) {
+ if (vehicle_get_attr(m_currentVehicle->vehicle(), attr_position_nmea, &attr, NULL))
+ dbg(lvl_debug, "NMEA : %s", attr.u.str);
+ } else {
+ dbg(lvl_debug, "m_currentVehicle->v is null");
+ }
- return m_currentVehicle;
+ return m_currentVehicle;
}
-void Backend::block_draw(){
- navit_block(this->nav, 1);
- dbg(lvl_debug, "Draw operations blocked per UI request\n");
+void Backend::block_draw() {
+ navit_block(this->nav, 1);
+ dbg(lvl_debug, "Draw operations blocked per UI request");
}
/**
@@ -362,124 +353,124 @@ void Backend::block_draw(){
* @param int width
* @param int height
* @returns nothing
- */
-void Backend::resize(int width, int height){
- // If we need to resize the canvas, it means that something (the main map,
- // or a menu item) wants to display a map. Ensure that draw operations
- // are not blocked then.
- navit_block(this->nav, -1);
- navit_handle_resize(nav, width, height);
+ */
+void Backend::resize(int width, int height) {
+ // If we need to resize the canvas, it means that something (the main map,
+ // or a menu item) wants to display a map. Ensure that draw operations
+ // are not blocked then.
+ navit_block(this->nav, -1);
+ navit_handle_resize(nav, width, height);
}
/**
* @brief set the active POI. Used when clicking on a POI list to display one single POI
* @param int index the index of the POI in the m_pois list
* @returns nothing
- */
+ */
void Backend::setActivePoi(int index) {
- struct pcoord c;
- m_activePoi = (PoiObject *)_pois.at(index);
- c = m_activePoi->coords();
- resize(320, 240);
- navit_set_center(this->nav, &c, 1);
- emit activePoiChanged();
+ struct pcoord c;
+ m_activePoi = (PoiObject *)_pois.at(index);
+ c = m_activePoi->coords();
+ resize(320, 240);
+ navit_set_center(this->nav, &c, 1);
+ emit activePoiChanged();
}
/**
* @brief set the current bookmark. Used when clicking on a bookmark list to display one single bookmark
* @param int index the index of the bookmark in the m_bookmarks list
* @returns nothing
- */
+ */
void Backend::setCurrentBookmark(int index) {
- struct pcoord c;
- m_currentBookmark = (BookmarkObject *)_bookmarks.at(index);
- c = m_currentBookmark->coords();
- resize(320, 240);
- navit_set_center(this->nav, &c, 1);
- emit currentBookmarkChanged();
+ struct pcoord c;
+ m_currentBookmark = (BookmarkObject *)_bookmarks.at(index);
+ c = m_currentBookmark->coords();
+ resize(320, 240);
+ navit_set_center(this->nav, &c, 1);
+ emit currentBookmarkChanged();
}
/**
* @brief set the current vehicle. Used when clicking on a vehicle list to display one single vehicle
* @param int index the index of the vehicle in the m_vehicles list
* @returns nothing
- */
+ */
void Backend::setCurrentVehicle(int index) {
- m_currentVehicle = (VehicleObject *)_vehicles.at(index);
- emit currentVehicleChanged();
+ m_currentVehicle = (VehicleObject *)_vehicles.at(index);
+ emit currentVehicleChanged();
}
/**
* @brief returns the icon absolute path
* @param none
* @returns the icon absolute path as a QString
- */
-QString Backend::get_icon_path(){
- return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",NULL));
+ */
+QString Backend::get_icon_path() {
+ return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",NULL));
}
/**
* @brief set the destination using the currently active POI's coordinates
* @param none
* @returns nothing
- */
-void Backend::setActivePoiAsDestination(){
- struct pcoord c;
- c = m_activePoi->coords();
- dbg(lvl_debug, "Destination : %s c=%d:0x%x,0x%x\n",
- m_activePoi->name().toUtf8().data(),
- c.pro, c.x, c.y);
- navit_set_destination(this->nav, &c, m_activePoi->name().toUtf8().data(), 1);
- emit hideMenu();
+ */
+void Backend::setActivePoiAsDestination() {
+ struct pcoord c;
+ c = m_activePoi->coords();
+ dbg(lvl_debug, "Destination : %s c=%d:0x%x,0x%x",
+ m_activePoi->name().toUtf8().data(),
+ c.pro, c.x, c.y);
+ navit_set_destination(this->nav, &c, m_activePoi->name().toUtf8().data(), 1);
+ emit hideMenu();
}
/**
* @brief save the search result for the next search step
* @param int index the index of the result in the m_search_results list
* @returns nothing
- */
-void Backend::searchValidateResult(int index){
- SearchObject * r = (SearchObject *)_search_results.at(index);
- dbg(lvl_debug, "Saving %s [%i] as search result\n", r->name().toUtf8().data(), index);
- if (r->getCoords()){
- dbg(lvl_debug, "Item is at %x x %x\n", r->getCoords()->x, r->getCoords()->y);
- }
- if (_search_context == attr_country_all) {
- _current_country = g_strdup(r->name().toUtf8().data());
- _current_town = NULL;
- _current_street = NULL;
- } else if (_search_context == attr_town_name) {
- _current_town = g_strdup(r->name().toUtf8().data());
- _current_street = NULL;
- } else if (_search_context == attr_street_name) {
- _current_street = g_strdup(r->name().toUtf8().data());
- } else {
- dbg(lvl_error, "Unknown search context for '%s'\n", r->name().toUtf8().data());
- }
- // navit_set_center(this->nav, r->getCoords(), 1);
- emit displayMenu("destination_address.qml");
+ */
+void Backend::searchValidateResult(int index) {
+ SearchObject * r = (SearchObject *)_search_results.at(index);
+ dbg(lvl_debug, "Saving %s [%i] as search result", r->name().toUtf8().data(), index);
+ if (r->getCoords()) {
+ dbg(lvl_debug, "Item is at %x x %x", r->getCoords()->x, r->getCoords()->y);
+ }
+ if (_search_context == attr_country_all) {
+ _current_country = g_strdup(r->name().toUtf8().data());
+ _current_town = NULL;
+ _current_street = NULL;
+ } else if (_search_context == attr_town_name) {
+ _current_town = g_strdup(r->name().toUtf8().data());
+ _current_street = NULL;
+ } else if (_search_context == attr_street_name) {
+ _current_street = g_strdup(r->name().toUtf8().data());
+ } else {
+ dbg(lvl_error, "Unknown search context for '%s'", r->name().toUtf8().data());
+ }
+ // navit_set_center(this->nav, r->getCoords(), 1);
+ emit displayMenu("destination_address.qml");
}
/**
* @brief get the icon that matches the country currently used for searches
* @param none
* @returns an absolute path for the country icon
- */
-QString Backend::get_country_icon(char * country_iso_code){
+ */
+QString Backend::get_country_icon(char * country_iso_code) {
// if ( country_iso_code == "" ) {
// country_iso_code = _country_iso2;
// }
- return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",country_iso_code,".svg",NULL));
+ return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",country_iso_code,".svg",NULL));
}
static struct search_param {
- struct navit *nav;
- struct mapset *ms;
- struct search_list *sl;
- struct attr attr;
- int partial;
- void *entry_country, *entry_postal, *entry_city, *entry_district;
- void *entry_street, *entry_number;
+ struct navit *nav;
+ struct mapset *ms;
+ struct search_list *sl;
+ struct attr attr;
+ int partial;
+ void *entry_country, *entry_postal, *entry_city, *entry_district;
+ void *entry_street, *entry_number;
} search_param;
/**
@@ -487,9 +478,9 @@ static struct search_param {
* @param none
* returns nothing
*/
-void Backend::set_default_country(){
- _current_country = "Germany";
- _country_iso2 = "DE";
+void Backend::set_default_country() {
+ _current_country = "Germany";
+ _country_iso2 = "DE";
}
@@ -497,107 +488,107 @@ void Backend::set_default_country(){
* @brief update the current search results according to new inputs. Currently only works to search for towns
* @param QString text the text to search for
* @returns nothing
- */
-void Backend::updateSearch(QString text){
- struct search_list_result *res;
- struct attr search_attr;
-
- if (search == NULL){
- search=&search_param;
- dbg(lvl_debug, "search = %p\n", search);
- search->nav=this->nav;
- search->ms=navit_get_mapset(this->nav);
- search->sl=search_list_new(search->ms);
- search->partial = 1;
- dbg(lvl_debug,"attempting to use country '%s'\n", _country_iso2);
- search_attr.type=attr_country_iso2;
- search_attr.u.str=_country_iso2;
- search_list_search(search->sl, &search_attr, 0);
-
- while((res=search_list_get_result(search->sl)));
- }
-
- _search_results.clear();
- // search->attr.type=attr_country_all;
- // search->attr.type=attr_town_postal;
- // search->attr.type=attr_town_name;
- // search->attr.type=attr_street_name;
+ */
+void Backend::updateSearch(QString text) {
+ struct search_list_result *res;
+ struct attr search_attr;
+
+ if (search == NULL) {
+ search=&search_param;
+ dbg(lvl_debug, "search = %p", search);
+ search->nav=this->nav;
+ search->ms=navit_get_mapset(this->nav);
+ search->sl=search_list_new(search->ms);
+ search->partial = 1;
+ dbg(lvl_debug,"attempting to use country '%s'", _country_iso2);
+ search_attr.type=attr_country_iso2;
+ search_attr.u.str=_country_iso2;
+ search_list_search(search->sl, &search_attr, 0);
+
+ while((res=search_list_get_result(search->sl)));
+ }
+
+ _search_results.clear();
+ // search->attr.type=attr_country_all;
+ // search->attr.type=attr_town_postal;
+ // search->attr.type=attr_town_name;
+ // search->attr.type=attr_street_name;
// search->attr.type=attr_town_name;
// search->attr.u.str="Oberhaching";
// search_list_search(search->sl, &search->attr, search->partial);
// while((res=search_list_get_result(search->sl)));
- search->attr.u.str = text.toUtf8().data();
- dbg(lvl_error, "searching for %s partial %d\n", search->attr.u.str, search->partial);
-
- search->attr.type = _search_context;
- search_list_search(search->sl, &search->attr, search->partial);
- int count = 0;
- while((res=search_list_get_result(search->sl))) {
- if ( _search_context == attr_country_all && res->country) {
- char * label;
- label = g_strdup(res->country->name);
- _search_results.append(
- new SearchObject(label, get_country_icon(res->country->flag) , res->c)
- );
- }
- if ( _search_context == attr_town_name && res->town) {
- char * label;
- label = g_strdup(res->town->common.town_name);
- _search_results.append(
- new SearchObject(label, "icons/bigcity.png", res->c)
- );
- }
- if (res->street) {
- char * label;
- label = g_strdup(res->street->name);
- _search_results.append(
- new SearchObject(label, "icons/smallcity.png", res->c)
- );
- }
- if (count ++ > 50) {
- break;
- }
+ search->attr.u.str = text.toUtf8().data();
+ dbg(lvl_error, "searching for %s partial %d", search->attr.u.str, search->partial);
+
+ search->attr.type = _search_context;
+ search_list_search(search->sl, &search->attr, search->partial);
+ int count = 0;
+ while((res=search_list_get_result(search->sl))) {
+ if ( _search_context == attr_country_all && res->country) {
+ char * label;
+ label = g_strdup(res->country->name);
+ _search_results.append(
+ new SearchObject(label, get_country_icon(res->country->flag), res->c)
+ );
+ }
+ if ( _search_context == attr_town_name && res->town) {
+ char * label;
+ label = g_strdup(res->town->common.town_name);
+ _search_results.append(
+ new SearchObject(label, "icons/bigcity.png", res->c)
+ );
+ }
+ if (res->street) {
+ char * label;
+ label = g_strdup(res->street->name);
+ _search_results.append(
+ new SearchObject(label, "icons/smallcity.png", res->c)
+ );
}
- emit searchResultsChanged();
+ if (count ++ > 50) {
+ break;
+ }
+ }
+ emit searchResultsChanged();
}
-void Backend::setSearchContext(QString text){
- if (text == "country") {
- _search_context = attr_country_all;
- } else if (text == "town") {
- _search_context = attr_town_name;
- } else if (text == "street") {
- _search_context = attr_street_name;
- } else {
- dbg(lvl_error, "Unhandled search context '%s'\n", text.toUtf8().data());
- }
-
+void Backend::setSearchContext(QString text) {
+ if (text == "country") {
+ _search_context = attr_country_all;
+ } else if (text == "town") {
+ _search_context = attr_town_name;
+ } else if (text == "street") {
+ _search_context = attr_street_name;
+ } else {
+ dbg(lvl_error, "Unhandled search context '%s'", text.toUtf8().data());
+ }
+
}
QString Backend::currentCountry() {
- dbg(lvl_debug, "Current country : %s/%s\n", _country_iso2, _current_country);
- return QString(_current_country);
+ dbg(lvl_debug, "Current country : %s/%s", _country_iso2, _current_country);
+ return QString(_current_country);
}
QString Backend::currentCountryIso2() {
- dbg(lvl_debug, "Current country : %s/%s\n", _country_iso2, _current_country);
- return QString(_country_iso2);
+ dbg(lvl_debug, "Current country : %s/%s", _country_iso2, _current_country);
+ return QString(_country_iso2);
}
QString Backend::currentTown() {
- if (_current_town == NULL) {
- _current_town = "Enter City";
- }
- dbg(lvl_debug, "Current town : %s\n", _current_town);
- return QString(_current_town);
+ if (_current_town == NULL) {
+ _current_town = "Enter City";
+ }
+ dbg(lvl_debug, "Current town : %s", _current_town);
+ return QString(_current_town);
}
QString Backend::currentStreet() {
- if (_current_street == NULL) {
- _current_street = "Enter Street";
- }
- dbg(lvl_debug, "Current street : %s\n", _current_street);
- return QString(_current_street);
+ if (_current_street == NULL) {
+ _current_street = "Enter Street";
+ }
+ dbg(lvl_debug, "Current street : %s", _current_street);
+ return QString(_current_street);
}
diff --git a/navit/gui/qt5_qml/editor/main.cpp b/navit/gui/qt5_qml/editor/main.cpp
index 9089c5a29..32d6f9df4 100644
--- a/navit/gui/qt5_qml/editor/main.cpp
+++ b/navit/gui/qt5_qml/editor/main.cpp
@@ -1,8 +1,7 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
diff --git a/navit/gui/qt5_qml/gui_qt5_qml.cpp b/navit/gui/qt5_qml/gui_qt5_qml.cpp
index 1b4062d33..dfdbf5d14 100644
--- a/navit/gui/qt5_qml/gui_qt5_qml.cpp
+++ b/navit/gui/qt5_qml/gui_qt5_qml.cpp
@@ -68,7 +68,7 @@ struct gui_priv {
/* list of callbacks to navit */
struct callback_list* callbacks;
/* own callbacks *
- * TODO: Why do we need them as members? */
+ * TODO: Why do we need them as members? */
struct callback* button_cb;
struct callback* motion_cb;
struct callback* resize_cb;
@@ -95,54 +95,46 @@ struct gui_priv {
#include "backend.h"
-static void
-gui_qt5_qml_button(void* data, int pressed, int button, struct point* p)
-{
+static void gui_qt5_qml_button(void* data, int pressed, int button, struct point* p) {
struct gui_priv* gui_priv = (struct gui_priv*)data;
/* check if navit wants to handle this */
if (!navit_handle_button(gui_priv->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug, "navit has handled button\n");
+ dbg(lvl_debug, "navit has handled button");
return;
}
- dbg(lvl_debug, "enter %d %d\n", pressed, button);
+ dbg(lvl_debug, "enter %d %d", pressed, button);
/* check if user requested menu */
if (button == 1 && gui_priv->menu_on_map_click) {
- dbg(lvl_debug, "navit wants us to enter menu\n");
+ dbg(lvl_debug, "navit wants us to enter menu");
/*TODO: want to emit a signal somewhere? */
gui_priv->backend->showMenu(p);
}
}
-static void
-gui_qt5_qml_motion(void* data, struct point* p)
-{
+static void gui_qt5_qml_motion(void* data, struct point* p) {
struct gui_priv* gui_priv = (struct gui_priv*)data;
- dbg(lvl_debug, "enter (%d, %d)\n", p->x, p->y);
+ dbg(lvl_debug, "enter (%d, %d)", p->x, p->y);
/* forward this to navit */
navit_handle_motion(gui_priv->nav, p);
}
-static void
-gui_qt5_qml_resize(void* data, int w, int h)
-{
+static void gui_qt5_qml_resize(void* data, int w, int h) {
struct gui_priv* gui_priv = (struct gui_priv*)data;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
/* forward this to navit */
navit_handle_resize(gui_priv->nav, w, h);
}
-static void
-gui_qml_keypress(void* data, char* key)
-{
+static void gui_qml_keypress(void* data, char* key) {
struct gui_priv* this_ = (struct gui_priv*)data;
int w, h;
struct point p;
transform_get_size(navit_get_trans(this_->nav), &w, &h);
switch (*key) {
case NAVIT_KEY_UP:
- dbg(lvl_debug, "got KEY_UP\n");
+ dbg(lvl_debug, "got KEY_UP");
p.x = w / 2;
p.y = 0;
navit_set_center_screen(this_->nav, &p, 1);
@@ -163,7 +155,7 @@ gui_qml_keypress(void* data, char* key)
navit_set_center_screen(this_->nav, &p, 1);
break;
case NAVIT_KEY_ZOOM_IN:
- dbg(lvl_debug, "got ZOOM_IN\n");
+ dbg(lvl_debug, "got ZOOM_IN");
navit_zoom_in(this_->nav, 2, NULL);
break;
case NAVIT_KEY_ZOOM_OUT:
@@ -179,11 +171,9 @@ gui_qml_keypress(void* data, char* key)
return;
}
-static int
-gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
-{
+static int gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra) {
struct transformation* trans;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
/* get navit transition */
trans = navit_get_trans(gui_priv->nav);
@@ -212,14 +202,14 @@ gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
/* get main navit window */
gui_priv->win = (struct window*)graphics_get_data(gra, "window");
if (!gui_priv->win) {
- dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics\n");
+ dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics");
return 1;
}
/* expect to have qt5 graphics. So get the qml engine prepared by graphics */
gui_priv->engine = (QQmlApplicationEngine*)graphics_get_data(gra, "engine");
if (gui_priv->engine == NULL) {
- dbg(lvl_error, "Graphics doesn't seem to be qt5, or doesn't have QML. Cannot set graphics\n");
+ dbg(lvl_error, "Graphics doesn't seem to be qt5, or doesn't have QML. Cannot set graphics");
return 1;
}
@@ -233,13 +223,13 @@ gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
/* find the loader component */
gui_priv->loader = gui_priv->engine->rootObjects().value(0)->findChild<QObject*>("navit_loader");
if (gui_priv->loader != NULL) {
- dbg(lvl_debug, "navit_loader found\n");
+ dbg(lvl_debug, "navit_loader found");
/* load our root window into the loader component */
gui_priv->loader->setProperty("source", "qrc:///skins/modern/main.qml");
}
transform_get_size(trans, &gui_priv->w, &gui_priv->h);
- dbg(lvl_debug, "navit provided geometry: (%d, %d)\n", gui_priv->w, gui_priv->h);
+ dbg(lvl_debug, "navit provided geometry: (%d, %d)", gui_priv->w, gui_priv->h);
/* Was resize callback already issued? */
// if (navit_get_ready(gui_priv->nav) & 2)
@@ -251,17 +241,13 @@ gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
return 0;
}
-static int
-gui_qt5_qml_get_attr(struct gui_priv* gui_priv, enum attr_type type, struct attr* attr)
-{
- dbg(lvl_debug, "enter\n");
+static int gui_qt5_qml_get_attr(struct gui_priv* gui_priv, enum attr_type type, struct attr* attr) {
+ dbg(lvl_debug, "enter");
return 1;
}
-static int
-gui_qt5_qml_set_attr(struct gui_priv* gui_priv, struct attr* attr)
-{
- dbg(lvl_debug, "enter\n");
+static int gui_qt5_qml_set_attr(struct gui_priv* gui_priv, struct attr* attr) {
+ dbg(lvl_debug, "enter");
return 1;
}
@@ -278,13 +264,12 @@ struct gui_methods gui_qt5_qml_methods = {
gui_qt5_qml_set_attr,
};
-static struct gui_priv*
-gui_qt5_qml_new(struct navit* nav, struct gui_methods* meth, struct attr** attrs, struct gui* gui)
-{
+static struct gui_priv* gui_qt5_qml_new(struct navit* nav, struct gui_methods* meth, struct attr** attrs,
+ struct gui* gui) {
struct gui_priv* gui_priv;
struct attr* attr;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
/* tell navit our methods */
*meth = gui_qt5_qml_methods;
@@ -315,8 +300,7 @@ gui_qt5_qml_new(struct navit* nav, struct gui_methods* meth, struct attr** attrs
return gui_priv;
}
-void plugin_init(void)
-{
+void plugin_init(void) {
Q_INIT_RESOURCE(gui_qt5_qml);
plugin_register_category_gui("qt5_qml", gui_qt5_qml_new);
}
diff --git a/navit/gui/qt5_qml/proxy.c b/navit/gui/qt5_qml/proxy.c
index 6a3546716..399925519 100644
--- a/navit/gui/qt5_qml/proxy.c
+++ b/navit/gui/qt5_qml/proxy.c
@@ -11,8 +11,7 @@
#include "search.h"
-char * get_icon(struct navit *nav, struct item *item)
-{
+char * get_icon(struct navit *nav, struct item *item) {
struct attr layout;
struct attr icon_src;
@@ -25,7 +24,7 @@ char * get_icon(struct navit *nav, struct item *item)
while(itemgra) {
GList *types=((struct itemgra *)itemgra->data)->type;
while(types) {
- if((long)types->data==item->type) {
+ if((long)types->data==item->type) {
GList *element=((struct itemgra *)itemgra->data)->elements;
while(element) {
struct element * el=element->data;
@@ -41,12 +40,10 @@ char * get_icon(struct navit *nav, struct item *item)
if(!src || !src[0])
src="%s";
icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
- }
- else {
+ } else {
icon=g_strdup(el->u.icon.src);
}
- }
- else {
+ } else {
icon=g_strdup(el->u.icon.src);
}
icon[strlen(icon)-3]='s';
diff --git a/navit/gui/qt5_qml/qml_bookmark.cpp b/navit/gui/qt5_qml/qml_bookmark.cpp
index e215bcd11..5f46a3a44 100644
--- a/navit/gui/qt5_qml/qml_bookmark.cpp
+++ b/navit/gui/qt5_qml/qml_bookmark.cpp
@@ -1,32 +1,27 @@
#include "qml_bookmark.h"
BookmarkObject::BookmarkObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
BookmarkObject::BookmarkObject(
const QString &name,
struct pcoord &coords,
QObject *parent)
- : QObject(parent), m_name(name), m_coords(coords)
-{
+ : QObject(parent), m_name(name), m_coords(coords) {
}
-QString BookmarkObject::name() const
-{
+QString BookmarkObject::name() const {
return m_name;
}
-void BookmarkObject::setName(const QString &name)
-{
+void BookmarkObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-struct pcoord BookmarkObject::coords() const
-{
+struct pcoord BookmarkObject::coords() const {
return m_coords;
}
diff --git a/navit/gui/qt5_qml/qml_map.cpp b/navit/gui/qt5_qml/qml_map.cpp
index 0f38a4768..5a12a29b7 100644
--- a/navit/gui/qt5_qml/qml_map.cpp
+++ b/navit/gui/qt5_qml/qml_map.cpp
@@ -1,35 +1,29 @@
#include "qml_map.h"
MapObject::MapObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
MapObject::MapObject(const QString &name, const bool &active, QObject *parent)
- : QObject(parent), m_name(name), m_active(active)
-{
+ : QObject(parent), m_name(name), m_active(active) {
}
-QString MapObject::name() const
-{
+QString MapObject::name() const {
return m_name;
}
-void MapObject::setName(const QString &name)
-{
+void MapObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-bool MapObject::active() const
-{
+bool MapObject::active() const {
return m_active;
}
-void MapObject::setActive(const bool &active)
-{
+void MapObject::setActive(const bool &active) {
if (active != m_active) {
m_active = active;
emit activeChanged();
diff --git a/navit/gui/qt5_qml/qml_poi.cpp b/navit/gui/qt5_qml/qml_poi.cpp
index 93adf2925..8f0a0ab64 100644
--- a/navit/gui/qt5_qml/qml_poi.cpp
+++ b/navit/gui/qt5_qml/qml_poi.cpp
@@ -1,8 +1,7 @@
#include "qml_poi.h"
PoiObject::PoiObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
PoiObject::PoiObject(
@@ -12,63 +11,53 @@ PoiObject::PoiObject(
const QString &icon,
struct pcoord &coords,
QObject *parent)
- : QObject(parent), m_name(name), m_type(type), m_icon(icon), m_coords(coords)
-{
+ : QObject(parent), m_name(name), m_type(type), m_icon(icon), m_coords(coords) {
}
-QString PoiObject::name() const
-{
+QString PoiObject::name() const {
return m_name;
}
-void PoiObject::setName(const QString &name)
-{
+void PoiObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-QString PoiObject::type() const
-{
+QString PoiObject::type() const {
return m_type;
}
-void PoiObject::setType(const QString &type)
-{
+void PoiObject::setType(const QString &type) {
if (type != m_type) {
m_type = type;
emit typeChanged();
}
}
-float PoiObject::distance() const
-{
+float PoiObject::distance() const {
return m_distance/1000;
}
-void PoiObject::setDistance(const int distance)
-{
+void PoiObject::setDistance(const int distance) {
if (distance != m_distance) {
m_distance = distance;
emit distanceChanged();
}
}
-void PoiObject::setIcon(const QString &icon)
-{
+void PoiObject::setIcon(const QString &icon) {
if (icon != m_icon) {
m_icon = icon;
emit iconChanged();
}
}
-QString PoiObject::icon() const
-{
+QString PoiObject::icon() const {
return m_icon;
}
-struct pcoord PoiObject::coords() const
-{
+struct pcoord PoiObject::coords() const {
return m_coords;
}
diff --git a/navit/gui/qt5_qml/qml_search.cpp b/navit/gui/qt5_qml/qml_search.cpp
index 0a82e37d3..8c15fbd03 100644
--- a/navit/gui/qt5_qml/qml_search.cpp
+++ b/navit/gui/qt5_qml/qml_search.cpp
@@ -1,42 +1,35 @@
#include "qml_search.h"
SearchObject::SearchObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
SearchObject::SearchObject(const QString &name, const QString &icon, struct pcoord *c, QObject *parent)
- : QObject(parent), m_name(name), m_icon(icon), m_c(c)
-{
+ : QObject(parent), m_name(name), m_icon(icon), m_c(c) {
}
-QString SearchObject::name() const
-{
+QString SearchObject::name() const {
return m_name;
}
-void SearchObject::setName(const QString &name)
-{
+void SearchObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-QString SearchObject::icon() const
-{
+QString SearchObject::icon() const {
return m_icon;
}
-void SearchObject::setIcon(const QString &icon)
-{
+void SearchObject::setIcon(const QString &icon) {
if (icon != m_icon) {
m_icon = icon;
emit iconChanged();
}
}
-struct pcoord * SearchObject::getCoords() const
-{
+struct pcoord * SearchObject::getCoords() const {
return m_c;
}
diff --git a/navit/gui/qt5_qml/qml_vehicle.cpp b/navit/gui/qt5_qml/qml_vehicle.cpp
index bf79ad4c4..d09d65408 100644
--- a/navit/gui/qt5_qml/qml_vehicle.cpp
+++ b/navit/gui/qt5_qml/qml_vehicle.cpp
@@ -1,48 +1,40 @@
#include "qml_vehicle.h"
VehicleObject::VehicleObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
VehicleObject::VehicleObject(const QString &name, const bool &active, struct vehicle *v, QObject *parent)
- : QObject(parent), m_name(name), m_active(active), m_vehicle(v)
-{
+ : QObject(parent), m_name(name), m_active(active), m_vehicle(v) {
}
-QString VehicleObject::name() const
-{
+QString VehicleObject::name() const {
return m_name;
}
-void VehicleObject::setName(const QString &name)
-{
+void VehicleObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-bool VehicleObject::active() const
-{
+bool VehicleObject::active() const {
return m_active;
}
-void VehicleObject::setActive(const bool &active)
-{
+void VehicleObject::setActive(const bool &active) {
if (active != m_active) {
m_active = active;
emit activeChanged();
}
}
-struct vehicle * VehicleObject::vehicle() const
-{
+struct vehicle * VehicleObject::vehicle() const {
return m_vehicle;
}
-void VehicleObject::setVehicle(struct vehicle * vehicle)
-{
+void VehicleObject::setVehicle(struct vehicle * vehicle) {
if (vehicle != m_vehicle) {
m_vehicle = vehicle;
emit vehicleChanged();
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg b/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg
index 3917fc7cd..7dfd18eb4 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,39.5833L 52.1016,24.9375L 52.1016,35.2292L 37.8516,50.2708L 23.6016,35.2292L 23.6016,24.9375L 37.8516,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg b/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg
index b737d9773..a84cb0b21 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,35.625L 34.6849,38.7917L 23.6016,50.2708L 23.6016,39.9792L 37.8516,24.9375L 52.1016,39.9792L 52.1016,50.2708L 41.0182,38.7917L 37.8516,35.625 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.cog.svg b/navit/gui/qt5_qml/skins/icons/appbar.cog.svg
index 4ef1ef8c2..0c0590fcc 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.cog.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.cog.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.5314,21.8628L 33.0126,19.4224L 34.7616,23.3507C 36.6693,22.9269 38.6044,22.8903 40.4668,23.2026L 42.0083,19.1868L 47.6098,21.337L 46.0683,25.3528C 47.6612,26.3669 49.0747,27.6889 50.2088,29.2803L 54.1371,27.5313L 56.5776,33.0126L 52.6493,34.7616C 53.0731,36.6693 53.1097,38.6043 52.7974,40.4668L 56.8131,42.0083L 54.6629,47.6097L 50.6472,46.0683C 49.6331,47.6613 48.3111,49.0748 46.7197,50.2089L 48.4686,54.1372L 42.9874,56.5776L 41.2384,52.6493C 39.3307,53.0731 37.3957,53.1097 35.5333,52.7974L 33.9918,56.8131L 28.3903,54.6629L 29.9318,50.6472C 28.3388,49.6331 26.9252,48.3111 25.7911,46.7196L 21.8628,48.4686L 19.4224,42.9873L 23.3507,41.2383C 22.9269,39.3307 22.8903,37.3957 23.2026,35.5332L 19.1869,33.9918L 21.3371,28.3903L 25.3528,29.9318C 26.3669,28.3388 27.6889,26.9252 29.2804,25.7911L 27.5314,21.8628 Z M 34.3394,29.7781C 29.7985,31.7998 27.7564,37.1198 29.7781,41.6606C 31.7998,46.2015 37.1198,48.2436 41.6606,46.2219C 46.2015,44.2002 48.2436,38.8802 46.2219,34.3394C 44.2002,29.7985 38.8802,27.7564 34.3394,29.7781 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg b/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg
index e3fdaa4ce..d8c1ab0fa 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 32.6227,68.9728C 33.1208,70.2446 33.7077,71.4719 34.3757,72.6471C 35.567,72.7702 36.7761,72.8333 38,72.8333C 40.6447,72.8333 43.2205,72.5386 45.6965,71.9802C 42.2807,68.5449 40.1698,63.8107 40.1698,58.5835C 40.1698,48.0901 48.6764,39.5835 59.1698,39.5835C 64.2047,39.5835 68.7822,41.5419 72.182,44.7385C 72.6094,42.5584 72.8333,40.3053 72.8333,38C 72.8333,36.442 72.731,34.908 72.5328,33.4041C 70.4772,32.3109 68.2718,31.4621 65.9554,30.8963L 65.6219,22.7367C 63.5664,22.3692 61.4511,22.1741 59.2916,22.1671L 57.491,30.1322C 54.2845,30.3184 51.2204,31.0348 48.3848,32.1949L 43.318,25.7887C 41.3995,26.7177 39.5749,27.8102 37.8622,29.0479L 41.0883,36.5527C 38.6742,38.5364 36.5919,40.9091 34.9373,43.575L 27.0703,41.3697C 26.073,43.2256 25.2319,45.178 24.5646,47.2093L 31.5867,51.385C 30.9883,53.6844 30.6698,56.0968 30.6698,58.5835L 30.746,60.6839L 23.0854,63.5239C 23.3743,65.6539 23.8474,67.7255 24.4881,69.7219L 32.6227,68.9728 Z M 27.0669,37.1755L 34.9338,39.3807C 35.9312,37.5248 36.7723,35.5724 37.4395,33.5412L 30.4175,29.3654C 31.0159,27.066 31.3344,24.6537 31.3344,22.1669L 31.2581,20.0665L 38.9187,17.2265C 38.6299,15.0965 38.1568,13.0249 37.5161,11.0285L 29.3815,11.7776C 28.4787,9.47258 27.2844,7.31377 25.8439,5.34655C 22.7943,6.48232 19.9467,8.03307 17.3698,9.93015C 20.1557,13.2359 21.8344,17.5054 21.8344,22.1669C 21.8344,32.5019 13.5826,40.9096 3.30816,41.1611C 3.60321,44.4411 4.35293,47.59 5.49381,50.5444C 8.34489,50.2806 11.0742,49.5968 13.6194,48.5555L 18.6861,54.9617C 20.6046,54.0327 22.4293,52.9403 24.142,51.7025L 20.9158,44.1977C 23.3299,42.2141 25.4123,39.8414 27.0669,37.1755 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg b/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg
index 13e6840e5..a3e73f41a 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 19,57L 19,19L 57,19L 57,57L 19,57 Z M 24,29L 47,29L 47,52L 52,52L 52,24L 24,24L 24,29 Z M 24,34L 24,52L 42,52L 42,34L 24,34 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg b/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg
index ea951fd19..273ff72cd 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 24.0033,56.0078L 24.0033,38.0053L 22.0031,40.0056L 19.0027,35.0049L 38.0053,20.0028L 45.0063,25.5299L 45.0063,21.753L 49.0068,21.0029L 49.0068,28.6882L 57.008,35.0049L 54.0075,40.0056L 52.0073,38.0053L 52.0073,56.0078L 24.0033,56.0078 Z M 38.0053,26.9204L 27.0038,36.005L 27.0038,53.0074L 38.0045,53.0075L 38.0045,41.0061L 46.0058,41.0061L 46.0059,53.0075L 49.0068,53.0074L 49.0068,36.005L 38.0053,26.9204 Z M 30.004,41.0057L 35.0049,41.0057L 35.0049,47.0066L 30.004,47.0066L 30.004,41.0057 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg b/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg
index 031bd37f5..35a156ae9 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 48.4934,19 57,27.5066 57,38C 57,48.4934 48.4934,57 38,57C 27.5066,57 19,48.4934 19,38C 19,27.5066 27.5066,19 38,19 Z M 33.25,33.25L 33.25,36.4167L 36.4166,36.4167L 36.4166,47.5L 33.25,47.5L 33.25,50.6667L 44.3333,50.6667L 44.3333,47.5L 41.1666,47.5L 41.1666,36.4167L 41.1666,33.25L 33.25,33.25 Z M 38.7917,25.3333C 37.48,25.3333 36.4167,26.3967 36.4167,27.7083C 36.4167,29.02 37.48,30.0833 38.7917,30.0833C 40.1033,30.0833 41.1667,29.02 41.1667,27.7083C 41.1667,26.3967 40.1033,25.3333 38.7917,25.3333 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg b/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg
index ddbeb21ca..5157af942 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 18.5088,44.0374L 21.8676,40.6786L 27.4655,46.2765L 33.0634,40.6786L 36.4222,44.0374L 30.8243,49.6353L 36.4222,55.2332L 33.0634,58.592L 27.4655,52.994L 21.8676,58.592L 18.5088,55.2332L 24.1068,49.6353L 18.5088,44.0374 Z M 57.0079,38.0053L 38.0053,47.5066L 36.7482,46.8781L 39.5889,44.0374L 35.2559,39.7977L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 19.0026,38.0053L 25.3369,34.8382L 32.3326,38.3361L 29.8968,40.7719L 28.1098,42.5589L 25.7193,41.3636L 21.8676,37.6052L 20.6459,38.8269L 19.0026,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 37.8778,56.9442L 39.5889,55.2332L 33.9909,49.6353L 34.6367,48.9895L 38.0053,50.6738L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.layer.svg b/navit/gui/qt5_qml/skins/icons/appbar.layer.svg
index 9eb28235c..b89bb2da3 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.layer.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.layer.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 57.0079,38.0053L 38.0053,47.5066L 19.0027,38.0053L 25.3369,34.8382L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 19.0026,47.5066L 25.3369,44.3395L 38.0053,50.6737L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg b/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg
index 3b21754c6..a58141d22 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-linejoin="round" d="M 38,19C 42.9706,19 47,23.0294 47,28C 47,30.5642 45.9276,32.878 38,49C 30.0724,32.878 29,30.5642 29,28C 29,23.0294 33.0294,19 38,19 Z M 38,24C 35.7909,24 34,25.7909 34,28C 34,30.2092 35.7909,32 38,32C 40.2091,32 42,30.2092 42,28C 42,25.7909 40.2091,24 38,24 Z M 19,57L 24,42L 31.5,42L 33.5,46L 27.6641,46L 25.3324,53L 50.6676,53L 48.3359,46L 42.5,46L 44.5,42L 52,42L 57,57L 19,57 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.map.svg b/navit/gui/qt5_qml/skins/icons/appbar.map.svg
index 241f71e59..0a157d0da 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.map.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.map.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.7083,23.75L 38.7917,26.9167L 48.2917,20.5833L 62,24L 62,51L 48.2917,47.5L 38.7917,53.8333L 27.7083,50.6667L 16,55.5L 16,28.5L 27.7083,23.75 Z M 27,46.25L 27,29L 20,31.75L 20,49L 27,46.25 Z M 49,25.5L 49,42.75L 58,45.25L 58,28L 49,25.5 Z M 39,31.5L 39,49L 48,43L 48,25.5L 39,31.5 Z M 28,28.75L 28,46L 38,48.5L 38,31.75L 28,28.75 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.power.svg b/navit/gui/qt5_qml/skins/icons/appbar.power.svg
index d3f865c0d..db23bca1f 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.power.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.power.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 36.4167,36.4167L 36.4167,17.4167L 41.1667,17.4167L 41.1667,36.4167L 36.4167,36.4167 Z M 57,39.5833C 57,50.0767 48.4934,58.5833 38,58.5833C 27.5066,58.5833 19,50.0767 19,39.5833C 19,30.7301 25.0552,23.2911 33.25,21.1819L 33.25,27.8374C 28.6079,29.7165 25.3333,34.2675 25.3333,39.5833C 25.3333,46.5789 31.0044,52.25 38,52.25C 44.9956,52.25 50.6667,46.5789 50.6667,39.5833C 50.6667,34.8949 48.1194,30.8014 44.3333,28.6113L 44.3333,21.6645C 51.7129,24.2728 57,31.3106 57,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg b/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg
index a8c5c273a..d3b9d0a16 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 39.4823,20.6344 43,26.1259 43,41L 47,46L 47,55L 43,50L 33,50L 29,55L 29,46L 33,41C 33,26.1259 36.0177,20.6344 38,19 Z M 38,57.5L 35,51L 41,51L 38,57.5 Z M 38,27L 36.1552,27.4612L 35.6203,30.5949L 38,30L 40.2918,30.573L 39.6953,27.4238L 38,27 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg b/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg
index 8ea1a7c5d..3a6e7a287 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 17.4167,50.6667C 16.5422,50.6667 15.8333,49.9578 15.8333,49.0833L 15.8333,39.5834C 15.8333,37.0877 17.2768,34.9292 19.3745,33.8972L 25.3333,19L 26.9167,19L 30.0833,19L 45.9167,19L 49.0833,19L 50.6667,19L 56.6255,33.8972C 58.7231,34.9292 60.1666,37.0877 60.1666,39.5834L 60.1667,49.0833C 60.1667,49.9578 59.4578,50.6667 58.5833,50.6667L 57,50.6667L 57,53.8333C 57,55.5822 55.5822,57 53.8333,57C 52.0844,57 50.6667,55.5822 50.6667,53.8333L 50.6667,50.6667L 25.3333,50.6667L 25.3333,53.8333C 25.3333,55.5822 23.9156,57 22.1667,57C 20.4178,57 19,55.5822 19,53.8333L 19,50.6667L 17.4167,50.6667 Z M 24.3833,33.25L 51.6166,33.25L 47.8166,23.75L 28.1833,23.75L 24.3833,33.25 Z M 24.1458,36.0209C 22.3969,36.0209 20.5833,37.8344 20.5833,39.5833C 20.5833,41.3322 22.3969,43.1458 24.1458,43.1458C 25.8947,43.1458 27.7083,41.3323 27.7083,39.5834C 27.7083,37.8345 25.8947,36.0209 24.1458,36.0209 Z M 51.8542,36.0208C 50.1053,36.0208 48.2917,37.8344 48.2917,39.5833C 48.2917,41.3322 50.1053,43.1458 51.8542,43.1458C 53.6031,43.1458 55.4167,41.3322 55.4167,39.5833C 55.4167,37.8344 53.6031,36.0208 51.8542,36.0208 Z "/>
diff --git a/navit/gui/qt5_qml/skins/menu.qml b/navit/gui/qt5_qml/skins/menu.qml
index 540a16032..0cb9ce38c 100644
--- a/navit/gui/qt5_qml/skins/menu.qml
+++ b/navit/gui/qt5_qml/skins/menu.qml
@@ -18,7 +18,7 @@ Rectangle {
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
-
+
Loader {
id: menucontent
width: parent.width
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg
index 9dda725d2..c8e86b13f 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 22,19L 24,19L 24,57L 22,57L 22,19 Z M 26,57L 26,19.0001L 53.9999,19.0001L 53.9999,57L 26,57 Z M 30,24L 30,27L 50,27L 50,24L 30,24 Z M 30,32L 30,35L 33,35L 33,32L 30,32 Z M 36,32L 36,35L 49,35L 49,32L 36,32 Z M 30,40L 30,43L 33,43L 33,40L 30,40 Z M 36,40L 36,43L 48,43L 48,40L 36,40 Z M 30,48L 30,51L 33,51L 33,48L 30,48 Z M 36,48L 36,51L 50,51L 50,48L 36,48 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg
index 3917fc7cd..7dfd18eb4 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,39.5833L 52.1016,24.9375L 52.1016,35.2292L 37.8516,50.2708L 23.6016,35.2292L 23.6016,24.9375L 37.8516,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg
index b737d9773..a84cb0b21 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,35.625L 34.6849,38.7917L 23.6016,50.2708L 23.6016,39.9792L 37.8516,24.9375L 52.1016,39.9792L 52.1016,50.2708L 41.0182,38.7917L 37.8516,35.625 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg
index f66893f7e..b23bfadeb 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 44.3333,30.0833L 57,30.0833L 57,57L 44.3333,57L 44.3333,30.0833 Z M 46.3125,35.2292L 46.3125,38L 49.0833,38L 49.0833,35.2292L 46.3125,35.2292 Z M 52.25,35.2292L 52.25,38L 55.0208,38L 55.0208,35.2292L 52.25,35.2292 Z M 46.3125,39.9792L 46.3125,42.75L 49.0833,42.75L 49.0833,39.9792L 46.3125,39.9792 Z M 52.25,39.9792L 52.25,42.75L 55.0208,42.75L 55.0208,39.9792L 52.25,39.9792 Z M 46.3125,44.7292L 46.3125,47.5L 49.0833,47.5L 49.0833,44.7292L 46.3125,44.7292 Z M 52.25,44.7292L 52.25,47.5L 55.0208,47.5L 55.0208,44.7292L 52.25,44.7292 Z M 46.3125,49.4792L 46.3125,52.25L 49.0833,52.25L 49.0833,49.4792L 46.3125,49.4792 Z M 52.25,49.4792L 52.25,52.25L 55.0208,52.25L 55.0208,49.4792L 52.25,49.4792 Z M 23.75,25.3333L 25.3333,22.1667L 26.9167,22.1667L 26.9167,18.2084L 28.5,18.2084L 28.5,22.1667L 31.6667,22.1667L 31.6667,18.2084L 33.25,18.2084L 33.25,22.1667L 34.8333,22.1667L 36.4167,25.3333L 36.4167,34.8334L 38.7917,34.8333L 41.1667,37.2083L 41.1667,57L 19,57L 19,37.2083L 21.375,34.8333L 23.75,34.8334L 23.75,25.3333 Z M 25.7291,27.3125L 25.7291,30.0834L 28.1041,30.0834L 28.1041,27.3125L 25.7291,27.3125 Z M 32.0625,27.3125L 32.0625,30.0834L 34.4375,30.0834L 34.4375,27.3125L 32.0625,27.3125 Z M 25.7291,32.0625L 25.7291,34.8334L 28.1041,34.8334L 28.1041,32.0625L 25.7291,32.0625 Z M 32.0625,32.0625L 32.0625,34.8334L 34.4375,34.8334L 34.4375,32.0625L 32.0625,32.0625 Z M 30.875,39.9792L 28.8958,39.9792L 28.8958,42.75L 30.875,42.75L 30.875,39.9792 Z M 24.5416,39.9792L 24.5416,42.75L 26.9166,42.75L 26.9166,39.9792L 24.5416,39.9792 Z M 36.0208,39.9792L 33.25,39.9792L 33.25,42.75L 36.0208,42.75L 36.0208,39.9792 Z M 30.875,44.7292L 28.8958,44.7292L 28.8958,47.5L 30.875,47.5L 30.875,44.7292 Z M 26.9166,44.7292L 24.5416,44.7292L 24.5416,47.5L 26.9166,47.5L 26.9166,44.7292 Z M 36.0208,44.7292L 33.25,44.7292L 33.25,47.5L 36.0208,47.5L 36.0208,44.7292 Z M 30.875,49.4792L 28.8958,49.4792L 28.8958,52.25L 30.875,52.25L 30.875,49.4792 Z M 26.9166,49.4792L 24.5416,49.4792L 24.5417,52.25L 26.9167,52.25L 26.9166,49.4792 Z M 36.0208,49.4792L 33.25,49.4792L 33.25,52.25L 36.0208,52.25L 36.0208,49.4792 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg
index 4ef1ef8c2..0c0590fcc 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.5314,21.8628L 33.0126,19.4224L 34.7616,23.3507C 36.6693,22.9269 38.6044,22.8903 40.4668,23.2026L 42.0083,19.1868L 47.6098,21.337L 46.0683,25.3528C 47.6612,26.3669 49.0747,27.6889 50.2088,29.2803L 54.1371,27.5313L 56.5776,33.0126L 52.6493,34.7616C 53.0731,36.6693 53.1097,38.6043 52.7974,40.4668L 56.8131,42.0083L 54.6629,47.6097L 50.6472,46.0683C 49.6331,47.6613 48.3111,49.0748 46.7197,50.2089L 48.4686,54.1372L 42.9874,56.5776L 41.2384,52.6493C 39.3307,53.0731 37.3957,53.1097 35.5333,52.7974L 33.9918,56.8131L 28.3903,54.6629L 29.9318,50.6472C 28.3388,49.6331 26.9252,48.3111 25.7911,46.7196L 21.8628,48.4686L 19.4224,42.9873L 23.3507,41.2383C 22.9269,39.3307 22.8903,37.3957 23.2026,35.5332L 19.1869,33.9918L 21.3371,28.3903L 25.3528,29.9318C 26.3669,28.3388 27.6889,26.9252 29.2804,25.7911L 27.5314,21.8628 Z M 34.3394,29.7781C 29.7985,31.7998 27.7564,37.1198 29.7781,41.6606C 31.7998,46.2015 37.1198,48.2436 41.6606,46.2219C 46.2015,44.2002 48.2436,38.8802 46.2219,34.3394C 44.2002,29.7985 38.8802,27.7564 34.3394,29.7781 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg
index e3fdaa4ce..d8c1ab0fa 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 32.6227,68.9728C 33.1208,70.2446 33.7077,71.4719 34.3757,72.6471C 35.567,72.7702 36.7761,72.8333 38,72.8333C 40.6447,72.8333 43.2205,72.5386 45.6965,71.9802C 42.2807,68.5449 40.1698,63.8107 40.1698,58.5835C 40.1698,48.0901 48.6764,39.5835 59.1698,39.5835C 64.2047,39.5835 68.7822,41.5419 72.182,44.7385C 72.6094,42.5584 72.8333,40.3053 72.8333,38C 72.8333,36.442 72.731,34.908 72.5328,33.4041C 70.4772,32.3109 68.2718,31.4621 65.9554,30.8963L 65.6219,22.7367C 63.5664,22.3692 61.4511,22.1741 59.2916,22.1671L 57.491,30.1322C 54.2845,30.3184 51.2204,31.0348 48.3848,32.1949L 43.318,25.7887C 41.3995,26.7177 39.5749,27.8102 37.8622,29.0479L 41.0883,36.5527C 38.6742,38.5364 36.5919,40.9091 34.9373,43.575L 27.0703,41.3697C 26.073,43.2256 25.2319,45.178 24.5646,47.2093L 31.5867,51.385C 30.9883,53.6844 30.6698,56.0968 30.6698,58.5835L 30.746,60.6839L 23.0854,63.5239C 23.3743,65.6539 23.8474,67.7255 24.4881,69.7219L 32.6227,68.9728 Z M 27.0669,37.1755L 34.9338,39.3807C 35.9312,37.5248 36.7723,35.5724 37.4395,33.5412L 30.4175,29.3654C 31.0159,27.066 31.3344,24.6537 31.3344,22.1669L 31.2581,20.0665L 38.9187,17.2265C 38.6299,15.0965 38.1568,13.0249 37.5161,11.0285L 29.3815,11.7776C 28.4787,9.47258 27.2844,7.31377 25.8439,5.34655C 22.7943,6.48232 19.9467,8.03307 17.3698,9.93015C 20.1557,13.2359 21.8344,17.5054 21.8344,22.1669C 21.8344,32.5019 13.5826,40.9096 3.30816,41.1611C 3.60321,44.4411 4.35293,47.59 5.49381,50.5444C 8.34489,50.2806 11.0742,49.5968 13.6194,48.5555L 18.6861,54.9617C 20.6046,54.0327 22.4293,52.9403 24.142,51.7025L 20.9158,44.1977C 23.3299,42.2141 25.4123,39.8414 27.0669,37.1755 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg
index 13e6840e5..a3e73f41a 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 19,57L 19,19L 57,19L 57,57L 19,57 Z M 24,29L 47,29L 47,52L 52,52L 52,24L 24,24L 24,29 Z M 24,34L 24,52L 42,52L 42,34L 24,34 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg
index ea951fd19..273ff72cd 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 24.0033,56.0078L 24.0033,38.0053L 22.0031,40.0056L 19.0027,35.0049L 38.0053,20.0028L 45.0063,25.5299L 45.0063,21.753L 49.0068,21.0029L 49.0068,28.6882L 57.008,35.0049L 54.0075,40.0056L 52.0073,38.0053L 52.0073,56.0078L 24.0033,56.0078 Z M 38.0053,26.9204L 27.0038,36.005L 27.0038,53.0074L 38.0045,53.0075L 38.0045,41.0061L 46.0058,41.0061L 46.0059,53.0075L 49.0068,53.0074L 49.0068,36.005L 38.0053,26.9204 Z M 30.004,41.0057L 35.0049,41.0057L 35.0049,47.0066L 30.004,47.0066L 30.004,41.0057 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg
index 031bd37f5..35a156ae9 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 48.4934,19 57,27.5066 57,38C 57,48.4934 48.4934,57 38,57C 27.5066,57 19,48.4934 19,38C 19,27.5066 27.5066,19 38,19 Z M 33.25,33.25L 33.25,36.4167L 36.4166,36.4167L 36.4166,47.5L 33.25,47.5L 33.25,50.6667L 44.3333,50.6667L 44.3333,47.5L 41.1666,47.5L 41.1666,36.4167L 41.1666,33.25L 33.25,33.25 Z M 38.7917,25.3333C 37.48,25.3333 36.4167,26.3967 36.4167,27.7083C 36.4167,29.02 37.48,30.0833 38.7917,30.0833C 40.1033,30.0833 41.1667,29.02 41.1667,27.7083C 41.1667,26.3967 40.1033,25.3333 38.7917,25.3333 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg
index ddbeb21ca..5157af942 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 18.5088,44.0374L 21.8676,40.6786L 27.4655,46.2765L 33.0634,40.6786L 36.4222,44.0374L 30.8243,49.6353L 36.4222,55.2332L 33.0634,58.592L 27.4655,52.994L 21.8676,58.592L 18.5088,55.2332L 24.1068,49.6353L 18.5088,44.0374 Z M 57.0079,38.0053L 38.0053,47.5066L 36.7482,46.8781L 39.5889,44.0374L 35.2559,39.7977L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 19.0026,38.0053L 25.3369,34.8382L 32.3326,38.3361L 29.8968,40.7719L 28.1098,42.5589L 25.7193,41.3636L 21.8676,37.6052L 20.6459,38.8269L 19.0026,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 37.8778,56.9442L 39.5889,55.2332L 33.9909,49.6353L 34.6367,48.9895L 38.0053,50.6738L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg
index 9eb28235c..b89bb2da3 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 57.0079,38.0053L 38.0053,47.5066L 19.0027,38.0053L 25.3369,34.8382L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 19.0026,47.5066L 25.3369,44.3395L 38.0053,50.6737L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg
index 3b21754c6..a58141d22 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-linejoin="round" d="M 38,19C 42.9706,19 47,23.0294 47,28C 47,30.5642 45.9276,32.878 38,49C 30.0724,32.878 29,30.5642 29,28C 29,23.0294 33.0294,19 38,19 Z M 38,24C 35.7909,24 34,25.7909 34,28C 34,30.2092 35.7909,32 38,32C 40.2091,32 42,30.2092 42,28C 42,25.7909 40.2091,24 38,24 Z M 19,57L 24,42L 31.5,42L 33.5,46L 27.6641,46L 25.3324,53L 50.6676,53L 48.3359,46L 42.5,46L 44.5,42L 52,42L 57,57L 19,57 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg
index fff6bf3e1..22f2d7001 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 26.9167,13.8542L 50.6666,13.8542L 50.6667,39.5833L 26.9167,63.3333L 26.9167,13.8542 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg
index 241f71e59..0a157d0da 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.7083,23.75L 38.7917,26.9167L 48.2917,20.5833L 62,24L 62,51L 48.2917,47.5L 38.7917,53.8333L 27.7083,50.6667L 16,55.5L 16,28.5L 27.7083,23.75 Z M 27,46.25L 27,29L 20,31.75L 20,49L 27,46.25 Z M 49,25.5L 49,42.75L 58,45.25L 58,28L 49,25.5 Z M 39,31.5L 39,49L 48,43L 48,25.5L 39,31.5 Z M 28,28.75L 28,46L 38,48.5L 38,31.75L 28,28.75 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg
index d3f865c0d..db23bca1f 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 36.4167,36.4167L 36.4167,17.4167L 41.1667,17.4167L 41.1667,36.4167L 36.4167,36.4167 Z M 57,39.5833C 57,50.0767 48.4934,58.5833 38,58.5833C 27.5066,58.5833 19,50.0767 19,39.5833C 19,30.7301 25.0552,23.2911 33.25,21.1819L 33.25,27.8374C 28.6079,29.7165 25.3333,34.2675 25.3333,39.5833C 25.3333,46.5789 31.0044,52.25 38,52.25C 44.9956,52.25 50.6667,46.5789 50.6667,39.5833C 50.6667,34.8949 48.1194,30.8014 44.3333,28.6113L 44.3333,21.6645C 51.7129,24.2728 57,31.3106 57,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg
index a8c5c273a..d3b9d0a16 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 39.4823,20.6344 43,26.1259 43,41L 47,46L 47,55L 43,50L 33,50L 29,55L 29,46L 33,41C 33,26.1259 36.0177,20.6344 38,19 Z M 38,57.5L 35,51L 41,51L 38,57.5 Z M 38,27L 36.1552,27.4612L 35.6203,30.5949L 38,30L 40.2918,30.573L 39.6953,27.4238L 38,27 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg
index a02cff6b7..7aded7af0 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 53.8333,41.1667C 53.8333,49.9112 46.7445,57 38,57C 29.2555,57 22.1667,49.9112 22.1667,41.1667C 22.1667,32.9565 28.4156,26.2059 36.4167,25.4115L 36.4167,23.75L 31.6667,23.75L 31.6667,19L 44.3333,19L 44.3333,23.75L 39.5833,23.75L 39.5833,25.4115C 42.7678,25.7277 45.6747,26.9874 48.0205,28.907L 49.1629,27.7646L 46.9237,25.5254L 50.2825,22.1667L 57,28.8842L 53.6412,32.2429L 51.4021,30.0038L 50.2597,31.1462C 52.4932,33.8756 53.8333,37.3647 53.8333,41.1667 Z M 26.2296,39.5834L 30.0833,39.5834L 30.0833,42.75L 26.2296,42.75C 26.9347,48.0419 31.1248,52.232 36.4166,52.9371L 36.4166,49.0833L 39.5833,49.0833L 39.5833,52.9371C 44.8752,52.232 49.0653,48.0419 49.7703,42.75L 45.9166,42.75L 45.9166,39.5834L 49.7703,39.5834C 49.0652,34.2915 44.8751,30.1014 39.5833,29.3964L 39.5833,33.25L 36.4166,33.25L 36.4166,29.3964C 31.1248,30.1014 26.9347,34.2915 26.2296,39.5834 Z M 38,38C 39.7488,38 41.1666,39.4178 41.1666,41.1667C 41.1666,42.9156 39.7488,44.3334 38,44.3334L 31.6666,49.0834L 34.8333,41.1667C 34.8333,39.4178 36.2511,38 38,38 Z M 19.7917,33.25L 19.7917,26.938C 17.2963,30.5244 15.8333,34.883 15.8333,39.5833C 15.8333,51.8257 25.7577,61.75 38,61.75L 42.3542,61.75C 54.3778,61.75 64.1249,51.8257 64.125,39.5835C 64.125,54.0119 52.4284,65.7083 38,65.7083C 23.5716,65.7083 11.875,54.0118 11.875,39.5833C 11.875,33.9832 13.6371,28.7946 16.637,24.5417L 11.0833,24.5417L 15.0417,20.5834L 23.75,20.5833L 23.75,29.2917L 19.7917,33.25 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg
index 8ea1a7c5d..3a6e7a287 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 17.4167,50.6667C 16.5422,50.6667 15.8333,49.9578 15.8333,49.0833L 15.8333,39.5834C 15.8333,37.0877 17.2768,34.9292 19.3745,33.8972L 25.3333,19L 26.9167,19L 30.0833,19L 45.9167,19L 49.0833,19L 50.6667,19L 56.6255,33.8972C 58.7231,34.9292 60.1666,37.0877 60.1666,39.5834L 60.1667,49.0833C 60.1667,49.9578 59.4578,50.6667 58.5833,50.6667L 57,50.6667L 57,53.8333C 57,55.5822 55.5822,57 53.8333,57C 52.0844,57 50.6667,55.5822 50.6667,53.8333L 50.6667,50.6667L 25.3333,50.6667L 25.3333,53.8333C 25.3333,55.5822 23.9156,57 22.1667,57C 20.4178,57 19,55.5822 19,53.8333L 19,50.6667L 17.4167,50.6667 Z M 24.3833,33.25L 51.6166,33.25L 47.8166,23.75L 28.1833,23.75L 24.3833,33.25 Z M 24.1458,36.0209C 22.3969,36.0209 20.5833,37.8344 20.5833,39.5833C 20.5833,41.3322 22.3969,43.1458 24.1458,43.1458C 25.8947,43.1458 27.7083,41.3323 27.7083,39.5834C 27.7083,37.8345 25.8947,36.0209 24.1458,36.0209 Z M 51.8542,36.0208C 50.1053,36.0208 48.2917,37.8344 48.2917,39.5833C 48.2917,41.3322 50.1053,43.1458 51.8542,43.1458C 53.6031,43.1458 55.4167,41.3322 55.4167,39.5833C 55.4167,37.8344 53.6031,36.0208 51.8542,36.0208 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/main.qml b/navit/gui/qt5_qml/skins/modern/main.qml
index 3c35a4dd0..5ffd1de3e 100644
--- a/navit/gui/qt5_qml/skins/modern/main.qml
+++ b/navit/gui/qt5_qml/skins/modern/main.qml
@@ -68,7 +68,7 @@ Rectangle {
NumberAnimation {
properties: "x,y,opacity";duration: 200
}
- onRunningChanged: {
+ onRunningChanged: {
if ((mainMenu.opacity == 0) && (!running)){
backend.resize(navit1.width, navit1.height);
console.log("transition done, hiding menu window size " + navit1.width + " x " + navit1.height)
diff --git a/navit/gui/qt5_qml/skins/modern/menu.qml b/navit/gui/qt5_qml/skins/modern/menu.qml
index ee51f68a2..bcca54b0b 100644
--- a/navit/gui/qt5_qml/skins/modern/menu.qml
+++ b/navit/gui/qt5_qml/skins/modern/menu.qml
@@ -8,7 +8,7 @@ Item {
width: parent.width
y: topBar.height
height: parent.height - ( topBar.height + bottomBar.height )
-
+
Loader {
id: menucontent
width: parent.width
diff --git a/navit/gui/qt5_qml/skins/pois.qml b/navit/gui/qt5_qml/skins/pois.qml
index bc083e1ed..a78260211 100644
--- a/navit/gui/qt5_qml/skins/pois.qml
+++ b/navit/gui/qt5_qml/skins/pois.qml
@@ -10,14 +10,14 @@ Item {
color: "#ff0000"
radius: 2
border.width: 1
-
+
Image {
id: image1
height: parent.height - 4;
source : model.modelData.active ? "icons/appbar.layer.svg" : "icons/appbar.layer.delete.svg"
opacity: model.modelData.active ? 1 : 0.4
}
-
+
Text {
width: 128
id: distanceText
@@ -27,7 +27,7 @@ Item {
anchors.left: image1.right
anchors.leftMargin: 8
}
-
+
Text {
text: name
color: "#ffffff"
@@ -35,7 +35,7 @@ Item {
anchors.left: distanceText.right
anchors.leftMargin: 8
}
-
+
MouseArea{
anchors.fill: parent
hoverEnabled: true
@@ -44,7 +44,7 @@ Item {
}
}
}
-
+
Component.onCompleted: backend.get_pois()
}
diff --git a/navit/gui/win32/CMakeLists.txt b/navit/gui/win32/CMakeLists.txt
index 16b653c9f..2c5dd0923 100644
--- a/navit/gui/win32/CMakeLists.txt
+++ b/navit/gui/win32/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(gui_win32 gui_win32.c win32_gui_destination.c win32_gui_notify.c ceglue.c)
+module_add_library(gui_win32 gui_win32.c win32_gui_destination.c win32_gui_notify.c ceglue.c)
diff --git a/navit/gui/win32/ceglue.c b/navit/gui/win32/ceglue.c
index a0817f935..ff3310fb2 100644
--- a/navit/gui/win32/ceglue.c
+++ b/navit/gui/win32/ceglue.c
@@ -1,77 +1,72 @@
-#include <windows.h>
-#include "ceglue.h"
-
-BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;
-
-void InitCeGlue (void)
-{
- HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
- if (ayg != NULL) {
- SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
- GetProcAddressW (ayg, TEXT ("SHFullScreen"));
- }
-}
-
-// code to turn of screen adopted from
-// http://msdn.microsoft.com/en-us/library/ms838354.aspx
-
-// GDI Escapes for ExtEscape()
-#define QUERYESCSUPPORT 8
-
-// The following are unique to CE
-#define GETVFRAMEPHYSICAL 6144
-#define GETVFRAMELEN 6145
-#define DBGDRIVERSTAT 6146
-#define SETPOWERMANAGEMENT 6147
-#define GETPOWERMANAGEMENT 6148
-
-
-typedef enum _VIDEO_POWER_STATE {
- VideoPowerOn = 1,
- VideoPowerStandBy,
- VideoPowerSuspend,
- VideoPowerOff
-} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
-
-
-typedef struct _VIDEO_POWER_MANAGEMENT {
- ULONG Length;
- ULONG DPMSVersion;
- ULONG PowerState;
-} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
-
-
-int CeEnableBacklight(int enable)
-{
- HDC gdc;
- int iESC=SETPOWERMANAGEMENT;
-
- gdc = GetDC(NULL);
- if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
- 0, NULL)==0)
- {
- MessageBox(NULL,
- L"Sorry, your Pocket PC does not support DisplayOff",
- L"Pocket PC Display Off Feature",
- MB_OK);
- ReleaseDC(NULL, gdc);
- return FALSE;
- }
- else
- {
- VIDEO_POWER_MANAGEMENT vpm;
- vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
- vpm.DPMSVersion = 0x0001;
- if (enable) {
- vpm.PowerState = VideoPowerOn;
- } else {
- vpm.PowerState = VideoPowerOff;
- }
- // Power off the display
- ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
- 0, NULL);
- ReleaseDC(NULL, gdc);
- return TRUE;
- }
-}
-
+#include <windows.h>
+#include "ceglue.h"
+
+BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;
+
+void InitCeGlue (void) {
+ HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
+ if (ayg != NULL) {
+ SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
+ GetProcAddressW (ayg, TEXT ("SHFullScreen"));
+ }
+}
+
+// code to turn of screen adopted from
+// http://msdn.microsoft.com/en-us/library/ms838354.aspx
+
+// GDI Escapes for ExtEscape()
+#define QUERYESCSUPPORT 8
+
+// The following are unique to CE
+#define GETVFRAMEPHYSICAL 6144
+#define GETVFRAMELEN 6145
+#define DBGDRIVERSTAT 6146
+#define SETPOWERMANAGEMENT 6147
+#define GETPOWERMANAGEMENT 6148
+
+
+typedef enum _VIDEO_POWER_STATE {
+ VideoPowerOn = 1,
+ VideoPowerStandBy,
+ VideoPowerSuspend,
+ VideoPowerOff
+} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
+
+
+typedef struct _VIDEO_POWER_MANAGEMENT {
+ ULONG Length;
+ ULONG DPMSVersion;
+ ULONG PowerState;
+} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
+
+
+int CeEnableBacklight(int enable) {
+ HDC gdc;
+ int iESC=SETPOWERMANAGEMENT;
+
+ gdc = GetDC(NULL);
+ if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
+ 0, NULL)==0) {
+ MessageBox(NULL,
+ L"Sorry, your Pocket PC does not support DisplayOff",
+ L"Pocket PC Display Off Feature",
+ MB_OK);
+ ReleaseDC(NULL, gdc);
+ return FALSE;
+ } else {
+ VIDEO_POWER_MANAGEMENT vpm;
+ vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
+ vpm.DPMSVersion = 0x0001;
+ if (enable) {
+ vpm.PowerState = VideoPowerOn;
+ } else {
+ vpm.PowerState = VideoPowerOff;
+ }
+ // Power off the display
+ ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
+ 0, NULL);
+ ReleaseDC(NULL, gdc);
+ return TRUE;
+ }
+}
+
diff --git a/navit/gui/win32/ceglue.h b/navit/gui/win32/ceglue.h
index b0dc79d42..bb185dbed 100644
--- a/navit/gui/win32/ceglue.h
+++ b/navit/gui/win32/ceglue.h
@@ -1,16 +1,16 @@
-#ifndef CEGLUE_H
-#define CEGLUE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern BOOL (*SHFullScreenPtr)(HWND hwnd, DWORD state);
-void InitCeGlue (void);
-
-int CeEnableBacklight(int enable);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#ifndef CEGLUE_H
+#define CEGLUE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern BOOL (*SHFullScreenPtr)(HWND hwnd, DWORD state);
+void InitCeGlue (void);
+
+int CeEnableBacklight(int enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/navit/gui/win32/gui_win32.c b/navit/gui/win32/gui_win32.c
index 8a8cb37b9..63edd73df 100644
--- a/navit/gui/win32/gui_win32.c
+++ b/navit/gui/win32/gui_win32.c
@@ -36,459 +36,429 @@ const TCHAR g_szClassName[] = TEXT("navit_gui_class");
static UINT_PTR menu_id = 0;
#if 0
-static gboolean message_pump( gpointer data )
-{
+static gboolean message_pump( gpointer data ) {
MSG messages;
- Sleep( 1 );
+ Sleep( 1 );
- if (GetMessage (&messages, NULL, 0, 0))
- {
+ if (GetMessage (&messages, NULL, 0, 0)) {
TranslateMessage(&messages);
DispatchMessage(&messages);
+ } else {
+ exit( 0 );
}
- else{
- exit( 0 );
- }
- return TRUE;
+ return TRUE;
}
-static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
-{
+static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) {
LPRECT rcParent;
int idChild;
idChild = GetWindowLong(hwndChild, GWL_ID);
- if ( idChild == ID_CHILD_GFX )
- {
- rcParent = (LPRECT) lParam;
+ if ( idChild == ID_CHILD_GFX ) {
+ rcParent = (LPRECT) lParam;
- MoveWindow( hwndChild, 0, 0, rcParent->right, rcParent->bottom, TRUE );
- PostMessage( hwndChild, WM_USER+1, 0, 0 );
- }
+ MoveWindow( hwndChild, 0, 0, rcParent->right, rcParent->bottom, TRUE );
+ PostMessage( hwndChild, WM_USER+1, 0, 0 );
+ }
return TRUE;
}
#endif
#ifndef GET_WHEEL_DELTA_WPARAM
- #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
+#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
#endif
-static void CreateToolBar(HWND hwnd)
-{
- // Create Toolbar
- HWND hTool;
- TBBUTTON tbb[8];
- TBADDBITMAP tbab;
+static void CreateToolBar(HWND hwnd) {
+ // Create Toolbar
+ HWND hTool;
+ TBBUTTON tbb[8];
+ TBADDBITMAP tbab;
#if 0 /* def _WIN32_WCE */
- /* Have to initialize common controls under CE */
- INITCOMMONCONTROLSEX iccex;
- iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
- iccex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx (&iccex);
+ /* Have to initialize common controls under CE */
+ INITCOMMONCONTROLSEX iccex;
+ iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
+ iccex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx (&iccex);
#else
- InitCommonControls();
+ InitCommonControls();
#endif
- hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
- hwnd, (HMENU)ID_CHILD_TOOLBAR, GetModuleHandle(NULL), NULL);
-
- if(hTool == NULL)
- MessageBox(hwnd, TEXT("Could not create tool bar."), TEXT("Error"), MB_OK | MB_ICONERROR);
-
- SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
-
- tbab.hInst = GetModuleHandle(NULL);
- tbab.nID = IDB_NAVITTOOLBAR;
- int iImageOffset = SendMessage(hTool, TB_ADDBITMAP, 10, (LPARAM) &tbab);
-
- int iStr;
-
- ZeroMemory(tbb, sizeof(tbb));
-
- tbb[0].iBitmap = iImageOffset;
- tbb[0].fsState = TBSTATE_ENABLED;
- tbb[0].fsStyle = TBSTYLE_BUTTON;
- tbb[0].idCommand = ID_DISPLAY_ZOOMIN;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomIn" );
- tbb[0].iString = iStr;
-
- tbb[1].iBitmap = iImageOffset+1;
- tbb[1].fsState = TBSTATE_ENABLED;
- tbb[1].fsStyle = TBSTYLE_BUTTON;
- tbb[1].idCommand = ID_DISPLAY_ZOOMOUT;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomOut" );
- tbb[1].iString = iStr;
-
- tbb[2].iBitmap = iImageOffset+4;
- tbb[2].fsState = TBSTATE_ENABLED;
- tbb[2].fsStyle = TBSTYLE_BUTTON;
- tbb[2].idCommand = ID_DISPLAY_REFRESH;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Refresh" );
- tbb[2].iString = iStr;
-
- tbb[3].iBitmap = iImageOffset+2;
- tbb[3].fsState = TBSTATE_ENABLED;
- tbb[3].fsStyle = TBSTYLE_BUTTON;
- tbb[3].idCommand = ID_DISPLAY_ZOOMIN;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Cursor" );
- tbb[3].iString = iStr;
-
- tbb[4].iBitmap = iImageOffset+5;
- tbb[4].fsState = TBSTATE_ENABLED;
- tbb[4].fsStyle = TBSTYLE_BUTTON;
- tbb[4].idCommand = ID_DISPLAY_ORIENT;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Orientation" );
- tbb[4].iString = iStr;
-
- tbb[5].iBitmap = iImageOffset+8;
- tbb[5].fsState = TBSTATE_ENABLED;
- tbb[5].fsStyle = TBSTYLE_BUTTON;
- tbb[5].idCommand = ID_DISPLAY_ZOOMIN;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Destination" );
- tbb[5].iString = iStr;
-
- tbb[6].iBitmap = iImageOffset+3;
- tbb[6].fsState = TBSTATE_ENABLED;
- tbb[6].fsStyle = TBSTYLE_BUTTON;
- tbb[6].idCommand = ID_DISPLAY_ZOOMIN;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Roadbook" );
- tbb[6].iString = iStr;
-
- tbb[7].iBitmap = iImageOffset+9;
- tbb[7].fsState = TBSTATE_ENABLED;
- tbb[7].fsStyle = TBSTYLE_BUTTON;
- tbb[7].idCommand = ID_FILE_EXIT;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"_Quit" );
- tbb[7].iString = iStr;
-
- SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
+ hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
+ hwnd, (HMENU)ID_CHILD_TOOLBAR, GetModuleHandle(NULL), NULL);
+
+ if(hTool == NULL)
+ MessageBox(hwnd, TEXT("Could not create tool bar."), TEXT("Error"), MB_OK | MB_ICONERROR);
+
+ SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+
+ tbab.hInst = GetModuleHandle(NULL);
+ tbab.nID = IDB_NAVITTOOLBAR;
+ int iImageOffset = SendMessage(hTool, TB_ADDBITMAP, 10, (LPARAM) &tbab);
+
+ int iStr;
+
+ ZeroMemory(tbb, sizeof(tbb));
+
+ tbb[0].iBitmap = iImageOffset;
+ tbb[0].fsState = TBSTATE_ENABLED;
+ tbb[0].fsStyle = TBSTYLE_BUTTON;
+ tbb[0].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomIn" );
+ tbb[0].iString = iStr;
+
+ tbb[1].iBitmap = iImageOffset+1;
+ tbb[1].fsState = TBSTATE_ENABLED;
+ tbb[1].fsStyle = TBSTYLE_BUTTON;
+ tbb[1].idCommand = ID_DISPLAY_ZOOMOUT;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomOut" );
+ tbb[1].iString = iStr;
+
+ tbb[2].iBitmap = iImageOffset+4;
+ tbb[2].fsState = TBSTATE_ENABLED;
+ tbb[2].fsStyle = TBSTYLE_BUTTON;
+ tbb[2].idCommand = ID_DISPLAY_REFRESH;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Refresh" );
+ tbb[2].iString = iStr;
+
+ tbb[3].iBitmap = iImageOffset+2;
+ tbb[3].fsState = TBSTATE_ENABLED;
+ tbb[3].fsStyle = TBSTYLE_BUTTON;
+ tbb[3].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Cursor" );
+ tbb[3].iString = iStr;
+
+ tbb[4].iBitmap = iImageOffset+5;
+ tbb[4].fsState = TBSTATE_ENABLED;
+ tbb[4].fsStyle = TBSTYLE_BUTTON;
+ tbb[4].idCommand = ID_DISPLAY_ORIENT;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Orientation" );
+ tbb[4].iString = iStr;
+
+ tbb[5].iBitmap = iImageOffset+8;
+ tbb[5].fsState = TBSTATE_ENABLED;
+ tbb[5].fsStyle = TBSTYLE_BUTTON;
+ tbb[5].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Destination" );
+ tbb[5].iString = iStr;
+
+ tbb[6].iBitmap = iImageOffset+3;
+ tbb[6].fsState = TBSTATE_ENABLED;
+ tbb[6].fsStyle = TBSTYLE_BUTTON;
+ tbb[6].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Roadbook" );
+ tbb[6].iString = iStr;
+
+ tbb[7].iBitmap = iImageOffset+9;
+ tbb[7].fsState = TBSTATE_ENABLED;
+ tbb[7].fsStyle = TBSTYLE_BUTTON;
+ tbb[7].idCommand = ID_FILE_EXIT;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"_Quit" );
+ tbb[7].iString = iStr;
+
+ SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
}
-static void window_layout( HWND hwnd )
-{
+static void window_layout( HWND hwnd ) {
#ifndef HAVE_API_WIN32_CE
- RECT rcClient;
- RECT rcTool;
- int iToolHeight;
+ RECT rcClient;
+ RECT rcTool;
+ int iToolHeight;
- HWND hChild = GetDlgItem(hwnd, ID_CHILD_TOOLBAR);
- SendMessage(hChild, TB_AUTOSIZE, 0, 0);
+ HWND hChild = GetDlgItem(hwnd, ID_CHILD_TOOLBAR);
+ SendMessage(hChild, TB_AUTOSIZE, 0, 0);
- GetWindowRect(hChild, &rcTool);
- iToolHeight = rcTool.bottom - rcTool.top;
+ GetWindowRect(hChild, &rcTool);
+ iToolHeight = rcTool.bottom - rcTool.top;
- GetClientRect(hwnd, &rcClient);
- //printf( "BEFORE resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
+ GetClientRect(hwnd, &rcClient);
+ //printf( "BEFORE resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
- rcClient.top += iToolHeight;
+ rcClient.top += iToolHeight;
- dbg(lvl_debug, "resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
+ dbg(lvl_debug, "resize gui to: %d %d %d %d ", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
- hChild = GetDlgItem(hwnd, ID_CHILD_GFX);
- if ( hChild )
- {
- MoveWindow( hChild, rcClient.left, rcClient.top, rcClient.right- rcClient.left, rcClient.bottom - rcClient.top, TRUE );
- PostMessage( hChild, WM_USER+1, 0, 0 );
- }
+ hChild = GetDlgItem(hwnd, ID_CHILD_GFX);
+ if ( hChild ) {
+ MoveWindow( hChild, rcClient.left, rcClient.top, rcClient.right- rcClient.left, rcClient.bottom - rcClient.top, TRUE );
+ PostMessage( hChild, WM_USER+1, 0, 0 );
+ }
#endif
}
#ifdef __CEGCC__
-static void toggle_fullscreen(HWND mWnd)
-{
- if (SHFullScreenPtr) {
- if (!ce_fullscreen) {
- (*SHFullScreenPtr)(mWnd, SHFS_HIDETASKBAR |
- SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
- } else {
- (*SHFullScreenPtr)(mWnd, SHFS_HIDESIPBUTTON);
- }
- ce_fullscreen = !ce_fullscreen;
- }
+static void toggle_fullscreen(HWND mWnd) {
+ if (SHFullScreenPtr) {
+ if (!ce_fullscreen) {
+ (*SHFullScreenPtr)(mWnd, SHFS_HIDETASKBAR |
+ SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
+ } else {
+ (*SHFullScreenPtr)(mWnd, SHFS_HIDESIPBUTTON);
+ }
+ ce_fullscreen = !ce_fullscreen;
+ }
}
-static void toggle_backlight(void)
-{
- if (ce_backlight)
- if (CeEnableBacklight(FALSE))
- ce_backlight = 0;
- else
- if (CeEnableBacklight(TRUE))
- ce_backlight = 1;
+static void toggle_backlight(void) {
+ if (ce_backlight)
+ if (CeEnableBacklight(FALSE))
+ ce_backlight = 0;
+ else if (CeEnableBacklight(TRUE))
+ ce_backlight = 1;
}
#endif
-static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
RECT rcClient;
// printf( "PARENT %d %d %d \n", Message, wParam, lParam );
- switch(Message)
- {
- case WM_CREATE:
- {
- HMENU hMenu, hSubMenu;
+ switch(Message) {
+ case WM_CREATE: {
+ HMENU hMenu, hSubMenu;
- CreateToolBar( hwnd );
+ CreateToolBar( hwnd );
- hMenu = CreateMenu();
- // g_this_->hwnd = hwnd;
+ hMenu = CreateMenu();
+ // g_this_->hwnd = hwnd;
- hSubMenu = CreatePopupMenu();
+ hSubMenu = CreatePopupMenu();
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMIN, L"ZoomIn" );
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMOUT, L"ZoomOut" );
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_REFRESH, L"Refresh" );
- AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL );
- AppendMenuW(hSubMenu, MF_STRING, ID_FILE_EXIT, L"_Quit" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMIN, L"ZoomIn" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMOUT, L"ZoomOut" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_REFRESH, L"Refresh" );
+ AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL );
+ AppendMenuW(hSubMenu, MF_STRING, ID_FILE_EXIT, L"_Quit" );
- AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"Display" );
- hSubMenu = CreatePopupMenu();
- AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, TEXT("&Go"));
- AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&Stuff"));
+ AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"Display" );
+ hSubMenu = CreatePopupMenu();
+ AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, TEXT("&Go"));
+ AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&Stuff"));
#ifndef HAVE_API_WIN32_CE
- SetMenu(hwnd, hMenu);
+ SetMenu(hwnd, hMenu);
#endif
- window_layout( hwnd );
-
- }
- break;
- case WM_COMMAND:
- {
- printf( "WM_COMMAND %d\n", LOWORD(wParam) );
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
-
- switch(LOWORD(wParam))
- {
- case ID_DISPLAY_ZOOMIN:
- navit_zoom_in(gui->nav, 2, NULL);
- return 0;
- break;
- case ID_DISPLAY_ZOOMOUT:
- navit_zoom_out(gui->nav, 2, NULL);
- return 0;
- break;
- case ID_DISPLAY_REFRESH:
- navit_draw(gui->nav);
- return 0;
- break;
- case ID_DISPLAY_CURSOR:
- {
- struct attr attr;
- attr.type=attr_cursor;
- // TODO attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_cursor\n");
- }
- return 0;
- }
- break;
- case ID_DISPLAY_ORIENT:
- {
- struct attr attr;
-
- attr.type=attr_orientation;
- // attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- attr.u.num = 0; // TODO
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_orientation\n");
- }
- return 0;
- }
-
- case ID_FILE_EXIT:
- PostMessage(hwnd, WM_CLOSE, 0, 0);
- return 0;
- break;
- }
-#if HAVE_GLIB
- if ( popup_menu_array )
- {
- struct menu_priv* priv = (struct menu_priv*)g_array_index( popup_menu_array, gint, LOWORD(wParam) - POPUP_MENU_OFFSET );
-
- if ( priv )
- {
- struct callback* cb = priv->cb;
- if ( priv->cb )
- {
- callback_call_0( priv->cb );
- return 0;
- }
- }
- }
-#endif
- }
- break;
- case WM_USER+ 1:
- GetClientRect(hwnd, &rcClient);
- printf( "resize gui to: %d %d \n", rcClient.right, rcClient.bottom );
-
- window_layout( hwnd );
- //EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient);
+ window_layout( hwnd );
+
+ }
+ break;
+ case WM_COMMAND: {
+ printf( "WM_COMMAND %d\n", LOWORD(wParam) );
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+
+
+ switch(LOWORD(wParam)) {
+ case ID_DISPLAY_ZOOMIN:
+ navit_zoom_in(gui->nav, 2, NULL);
+ return 0;
+ break;
+ case ID_DISPLAY_ZOOMOUT:
+ navit_zoom_out(gui->nav, 2, NULL);
+ return 0;
+ break;
+ case ID_DISPLAY_REFRESH:
+ navit_draw(gui->nav);
+ return 0;
+ break;
+ case ID_DISPLAY_CURSOR: {
+ struct attr attr;
+ attr.type=attr_cursor;
+ // TODO attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_cursor");
+ }
return 0;
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_SIZE:
- window_layout( hwnd );
+ }
+ break;
+ case ID_DISPLAY_ORIENT: {
+ struct attr attr;
+
+ attr.type=attr_orientation;
+ // attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ attr.u.num = 0; // TODO
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_orientation");
+ }
return 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
-
- case WM_MOUSEWHEEL:
- {
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
- short delta = GET_WHEEL_DELTA_WPARAM( wParam );
- if ( delta > 0 )
- {
- navit_zoom_in(gui->nav, 2, NULL);
- }
- else{
- navit_zoom_out(gui->nav, 2, NULL);
- }
- }
- break;
+ }
+
+ case ID_FILE_EXIT:
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ return 0;
+ break;
+ }
+#if HAVE_GLIB
+ if ( popup_menu_array ) {
+ struct menu_priv* priv = (struct menu_priv*)g_array_index( popup_menu_array, gint, LOWORD(wParam) - POPUP_MENU_OFFSET );
+
+ if ( priv ) {
+ struct callback* cb = priv->cb;
+ if ( priv->cb ) {
+ callback_call_0( priv->cb );
+ return 0;
+ }
+ }
+ }
+#endif
+ }
+ break;
+ case WM_USER+ 1:
+ GetClientRect(hwnd, &rcClient);
+ printf( "resize gui to: %d %d \n", rcClient.right, rcClient.bottom );
+
+ window_layout( hwnd );
+ //EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient);
+ return 0;
+ break;
+ case WM_CLOSE:
+ DestroyWindow(hwnd);
+ break;
+ case WM_SIZE:
+ window_layout( hwnd );
+ return 0;
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+
+ case WM_MOUSEWHEEL: {
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+
+ short delta = GET_WHEEL_DELTA_WPARAM( wParam );
+ if ( delta > 0 ) {
+ navit_zoom_in(gui->nav, 2, NULL);
+ } else {
+ navit_zoom_out(gui->nav, 2, NULL);
+ }
+ }
+ break;
#ifdef HAVE_API_WIN32_CE
- case WM_KEYDOWN:
- {
- struct point p;
- int w,h;
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
- transform_get_size(navit_get_trans(gui->nav), &w, &h);
-
- if (wParam == VK_LEFT || wParam == '4') {
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_RIGHT || wParam == '6') {
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_UP || wParam == '2') {
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_DOWN || wParam == '8') {
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == '1') {
- navit_zoom_in(gui->nav, 2, NULL);
- } else if (wParam == '3') {
- navit_zoom_out(gui->nav, 2, NULL);
- } else if (wParam == '7') {
+ case WM_KEYDOWN: {
+ struct point p;
+ int w,h;
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+ transform_get_size(navit_get_trans(gui->nav), &w, &h);
+
+ if (wParam == VK_LEFT || wParam == '4') {
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_RIGHT || wParam == '6') {
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_UP || wParam == '2') {
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_DOWN || wParam == '8') {
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == '1') {
+ navit_zoom_in(gui->nav, 2, NULL);
+ } else if (wParam == '3') {
+ navit_zoom_out(gui->nav, 2, NULL);
+ } else if (wParam == '7') {
#if 0
- toggle_backlight();
+ toggle_backlight();
#endif
- } else if (wParam == '9') {
+ } else if (wParam == '9') {
#if 0
- toggle_fullscreen(hwnd);
+ toggle_fullscreen(hwnd);
#endif
- }
- }
- break;
+ }
+ }
+ break;
#endif
- default:
- return DefWindowProc(hwnd, Message, wParam, lParam);
- }
- return 0;
+ default:
+ return DefWindowProc(hwnd, Message, wParam, lParam);
+ }
+ return 0;
}
-static HANDLE CreateWin32Window( void )
-{
+static HANDLE CreateWin32Window( void ) {
#ifdef HAVE_API_WIN32_CE
- WNDCLASS wc;
+ WNDCLASS wc;
#else
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
+ WNDCLASSEX wc;
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
#endif
- HWND hwnd;
+ HWND hwnd;
// MSG Msg;
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 32;
- wc.hInstance = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = g_szClassName;
- wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
+ wc.style = 0;
+ wc.lpfnWndProc = WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 32;
+ wc.hInstance = NULL;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = g_szClassName;
+ wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
#ifdef HAVE_API_WIN32_CE
- if(!RegisterClass(&wc))
+ if(!RegisterClass(&wc))
#else
- if(!RegisterClassEx(&wc))
+ if(!RegisterClassEx(&wc))
#endif
- {
- MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
+ {
+ MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
+ return 0;
+ }
- hwnd = CreateWindowEx(
- WS_EX_CLIENTEDGE,
- g_szClassName,
- TEXT( "Navit" ),
+ hwnd = CreateWindowEx(
+ WS_EX_CLIENTEDGE,
+ g_szClassName,
+ TEXT( "Navit" ),
#ifdef HAVE_API_WIN32_CE
- WS_SYSMENU | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ WS_SYSMENU | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
#else
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
#endif
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
- if(hwnd == NULL)
- {
- MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
+ if(hwnd == NULL) {
+ MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
+ return 0;
+ }
- ShowWindow(hwnd, TRUE);
- UpdateWindow(hwnd);
+ ShowWindow(hwnd, TRUE);
+ UpdateWindow(hwnd);
#if 0
- g_idle_add (message_pump, NULL);
+ g_idle_add (message_pump, NULL);
#endif
- return hwnd;
+ return hwnd;
}
-static int win32_gui_set_graphics(struct gui_priv *this_, struct graphics *gra)
-{
- HANDLE* wndHandle_ptr = graphics_get_data(gra, "wnd_parent_handle_ptr");
- *wndHandle_ptr = this_->hwnd;
- graphics_get_data(gra, "START_CLIENT");
- return 0;
+static int win32_gui_set_graphics(struct gui_priv *this_, struct graphics *gra) {
+ HANDLE* wndHandle_ptr = graphics_get_data(gra, "wnd_parent_handle_ptr");
+ *wndHandle_ptr = this_->hwnd;
+ graphics_get_data(gra, "START_CLIENT");
+ return 0;
}
-static void win32_gui_add_bookmark_do(struct gui_priv *gui)
-{
+static void win32_gui_add_bookmark_do(struct gui_priv *gui) {
// navit_add_bookmark(gui->nav, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
// gtk_widget_destroy(gui->dialog_win);
}
-static int win32_gui_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description)
-{
- return 1;
+static int win32_gui_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description) {
+ return 1;
}
@@ -496,148 +466,135 @@ static struct menu_methods menu_methods;
static struct menu_priv *add_menu( struct menu_priv *menu,
- struct menu_methods *meth,
- char *name,
- enum menu_type type,
- struct callback *cb)
-{
- struct menu_priv* ret = NULL;
-
- ret = g_new0(struct menu_priv, 1);
-
- *ret = *menu;
- *meth = menu_methods;
-
- TCHAR *menuname = newSysString(name);
-
- if ( type == menu_type_submenu )
- {
- HMENU hSubMenu = NULL;
- hSubMenu = CreatePopupMenu();
- AppendMenu(menu->hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, menuname );
- ret->hMenu = hSubMenu;
- }
- else
- {
- AppendMenu( menu->hMenu, MF_STRING, menu_id, name );
- }
-
- // g_hash_table_insert( popup_callback_hash, GINT_TO_POINTER( menu_id ), (gpointer)cb );
+ struct menu_methods *meth,
+ char *name,
+ enum menu_type type,
+ struct callback *cb) {
+ struct menu_priv* ret = NULL;
+
+ ret = g_new0(struct menu_priv, 1);
+
+ *ret = *menu;
+ *meth = menu_methods;
+
+ TCHAR *menuname = newSysString(name);
+
+ if ( type == menu_type_submenu ) {
+ HMENU hSubMenu = NULL;
+ hSubMenu = CreatePopupMenu();
+ AppendMenu(menu->hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, menuname );
+ ret->hMenu = hSubMenu;
+ } else {
+ AppendMenu( menu->hMenu, MF_STRING, menu_id, name );
+ }
+
+ // g_hash_table_insert( popup_callback_hash, GINT_TO_POINTER( menu_id ), (gpointer)cb );
#if HAVE_GLIB
- g_array_append_val( popup_menu_array, ret );
+ g_array_append_val( popup_menu_array, ret );
#endif
- ret->cb = cb;
+ ret->cb = cb;
- menu_id++;
+ menu_id++;
- return ret;
+ return ret;
}
-static void set_toggle(struct menu_priv *menu, int active)
-{
- // gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
+static void set_toggle(struct menu_priv *menu, int active) {
+ // gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
}
-static int get_toggle(struct menu_priv *menu)
-{
- // return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
- return 0;
+static int get_toggle(struct menu_priv *menu) {
+ // return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
+ return 0;
}
static struct menu_methods menu_methods = {
- add_menu,
- set_toggle,
- get_toggle,
+ add_menu,
+ set_toggle,
+ get_toggle,
};
-static void popup_activate(struct menu_priv *menu)
-{
- POINT pnt;
- GetCursorPos( &pnt );
+static void popup_activate(struct menu_priv *menu) {
+ POINT pnt;
+ GetCursorPos( &pnt );
- if (menu->hMenu)
- {
- TrackPopupMenu( menu->hMenu, 0, pnt.x, pnt.y, 0, menu->wnd_handle, NULL );
- DestroyMenu( menu->hMenu );
- }
+ if (menu->hMenu) {
+ TrackPopupMenu( menu->hMenu, 0, pnt.x, pnt.y, 0, menu->wnd_handle, NULL );
+ DestroyMenu( menu->hMenu );
+ }
}
-static void popup_deactivate( struct menu_priv *menu )
-{
- DestroyMenu( menu->hMenu );
+static void popup_deactivate( struct menu_priv *menu ) {
+ DestroyMenu( menu->hMenu );
}
-static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth)
-{
- struct menu_priv* ret = NULL;
+static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth) {
+ struct menu_priv* ret = NULL;
- ret = g_new0(struct menu_priv, 1);
- *meth = menu_methods;
+ ret = g_new0(struct menu_priv, 1);
+ *meth = menu_methods;
- menu_id = POPUP_MENU_OFFSET;
+ menu_id = POPUP_MENU_OFFSET;
#if HAVE_GLIB
- if ( popup_menu_array )
- {
- g_array_free (popup_menu_array, TRUE);
- popup_menu_array = NULL;
- }
+ if ( popup_menu_array ) {
+ g_array_free (popup_menu_array, TRUE);
+ popup_menu_array = NULL;
+ }
- popup_menu_array = g_array_new (FALSE, FALSE, sizeof (gint));
+ popup_menu_array = g_array_new (FALSE, FALSE, sizeof (gint));
#endif
- ret->cb = NULL;
- ret->hMenu = CreatePopupMenu();
- ret->wnd_handle = this_->hwnd;
- meth->popup=popup_activate;
+ ret->cb = NULL;
+ ret->hMenu = CreatePopupMenu();
+ ret->wnd_handle = this_->hwnd;
+ meth->popup=popup_activate;
-printf( "create popup menu %d \n", ret->hMenu );
+ printf( "create popup menu %d \n", ret->hMenu );
- return ret;
+ return ret;
}
struct gui_methods win32_gui_methods = {
- NULL, // win32_gui_menubar_new,
- win32_gui_popup_new,
- win32_gui_set_graphics,
- NULL,
- NULL, // win32_gui_datawindow_new,
- win32_gui_add_bookmark,
+ NULL, // win32_gui_menubar_new,
+ win32_gui_popup_new,
+ win32_gui_set_graphics,
+ NULL,
+ NULL, // win32_gui_datawindow_new,
+ win32_gui_add_bookmark,
};
-static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *meth, struct attr **attrs)
-{
- struct gui_priv *this_;
+static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *meth, struct attr **attrs) {
+ struct gui_priv *this_;
#ifdef HAVE_API_WIN32_CE
- /* Do not run multiple instances under CE */
- HWND prev;
- prev = FindWindow(g_szClassName, NULL);
- if (prev) {
- ShowWindow(prev, SW_RESTORE);
- SetForegroundWindow(prev);
- InvalidateRect (prev, NULL, FALSE);
- exit(0);
- }
- InitCeGlue();
+ /* Do not run multiple instances under CE */
+ HWND prev;
+ prev = FindWindow(g_szClassName, NULL);
+ if (prev) {
+ ShowWindow(prev, SW_RESTORE);
+ SetForegroundWindow(prev);
+ InvalidateRect (prev, NULL, FALSE);
+ exit(0);
+ }
+ InitCeGlue();
#endif
- *meth=win32_gui_methods;
+ *meth=win32_gui_methods;
- this_=g_new0(struct gui_priv, 1);
- this_->nav=nav;
+ this_=g_new0(struct gui_priv, 1);
+ this_->nav=nav;
- this_->hwnd = CreateWin32Window();
- SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR)this_ );
+ this_->hwnd = CreateWin32Window();
+ SetWindowLongPtr( this_->hwnd, DWLP_USER, (LONG_PTR)this_ );
- return this_;
+ return this_;
}
-void plugin_init(void)
-{
- plugin_register_category_gui("win32", win32_gui_new);
+void plugin_init(void) {
+ plugin_register_category_gui("win32", win32_gui_new);
}
diff --git a/navit/gui/win32/win32_gui_destination.c b/navit/gui/win32/win32_gui_destination.c
index 115b9058b..82ff2c713 100644
--- a/navit/gui/win32/win32_gui_destination.c
+++ b/navit/gui/win32/win32_gui_destination.c
@@ -13,8 +13,7 @@
static const TCHAR g_szDestinationClassName[] = TEXT("navit_gui_destinationwindow_class");
-struct datawindow_priv
-{
+struct datawindow_priv {
HWND hwnd;
HWND hwndLabel;
HWND hwndEdit;
@@ -27,8 +26,7 @@ struct datawindow_priv
struct notify_priv *notifications;
};
-static void setlayout(struct datawindow_priv *datawindow)
-{
+static void setlayout(struct datawindow_priv *datawindow) {
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
@@ -39,22 +37,18 @@ static void setlayout(struct datawindow_priv *datawindow)
lvc.cx = (winrect.right - winrect.left) - 52 ;
lvc.fmt = LVCFMT_LEFT; // left-aligned column
- switch (datawindow->currentSearchState)
- {
- case attr_country_name:
- {
+ switch (datawindow->currentSearchState) {
+ case attr_country_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Country"));
lvc.pszText = TEXT("Country");
}
break;
- case attr_town_name:
- {
+ case attr_town_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Postal or Town"));
lvc.pszText = TEXT("Town");
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Street"));
lvc.pszText = TEXT("Street");
}
@@ -70,16 +64,14 @@ static void setlayout(struct datawindow_priv *datawindow)
SetFocus(datawindow->hwndEdit);
}
-static void notify_apply(struct datawindow_priv *datawindow, int index, int param2)
-{
+static void notify_apply(struct datawindow_priv *datawindow, int index, int param2) {
TCHAR txtBuffer[1024];
char search_string[1024];
struct attr search_attr;
struct search_list_result *res;
-
- if ( index >= 0 )
- {
+
+ if ( index >= 0 ) {
ListView_GetItemText(datawindow->hwndList, index, 1, txtBuffer, 1024);
TCHAR_TO_UTF8(txtBuffer, search_string);
@@ -91,20 +83,16 @@ static void notify_apply(struct datawindow_priv *datawindow, int index, int para
res=search_list_get_result(datawindow->sl);
}
- switch (datawindow->currentSearchState)
- {
- case attr_country_name:
- {
+ switch (datawindow->currentSearchState) {
+ case attr_country_name: {
datawindow->currentSearchState = attr_town_name;
}
break;
- case attr_town_name:
- {
+ case attr_town_name: {
datawindow->currentSearchState = attr_street_name;
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
navit_set_destination(datawindow->nav, res->c, "Mein Test", 1);
DestroyWindow(datawindow->hwnd);
}
@@ -118,19 +106,15 @@ static void notify_apply(struct datawindow_priv *datawindow, int index, int para
}
-static void notify_back(struct datawindow_priv *datawindow, int param1, int param2)
-{
- switch (datawindow->currentSearchState)
- {
+static void notify_back(struct datawindow_priv *datawindow, int param1, int param2) {
+ switch (datawindow->currentSearchState) {
case attr_country_name:
- break;
- case attr_town_name:
- {
+ break;
+ case attr_town_name: {
datawindow->currentSearchState = attr_country_name;
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
datawindow->currentSearchState = attr_town_name;
}
break;
@@ -142,14 +126,13 @@ static void notify_back(struct datawindow_priv *datawindow, int param1, int para
setlayout(datawindow);
}
-static void notify_textchange(struct datawindow_priv *datawindow, int param1, int param2)
-{
+static void notify_textchange(struct datawindow_priv *datawindow, int param1, int param2) {
struct attr search_attr;
struct search_list_result *res;
char search_string[1024];
TCHAR converted_iso2[32];
-
+
int lineLength = Edit_LineLength(datawindow->hwndEdit, 0);
TCHAR line[lineLength + 1];
@@ -178,11 +161,9 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
lvI.state = 0;
lvI.stateMask = 0;
- while ((res=search_list_get_result(datawindow->sl)) && listIndex < 50)
- {
+ while ((res=search_list_get_result(datawindow->sl)) && listIndex < 50) {
- switch (search_attr.type)
- {
+ switch (search_attr.type) {
case attr_country_name:
tcharBuffer = newSysString(res->country->name);
break;
@@ -190,12 +171,9 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
tcharBuffer = newSysString(res->town->common.town_name);
break;
case attr_street_name:
- if (res->street->name)
- {
+ if (res->street->name) {
tcharBuffer = newSysString(res->street->name);
- }
- else
- {
+ } else {
continue;
}
break;
@@ -212,24 +190,20 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
(void)ListView_InsertItem(datawindow->hwndList, &lvI);
ListView_SetItemText(datawindow->hwndList, listIndex, 1, tcharBuffer);
g_free(tcharBuffer);
- dbg(lvl_debug,"%s\n", res->country->name);
+ dbg(lvl_debug,"%s", res->country->name);
listIndex++;
}
}
-static void notify_destroy(struct datawindow_priv *datawindow, int param1, int param2)
-{
- if ( datawindow )
- {
+static void notify_destroy(struct datawindow_priv *datawindow, int param1, int param2) {
+ if ( datawindow ) {
search_list_destroy(datawindow->sl);
g_free(datawindow);
}
}
-static void notify_size(struct datawindow_priv *datawindow, int width, int height)
-{
- if (datawindow)
- {
+static void notify_size(struct datawindow_priv *datawindow, int width, int height) {
+ if (datawindow) {
MoveWindow(datawindow->hwndLabel,
0, 0, // starting x- and y-coordinates
width, // width of client area
@@ -261,8 +235,7 @@ static void notify_size(struct datawindow_priv *datawindow, int width, int heigh
}
}
-static BOOL init_lv_columns(HWND hWndListView)
-{
+static BOOL init_lv_columns(HWND hWndListView) {
// struct LVCOLUMN lvc = {LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
// LVCFMT_LEFT, 100, szText[iCol], 0, iCol, 0, 0 };
@@ -273,8 +246,7 @@ static BOOL init_lv_columns(HWND hWndListView)
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- for (iCol = 0; iCol < 2; iCol++)
- {
+ for (iCol = 0; iCol < 2; iCol++) {
lvc.iSubItem = iCol;
lvc.pszText = szText[iCol];
lvc.cx = 50; // width of column in pixels
@@ -290,8 +262,7 @@ static BOOL init_lv_columns(HWND hWndListView)
return TRUE;
}
-BOOL register_destination_window()
-{
+BOOL register_destination_window() {
WNDCLASS wc;
wc.style = 0;
@@ -305,16 +276,14 @@ BOOL register_destination_window()
wc.lpszClassName = g_szDestinationClassName;
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
- if (!RegisterClass(&wc))
- {
- dbg(lvl_error, "Window Registration Failed!\n");
+ if (!RegisterClass(&wc)) {
+ dbg(lvl_error, "Window Registration Failed!");
return FALSE;
}
return TRUE;
}
-HANDLE create_destination_window( struct navit *nav )
-{
+HANDLE create_destination_window( struct navit *nav ) {
struct datawindow_priv *this_;
@@ -337,18 +306,17 @@ HANDLE create_destination_window( struct navit *nav )
#endif
NULL, NULL, NULL, NULL);
- if (this_->hwnd == NULL)
- {
- dbg(lvl_error, "Window Creation Failed!\n");
+ if (this_->hwnd == NULL) {
+ dbg(lvl_error, "Window Creation Failed!");
return 0;
}
this_->notifications = win32_gui_notify_new(this_);
- SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR) this_->notifications );
+ SetWindowLongPtr( this_->hwnd, DWLP_USER, (LONG_PTR) this_->notifications );
this_->hwndLabel = CreateWindow(WC_STATIC, // predefined class
TEXT("Country"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -357,7 +325,7 @@ HANDLE create_destination_window( struct navit *nav )
this_->hwndEdit = CreateWindow(WC_EDIT, // predefined class
NULL, // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -366,7 +334,7 @@ HANDLE create_destination_window( struct navit *nav )
this_->hwndList = CreateWindow(WC_LISTVIEW, // predefined class
NULL, // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -374,21 +342,21 @@ HANDLE create_destination_window( struct navit *nav )
NULL); // pointer not needed
this_->hwndButtonPrev = CreateWindow(WC_BUTTON, // predefined class
- TEXT("<<"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
- 0, 0, 0, 0, // set size in WM_SIZE message
- this_->hwnd, // parent window
- NULL,//(HMENU) ID_EDITCHILD, // edit control ID
- (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
- NULL); // pointer not needed
+ TEXT("<<"), // no window title
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ this_->hwnd, // parent window
+ NULL,//(HMENU) ID_EDITCHILD, // edit control ID
+ (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
+ NULL); // pointer not needed
this_->hwndButtonNext = CreateWindow(WC_BUTTON, // predefined class
- TEXT(">>"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
- 0, 0, 0, 0, // set size in WM_SIZE message
- this_->hwnd, // parent window
- NULL,//(HMENU) ID_EDITCHILD, // edit control ID
- (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
- NULL); // pointer not needed
+ TEXT(">>"), // no window title
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ this_->hwnd, // parent window
+ NULL,//(HMENU) ID_EDITCHILD, // edit control ID
+ (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
+ NULL); // pointer not needed
#ifdef LVS_EX_FULLROWSELECT
(void)ListView_SetExtendedListViewStyle(this_->hwndList,LVS_EX_FULLROWSELECT);
#endif
diff --git a/navit/gui/win32/win32_gui_notify.c b/navit/gui/win32/win32_gui_notify.c
index c801e9da8..222a7a5a9 100644
--- a/navit/gui/win32/win32_gui_notify.c
+++ b/navit/gui/win32/win32_gui_notify.c
@@ -4,23 +4,21 @@
#include <glib.h>
#include "win32_gui_notify.h"
-struct window_data
-{
+struct window_data {
HWND hwnd;
UINT message;
void(*func)(struct datawindow_priv *parent, int param1, int param2);
};
-struct notify_priv
-{
+struct notify_priv {
GList *window_list;
struct datawindow_priv *parent;
};
-void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, void(*func)(struct datawindow_priv *parent, int param1, int param2))
-{
+void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, void(*func)(struct datawindow_priv *parent,
+ int param1, int param2)) {
struct window_data *wnd_data = g_new( struct window_data,1);
wnd_data->hwnd = hwnd;
@@ -31,97 +29,81 @@ void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, voi
}
-struct notify_priv* win32_gui_notify_new(struct datawindow_priv *parent)
-{
+struct notify_priv* win32_gui_notify_new(struct datawindow_priv *parent) {
struct notify_priv* notify = g_new0(struct notify_priv,1);
notify->parent = parent;
return notify;
}
-LRESULT CALLBACK message_handler(HWND hwnd, UINT win_message, WPARAM wParam, LPARAM lParam)
-{
+LRESULT CALLBACK message_handler(HWND hwnd, UINT win_message, WPARAM wParam, LPARAM lParam) {
enum message_id message = INVALID;
int param1 = -1;
int param2 = -1;
HWND hwndDlg = hwnd;
- switch (win_message)
- {
- case WM_CREATE:
- {
- message = WINDOW_CREATE;
+ switch (win_message) {
+ case WM_CREATE: {
+ message = WINDOW_CREATE;
+ }
+ break;
+ case WM_SIZE: {
+ message = WINDOW_SIZE;
+ param1 = LOWORD(lParam);
+ param2 = HIWORD(lParam);
+ }
+ break;
+ case WM_DESTROY: {
+ message = WINDOW_DESTROY;
+ }
+ break;
+ case WM_NOTIFY: {
+ hwndDlg = (((LPNMHDR)lParam)->hwndFrom);
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_DBLCLK: {
+ message = DBLCLICK;
+#ifdef LPNMITEMACTIVATE
+ param1 = ((LPNMITEMACTIVATE)lParam)->iItem;
+#endif
}
break;
- case WM_SIZE:
- {
- message = WINDOW_SIZE;
- param1 = LOWORD(lParam);
- param2 = HIWORD(lParam);
+ case NM_CLICK:
+ message = CLICK;
+ break;
}
- break;
- case WM_DESTROY:
- {
- message = WINDOW_DESTROY;
+ }
+ break;
+ case WM_COMMAND: {
+ hwndDlg = (HWND)lParam;
+
+ switch (HIWORD(wParam)) {
+ case EN_CHANGE: {
+ message = CHANGE;
}
break;
- case WM_NOTIFY:
- {
- hwndDlg = (((LPNMHDR)lParam)->hwndFrom);
- switch (((LPNMHDR)lParam)->code)
- {
- case NM_DBLCLK:
- {
- message = DBLCLICK;
-#ifdef LPNMITEMACTIVATE
- param1 = ((LPNMITEMACTIVATE)lParam)->iItem;
-#endif
- }
- break;
- case NM_CLICK:
- message = CLICK;
- break;
- }
+ case BN_CLICKED: {
+ message = BUTTON_CLICK;
}
break;
- case WM_COMMAND:
- {
- hwndDlg = (HWND)lParam;
-
- switch (HIWORD(wParam))
- {
- case EN_CHANGE:
- {
- message = CHANGE;
- }
- break;
- case BN_CLICKED:
- {
- message = BUTTON_CLICK;
- }
- break;
- }
}
- break;
+ }
+ break;
- default:
- return DefWindowProc(hwnd, win_message, wParam, lParam);
+ default:
+ return DefWindowProc(hwnd, win_message, wParam, lParam);
}
- struct notify_priv* notify_data = (struct notify_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
+ struct notify_priv* notify_data = (struct notify_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
- if ( message != INVALID && notify_data && notify_data->window_list )
- {
+ if ( message != INVALID && notify_data && notify_data->window_list ) {
GList* current_element = g_list_first(notify_data->window_list);
struct window_data* wnd_data = NULL;
- while (current_element != NULL)
- {
+ while (current_element != NULL) {
wnd_data = current_element->data;
- if ( (wnd_data->hwnd == hwndDlg || wnd_data->hwnd == NULL) && message == wnd_data->message)
- {
+ if ( (wnd_data->hwnd == hwndDlg || wnd_data->hwnd == NULL) && message == wnd_data->message) {
wnd_data->func(notify_data->parent, param1, param2);
}