void DataFieldTime::AppendComboValue(ComboList &combo_list, int value) const { TCHAR buffer[128]; FormatTimespanSmart(buffer, value, max_tokens); combo_list.Append(value, buffer); }
static void AppendComboValue(ComboList &combo_list, unsigned value) { TCHAR buffer1[ARRAY_SIZE(buffer)], buffer2[ARRAY_SIZE(buffer)]; _stprintf(buffer1, _T("%u"), value); _stprintf(buffer2, _T("%u°"), value); combo_list.Append(value, buffer1, buffer2); }
void DataFieldInteger::AppendComboValue(ComboList &combo_list, int value) const { TCHAR a[edit_format.MAX_SIZE], b[display_format.MAX_SIZE]; _stprintf(a, edit_format, value); _stprintf(b, display_format, value); combo_list.Append(combo_list.size(), a, b); }
void DataFieldTime::AppendComboValue(ComboList &combo_list, int value) const { TCHAR buffer[128], buffer2[32]; FormatTimespanSmart(buffer, value, max_tokens); StringFormatUnsafe(buffer2, _T("%d"), value); combo_list.Append(value, buffer2, buffer); }
void DataFieldFloat::AppendComboValue(ComboList &combo_list, fixed value) const { TCHAR a[edit_format.capacity()], b[display_format.capacity()]; _stprintf(a, edit_format, (double)value); _stprintf(b, display_format, (double)value, unit.c_str()); combo_list.Append(combo_list.size(), a, b); }
void DataFieldInteger::AppendComboValue(ComboList &combo_list, int value) const { TCHAR a[16], b[16]; _stprintf(a, mEditFormat, value); _stprintf(b, mDisplayFormat, value, mUnits); combo_list.Append(combo_list.size(), a, b); }
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); }
ComboList * DataFieldFileReader::CreateComboList() const { /* sorry for the const_cast .. this method keeps the promise of not modifying the object, given that one does not count filling the (cached) file list as "modification" */ EnsureLoadedDeconst(); ComboList *cl = new ComboList(); TCHAR buffer[MAX_PATH]; for (unsigned i = 0; i < files.size(); i++) { const TCHAR *path = files[i].mTextFile; if (path == NULL) path = _T(""); /* is a file with the same base name present in another data directory? */ bool found = false; for (unsigned j = 1; j < files.size(); j++) { if (j != i && _tcscmp(path, files[j].mTextFile) == 0) { found = true; break; } } if (found) { /* yes - append the absolute path to allow the user to see the difference */ _tcscpy(buffer, path); _tcscat(buffer, _T(" (")); _tcscat(buffer, files[i].mTextPathFile); _tcscat(buffer, _T(")")); path = buffer; } cl->Append(i, path); if (i == mValue) { cl->ComboPopupItemSavedIndex = i; } } return cl; }
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(); } }
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(); }
static const RecordedFlightInfo * ShowFlightList(const RecordedFlightList &flight_list) { // Prepare list of the flights for displaying ComboList combo; for (unsigned i = 0; i < flight_list.size(); ++i) { const RecordedFlightInfo &flight = flight_list[i]; StaticString<64> buffer; buffer.UnsafeFormat(_T("%04u/%02u/%02u %02u:%02u-%02u:%02u"), flight.date.year, flight.date.month, flight.date.day, flight.start_time.hour, flight.start_time.minute, flight.end_time.hour, flight.end_time.minute); combo.Append(i, buffer); } // Show list of the flights int i = ComboPicker(_T("Choose a flight"), combo, NULL, false); return (i < 0) ? NULL : &flight_list[i]; }
static const RecordedFlightInfo * ShowFlightList(const RecordedFlightList &flight_list) { // Prepare list of the flights for displaying ComboList combo; for (unsigned i = 0; i < flight_list.size(); ++i) { const RecordedFlightInfo &flight = flight_list[i]; TCHAR buffer[64]; _sntprintf(buffer, 64, _T("%04u/%02u/%02u %02u:%02u-%02u:%02u"), flight.date.year, flight.date.month, flight.date.day, flight.start_time.hour, flight.start_time.minute, flight.end_time.hour, flight.end_time.minute); combo.Append(i, buffer); } // Show list of the flights int i = ComboPicker(UIGlobals::GetMainWindow(), _T("Choose a flight"), combo, NULL, false); return (i < 0) ? NULL : &flight_list[i]; }
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(); } }
void Visit(const TCHAR *path, const TCHAR *filename) override { combo_list.Append(combo_list.size(), path, filename); }