Ejemplo n.º 1
0
void dlgTextEntryKeyboardShowModal(TCHAR *text, int width, unsigned ResID)
{
  wf = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  wf = dlgLoadFromXML(CallBackTable, ResID);
  if (!wf) return;

 // cursor = _tcslen(text);
  ClearText();

  if (_tcslen(text)>0) {
    CharUpper(text);
    LK_tcsncpy(edittext, text, max_width-1);
    // show previous test.
    // this text is replaced by first key down
    // but used if "OK" is clicked first for don't reset current value.
  }
  cursor = _tcslen(edittext);
  UpdateTextboxProp();

  WindowControl* pBtHelp = wf->FindByName(TEXT("cmdHelp"));
  if(pBtHelp) {
     pBtHelp->SetVisible(wKeyboardPopupWndProperty && wKeyboardPopupWndProperty->HasHelpText());
  }

  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  LK_tcsncpy(text, edittext, max_width-1);
 // cursor = _tcslen(text);
  delete wf;
  wf=NULL;
}
Ejemplo n.º 2
0
    void NextPage(int Step) {
        if( ((CurrentPage+Step) >= 0) && ((CurrentPage+Step) < lstPageWnd.size()) ) {
            lstPageWnd[CurrentPage]->Close();
            CurrentPage+=Step;
            lstPageWnd[CurrentPage]->Show();
            
            WindowControl * pWnd = wfDlg->FindByName(_T("cmdNext"));
            if(pWnd) {
                pWnd->SetVisible(CurrentPage<(lstPageWnd.size()-1));
            }
            pWnd = wfDlg->FindByName(_T("cmdPrev"));
            if(pWnd) {
                pWnd->SetVisible(CurrentPage>0);
            }

            TCHAR szTmp[50] = {0};
            _stprintf(szTmp, _T("BlueFlyVario %d/%d"), CurrentPage+1, lstPageWnd.size());
            wfDlg->SetCaption(szTmp);
        }
    }
