Esempio n. 1
0
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();
}
Esempio n. 2
0
void
TimeFormatSettingsView::RecordRevertSettings()
{
	TrackerSettings settings;

	f24HrClock = settings.ClockIs24Hr();
	fSeparator = settings.TimeFormatSeparator();
	fFormat = settings.DateOrderFormat();
}
Esempio n. 3
0
bool
TimeFormatSettingsView::IsDefaultable() const
{
	TrackerSettings settings;

	return settings.TimeFormatSeparator() != kSlashSeparator
		|| settings.DateOrderFormat() != kMDYFormat
		|| settings.ClockIs24Hr() != false;
}
Esempio n. 4
0
void
TimeFormatSettingsView::_SendNotices()
{
	TTracker *tracker = dynamic_cast<TTracker *>(be_app);
	if (!tracker)
		return;

	TrackerSettings settings;

	// Make the notification message and send it to the tracker:
	BMessage notificationMessage;
	notificationMessage.AddInt32("TimeFormatSeparator", (int32)settings.TimeFormatSeparator());
	notificationMessage.AddInt32("DateOrderFormat", (int32)settings.DateOrderFormat());
	notificationMessage.AddBool("24HrClock", settings.ClockIs24Hr());
	tracker->SendNotices(kDateFormatChanged, &notificationMessage);
}
Esempio n. 5
0
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;
}