Пример #1
0
bool dlgAirspaceWarningIsEmpty(void) {
#ifdef LKAIRSPACE
    return (airspaces.size() == 0);
#else
  return (AirspaceWarnGetItemCount()==0);
#endif
}
Пример #2
0
int UserMsgNotify(WindowControl *Sender, MSG *msg){

  if (msg->message != WM_USER+1)
    return(1);

  if (!wf->GetVisible())
    return(0);
#ifndef LKAIRSPACE
  bool do_refocus = false;

  if (actListSizeChange){
    actListSizeChange = false;
#ifdef LKAIRSPACE
    Count = airspaces.size();
#else
    Count = AirspaceWarnGetItemCount();
#endif
    do_refocus = FindFocus();

    wAirspaceList->ResetList();

    if (Count == 0) {
      // auto close
      OnCloseClicked(Sender);
    }
  }

  if (actShow){
    actShow = false;
    if (!do_refocus) {
      do_refocus = FindFocus();
    }

    /*
    if (!wf->GetVisible()){
      Count = AirspaceWarnGetItemCount();
      wAirspaceList->ResetList();
      FocusedIdx = 0;
      FocusedID = -1;
      wf->Show();
      SetFocus(wAirspaceListEntry->GetHandle());
    } else {
      SetFocus(wAirspaceListEntry->GetHandle());
    }
    */
    //    return(0);
  }

  if (actListChange) {
    actListChange = false;
    wAirspaceList->Redraw();
  }

  if (do_refocus) {
    SetFocus(wAirspaceListEntry->GetHandle());    
  }
#endif
  // this is our message, we have handled it.
  return(0);
}
Пример #3
0
static void DoAck(int Ack){
  int Idx;

  Idx = SelectedIdx;				//use selected list entry
  if (Idx < 0) Idx = FocusedIdx;	//if none selected use focused
  if (Idx < 0) Idx = 0;				//if none focused?
  if (Idx>=(int)airspaces.size()) return;
  
  CAirspace *p;
  p = airspaces[Idx];
  
	switch (Ack) {
	  default:
	  case -1:		//-1 Ack warning
		CAirspaceManager::Instance().AirspaceAckWarn(*p);
		break;

	  case 3:		//3 Ack airspace
		CAirspaceManager::Instance().AirspaceAckSpace(*p);
		break;

	  case 4:		//4 Dailyack clicked 
		CAirspaceManager::Instance().AirspaceDisable(*p);
		break;

	  case 0:		//0 Enable clicked 
		CAirspaceManager::Instance().AirspaceEnable(*p);
		break;
	}//sw
    wAirspaceList->Redraw();
}
Пример #4
0
static int OnTimer(WindowControl * Sender){
  (void)Sender;
#ifdef LKAIRSPACE
  airspaces.clear();
  airspaces = CAirspaceManager::Instance().GetAirspacesInWarning();
  Count = airspaces.size();
  wAirspaceList->Redraw();
#endif
  return(0);
}
Пример #5
0
bool dlgAirspaceWarningShowDlg(bool Force){

  if (fDialogOpen)
    return(false);
#ifndef LKAIRSPACE
  if (!actShow && !Force)
    return false;
#endif
#ifdef LKAIRSPACE
	airspaces = CAirspaceManager::Instance().GetAirspacesInWarning();
    Count = airspaces.size();
#else
  Count = AirspaceWarnGetItemCount();
#endif
  if (Count == 0)
    return(false);

  if (wf==NULL) {
	StartupStore(_T("------ BAD SW ERROR AirspaceWarningDlg problem no window!%s"),NEWLINE);
	FailStore(_T("BAD SW ERROR AirspaceWarningDlg problem no window!"));
	return(false);
  }
  if (wAirspaceList==NULL) {
	StartupStore(_T("------ BAD SW ERROR AirspaceList empty!%s"),NEWLINE);
	FailStore(_T("BAD SW ERROR AirspaceList empty!"));
	return(false);
  }

  wAirspaceList->ResetList();

  if (!fDialogOpen) {
    fDialogOpen = true;
    #ifndef DISABLEAUDIO
    if (EnableSoundModes) LKSound(_T("LK_AIRSPACE.WAV")); // 100819
    #endif
    HWND oldFocusHwnd = GetFocus();
    wf->ShowModal();
    if (oldFocusHwnd) {
      SetFocus(oldFocusHwnd);
    }


    // JMW need to deselect everything on new reopening of dialog
#ifndef LKAIRSPACE
    SelectedID = -1;
#endif
    SelectedIdx = -1;
#ifndef LKAIRSPACE
    FocusedID = -1;
#endif
    FocusedIdx = -1;
#ifdef LKAIRSPACE
	airspaces.clear();
#endif
    fDialogOpen = false;

    //    SetFocus(hWndMapWindow);
    // JMW why do this? --- not necessary?
    // concerned it may interfere if a dialog is already open
  }

  return(true);
}
Пример #6
0
static void OnAirspaceListItemPaint(WindowControl * Sender, HDC hDC){
  TCHAR sTmp[128];

  if (Count != 0){

#ifndef LKAIRSPACE
    TCHAR sAckIndicator[6] = TEXT(" -++*");
#endif
	TCHAR sName[21];
    TCHAR sTop[32];
    TCHAR sBase[32];
    TCHAR sType[32];
    AIRSPACE_ALT Base;
    AIRSPACE_ALT Top;
    int i = DrawListIndex;
#ifndef LKAIRSPACE
    AirspaceInfo_c pAS;
#endif
    int          Type;
    int          TextHeight = 12;
    int          TextTop = 1;
    int          Col0Left = 3;
    int          Col1Left = 120;
    RECT         rc;
    RECT         rcTextClip;
    HBRUSH       hBrushBk = NULL;

    if (i>=Count) return;

    CopyRect(&rc, Sender->GetBoundRect());
    CopyRect(&rcTextClip, Sender->GetBoundRect());
    rcTextClip.right = IBLSCALE(Col1Left - 2);

    InflateRect(&rc, IBLSCALE(-2), IBLSCALE(-2));
#ifdef LKAIRSPACE
	if (i>=(int)airspaces.size()) return;
	// Method: get an airspace object copy from CAirspaceManager to use it in this thread indepently
	CAirspace airspace_copy = CAirspaceManager::Instance().GetAirspaceCopy(airspaces[i]);
    if (ItemIndex == DrawListIndex) {
      FocusedIdx = ItemIndex;
    }
#else
    if (!AirspaceWarnGetItem(i, pAS)) return;
    if (ItemIndex == DrawListIndex){
      FocusedID = pAS.ID;
    }
#endif

#ifdef LKAIRSPACE
	_tcsncpy(sName, airspace_copy.Name(), sizeof(sName)/sizeof(sName[0]));
    sName[sizeof(sName)/sizeof(sName[0])-1] = '\0';
	memcpy(&Base, airspace_copy.Base(), sizeof(Base));
	memcpy(&Top, airspace_copy.Top(), sizeof(Top));
	Type = airspace_copy.Type();

	CAirspaceManager::Instance().GetAirspaceAltText(sTop, sizeof(sTop)/sizeof(sTop[0]), &Top); 
	CAirspaceManager::Instance().GetAirspaceAltText(sBase, sizeof(sBase)/sizeof(sBase[0]), &Base); 
	_tcsncpy(sType, CAirspaceManager::Instance().GetAirspaceTypeShortText(Type), 4);
#else
    if (pAS.IsCircle){
      _tcsncpy(sName, AirspaceCircle[pAS.AirspaceIndex].Name, 
	       sizeof(sName)/sizeof(sName[0]));
      Base = AirspaceCircle[pAS.AirspaceIndex].Base;
      Top  = AirspaceCircle[pAS.AirspaceIndex].Top;
      Type = AirspaceCircle[pAS.AirspaceIndex].Type;
    } else {
      _tcsncpy(sName, AirspaceArea[pAS.AirspaceIndex].Name, 
	       sizeof(sName)/sizeof(sName[0]));
      Base = AirspaceArea[pAS.AirspaceIndex].Base;
      Top  = AirspaceArea[pAS.AirspaceIndex].Top;
      Type = AirspaceArea[pAS.AirspaceIndex].Type;
    }

    if (_tcslen(sName)>0) // 100324
    sName[sizeof(sName)/sizeof(sName[0])-1] = '\0';

    fmtAirspaceAlt(sTop, &Top);
    fmtAirspaceAlt(sBase, &Base);
    getAirspaceType(sType, Type);
#endif

#ifdef LKAIRSPACE
	// Select brush based on warning and ack level
	hBrushBk = hBrushNormal;
	  if (airspace_copy.WarningLevel() == awYellow) {
		if (airspace_copy.WarningAckLevel() >= awYellow) {
		  hBrushBk = hBrushNearAckBk;
		} else {
		  hBrushBk = hBrushNearBk;
		}
	  }
	  
	  if (airspace_copy.WarningLevel() == awRed) {
		if (airspace_copy.WarningAckLevel() >= awRed) {
		  hBrushBk = hBrushInsideAckBk;
		} else {
		  hBrushBk = hBrushInsideBk;
		}
	  }
#else
    if (pAS.Inside){
      if (pAS.Acknowledge >= 3)
        hBrushBk = hBrushInsideAckBk;
      else
        hBrushBk = hBrushInsideBk;
    } else { 
      if ((pAS.hDistance < 2500) && (abs(pAS.vDistance) < 250)) {
        if (pAS.Acknowledge >= 1) 
          hBrushBk = hBrushNearAckBk;
        else
          hBrushBk = hBrushNearBk;
	  }
    }
#endif
    
    if (SelectedIdx == DrawListIndex){
      InflateRect(&rc, 1, 1);
      SelectObject(hDC, (HPEN)GetStockObject(BLACK_PEN));
      Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
    } else {
      FillRect(hDC, &rc, hBrushBk);
    }

#ifdef LKAIRSPACE
    if ((airspace_copy.WarningAckLevel() > 0) && (airspace_copy.WarningAckLevel() >= airspace_copy.WarningLevel())) {
      SetTextColor(hDC, clGray);
    }

    #if defined(DEBUG)
    wsprintf(sTmp, TEXT("%-20s%d"), sName , airspace_copy.WarningLevel() - airspace_copy.WarningAckLevel() );
    #else
    if (_tcslen(sName)>0) wsprintf(sTmp, TEXT("%-20s"), sName);  //@ FIX ATTEMPT 101027
	else _tcscpy(sTmp,_T("UNKNOWN")); //@ 101027
    #endif
#else
    if ((pAS.Acknowledge > 0) && (pAS.Acknowledge >= pAS.WarnLevel)){
      SetTextColor(hDC, clGray);
    }

    #if defined(DEBUG)
    wsprintf(sTmp, TEXT("%-20s%d"), sName , pAS.WarnLevel - pAS.Acknowledge);
    #else
    if (_tcslen(sName)>0) wsprintf(sTmp, TEXT("%-20s"), sName);  //@ FIX ATTEMPT 101027
	else _tcscpy(sTmp,_T("UNKNOWN")); //@ 101027
    #endif
#endif
	
    ExtTextOut(hDC, IBLSCALE(Col0Left), IBLSCALE(TextTop),
      ETO_CLIPPED, &rcTextClip, sTmp, _tcslen(sTmp), NULL);

    wsprintf(sTmp, TEXT("%-20s"), sTop);

    ExtTextOut(hDC, IBLSCALE(Col1Left), IBLSCALE(TextTop),
      ETO_OPAQUE, NULL, sTmp, _tcslen(sTmp), NULL);

    wsprintf(sTmp, TEXT("%-20s"), sBase);

    ExtTextOut(hDC, IBLSCALE(Col1Left), IBLSCALE(TextTop+TextHeight),
      ETO_OPAQUE, NULL, sTmp, _tcslen(sTmp), NULL);
#ifdef LKAIRSPACE
	int hdistance;
	int vdistance;
	int bearing;
	bool inside;
	
	// Unfortunatelly virtual methods don't work on copied instances
	// we have to ask airspacemanager to perform the required calculations
	//inside = airspace_copy.CalculateDistance(&hdistance, &bearing, &vdistance);
	//inside = CAirspaceManager::Instance().AirspaceCalculateDistance(airspaces[i], &hdistance, &bearing, &vdistance);
	bool distances_ready = airspace_copy.GetDistanceInfo(inside, hdistance, bearing, vdistance);
	
	switch (airspace_copy.WarningLevel()) {
	  default:
		if (inside) {
		  wsprintf(sTmp, TEXT("> %c %s"), GetAckIndicator(airspace_copy.WarningAckLevel()), sType );
		} else {
		  wsprintf(sTmp, TEXT("< %c %s"), GetAckIndicator(airspace_copy.WarningAckLevel()), sType );
		}
		break;
	  case awRed:
		if (inside) {
		  wsprintf(sTmp, TEXT("> %c %s %s"), GetAckIndicator(airspace_copy.WarningAckLevel()), sType, gettext(TEXT("_@M789_")));	//LKTOKEN _@M789_ "Warn"
		} else {
		  wsprintf(sTmp, TEXT("< %c %s %s"), GetAckIndicator(airspace_copy.WarningAckLevel()), sType, gettext(TEXT("_@M789_")));	//LKTOKEN _@M789_ "Warn"
		}
		break;
		
	  case awYellow:
		TCHAR DistanceText[MAX_PATH];
		if (!airspace_copy.Flyzone()) {
		  //Non fly zone
		  if (distances_ready) {
			if (hdistance <= 0) {
			  // Directly above or below airspace
			  Units::FormatUserAltitude(fabs(vdistance),DistanceText, 7);
			  if (vdistance > 0) {
				wsprintf(sTmp, TEXT("< %c %s ab %s"), 
						GetAckIndicator(airspace_copy.WarningAckLevel()), 
						sType, DistanceText);
			  } else {
				wsprintf(sTmp, TEXT("< %c %s bl %s"), 
						GetAckIndicator(airspace_copy.WarningAckLevel()), 
						sType, DistanceText);
			  }
			} else {
				// Horizontally separated
				Units::FormatUserDistance(fabs(hdistance),DistanceText, 7);
				wsprintf(sTmp, TEXT("< %c %s H %s"), GetAckIndicator(airspace_copy.WarningAckLevel()),
						sType, DistanceText);
			}
		  } else {
			// distance info not available
			wsprintf(sTmp, TEXT("< %c %s ---"), GetAckIndicator(airspace_copy.WarningAckLevel()), sType );
		  }
		} else {
		  //Fly zone
		  if (distances_ready) {
			if ( abs(hdistance) > abs(vdistance)*30) {
			  // vDist smaller than horizontal
			  Units::FormatUserAltitude(fabs(vdistance),DistanceText, 7);
			  if (vdistance > 0) {
				wsprintf(sTmp, TEXT("> %c %s ab %s"), 
						GetAckIndicator(airspace_copy.WarningAckLevel()), 
						sType, DistanceText);
			  } else {
				wsprintf(sTmp, TEXT("> %c %s bl %s"), 
						GetAckIndicator(airspace_copy.WarningAckLevel()), 
						sType, DistanceText);
			  }
			} else {
				// Horizontally separated
				Units::FormatUserDistance(fabs(hdistance),DistanceText, 7);
				wsprintf(sTmp, TEXT("> %c %s H %s"), GetAckIndicator(airspace_copy.WarningAckLevel()),
						sType, DistanceText);
			}
		  } else {
			// distance info not available
			wsprintf(sTmp, TEXT("> %c %s ---"), GetAckIndicator(airspace_copy.WarningAckLevel()), sType );
		  }
		}
		break;
    }//sw
#else
    if (pAS.Inside){
      wsprintf(sTmp, TEXT("> %c %s"), sAckIndicator[pAS.Acknowledge], sType);
    } else {
      TCHAR DistanceText[MAX_PATH];
      if (pAS.hDistance == 0) {

        // Directly above or below airspace

        Units::FormatUserAltitude(fabs((double)pAS.vDistance),DistanceText, 7);
        if (pAS.vDistance > 0) {
          wsprintf(sTmp, TEXT("< %c %s ab %s"), 
                   sAckIndicator[pAS.Acknowledge], 
                   sType, DistanceText);
        }
        if (pAS.vDistance < 0) {
          Units::FormatUserAltitude(fabs((double)pAS.vDistance),DistanceText, 7);
          wsprintf(sTmp, TEXT("< %c %s bl %s"), 
                   sAckIndicator[pAS.Acknowledge], 
                   sType, DistanceText);
        }
      } else {
        if ((pAS.vDistance == 0) || 
            (pAS.hDistance < abs(pAS.vDistance)*30 )) {

          // Close to airspace altitude, horizontally separated

          Units::FormatUserDistance(fabs((double)pAS.hDistance),DistanceText, 7);
          wsprintf(sTmp, TEXT("< %c %s H %s"), sAckIndicator[pAS.Acknowledge],
                   sType, DistanceText);
        } else {

          // Effectively above or below airspace, steep climb or descent 
          // necessary to enter

          Units::FormatUserAltitude(fabs((double)pAS.vDistance),DistanceText, 7);
          if (pAS.vDistance > 0) {
            wsprintf(sTmp, TEXT("< %c %s ab %s"), 
                     sAckIndicator[pAS.Acknowledge], 
                     sType, DistanceText); 
          } else {
            wsprintf(sTmp, TEXT("< %c %s bl %s"), 
                     sAckIndicator[pAS.Acknowledge], sType, 
                     DistanceText);
          }
        }
      }
    }
#endif  
    ExtTextOut(hDC, IBLSCALE(Col0Left), IBLSCALE(TextTop+TextHeight),
      ETO_CLIPPED, &rcTextClip, sTmp, _tcslen(sTmp), NULL);

  } else {
    if (DrawListIndex == 0){
	// LKTOKEN  _@M469_ = "No Warnings" 
      _stprintf(sTmp, TEXT("%s"), gettext(TEXT("_@M469_")));
      ExtTextOut(hDC, NIBLSCALE(2), NIBLSCALE(2),
        ETO_OPAQUE, NULL,
        sTmp, _tcslen(sTmp), NULL);
    }
  }
}