Ejemplo n.º 3
0
static void SetWaypointValues(bool first=false) {
  WndProperty* wp;

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATType"));
  if (wp) {
    DataField* dfe = wp->GetDataField();
    if (first) {
	// LKTOKEN  _@M210_ = "Cylinder" 
      dfe->addEnumText(MsgToken(210));
	// LKTOKEN  _@M590_ = "Sector" 
      dfe->addEnumText(MsgToken(590));
      if(DoOptimizeRoute()) {
        // Conical ESS
        dfe->addEnumText(MsgToken(2175));
        // Circle ESS
        dfe->addEnumText(MsgToken(2189));
      }
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(Task[twItemIndex].AATType);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  WindowControl* pFrm = wf->FindByName(_T("frmCircle"));
  if(pFrm) {
    pFrm->SetVisible((Task[twItemIndex].AATType==0) || (Task[twItemIndex].AATType==3));
  }
  pFrm = wf->FindByName(_T("frmSector"));
  if(pFrm) {
    pFrm->SetVisible(Task[twItemIndex].AATType==1);
  }
  pFrm = wf->FindByName(_T("frmCone"));
  if(pFrm) {
    pFrm->SetVisible(Task[twItemIndex].AATType==2);
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATCircleRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(Task[twItemIndex].AATCircleRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATSectorRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(Task[twItemIndex].AATSectorRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();    
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATStartRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].AATStartRadial);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATFinishRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].AATFinishRadial);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpOutCircle"));
  if (wp) {
	  DataField* dfe = wp->GetDataField();
	  if (dfe) {
		  if (first) {
			  // LKTOKEN  _@M2226_ = "Enter" 
			  dfe->addEnumText(MsgToken(2145));
			  // LKTOKEN  _@M2227_ = "Exit" 
			  dfe->addEnumText(MsgToken(2146));
		  }
		  dfe->Set(Task[twItemIndex].OutCircle);
	  }
	  wp->SetVisible(DoOptimizeRoute());
	  wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpConeSlope"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].PGConeSlope);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpConeBase"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].PGConeBase*ALTITUDEMODIFY);
    wp->GetDataField()->SetUnits(Units::GetAltitudeName());
    wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpConeRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(Task[twItemIndex].PGConeBaseRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }
  
}
Ejemplo n.º 4
0
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();
  }

}
Ejemplo n.º 5
0
// Will return 0 if cancel or error, 1 if details needed, 2 if goto, 3 if alt1, 4 if alt2
short dlgWayQuickShowModal(void){

  TCHAR sTmp[128];

  wf = dlgLoadFromXML(CallBackTable, 
            ScreenLandscape ? TEXT("dlgWayQuick_L.xml") : TEXT("dlgWayQuick_P.xml"),
            ScreenLandscape ? IDR_XML_WAYPOINTQUICK_L : IDR_XML_WAYPOINTQUICK_P);

  if (!wf) return 0;

  retStatus=0;
  if (WPLSEL.Format == LKW_CUP) {
        TCHAR ttmp[50];
        // and it is landable
        if ((WPLSEL.Style>1) && (WPLSEL.Style<6) ) {

                _stprintf(sTmp, TEXT("%s "), WPLSEL.Name);
		if (_tcslen(sTmp)>9) {
			sTmp[9]='\0';
			_tcscat(sTmp, _T(" "));
		}

                if ( _tcslen(WPLSEL.Freq)>0 )  {
                        _stprintf(ttmp,_T("%s "),WPLSEL.Freq);
                        _tcscat(sTmp, ttmp);
                }

                if ( WPLSEL.RunwayDir>=0 )  {
                        _stprintf(ttmp,_T("RW %d "),WPLSEL.RunwayDir);
                        _tcscat(sTmp, ttmp);
                }
                if ( WPLSEL.RunwayLen>0 )  {
                        // we use Altitude instead of distance, to keep meters and feet
                        _stprintf(ttmp,_T("%.0f%s"),Units::ToUserAltitude((double)WPLSEL.RunwayLen), Units::GetAltitudeName());
                        _tcscat(sTmp, ttmp);
                }

        } else {
		_stprintf(sTmp, _T(" %s"),WayPointList[SelectedWaypoint].Name);
        }
  } else {
	_stprintf(sTmp, _T(" %s"),WayPointList[SelectedWaypoint].Name);
  }
  wf->SetCaption(sTmp);

#ifdef RADIO_ACTIVE
    const bool bRadioFreq = (_tcstol(WayPointList[SelectedWaypoint].Freq, nullptr, 10) > 0) && RadioPara.Enabled;
#else
    const bool bRadioFreq = false;
#endif // RADIO_ACTIVE       
  
  if (ScreenLandscape) {
    PixelScalar left = 0;
    WindowControl* pWnd = wf->FindByName(TEXT("cmdGoto"));
    if(pWnd) {
      left = pWnd->GetLeft();
      pWnd->SetWidth(ScreenSizeX-NIBLSCALE(5)-left);
    }

	pWnd = wf->FindByName(TEXT("cmdSetAlt1"));
    if(pWnd) {
      pWnd->SetWidth((ScreenSizeX/2)-NIBLSCALE(5));
	  pWnd->SetLeft(NIBLSCALE(3));
    }

	pWnd = wf->FindByName(TEXT("cmdSetAlt2"));
    if(pWnd) {
      pWnd->SetWidth((ScreenSizeX/2)-NIBLSCALE(7));
	  pWnd->SetLeft((ScreenSizeX/2)+NIBLSCALE(2));
    }
	pWnd = wf->FindByName(TEXT("cmdDetails"));
    if(pWnd) {
      pWnd->SetWidth((ScreenSizeX/2)-NIBLSCALE(5));
	  pWnd->SetLeft(NIBLSCALE(3));
    }
	pWnd = wf->FindByName(TEXT("cmdTask"));
    if(pWnd) {
      pWnd->SetWidth((ScreenSizeX/2)-NIBLSCALE(7));
	  pWnd->SetLeft((ScreenSizeX/2)+NIBLSCALE(2));
    }

	if(bRadioFreq) {
	  pWnd = wf->FindByName(TEXT("cmdCancel"));
      if(pWnd) {
        pWnd->SetLeft(NIBLSCALE(3));
	    pWnd->SetWidth((ScreenSizeX/2)-NIBLSCALE(5));
      }

	  pWnd = wf->FindByName(TEXT("cmdRadioFreq"));
      if(pWnd) {
        pWnd->SetWidth((ScreenSizeX/2)-NIBLSCALE(7));
	    pWnd->SetLeft((ScreenSizeX/2)+NIBLSCALE(2));
      }
	} else {
      pWnd = wf->FindByName(TEXT("cmdCancel"));
      if(pWnd) {
        pWnd->SetLeft(NIBLSCALE(3));
        pWnd->SetWidth((ScreenSizeX)-NIBLSCALE(8));
      }

	  pWnd = wf->FindByName(TEXT("cmdRadioFreq"));
      if(pWnd) {
        pWnd->SetVisible(false);
	  }
    }
  } else {
	if(bRadioFreq) {
#warning "TODO : don't work on 4/3 Portrait mode"
    } else {
      WindowControl* pWndCancel = wf->FindByName(TEXT("cmdCancel"));
      WindowControl* pWndFreq = wf->FindByName(TEXT("cmdRadioFreq"));
      if(pWndCancel && pWndFreq) {
        pWndCancel->SetTop(pWndFreq->GetTop());
      }
      if(pWndFreq) {
          pWndFreq->SetVisible(false);
      }
    }
  } 

  wf->ShowModal();

  delete wf;

  wf = NULL;

  return retStatus;

}
Ejemplo n.º 6
0
int dlgComboPicker(WndProperty* theProperty){

  static bool bInComboPicker=false;
  bool bInitialPage=true;
  bool bOpenCombo=true; // used to exit loop (optionally reruns combo with 
                        //lower/higher index of items for int/float

  if (bInComboPicker) // prevents multiple instances
    return 0;
  else
    bInComboPicker=true;

  while (bOpenCombo)
  {
    LKASSERT(theProperty!=NULL);
    wComboPopupWndProperty = theProperty;

    wf = dlgLoadFromXML(CallBackTable, 
                          ScreenLandscape ? TEXT("dlgComboPicker_L.xml") : TEXT("dlgComboPicker_P.xml"),
                          ScreenLandscape ? IDR_XML_COMBOPICKER_L : IDR_XML_COMBOPICKER_P);

    if (!wf) return -1;

    wf->SetCaption(theProperty->GetCaption());

    wComboPopupListFrame = (WndListFrame*)wf->FindByName(TEXT("frmComboPopupList"));
    LKASSERT(wComboPopupListFrame!=NULL);
    wComboPopupListFrame->SetBorderKind(BORDERLEFT | BORDERTOP | BORDERRIGHT|BORDERBOTTOM);
    wComboPopupListFrame->SetEnterCallback(OnComboPopupListEnter);

    // allow item to be focused / hightlighted
    wComboPopupListEntry = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmComboPopupListEntry"));
    LKASSERT(wComboPopupListEntry!=NULL);
    wComboPopupListEntry->SetCanFocus(true);

    ComboPopupDataField = wComboPopupWndProperty->GetDataField();
    ComboListPopup = ComboPopupDataField->GetCombo();
    LKASSERT(ComboPopupDataField!=NULL);

    ComboPopupDataField->CreateComboList();
    wComboPopupListFrame->ResetList();
    wComboPopupListFrame->SetItemIndex(ComboListPopup->ComboPopupItemSavedIndex);
    if (bInitialPage) { // save values for "Cancel" from first page only
      bInitialPage=false;
      iSavedInitialDataIndex=ComboListPopup->ComboPopupItemList[ComboListPopup->ComboPopupItemSavedIndex]->DataFieldIndex;
      ComboPopupDataField->CopyString(sSavedInitialValue,false);
    }
   
    WindowControl* pBtHelp = wf->FindByName(TEXT("cmdHelp"));
    if(pBtHelp) {
       pBtHelp->SetVisible(wComboPopupWndProperty->HasHelpText());
    }

    wf->ShowModal();

    bOpenCombo=false;  //tell  combo to exit loop after close

    if (ComboListPopup->ComboPopupItemIndex >=0) // OK/Select
    {
      #if 0
      ComboPopupDataField->GetCombo()->LastModalResult=1; // OK Hit Used then calling via SendMessage()
      #endif

      if (ComboListPopup->ComboPopupItemList[ComboListPopup->ComboPopupItemIndex]->DataFieldIndex
                          ==ComboPopupReopenMOREDataIndex)
      { // we're last in list and the want more past end of list so select last real list item and reopen
        ComboPopupDataField->SetDetachGUI(true);  // we'll reopen, so don't call xcsoar data changed routine yet
        ComboListPopup->ComboPopupItemIndex--;
        bOpenCombo=true; // reopen combo with new selected index at center
      }
      else if (ComboListPopup->ComboPopupItemList[ComboListPopup->ComboPopupItemIndex]->DataFieldIndex
                          ==ComboPopupReopenLESSDataIndex) // same as above but lower items needed
      { 
        ComboPopupDataField->SetDetachGUI(true); 
        ComboListPopup->ComboPopupItemIndex++;
        bOpenCombo=true; 
      }
      int iDataIndex = ComboListPopup->ComboPopupItemList[ComboListPopup->ComboPopupItemIndex]->DataFieldIndex;
      ComboPopupDataField->SetFromCombo(iDataIndex, 
        ComboListPopup->ComboPopupItemList[ComboListPopup->ComboPopupItemIndex]->StringValue);
    }
    else // Cancel
    { // if we've detached the GUI during the load, then there is nothing to do here
      #if 0
      ComboPopupDataField->GetCombo()->LastModalResult=0; // Cancel Hit.  Used then calling via SendMessage()
      #endif
      // NOTE 130206 : we are missing currently the Cancel return status .
      // The list selection does not return the Cancel button status, because so far we have been setting an empty
      // value on entry, and we check on exit if it is still empty. In such case, a no/action is performed, either
      // because the user did not select anything with Select (click on empty field at the top) or because he really
      // clicked on Cancel and we returned again the initial empty value.
      // BUT, in some cases, like on TaskOverview, we set the initial item of the list to Default.task, 
      // and in this case a Cancel will return correctly Default.tsk!
      // This is why we get the confirmation message for loading default task, instead of a quiet return.
      // Solution: either use a WindowControl variable, or a more simple global for ComboCancel.
      // This would be an hack, but quick and dirty solution with no disde effects.
      // Set ComboCancel true if we are here, otherwise false, and check that after 
      // dfe = (DataFieldFileReader*) wp->GetDataField()
      // If ever we want to manage this Cancel button correctly, we should use one of these approaches.

      LKASSERT(iSavedInitialDataIndex >=0);
      if (iSavedInitialDataIndex >=0) {
        ComboPopupDataField->SetFromCombo(iSavedInitialDataIndex, sSavedInitialValue);
      }
    }


    wComboPopupWndProperty->RefreshDisplay();
    ComboListPopup->FreeComboPopupItemList();

    delete wf;

    wf = NULL;

  } // loop reopen combo if <<More>> << LESS>> picked

  bInComboPicker=false;
  return 1;  

}
Ejemplo n.º 7
0
static void RefreshCalculator(void) {
  WndProperty* wp;

  RefreshTask();
  RefreshTaskStatistics();
  target_point = max(target_point,ActiveWayPoint);

  bool nodisplay = !AATEnabled 
    || (target_point==0) 
    || !ValidTaskPoint(target_point+1);

  if (btnMove) {
    if (nodisplay) {
      btnMove->SetVisible(false);
      TargetMoveMode = false;
    } else {
      btnMove->SetVisible(true);
    }
  } 

  nodisplay = nodisplay || TargetMoveMode;

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskPoint"));
  if (wp) {
    if (TargetMoveMode) {
      wp->SetVisible(false);
    } else {
      wp->SetVisible(true);
    }
  }

  WindowControl* wc = (WindowControl*)wf->FindByName(TEXT("btnOK"));
  if (wc) {
    if (TargetMoveMode) {
      wc->SetVisible(false);
    } else {
      wc->SetVisible(true);
    }
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATTargetLocked"));
  if (wp) {
    wp->GetDataField()->Set(Task[target_point].AATTargetLocked);
    wp->RefreshDisplay();
    if (nodisplay) {
      wp->SetVisible(false);
    } else {
      wp->SetVisible(true);
    }
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpRange"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Range*100.0);
    wp->RefreshDisplay();
    if (nodisplay) {
      wp->SetVisible(false);
    } else {
      wp->SetVisible(true);
    }
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Radial);
    wp->RefreshDisplay();
    if (nodisplay) {
      wp->SetVisible(false);
    } else {
      wp->SetVisible(true);
    }
  }

  // update outputs
  double dd = CALCULATED_INFO.TaskTimeToGo;
  if ((CALCULATED_INFO.TaskStartTime>0.0)&&(CALCULATED_INFO.Flying)) {
    dd += GPS_INFO.Time-CALCULATED_INFO.TaskStartTime;
  }
  dd= min(24.0*60.0,dd/60.0);
  wp = (WndProperty*)wf->FindByName(TEXT("prpAATEst"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(dd);
    wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpAATDelta"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(dd-AATTaskLength);
    if (AATEnabled) {
      wp->SetVisible(true);
    } else {
      wp->SetVisible(false);
    }
    wp->RefreshDisplay();
  }

  double v1;
  if (CALCULATED_INFO.TaskTimeToGo>0) {
    v1 = CALCULATED_INFO.TaskDistanceToGo/
      CALCULATED_INFO.TaskTimeToGo;
  } else {
    v1 = 0;
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpSpeedRemaining"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(v1*TASKSPEEDMODIFY);
    wp->GetDataField()->SetUnits(Units::GetTaskSpeedName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpSpeedAchieved"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(CALCULATED_INFO.TaskSpeed*TASKSPEEDMODIFY);
    wp->GetDataField()->SetUnits(Units::GetTaskSpeedName());
    wp->RefreshDisplay();
  }

}