本文整理汇总了C++中StaticString::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ StaticString::Format方法的具体用法?C++ StaticString::Format怎么用?C++ StaticString::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StaticString
的用法示例。
在下文中一共展示了StaticString::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pt
void
MapItemListRenderer::Draw(Canvas &canvas, const PixelRect rc,
const MarkerMapItem &item,
const DialogLook &dialog_look,
const MarkerLook &look)
{
const PixelScalar line_height = rc.bottom - rc.top;
const Marker &marker = item.marker;
const RasterPoint pt(rc.left + line_height / 2,
rc.top + line_height / 2);
look.icon.Draw(canvas, pt);
const Font &name_font = *dialog_look.list.font_bold;
const Font &small_font = *dialog_look.small_font;
PixelScalar left = rc.left + line_height + Layout::FastScale(2);
StaticString<256> buffer;
buffer.Format(_T("%s #%d"), _("Marker"), item.id + 1);
canvas.Select(name_font);
canvas.DrawClippedText(left, rc.top + Layout::FastScale(2), rc, buffer);
TCHAR time_buffer[32], timespan_buffer[32];
FormatSignedTimeHHMM(time_buffer, TimeLocal(marker.time.GetSecondOfDay()));
FormatTimespanSmart(timespan_buffer, BrokenDateTime::NowUTC() - marker.time);
buffer.Format(_("dropped %s ago"), timespan_buffer);
buffer.AppendFormat(_T(" (%s)"), time_buffer);
canvas.Select(small_font);
canvas.DrawClippedText(left,
rc.top + name_font.GetHeight() + Layout::FastScale(4),
rc, buffer);
}
示例2: assert
bool
DeviceDescriptor::ReadFlightList(RecordedFlightList &flight_list,
OperationEnvironment &env)
{
assert(borrowed);
assert(port != nullptr);
assert(driver != nullptr);
assert(device != nullptr);
StaticString<60> text;
if (driver->HasPassThrough() && second_device != nullptr) {
text.Format(_T("%s: %s."), _("Reading flight list"),
second_driver->display_name);
env.SetText(text);
device->EnablePassThrough(env);
return second_device->ReadFlightList(flight_list, env);
} else {
text.Format(_T("%s: %s."), _("Reading flight list"), driver->display_name);
env.SetText(text);
return device->ReadFlightList(flight_list, env);
}
}
示例3: if
void
ManagedFileListWidget::OnPaintItem(Canvas &canvas, const PixelRect rc,
unsigned i)
{
const FileItem &file = items[i];
canvas.Select(row_renderer.GetFirstFont());
row_renderer.DrawFirstRow(canvas, rc, file.name.c_str());
canvas.Select(row_renderer.GetSecondFont());
if (file.downloading) {
StaticString<64> text;
if (file.download_status.position < 0) {
text = _("Queued");
} else if (file.download_status.size > 0) {
text.Format(_T("%s (%u%%)"), _("Downloading"),
unsigned(file.download_status.position * 100
/ file.download_status.size));
} else {
TCHAR size[32];
FormatByteSize(size, ARRAY_SIZE(size), file.download_status.position);
text.Format(_T("%s (%s)"), _("Downloading"), size);
}
row_renderer.DrawRightFirstRow(canvas, rc, text);
} else if (file.failed) {
const TCHAR *text = _("Error");
row_renderer.DrawRightFirstRow(canvas, rc, text);
}
row_renderer.DrawRightSecondRow(canvas, rc, file.last_modified.c_str());
row_renderer.DrawSecondRow(canvas, rc, file.size.c_str());
}
示例4: FormatUserMass
void
RenderGlidePolarInfo(Canvas &canvas, const PixelRect rc,
const ChartLook &chart_look,
const GlidePolar &glide_polar)
{
canvas.Select(chart_look.label_font);
StaticString<80> text;
StaticString<20> value;
canvas.SetBackgroundTransparent();
FormatUserMass(glide_polar.GetTotalMass(), value.buffer(), true);
int left = rc.left*0.8 + rc.right*0.2;
text.Format(_T("%s: %s"), _("Mass"), value.c_str());
canvas.DrawText(left,
rc.bottom - Layout::Scale(50),
text);
double wl = glide_polar.GetWingLoading();
if (wl != 0) {
FormatUserWingLoading(wl, value.buffer(), true);
text.Format(_T("%s: %s"), _("Wing loading"), value.c_str());
canvas.DrawText(left,
rc.bottom - Layout::Scale(35),
text);
}
}
示例5: tstring
const tstring
AirspaceAltitude::GetAsTextUnits(const bool concise) const
{
StaticString<64> buffer;
switch (type) {
case AGL:
if (!positive(altitude_above_terrain))
buffer = _T("GND");
else
buffer.Format(_T("%d %s AGL"),
iround(Units::ToUserAltitude(altitude_above_terrain)),
Units::GetAltitudeName());
break;
case FL:
buffer.Format(_T("FL%d"), (int)flight_level);
break;
case MSL:
buffer.Format(_T("%d %s"), iround(Units::ToUserAltitude(altitude)),
Units::GetAltitudeName());
break;
case UNDEFINED:
default:
buffer.clear();
break;
}
if (!concise && type != MSL && positive(altitude))
buffer.AppendFormat(_T(" %d %s"), iround(Units::ToUserAltitude(altitude)),
Units::GetAltitudeName());
return tstring(buffer);
}
示例6: flarm
bool
DeviceDescriptor::Declare(const struct Declaration &declaration,
const Waypoint *home,
OperationEnvironment &env)
{
if (port == NULL)
return false;
SetBusy(true);
StaticString<60> text;
text.Format(_T("%s: %s."), _("Sending declaration"), driver->display_name);
env.SetText(text);
port->StopRxThread();
bool result = device != NULL && device->Declare(declaration, home, env);
if (device_blackboard->IsFLARM(index) && !IsDriver(_T("FLARM"))) {
text.Format(_T("%s: FLARM."), _("Sending declaration"));
env.SetText(text);
FlarmDevice flarm(*port);
result = flarm.Declare(declaration, home, env) || result;
}
port->StartRxThread();
SetBusy(false);
return result;
}
示例7: FormatTimespanSmart
gcc_pure
const TCHAR *MakeMessage(const AbstractAirspace &airspace,
AirspaceWarning::State state,
const AirspaceInterceptSolution &solution) {
if (state == AirspaceWarning::WARNING_INSIDE)
buffer.Format(_T("%s: %s"), _("Inside airspace"), airspace.GetName());
else
buffer.Format(_T("%s: %s (%s)"), _("Near airspace"), airspace.GetName(),
FormatTimespanSmart(int(solution.elapsed_time),
2).c_str());
return buffer;
}
示例8: SetCaption
void
TaskManagerDialog::UpdateCaption()
{
StaticString<128> title;
if (task->GetName().empty())
title.Format(_T("%s: %s"), _("Task Manager"),
tab_bar->GetButtonCaption(tab_bar->GetCurrentPage()));
else
title.Format(_T("%s: %s - %s"), _("Task Manager"),
task->GetName().c_str(),
tab_bar->GetButtonCaption(tab_bar->GetCurrentPage()));
SetCaption(title);
}
示例9:
static void
UpdateButtons()
{
StaticString<64> text;
text.Format(_T("%s: %s"), _("Name"),
global_wpt->name.empty()
? _("(blank)") : global_wpt->name.c_str());
buttonName->SetCaption(text);
text.Format(_T("%s: %s"), _("Comment"),
global_wpt->comment.empty()
? _("(blank)") : global_wpt->comment.c_str());
buttonComment->SetCaption(text);
}
示例10: switch
static void
UpdateCaption(WndForm *form, const Waypoint *waypoint)
{
StaticString<256> buffer;
buffer.Format(_T("%s: %s"), _("Waypoint"), waypoint->name.c_str());
const char *key = nullptr;
switch (waypoint->file_num) {
case 1:
key = ProfileKeys::WaypointFile;
break;
case 2:
key = ProfileKeys::AdditionalWaypointFile;
break;
case 3:
key = ProfileKeys::WatchedWaypointFile;
break;
}
if (key != nullptr) {
const TCHAR *filename = Profile::GetPathBase(key);
if (filename != nullptr)
buffer.AppendFormat(_T(" (%s)"), filename);
}
form->SetCaption(buffer);
}
示例11: pt
static void
Draw(Canvas &canvas, PixelRect rc,
const ThermalMapItem &item,
RoughTimeDelta utc_offset,
const TwoTextRowsRenderer &row_renderer,
const MapLook &look)
{
const unsigned line_height = rc.GetHeight();
const unsigned text_padding = Layout::GetTextPadding();
const ThermalSource &thermal = item.thermal;
const PixelPoint pt(rc.left + line_height / 2,
rc.top + line_height / 2);
look.thermal_source_icon.Draw(canvas, pt);
rc.left += line_height + text_padding;
row_renderer.DrawFirstRow(canvas, rc, _("Thermal"));
StaticString<256> buffer;
TCHAR lift_buffer[32];
FormatUserVerticalSpeed(thermal.lift_rate, lift_buffer, 32);
int timespan = BrokenDateTime::NowUTC().GetSecondOfDay() - (int)thermal.time;
if (timespan < 0)
timespan += 24 * 60 * 60;
buffer.Format(_T("%s: %s - left %s ago (%s)"),
_("Avg. lift"), lift_buffer,
FormatTimespanSmart(timespan).c_str(),
FormatLocalTimeHHMM((int)thermal.time, utc_offset).c_str());
row_renderer.DrawSecondRow(canvas, rc, buffer);
}
示例12: uround
void
WindArrowRenderer::Draw(Canvas &canvas, const Angle screen_angle,
const SpeedVector wind, const PixelPoint pos,
const PixelRect rc, WindArrowStyle arrow_style)
{
// Draw arrow (and tail)
const unsigned length = uround(Quadruple(wind.norm));
DrawArrow(canvas, pos, wind.bearing - screen_angle, length, arrow_style);
// Draw wind speed label
StaticString<12> buffer;
buffer.Format(_T("%i"), iround(Units::ToUserWindSpeed(wind.norm)));
canvas.SetTextColor(COLOR_BLACK);
canvas.Select(*look.font);
const unsigned offset = uround(M_SQRT2 * wind.norm);
BulkPixelPoint label[] = {
{ 18, -26 - int(offset) },
};
PolygonRotateShift(label, ARRAY_SIZE(label),
pos, wind.bearing - screen_angle);
TextInBoxMode style;
style.align = TextInBoxMode::Alignment::CENTER;
style.vertical_position = TextInBoxMode::VerticalPosition::CENTERED;
style.shape = LabelShape::OUTLINED;
TextInBox(canvas, buffer, label[0].x, label[0].y, style, rc);
}
示例13: switch
static void
UpdateCaption(const TCHAR *waypoint_name, int8_t file_num)
{
StaticString<256> buffer;
buffer.Format(_T("%s: %s"), _("Waypoint"), waypoint_name);
if (file_num > 0) {
const TCHAR *key;
switch (file_num) {
case 1:
key = szProfileWaypointFile;
break;
case 2:
key = szProfileAdditionalWaypointFile;
break;
case 3:
key = szProfileWatchedWaypointFile;
break;
}
const TCHAR *filename = Profile::GetPathBase(key);
if (filename != NULL)
buffer.AppendFormat(_T(" (%s)"), filename);
}
wf->SetCaption(buffer);
}
示例14: assert
void
TabMenuControl::SetCurrentPage(unsigned page)
{
assert(page < buttons.size());
if (!pager.ClickPage(page))
return;
if (page == GetMenuPage()) {
form.SetCaption(caption);
const MenuTabIndex di = FindPage(last_content_page);
this->GetTabMenuDisplay()->SetSelectedIndex(di);
} else {
const PageItem& theitem = GetPageItem(page);
SetLastContentPage(page);
const MainMenuButton &main_button =
GetMainMenuButton(theitem.main_menu_index);
StaticString<128> caption;
caption.Format(_T("%s > %s"),
gettext(main_button.caption),
gettext(theitem.menu_caption));
form.SetCaption(caption);
}
}
示例15: while
static void
NewClicked(gcc_unused WndButton &button)
{
Plane plane = CommonInterface::GetComputerSettings().plane;
while (dlgPlaneDetailsShowModal(*(SingleWindow*)dialog->get_root_owner(), plane)) {
if (plane.registration.empty()) {
MessageBoxX(_("Please enter the registration of the plane!"),
_("Error"), MB_OK);
continue;
}
StaticString<42> filename(plane.registration);
filename += _T(".xcp");
StaticString<MAX_PATH> path;
LocalPath(path.buffer(), filename);
if (File::Exists(path)) {
StaticString<256> tmp;
tmp.Format(_("A plane profile \"%s\" already exists. "
"Do you want to overwrite it?"),
filename.c_str());
if (MessageBoxX(tmp, _("Overwrite"), MB_YESNO) != IDYES)
continue;
}
PlaneGlue::WriteFile(plane, path);
UpdateList();
break;
}
}