void RASPSettingsPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) { WndProperty *wp; wp = AddEnum(_("Field"), nullptr); DataFieldEnum *dfe = (DataFieldEnum *)wp->GetDataField(); dfe->EnableItemHelp(true); dfe->addEnumText(_("Terrain")); for (unsigned i = 1; i < RasterWeather::MAX_WEATHER_MAP; i++) { const TCHAR *label = RASP.ItemLabel(i); if (label != NULL) dfe->AddChoice(i, label, nullptr, RASP.ItemHelp(i)); } dfe->Set(RASP.GetParameter()); wp->RefreshDisplay(); wp = AddEnum(_("Time"), nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); dfe->addEnumText(_("Now")); for (unsigned i = 1; i < RasterWeather::MAX_WEATHER_TIMES; i++) { if (RASP.isWeatherAvailable(i)) { TCHAR timetext[10]; _stprintf(timetext, _T("%04d"), RASP.IndexToTime(i)); dfe->addEnumText(timetext, i); } } dfe->Set(RASP.GetTime()); wp->RefreshDisplay(); }
void RASPSettingsPanel::Prepare(ContainerWindow &parent, const PixelRect &rc) { const WeatherUIState &state = CommonInterface::GetUIState().weather; time = state.time; WndProperty *wp; wp = AddEnum(_("Field"), nullptr, this); DataFieldEnum *dfe = (DataFieldEnum *)wp->GetDataField(); dfe->EnableItemHelp(true); for (unsigned i = 0; i < rasp.GetItemCount(); i++) { const auto &mi = rasp.GetItemInfo(i); const TCHAR *label = mi.label; if (label != nullptr) label = gettext(label); const TCHAR *help = mi.help; if (help != nullptr) help = gettext(help); dfe->AddChoice(i, mi.name, label, help); } dfe->Set(state.map); wp->RefreshDisplay(); AddEnum(_("Time"), nullptr, this); UpdateTimeControl(); }
static void FillDirectionEnum(DataFieldEnum &df) { TCHAR buffer[64]; df.AddChoice(WILDCARD, _T("*")); df.AddChoice(0, GetHeadingString(buffer)); static constexpr unsigned directions[] = { 360, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330 }; for (unsigned i = 0; i < ARRAY_SIZE(directions); ++i) df.AddChoice(directions[i], FormatBearing(directions[i]).c_str()); df.Set(WILDCARD); }
static void FillDistanceEnum(DataFieldEnum &df) { df.AddChoice(0, _T("*")); static constexpr unsigned distances[] = { 25, 50, 75, 100, 150, 250, 500, 1000 }; TCHAR buffer[64]; const TCHAR *unit = Units::GetDistanceName(); for (unsigned i = 0; i < ARRAY_SIZE(distances); ++i) { _stprintf(buffer, _T("%u %s"), distances[i], unit); df.AddChoice(distances[i], buffer); } df.Set(0u); }
static unsigned AddPort(DataFieldEnum &df, DeviceConfig::PortType type, const TCHAR *text, const TCHAR *display_string=NULL, const TCHAR *help=NULL) { /* the uppper 16 bit is the port type, and the lower 16 bit is a serial number to make the enum id unique */ unsigned id = ((unsigned)type << 16) + df.Count(); df.AddChoice(id, text, display_string, help); return id; }
void dlgWeatherShowModal() { WndForm *wf = LoadDialog(nullptr, UIGlobals::GetMainWindow(), _T("IDR_XML_WEATHER")); if (wf == NULL) return; WndProperty* wp; wp = (WndProperty*)wf->FindByName(_T("prpTime")); assert(wp != nullptr); DataFieldEnum *dfe = (DataFieldEnum *)wp->GetDataField(); dfe->addEnumText(_("Now")); for (unsigned i = 1; i < RasterWeather::MAX_WEATHER_TIMES; i++) { if (RASP.isWeatherAvailable(i)) { TCHAR timetext[10]; _stprintf(timetext, _T("%04d"), RASP.IndexToTime(i)); dfe->addEnumText(timetext, i); } } dfe->Set(RASP.GetTime()); wp->RefreshDisplay(); wp = (WndProperty *)wf->FindByName(_T("prpDisplayItem")); assert(wp != nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); dfe->EnableItemHelp(true); dfe->addEnumText(_("Terrain")); for (int i = 1; i <= 15; i++) { const TCHAR *label = RASP.ItemLabel(i); if (label != NULL) dfe->AddChoice(i, label, nullptr, RASP.ItemHelp(i)); } dfe->Set(RASP.GetParameter()); wp->RefreshDisplay(); wf->ShowModal(); wp = (WndProperty *)wf->FindByName(_T("prpTime")); assert(wp != nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); RASP.SetTime(dfe->GetValue()); wp = (WndProperty *)wf->FindByName(_T("prpDisplayItem")); assert(wp != nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); RASP.SetParameter(dfe->GetValue()); delete wf; }