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); }
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 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); }
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); }
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(); }
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; }
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(); }
void Visit(const TCHAR *path, const TCHAR *filename) override { combo_list.Append(combo_list.size(), path, filename); }