Пример #1
0
bool
DeviceEditWidget::Save(bool &_changed, bool &require_restart)
{
  bool changed = false;

  changed |= FinishPortField(config, (const DataFieldEnum &)GetDataField(Port));

  if (config.UsesSpeed()) {
    changed |= SaveValue(BaudRate, config.baud_rate);
    changed |= SaveValue(BulkBaudRate, config.bulk_baud_rate);
  }

  if (config.UsesTCPPort())
    changed |= SaveValue(TCPPort, config.tcp_port);


  if (config.UsesDriver()) {
    changed |= SaveValue(Driver, config.driver_name.buffer(),
                         config.driver_name.MAX_SIZE);

    if (CanReceiveSettings(GetDataField(Driver)))
      changed |= SaveValue(SyncFromDevice, config.sync_from_device);

    if (CanSendSettings(GetDataField(Driver)))
      changed |= SaveValue(SyncToDevice, config.sync_to_device);

    changed |= SaveValue(IgnoreCheckSum, config.ignore_checksum);
  }

  _changed |= changed;
  return true;
}
Пример #2
0
void
PageLayoutEditWidget::OnModified(DataField &df)
{
  if (&df == &GetDataField(MAIN)) {
    const DataFieldEnum &dfe = (const DataFieldEnum &)df;
    value.main = (PageLayout::Main)dfe.GetValue();
  } else if (&df == &GetDataField(INFO_BOX_PANEL)) {
    const DataFieldEnum &dfe = (const DataFieldEnum &)df;
    const unsigned ibp = dfe.GetValue();
    if (ibp == IBP_AUTO) {
      value.infobox_config.enabled = true;
      value.infobox_config.auto_switch = true;
      value.infobox_config.panel = 0;
    } else if (ibp == IBP_NONE)
      value.infobox_config.enabled = false;
    else if (ibp < InfoBoxSettings::MAX_PANELS) {
      value.infobox_config.enabled = true;
      value.infobox_config.auto_switch = false;
      value.infobox_config.panel = ibp;
    }
  } else if (&df == &GetDataField(BOTTOM)) {
    const DataFieldEnum &dfe = (const DataFieldEnum &)df;
    value.bottom = (PageLayout::Bottom)dfe.GetValue();
  } else {
    gcc_unreachable();
  }

  listener.OnModified(value);
}
Пример #3
0
void
DeviceEditWidget::UpdateVisibilities()
{
  const DeviceConfig::PortType type = GetPortType(GetDataField(Port));
  const bool maybe_bluetooth =
    DeviceConfig::MaybeBluetooth(type, GetDataField(Port).GetAsString());
  const bool k6bt = maybe_bluetooth && GetValueBoolean(K6Bt);
  const bool uses_speed = DeviceConfig::UsesSpeed(type) || k6bt;

  SetRowAvailable(BaudRate, uses_speed);
  SetRowAvailable(BulkBaudRate, uses_speed &&
                  DeviceConfig::UsesDriver(type));
  SetRowVisible(BulkBaudRate, uses_speed &&
                DeviceConfig::UsesDriver(type) &&
                SupportsBulkBaudRate(GetDataField(Driver)));
  SetRowAvailable(IP_ADDRESS, DeviceConfig::UsesIPAddress(type));
  SetRowAvailable(TCPPort, DeviceConfig::UsesTCPPort(type));
  SetRowAvailable(I2CBus, DeviceConfig::UsesI2C(type));
  SetRowAvailable(I2CAddr, DeviceConfig::UsesI2C(type) &&
                type != DeviceConfig::PortType::NUNCHUCK);
  SetRowAvailable(PressureUsage, DeviceConfig::IsPressureSensor(type));
  SetRowVisible(Driver, DeviceConfig::UsesDriver(type));
  SetRowVisible(SyncFromDevice, DeviceConfig::UsesDriver(type) &&
                CanReceiveSettings(GetDataField(Driver)));
  SetRowVisible(SyncToDevice, DeviceConfig::UsesDriver(type) &&
                CanSendSettings(GetDataField(Driver)));
  SetRowAvailable(K6Bt, maybe_bluetooth);
}
Пример #4
0
void
DeviceEditWidget::UpdateVisibilities()
{
  const DeviceConfig::PortType type = GetPortType(GetDataField(Port));

  GetControl(BaudRate).set_visible(DeviceConfig::UsesSpeed(type));
  GetControl(BulkBaudRate).set_visible(DeviceConfig::UsesSpeed(type) &&
                                       DeviceConfig::UsesDriver(type) &&
                                       SupportsBulkBaudRate(GetDataField(Driver)));
  GetControl(TCPPort).set_visible(DeviceConfig::UsesTCPPort(type));
  GetControl(Driver).set_visible(DeviceConfig::UsesDriver(type));
}
Пример #5
0
bool
DeviceEditWidget::Save(bool &_changed)
{
  bool changed = false;

  changed |= FinishPortField(config, (const DataFieldEnum &)GetDataField(Port));

  if (config.MaybeBluetooth())
    changed |= SaveValue(K6Bt, config.k6bt);

  if (config.UsesSpeed()) {
    changed |= SaveValue(BaudRate, config.baud_rate);
    changed |= SaveValue(BulkBaudRate, config.bulk_baud_rate);
  }

  if (config.UsesIPAddress())
    changed |= SaveValue(IP_ADDRESS, config.ip_address);

  if (config.UsesTCPPort())
    changed |= SaveValue(TCPPort, config.tcp_port);

  if (config.UsesI2C()) {
    changed |= SaveValue(I2CBus, config.i2c_bus);
    changed |= SaveValue(I2CAddr, config.i2c_addr);
    changed |= SaveValueEnum(PressureUsage, config.press_use);
  }

  if (config.UsesDriver()) {
    changed |= SaveValue(Driver, config.driver_name);

    if (CanReceiveSettings(GetDataField(Driver)))
      changed |= SaveValue(SyncFromDevice, config.sync_from_device);

    if (CanSendSettings(GetDataField(Driver)))
      changed |= SaveValue(SyncToDevice, config.sync_to_device);

    if (CanPassThrough(GetDataField(Driver))) {
      changed |= SaveValue(UseSecondDriver, config.use_second_device);
      changed |= SaveValue(SecondDriver, config.driver2_name.buffer(),
                           config.driver2_name.CAPACITY);
    }
  }

  if (CommonInterface::Basic().sensor_calibration_available)
    changed = true;

  _changed |= changed;
  return true;
}
Пример #6
0
void
TaskCalculatorPanel::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  assert(protected_task_manager != nullptr);

  instance = this;

  Add(new TextWidget());
  SetRowVisible(WARNING, false);

  AddReadOnly(_("Assigned task time"));
  AddReadOnly(_("Estimated task time"));
  AddReadOnly(_("Task distance"), nullptr, _T("%.0f %s"),
              UnitGroup::DISTANCE, fixed(0));

  AddFloat(_("Set MacCready"),
           _("Adjusts MC value used in the calculator.  "
             "Use this to determine the effect on estimated task time due to changes in conditions.  "
             "This value will not affect the main computer's setting if the dialog is exited with the Cancel button."),
           _T("%.1f %s"), _T("%.1f"),
           fixed(0), Units::ToUserVSpeed(fixed(5)),
           GetUserVerticalSpeedStep(), false, fixed(0),
           this);
  DataFieldFloat &mc_df = (DataFieldFloat &)GetDataField(MC);
  mc_df.SetFormat(GetUserVerticalSpeedFormat(false, false));

  AddReadOnly(_("AAT range"),
              /* xgettext:no-c-format */
              _("For AAT tasks, this value tells you how far based on the targets of your task you will fly relative to the minimum and maximum possible tasks. -100% indicates the minimum AAT distance.  0% is the nominal AAT distance.  +100% is maximum AAT distance."),
              _T("%.0f %%"), fixed(0));

  AddReadOnly(_("Speed remaining"), nullptr, _T("%.0f %s"),
              UnitGroup::TASK_SPEED, fixed(0));

  AddReadOnly(_("Achieved MacCready"), nullptr, _T("%.1f %s"),
              UnitGroup::VERTICAL_SPEED, fixed(0));
  DataFieldFloat &emc_df = (DataFieldFloat &)GetDataField(EFFECTIVE_MC);
  emc_df.SetFormat(GetUserVerticalSpeedFormat(false, false));

  AddReadOnly(_("Achieved speed"), nullptr, _T("%.0f %s"),
              UnitGroup::TASK_SPEED, fixed(0));

  AddFloat(_("Cruise efficiency"),
           _("Efficiency of cruise.  100 indicates perfect MacCready performance, greater than 100 indicates better than MacCready performance is achieved through flying in streets.  Less than 100 is appropriate if you fly considerably off-track.  This value estimates your cruise efficiency according to the current flight history with the set MC value.  Calculation begins after task is started."),
           _T("%.0f %%"), _T("%.0f"),
           fixed(0), fixed(100), fixed(1), false, fixed(0),
           this);
}
Пример #7
0
bool
DeviceEditWidget::Save(bool &_changed, bool &require_restart)
{
  bool changed = false;

  changed |= FinishPortField(config, (const DataFieldEnum &)GetDataField(Port));

  if (config.MaybeBluetooth())
    changed |= SaveValue(K6Bt, config.k6bt);

  if (config.UsesSpeed() || (config.MaybeBluetooth() && config.k6bt)) {
    changed |= SaveValue(BaudRate, config.baud_rate);
    changed |= SaveValue(BulkBaudRate, config.bulk_baud_rate);
  }

  if (config.UsesTCPPort())
    changed |= SaveValue(TCPPort, config.tcp_port);

  if (config.UsesI2C()) {
    changed |= SaveValue(I2CBus, config.i2c_bus);
    changed |= SaveValue(I2CAddr, config.i2c_addr);
    changed |= SaveValueEnum(PressureUsage, config.press_use);
  }

  if (config.UsesDriver()) {
    changed |= SaveValue(Driver, config.driver_name.buffer(),
                         config.driver_name.MAX_SIZE);

    if (CanReceiveSettings(GetDataField(Driver)))
      changed |= SaveValue(SyncFromDevice, config.sync_from_device);

    if (CanSendSettings(GetDataField(Driver)))
      changed |= SaveValue(SyncToDevice, config.sync_to_device);

    changed |= SaveValue(IgnoreCheckSum, config.ignore_checksum);
  }

  if (CommonInterface::Basic().sensor_calibration_available)
    changed = true;

#ifndef NDEBUG
  if (config.UsesPort())
    changed |= SaveValue(DumpPort, config.dump_port);
#endif

  _changed |= changed;
  return true;
}
Пример #8
0
void
InfoBoxesConfigWidget::RefreshEditContentDescription()
{
  DataFieldEnum &df = (DataFieldEnum &)GetDataField(CONTENT);
  WndFrame &description = (WndFrame &)GetRow(DESCRIPTION);
  description.SetText(df.GetHelp() != nullptr ? df.GetHelp() : _T(""));
}
Пример #9
0
bool
WaypointEditWidget::Save(bool &_changed)
{
  bool changed = false;
  value.name = GetValueString(NAME);
  value.comment = GetValueString(COMMENT);
  value.location = ((GeoPointDataField &)GetDataField(LOCATION)).GetValue();
  changed |= SaveValue(ELEVATION, UnitGroup::ALTITUDE, value.elevation);
  _changed |= changed;

  switch (GetValueInteger(TYPE)) {
  case 1:
    value.flags.turn_point = true;
    value.type = Waypoint::Type::AIRFIELD;
    break;

  case 2:
    value.type = Waypoint::Type::OUTLANDING;
    break;

  default:
    value.type = Waypoint::Type::NORMAL;
    value.flags.turn_point = true;
    break;
  };

  return true;
}
Пример #10
0
RoughTime
RowFormWidget::GetValueRoughTime(unsigned i) const
{
  const RoughTimeDataField &df =
    (const RoughTimeDataField &)GetDataField(i);
  assert(df.GetType() == DataField::Type::ROUGH_TIME);
  return df.GetValue();
}
Пример #11
0
unsigned
RowFormWidget::GetValueIntegerAngle(unsigned i) const
{
  const AngleDataField &df =
    (const AngleDataField &)GetDataField(i);
  assert(df.GetType() == DataField::Type::ANGLE);
  return df.GetIntegerValue();
}
Пример #12
0
bool
RowFormWidget::GetValueBoolean(unsigned i) const
{
  const DataFieldBoolean &df =
    (const DataFieldBoolean &)GetDataField(i);
  assert(df.GetType() == DataField::Type::BOOLEAN);
  return df.GetAsBoolean();
}
Пример #13
0
fixed
RowFormWidget::GetValueFloat(unsigned i) const
{
  const DataFieldFloat &df =
    (const DataFieldFloat &)GetDataField(i);
  assert(df.GetType() == DataField::Type::REAL);
  return df.GetAsFixed();
}
Пример #14
0
bool
InfoBoxesConfigWidget::KeyPress(unsigned key_code)
{
  /* map the Altair hardware buttons */
  switch (key_code){
  case KEY_UP:
    ((DataFieldEnum &)GetDataField(INFOBOX)).Dec();
    GetControl(INFOBOX).RefreshDisplay();
    return true;

  case KEY_DOWN:
    ((DataFieldEnum &)GetDataField(INFOBOX)).Inc();
    GetControl(INFOBOX).RefreshDisplay();
    return true;

  case KEY_LEFT:
    ((DataFieldEnum &)GetDataField(CONTENT)).Dec();
    GetControl(CONTENT).RefreshDisplay();
    return true;

  case KEY_RIGHT:
    ((DataFieldEnum &)GetDataField(CONTENT)).Inc();
    GetControl(CONTENT).RefreshDisplay();
    return true;

  case KEY_APP1:
    GetControl(NAME).BeginEditing();
    return true;

  case '6':
    dialog.OnAction(mrOK);
    return true;

  case '7':
    OnCopy();
    return true;

  case '8':
    OnPaste();
    return true;

  default:
    return false;
  }
}
Пример #15
0
inline void
ReplayControlWidget::OnStartClicked()
{
  const auto &df = (const FileDataField &)GetDataField(FILE);
  const Path path = df.GetPathFile();
  Error error;
  if (!replay->Start(path, error))
    ShowError(error, _("Replay"));
}
Пример #16
0
void
WindSettingsPanel::OnModified(DataField &df)
{
  if (!edit_manual_wind)
    return;

  const NMEAInfo &basic = CommonInterface::Basic();
  WindSettings &settings = CommonInterface::SetComputerSettings().wind;

  if (&df == &GetDataField(Speed) || &df == &GetDataField(Direction)) {
    settings.manual_wind.norm = Units::ToSysWindSpeed(GetValueFloat(Speed));
    settings.manual_wind.bearing = GetValueAngle(Direction);
    settings.manual_wind_available.Update(basic.clock);
    manual_modified = true;
  }

  UpdateVector();
}
Пример #17
0
void
DeviceEditWidget::UpdateVisibilities()
{
  const DeviceConfig::PortType type = GetPortType(GetDataField(Port));

  SetRowAvailable(BaudRate, DeviceConfig::UsesSpeed(type));
  SetRowAvailable(BulkBaudRate, DeviceConfig::UsesSpeed(type) &&
                  DeviceConfig::UsesDriver(type));
  SetRowVisible(BulkBaudRate, DeviceConfig::UsesSpeed(type) &&
                DeviceConfig::UsesDriver(type) &&
                SupportsBulkBaudRate(GetDataField(Driver)));
  SetRowAvailable(TCPPort, DeviceConfig::UsesTCPPort(type));
  SetRowVisible(Driver, DeviceConfig::UsesDriver(type));
  SetRowVisible(SyncFromDevice, DeviceConfig::UsesDriver(type) &&
                CanReceiveSettings(GetDataField(Driver)));
  SetRowVisible(SyncToDevice, DeviceConfig::UsesDriver(type) &&
                CanSendSettings(GetDataField(Driver)));
  SetRowVisible(IgnoreCheckSum, DeviceConfig::UsesDriver(type));
}
Пример #18
0
bool
StartupWidget::Save(bool &changed)
{
  const DataFieldFileReader &dff =
    (const DataFieldFileReader &)GetDataField(PROFILE);
  SelectProfile(dff.GetPathFile());
  changed = true;

  return true;
}
Пример #19
0
bool
StartupWidget::Save(bool &changed)
{
  const auto &dff = (const FileDataField &)GetDataField(PROFILE);
  if (!SelectProfile(dff.GetPathFile()))
    return false;

  changed = true;

  return true;
}
Пример #20
0
inline void
FontEditWidget::SaveValues()
{
#ifdef USE_GDI
  CopyString(data.lfFaceName, GetDataField(FACE).GetAsString(), LF_FACESIZE);
#endif

  data.lfHeight = GetValueInteger(HEIGHT);
  data.lfWeight = GetValueBoolean(WEIGHT) ? 700 : 500;
  data.lfItalic = GetValueBoolean(ITALIC);
}
bool
AirspaceClassRendererSettingsPanel::Save(bool &changed)
{
  if (border_color_changed) {
    Profile::SetAirspaceBorderColor(type, settings.border_color);
    changed = true;
  }

  if (fill_color_changed) {
    Profile::SetAirspaceFillColor(type, settings.fill_color);
    changed = true;
  }

#ifdef HAVE_HATCHED_BRUSH
  if (fill_brush_changed) {
    Profile::SetAirspaceBrush(type, settings.brush);
    changed = true;
  }
#endif

  const auto &border_width_df = GetDataField(BorderWidth);
  unsigned border_width = border_width_df.GetAsInteger();
  if (border_width != settings.border_width) {
    settings.border_width = border_width;
    Profile::SetAirspaceBorderWidth(type, border_width);
    changed = true;
  }

  const auto &fill_mode_df = GetDataField(FillMode);
  auto fill_mode = (AirspaceClassRendererSettings::FillMode)fill_mode_df.GetAsInteger();
  if (fill_mode != settings.fill_mode) {
    settings.fill_mode = fill_mode;
    Profile::SetAirspaceFillMode(type, (unsigned)fill_mode);
    changed = true;
  }

  if (changed)
    CommonInterface::SetMapSettings().airspace.classes[type] = settings;

  return true;
}
Пример #22
0
bool
RowFormWidget::SaveValue(unsigned i, TCHAR *string, size_t max_size) const
{
  const TCHAR *new_value = GetDataField(i).GetAsString();
  assert(new_value != NULL);

  if (_tcscmp(string, new_value) == 0)
    return false;

  CopyString(string, new_value, max_size);
  return true;
}
Пример #23
0
bool
RowFormWidget::SaveValue(unsigned i, TCHAR *string, size_t max_size) const
{
  const TCHAR *new_value = GetDataField(i).GetAsString();
  assert(new_value != nullptr);

  if (StringIsEqual(string, new_value))
    return false;

  CopyTruncateString(string, max_size, new_value);
  return true;
}
Пример #24
0
void
RASPSettingsPanel::UpdateTimeControl()
{
  const DataFieldEnum &item = (const DataFieldEnum &)GetDataField(ITEM);

  const int item_index = item.GetValue();
  SetRowEnabled(TIME, item_index >= 0);

  if (item_index >= 0) {
    DataFieldEnum &time_df = (DataFieldEnum &)GetDataField(TIME);
    time_df.ClearChoices();
    time_df.addEnumText(_("Now"));

    rasp->ForEachTime(item_index, [&time_df](BrokenTime t){
        TCHAR timetext[10];
        _stprintf(timetext, _T("%02u:%02u"), t.hour, t.minute);
        time_df.addEnumText(timetext, t.GetMinuteOfDay());
      });

    if (time.IsPlausible())
      time_df.Set(time.GetMinuteOfDay());
    GetControl(TIME).RefreshDisplay();
  }
}
Пример #25
0
bool
RowFormWidget::SaveValue(unsigned i, UnitGroup unit_group, fixed &value) const
{
  const DataFieldFloat &df =
    (const DataFieldFloat &)GetDataField(i);
  assert(df.GetType() == DataField::Type::REAL);

  fixed new_value = df.GetAsFixed();
  const Unit unit = Units::GetUserUnitByGroup(unit_group);
  new_value = Units::ToSysUnit(new_value, unit);
  if (new_value > value - df.GetStep() / 2 &&
      new_value < value + df.GetStep() / 2)
    return false;

  value = new_value;
  return true;
}
Пример #26
0
void
FontEditWidget::Load()
{
#ifdef USE_GDI
  {
    DataFieldEnum &df = (DataFieldEnum &)GetDataField(FACE);
    df.SetStringAutoAdd(data.lfFaceName);
    GetControl(FACE).RefreshDisplay();
  }
#endif

  LoadValue(HEIGHT, (int)data.lfHeight);
  LoadValue(WEIGHT, data.lfWeight > 500);
  LoadValue(ITALIC, !!data.lfItalic);

  UpdatePreview();
}
Пример #27
0
bool
RowFormWidget::SaveValue(unsigned i, UnitGroup unit_group,
                         const char *registry_key, fixed &value) const
{
  const DataFieldFloat &df =
    (const DataFieldFloat &)GetDataField(i);
  assert(df.GetType() == DataField::Type::REAL);

  const Unit unit = Units::GetUserUnitByGroup(unit_group);
  fixed new_value = df.GetAsFixed();
  fixed old_value = Units::ToUserUnit(value, unit);

  if (fabs(new_value - old_value) < df.GetStep() / 100)
    return false;

  value = Units::ToSysUnit(new_value, unit);
  Profile::Set(registry_key, value);
  return true;
}
Пример #28
0
bool
RowFormWidget::SaveValue(unsigned i, UnitGroup unit_group,
                         const TCHAR *registry_key, unsigned int &value) const
{
  const DataFieldFloat &df =
    (const DataFieldFloat &)GetDataField(i);
  assert(df.GetType() == DataField::Type::INTEGER ||
         df.GetType() == DataField::Type::REAL);

  fixed new_value = df.GetAsFixed();
  const Unit unit = Units::GetUserUnitByGroup(unit_group);
  new_value = Units::ToSysUnit(new_value, unit);
  if ((unsigned int)(new_value) > value - iround(df.GetStep()) / 2 &&
      (unsigned int)(new_value) < value + iround(df.GetStep()) / 2)
    return false;

  value = iround(new_value);
  Profile::Set(registry_key, value);
  return true;
}
Пример #29
0
void
VegaParametersWidget::UpdateUI()
{
  for (unsigned i = 0, end = parameters.size(); i != end; ++i) {
    Parameter &parameter = parameters[i];
    if (loaded) {
      const int ui_value = GetValueInteger(i);
      if (ui_value != parameter.value)
        /* don't update parameters that were changed by the user */
        continue;
    }

    auto x = device.GetSetting(parameter.name);
    if (x.first) {
      parameter.value = x.second;
      GetDataField(i).SetAsInteger(x.second);
      GetControl(i).RefreshDisplay();
    }
  }

  loaded = true;
}
Пример #30
0
void
RASPSettingsPanel::FillItemControl()
{
  auto &df = (DataFieldEnum &)GetDataField(ITEM);

  df.ClearChoices();
  df.AddChoice(-1, _T("none"), _T("none"), nullptr);
  for (unsigned i = 0; i < rasp->GetItemCount(); i++) {
    const auto &mi = rasp->GetItemInfo(i);
    const TCHAR *label = mi.label;
    if (label != nullptr)
      label = gettext(label);

    const TCHAR *help = mi.help;
    if (help != nullptr)
      help = gettext(help);

    df.AddChoice(i, mi.name, label, help);
  }

  const WeatherUIState &state = CommonInterface::GetUIState().weather;
  df.Set(state.map);
}