Esempio n. 1
0
bool
SaveFormProperty(const SubForm &form, const TCHAR *field, unsigned int &value)
{
  unsigned new_value = (unsigned)GetFormValueInteger(form, field);
  if (new_value == value)
    return false;

  value = new_value;
  return true;
}
Esempio n. 2
0
bool
SaveFormProperty(const WndForm &form, const TCHAR *field, uint16_t &value)
{
  uint16_t new_value = (uint16_t)GetFormValueInteger(form, field);
  if (new_value == value)
    return false;

  value = new_value;
  return true;
}
Esempio n. 3
0
static void
GetLogFont(LOGFONT &logfont)
{
  WndProperty* wp;
  wp = (WndProperty*)wf->FindByName(_T("prpFontName"));
  if (wp)
    _tcsncpy(logfont.lfFaceName,
             wp->GetDataField()->GetAsString(), LF_FACESIZE - 1);

  logfont.lfHeight = GetFormValueInteger(*wf, _T("prpFontHeight"));
  logfont.lfWeight = GetFormValueBoolean(*wf, _T("prpFontWeight")) ? 700 : 500;
  logfont.lfItalic = GetFormValueBoolean(*wf, _T("prpFontItalic"));
}
Esempio n. 4
0
bool
SaveFormProperty(const WndForm &form, const TCHAR *control_name,
                 UnitGroup_t unit_group, int &value,
                 const TCHAR *registry_name)
{
  assert(control_name != NULL);
  assert(registry_name != NULL);

  Units_t unit = Units::GetUserUnitByGroup(unit_group);
  int new_value = GetFormValueInteger(form, control_name);
  new_value = iround(Units::ToSysUnit(fixed(new_value), unit));
  if (new_value == value)
    return false;

  value = new_value;
  Profile::Set(registry_name, new_value);
  return true;
}
Esempio n. 5
0
static void
GetValues()
{
  WndProperty* wp;
  bool sign = false;
  int dd = 0;
  // mm,ss are numerators (division) so don't want to lose decimals
  double num = 0, mm = 0, ss = 0;

  sign = GetFormValueInteger(*wf, _T("prpLongitudeSign")) == 1;
  dd = GetFormValueInteger(*wf, _T("prpLongitudeD"));

  switch (CommonInterface::GetUISettings().coordinate_format) {
  case CoordinateFormat::DDMMSS: // ("DDMMSS");
  case CoordinateFormat::DDMMSS_SS: // ("DDMMSS.ss");
    mm = GetFormValueInteger(*wf, _T("prpLongitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLongitudeS"));
    num = dd + mm / 60.0 + ss / 3600.0;
    break;
  case CoordinateFormat::DDMM_MMM: // ("DDMM.mmm");
    mm = GetFormValueInteger(*wf, _T("prpLongitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLongitudemmm"));
    num = dd + (mm + ss / 1000.0) / 60.0;
    break;
  case CoordinateFormat::DD_DDDD: // ("DD.dddd");
    mm = GetFormValueInteger(*wf, _T("prpLongitudeDDDD"));
    num = dd + mm / 10000;
    break;
  case CoordinateFormat::UTM:
    break;
  }

  if (!sign)
    num = -num;

  global_wpt->location.longitude = Angle::Degrees(fixed(num));

  sign = GetFormValueInteger(*wf, _T("prpLatitudeSign")) == 1;
  dd = GetFormValueInteger(*wf, _T("prpLatitudeD"));

  switch (CommonInterface::GetUISettings().coordinate_format) {
  case CoordinateFormat::DDMMSS: // ("DDMMSS");
  case CoordinateFormat::DDMMSS_SS: // ("DDMMSS.ss");
    mm = GetFormValueInteger(*wf, _T("prpLatitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLatitudeS"));
    num = dd + mm / 60.0 + ss / 3600.0;
    break;
  case CoordinateFormat::DDMM_MMM: // ("DDMM.mmm");
    mm = GetFormValueInteger(*wf, _T("prpLatitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLatitudemmm"));
    num = dd + (mm + ss / 1000.0) / 60.0;
    break;
  case CoordinateFormat::DD_DDDD: // ("DD.dddd");
    mm = GetFormValueInteger(*wf, _T("prpLatitudeDDDD"));
    num = dd + mm / 10000;
    break;
  case CoordinateFormat::UTM:
    break;
  }

  if (!sign)
    num = -num;

  global_wpt->location.latitude = Angle::Degrees(fixed(num));

  ss = GetFormValueInteger(*wf, _T("prpAltitude"));
  global_wpt->elevation = (ss == 0 && terrain != NULL)
    ? fixed(terrain->GetTerrainHeight(global_wpt->location))
    : Units::ToSysAltitude(fixed(ss));

  wp = (WndProperty*)wf->FindByName(_T("prpFlags"));
  assert(wp != NULL);
  switch(wp->GetDataField()->GetAsInteger()) {
  case 1:
    global_wpt->flags.turn_point = true;
    global_wpt->type = Waypoint::Type::AIRFIELD;
    break;
  case 2:
    global_wpt->type = Waypoint::Type::OUTLANDING;
    break;
  default:
    global_wpt->type = Waypoint::Type::NORMAL;
    global_wpt->flags.turn_point = true;
  };
}
Esempio n. 6
0
static void GetValues(void) {
  WndProperty* wp;
  bool sign = false;
  int dd = 0;
  double num=0, mm = 0, ss = 0; // mm,ss are numerators (division) so don't want to lose decimals

  sign = GetFormValueInteger(*wf, _T("prpLongitudeSign")) == 1;
  dd = GetFormValueInteger(*wf, _T("prpLongitudeD"));

  switch (Units::GetCoordinateFormat()) {
  case 0: // ("DDMMSS");
  case 1: // ("DDMMSS.ss");
    mm = GetFormValueInteger(*wf, _T("prpLongitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLongitudeS"));
    num = dd+mm/60.0+ss/3600.0;
    break;
  case 2: // ("DDMM.mmm");
    mm = GetFormValueInteger(*wf, _T("prpLongitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLongitudemmm"));
    num = dd+(mm+ss/1000.0)/60.0;
    break;
  case 3: // ("DD.dddd");
    mm = GetFormValueInteger(*wf, _T("prpLongitudeDDDD"));
    num = dd+mm/10000;
    break;
  }
  if (!sign) {
    num = -num;
  }

  global_wpt->Location.Longitude = Angle::degrees(fixed(num));

  sign = GetFormValueInteger(*wf, _T("prpLatitudeSign")) == 1;
  dd = GetFormValueInteger(*wf, _T("prpLatitudeD"));

  switch (Units::GetCoordinateFormat()) {
  case 0: // ("DDMMSS");
  case 1: // ("DDMMSS.ss");
    mm = GetFormValueInteger(*wf, _T("prpLatitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLatitudeS"));
    num = dd+mm/60.0+ss/3600.0;
    break;
  case 2: // ("DDMM.mmm");
    mm = GetFormValueInteger(*wf, _T("prpLatitudeM"));
    ss = GetFormValueInteger(*wf, _T("prpLatitudemmm"));
    num = dd+(mm+ss/1000.0)/60.0;
    break;
  case 3: // ("DD.dddd");
    mm = GetFormValueInteger(*wf, _T("prpLatitudeDDDD"));
    num = dd+mm/10000;
    break;
  }
  if (!sign) {
    num = -num;
  }

  global_wpt->Location.Latitude = Angle::degrees(fixed(num));

  ss = GetFormValueInteger(*wf, _T("prpAltitude"));
  global_wpt->Altitude = ss == 0 && terrain != NULL
    ? fixed(WayPointFile::AltitudeFromTerrain(global_wpt->Location, *terrain))
    : Units::ToSysUnit(fixed(ss), Units::AltitudeUnit);

  wp = (WndProperty*)wf->FindByName(_T("prpFlags"));
  if (wp) {
    int myflag = wp->GetDataField()->GetAsInteger();
    switch(myflag) {
    case 1:
      global_wpt->Flags.TurnPoint = true;
      global_wpt->Flags.Airport = true;
      break;
    case 2:
      global_wpt->Flags.LandPoint = true;
      break;
    default:
      global_wpt->Flags.TurnPoint = true;
      global_wpt->Flags.Airport = false;
      global_wpt->Flags.LandPoint = false;
    };
  }
}