本文整理汇总了C++中TrackerSettings::DateOrderFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackerSettings::DateOrderFormat方法的具体用法?C++ TrackerSettings::DateOrderFormat怎么用?C++ TrackerSettings::DateOrderFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrackerSettings
的用法示例。
在下文中一共展示了TrackerSettings::DateOrderFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
TimeFormatSettingsView::ShowCurrentSettings()
{
TrackerSettings settings;
f24HrRadioButton->SetValue(settings.ClockIs24Hr());
f12HrRadioButton->SetValue(!settings.ClockIs24Hr());
switch (settings.DateOrderFormat()) {
case kYMDFormat:
fYMDRadioButton->SetValue(1);
break;
case kMDYFormat:
fMDYRadioButton->SetValue(1);
break;
default:
case kDMYFormat:
fDMYRadioButton->SetValue(1);
break;
}
FormatSeparator separator = settings.TimeFormatSeparator();
if (separator >= kNoSeparator && separator < kSeparatorsEnd)
fSeparatorMenuField->Menu()->ItemAt((int32)separator)->SetMarked(true);
_UpdateExamples();
}
示例2: TruncStringBase
float
TruncTimeBase(BString *result, int64 value, const View *view, float width)
{
TrackerSettings settings;
FormatSeparator separator = settings.TimeFormatSeparator();
DateOrder order = settings.DateOrderFormat();
bool clockIs24hr = settings.ClockIs24Hr();
float resultWidth = 0;
char buffer[256];
time_t timeValue = (time_t)value;
tm timeData;
// use reentrant version of localtime to avoid having to have a semaphore
// (localtime uses a global structure to do it's conversion)
localtime_r(&timeValue, &timeData);
BString timeFormat;
for (int32 index = 0; ; index++) {
if (TimeFormat(timeFormat, index, separator, order, clockIs24hr)
!= B_OK)
break;
strftime(buffer, 256, timeFormat.String(), &timeData);
resultWidth = view->StringWidth(buffer);
if (resultWidth <= width)
break;
}
if (resultWidth > width) {
// even the shortest format string didn't do it, insert ellipsis
resultWidth = TruncStringBase(result, buffer, (ssize_t)strlen(buffer),
view, width);
} else
*result = buffer;
return resultWidth;
}