* basic settings view, not functional atm...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22608 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich 2007-10-17 23:28:43 +00:00
parent 23b034566f
commit 77f02aaead
5 changed files with 215 additions and 6 deletions

View File

@ -20,6 +20,7 @@ Preference Time :
TZDisplay.cpp
ZoneView.cpp
DateTime.cpp
SettingsView.cpp
: be
: Time.rdef
;

View File

@ -0,0 +1,152 @@
/*
* Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Julun <host.haiku@gmx.de>
*/
#include "SettingsView.h"
#include "TimeMessages.h"
#include <CheckBox.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <StringView.h>
#include <RadioButton.h>
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();
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Julun <host.haiku@gmx.de>
*/
#ifndef SETTINGS_VIEW_H
#define SETTINGS_VIEW_H
#include <View.h>
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

View File

@ -13,6 +13,7 @@
#include "DateTimeView.h"
#include "TimeMessages.h"
#include "ZoneView.h"
#include "SettingsView.h"
#include <Application.h>
@ -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;

View File

@ -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