Пример #1
0
void
InfoBoxManager::ShowInfoBoxPicker(const int id)
{
  int i;

  if (id < 0) i = GetFocused();
  else i = id;

  if (i < 0)
    return;

  InfoBoxSettings &settings = CommonInterface::SetUISettings().info_boxes;
  const unsigned panel_index = GetCurrentPanel();
  InfoBoxSettings::Panel &panel = settings.panels[panel_index];

  const InfoBoxFactory::t_InfoBox old_type = panel.contents[i];

  ComboList list;
  for (unsigned j = InfoBoxFactory::MIN_TYPE_VAL; j < InfoBoxFactory::NUM_TYPES; j++) {
    const TCHAR * desc = InfoBoxFactory::GetDescription((t_InfoBox) j);
    list.Append(j, gettext(InfoBoxFactory::GetName((t_InfoBox) j)),
                gettext(InfoBoxFactory::GetName((t_InfoBox) j)),
                desc != NULL ? gettext(desc) : NULL);
  }

  list.Sort();
  list.ComboPopupItemSavedIndex = list.LookUp(old_type);

  /* let the user select */

  StaticString<20> caption;
  caption.Format(_T("%s: %d"), _("InfoBox"), i + 1);
  info_box_combo_list = &list;
  int result = ComboPicker(XCSoarInterface::main_window, caption, list,
                           OnInfoBoxHelp, true);
  if (result < 0)
    return;

  /* was there a modification? */

  InfoBoxFactory::t_InfoBox new_type = (InfoBoxFactory::t_InfoBox)list[result].DataFieldIndex;
  if (new_type == old_type)
    return;

  /* yes: apply and save it */

  panel.contents[i] = new_type;
  DisplayInfoBox();

  Profile::Save(panel, panel_index);
}
void
InfoBoxManager::SetupFocused(const int id)
{
  int i;

  if (id < 0) i = GetFocused();
  else i = id;

  if (i < 0)
    return;

  const unsigned panel = GetCurrentPanel();
  int old_type = GetType(i, panel);

  ComboList list;
  for (unsigned i = 0; i < InfoBoxFactory::NUM_TYPES; i++)
    list.Append(i, gettext(InfoBoxFactory::GetName(i)));

  list.Sort();
  list.ComboPopupItemSavedIndex = list.LookUp(old_type);

  /* let the user select */

  TCHAR caption[20];
  _stprintf(caption, _T("%s: %d"), _("InfoBox"), i + 1);
  info_box_combo_list = &list;
  int result = ComboPicker(XCSoarInterface::main_window, caption, list,
                           OnInfoBoxHelp);
  if (result < 0)
    return;

  /* was there a modification? */

  int new_type = list[result].DataFieldIndex;
  if (new_type == old_type)
    return;

  /* yes: apply and save it */

  SetType(i, new_type, panel);
  DisplayInfoBox();
  Profile::SetInfoBoxManagerConfig(infoBoxManagerConfig);
}