* code cleanup, small refactoring
* make the panel font sensitve within the possible plain font range git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22633 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9db35b6825
commit
85b69a9437
@ -183,8 +183,8 @@ OffscreenClock::_DrawHands(float x, float y, float radius,
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TAnalogClock::TAnalogClock(BRect frame, const char *name, uint32 resizeMask, uint32 flags)
|
||||
: BView(frame, name, resizeMask, flags | B_DRAW_ON_CHILDREN),
|
||||
TAnalogClock::TAnalogClock(BRect frame, const char *name)
|
||||
: BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_DRAW_ON_CHILDREN),
|
||||
fBitmap(NULL),
|
||||
fClock(NULL)
|
||||
{
|
||||
|
@ -19,8 +19,7 @@ class OffscreenClock;
|
||||
|
||||
class TAnalogClock : public BView {
|
||||
public:
|
||||
TAnalogClock(BRect frame, const char *name,
|
||||
uint32 resizeMask, uint32 flags);
|
||||
TAnalogClock(BRect frame, const char *name);
|
||||
virtual ~TAnalogClock();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
TTimeBaseView::TTimeBaseView(BRect frame, const char *name)
|
||||
: BView(frame, name, B_FOLLOW_ALL_SIDES, B_PULSE_NEEDED),
|
||||
: BView(frame, name, B_FOLLOW_NONE, B_PULSE_NEEDED),
|
||||
fMessage(H_TIME_UPDATE)
|
||||
{
|
||||
}
|
||||
|
@ -27,9 +27,6 @@
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||
#include <syscalls.h>
|
||||
#else
|
||||
@ -39,12 +36,13 @@ void _kset_tzfilename_(const char *name, size_t length, bool isGMT);
|
||||
|
||||
|
||||
DateTimeView::DateTimeView(BRect frame)
|
||||
: BView(frame,"Settings", B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP),
|
||||
: BView(frame, "dateTimeView", B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE_JUMP),
|
||||
fGmtTime(NULL),
|
||||
fUseGmtTime(false),
|
||||
fInitialized(false)
|
||||
{
|
||||
_ReadRTCSettings();
|
||||
_InitView();
|
||||
}
|
||||
|
||||
|
||||
@ -61,8 +59,11 @@ DateTimeView::AttachedToWindow()
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
|
||||
if (!fInitialized) {
|
||||
_InitView();
|
||||
fInitialized = true;
|
||||
|
||||
fGmtTime->SetTarget(this);
|
||||
fLocalTime->SetTarget(this);
|
||||
fCalendarView->SetTarget(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,8 +77,8 @@ DateTimeView::Draw(BRect /*updateRect*/)
|
||||
|
||||
//draw a separator line
|
||||
BRect bounds(Bounds());
|
||||
BPoint start(bounds.Width() / 2.0f + 2.0f, bounds.top + 2.0f);
|
||||
BPoint end(bounds.Width() / 2.0 + 2.0f, bounds.bottom - 2.0f);
|
||||
BPoint start(bounds.Width() / 2.0f, bounds.top + 5.0f);
|
||||
BPoint end(bounds.Width() / 2.0, bounds.bottom - 5.0f);
|
||||
|
||||
BeginLineArray(2);
|
||||
AddLine(start, end, dark);
|
||||
@ -118,6 +119,7 @@ DateTimeView::MessageReceived(BMessage *message)
|
||||
} break;
|
||||
|
||||
case kRTCUpdate:
|
||||
fUseGmtTime = !fUseGmtTime;
|
||||
_UpdateGmtSettings();
|
||||
break;
|
||||
|
||||
@ -128,95 +130,69 @@ DateTimeView::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DateTimeView::GetPreferredSize(float *width, float *height)
|
||||
{
|
||||
// hardcode in TimeWindow ...
|
||||
*width = 470.0f;
|
||||
*height = 227.0f;
|
||||
|
||||
if (fInitialized) {
|
||||
// we are initialized
|
||||
*width = Bounds().Width();
|
||||
*height = fGmtTime->Frame().bottom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DateTimeView::_InitView()
|
||||
{
|
||||
font_height fontHeight;
|
||||
be_plain_font->GetHeight(&fontHeight);
|
||||
float textHeight = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
|
||||
float textHeight = fontHeight.descent + fontHeight.ascent
|
||||
+ fontHeight.leading + 6.0; // 6px border
|
||||
|
||||
// left side
|
||||
BRect frameLeft(Bounds());
|
||||
frameLeft.right = frameLeft.Width() / 2.0;
|
||||
frameLeft.InsetBy(10.0f, 10.0f);
|
||||
frameLeft.bottom = frameLeft.top + textHeight + 6.0;
|
||||
BRect bounds = Bounds();
|
||||
bounds.InsetBy(10.0, 10.0);
|
||||
bounds.top += textHeight + 10.0;
|
||||
|
||||
fDateEdit = new TDateEdit(frameLeft, "date_edit", 3);
|
||||
AddChild(fDateEdit);
|
||||
|
||||
frameLeft.top = fDateEdit->Frame().bottom + 10;
|
||||
frameLeft.bottom = Bounds().bottom - 10;
|
||||
|
||||
fCalendarView = new BCalendarView(frameLeft, "calendar");
|
||||
fCalendarView = new BCalendarView(bounds, "calendar");
|
||||
fCalendarView->SetWeekNumberHeaderVisible(false);
|
||||
AddChild(fCalendarView);
|
||||
fCalendarView->ResizeToPreferred();
|
||||
fCalendarView->SetSelectionMessage(new BMessage(kDayChanged));
|
||||
fCalendarView->SetInvocationMessage(new BMessage(kDayChanged));
|
||||
fCalendarView->SetTarget(this);
|
||||
|
||||
// right side
|
||||
BRect frameRight(Bounds());
|
||||
frameRight.left = frameRight.Width() / 2.0;
|
||||
frameRight.InsetBy(10.0f, 10.0f);
|
||||
frameRight.bottom = frameRight.top + textHeight + 6.0;
|
||||
bounds.top -= textHeight + 10.0;
|
||||
bounds.bottom = bounds.top + textHeight;
|
||||
bounds.right = fCalendarView->Frame().right;
|
||||
|
||||
fTimeEdit = new TTimeEdit(frameRight, "time_edit", 4);
|
||||
fDateEdit = new TDateEdit(bounds, "dateEdit", 3);
|
||||
AddChild(fDateEdit);
|
||||
AddChild(fCalendarView);
|
||||
|
||||
// right side, 2px extra for separator
|
||||
bounds.OffsetBy(bounds.Width() + 22.0, 0.0);
|
||||
fTimeEdit = new TTimeEdit(bounds, "timeEdit", 4);
|
||||
AddChild(fTimeEdit);
|
||||
|
||||
frameRight.top = fTimeEdit->Frame().bottom + 10.0;
|
||||
frameRight.bottom = Bounds().bottom - 10.0;
|
||||
bounds = fCalendarView->Frame();
|
||||
bounds.OffsetBy(bounds.Width() + 22.0, 0.0);
|
||||
|
||||
float left = fTimeEdit->Frame().left;
|
||||
float tmp = MIN(frameRight.Width(), frameRight.Height());
|
||||
frameRight.left = left + (fTimeEdit->Bounds().Width() - tmp) / 2.0;
|
||||
frameRight.bottom = frameRight.top + tmp;
|
||||
frameRight.right = frameRight.left + tmp;
|
||||
|
||||
fClock = new TAnalogClock(frameRight, "analog clock", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
fClock = new TAnalogClock(bounds, "analogClock");
|
||||
AddChild(fClock);
|
||||
|
||||
// clock radio buttons
|
||||
frameRight.left = left;
|
||||
frameRight.top = fClock->Frame().bottom + 10.0;
|
||||
BStringView *text = new BStringView(frameRight, "clockis", "Clock set to:");
|
||||
bounds.top = fClock->Frame().bottom + 10.0;
|
||||
BStringView *text = new BStringView(bounds, "clockSetTo", "Clock set to:");
|
||||
AddChild(text);
|
||||
text->ResizeToPreferred();
|
||||
|
||||
frameRight.left += 10.0f;
|
||||
frameRight.top = text->Frame().bottom + 5.0;
|
||||
|
||||
fLocalTime = new BRadioButton(frameRight, "local", "Local time",
|
||||
bounds.left += 10.0f;
|
||||
bounds.top = text->Frame().bottom;
|
||||
fLocalTime = new BRadioButton(bounds, "localTime", "Local Time",
|
||||
new BMessage(kRTCUpdate));
|
||||
AddChild(fLocalTime);
|
||||
fLocalTime->ResizeToPreferred();
|
||||
fLocalTime->SetTarget(this);
|
||||
|
||||
frameRight.left = fLocalTime->Frame().right +10.0f;
|
||||
|
||||
fGmtTime = new BRadioButton(frameRight, "gmt", "GMT", new BMessage(kRTCUpdate));
|
||||
bounds.left = fLocalTime->Frame().right + 10.0;
|
||||
fGmtTime = new BRadioButton(bounds, "greenwichMeanTime", "GMT",
|
||||
new BMessage(kRTCUpdate));
|
||||
AddChild(fGmtTime);
|
||||
fGmtTime->ResizeToPreferred();
|
||||
fGmtTime->SetTarget(this);
|
||||
|
||||
if (fIsLocalTime)
|
||||
fLocalTime->SetValue(B_CONTROL_ON);
|
||||
else
|
||||
if (fUseGmtTime)
|
||||
fGmtTime->SetValue(B_CONTROL_ON);
|
||||
else
|
||||
fLocalTime->SetValue(B_CONTROL_ON);
|
||||
|
||||
ResizeTo(fClock->Frame().right + 10.0, fGmtTime->Frame().bottom + 10.0);
|
||||
}
|
||||
|
||||
|
||||
@ -228,26 +204,18 @@ DateTimeView::_ReadRTCSettings()
|
||||
return;
|
||||
|
||||
path.Append("RTC_time_settings");
|
||||
|
||||
BFile file;
|
||||
|
||||
BEntry entry(path.Path());
|
||||
if (entry.Exists()) {
|
||||
file.SetTo(&entry, B_READ_ONLY);
|
||||
BFile file(&entry, B_READ_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
char localTime[6];
|
||||
file.Read(localTime, 6);
|
||||
BString text(localTime);
|
||||
if (text.Compare("local", 4) == 0)
|
||||
fIsLocalTime = true;
|
||||
else
|
||||
fIsLocalTime = false;
|
||||
char buffer[6];
|
||||
file.Read(buffer, 6);
|
||||
if (strncmp(buffer, "gmt", 3) == 0)
|
||||
fUseGmtTime = true;
|
||||
}
|
||||
} else {
|
||||
// create set to local
|
||||
fIsLocalTime = true;
|
||||
file.SetTo(&entry, B_CREATE_FILE | B_READ_WRITE);
|
||||
file.Write("local", 5);
|
||||
}
|
||||
} else
|
||||
_UpdateGmtSettings();
|
||||
}
|
||||
|
||||
|
||||
@ -262,10 +230,10 @@ DateTimeView::_WriteRTCSettings()
|
||||
|
||||
BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
|
||||
if (file.InitCheck() == B_OK) {
|
||||
if (fLocalTime->Value() == B_CONTROL_ON)
|
||||
file.Write("local", 5);
|
||||
else
|
||||
if (fUseGmtTime)
|
||||
file.Write("gmt", 3);
|
||||
else
|
||||
file.Write("local", 5);
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,8 +256,7 @@ DateTimeView::_UpdateGmtSettings()
|
||||
entry.GetPath(&path);
|
||||
|
||||
// take the existing timezone and set it's gmt use
|
||||
_kern_set_tzfilename(path.Path(), B_PATH_NAME_LENGTH
|
||||
, fGmtTime->Value() == B_CONTROL_ON);
|
||||
_kern_set_tzfilename(path.Path(), B_PATH_NAME_LENGTH, fUseGmtTime);
|
||||
}
|
||||
|
||||
|
||||
@ -314,7 +281,7 @@ DateTimeView::_UpdateDateTime(BMessage *message)
|
||||
&& message->FindInt32("minute", &minute) == B_OK
|
||||
&& message->FindInt32("second", &second) == B_OK)
|
||||
{
|
||||
fTimeEdit->SetTime(hour, minute, second);
|
||||
fClock->SetTime(hour, minute, second);
|
||||
fTimeEdit->SetTime(hour, minute, second);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ class DateTimeView : public BView {
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updaterect);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
|
||||
private:
|
||||
void _InitView();
|
||||
@ -46,7 +45,7 @@ class DateTimeView : public BView {
|
||||
BCalendarView *fCalendarView;
|
||||
TAnalogClock *fClock;
|
||||
|
||||
bool fIsLocalTime;
|
||||
bool fUseGmtTime;
|
||||
bool fInitialized;
|
||||
};
|
||||
|
||||
|
@ -19,8 +19,8 @@ namespace {
|
||||
{
|
||||
font_height fontHeight;
|
||||
be_plain_font->GetHeight(&fontHeight);
|
||||
float height = ceil(fontHeight.descent) + ceil(fontHeight.ascent)
|
||||
+ ceil(fontHeight.leading);
|
||||
float height = ceil(fontHeight.descent + fontHeight.ascent
|
||||
+ fontHeight.leading);
|
||||
return height;
|
||||
}
|
||||
}
|
||||
@ -51,28 +51,28 @@ TTZDisplay::AttachedToWindow()
|
||||
void
|
||||
TTZDisplay::ResizeToPreferred()
|
||||
{
|
||||
float height = _FontHeight();
|
||||
ResizeTo(Bounds().Width(), height *2);
|
||||
ResizeTo(Bounds().Width(), _FontHeight() * 2.0 + 4.0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TTZDisplay::Draw(BRect /* updateRect */)
|
||||
{
|
||||
BRect bounds(Bounds());
|
||||
SetLowColor(ViewColor());
|
||||
FillRect(bounds, B_SOLID_LOW);
|
||||
|
||||
float height = _FontHeight();
|
||||
|
||||
BPoint drawpt(bounds.left +2, height /2.0 +1);
|
||||
DrawString(fLabel.String(), drawpt);
|
||||
|
||||
drawpt.y += height +2;
|
||||
DrawString(fText.String(), drawpt);
|
||||
BRect bounds = Bounds();
|
||||
FillRect(Bounds(), B_SOLID_LOW);
|
||||
|
||||
drawpt.x = bounds.right -be_plain_font->StringWidth(fTime.String()) - 2;
|
||||
DrawString(fTime.String(), drawpt);
|
||||
float fontHeight = _FontHeight();
|
||||
|
||||
BPoint pt(bounds.left + 2.0, fontHeight / 2.0 + 2.0);
|
||||
DrawString(fLabel.String(), pt);
|
||||
|
||||
pt.y += fontHeight;
|
||||
DrawString(fText.String(), pt);
|
||||
|
||||
pt.x = bounds.right - StringWidth(fTime.String()) - 2.0;
|
||||
DrawString(fTime.String(), pt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ TTimeWindow::QuitRequested()
|
||||
{
|
||||
TimeSettings().SetLeftTop(Frame().LeftTop());
|
||||
|
||||
fBaseView->StopWatchingAll(fTimeZones);
|
||||
fBaseView->StopWatchingAll(fTimeZoneView);
|
||||
fBaseView->StopWatchingAll(fDateTimeView);
|
||||
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
@ -75,40 +75,35 @@ TTimeWindow::_InitWindow()
|
||||
{
|
||||
SetPulseRate(500000);
|
||||
|
||||
BRect bounds(Bounds());
|
||||
fDateTimeView = new DateTimeView(Bounds());
|
||||
|
||||
fBaseView = new TTimeBaseView(bounds, "background view");
|
||||
BRect bounds = fDateTimeView->Bounds();
|
||||
fTimeZoneView = new TimeZoneView(bounds);
|
||||
|
||||
fBaseView = new TTimeBaseView(bounds, "baseView");
|
||||
AddChild(fBaseView);
|
||||
|
||||
bounds.top = 9;
|
||||
BTabView *tabview = new BTabView(bounds, "tab_view");
|
||||
|
||||
bounds = tabview->Bounds();
|
||||
bounds.InsetBy(4, 6);
|
||||
bounds.bottom -= tabview->TabHeight();
|
||||
|
||||
fDateTimeView = new DateTimeView(bounds);
|
||||
fBaseView->StartWatchingAll(fDateTimeView);
|
||||
fBaseView->StartWatchingAll(fTimeZoneView);
|
||||
|
||||
bounds.OffsetBy(10.0, 10.0);
|
||||
BTabView *tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
|
||||
"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
|
||||
|
||||
BTab *tab = new BTab();
|
||||
tabview->AddTab(fDateTimeView, tab);
|
||||
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");
|
||||
tabView->AddTab(fTimeZoneView, tab);
|
||||
tab->SetLabel("Timezone");
|
||||
|
||||
fBaseView->AddChild(tabview);
|
||||
fBaseView->AddChild(tabView);
|
||||
tabView->ResizeBy(0.0, tabView->TabHeight());
|
||||
fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0,
|
||||
tabView->Bounds().Height() + 10.0);
|
||||
|
||||
float width;
|
||||
float height;
|
||||
fDateTimeView->GetPreferredSize(&width, &height);
|
||||
|
||||
// width/ height from DateTimeView + all InsetBy etc..
|
||||
ResizeTo(width +10, height + tabview->TabHeight() +25);
|
||||
ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
class BMessage;
|
||||
class DateTimeView;
|
||||
class TTimeBaseView;
|
||||
class TZoneView;
|
||||
class TimeZoneView;
|
||||
|
||||
|
||||
class TTimeWindow : public BWindow {
|
||||
@ -35,7 +35,7 @@ class TTimeWindow : public BWindow {
|
||||
private:
|
||||
TTimeBaseView *fBaseView;
|
||||
DateTimeView *fDateTimeView;
|
||||
TZoneView *fTimeZones;
|
||||
TimeZoneView *fTimeZoneView;
|
||||
};
|
||||
|
||||
#endif // TIME_WINDOW_H
|
||||
|
@ -58,32 +58,33 @@ class TZoneItem : public BStringItem {
|
||||
};
|
||||
|
||||
|
||||
TZoneView::TZoneView(BRect frame)
|
||||
: BView(frame, B_EMPTY_STRING, B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE_JUMP),
|
||||
fNotInitialized(true)
|
||||
TimeZoneView::TimeZoneView(BRect frame)
|
||||
: BView(frame, "timeZoneView", B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE_JUMP),
|
||||
fInitialized(false)
|
||||
{
|
||||
ReadTimeZoneLink();
|
||||
InitView();
|
||||
}
|
||||
|
||||
|
||||
TZoneView::~TZoneView()
|
||||
TimeZoneView::~TimeZoneView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TZoneView::AttachedToWindow()
|
||||
TimeZoneView::AttachedToWindow()
|
||||
{
|
||||
if (Parent())
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
|
||||
if (fNotInitialized) {
|
||||
// stupid hack
|
||||
fRegionPopUp->SetTargetForItems(this);
|
||||
if (!fInitialized) {
|
||||
fInitialized = true;
|
||||
|
||||
fSetZone->SetTarget(this);
|
||||
fCityList->SetTarget(this);
|
||||
|
||||
fRegionPopUp->SetTargetForItems(this);
|
||||
|
||||
// update displays
|
||||
BPath parent;
|
||||
fCurrentZone.GetParent(&parent);
|
||||
@ -92,15 +93,13 @@ TZoneView::AttachedToWindow()
|
||||
fCityList->Select(czone);
|
||||
fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text());
|
||||
}
|
||||
fNotInitialized = false;
|
||||
ResizeTo(Bounds().Width(), Bounds().Height() +40);
|
||||
}
|
||||
fCityList->ScrollToSelection();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TZoneView::MessageReceived(BMessage *message)
|
||||
TimeZoneView::MessageReceived(BMessage *message)
|
||||
{
|
||||
int32 change;
|
||||
switch(message->what) {
|
||||
@ -135,15 +134,8 @@ TZoneView::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
TZoneView::TimeZone()
|
||||
{
|
||||
return fCurrent->Text();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TZoneView::UpdateDateTime(BMessage *message)
|
||||
TimeZoneView::UpdateDateTime(BMessage *message)
|
||||
{
|
||||
int32 hour;
|
||||
int32 minute;
|
||||
@ -165,58 +157,53 @@ TZoneView::UpdateDateTime(BMessage *message)
|
||||
|
||||
|
||||
void
|
||||
TZoneView::InitView()
|
||||
TimeZoneView::InitView()
|
||||
{
|
||||
font_height fontHeight;
|
||||
be_plain_font->GetHeight(&fontHeight);
|
||||
float textHeight = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
|
||||
|
||||
// Zone menu
|
||||
fRegionPopUp = new BPopUpMenu(B_EMPTY_STRING, true, true, B_ITEMS_IN_COLUMN);
|
||||
fRegionPopUp = new BPopUpMenu("", true, true, B_ITEMS_IN_COLUMN);
|
||||
|
||||
BuildRegionMenu();
|
||||
|
||||
// left side
|
||||
BRect frameLeft(Bounds());
|
||||
frameLeft.right = frameLeft.Width() / 2;
|
||||
frameLeft.right = frameLeft.Width() / 2.0;
|
||||
frameLeft.InsetBy(10.0f, 10.0f);
|
||||
|
||||
BMenuField *menuField = new BMenuField(frameLeft, "regions", NULL, fRegionPopUp, false);
|
||||
AddChild(menuField);
|
||||
menuField->ResizeToPreferred();
|
||||
|
||||
frameLeft.top = menuField->Frame().bottom +10;
|
||||
frameLeft.top = menuField->Frame().bottom + 10.0;
|
||||
frameLeft.right -= B_V_SCROLL_BAR_WIDTH;
|
||||
|
||||
// City Listing
|
||||
fCityList = new BListView(frameLeft, "cityList", B_SINGLE_SELECTION_LIST,
|
||||
B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS);
|
||||
fCityList = new BListView(frameLeft, "cityList", B_SINGLE_SELECTION_LIST);
|
||||
fCityList->SetSelectionMessage(new BMessage(H_CITY_CHANGED));
|
||||
fCityList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE));
|
||||
|
||||
BScrollView *scrollList = new BScrollView("scroll_list", fCityList,
|
||||
BScrollView *scrollList = new BScrollView("scrollList", fCityList,
|
||||
B_FOLLOW_ALL, 0, false, true);
|
||||
AddChild(scrollList);
|
||||
|
||||
// right side
|
||||
BRect frameRight(Bounds());
|
||||
frameRight.left = frameRight.Width() / 2;
|
||||
frameRight.left = frameRight.Width() / 2.0;
|
||||
frameRight.InsetBy(10.0f, 10.0f);
|
||||
frameRight.top = frameLeft.top;
|
||||
|
||||
// Time Displays
|
||||
fCurrent = new TTZDisplay(frameRight, "current", "Current time:");
|
||||
fCurrent = new TTZDisplay(frameRight, "currentTime", "Current time:");
|
||||
AddChild(fCurrent);
|
||||
fCurrent->ResizeToPreferred();
|
||||
|
||||
frameRight.OffsetBy(0, (textHeight) * 3 +10.0);
|
||||
fPreview = new TTZDisplay(frameRight, "preview", "Preview time:");
|
||||
frameRight.top = fCurrent->Frame().bottom + 10.0;
|
||||
fPreview = new TTZDisplay(frameRight, "previewTime", "Preview time:");
|
||||
AddChild(fPreview);
|
||||
fPreview->ResizeToPreferred();
|
||||
|
||||
// set button
|
||||
fSetZone = new BButton(frameRight, "set", "Set Timezone",
|
||||
new BMessage(H_SET_TIME_ZONE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
fSetZone = new BButton(frameRight, "setTimeZone", "Set Time Zone",
|
||||
new BMessage(H_SET_TIME_ZONE));
|
||||
AddChild(fSetZone);
|
||||
fSetZone->SetEnabled(false);
|
||||
fSetZone->ResizeToPreferred();
|
||||
@ -227,7 +214,7 @@ TZoneView::InitView()
|
||||
|
||||
|
||||
void
|
||||
TZoneView::BuildRegionMenu()
|
||||
TimeZoneView::BuildRegionMenu()
|
||||
{
|
||||
BPath path;
|
||||
if (find_directory(B_BEOS_ETC_DIRECTORY, &path) != B_OK)
|
||||
@ -280,7 +267,7 @@ TZoneView::BuildRegionMenu()
|
||||
|
||||
|
||||
int32
|
||||
TZoneView::FillCityList(const char *area)
|
||||
TimeZoneView::FillCityList(const char *area)
|
||||
{
|
||||
// clear list
|
||||
int32 count = fCityList->CountItems();
|
||||
@ -334,7 +321,7 @@ TZoneView::FillCityList(const char *area)
|
||||
|
||||
|
||||
void
|
||||
TZoneView::ChangeRegion(BMessage *message)
|
||||
TimeZoneView::ChangeRegion(BMessage *message)
|
||||
{
|
||||
BString area;
|
||||
message->FindString("region", &area);
|
||||
@ -344,7 +331,7 @@ TZoneView::ChangeRegion(BMessage *message)
|
||||
|
||||
|
||||
void
|
||||
TZoneView::ReadTimeZoneLink()
|
||||
TimeZoneView::ReadTimeZoneLink()
|
||||
{
|
||||
BEntry tzLink;
|
||||
|
||||
@ -387,7 +374,7 @@ TZoneView::ReadTimeZoneLink()
|
||||
|
||||
|
||||
void
|
||||
TZoneView::SetPreview()
|
||||
TimeZoneView::SetPreview()
|
||||
{
|
||||
int32 selection = fCityList->CurrentSelection();
|
||||
if (selection >= 0) {
|
||||
@ -413,7 +400,7 @@ TZoneView::SetPreview()
|
||||
|
||||
|
||||
void
|
||||
TZoneView::SetCurrent(const char *text)
|
||||
TimeZoneView::SetCurrent(const char *text)
|
||||
{
|
||||
SetTimeZone(fCurrentZone.Path());
|
||||
|
||||
@ -426,7 +413,7 @@ TZoneView::SetCurrent(const char *text)
|
||||
|
||||
|
||||
void
|
||||
TZoneView::SetTimeZone()
|
||||
TimeZoneView::SetTimeZone()
|
||||
{
|
||||
/* set time based on supplied timezone. How to do this?
|
||||
1) replace symlink "timezone" in B_USER_SETTINGS_DIR with a link to the new timezone
|
||||
@ -486,7 +473,7 @@ TZoneView::SetTimeZone()
|
||||
|
||||
|
||||
void
|
||||
TZoneView::SetTimeZone(const char *zone)
|
||||
TimeZoneView::SetTimeZone(const char *zone)
|
||||
{
|
||||
putenv(BString("TZ=").Append(zone).String());
|
||||
tzset();
|
||||
|
@ -21,15 +21,13 @@ class BButton;
|
||||
class TTZDisplay;
|
||||
|
||||
|
||||
class TZoneView : public BView {
|
||||
class TimeZoneView : public BView {
|
||||
public:
|
||||
TZoneView(BRect frame);
|
||||
virtual ~TZoneView();
|
||||
TimeZoneView(BRect frame);
|
||||
virtual ~TimeZoneView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
const char* TimeZone();
|
||||
|
||||
private:
|
||||
void UpdateDateTime(BMessage *message);
|
||||
@ -55,7 +53,7 @@ class TZoneView : public BView {
|
||||
int32 fHour;
|
||||
int32 fMinute;
|
||||
BPath fCurrentZone;
|
||||
bool fNotInitialized;
|
||||
bool fInitialized;
|
||||
};
|
||||
|
||||
#endif //Zone_View_H
|
||||
|
Loading…
Reference in New Issue
Block a user