TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) : BView(BRect(0, 0, 1, 1), "Status", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS), fTime(NULL), fBarView(parent), fShelf(new TReplicantShelf(this)), fMultiRowMode(vertical), fMinimumTrayWidth(kMinimumTrayWidth), fAlignmentSupport(false) { // init the minimum window width according to the logo. const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap); if (logoBitmap != NULL) { sMinimumWindowWidth = max_c(sMinimumWindowWidth, 2 * (logoBitmap->Bounds().Width() + 8)); fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth; } BFormattingConventions conventions; BLocale::Default()->GetFormattingConventions(&conventions); bool use24HourClock = conventions.Use24HourClock(); desk_settings* settings = ((TBarApp*)be_app)->Settings(); // Create the time view fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, use24HourClock, settings->showSeconds, settings->showDayOfWeek); }
void TReplicantTray::MessageReceived(BMessage* message) { switch (message->what) { case B_LOCALE_CHANGED: { if (fTime == NULL) return; // Locale may have updated 12/24 hour clock BFormattingConventions conventions; BLocale::Default()->GetFormattingConventions(&conventions); fTime->SetUse24HourClock(conventions.Use24HourClock()); // time string reformat -> realign RealignReplicants(); AdjustPlacement(); break; } case kShowHideTime: // from context menu in clock and in this view ShowHideTime(); break; case kShowSeconds: if (fTime == NULL) return; fTime->SetShowSeconds(!fTime->ShowSeconds()); // time string reformat -> realign RealignReplicants(); AdjustPlacement(); break; case kShowDayOfWeek: if (fTime == NULL) return; fTime->SetShowDayOfWeek(!fTime->ShowDayOfWeek()); // time string reformat -> realign RealignReplicants(); AdjustPlacement(); break; #ifdef DB_ADDONS case B_NODE_MONITOR: HandleEntryUpdate(message); break; #endif default: BView::MessageReceived(message); break; } }
void FormatSettingsView::MessageReceived(BMessage* message) { switch (message->what) { case B_LOCALE_CHANGED: { // Time updated 12/24 hour clock BFormattingConventions conventions; BLocale::Default()->GetFormattingConventions(&conventions); if (conventions.Use24HourClock()) f24HourRadioButton->SetValue(B_CONTROL_ON); else f12HourRadioButton->SetValue(B_CONTROL_ON); _UpdateExamples(); Window()->PostMessage(kMsgSettingsChanged); break; } case kClockFormatChange: { BFormattingConventions conventions; BLocale::Default()->GetFormattingConventions(&conventions); conventions.SetExplicitUse24HourClock( f24HourRadioButton->Value() == B_CONTROL_ON); MutableLocaleRoster::Default()->SetDefaultFormattingConventions( conventions); _UpdateExamples(); Window()->PostMessage(kMsgSettingsChanged); break; } case kStringsLanguageChange: { BFormattingConventions conventions; BLocale::Default()->GetFormattingConventions(&conventions); conventions.SetUseStringsFromPreferredLanguage( fUseLanguageStringsCheckBox->Value() ? true : false); MutableLocaleRoster::Default()->SetDefaultFormattingConventions( conventions); _UpdateExamples(); Window()->PostMessage(kMsgSettingsChanged); break; } default: BView::MessageReceived(message); } }
void FormatSettingsView::Refresh(bool setInitial) { BFormattingConventions conventions; BLocale::Default()->GetFormattingConventions(&conventions); if (setInitial) fInitialConventions = conventions; if (!conventions.Use24HourClock()) { f12HourRadioButton->SetValue(B_CONTROL_ON); fLocaleIs24Hour = false; } else { f24HourRadioButton->SetValue(B_CONTROL_ON); fLocaleIs24Hour = true; } fUseLanguageStringsCheckBox->SetValue( conventions.UseStringsFromPreferredLanguage() ? B_CONTROL_ON : B_CONTROL_OFF); _UpdateExamples(); }