static void OnCodeClicked(gcc_unused WndButton &button) { TCHAR newTeammateCode[10]; _tcsncpy(newTeammateCode, XCSoarInterface::SettingsComputer().TeammateCode.GetCode(), 10); if (!dlgTextEntryShowModal(newTeammateCode, 7)) return; for (int i = _tcslen(newTeammateCode) - 1; i >= 0; i--) { if (newTeammateCode[i] != _T(' ')) break; newTeammateCode[i] = 0; } XCSoarInterface::SetSettingsComputer().TeammateCode.Update(newTeammateCode); if (!string_is_empty(XCSoarInterface::SettingsComputer().TeammateCode.GetCode())) { XCSoarInterface::SetSettingsComputer().TeammateCodeValid = true; XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = false; } else XCSoarInterface::SetSettingsComputer().TeammateCodeValid = false; }
static void OnSaveClicked(WndButton* pWnd){ int file_index; TCHAR task_name[MAX_PATH]; WndProperty* wp; DataFieldFileReader *dfe; wp = (WndProperty*)wf->FindByName(TEXT("prpFile")); if (!wp) return; dfe = (DataFieldFileReader*)wp->GetDataField(); file_index = dfe->GetAsInteger(); // TODO enhancement: suggest a good new name not already in the list _tcscpy(task_name,TEXT("NEW")); dlgTextEntryShowModal(task_name, 10); // max length if (_tcslen(task_name)>0) { _tcscat(task_name, TEXT(LKS_TSK)); dfe->Lookup(task_name); file_index = dfe->GetAsInteger(); if (file_index==0) { // good, this file is unique.. dfe->addFile(task_name, task_name); dfe->Lookup(task_name); wp->RefreshDisplay(); } } else { // TODO code: report error, task not saved since no name was given return; } if (file_index>0) { // file already exists! ask if want to overwrite TCHAR sTmp[500]; _sntprintf(sTmp, array_size(sTmp), TEXT("%s: '%s'"), // LKTOKEN _@M696_ = "Task file already exists" MsgToken(696), dfe->GetAsString()); if(MessageBoxX( sTmp, // LKTOKEN _@M510_ = "Overwrite?" MsgToken(510), mbYesNo) != IdYes) { return; } } TCHAR file_name[MAX_PATH]; LocalPath(file_name,TEXT(LKD_TASKS), task_name); SaveTask(file_name); UpdateCaption(); }
static void OnFilterNameButton(gcc_unused WndButton &button) { TCHAR new_name_filter[NAME_FILTER_LENGTH + 1]; CopyString(new_name_filter, filter_data.name, NAME_FILTER_LENGTH + 1); dlgTextEntryShowModal(*(SingleWindow *)button.GetRootOwner(), new_name_filter, NAME_FILTER_LENGTH, _("Waypoint name"), WaypointNameAllowedCharacters); int i = _tcslen(new_name_filter) - 1; while (i >= 0) { if (new_name_filter[i] != _T(' ')) break; new_name_filter[i] = 0; i--; } CopyString(filter_data.name, new_name_filter, NAME_FILTER_LENGTH + 1); if (name_button) { if (StringIsEmpty(filter_data.name)) name_button->SetCaption(_T("*")); else name_button->SetCaption(filter_data.name); } UpdateList(); }
static void OnFilterNameButton(gcc_unused WndButton &button) { TCHAR newNameFilter[NAMEFILTERLEN + 1]; _tcsncpy(newNameFilter, filter_data.name, NAMEFILTERLEN); dlgTextEntryShowModal(newNameFilter, NAMEFILTERLEN, WaypointNameAllowedCharacters); int i = _tcslen(newNameFilter) - 1; while (i >= 0) { if (newNameFilter[i] != _T(' ')) break; newNameFilter[i] = 0; i--; }; _tcsncpy(filter_data.name, newNameFilter, NAMEFILTERLEN); if (wbName) { if (string_is_empty(filter_data.name)) wbName->SetCaption(_T("*")); else wbName->SetCaption(filter_data.name); } UpdateList(); }
static void OnFlarmLockClicked(WindowControl * Sender) { (void)Sender; dlgTextEntryShowModal(XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget, 4); XCSoarInterface::SetSettingsComputer().TeammateCodeValid = false; int flarmId = LookupFLARMDetails(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget); if (flarmId == 0) { MessageBoxX(gettext(TEXT("Unknown Competition Number")), gettext(TEXT("Not Found")), MB_OK|MB_ICONINFORMATION); XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = false; XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget = 0; XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget[0] = 0; } else { XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget = flarmId; XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = true; } }
static void OnNameClicked(WindowControl *Sender) { (void)Sender; if (buttonName) { dlgTextEntryShowModal(global_wpt->Name, NAME_SIZE); } UpdateButtons(); }
static void OnFlarmLockClicked() { TeamCodeSettings &settings = CommonInterface::SetComputerSettings().team_code; TCHAR newTeamFlarmCNTarget[settings.team_flarm_callsign.MAX_SIZE]; _tcscpy(newTeamFlarmCNTarget, settings.team_flarm_callsign.c_str()); if (!dlgTextEntryShowModal(newTeamFlarmCNTarget, 4)) return; if (StringIsEmpty(newTeamFlarmCNTarget)) { settings.team_flarm_id.Clear(); settings.team_flarm_callsign.clear(); return; } LoadFlarmDatabases(); FlarmId ids[30]; unsigned count = FlarmDetails::FindIdsByCallSign(newTeamFlarmCNTarget, ids, 30); if (count == 0) { ShowMessageBox(_("Unknown Competition Number"), _("Not Found"), MB_OK | MB_ICONINFORMATION); return; } const FlarmId id = PickFlarmTraffic(_("Set new teammate"), ids, count); if (!id.IsDefined()) return; TeamActions::TrackFlarm(id, newTeamFlarmCNTarget); }
static void OnCommentClicked(WindowControl *Sender) { (void)Sender; if (buttonComment) { //@ 101219 TCHAR comment[COMMENT_SIZE*2]; if (global_wpt->Comment != NULL) _tcscpy(comment,global_wpt->Comment); else _tcscpy(comment,_T("")); dlgTextEntryShowModal(comment, COMMENT_SIZE); // in any case free the space if (global_wpt->Comment != NULL) free(global_wpt->Comment); if (_tcslen(comment)>0) { // do we have a new comment? global_wpt->Comment = (TCHAR*)malloc((_tcslen(comment)+2)*sizeof(TCHAR)); if (global_wpt->Comment == NULL) { StartupStore(_T("------ Wp Edit new comment malloc failed for comment <%s>! Memory problem!%s"),comment,NEWLINE); } else { _tcscpy(global_wpt->Comment,comment); } } } UpdateButtons(); }
inline void NOAAListWidget::AddClicked() { TCHAR code[5] = _T(""); if (!dlgTextEntryShowModal(code, 5, _("Airport ICAO code"))) return; if (_tcslen(code) != 4) { ShowMessageBox(_("Please enter the FOUR letter code of the desired station."), _("Error"), MB_OK); return; } if (!NOAAStore::IsValidCode(code)) { ShowMessageBox(_("Please don't use special characters in the four letter code of the desired station."), _("Error"), MB_OK); return; } NOAAStore::iterator i = noaa_store->AddStation(code); noaa_store->SaveToProfile(); DialogJobRunner runner(UIGlobals::GetMainWindow(), UIGlobals::GetDialogLook(), _("Download"), true); NOAAUpdater::Update(*i, runner); UpdateList(); }
static void OnFlarmLockClicked(gcc_unused WndButton &button) { TCHAR newTeamFlarmCNTarget[4]; _tcsncpy(newTeamFlarmCNTarget, XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget, 4); if (!dlgTextEntryShowModal(newTeamFlarmCNTarget, 4)) return; _tcsncpy(XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget, newTeamFlarmCNTarget, 4); XCSoarInterface::SetSettingsComputer().TeammateCodeValid = false; if (string_is_empty(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget)) { XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = false; XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget.clear(); return; } FlarmId flarmId = FlarmDetails::LookupId( XCSoarInterface::SettingsComputer().TeamFlarmCNTarget); if (!flarmId.defined()) { MessageBoxX(_("Unknown Competition Number"), _("Not Found"), MB_OK | MB_ICONINFORMATION); XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = false; XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget.clear(); XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget[0] = 0; } else { XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget = flarmId; XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = true; } }
static void OnFilterNameButton(gcc_unused WndButton &button) { TCHAR new_name_filter[WaypointFilter::NAME_LENGTH + 1]; CopyString(new_name_filter, dialog_state.name.c_str(), WaypointFilter::NAME_LENGTH + 1); dlgTextEntryShowModal(*(SingleWindow *)button.GetRootOwner(), new_name_filter, WaypointFilter::NAME_LENGTH, _("Waypoint name"), WaypointNameAllowedCharacters); int i = _tcslen(new_name_filter) - 1; while (i >= 0) { if (new_name_filter[i] != _T(' ')) break; new_name_filter[i] = 0; i--; } CopyString(dialog_state.name.buffer(), new_name_filter, WaypointFilter::NAME_LENGTH + 1); UpdateNameButtonCaption(); UpdateList(); }
static void CompetitionIDClicked(gcc_unused WndButton &button) { if (!dlgTextEntryShowModal(*(SingleWindow *)dialog->get_root_owner(), plane.competition_id.buffer(), plane.competition_id.MAX_SIZE)) return; UpdateButton(_T("CompetitionIDButton"), plane.competition_id); }
static void TypeClicked(gcc_unused WndButton &button) { if (!dlgTextEntryShowModal(*(SingleWindow *)dialog->get_root_owner(), plane.type.buffer(), plane.type.MAX_SIZE)) return; UpdateButton(_T("TypeButton"), plane.type); }
static void OnNameClicked(gcc_unused WndButton &button) { if (buttonName) { TCHAR buff[NAME_SIZE+1]; _tcscpy(buff, global_wpt->Name.c_str()); dlgTextEntryShowModal(buff, NAME_SIZE); global_wpt->Name = buff; } UpdateButtons(); }
static void OnCommentClicked(gcc_unused WndButton &button) { if (buttonComment) { TCHAR buff[COMMENT_SIZE+1]; _tcscpy(buff, global_wpt->Comment.c_str()); dlgTextEntryShowModal(buff, COMMENT_SIZE); global_wpt->Comment = buff; } UpdateButtons(); }
static void RegistrationClicked(gcc_unused WndButton &button) { if (!dlgTextEntryShowModal(*(SingleWindow *)dialog->get_root_owner(), plane.registration.buffer(), plane.registration.MAX_SIZE)) return; UpdateCaption(); UpdateButton(_T("RegistrationButton"), plane.registration); }
static void OnNameAccess(WndButton &button) { if (buttonPanelName) { TCHAR buffer[data.name.MAX_SIZE]; _tcscpy(buffer, data.name); if (dlgTextEntryShowModal(*(SingleWindow *)button.get_root_owner(), buffer, data.name.MAX_SIZE, _("Panel name"))) { data.name = buffer; UpdatePanelName(); } } }
static void OnSetCNClicked(WindowControl * Sender) { (void)Sender; int index = wDetails->GetItemIndex(); if (index != -1) { TCHAR newName[21]; newName[0] = 0; dlgTextEntryShowModal(newName, 4); AddFlarmLookupItem(XCSoarInterface::Basic().FLARM_Traffic[index].ID, newName, true); } }
void PolarConfigPanel::Export() { TCHAR filename[69] = _T(""); if (!dlgTextEntryShowModal(filename, 64, _("Polar name"))) return; TCHAR path[MAX_PATH]; _tcscat(filename, _T(".plr")); LocalPath(path, filename); PolarInfo polar; SaveFormToPolar(form, polar); if (PolarGlue::SaveToFile(polar, path)) { CommonInterface::SetComputerSettings().plane.polar_name = filename; UpdatePolarTitle(); } }
static void OnCodeClicked() { TCHAR newTeammateCode[10]; CopyString(newTeammateCode, CommonInterface::GetComputerSettings().team_code.team_code.GetCode(), 10); if (!dlgTextEntryShowModal(newTeammateCode, 7)) return; TrimRight(newTeammateCode); TeamCodeSettings &settings = CommonInterface::SetComputerSettings().team_code; settings.team_code.Update(newTeammateCode); if (settings.team_code.IsDefined()) settings.team_flarm_id.Clear(); }
static void OnFlarmLockClicked(gcc_unused WndButton &button) { TCHAR newTeamFlarmCNTarget[4]; _tcsncpy(newTeamFlarmCNTarget, XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget, 4); if (!dlgTextEntryShowModal(newTeamFlarmCNTarget, 4)) return; _tcsncpy(XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget, newTeamFlarmCNTarget, 4); XCSoarInterface::SetSettingsComputer().TeammateCodeValid = false; if (string_is_empty(XCSoarInterface::SettingsComputer().TeamFlarmCNTarget)) { XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = false; XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget.clear(); return; } const FlarmId *ids[30]; unsigned count = FlarmDetails::FindIdsByCallSign( XCSoarInterface::SettingsComputer().TeamFlarmCNTarget, ids, 30); if (count > 0) { const FlarmId *id = dlgFlarmDetailsListShowModal( XCSoarInterface::main_window, _("Set new teammate:"), ids, count); if (id != NULL && id->defined()) { XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget = *id; XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = true; return; } } else { MessageBoxX(_("Unknown Competition Number"), _("Not Found"), MB_OK | MB_ICONINFORMATION); } XCSoarInterface::SetSettingsComputer().TeamFlarmTracking = false; XCSoarInterface::SetSettingsComputer().TeamFlarmIdTarget.clear(); XCSoarInterface::SetSettingsComputer().TeamFlarmCNTarget[0] = 0; }
static void OnCodeClicked(WindowControl *Sender) { TCHAR newTeammateCode[10]; _tcsncpy(newTeammateCode, XCSoarInterface::SettingsComputer().TeammateCode, 10); dlgTextEntryShowModal(newTeammateCode, 7); int i= _tcslen(newTeammateCode)-1; while (i>=0) { if (newTeammateCode[i]!=_T(' ')) { break; } newTeammateCode[i]=0; i--; }; _tcsncpy(XCSoarInterface::SetSettingsComputer().TeammateCode, newTeammateCode, 10); if (_tcslen(XCSoarInterface::SettingsComputer().TeammateCode)>0) { XCSoarInterface::SetSettingsComputer().TeammateCodeValid = true; } }
void OnPair(WndButton* pWnd) { CBtHandler* pBtHandler = CBtHandler::Get(); if (pBtHandler) { CBtDevice * SelectedDevice = pBtHandler->GetDevice(ItemIndex); if (SelectedDevice && SelectedDevice->m_src == BDSRC_LOOKUP) { TCHAR szPin[20] = {0}; dlgTextEntryShowModal(szPin, 20, false); if (!pBtHandler->Pair(SelectedDevice->m_ba, SelectedDevice->GetName().c_str(), szPin)) { StartupStore(_T("Bluetooth pairing <%s> : Failed%s"), SelectedDevice->GetName().c_str(), NEWLINE); MessageBoxX(LKGetText(TEXT("_@M1835_")), TEXT("Bluetooth"), mbOk, false); } else { StartupStore(_T("Bluetooth pairing <%s> : success%s"), SelectedDevice->GetName().c_str(), NEWLINE); SelectedDevice->m_src |= BDSRC_REGNAV; } } WndListFrame* BthList = (WndListFrame*) wfBth->FindByName(TEXT("frmBthList")); if (BthList) { BthList->ResetList(); BthList->Redraw(); } } }
bool OrderedTaskSave(const OrderedTask& task, bool noask) { assert(protected_task_manager != NULL); if (!noask && ShowMessageBox(_("Save task?"), _("Task Selection"), MB_YESNO | MB_ICONQUESTION) != IDYES) return false; TCHAR fname[69] = _T(""); if (!dlgTextEntryShowModal(fname, 64)) return false; TCHAR path[MAX_PATH]; LocalPath(path, _T("tasks")); Directory::Create(path); _tcscat(fname, _T(".tsk")); LocalPath(path, _T("tasks"), fname); protected_task_manager->TaskSave(path, task); return true; }
static void OnCodeClicked(WindowControl *Sender) { TCHAR newTeammateCode[10]; _tcsncpy(newTeammateCode, TeammateCode, 10); dlgTextEntryShowModal(newTeammateCode, 7); int i= _tcslen(newTeammateCode)-1; while (i>=0) { if (newTeammateCode[i]!=_T(' ')) { break; } newTeammateCode[i]=0; i--; }; _tcsncpy(TeammateCode, newTeammateCode, 10); if (_tcslen(TeammateCode)>0) { TeammateCodeValid = true; OvertargetMode = OVT_MATE; } else { TeammateCodeValid = false; Update(); } }
static void OnSaveClicked(WindowControl * Sender, WndListFrame::ListInfo_t *ListInfo){ (void)ListInfo; (void)Sender; int file_index; TCHAR task_name[MAX_PATH]; TCHAR file_name[MAX_PATH]; WndProperty* wp; DataFieldFileReader *dfe; wp = (WndProperty*)wf->FindByName(TEXT("prpFile")); if (!wp) return; dfe = (DataFieldFileReader*)wp->GetDataField(); file_index = dfe->GetAsInteger(); // TODO enhancement: suggest a good new name not already in the list _tcscpy(task_name,TEXT("NEW")); dlgTextEntryShowModal(task_name, 10); // max length if (_tcslen(task_name)>0) { _tcscat(task_name, TEXT(LKS_TSK)); LocalPath(file_name,TEXT(LKD_TASKS)); _tcscat(file_name,TEXT("\\")); _tcscat(file_name,task_name); // 091101 dfe->Lookup(file_name); file_index = dfe->GetAsInteger(); if (file_index==0) { // good, this file is unique.. dfe->addFile(task_name, file_name); dfe->Lookup(file_name); wp->RefreshDisplay(); } } else { // TODO code: report error, task not saved since no name was given return; } if (file_index>0) { // file already exists! ask if want to overwrite _stprintf(file_name, TEXT("%s: '%s'"), // LKTOKEN _@M696_ = "Task file already exists" gettext(TEXT("_@M696_")), dfe->GetAsString()); if(MessageBoxX(hWndMapWindow, file_name, // LKTOKEN _@M510_ = "Overwrite?" gettext(TEXT("_@M510_")), MB_YESNO|MB_ICONQUESTION) != IDYES) { return; } } SaveTask(dfe->GetPathFile()); UpdateCaption(); }
static void OnSaveNewClicked(WindowControl * Sender) { (void)Sender; int file_index; TCHAR file_name[MAX_PATH]; TCHAR profile_name[MAX_PATH]; TCHAR tmptext[MAX_PATH]; WndProperty* wp; DataFieldFileReader *dfe; wp = (WndProperty*)wf->FindByName(TEXT("prpFile")); if (!wp) return; dfe = (DataFieldFileReader*) wp->GetDataField(); _tcscpy(profile_name,_T("")); dlgTextEntryShowModal(profile_name, 13); // max length including termination 0 if (_tcslen(profile_name)<=0) return; _tcscat(profile_name, TEXT(LKS_PRF)); LocalPath(file_name,TEXT(LKD_CONF)); _tcscat(file_name,TEXT("\\")); _tcscat(file_name,profile_name); dfe->Lookup(file_name); file_index = dfe->GetAsInteger(); if (file_index==0) { _stprintf(tmptext, TEXT("%s: %s"), // LKTOKEN _@M458_ = "New profile" gettext(TEXT("_@M458_")), profile_name); if(MessageBoxX(hWndMapWindow, tmptext, // LKTOKEN _@M579_ = "Save ?" gettext(TEXT("_@M579_")), MB_YESNO|MB_ICONQUESTION) == IDYES) { WriteProfile(file_name); dfe->addFile(profile_name, file_name); MessageBoxX(hWndMapWindow, // LKTOKEN _@M535_ = "Profile saved!" gettext(TEXT("_@M535_")), _T(""), MB_OK|MB_ICONEXCLAMATION); dfe->Set(0); return; } } if (file_index>0) { _stprintf(tmptext, TEXT("%s: %s"), // LKTOKEN _@M533_ = "Profile already exists" gettext(TEXT("_@M533_")), profile_name); if (CheckClubVersion() ) { MessageBoxX(hWndMapWindow, tmptext, // LKTOKEN _@M162_ = "Cannot overwrite!" gettext(TEXT("_@M162_")), MB_OK|MB_ICONEXCLAMATION); } else { if(MessageBoxX(hWndMapWindow, tmptext, // LKTOKEN _@M510_ = "Overwrite?" gettext(TEXT("_@M510_")), MB_YESNO|MB_ICONQUESTION) == IDYES) { WriteProfile(file_name); MessageBoxX(hWndMapWindow, // LKTOKEN _@M535_ = "Profile saved!" gettext(TEXT("_@M535_")), _T(""), MB_OK|MB_ICONEXCLAMATION); return; } } dfe->Set(0); } }
static void Main() { TCHAR text[64] = _T(""); dlgTextEntryShowModal(text, ARRAY_SIZE(text), _T("The caption")); }
static void OnTargetClicked(WindowControl * Sender) { (void)Sender; if (SelectedTraffic<0 || SelectedTraffic>MAXTRAFFIC) { StartupStore(_T("--- Invalid traffic selected to Target, out of range%s"),NEWLINE); DoStatusMessage(_T("ERR-126 invalid TARGET traffic")); return; } if ( GPS_INFO.FLARM_Traffic[SelectedTraffic].ID <1 ) { DoStatusMessage(gettext(TEXT("_@M879_"))); // SORRY TARGET JUST DISAPPEARED return; } if ( LKTraffic[SelectedTraffic].Locked ) { #if 0 if (MessageBoxX(hWndMapWindow, gettext(TEXT("_@M880_")), // UNLOCK current target? gettext(TEXT("_@M881_")), // Target selection MB_YESNO|MB_ICONQUESTION) == IDYES) { #endif LockFlightData(); GPS_INFO.FLARM_Traffic[SelectedTraffic].Locked=false; UnlockFlightData(); LKTargetIndex=-1; LKTargetType=LKT_TYPE_NONE; WayPointList[RESWP_FLARMTARGET].Latitude = RESWP_INVALIDNUMBER; WayPointList[RESWP_FLARMTARGET].Longitude = RESWP_INVALIDNUMBER; WayPointList[RESWP_FLARMTARGET].Altitude = RESWP_INVALIDNUMBER; _tcscpy(WayPointList[RESWP_FLARMTARGET].Name,_T(RESWP_FLARMTARGET_NAME) ); DoStatusMessage(gettext(TEXT("_@M882_"))); // TARGET RELEASED wf->SetModalResult(mrOK); return; } #if 0 if (MessageBoxX(hWndMapWindow, gettext(TEXT("_@M884_")), // LOCK this target? gettext(TEXT("_@M881_")), // Target selection MB_YESNO|MB_ICONQUESTION) == IDYES) { #endif // one more check for existance if ( GPS_INFO.FLARM_Traffic[SelectedTraffic].ID <1 ) { DoStatusMessage(gettext(TEXT("_@M883_"))); // TARGET DISAPPEARED! return; } LockFlightData(); // unlock previous target, if any if (LKTargetIndex>=0 && LKTargetIndex<MAXTRAFFIC) { GPS_INFO.FLARM_Traffic[LKTargetIndex].Locked=false; } GPS_INFO.FLARM_Traffic[SelectedTraffic].Locked=true; UnlockFlightData(); // LKTOKEN _@M675_ = "TARGET LOCKED" DoStatusMessage(gettext(TEXT("_@M675_"))); LKTargetIndex=SelectedTraffic; LKTargetType=LKT_TYPE_MASTER; // Remember that we need to update the virtual waypoint constantly when we receive FLARM data of target // Probably name is not updated if changed from Flarm menu... OvertargetMode=OVT_FLARM; WayPointList[RESWP_FLARMTARGET].Latitude = GPS_INFO.FLARM_Traffic[LKTargetIndex].Latitude; WayPointList[RESWP_FLARMTARGET].Longitude = GPS_INFO.FLARM_Traffic[LKTargetIndex].Longitude; WayPointList[RESWP_FLARMTARGET].Altitude = GPS_INFO.FLARM_Traffic[LKTargetIndex].Altitude; if (_tcslen(GPS_INFO.FLARM_Traffic[LKTargetIndex].Name) == 1) { _stprintf(WayPointList[RESWP_FLARMTARGET].Name,_T("%0x"),GPS_INFO.FLARM_Traffic[LKTargetIndex].ID); } else { _stprintf(WayPointList[RESWP_FLARMTARGET].Name,_T("%s"),GPS_INFO.FLARM_Traffic[LKTargetIndex].Name); } SetModeType(LKMODE_TRF, IM_TARGET); wf->SetModalResult(mrOK); } static void OnRenameClicked(WindowControl * Sender){ (void)Sender; if (SelectedTraffic<0 || SelectedTraffic>MAXTRAFFIC) { StartupStore(_T("--- Invalid traffic selected to rename, out of range%s"),NEWLINE); DoStatusMessage(_T("ERR-126 invalid traffic")); return; } if ( LKTraffic[SelectedTraffic].ID <1 ) { StartupStore(_T("--- Invalid traffic selected to rename, invalid ID%s"),NEWLINE); DoStatusMessage(_T("ERR-127 invalid traffic")); return; } TCHAR newName[MAXFLARMNAME+1]; newName[0] = 0; dlgTextEntryShowModal(newName, 7); // 100322 raised from 3 to 6 (+1) newName[MAXFLARMNAME] = 0; #ifdef DEBUG_LKT StartupStore(_T("************ dlgLK RenameClicked for slot=%d id=%lx status=%d oldname=<%s> newName=<%s>\n"), SelectedTraffic, GPS_INFO.FLARM_Traffic[SelectedTraffic].ID, GPS_INFO.FLARM_Traffic[SelectedTraffic].Status, GPS_INFO.FLARM_Traffic[SelectedTraffic].Name, newName); #endif int newnamelen=_tcslen(newName); if (newnamelen>0) { LockFlightData(); // Since we don-t know if a new PFLAA with this ID will arrive, and the UpdateNameFlag will be used, // we must change the name here now. _tcscpy(GPS_INFO.FLARM_Traffic[SelectedTraffic].Name,newName); // ... and here also, because SetValues is using this copy _tcscpy(LKTraffic[SelectedTraffic].Name,newName); // we assume that no Cn is available, or in any case cannot be kept // If newName is smaller or equal to possible Cn, we use it entirely if (newnamelen<=MAXFLARMCN) { _tcscpy( GPS_INFO.FLARM_Traffic[SelectedTraffic].Cn, newName); } else { // else we create a fake Cn GPS_INFO.FLARM_Traffic[SelectedTraffic].Cn[0]=newName[0]; GPS_INFO.FLARM_Traffic[SelectedTraffic].Cn[1]=newName[newnamelen-2]; GPS_INFO.FLARM_Traffic[SelectedTraffic].Cn[2]=newName[newnamelen-1]; GPS_INFO.FLARM_Traffic[SelectedTraffic].Cn[3]=_T('\0'); } // update it temporarily so that it appears updated leaving the edit page _tcscpy(LKTraffic[SelectedTraffic].Cn,GPS_INFO.FLARM_Traffic[SelectedTraffic].Cn); // It will be useless, because we already updated the name.. but never mind. GPS_INFO.FLARM_Traffic[SelectedTraffic].UpdateNameFlag=true; // This will create the local flarmid entry, but won't update the structure in GPS_INFO // until a new PFLAA arrives from this ID. AddFlarmLookupItem(GPS_INFO.FLARM_Traffic[SelectedTraffic].ID, newName, true); UnlockFlightData(); #ifdef DEBUG_LKT StartupStore(_T("...... dlgLK RENAMED slot=%d id=%lx status=%d name=<%s>\n"), SelectedTraffic, GPS_INFO.FLARM_Traffic[SelectedTraffic].ID, GPS_INFO.FLARM_Traffic[SelectedTraffic].Status, GPS_INFO.FLARM_Traffic[SelectedTraffic].Name); #endif // reload the name... SetValues(SelectedTraffic); } } static void OnCloseClicked(WindowControl * Sender){ (void)Sender; wf->SetModalResult(mrOK); }