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); }
static void ImportClicked(gcc_unused WndButton &button) { ComboList list; PolarFileVisitor fv(list); // Fill list VisitDataFiles(_T("*.plr"), fv); list.Sort(); // let the user select int result = ComboPicker(UIGlobals::GetMainWindow(), _("Load Polar From File"), list, NULL); if (result < 0) return; assert((unsigned)result < list.size()); PolarInfo polar; const TCHAR* path = list[result].StringValue; PolarGlue::LoadFromFile(polar, path); plane.reference_mass = polar.reference_mass; plane.dry_mass = polar.reference_mass; plane.max_ballast = polar.max_ballast; if (positive(polar.wing_area)) plane.wing_area = polar.wing_area; if (positive(polar.v_no)) plane.max_speed = polar.v_no; plane.v1 = polar.v1; plane.v2 = polar.v2; plane.v3 = polar.v3; plane.w1 = polar.w1; plane.w2 = polar.w2; plane.w3 = polar.w3; plane.polar_name = list[result].StringValueFormatted; Update(); }
static void ListClicked(gcc_unused WndButton &button) { ComboList list; unsigned len = PolarStore::Count(); for (unsigned i = 0; i < len; i++) list.Append(i, PolarStore::GetItem(i).name); list.Sort(); // let the user select int result = ComboPicker(UIGlobals::GetMainWindow(), _("Load Polar"), list, NULL); if (result < 0) return; assert((unsigned)result < len); const PolarStore::Item &item = PolarStore::GetItem(list[result].DataFieldIndex); plane.reference_mass = fixed(item.reference_mass); plane.dry_mass = fixed(item.reference_mass); plane.max_ballast = fixed(item.max_ballast); if (item.wing_area > 0.0) plane.wing_area = fixed(item.wing_area); if (item.v_no > 0.0) plane.max_speed = fixed(item.v_no); plane.v1 = Units::ToSysUnit(fixed(item.v1), Unit::KILOMETER_PER_HOUR); plane.v2 = Units::ToSysUnit(fixed(item.v2), Unit::KILOMETER_PER_HOUR); plane.v3 = Units::ToSysUnit(fixed(item.v3), Unit::KILOMETER_PER_HOUR); plane.w1 = fixed(item.w1); plane.w2 = fixed(item.w2); plane.w3 = fixed(item.w3); plane.polar_name = list[result].StringValue; if (item.contest_handicap > 0) plane.handicap = item.contest_handicap; Update(); }
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); }
void PolarConfigPanel::LoadInternal() { ComboList list; unsigned len = PolarStore::Count(); for (unsigned i = 0; i < len; i++) list.Append(i, PolarStore::GetItem(i).name); list.Sort(); /* let the user select */ int result = ComboPicker(UIGlobals::GetMainWindow(), _("Load Polar"), list, NULL); if (result >= 0) { const PolarStore::Item &item = PolarStore::GetItem(list[result].DataFieldIndex); UpdatePolarPoints(Units::ToSysUnit(fixed(item.v1), unKiloMeterPerHour), Units::ToSysUnit(fixed(item.v2), unKiloMeterPerHour), Units::ToSysUnit(fixed(item.v3), unKiloMeterPerHour), fixed(item.w1), fixed(item.w2), fixed(item.w3)); LoadFormProperty(form, _T("prpPolarReferenceMass"), fixed(item.reference_mass)); LoadFormProperty(form, _T("prpPolarDryMass"), fixed(item.reference_mass)); LoadFormProperty(form, _T("prpPolarMaxBallast"), fixed(item.max_ballast)); if (item.wing_area > 0.0) LoadFormProperty(form, _T("prpPolarWingArea"), fixed(item.wing_area)); if (item.v_no > 0.0) LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), ugHorizontalSpeed, fixed(item.v_no)); if (item.contest_handicap > 0) LoadFormProperty(form, _T("prpHandicap"), item.contest_handicap); CommonInterface::SetComputerSettings().plane.polar_name = item.name; UpdatePolarTitle(); UpdatePolarInvalidLabel(); } }
void PolarConfigPanel::LoadFromFile() { ComboList list; PolarFileVisitor fv(list); // Fill list VisitDataFiles(_T("*.plr"), fv); // Sort list list.Sort(); // Show selection dialog int result = ComboPicker(UIGlobals::GetMainWindow(), _("Load Polar From File"), list, NULL); if (result >= 0) { const TCHAR* path = list[result].StringValue; PolarInfo polar; PolarGlue::LoadFromFile(polar, path); UpdatePolarPoints(polar.v1, polar.v2, polar.v3, polar.w1, polar.w2, polar.w3); LoadFormProperty(form, _T("prpPolarReferenceMass"), polar.reference_mass); LoadFormProperty(form, _T("prpPolarDryMass"), polar.reference_mass); LoadFormProperty(form, _T("prpPolarMaxBallast"), polar.max_ballast); if (positive(polar.wing_area)) LoadFormProperty(form, _T("prpPolarWingArea"), polar.wing_area); if (positive(polar.v_no)) LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), ugHorizontalSpeed, polar.v_no); CommonInterface::SetComputerSettings().plane.polar_name = list[result].StringValueFormatted; UpdatePolarTitle(); UpdatePolarInvalidLabel(); } }
inline void PlanePolarWidget::ImportClicked() { ComboList list; PolarFileVisitor fv(list); // Fill list VisitDataFiles(_T("*.plr"), fv); list.Sort(); // let the user select int result = ComboPicker(_("Load Polar From File"), list, NULL); if (result < 0) return; assert((unsigned)result < list.size()); PolarInfo polar; const TCHAR* path = list[result].StringValue; PolarGlue::LoadFromFile(polar, path); plane.reference_mass = polar.reference_mass; plane.dry_mass = polar.reference_mass; plane.max_ballast = polar.max_ballast; if (positive(polar.wing_area)) plane.wing_area = polar.wing_area; if (positive(polar.v_no)) plane.max_speed = polar.v_no; plane.polar_shape = polar.shape; plane.polar_name = list[result].StringValueFormatted; Update(); }
inline void PlanePolarWidget::ListClicked() { ComboList list; unsigned len = PolarStore::Count(); for (unsigned i = 0; i < len; i++) list.Append(i, PolarStore::GetItem(i).name); list.Sort(); // let the user select int result = ComboPicker(_("Load Polar"), list, NULL); if (result < 0) return; assert((unsigned)result < len); const PolarStore::Item &item = PolarStore::GetItem(list[result].DataFieldIndex); plane.reference_mass = fixed(item.reference_mass); plane.dry_mass = fixed(item.reference_mass); plane.max_ballast = fixed(item.max_ballast); if (item.wing_area > 0.0) plane.wing_area = fixed(item.wing_area); if (item.v_no > 0.0) plane.max_speed = fixed(item.v_no); plane.polar_shape = item.ToPolarShape(); plane.polar_name = list[result].StringValue; if (item.contest_handicap > 0) plane.handicap = item.contest_handicap; Update(); }
void PolarConfigPanel::LoadInternal() { ComboList list; unsigned len = PolarStore::Count(); for (unsigned i = 0; i < len; i++) list.Append(i, PolarStore::GetItem(i).name); list.Sort(); /* let the user select */ int result = ComboPicker(_("Load Polar"), list, NULL); if (result >= 0) { const PolarStore::Item &item = PolarStore::GetItem(list[result].DataFieldIndex); LoadPolarShape(form, item.ToPolarShape()); LoadFormProperty(form, _T("prpPolarReferenceMass"), fixed(item.reference_mass)); LoadFormProperty(form, _T("prpPolarDryMass"), fixed(item.reference_mass)); LoadFormProperty(form, _T("prpPolarMaxBallast"), fixed(item.max_ballast)); if (item.wing_area > 0.0) LoadFormProperty(form, _T("prpPolarWingArea"), fixed(item.wing_area)); if (item.v_no > 0.0) LoadFormProperty(form, _T("prpMaxManoeuveringSpeed"), UnitGroup::HORIZONTAL_SPEED, fixed(item.v_no)); if (item.contest_handicap > 0) LoadFormProperty(form, _T("prpHandicap"), item.contest_handicap); CommonInterface::SetComputerSettings().plane.polar_name = item.name; UpdatePolarTitle(); UpdatePolarInvalidLabel(); } }