ATTR(icon)
ATTR(info_html)
ATTR(price_html)
+/* navigation */
+ATTR(navigation_short)
+ATTR(navigation_long)
+ATTR(navigation_long_exact)
+ATTR(navigation_speech)
ATTR2(type_string_end,0x0003ffff)
// First, update the 'Navigation Tip' on the main window
try {
- WindowManager::getSingleton().getWindow("Navit/Routing/Tips")->setText(navigation_list_get(list, navigation_mode_speech));
+ struct attr attr;
+ item_attr_get(navigation_list_get_item(list), attr_navigation_speech, &attr);
+ WindowManager::getSingleton().getWindow("Navit/Routing/Tips")->setText(attr.u.str);
}
catch (CEGUI::Exception& e)
{
MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Roadbook"));
mcl->resetList();
- char *str;
+ item *item;
+ struct attr attr;
list=navigation_list_new(nav);
- while ((str=navigation_list_get(list, navigation_mode_short))) {
+ while ((item=navigation_list_get_item(list))) {
// printf("SDL : %s\n", str);
mcl->addRow();
-
- ListboxTextItem* itemListbox = new ListboxTextItem(str);
+ item_attr_get(item, attr_navigation_short, &attr);
+ ListboxTextItem* itemListbox = new ListboxTextItem(attr.u.str);
itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
mcl->setItem(itemListbox, 0, mcl->getRowCount()-1);
}
navig=navit_get_navigation(sdl_gui_navit);
navigation_register_callback(navig,
- navigation_mode_long,
+ attr_navigation_long,
callback_new_0((void (*)())sdl_update_roadbook)
);
struct navigation_list {
struct navigation *nav;
struct navigation_command *cmd;
+ struct navigation_command *cmd_next;
struct navigation_itm *itm;
+ struct navigation_itm *itm_next;
+ struct item item;
+#if 0
char *str;
+#endif
};
struct street_data {
}
static char *
-get_distance(int dist, enum navigation_mode mode, int is_length)
+get_distance(int dist, enum attr_type type, int is_length)
{
- if (mode == navigation_mode_long) {
+ if (type == attr_navigation_long) {
if (is_length)
return g_strdup_printf(_("%d m"), dist);
else
}
static char *
-show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum navigation_mode mode)
+show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum attr_type type)
{
char *dir=_("right"),*strength="";
int distance=itm->dest_length-cmd->itm->dest_length;
dbg(1,"delta=%d\n", delta);
strength=_("unknown ");
}
- if (mode != navigation_mode_long_exact)
+ if (type != attr_navigation_long_exact)
distance=round_distance(distance);
- if (mode == navigation_mode_speech) {
+ if (type == attr_navigation_speech) {
if (nav->turn_around)
return g_strdup(_("When possible, please turn around"));
level=navigation_get_announce_level(nav, itm->item.type, distance);
}
switch(level) {
case 3:
- d=get_distance(distance, mode, 1);
+ d=get_distance(distance, type, 1);
ret=g_strdup_printf(_("Follow the road for the next %s"), d);
g_free(d);
return ret;
d=g_strdup(_("soon"));
break;
case 1:
- d=get_distance(distance, mode, 0);
+ d=get_distance(distance, type, 0);
break;
case 0:
d=g_strdup(_("now"));
return ret;
}
+static int
+navigation_list_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
+{
+ struct navigation_list *this_=priv_data;
+ switch(attr_type) {
+ case attr_navigation_short:
+ case attr_navigation_long:
+ case attr_navigation_long_exact:
+ case attr_navigation_speech:
+ attr->u.str=show_maneuver(this_->nav, this_->itm, this_->cmd, attr_type);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+struct item_methods navigation_list_item_methods = {
+ NULL,
+ NULL,
+ NULL,
+ navigation_list_item_attr_get,
+};
+
+
+
struct navigation_list *
navigation_list_new(struct navigation *this_)
{
struct navigation_list *ret=g_new0(struct navigation_list, 1);
ret->nav=this_;
- ret->cmd=this_->cmd_first;
- ret->itm=this_->first;
+ ret->cmd_next=this_->cmd_first;
+ ret->itm_next=this_->first;
+ ret->item.meth=&navigation_list_item_methods;
+ ret->item.priv_data=ret;
return ret;
}
-char *
-navigation_list_get(struct navigation_list *this_, enum navigation_mode mode)
+struct item *
+navigation_list_get_item(struct navigation_list *this_)
{
- if (!this_->cmd)
+ if (!this_->cmd_next)
return NULL;
- g_free(this_->str);
+ this_->cmd=this_->cmd_next;
+ this_->itm=this_->itm_next;
+#if 0
this_->str=show_maneuver(this_->nav, this_->itm, this_->cmd, mode);
- this_->itm=this_->cmd->itm;
- this_->cmd=this_->cmd->next;
+#endif
+ this_->itm_next=this_->cmd->itm;
+ this_->cmd_next=this_->cmd->next;
- return this_->str;
+ return &this_->item;
}
void
navigation_list_destroy(struct navigation_list *this_)
{
- g_free(this_->str);
g_free(this_);
}
}
int
-navigation_register_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb)
+navigation_register_callback(struct navigation *this_, enum attr_type type, struct callback *cb)
{
- if (mode == navigation_mode_speech)
+ if (type == attr_navigation_speech)
callback_list_add(this_->callback_speech, cb);
else
callback_list_add(this_->callback, cb);
}
void
-navigation_unregister_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb)
+navigation_unregister_callback(struct navigation *this_, enum attr_type type, struct callback *cb)
{
- if (mode == navigation_mode_speech)
+ if (type == attr_navigation_speech)
callback_list_remove_destroy(this_->callback_speech, cb);
else
callback_list_remove_destroy(this_->callback, cb);
#ifdef __cplusplus
extern "C" {
#endif
-enum navigation_mode {
- navigation_mode_long,
- navigation_mode_long_exact,
- navigation_mode_short,
- navigation_mode_speech,
-};
-
/* prototypes */
+enum attr_type;
enum item_type;
-enum navigation_mode;
struct callback;
+struct item;
struct mapset;
struct navigation;
struct navigation_list;
void navigation_set_mapset(struct navigation *this_, struct mapset *ms);
int navigation_set_announce(struct navigation *this_, enum item_type type, int *level);
struct navigation_list *navigation_list_new(struct navigation *this_);
-char *navigation_list_get(struct navigation_list *this_, enum navigation_mode mode);
+struct item *navigation_list_get_item(struct navigation_list *this_);
void navigation_list_destroy(struct navigation_list *this_);
void navigation_update(struct navigation *this_, struct route *route);
void navigation_destroy(struct navigation *this_);
-int navigation_register_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb);
-void navigation_unregister_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb);
+int navigation_register_callback(struct navigation *this_, enum attr_type type, struct callback *cb);
+void navigation_unregister_callback(struct navigation *this_, enum attr_type type, struct callback *cb);
/* end of prototypes */
#ifdef __cplusplus
}
{
struct navigation *nav=this_->navigation;
struct navigation_list *list;
- char *text;
+ struct item *item;
+ struct attr attr;
list=navigation_list_new(nav);
- text=navigation_list_get(list, navigation_mode_speech);
- speech_say(this_->speech, text);
+ item=navigation_list_get_item(list);
+ if (item_attr_get(item, attr_navigation_speech, &attr))
+ speech_say(this_->speech, attr.u.str);
navigation_list_destroy(list);
}
{
struct navigation *nav=this_->navigation;
struct navigation_list *list;
- char *str;
+ struct item *item;
+ struct attr attr;
struct param_list param[1];
dbg(1,"enter\n");
datawindow_mode(this_->roadbook_window, 1);
list=navigation_list_new(nav);
- while ((str=navigation_list_get(list, navigation_mode_long_exact))) {
- dbg(2, "Command='%s'\n", str);
+ while ((item=navigation_list_get_item(list))) {
+ attr.u.str=NULL;
+ item_attr_get(item, attr_navigation_long, &attr);
+ dbg(2, "Command='%s'\n", attr.u.str);
param[0].name="Command";
- param[0].value=str;
+ param[0].value=attr.u.str;
datawindow_add(this_->roadbook_window, param, 1);
}
navigation_list_destroy(list);
navit_window_roadbook_destroy(struct navit *this_)
{
dbg(0, "enter\n");
- navigation_unregister_callback(this_->navigation, navigation_mode_long, this_->roadbook_callback);
+ navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
this_->roadbook_window=NULL;
this_->roadbook_callback=NULL;
}
navit_window_roadbook_new(struct navit *this_)
{
this_->roadbook_callback=callback_new_1(callback_cast(navit_window_roadbook_update), this_);
- navigation_register_callback(this_->navigation, navigation_mode_long, this_->roadbook_callback);
+ navigation_register_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
this_->roadbook_window=gui_datawindow_new(this_->gui, "Roadbook", NULL, callback_new_1(callback_cast(navit_window_roadbook_destroy), this_));
navit_window_roadbook_update(this_);
}
}
if (this_->navigation && this_->speech) {
this_->nav_speech_cb=callback_new_1(callback_cast(navit_speak), this_);
- navigation_register_callback(this_->navigation, navigation_mode_speech, this_->nav_speech_cb);
+ navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb);
#if 0
#endif
}