本文整理汇总了C++中FlarmId::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ FlarmId::Format方法的具体用法?C++ FlarmId::Format怎么用?C++ FlarmId::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlarmId
的用法示例。
在下文中一共展示了FlarmId::Format方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFormValue
/**
* Updates all the dialogs fields.
* Should be called on dialog opening as it closes the dialog when the
* target does not exist.
*/
static void
Update()
{
TCHAR tmp[200], tmp_id[7];
// Set the dialog caption
_stprintf(tmp, _T("%s (%s)"),
_("FLARM Traffic Details"), target_id.Format(tmp_id));
wf->SetCaption(tmp);
// Try to find the target in the FLARMnet database
/// @todo: make this code a little more usable
const FlarmRecord *record = FlarmDetails::LookupRecord(target_id);
if (record) {
// Fill the pilot name field
SetFormValue(*wf, _T("prpPilot"), record->pilot);
// Fill the frequency field
if (!StringIsEmpty(record->frequency)) {
_tcscpy(tmp, record->frequency);
_tcscat(tmp, _T(" MHz"));
SetFormValue(*wf, _T("prpFrequency"), tmp);
} else
SetFormValue(*wf, _T("prpFrequency"), _T("--"));
// Fill the home airfield field
SetFormValue(*wf, _T("prpAirport"), record->airfield);
// Fill the plane type field
SetFormValue(*wf, _T("prpPlaneType"), record->plane_type);
} else {
// Fill the pilot name field
SetFormValue(*wf, _T("prpPilot"), _T("--"));
// Fill the frequency field
SetFormValue(*wf, _T("prpFrequency"), _T("--"));
// Fill the home airfield field
SetFormValue(*wf, _T("prpAirport"), _T("--"));
// Fill the plane type field
const FlarmTraffic* target =
XCSoarInterface::Basic().flarm.traffic.FindTraffic(target_id);
const TCHAR* actype;
if (target == NULL ||
(actype = FlarmTraffic::GetTypeString(target->type)) == NULL)
actype = _T("--");
SetFormValue(*wf, _T("prpPlaneType"), actype);
}
// Fill the callsign field (+ registration)
// note: don't use target->Name here since it is not updated
// yet if it was changed
const TCHAR* cs = FlarmDetails::LookupCallsign(target_id);
if (cs != NULL && cs[0] != 0) {
_tcscpy(tmp, cs);
if (record) {
_tcscat(tmp, _T(" ("));
_tcscat(tmp, record->registration);
_tcscat(tmp, _T(")"));
}
} else
_tcscpy(tmp, _T("--"));
SetFormValue(*wf, _T("prpCallsign"), tmp);
// Update the frequently changing fields too
UpdateChanging();
}
示例2: StringFormatUnsafe
/**
* Updates all the dialogs fields.
* Should be called on dialog opening as it closes the dialog when the
* target does not exist.
*/
void
FlarmTrafficDetailsWidget::Update()
{
TCHAR tmp[200], tmp_id[7];
const TCHAR *value;
// Set the dialog caption
StringFormatUnsafe(tmp, _T("%s (%s)"),
_("FLARM Traffic Details"), target_id.Format(tmp_id));
dialog.SetCaption(tmp);
// Try to find the target in the FLARMnet database
/// @todo: make this code a little more usable
const FlarmNetRecord *record = FlarmDetails::LookupRecord(target_id);
if (record) {
// Fill the pilot name field
SetText(PILOT, record->pilot);
// Fill the frequency field
if (!StringIsEmpty(record->frequency))
value = UnsafeBuildString(tmp, record->frequency.c_str(), _T(" MHz"));
else
value = _T("--");
SetText(RADIO, value);
// Fill the home airfield field
SetText(AIRPORT, record->airfield);
// Fill the plane type field
SetText(PLANE, record->plane_type);
} else {
// Fill the pilot name field
SetText(PILOT, _T("--"));
// Fill the frequency field
SetText(RADIO, _T("--"));
// Fill the home airfield field
SetText(AIRPORT, _T("--"));
// Fill the plane type field
const FlarmTraffic* target =
CommonInterface::Basic().flarm.traffic.FindTraffic(target_id);
const TCHAR* actype;
if (target == nullptr ||
(actype = FlarmTraffic::GetTypeString(target->type)) == nullptr)
actype = _T("--");
SetText(PLANE, actype);
}
// Fill the callsign field (+ registration)
// note: don't use target->Name here since it is not updated
// yet if it was changed
const TCHAR* cs = FlarmDetails::LookupCallsign(target_id);
if (cs != nullptr && cs[0] != 0) {
StringBuilder<TCHAR> builder(tmp, ARRAY_SIZE(tmp));
builder.Append(cs);
if (record)
builder.Append(_T(" ("), record->registration.c_str(), _T(")"));
value = tmp;
} else
value = _T("--");
SetText(CALLSIGN, value);
// Update the frequently changing fields too
UpdateChanging(CommonInterface::Basic());
}
示例3: if
static void
PaintListItem(Canvas &canvas, const PixelRect rc, unsigned index)
{
assert(array[index].IsDefined());
const FlarmId id = array[index];
const DialogLook &look = UIGlobals::GetDialogLook();
const Font &name_font = *look.list.font;
const Font &small_font = *look.small_font;
canvas.SetTextColor(COLOR_BLACK);
TCHAR tmp_id[10];
id.Format(tmp_id);
const FlarmRecord *record = FlarmNet::FindRecordById(id);
const TCHAR *callsign = FlarmDetails::LookupCallsign(id);
canvas.Select(name_font);
StaticString<256> tmp;
if (record != NULL)
tmp.Format(_T("%s - %s - %s"), callsign, record->registration, tmp_id);
else if (callsign != NULL)
tmp.Format(_T("%s - %s"), callsign, tmp_id);
else
tmp.Format(_T("%s"), tmp_id);
canvas.text_clipped(rc.left + Layout::FastScale(2),
rc.top + Layout::FastScale(2), rc, tmp);
canvas.Select(small_font);
tmp.clear();
if (record != NULL) {
if (!StringIsEmpty(record->pilot))
tmp = record->pilot;
if (!StringIsEmpty(record->plane_type)) {
if (!tmp.empty())
tmp.append(_T(" - "));
tmp.append(record->plane_type);
}
if (!StringIsEmpty(record->airfield)) {
if (!tmp.empty())
tmp.append(_T(" - "));
tmp.append(record->airfield);
}
}
if (tmp.empty())
tmp = _("No further information");
canvas.text_clipped(rc.left + Layout::FastScale(2),
rc.top + name_font.GetHeight() + Layout::FastScale(4),
rc, tmp);
}