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 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 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 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 DataFieldTime::AppendComboValue(ComboList &combo_list, int value) const { TCHAR buffer[128]; FormatTimespanSmart(buffer, value, max_tokens); combo_list.Append(value, buffer); }
int ComboPicker(SingleWindow &parent, const TCHAR *caption, const ComboList &combo_list, ListHelpCallback_t help_callback, bool enable_item_help) { ComboListPopup = &combo_list; const UPixelScalar font_height = UIGlobals::GetDialogLook().text_font->GetHeight() + Layout::FastScale(2); const UPixelScalar max_height = Layout::GetMaximumControlHeight(); const UPixelScalar row_height = font_height >= max_height ? font_height /* this formula is supposed to be a compromise between too small and too large: */ : (font_height + max_height) / 2; padding = (row_height - font_height) / 2; return ListPicker(parent, caption, combo_list.size(), combo_list.ComboPopupItemSavedIndex, row_height, OnPaintComboPopupListItem, false, help_callback, enable_item_help ? OnItemHelp : NULL); }
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 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 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); }
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(); }
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(); }
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); }
bool FilePicker(const TCHAR *caption, const TCHAR *patterns, TCHAR *buffer) { assert(patterns != NULL); DataFieldFileReader df; df.ScanMultiplePatterns(patterns); const ComboList combo_list = df.CreateComboList(nullptr); if (combo_list.size() == 0) return false; int i = ComboPicker(caption, combo_list, nullptr); if (i < 0) return false; const ComboList::Item &item = combo_list[i]; df.SetFromCombo(item.DataFieldIndex, item.StringValue); _tcscpy(buffer, df.GetAsString()); return true; }
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(); }
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(); } }
int ComboPicker(SingleWindow &parent, const TCHAR *caption, const ComboList &combo_list, ListHelpCallback_t help_callback, bool enable_item_help) { ComboListPopup = &combo_list; return ListPicker(parent, caption, combo_list.size(), combo_list.ComboPopupItemSavedIndex, Layout::Scale(18), OnPaintComboPopupListItem, false, help_callback, enable_item_help ? OnItemHelp : NULL); }
void Visit(const TCHAR *path, const TCHAR *filename) override { combo_list.Append(combo_list.size(), path, filename); }