diff --git a/src/preferences/time/Jamfile b/src/preferences/time/Jamfile index 5d32a5efec..dc23491d5f 100644 --- a/src/preferences/time/Jamfile +++ b/src/preferences/time/Jamfile @@ -20,6 +20,7 @@ Preference Time : TZDisplay.cpp ZoneView.cpp DateTime.cpp + SettingsView.cpp : be : Time.rdef ; diff --git a/src/preferences/time/SettingsView.cpp b/src/preferences/time/SettingsView.cpp new file mode 100644 index 0000000000..6855172b08 --- /dev/null +++ b/src/preferences/time/SettingsView.cpp @@ -0,0 +1,152 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Julun + */ + +#include "SettingsView.h" +#include "TimeMessages.h" + + +#include +#include +#include +#include +#include +#include + + +const uint32 kMsgMilTime = 'MilT'; +const uint32 kMsgEuroDate = 'EDat'; +const uint32 kMsgShowSeconds = 'ShSc'; + +const uint32 kYearMonthDay = '_ymd'; +const uint32 kDayMonthYear = '_dmy'; +const uint32 kMonthDayYear = '_mdy'; +const uint32 kSeparatorChanged = '_tsc'; +const uint32 kTrackerDateFormatChanged = 'TDFC'; + + +SettingsView::SettingsView(BRect frame) + : BView(frame,"Settings", B_FOLLOW_ALL, + B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), + fInitialized(false) +{ +} + + +SettingsView::~SettingsView() +{ +} + + +void +SettingsView::AttachedToWindow() +{ + if (Parent()) + SetViewColor(Parent()->ViewColor()); + + if (!fInitialized) { + _InitView(); + fInitialized = true; + } +} + + +void +SettingsView::MessageReceived(BMessage *message) +{ + BView::MessageReceived(message); +} + + +void +SettingsView::_InitView() +{ + BRect bounds(Bounds()); + bounds.InsetBy(10.0, 10.0); + + BRect frameLeft(Bounds()); + frameLeft.right = frameLeft.Width() / 2; + frameLeft.InsetBy(10.0f, 10.0f); + + BStringView *timeSettings = new BStringView(frameLeft, "time", "Time:"); + AddChild(timeSettings); + timeSettings->ResizeToPreferred(); + + frameLeft.OffsetBy(10.0, timeSettings->Bounds().Height() + 5.0); + fShow24Hours = new BCheckBox(frameLeft, "show24Hours", "24 Hour Clock" + , new BMessage(kMsgMilTime)); + AddChild(fShow24Hours); + fShow24Hours->ResizeToPreferred(); + + frameLeft.OffsetBy(0.0, fShow24Hours->Bounds().Height() + 5.0); + fShowSeconds = new BCheckBox(frameLeft, "showSeconds", "Show Seconds" + , new BMessage(kMsgShowSeconds)); + AddChild(fShowSeconds); + fShowSeconds->ResizeToPreferred(); + + frameLeft.OffsetBy(0.0, 2 * fShowSeconds->Bounds().Height() + 5.0); + fGmtTime = new BRadioButton(frameLeft, "gmtTime", "Set clock to GMT" + , new BMessage(kRTCUpdate)); + AddChild(fGmtTime); + fGmtTime->ResizeToPreferred(); + + frameLeft.OffsetBy(0.0, fGmtTime->Bounds().Height() + 5.0); + fLocalTime = new BRadioButton(frameLeft, "local", "Set clock to local time", + new BMessage(kRTCUpdate)); + AddChild(fLocalTime); + fLocalTime->ResizeToPreferred(); + fLocalTime->SetValue(B_CONTROL_ON); + + BRect frameRight(Bounds()); + frameRight.left = frameRight.Width() / 2; + frameRight.InsetBy(10.0f, 10.0f); + + BStringView *dateSettings = new BStringView(frameRight, "date", "Date:"); + AddChild(dateSettings); + dateSettings->ResizeToPreferred(); + + frameRight.OffsetBy(10.0, dateSettings->Bounds().Height() + 5.0); + fYearMonthDay = new BCheckBox(frameRight, "yearMonthDay", "Year-Month-Day" + , new BMessage(kYearMonthDay)); + AddChild(fYearMonthDay); + fYearMonthDay->ResizeToPreferred(); + + frameRight.OffsetBy(0.0, fYearMonthDay->Bounds().Height() + 5.0); + fDayMonthYear = new BCheckBox(frameRight, "dayMonthYear", "Day-Month-Year" + , new BMessage(kDayMonthYear)); + AddChild(fDayMonthYear); + fDayMonthYear->ResizeToPreferred(); + + frameRight.OffsetBy(0.0, fDayMonthYear->Bounds().Height() + 5.0); + fMonthDayYear = new BCheckBox(frameRight, "monthDayYear", "Month-Day-Year" + , new BMessage(kMonthDayYear)); + AddChild(fMonthDayYear); + fMonthDayYear->ResizeToPreferred(); + fMonthDayYear->SetValue(B_CONTROL_ON); + + frameRight.OffsetBy(0.0, fMonthDayYear->Bounds().Height() + 5.0); + fStartWeekMonday = new BCheckBox(frameRight, "startWeekMonday" + , "Start week with Monday", new BMessage(kWeekStart)); + AddChild(fStartWeekMonday); + fStartWeekMonday->ResizeToPreferred(); + + fDateSeparator = new BPopUpMenu("Separator"); + fDateSeparator->AddItem(new BMenuItem("-", new BMessage(kSeparatorChanged))); + BMenuItem *item = new BMenuItem("/", new BMessage(kSeparatorChanged)); + fDateSeparator->AddItem(item); + item->SetMarked(true); + fDateSeparator->AddItem(new BMenuItem("\\", new BMessage(kSeparatorChanged))); + fDateSeparator->AddItem(new BMenuItem(".", new BMessage(kSeparatorChanged))); + fDateSeparator->AddItem(new BMenuItem("None", new BMessage(kSeparatorChanged))); + fDateSeparator->AddItem(new BMenuItem("Space", new BMessage(kSeparatorChanged))); + + frameRight.OffsetBy(0.0, fStartWeekMonday->Bounds().Height() + 5.0); + BMenuField *menuField = new BMenuField(frameRight, "regions", "Date separator:" + , fDateSeparator, false); + AddChild(menuField); + menuField->ResizeToPreferred(); +} diff --git a/src/preferences/time/SettingsView.h b/src/preferences/time/SettingsView.h new file mode 100644 index 0000000000..cb5ae46817 --- /dev/null +++ b/src/preferences/time/SettingsView.h @@ -0,0 +1,48 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Julun + */ +#ifndef SETTINGS_VIEW_H +#define SETTINGS_VIEW_H + + +#include + + +class BCheckBox; +class BMessage; +class BPopUpMenu; +class BRadioButton; + + +class SettingsView : public BView { + public: + SettingsView(BRect frame); + virtual ~SettingsView(); + + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage *message); + + private: + void _InitView(); + + private: + BCheckBox *fShow24Hours; + BCheckBox *fShowSeconds; + BRadioButton *fGmtTime; + BRadioButton *fLocalTime; + + BCheckBox *fYearMonthDay; + BCheckBox *fDayMonthYear; + BCheckBox *fMonthDayYear; + BCheckBox *fStartWeekMonday; + + BPopUpMenu *fDateSeparator; + + bool fInitialized; +}; + +#endif // SETTINGS_VIEW_H diff --git a/src/preferences/time/TimeWindow.cpp b/src/preferences/time/TimeWindow.cpp index 72631af4b5..9c2bdcf749 100644 --- a/src/preferences/time/TimeWindow.cpp +++ b/src/preferences/time/TimeWindow.cpp @@ -13,6 +13,7 @@ #include "DateTimeView.h" #include "TimeMessages.h" #include "ZoneView.h" +#include "SettingsView.h" #include @@ -91,18 +92,23 @@ TTimeWindow::_InitWindow() fDateTimeView = new DateTimeView(bounds); fBaseView->StartWatchingAll(fDateTimeView); - fTimeZones = new TZoneView(bounds); - fBaseView->StartWatchingAll(fTimeZones); - - // add tabs BTab *tab = new BTab(); tabview->AddTab(fDateTimeView, tab); tab->SetLabel("Date & Time"); - + + fTimeZones = new TZoneView(bounds); + fBaseView->StartWatchingAll(fTimeZones); + tab = new BTab(); tabview->AddTab(fTimeZones, tab); tab->SetLabel("Time Zone"); - + + fSettingsView = new SettingsView(bounds); + + tab = new BTab(); + tabview->AddTab(fSettingsView, tab); + tab->SetLabel("Settings"); + fBaseView->AddChild(tabview); float width; diff --git a/src/preferences/time/TimeWindow.h b/src/preferences/time/TimeWindow.h index 251b6c25eb..2a46913d98 100644 --- a/src/preferences/time/TimeWindow.h +++ b/src/preferences/time/TimeWindow.h @@ -18,6 +18,7 @@ class BMessage; class DateTimeView; class TTimeBaseView; class TZoneView; +class SettingsView; class TTimeWindow : public BWindow { @@ -34,6 +35,7 @@ class TTimeWindow : public BWindow { TTimeBaseView *fBaseView; DateTimeView *fDateTimeView; TZoneView *fTimeZones; + SettingsView *fSettingsView; }; #endif // TIME_WINDOW_H