bool AddressSearchSwitch(const CEGUI::EventArgs& event) { using namespace CEGUI; WindowManager::getSingleton().getWindow("DestinationChoose")->hide(); WindowManager::getSingleton().getWindow("AdressSearchWindow")->show(); if(sdl_gui_navit){ } else { dbg(0,"*** Invalid navit instance in sdl_events\n"); } struct search_param *search=&search_param; struct search_list_result *res; // dbg(1,"search->nav=sdl_gui_navit;\n"); search->nav=sdl_gui_navit; // dbg(1,"search->ms=navit_get_mapset(sdl_gui_navit);\n"); search->ms=navit_get_mapset(sdl_gui_navit); // dbg(1,"search->sl=search_list_new(search->ms);\n"); search->sl=search_list_new(search->ms); const CEGUI::WindowEventArgs& we = static_cast<const CEGUI::WindowEventArgs&>(event); Window* town_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox")); town_edit->setText(""); Window* street_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox")); street_edit->setText(""); town_edit->activate(); SDL_dest.current_search=SRCH_COUNTRY; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox")); mcl->resetList(); // Code to get the current country and set it by default for the search struct attr search_attr, country_name, *country_attr; struct tracking *tracking; struct country_search *cs; struct item *item; Editbox* country_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox")); country_attr=country_default(); tracking=navit_get_tracking(sdl_gui_navit); if (tracking && tracking_get_current_attr(tracking, attr_country_id, &search_attr)) country_attr=&search_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)){ country_edit->setText(country_name.u.str); handle_destination_change(); } country_search_destroy(cs); SDL_dest.current_search=SRCH_TOWN; return true; }
///////////////////////////////////////////////// // zhaohang 2010/3/16 // 控件数据显示更新 void GVEvent::SetItemContentInMulList(const UIData::tagGoodAttr *pGoodAttr, CEGUI::uint RowIdx) { if(pGoodAttr!=NULL) { MultiColumnList* mclbox = static_cast<MultiColumnList*>(m_wnd->getChildRecursive("GoodsTreeFrame/MultiColumnList")); //清空行 mclbox->resetList(); //设置每一行的值 mclbox->addRow(); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwIndex)),0,RowIdx); mclbox->setItem(new MyListItem(pGoodAttr->strOrigName.c_str()),1,RowIdx); mclbox->setItem(new MyListItem(pGoodAttr->strName.c_str()),2,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::boolToString(pGoodAttr->bSave)),3,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwIconId)),4,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwGroundId)),5,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwEquipID)),6,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwValue)),7,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSilverValue)),8,RowIdx); mclbox->setItem(new MyListItem(m_GoodsOP.GetGoodsType(pGoodAttr->dwType).c_str()),9,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSound)),10,RowIdx); mclbox->setItem(new MyListItem(pGoodAttr->strContent.c_str()),11,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSoundID1)),12,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::intToString(pGoodAttr->dwSoundID2)),13,RowIdx); mclbox->setItem(new MyListItem(PropertyHelper::boolToString(pGoodAttr->bSoundSwitch)),14,RowIdx); } }
static void sdl_update_roadbook(struct navigation *nav) { using namespace CEGUI; extern Window* myRoot; struct navigation_list *list; list=navigation_list_new(nav); // First, update the 'Navigation Tip' on the main window try { 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) { fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str()); printf("Missing control!...\n"); } // Then, update the whole roadbook try { /* Currently we use the 'Navit' text to display the roadbook, until Mineque design a button for that if(! WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->isVisible()){ WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->show(); } */ MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Roadbook")); mcl->resetList(); item *item; struct attr attr; list=navigation_list_new(nav); while ((item=navigation_list_get_item(list))) { // printf("SDL : %s\n", str); mcl->addRow(); 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); } navigation_list_destroy(list); } catch (CEGUI::Exception& e) { fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str()); printf("Missing control!...\n"); } }
void GVEvent::UpdateSuitAttrDisplay(const UIData::tagGoodAttr *pGoodAttr) { //更新套装属性 if(!pGoodAttr) return; MultiColumnList* mclbox = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("GoodsTreeFrame/GroupBoxSuitAtrr/MultiColumnList")); if(!mclbox) return; //清空行 mclbox->resetList(); for(CEGUI::uint i = 0 ; i < pGoodAttr->vecSuitAttr.size() ; ++i) { //设置每一行的值 mclbox->addRow(); const UIData::tagSuitAttr& suitAttr = pGoodAttr->vecSuitAttr[i]; mclbox->setItem(new MyListItem(m_GoodsOP.GetGoodItemType(suitAttr.wType).c_str()),0,i); mclbox->setItem(new MyListItem(PropertyHelper::intToString(suitAttr.lValue1)),1,i); mclbox->setItem(new MyListItem(PropertyHelper::intToString(suitAttr.lValue2)),2,i); mclbox->setItem(new MyListItem(PropertyHelper::intToString(suitAttr.wSuitNum)),3,i); } }
void GVEvent::UpdateAddAttrDisplay(const UIData::tagGoodAttr* pGoodAttr) { //更新物品附加属性显示 if(!pGoodAttr) return; MultiColumnList* mclbox = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("GoodsTreeFrame/AddProperty/MultiColumnList")); if(!mclbox) return; //清空行 mclbox->resetList(); for(size_t size = 0 ; size < pGoodAttr->vecAddAttr.size(); ++size) { //设置每一行的值 mclbox->addRow(); const UIData::tagAddAttr &addAttr = pGoodAttr->vecAddAttr[size]; mclbox->setItem(new MyListItem(m_GoodsOP.GetGoodItemType(addAttr.wType).c_str()),0,(CEGUI::uint)size); mclbox->setItem(new MyListItem(PropertyHelper::boolToString(addAttr.bEnable)),1,(CEGUI::uint)size); mclbox->setItem(new MyListItem(PropertyHelper::boolToString(addAttr.bHide)),2,(CEGUI::uint)size); mclbox->setItem(new MyListItem(PropertyHelper::intToString(addAttr.lValue1)),3,(CEGUI::uint)size); mclbox->setItem(new MyListItem(PropertyHelper::intToString(addAttr.lValue2)),4,(CEGUI::uint)size); } }
bool DialogWindowSwitch(const CEGUI::EventArgs& event) { using namespace CEGUI; extern CEGUI::Window* myRoot; const CEGUI::WindowEventArgs& we = static_cast<const CEGUI::WindowEventArgs&>(event); if(we.window->getParent()->getChild("DestinationWindow")->isVisible()){ we.window->getParent()->getChild("DestinationWindow")->hide(); } else { Window* town_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/TownEditbox")); town_edit->setText(""); Window* street_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/StreetEditbox")); street_edit->setText(""); town_edit->activate(); SDL_dest.current_search=SRCH_COUNTRY; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("DestinationWindow/Listbox")); mcl->resetList(); we.window->getParent()->getChild("DestinationWindow")->show(); } extern struct navit *sdl_gui_navit; if(sdl_gui_navit){ } else { printf("*** Invalid navit instance in sdl_events\n"); } struct search_param *search=&search_param; // dbg(1,"search->nav=sdl_gui_navit;\n"); search->nav=sdl_gui_navit; // dbg(1,"search->ms=navit_get_mapset(sdl_gui_navit);\n"); search->ms=navit_get_mapset(sdl_gui_navit); // dbg(1,"search->sl=search_list_new(search->ms);\n"); search->sl=search_list_new(search->ms); return true; }
void handle_destination_change(){ using namespace CEGUI; struct search_param *search=&search_param; struct search_list_result *res; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox")); if (SDL_dest.current_search==SRCH_COUNTRY) { Editbox* country_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox")); String content=country_edit->getText(); mcl->resetList(); dbg(0,"Starting a country search : %s\n",content.c_str()); search->attr.type=attr_country_all; // FIXME the following codeblock could be shared between country, town and street search search->attr.u.str=(char *)content.c_str(); search_list_search(search->sl, &search->attr, 1); while((res=search_list_get_result(search->sl))) { ListboxTextItem* itemListbox = new ListboxTextItem((CEGUI::utf8*)(res->country->name)); itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush"); mcl->addRow(itemListbox,0); } } else if (SDL_dest.current_search==SRCH_TOWN) { Editbox* town_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox")); String content=town_edit->getText(); mcl->resetList(); if(strlen(content.c_str())<4){ } else { dbg(0,"town searching for %s\n",content.c_str()); search->attr.type=attr_town_name; search->attr.u.str=(char *)content.c_str(); search_list_search(search->sl, &search->attr, 1); while((res=search_list_get_result(search->sl))) { ListboxTextItem* itemListbox = new ListboxTextItem((CEGUI::utf8*)(res->town->name)); itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush"); mcl->addRow(itemListbox,0); char x [256]; sprintf(x,"%li",res->c->x); ListboxTextItem* xitem = new ListboxTextItem(x); char y [256]; sprintf(y,"%li",res->c->y); ListboxTextItem* yitem = new ListboxTextItem(y); try { mcl->setItem(xitem, 3, mcl->getRowCount()-1); mcl->setItem(yitem, 4, mcl->getRowCount()-1); } // something went wrong, so cleanup the ListboxTextItem. catch (InvalidRequestException) { // delete item; } } } } else if (SDL_dest.current_search==SRCH_STREET) { Editbox* street_edit = static_cast<Editbox*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox")); String content=street_edit->getText(); if(strlen(content.c_str())<1){ } else { // dbg(1,"street searching for %s\n",content.c_str()); search->attr.type=attr_street_name; search->attr.u.str=(char *)content.c_str(); mcl->resetList(); search_list_search(search->sl, &search->attr, 1); while((res=search_list_get_result(search->sl))) { ListboxTextItem* itemListbox = new ListboxTextItem((CEGUI::utf8*)(res->street->name)); itemListbox->setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush"); mcl->addRow(itemListbox,0); char x [256]; sprintf(x,"%li",res->c->x); ListboxTextItem* xitem = new ListboxTextItem(x); char y [256]; sprintf(y,"%li",res->c->y); ListboxTextItem* yitem = new ListboxTextItem(y); try { mcl->setItem(xitem, 3, mcl->getRowCount()-1); mcl->setItem(yitem, 4, mcl->getRowCount()-1); } // something went wrong, so cleanup the ListboxTextItem. catch (InvalidRequestException) { // delete item; } } } } }
bool handleItemSelect(int r) { using namespace CEGUI; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox")); ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0)); ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1)); ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2)); Window* country_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox")); Window* twn_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox")); Window* street_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox")); if(SDL_dest.current_search==SRCH_COUNTRY){ country_edit->setText(item->getText()); twn_edit->activate(); SDL_dest.current_search=SRCH_TOWN; WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_TOWN){ twn_edit->setText(item->getText()); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; street_edit->activate(); WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_STREET){ street_edit->setText(item->getText()); WindowManager::getSingleton().getWindow("Navit/Keyboard")->hide(); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText(""); } else if (SDL_dest.current_search==SRCH_NUMBER){ struct coord pos; ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); pos.x=atoi(itemx->getText().c_str()); pos.y=atoi(itemy->getText().c_str()); route_to(pos.x,pos.y); } return true; }
bool handleItemSelect(int r) { using namespace CEGUI; extern CEGUI::Window* myRoot; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("DestinationWindow/Listbox")); ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0)); ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1)); ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2)); Window* country_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/CountryEditbox")); Window* twn_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/TownEditbox")); Window* street_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/StreetEditbox")); if(SDL_dest.current_search==SRCH_COUNTRY){ country_edit->setText(item->getText()); // Need to record the country here twn_edit->activate(); SDL_dest.current_search=SRCH_TOWN; myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_TOWN){ twn_edit->setText(item->getText()); // SDL_dest.town_street_assoc=atoi(item_assoc->getText().c_str()); // SDL_dest.town=atoi(itemid->getText().c_str()); // printf(" town %s , id=%lx, assoc=%li\n",item->getText().c_str(),SDL_dest.town_street_assoc,SDL_dest.town_street_assoc); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; street_edit->activate(); myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_STREET){ street_edit->setText(item->getText()); myRoot->getChild("Navit/Keyboard")->hide(); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText(""); /* ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1)); int segment_id=atoi(itemid->getText().c_str()); printf("street seg id : %li\n",segment_id); extern struct container *co; struct block_info res_blk_inf; struct street_str *res_str; street_get_by_id(co->map_data, 33, segment_id,&res_blk_inf,&res_str ); struct street_coord * streetcoord; streetcoord=street_coord_get(&res_blk_inf,res_str); printf("Street coordinates : %i,%i\n",streetcoord->c->x,streetcoord->c->y); char xbuff [256]; sprintf(xbuff,"%li",streetcoord->c->x); char ybuff [256]; sprintf(ybuff,"%li",streetcoord->c->y); Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x")); Dest_x->setText(xbuff); Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y")); Dest_y->setText(ybuff); struct street_name name; // printf("street_name_get_by_id returns : %i\n",street_name_get_by_id(&name, res_blk_inf.mdata, res_str->nameid)); street_name_get_by_id(&name, res_blk_inf.mdata, res_str->nameid); // printf("name1:%s / name2%s\n",name.name1,name.name2); struct street_name_number_info num; struct street_name_info inf; SDL_dest.current_search=SRCH_NUMBER; mcl->resetList(); while (street_name_get_info(&inf, &name)) { while(street_name_get_number_info(&num,&inf)){ // printf(" House Number : %i -> %i\n",num.first,num.last); for(int i=num.first;i<=num.last;i+=2){ add_number_to_list(i,num.c->x,num.c->y); } } } */ // route_to(streetcoord->c->x,streetcoord->c->y); } else if (SDL_dest.current_search==SRCH_NUMBER){ struct coord pos; ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); pos.x=atoi(itemx->getText().c_str()); pos.y=atoi(itemy->getText().c_str()); route_to(pos.x,pos.y); } return true; }
static void sdl_update_roadbook(struct navigation *nav) { using namespace CEGUI; struct map *map; struct map_rect *mr; if (! nav) return; map=navigation_get_map(nav); if (! map) return; mr=map_rect_new(map, NULL); if (! mr) return; // First, ensure the navigation tip is visible. quick workaround for when resuming a destination WindowManager::getSingleton().getWindow("Navit/Routing/Tips")->show(); // update the 'Navigation Tip' on the main window try { struct attr attr; item_attr_get(map_rect_get_item(mr), attr_navigation_speech, &attr); map_rect_destroy(mr); mr=map_rect_new(map, NULL); WindowManager::getSingleton().getWindow("Navit/Routing/Tips")->setText((CEGUI::utf8*)(attr.u.str)); } catch (CEGUI::Exception& e) { fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str()); printf("Missing control!...\n"); } // Then, update the whole roadbook try { /* Currently we use the 'Navit' text to display the roadbook, until Mineque design a button for that if(! WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->isVisible()){ WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->show(); } */ MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Roadbook")); mcl->resetList(); item *item; struct attr attr; while ((item=map_rect_get_item(mr))) { mcl->addRow(); 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); } map_rect_destroy(mr); } catch (CEGUI::Exception& e) { dbg(0,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str()); dbg(0,"Missing control!\n"); } }