当前位置: 首页>>代码示例>>C++>>正文


C++ TrackerSettings::ClockIs24Hr方法代码示例

本文整理汇总了C++中TrackerSettings::ClockIs24Hr方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackerSettings::ClockIs24Hr方法的具体用法?C++ TrackerSettings::ClockIs24Hr怎么用?C++ TrackerSettings::ClockIs24Hr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TrackerSettings的用法示例。


在下文中一共展示了TrackerSettings::ClockIs24Hr方法的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();
}
开发者ID:mariuz,项目名称:haiku,代码行数:30,代码来源:SettingsViews.cpp

示例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;
}
开发者ID:mmanley,项目名称:Antares,代码行数:37,代码来源:WidgetAttributeText.cpp


注:本文中的TrackerSettings::ClockIs24Hr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。