static void OnDetailsClicked(WndButton* pWnd){ TCHAR Details[READLINE_LENGTH +1] = _T(""); TCHAR Name[NAME_SIZE +1]= _T(""); { ScopeLock guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { if(airspace->Comment() != NULL) _sntprintf(Details,READLINE_LENGTH, _T("%s"), airspace->Comment()); else _sntprintf(Details, READLINE_LENGTH,_T("%s"), (TCHAR*)airspace->TypeName()); _sntprintf(Name,NAME_SIZE, _T("%s %s:"), (TCHAR*)airspace->TypeName(), MsgToken(231) ); } //#if TESTBENCH StartupStore(_T(". Airspace Name <%s>%s"),Details,NEWLINE); //#endif dlgHelpShowModal(Name, Details, false); } }
static void OnAirspaceListEnter(WindowControl * Sender, WndListFrame::ListInfo_t *ListInfo) { if (ItemIndex != -1) { if ((UpLimit-LowLimit>0) && (ItemIndex >= 0) // JMW fixed bug, was >0 && (ItemIndex < (UpLimit - LowLimit))) { const size_t i = (FullFlag) ? StrIndex[LowLimit + ItemIndex] : (LowLimit + ItemIndex); CAirspace *airspace = AirspaceSelectInfo[i].airspace; if (airspace) { if(airspace->Enabled()) { LKSound(TEXT("LK_BEEP0.WAV")); CAirspaceManager::Instance().AirspaceDisable(*airspace); }else{ LKSound(TEXT("LK_BEEP1.WAV")); CAirspaceManager::Instance().AirspaceEnable(*airspace); } } } } }
static void OnPaintAirspacePicto(WindowControl * Sender, LKSurface& Surface){ (void)Sender; WndFrame *wPicto = ((WndFrame *)wf->FindByName(TEXT("frmAirspacePicto"))); LKASSERT(wPicto!=NULL); const RECT rc = wPicto->GetClientRect(); Surface.SelectObject(LKPen_Petrol_C2); Surface.SelectObject(LKBrush_Petrol); Surface.Rectangle(rc.left,rc.top,rc.right,rc.bottom); Surface.SetBkColor(RGB_LIGHTGREY); /**************************************************************** * for drawing the airspace pictorial, we need the original data. * copy contain only base class property, not geo data, * original data are shared ressources ! * for that we need to grant all called methods are thread safe ****************************************************************/ { CCriticalSection::CGuard guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { airspace->DrawPicto(Surface, rc); } } }
static void OnPaintAirspacePicto(WindowControl * Sender, LKSurface& Surface){ const RECT rc = Sender->GetClientRect(); Surface.SetBkColor(RGB_LIGHTGREY); /**************************************************************** * for drawing the airspace pictorial, we need the original data. * copy contain only base class property, not geo data, * original data are shared ressources ! * for that we need to grant all called methods are thread safe ****************************************************************/ { ScopeLock guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { airspace->DrawPicto(Surface, rc); } } }
// Called periodically to show new airspace warning messages to user // return 1 only for requesting run analysis // This is called by WINMAIN thread, every second (1hz) short ShowAirspaceWarningsToUser() { if (msg.originator != NULL) return 0; // Dialog already open bool there_is_message = CAirspaceManager::Instance().PopWarningMessage(&msg); if (!there_is_message) return 0; // no message to display airspace_copy = CAirspaceManager::Instance().GetAirspaceCopy(msg.originator); bool ackdialog_required = false; TCHAR msgbuf[128]; // which message we need to show? switch (msg.event) { default: // normally not show DoStatusMessage(TEXT("Unknown airspace warning message")); break; //Unknown msg type case aweNone: case aweMovingInsideFly: // normal, no msg, normally this msg type shouldn't get here case awePredictedEnteringFly: // normal, no msg, normally this msg type shouldn't get here case aweMovingOutsideNonfly: // normal, no msg, normally this msg type shouldn't get here break; case awePredictedLeavingFly: case aweNearOutsideFly: case aweLeavingFly: case awePredictedEnteringNonfly: case aweNearInsideNonfly: case aweEnteringNonfly: case aweMovingInsideNonfly: // repeated messages case aweMovingOutsideFly: // repeated messages ackdialog_required = true; break; case aweEnteringFly: // LKTOKEN _@M1240_ "Entering" if( _tcsnicmp( airspace_copy.Name(), airspace_copy.TypeName() ,_tcslen(airspace_copy.TypeName())) == 0) _stprintf(msgbuf,TEXT("%s %s"),gettext(TEXT("_@M1240_")),airspace_copy.Name()); else _stprintf(msgbuf,TEXT("%s %s %s"),gettext(TEXT("_@M1240_")),airspace_copy.TypeName(),airspace_copy.Name()); // wsprintf(msgbuf, TEXT("%s %s %s "), gettext(TEXT("_@M1240_")),airspace_copy.TypeName(), airspace_copy.Name()); DoStatusMessage(msgbuf); break; case aweLeavingNonFly: // LKTOKEN _@M1241_ "Leaving" if( _tcsnicmp( airspace_copy.Name(), airspace_copy.TypeName() ,_tcslen(airspace_copy.TypeName())) == 0) _stprintf(msgbuf,TEXT("%s %s"),gettext(TEXT("_@M1241_")),airspace_copy.Name()); else _stprintf(msgbuf,TEXT("%s %s %s"),gettext(TEXT("_@M1241_")),airspace_copy.TypeName(),airspace_copy.Name()); // wsprintf(msgbuf, TEXT("%s %s %s"), gettext(TEXT("_@M1241_")),airspace_copy.TypeName(), airspace_copy.Name()); DoStatusMessage(msgbuf); break; } // show dialog to user if needed if (ackdialog_required && (airspace_copy.WarningLevel() == msg.warnlevel)) { if (!ScreenLandscape) dlg = dlgLoadFromXML(CallBackTable, NULL, hWndMainWindow, TEXT("IDR_XML_LKAIRSPACEWARNING_L")); else dlg = dlgLoadFromXML(CallBackTable, NULL, hWndMainWindow, TEXT("IDR_XML_LKAIRSPACEWARNING")); if (dlg==NULL) { StartupStore(_T("------ LKAirspaceWarning setup FAILED!%s"),NEWLINE); //@ 101027 return 0; } dlg->SetKeyDownNotify(OnKeyDown); dlg->SetTimerNotify(OnTimer); timer_counter = AirspaceWarningDlgTimeout; // Auto closing dialog in x secs WndButton *wb = (WndButton*)dlg->FindByName(TEXT("cmdAckForTime")); if (wb) { TCHAR stmp2[40]; wsprintf(stmp2,TEXT("%s (%dmin)"), gettext(TEXT("_@M46_")), AcknowledgementTime/60); wb->SetCaption(stmp2); } dlgLKAirspaceFill(); #ifndef DISABLEAUDIO if (EnableSoundModes) LKSound(_T("LK_AIRSPACE.WAV")); // 100819 #endif if( _tcsnicmp( airspace_copy.Name(), airspace_copy.TypeName() ,_tcslen(airspace_copy.TypeName())) == 0) _stprintf(msgbuf,TEXT("%s"),airspace_copy.Name()); else _stprintf(msgbuf,TEXT("%s %s"),airspace_copy.TypeName(),airspace_copy.Name()); // _stprintf(msgbuf,_T("%s: %s %s"),gettext(_T("_@M68_")),airspace_copy.TypeName(),airspace_copy.Name()); dlg->SetCaption(msgbuf); dlg->ShowModal(); delete dlg; dlg = NULL; } msg.originator = NULL; // If we clicked on Analysis button, we shall return 1 and the calling function will // detect and take care of it. // 120128 unused, we call directly eventSetup return 1; }
void dlgLKAirspaceFill() { if (msg.warnlevel != airspace_copy.WarningLevel()) { // we can automatically close the dialog when the warning level changes, probably new msg waiting in the queue dlg->SetModalResult(mrOK); } //Fill up dialog data WndProperty* wp; WndButton* wb; wp = (WndProperty*)dlg->FindByName(TEXT("prpReason")); if (wp) { switch (msg.event) { default: // Normally not show // LKTOKEN _@M765_ "Unknown" wp->SetText(gettext(TEXT("_@M765_"))); break; case aweNone: // LKTOKEN _@M479_ "None" wp->SetText(gettext(TEXT("_@M479_"))); break; case aweMovingInsideFly: // LKTOKEN _@M1242_ "Flying inside FLY zone" wp->SetText(gettext(TEXT("_@M1242_"))); break; case awePredictedLeavingFly: // LKTOKEN _@M1243_ "Predicted leaving FLY zone" wp->SetText(gettext(TEXT("_@M1243_"))); break; case aweNearOutsideFly: // LKTOKEN _@M1244_ "Near leaving FLY zone" wp->SetText(gettext(TEXT("_@M1244_"))); break; case aweLeavingFly: // LKTOKEN _@M1245_ "Leaving FLY zone" wp->SetText(gettext(TEXT("_@M1245_"))); break; case awePredictedEnteringFly: // LKTOKEN _@M1246_ "Predicted entering FLY zone" wp->SetText(gettext(TEXT("_@M1246_"))); break; case aweEnteringFly: // LKTOKEN _@M1247_ "Entering FLY zone" wp->SetText(gettext(TEXT("_@M1247_"))); break; case aweMovingOutsideFly: // LKTOKEN _@M1248_ "Flying outside FLY zone" wp->SetText(gettext(TEXT("_@M1248_"))); break; // Events for NON-FLY zones case aweMovingOutsideNonfly: // LKTOKEN _@M1249_ "Flying outside NOFLY zone" wp->SetText(gettext(TEXT("_@M1249_"))); break; case awePredictedEnteringNonfly: // LKTOKEN _@M1250_ "Predicted entering NOFLY zone" wp->SetText(gettext(TEXT("_@M1250_"))); break; case aweNearInsideNonfly: // LKTOKEN _@M1251_ "Near entering NOFLY zone" wp->SetText(gettext(TEXT("_@M1251_"))); break; case aweEnteringNonfly: // LKTOKEN _@M1252_ "Entering NOFLY zone" wp->SetText(gettext(TEXT("_@M1252_"))); break; case aweMovingInsideNonfly: // LKTOKEN _@M1253_ "Flying inside NOFLY zone" wp->SetText(gettext(TEXT("_@M1253_"))); break; case aweLeavingNonFly: // LKTOKEN _@M1254_ "Leaving NOFLY zone" wp->SetText(gettext(TEXT("_@M1254_"))); break; }//sw switch (airspace_copy.WarningLevel()) { case awYellow: wp->SetBackColor(RGB_YELLOW); wp->SetForeColor(RGB_BLACK); break; case awRed: wp->SetBackColor(RGB_RED); break; default: break; } wp->RefreshDisplay(); } #if 0 // unused but available for sometime wp = (WndProperty*)dlg->FindByName(TEXT("prpState")); if (wp) { switch (airspace_copy.WarningLevel()) { default: // LKTOKEN _@M765_ "Unknown" wp->SetText(gettext(TEXT("_@M765_"))); break; case awNone: // LKTOKEN _@M479_ "None" wp->SetText(gettext(TEXT("_@M479_"))); break; case awYellow: // LKTOKEN _@M1255_ "YELLOW WARNING" wp->SetText(gettext(TEXT("_@M1255_"))); wp->SetBackColor(RGB_YELLOW); wp->SetForeColor(RGB_BLACK); break; case awRed: // LKTOKEN _@M1256_ "RED WARNING" wp->SetText(gettext(TEXT("_@M1256_"))); wp->SetBackColor(RGB_RED); break; }//sw wp->RefreshDisplay(); } wp = (WndProperty*)dlg->FindByName(TEXT("prpName")); if (wp) { wp->SetText(airspace_copy.Name()); wp->RefreshDisplay(); } #endif int hdist; int vdist; int bearing; bool inside; TCHAR stmp[21]; TCHAR buffer[80]; wp = (WndProperty*)dlg->FindByName(TEXT("prpType")); if (wp) { if (airspace_copy.Flyzone()) { wsprintf(buffer,TEXT("%s %s"), gettext(TEXT("FLY")), airspace_copy.TypeName()); } else { wsprintf(buffer,TEXT("%s %s"), gettext(TEXT("NOFLY")), airspace_copy.TypeName()); } wp->SetText( buffer ); // wp->SetBackColor( airspace_copy.TypeColor()); // wp->SetForeColor( ContrastTextColor(airspace_copy.TypeColor())); wp->RefreshDisplay(); } // Unfortunatelly virtual methods don't work on copied instances // we have to ask airspacemanager to perform the required calculations //inside = airspace_copy.CalculateDistance(&hdist, &bearing, &vdist); //inside = CAirspaceManager::Instance().AirspaceCalculateDistance(msg.originator, &hdist, &bearing, &vdist); bool distances_ready = airspace_copy.GetDistanceInfo(inside, hdist, bearing, vdist); wp = (WndProperty*)dlg->FindByName(TEXT("prpHDist")); if (wp) { TCHAR stmp2[40]; if (distances_ready) { Units::FormatUserDistance((double)abs(hdist),stmp, 10); if (hdist<0) { // LKTOKEN _@M1257_ "to leave" wsprintf(stmp2, TEXT("%s %s"), stmp, gettext(TEXT("_@M1257_"))); } else { // LKTOKEN _@M1258_ "to enter" wsprintf(stmp2,TEXT("%s %s"), stmp, gettext(TEXT("_@M1258_"))); } } else { // no distance info calculated // LKTOKEN _@M1259_ "Too far, not calculated" wsprintf(stmp2,gettext(TEXT("_@M1259_"))); } wp->SetText(stmp2); wp->RefreshDisplay(); } wp = (WndProperty*)dlg->FindByName(TEXT("prpVDist")); if (wp) { TCHAR stmp2[40]; if (distances_ready) { Units::FormatUserAltitude((double)abs(vdist),stmp, 10); if (vdist<0) { // LKTOKEN _@M1260_ "below" wsprintf(stmp2,TEXT("%s %s"), stmp, gettext(TEXT("_@M1260_"))); } else { // LKTOKEN _@M1261_ "above" wsprintf(stmp2,TEXT("%s %s"), stmp, gettext(TEXT("_@M1261_"))); } } else { // no distance info calculated // LKTOKEN _@M1259_ "Too far, not calculated" wsprintf(stmp2,gettext(TEXT("_@M1259_"))); } wp->SetText(stmp2); wp->RefreshDisplay(); } wp = (WndProperty*)dlg->FindByName(TEXT("prpTopAlt")); if (wp) { TCHAR stmp2[40]; CAirspaceManager::Instance().GetAirspaceAltText(stmp2, 40, airspace_copy.Top()); wp->SetText(stmp2); wp->RefreshDisplay(); } wp = (WndProperty*)dlg->FindByName(TEXT("prpBaseAlt")); if (wp) { TCHAR stmp2[40]; CAirspaceManager::Instance().GetAirspaceAltText(stmp2, 40, airspace_copy.Base()); wp->SetText(stmp2); wp->RefreshDisplay(); } wb = (WndButton*)dlg->FindByName(TEXT("cmdClose")); if (wb) { TCHAR stmp2[40]; wsprintf(stmp2,TEXT("%s (%d)"), gettext(TEXT("_@M186_")), timer_counter); wb->SetCaption(stmp2); } }
static void SetValues(WndForm* wf) { WndProperty* wp; WndButton *wb; TCHAR buffer[80]; TCHAR buffer2[160]; // must contain buffer int bearing; int hdist; int vdist; bool inside = false; { ScopeLock guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace) { // Get an object instance copy with actual values airspace_copy = CAirspaceManager::Instance().GetAirspaceCopy(airspace); inside = CAirspaceManager::Instance().AirspaceCalculateDistance( airspace, &hdist, &bearing, &vdist); } else { // error : CAirspaceManager are closed ? return; } } if (wf!=NULL) { TCHAR capbuffer[250]; _stprintf(capbuffer,_T("%s ("),airspace_copy.Name()); if (airspace_copy.Enabled()) { _tcscat(capbuffer,MsgToken(1643)); // ENABLED } else { _tcscat(capbuffer,MsgToken(1600)); // DISABLED } _tcscat(capbuffer,_T(")")); // DISABLED wf->SetCaption(capbuffer); } wp = (WndProperty*)wf->FindByName(TEXT("prpType")); if (wp) { if (airspace_copy.Flyzone()) { _stprintf(buffer,TEXT("%s %s"), CAirspaceManager::GetAirspaceTypeText(airspace_copy.Type()), TEXT("FLY")); /* if( _tcsnicmp( airspace_copy.Name(), airspace_copy.TypeName() ,_tcslen(airspace_copy.TypeName())) == 0) _stprintf(buffer,TEXT("%s"),airspace_copy.Name()); else _stprintf(buffer,TEXT("%s %s"),airspace_copy.TypeName() // fixed strings max. 20 ,airspace_copy.Name()); // NAME_SIZE 30 => max. 30 char */ } else { _stprintf(buffer,TEXT("%s %s"), TEXT("NOFLY"), CAirspaceManager::GetAirspaceTypeText(airspace_copy.Type())); } wp->SetText( buffer ); // wp->SetBackColor( airspace_copy.TypeColor()); // wp->SetForeColor( ContrastTextColor(airspace_copy.TypeColor())); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(TEXT("prpTop")); if (wp) { CAirspaceManager::Instance().GetAirspaceAltText(buffer, sizeof(buffer)/sizeof(buffer[0]), airspace_copy.Top()); wp->SetText(buffer); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(TEXT("prpBase")); if (wp) { CAirspaceManager::Instance().GetAirspaceAltText(buffer, sizeof(buffer)/sizeof(buffer[0]), airspace_copy.Base()); wp->SetText(buffer); wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(TEXT("prpRange")); if (wp) { Units::FormatUserDistance(abs(hdist), buffer, 20); if (inside) { // LKTOKEN _@M359_ = "Inside" wp->SetCaption(MsgToken(359)); } if (hdist < 0) { // LKTOKEN _@M1257_ "to leave" _stprintf(buffer2, TEXT("%s %d%s %s"), buffer, iround(bearing), MsgToken(2179), MsgToken(1257)); } else { // LKTOKEN _@M1258_ "to enter" _stprintf(buffer2, TEXT("%s %d%s %s"), buffer, iround(bearing), MsgToken(2179), MsgToken(1258)); } wp->SetText(buffer2); wp->RefreshDisplay(); } WindowControl* wDetails = wf->FindByName(TEXT("cmdDetails")); { ScopeLock guard(CAirspaceManager::Instance().MutexRef()); CAirspace* airspace = CAirspaceManager::Instance().GetAirspacesForDetails(); if(airspace->Comment() != NULL) { if(_tcslen(airspace->Comment()) > 10 ) { WindowControl* wSelect = wf->FindByName(TEXT("cmdSelect")); if(wSelect) { wSelect->SetLeft(IBLSCALE(155)); wSelect->SetWidth(IBLSCALE(80)); } wDetails->SetLeft(IBLSCALE(80)); wDetails->SetWidth(IBLSCALE(75)); wDetails->Enable(true); } else wDetails->Enable(false); } } #ifdef RADIO_ACTIVE WindowControl* wFreq = wf->FindByName(TEXT("cmdSFrequency")); if (wFreq) { bool bRadio = false; if(RadioPara.Enabled) { double fASFrequency = ExtractFrequency((TCHAR*)airspace_copy.Name()); if(!ValidFrequency(fASFrequency)) { fASFrequency = ExtractFrequency((TCHAR*)airspace_copy.Comment()); } if(ValidFrequency(fASFrequency)) { WindowControl* wClose = wf->FindByName(TEXT("cmdClose")); if(wClose) { wClose->SetLeft(IBLSCALE(115)); wClose->SetWidth(IBLSCALE(120)); } wFreq->SetLeft(IBLSCALE(3)); wFreq->SetWidth(IBLSCALE(110)); _stprintf(buffer2,_T("%7.3fMHz"),fASFrequency); wFreq->SetCaption(buffer2); wFreq->Redraw(); bRadio = true; } } wFreq->SetVisible(bRadio); } #else WndProperty* wFreq = wf->FindByName(TEXT("cmdSFrequency")); if (wFreq) { wFreq->Hide(); } #endif // RADIO_ACTIVE // ONLY for DIAGNOSTICS- ENABLE ALSO XML #if 0 wp = (WndProperty*)wf->FindByName(TEXT("prpWarnLevel")); if (wp) { switch (airspace_copy.WarningLevel()) { default: // LKTOKEN _@M765_ "Unknown" wp->SetText(MsgToken(765)); break; case awNone: // LKTOKEN _@M479_ "None" wp->SetText(MsgToken(479)); break; case awYellow: // LKTOKEN _@M1255_ "YELLOW WARNING" wp->SetText(MsgToken(1255)); break; case awRed: // LKTOKEN _@M1256_ "RED WARNING" wp->SetText(MsgToken(1256)); break; }//sw wp->RefreshDisplay(); } wp = (WndProperty*)wf->FindByName(TEXT("prpAckLevel")); if (wp) { if (airspace_copy.Enabled()) { switch (airspace_copy.WarningAckLevel()) { default: // LKTOKEN _@M765_ "Unknown" wp->SetText(MsgToken(765)); break; case awNone: // LKTOKEN _@M479_ "None" wp->SetText(MsgToken(479)); break; case awYellow: // LKTOKEN _@M1267_ "Yellow acknowledged" wp->SetText(MsgToken(1267)); break; case awRed: // LKTOKEN _@M1268_ "Red acknowledged" wp->SetText(MsgToken(1268)); break; }//sw } else { // LKTOKEN _@M1269_ "Disabled" wp->SetText(MsgToken(1269)); } wp->RefreshDisplay(); } #endif wb = (WndButton*)wf->FindByName(TEXT("cmdFly")); if (wb) { if (airspace_copy.Flyzone()) { // LKTOKEN _@M1271_ "NOFLY" wb->SetCaption(MsgToken(1271)); } else { // LKTOKEN _@M1270_ "FLY" wb->SetCaption(MsgToken(1270)); } wb->Redraw(); } wb = (WndButton*)wf->FindByName(TEXT("cmdSelect")); if (wb) { if (airspace_copy.Selected()) { wb->SetCaption(MsgToken(1656)); // SELECTED! } else { wb->SetCaption(MsgToken(1654)); // SELECT } wb->Redraw(); } wb = (WndButton*)wf->FindByName(TEXT("cmdAcknowledge")); if (wb) { if (airspace_copy.Enabled()) { // LKTOKEN _@M1283_ "Disable" wb->SetCaption(MsgToken(1283)); } else { // LKTOKEN _@M1282_ "Enable" wb->SetCaption(MsgToken(1282)); } wb->Redraw(); } }