patch by Julun:

* fixed more style issues
* fixed small memory leaks
* refactoring
+ some small changes by myself, added back Michael Berg and Andrew McCall as
  likely authors of most files which had no author information


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22232 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2007-09-14 09:04:03 +00:00
parent b86754c363
commit fd7c0c2ed7
25 changed files with 523 additions and 544 deletions

View File

@ -21,9 +21,8 @@ class OffscreenClock : public BView {
OffscreenClock(BRect frame, const char *name);
~OffscreenClock();
void SetTo(int32 hour, int32 minute, int32 second);
bool IsDirty() const
{ return fDirty; }
void SetTime(int32 hour, int32 minute, int32 second);
bool IsDirty() const { return fDirty; }
void DrawClock();
private:
@ -54,7 +53,7 @@ OffscreenClock::~OffscreenClock()
void
OffscreenClock::SetTo(int32 hour, int32 minute, int32 second)
OffscreenClock::SetTime(int32 hour, int32 minute, int32 second)
{
if (fHours == hour && fMinutes == minute && fSeconds == second)
return;
@ -233,7 +232,7 @@ TAnalogClock::MessageReceived(BMessage *message)
if (message->FindInt32("hour", &hour) == B_OK
&& message->FindInt32("minute", &minute) == B_OK
&& message->FindInt32("second", &second) == B_OK)
SetTo(hour, minute, second);
SetTime(hour, minute, second);
break;
}
default:
@ -260,10 +259,10 @@ TAnalogClock::Draw(BRect /*updateRect*/)
void
TAnalogClock::SetTo(int32 hour, int32 minute, int32 second)
TAnalogClock::SetTime(int32 hour, int32 minute, int32 second)
{
if (fClock)
fClock->SetTo(hour, minute, second);
fClock->SetTime(hour, minute, second);
Invalidate();
}

View File

@ -27,7 +27,7 @@ class TAnalogClock : public BView {
virtual void Draw(BRect updateRect);
virtual void MessageReceived(BMessage *message);
void SetTo(int32 hour, int32 minute, int32 second);
void SetTime(int32 hour, int32 minute, int32 second);
private:
void _InitView(BRect frame);

View File

@ -3,6 +3,8 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/

View File

@ -3,6 +3,8 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/
#ifndef ANALOG_CLOCK_H

View File

@ -146,7 +146,7 @@ TDay::Draw(BRect updaterect)
SetHighColor(bgcolor);
FillRect(bounds);
if (f_day> 0) {
if (f_day > 0) {
if (!(Value() == 1))
SetHighColor(0, 0, 0, 255);
else
@ -207,7 +207,7 @@ TDay::SetTo(int day, bool selected)
f_day = day;
SetValue(selected);
if (Value() == 1) {
SetFlags(Flags()|B_NAVIGABLE);
SetFlags(Flags() | B_NAVIGABLE);
} else {
SetFlags(Flags() & ~B_NAVIGABLE);
}
@ -224,7 +224,7 @@ TCalendarView::TCalendarView(BRect frame, const char *name,
, f_firstday(0)
, f_month(0)
, f_day(0)
,f_year(0)
, f_year(0)
{
InitView();
}
@ -338,20 +338,19 @@ TCalendarView::Draw(BRect updaterect)
{
BRect bounds(0.0, 0.0, f_dayrect.Width(), f_dayrect.Height());
float width = 0;
float x = bounds.Width()/2.0;
BPoint drawpt;
BString day;
SetLowColor(ViewColor());
SetHighColor(0, 0, 0);
float offset = FontHeight(this, true);
BPoint drawpt;
drawpt.y = (bounds.top + bounds.bottom + FontHeight(this, true)) / 2.0;
float width = 0;
float x = bounds.Width() / 2.0;
BString day;
for (int i = 0; i < 7; i++) {
day = BString(&kDays[i], 1);
width = be_plain_font->StringWidth(day.String());
drawpt.x = bounds.left + (x - width / 2.0 + 2);
drawpt.y = bounds.bottom - offset / 2.0;
DrawString(day.String(), drawpt);
bounds.OffsetBy(bounds.Width() + 1, 0);
}

View File

@ -1,9 +1,20 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/
#ifndef CALENDAR_VIEW_H
#define CALENDAR_VIEW_H
#include <Control.h>
#include <View.h>
class TDay: public BControl {
public:
TDay(BRect frame, int day);

View File

@ -1,37 +1,38 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*
*/
#include "DateTimeEdit.h"
#include "DateUtils.h"
#include <List.h>
#include <String.h>
#include <stdio.h>
#define YEAR_DELTA_MAX 110
#define YEAR_DELTA_MIN 64
TDateTimeSection::TDateTimeSection(BRect frame, uint32 data)
: TSection(frame),
fData(data)
{
}
class TDateTimeSection : public TSection {
public:
TDateTimeSection(BRect frame, uint32 data = 0)
: TSection(frame), fData(data) { }
~TDateTimeSection();
uint32 Data() const { return fData; }
void SetData(uint32 data) { fData = data; }
TDateTimeSection::~TDateTimeSection()
{
}
uint32
TDateTimeSection::Data() const
{
return fData;
}
void
TDateTimeSection::SetData(uint32 data)
{
fData = data;
}
private:
uint32 fData;
};
// #pragma mark -
@ -46,32 +47,25 @@ TTimeEdit::TTimeEdit(BRect frame, const char *name, uint32 sections)
TTimeEdit::~TTimeEdit()
{
TSection *section;
if (f_sections->CountItems() > 0) {
for (int32 idx = 0; (section = (TSection *)f_sections->ItemAt(idx)); idx++)
delete section;
}
delete f_sections;
}
void
TTimeEdit::InitView()
{
// make sure we call the base class method, as it
// will create the arrow bitmaps and the section list
TSectionEdit::InitView();
SetSections(f_sectionsarea);
SetSections(fSectionArea);
}
void
TTimeEdit::DrawSection(uint32 index, bool hasFocus)
{
if (f_sections->CountItems() == 0)
printf("No Sections!!!\n");
// user defined section drawing
TDateTimeSection *section;
section = (TDateTimeSection *)f_sections->ItemAt(index);
section = (TDateTimeSection *)fSectionList->ItemAt(index);
BRect bounds = section->Frame();
@ -81,7 +75,7 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
if (hasFocus) {
SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
value = f_holdvalue;
value = fHoldValue;
} else {
SetLowColor(ViewColor());
value = section->Data();
@ -112,7 +106,7 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
break;
case 3: // am/pm
value = ((TDateTimeSection *)f_sections->ItemAt(0))->Data();
value = ((TDateTimeSection *)fSectionList->ItemAt(0))->Data();
if (value >= 12)
text << "PM";
else
@ -125,10 +119,9 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
}
// calc and center text in section rect
float width = be_plain_font->StringWidth(text.String());
BPoint offset(-(bounds.Width()/2.0 -width/2.0) -1.0, bounds.Height()/2.0 -6.0);
BPoint offset(-(bounds.Width() / 2.0 -width / 2.0) -1.0, bounds.Height() / 2.0 -6.0);
BPoint drawpt(bounds.LeftBottom() -offset);
@ -138,27 +131,31 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
}
/*
DrawSeperator(uint32 index) user drawn seperator. Section is the
index of the section in fSectionList or the section to the seps left
*/
void
TTimeEdit::DrawSeperator(uint32 index)
{
/* user drawn seperator. section is the index of the section
in f_sections or the section to the seps left
*/
if (index == 3)
return;
TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(index);
if (index >= 2)
return; // no seperator for am/pm
BString text(":");
uint32 sep;
GetSeperatorWidth(&sep);
TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(index);
BRect bounds = section->Frame();
float sepWidth = SeperatorWidth();
char* sep = ":";
if (index == 2)
sep = "-";
float width = be_plain_font->StringWidth(sep);
float width = be_plain_font->StringWidth(text.String());
BPoint offset(-(sep/2.0 -width/2.0) -1.0, bounds.Height()/2.0 -6.0);
BPoint offset(-(sepWidth / 2.0 - width / 2.0) -1.0, bounds.Height() / 2.0 -6.0);
BPoint drawpt(bounds.RightBottom() -offset);
DrawString(text.String(), drawpt);
DrawString(sep, drawpt);
}
@ -169,67 +166,63 @@ TTimeEdit::SetSections(BRect area)
BRect bounds(area);
// no comp for sep width
uint32 sep_width;
GetSeperatorWidth(&sep_width);
float sepWidth = SeperatorWidth();
float sep_2 = ceil(sep_width/f_sectioncount +1);
float width = bounds.Width()/f_sectioncount -sep_2;
bounds.right = bounds.left +(width -sep_width/f_sectioncount);
float sep_2 = ceil(sepWidth / fSectionCount +1);
float width = bounds.Width() / fSectionCount -sep_2;
bounds.right = bounds.left + (width -sepWidth / fSectionCount);
TDateTimeSection *section;
for (uint32 idx = 0; idx < f_sectioncount; idx++) {
section = new TDateTimeSection(bounds);
f_sections->AddItem(section);
for (uint32 idx = 0; idx < fSectionCount; idx++) {
fSectionList->AddItem(new TDateTimeSection(bounds));
bounds.left = bounds.right +sep_width;
if (idx == f_sectioncount -2)
bounds.left = bounds.right + sepWidth;
if (idx == fSectionCount -2)
bounds.right = area.right -1;
else
bounds.right = bounds.left +(width -sep_2);
bounds.right = bounds.left + (width -sep_2);
}
}
void
TTimeEdit::GetSeperatorWidth(uint32 *width)
float
TTimeEdit::SeperatorWidth() const
{
*width = 8;
return 8.0f;
}
void
TTimeEdit::SectionFocus(uint32 index)
{
f_focus = index;
fFocus = index;
// update hold value
f_holdvalue = ((TDateTimeSection *)f_sections->ItemAt(f_focus))->Data();
fHoldValue = ((TDateTimeSection *)fSectionList->ItemAt(fFocus))->Data();
Draw(Bounds());
}
void
TTimeEdit::SetTo(uint32 hour, uint32 minute, uint32 second)
TTimeEdit::SetTime(uint32 hour, uint32 minute, uint32 second)
{
if (f_sections->CountItems()> 0)
if (fSectionList->CountItems()> 0)
{
bool update = false;
TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(0);
TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(0);
if (section->Data() != hour) {
section->SetData(hour);
update = true;
}
section = (TDateTimeSection *)f_sections->ItemAt(1);
section = (TDateTimeSection *)fSectionList->ItemAt(1);
if (section->Data() != minute) {
section->SetData(minute);
update = true;
}
section = (TDateTimeSection *)f_sections->ItemAt(2);
section = (TDateTimeSection *)fSectionList->ItemAt(2);
if (section->Data() != second) {
section->SetData(second);
update = true;
@ -244,11 +237,11 @@ TTimeEdit::SetTo(uint32 hour, uint32 minute, uint32 second)
void
TTimeEdit::DoUpPress()
{
if (f_focus == -1)
if (fFocus == -1)
SectionFocus(0);
// update displayed value
f_holdvalue += 1;
fHoldValue += 1;
CheckRange();
@ -260,11 +253,11 @@ TTimeEdit::DoUpPress()
void
TTimeEdit::DoDownPress()
{
if (f_focus == -1)
if (fFocus == -1)
SectionFocus(0);
// update display value
f_holdvalue -= 1;
fHoldValue -= 1;
CheckRange();
@ -276,20 +269,18 @@ TTimeEdit::DoDownPress()
void
TTimeEdit::BuildDispatch(BMessage *message)
{
static const char *fields[4] = {"hour", "minute", "second", "isam"};
const char *fields[4] = {"hour", "minute", "second", "isam"};
message->AddBool("time", true);
for (int32 idx = 0; idx < f_sections->CountItems() -1; idx++) {
uint32 data;
for (int32 idx = 0; idx < fSectionList->CountItems() -1; idx++) {
uint32 data = ((TDateTimeSection *)fSectionList->ItemAt(idx))->Data();
if (f_focus == idx)
data = f_holdvalue;
else
data = ((TDateTimeSection *)f_sections->ItemAt(idx))->Data();
if (fFocus == idx)
data = fHoldValue;
if (idx == 3) // isam
message->AddBool("isam", data == 1);
message->AddBool(fields[idx], data == 1);
else
message->AddInt32(fields[idx], data);
}
@ -299,12 +290,12 @@ TTimeEdit::BuildDispatch(BMessage *message)
void
TTimeEdit::CheckRange()
{
int32 value = f_holdvalue;
switch (f_focus) {
int32 value = fHoldValue;
switch (fFocus) {
case 0: // hour
if (value> 23)
value = 0;
else if (value < 0)
else if (value < 0)
value = 23;
break;
@ -325,22 +316,22 @@ TTimeEdit::CheckRange()
case 3:
// modify hour value to reflect change in am/pm
value = ((TDateTimeSection *)f_sections->ItemAt(0))->Data();
value = ((TDateTimeSection *)fSectionList->ItemAt(0))->Data();
if (value < 13)
value += 12;
else
value -= 12;
if (value == 24)
value = 0;
((TDateTimeSection *)f_sections->ItemAt(0))->SetData(value);
((TDateTimeSection *)fSectionList->ItemAt(0))->SetData(value);
break;
default:
return;
}
((TDateTimeSection *)f_sections->ItemAt(f_focus))->SetData(value);
f_holdvalue = value;
((TDateTimeSection *)fSectionList->ItemAt(fFocus))->SetData(value);
fHoldValue = value;
Invalidate(Bounds());
}
@ -348,12 +339,7 @@ TTimeEdit::CheckRange()
// #pragma mark -
const char *months[] = {
"January", "Febuary", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
TDateEdit::TDateEdit(BRect frame, const char *name, uint32 sections)
: TSectionEdit(frame, name, sections)
{
@ -363,32 +349,25 @@ TDateEdit::TDateEdit(BRect frame, const char *name, uint32 sections)
TDateEdit::~TDateEdit()
{
TSection *section;
if (f_sections->CountItems() > 0) {
for (int32 idx = 0; (section = (TSection *)f_sections->ItemAt(idx)); idx++)
delete section;
}
delete f_sections;
}
void
TDateEdit::InitView()
{
// make sure we call the base class method, as it
// will create the arrow bitmaps and the section list
TSectionEdit::InitView();
SetSections(f_sectionsarea);
SetSections(fSectionArea);
}
void
TDateEdit::DrawSection(uint32 index, bool hasFocus)
{
if (f_sections->CountItems() == 0)
printf("No Sections!!!\n");
// user defined section drawing
TDateTimeSection *section;
section = (TDateTimeSection *)f_sections->ItemAt(index);
section = (TDateTimeSection *)fSectionList->ItemAt(index);
BRect bounds = section->Frame();
@ -398,147 +377,141 @@ TDateEdit::DrawSection(uint32 index, bool hasFocus)
if (hasFocus) {
SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
value = f_holdvalue;
value = fHoldValue;
} else {
SetLowColor(ViewColor());
value = section->Data();
}
char text[64];
// format value (new method?)
BString text;
switch (index) {
case 0: // month
case 0:
{ // month
struct tm tm;
tm.tm_mon = value;
strftime(text, sizeof(text), "%B", &tm);
break;
char buffer[64];
memset(buffer, 0, sizeof(buffer));
strftime(buffer, sizeof(buffer), "%B", &tm);
text.SetTo(buffer);
} break;
case 1: // day
snprintf(text, sizeof(text), "%lu", value);
text << value;
break;
case 2: // year
snprintf(text, sizeof(text), "%lu", value + 1900);
text << (value + 1900);
break;
default:
return;
}
// calc and center text in section rect
float width = StringWidth(text);
BPoint offset(-(bounds.Width() - width) /2.0 - 1.0, (bounds.Height() / 2.0 - 6.0));
float width = StringWidth(text.String());
BPoint offset(-(bounds.Width() - width) / 2.0 - 1.0, (bounds.Height() / 2.0 - 6.0));
if (index == 0)
offset.x = -(bounds.Width() - width) ;
SetHighColor(0, 0, 0, 255);
FillRect(bounds, B_SOLID_LOW);
DrawString(text, bounds.LeftBottom() - offset);
DrawString(text.String(), bounds.LeftBottom() - offset);
}
/*
DrawSeperator(uint32 index) user drawn seperator. Section is the
index of the section in fSectionList or the section to the seps left
*/
void
TDateEdit::DrawSeperator(uint32 index)
{
/* user drawn seperator. section is the index of the section
in f_sections or the section to the seps left
*/
if (index == 3) {
// no seperator for am/pm
if (index == 3)
return;
}
BString text("/");
uint32 sep;
GetSeperatorWidth(&sep);
TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(index);
TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(index);
BRect bounds = section->Frame();
float width = be_plain_font->StringWidth(text.String());
BPoint offset(-(sep/2.0 -width/2.0) -1.0, bounds.Height()/2.0 -6.0);
BPoint drawpt(bounds.RightBottom() -offset);
float sepWidth = SeperatorWidth();
float width = be_plain_font->StringWidth("/");
DrawString(text.String(), drawpt);
BPoint offset(-(sepWidth / 2.0 - width / 2.0) -1.0, bounds.Height() / 2.0 -6.0);
BPoint drawpt(bounds.RightBottom() - offset);
DrawString("/", drawpt);
}
void
TDateEdit::SetSections(BRect area)
{
TDateTimeSection *section;
// create sections
for (uint32 idx = 0; idx < f_sectioncount; idx++) {
section = new TDateTimeSection(area);
f_sections->AddItem(section);
}
for (uint32 idx = 0; idx < fSectionCount; idx++)
fSectionList->AddItem(new TDateTimeSection(area));
BRect bounds(area);
float width;
// year
width = be_plain_font->StringWidth("0000") +6;
float width = be_plain_font->StringWidth("0000") +6;
bounds.right = area.right;
bounds.left = bounds.right -width;
((TDateTimeSection *)f_sections->ItemAt(2))->SetBounds(bounds);
((TDateTimeSection *)fSectionList->ItemAt(2))->SetFrame(bounds);
uint32 sep;
GetSeperatorWidth(&sep);
float sepWidth = SeperatorWidth();
// day
width = be_plain_font->StringWidth("00") +6;
bounds.right = bounds.left -sep;
bounds.right = bounds.left -sepWidth;
bounds.left = bounds.right -width;
((TDateTimeSection *)f_sections->ItemAt(1))->SetBounds(bounds);
((TDateTimeSection *)fSectionList->ItemAt(1))->SetFrame(bounds);
// month
bounds.right = bounds.left -sep;
bounds.right = bounds.left - sepWidth;
bounds.left = area.left;
((TDateTimeSection *)f_sections->ItemAt(0))->SetBounds(bounds);
((TDateTimeSection *)fSectionList->ItemAt(0))->SetFrame(bounds);
}
void
TDateEdit::GetSeperatorWidth(uint32 *width)
float
TDateEdit::SeperatorWidth() const
{
*width = 8;
return 8.0f;
}
void
TDateEdit::SectionFocus(uint32 index)
{
f_focus = index;
fFocus = index;
// update hold value
f_holdvalue = ((TDateTimeSection *)f_sections->ItemAt(f_focus))->Data();
fHoldValue = ((TDateTimeSection *)fSectionList->ItemAt(fFocus))->Data();
Draw(Bounds());
}
void
TDateEdit::SetTo(uint32 year, uint32 month, uint32 day)
TDateEdit::SetDate(uint32 year, uint32 month, uint32 day)
{
if (f_sections->CountItems() > 0) {
if (fSectionList->CountItems() > 0) {
bool update = false;
TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(0);
TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(0);
if (section->Data() != month) {
section->SetData(month);
update = true;
}
section = (TDateTimeSection *)f_sections->ItemAt(1);
section = (TDateTimeSection *)fSectionList->ItemAt(1);
if (section->Data() != day) {
section->SetData(day);
update = true;
}
section = (TDateTimeSection *)f_sections->ItemAt(2);
section = (TDateTimeSection *)fSectionList->ItemAt(2);
if (section->Data() != year) {
section->SetData(year);
update = true;
@ -553,11 +526,11 @@ TDateEdit::SetTo(uint32 year, uint32 month, uint32 day)
void
TDateEdit::DoUpPress()
{
if (f_focus == -1)
if (fFocus == -1)
SectionFocus(0);
// update displayed value
f_holdvalue += 1;
fHoldValue += 1;
CheckRange();
@ -569,11 +542,11 @@ TDateEdit::DoUpPress()
void
TDateEdit::DoDownPress()
{
if (f_focus == -1)
if (fFocus == -1)
SectionFocus(0);
// update display value
f_holdvalue -= 1;
fHoldValue -= 1;
CheckRange();
@ -585,17 +558,15 @@ TDateEdit::DoDownPress()
void
TDateEdit::BuildDispatch(BMessage *message)
{
static const char *fields[3] = {"month", "day", "year"};
const char *fields[3] = {"month", "day", "year"};
message->AddBool("time", false);
for (int32 idx = 0; idx < f_sections->CountItems(); idx++) {
uint32 data;
for (int32 idx = 0; idx < fSectionList->CountItems(); idx++) {
uint32 data = ((TDateTimeSection *)fSectionList->ItemAt(idx))->Data();
if (f_focus == idx)
data = f_holdvalue;
else
data = ((TDateTimeSection *)f_sections->ItemAt(idx))->Data();
if (fFocus == idx)
data = fHoldValue;
message->AddInt32(fields[idx], data);
}
@ -605,9 +576,9 @@ TDateEdit::BuildDispatch(BMessage *message)
void
TDateEdit::CheckRange()
{
int32 value = f_holdvalue;
int32 value = fHoldValue;
switch (f_focus) {
switch (fFocus) {
case 0: // month
{
if (value > 11)
@ -619,8 +590,8 @@ TDateEdit::CheckRange()
case 1: //day
{
uint32 month = ((TDateTimeSection *)f_sections->ItemAt(0))->Data();
uint32 year = ((TDateTimeSection *)f_sections->ItemAt(2))->Data();
uint32 month = ((TDateTimeSection *)fSectionList->ItemAt(0))->Data();
uint32 year = ((TDateTimeSection *)fSectionList->ItemAt(2))->Data();
int daycnt = getDaysInMonth(month, year);
if (value > daycnt)
@ -643,8 +614,8 @@ TDateEdit::CheckRange()
return;
}
((TDateTimeSection *)f_sections->ItemAt(f_focus))->SetData(value);
f_holdvalue = value;
((TDateTimeSection *)fSectionList->ItemAt(fFocus))->SetData(value);
fHoldValue = value;
Draw(Bounds());
}

View File

@ -1,66 +1,66 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*
*/
#ifndef DATETIME_H
#define DATETIME_H
#include "SectionEdit.h"
// TSection descendent to hold uint32 value
class TDateTimeSection : public TSection {
public:
TDateTimeSection(BRect frame, uint32 data = 0);
~TDateTimeSection();
uint32 Data() const;
void SetData(uint32 data);
private:
uint32 fData;
};
// TSectionEdit descendent to edit time
class TTimeEdit : public TSectionEdit {
public:
TTimeEdit(BRect frame, const char *name, uint32 sections);
~TTimeEdit();
TTimeEdit(BRect frame, const char *name, uint32 sections);
virtual ~TTimeEdit();
virtual void InitView();
virtual void DrawSection(uint32 index, bool isfocus);
virtual void DrawSeperator(uint32 index);
virtual void InitView();
virtual void DrawSection(uint32 index, bool isfocus);
virtual void DrawSeperator(uint32 index);
virtual void SetSections(BRect area);
virtual void SectionFocus(uint32 index);
virtual void GetSeperatorWidth(uint32 *width);
virtual void SetSections(BRect area);
virtual void SectionFocus(uint32 index);
virtual float SeperatorWidth() const;
void CheckRange();
void CheckRange();
virtual void DoUpPress();
virtual void DoDownPress();
virtual void DoUpPress();
virtual void DoDownPress();
virtual void BuildDispatch(BMessage *message);
virtual void BuildDispatch(BMessage *message);
void SetTo(uint32 hour, uint32 minute, uint32 second);
void SetTime(uint32 hour, uint32 minute, uint32 second);
};
// TSectionEdit descendent to edit Date
class TDateEdit : public TSectionEdit {
public:
TDateEdit(BRect frame, const char *name, uint32 sections);
~TDateEdit();
TDateEdit(BRect frame, const char *name, uint32 sections);
virtual ~TDateEdit();
virtual void InitView();
virtual void DrawSection(uint32 index, bool isfocus);
virtual void DrawSeperator(uint32 index);
virtual void InitView();
virtual void DrawSection(uint32 index, bool isfocus);
virtual void DrawSeperator(uint32 index);
virtual void SetSections(BRect area);
virtual void SectionFocus(uint32 index);
virtual void GetSeperatorWidth(uint32 *width);
virtual void SetSections(BRect area);
virtual void SectionFocus(uint32 index);
virtual float SeperatorWidth() const;
void CheckRange();
void CheckRange();
virtual void DoUpPress();
virtual void DoDownPress();
virtual void DoUpPress();
virtual void DoDownPress();
virtual void BuildDispatch(BMessage *message);
virtual void BuildDispatch(BMessage *message);
void SetTo(uint32 hour, uint32 minute, uint32 second);
void SetDate(uint32 year, uint32 month, uint32 day);
};
#endif // DATETIME_H

View File

@ -1,3 +1,11 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
*/
#include "DateUtils.h"
#include "math.h"
@ -7,16 +15,15 @@ bool
isLeapYear(const int year)
{
int realYear = year + 1900;
return ((realYear % 400 == 0)||(realYear % 4 == 0 && realYear % 100 != 0));
return ((realYear % 400 == 0) || (realYear % 4 == 0 && realYear % 100 != 0));
}
int
getDaysInMonth(const int month, const int year)
{
if (month == 1 && isLeapYear(year)) {
if (month == 1 && isLeapYear(year))
return 29;
}
static const int DaysinMonth[12] =
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@ -44,3 +51,4 @@ getFirstDay(const int month, const int year)
return tm.tm_wday;
}

View File

@ -1,8 +1,20 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
*
*/
#ifndef CAL_HELPERS
#define CAL_HELPERS
bool isLeapYear(const int year);
int getDaysInMonth(const int month, const int year);
int getFirstDay(const int month, const int year);
#endif //CAL_HELPERS

View File

@ -1,54 +1,50 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*
*/
#include "SectionEdit.h"
#include "Bitmaps.h"
#include "TimeMessages.h"
#include <Bitmap.h>
#include <List.h>
#include <Window.h>
#include "Bitmaps.h"
#include "SectionEdit.h"
#include "TimeMessages.h"
const uint32 kArrowAreaWidth = 16;
const uint32 kSeperatorWidth = 8;
TSection::TSection(BRect frame)
: f_frame(frame)
{
}
void
TSection::SetBounds(BRect frame)
{
f_frame = frame;
}
BRect
TSection::Bounds() const
{
BRect bounds(f_frame);
return bounds.OffsetByCopy(B_ORIGIN);
}
BRect
TSection::Frame() const
{
return f_frame;
}
TSectionEdit::TSectionEdit(BRect frame, const char *name, uint32 sections)
: BControl(frame, name, NULL, NULL, B_FOLLOW_NONE, B_NAVIGABLE|B_WILL_DRAW)
, f_focus(-1)
: BControl(frame, name, NULL, NULL, B_FOLLOW_NONE, B_NAVIGABLE | B_WILL_DRAW),
fUpArrow(NULL),
fDownArrow(NULL),
fSectionList(NULL),
fFocus(-1),
fSectionCount(sections)
{
f_sectioncount = sections;
InitView();
}
TSectionEdit::~TSectionEdit()
{
delete fUpArrow;
delete fDownArrow;
int32 count = fSectionList->CountItems();
if (count > 0) {
for (int32 index = 0; index < count; index++)
delete (TSection*)fSectionList->ItemAt(index);
}
delete fSectionList;
}
@ -57,8 +53,8 @@ TSectionEdit::AttachedToWindow()
{
if (Parent()) {
SetViewColor(Parent()->ViewColor());
ReplaceTransparentColor(f_up, ViewColor());
ReplaceTransparentColor(f_down, ViewColor());
ReplaceTransparentColor(fUpArrow, ViewColor());
ReplaceTransparentColor(fDownArrow, ViewColor());
}
}
@ -67,10 +63,10 @@ void
TSectionEdit::Draw(BRect updaterect)
{
DrawBorder();
for (uint32 idx = 0; idx < f_sectioncount; idx++)
for (uint32 idx = 0; idx < fSectionCount; idx++)
{
DrawSection(idx, ((uint32)f_focus == idx) && IsFocus());
if (idx <f_sectioncount -1)
DrawSection(idx, ((uint32)fFocus == idx) && IsFocus());
if (idx <fSectionCount -1)
DrawSeperator(idx);
}
}
@ -80,14 +76,14 @@ void
TSectionEdit::MouseDown(BPoint where)
{
MakeFocus(true);
if (f_uprect.Contains(where))
if (fUpRect.Contains(where))
DoUpPress();
else if (f_downrect.Contains(where))
else if (fDownRect.Contains(where))
DoDownPress();
else if (f_sections->CountItems()> 0) {
else if (fSectionList->CountItems()> 0) {
TSection *section;
for (uint32 idx = 0; idx < f_sectioncount; idx++) {
section = (TSection *)f_sections->ItemAt(idx);
for (uint32 idx = 0; idx < fSectionCount; idx++) {
section = (TSection *)fSectionList->ItemAt(idx);
if (section->Frame().Contains(where)) {
SectionFocus(idx);
return;
@ -100,22 +96,22 @@ TSectionEdit::MouseDown(BPoint where)
void
TSectionEdit::KeyDown(const char *bytes, int32 numbytes)
{
if (f_focus == -1)
if (fFocus == -1)
SectionFocus(0);
switch (bytes[0]) {
case B_LEFT_ARROW:
f_focus -= 1;
if (f_focus < 0)
f_focus = f_sectioncount -1;
SectionFocus(f_focus);
fFocus -= 1;
if (fFocus < 0)
fFocus = fSectionCount -1;
SectionFocus(fFocus);
break;
case B_RIGHT_ARROW:
f_focus += 1;
if ((uint32)f_focus >= f_sectioncount)
f_focus = 0;
SectionFocus(f_focus);
fFocus += 1;
if ((uint32)fFocus >= fSectionCount)
fFocus = 0;
SectionFocus(fFocus);
break;
case B_UP_ARROW:
@ -146,14 +142,14 @@ TSectionEdit::DispatchMessage()
uint32
TSectionEdit::CountSections() const
{
return f_sections->CountItems();
return fSectionList->CountItems();
}
int32
TSectionEdit::FocusIndex() const
{
return f_focus;
return fFocus;
}
@ -162,33 +158,31 @@ TSectionEdit::InitView()
{
// create arrow bitmaps
f_up = new BBitmap(BRect(0, 0, kUpArrowWidth -1, kUpArrowHeight -1), kUpArrowColorSpace);
f_up->SetBits(kUpArrowBits, (kUpArrowWidth) *(kUpArrowHeight+1), 0, kUpArrowColorSpace);
fUpArrow = new BBitmap(BRect(0, 0, kUpArrowWidth -1, kUpArrowHeight -1), kUpArrowColorSpace);
fUpArrow->SetBits(kUpArrowBits, (kUpArrowWidth) *(kUpArrowHeight+1), 0, kUpArrowColorSpace);
f_down = new BBitmap(BRect(0, 0, kDownArrowWidth -1, kDownArrowHeight -2), kDownArrowColorSpace);
f_down->SetBits(kDownArrowBits, (kDownArrowWidth) *(kDownArrowHeight), 0, kDownArrowColorSpace);
fDownArrow = new BBitmap(BRect(0, 0, kDownArrowWidth -1, kDownArrowHeight -2), kDownArrowColorSpace);
fDownArrow->SetBits(kDownArrowBits, (kDownArrowWidth) *(kDownArrowHeight), 0, kDownArrowColorSpace);
// setup sections
f_sections = new BList(f_sectioncount);
f_sectionsarea = Bounds().InsetByCopy(2, 2);
f_sectionsarea.right -= (kArrowAreaWidth);
fSectionList = new BList(fSectionCount);
fSectionArea = Bounds().InsetByCopy(2, 2);
fSectionArea.right -= kArrowAreaWidth;
}
void
TSectionEdit::Draw3DFrame(BRect frame, bool inset)
{
rgb_color color1, color2;
rgb_color color1 = LowColor();
rgb_color color2 = HighColor();
if (inset) {
color1 = HighColor();
color2 = LowColor();
} else {
color1 = LowColor();
color2 = HighColor();
}
BeginLineArray(4);
// left side
AddLine(frame.LeftBottom(), frame.LeftTop(), color2);
@ -210,17 +204,18 @@ TSectionEdit::DrawBorder()
rgb_color dark = tint_color(bgcolor, B_DARKEN_1_TINT);
rgb_color darker = tint_color(bgcolor, B_DARKEN_3_TINT);
BRect bounds(Bounds());
SetHighColor(light);
SetLowColor(dark);
BRect bounds(Bounds());
Draw3DFrame(bounds, true);
StrokeLine(bounds.LeftBottom(), bounds.LeftBottom(), B_SOLID_LOW);
bounds.InsetBy(1, 1);
bounds.right -= kArrowAreaWidth;
f_showfocus = (IsFocus() && Window() && Window()->IsActive());
if (f_showfocus) {
fShowFocus = (IsFocus() && Window() && Window()->IsActive());
if (fShowFocus) {
rgb_color navcolor = keyboard_navigation_color();
SetHighColor(navcolor);
@ -234,13 +229,16 @@ TSectionEdit::DrawBorder()
// draw up/down control
SetHighColor(light);
bounds.left = bounds.right +1;// -kArrowAreaWidth;
bounds.left = bounds.right +1;
bounds.right = Bounds().right -1;
f_uprect.Set(bounds.left +3, bounds.top +2, bounds.right, bounds.bottom /2.0);
f_downrect = f_uprect.OffsetByCopy(0, f_uprect.Height()+2);
fUpRect.Set(bounds.left +3, bounds.top +2, bounds.right, bounds.bottom /2.0);
fDownRect = fUpRect.OffsetByCopy(0, fUpRect.Height()+2);
DrawBitmap(f_up, f_uprect.LeftTop());
DrawBitmap(f_down, f_downrect.LeftTop());
if (fUpArrow)
DrawBitmap(fUpArrow, fUpRect.LeftTop());
if (fDownArrow)
DrawBitmap(fDownArrow, fDownRect.LeftTop());
Draw3DFrame(bounds, false);
SetHighColor(dark);
@ -251,51 +249,9 @@ TSectionEdit::DrawBorder()
}
void
TSectionEdit::SetSections(BRect)
{
}
void
TSectionEdit::GetSeperatorWidth(uint32 *width)
{
*width = 0;
}
void
TSectionEdit::DrawSection(uint32 index, bool isfocus)
{
}
void
TSectionEdit::DrawSeperator(uint32 index)
{
}
void
TSectionEdit::SectionFocus(uint32 index)
{
}
void
TSectionEdit::SectionChange(uint32 section, uint32 value)
{
}
void
TSectionEdit::DoUpPress()
{
}
void
TSectionEdit::DoDownPress()
float
TSectionEdit::SeperatorWidth() const
{
return 0.0f;
}

View File

@ -1,67 +1,94 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*
*/
#ifndef SECTIONEDIT_H
#define SECTIONEDIT_H
#include <Control.h>
#include <List.h>
class BBitmap;
class BList;
class TSection {
public:
TSection(BRect frame);
TSection(BRect frame)
: fFrame(frame) {}
void SetBounds(BRect frame);
BRect Bounds() const
{
BRect frame(fFrame);
return frame.OffsetByCopy(B_ORIGIN);
}
void SetFrame(BRect frame)
{ fFrame = frame; }
BRect Bounds() const;
BRect Frame() const;
BRect Frame() const
{ return fFrame; }
private:
BRect f_frame;
BRect fFrame;
};
class TSectionEdit: public BControl {
public:
TSectionEdit(BRect frame, const char *name, uint32 sections);
~TSectionEdit();
TSectionEdit(BRect frame, const char *name, uint32 sections);
virtual ~TSectionEdit();
virtual void AttachedToWindow();
virtual void Draw(BRect);
virtual void MouseDown(BPoint);
virtual void KeyDown(const char *bytes, int32 numbytes);
virtual void AttachedToWindow();
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint point);
virtual void KeyDown(const char *bytes, int32 numBytes);
uint32 CountSections() const;
int32 FocusIndex() const;
BRect SectionArea() const;
uint32 CountSections() const;
int32 FocusIndex() const;
BRect SectionArea() const;
protected:
virtual void InitView();
virtual void InitView();
//hooks
virtual void DrawBorder();
virtual void DrawSection(uint32 index, bool isfocus);
virtual void DrawSeperator(uint32 index);
virtual void Draw3DFrame(BRect frame, bool inset);
virtual void DrawBorder();
virtual void DrawSection(uint32 index, bool isFocus) {}
virtual void DrawSeperator(uint32 index) {}
virtual void Draw3DFrame(BRect frame, bool inset);
virtual void SectionFocus(uint32 index);
virtual void SectionChange(uint32 index, uint32 value);
virtual void SetSections(BRect area);
virtual void GetSeperatorWidth(uint32 *width);
virtual void SectionFocus(uint32 index) {}
virtual void SectionChange(uint32 index, uint32 value) {}
virtual void SetSections(BRect area) {}
virtual float SeperatorWidth() const;
virtual void DoUpPress();
virtual void DoDownPress();
virtual void DoUpPress() {}
virtual void DoDownPress() {}
virtual void DispatchMessage();
virtual void BuildDispatch(BMessage *) = 0;
virtual void DispatchMessage();
virtual void BuildDispatch(BMessage *message) = 0;
BBitmap *f_up;
BBitmap *f_down;
BList *f_sections;
protected:
BBitmap *fUpArrow;
BBitmap *fDownArrow;
BList *fSectionList;
BRect f_uprect;
BRect f_downrect;
BRect f_sectionsarea;
BRect fUpRect;
BRect fDownRect;
BRect fSectionArea;
int32 f_focus;
uint32 f_sectioncount;
uint32 f_holdvalue;
int32 fFocus;
uint32 fSectionCount;
uint32 fHoldValue;
bool f_showfocus;
bool fShowFocus;
};
#endif

View File

@ -3,7 +3,8 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* <unkown>
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/
@ -201,7 +202,7 @@ TSettingsView::UpdateDateTime(BMessage *message)
&& message->FindInt32("day", &day) == B_OK
&& message->FindInt32("year", &year) == B_OK)
{
fDateEdit->SetTo(year, month, day);
fDateEdit->SetDate(year, month, day);
fCalendar->SetTo(year, month, day);
}
@ -212,8 +213,8 @@ TSettingsView::UpdateDateTime(BMessage *message)
&& message->FindInt32("minute", &minute) == B_OK
&& message->FindInt32("second", &second) == B_OK)
{
fTimeEdit->SetTo(hour, minute, second);
fClock->SetTo(hour, minute, second);
fTimeEdit->SetTime(hour, minute, second);
fClock->SetTime(hour, minute, second);
}
}

View File

@ -3,7 +3,8 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* <unkown>
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/
#ifndef SETTINGS_VIEW_H

View File

@ -1,24 +1,35 @@
#include<Message.h>
#include <String.h>
#include <stdio.h>
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*
*/
#include <math.h>
#include "TimeMessages.h"
#include "TZDisplay.h"
TTZDisplay::TTZDisplay(BRect frame, const char *name,
uint32 resizingmode, uint32 flags,
const char *label, const char *text,
int32 hour, int32 minute)
: BView(frame, name, resizingmode, flags)
namespace {
float _FontHeight()
{
font_height fontHeight;
be_plain_font->GetHeight(&fontHeight);
float height = ceil(fontHeight.descent) + ceil(fontHeight.ascent)
+ ceil(fontHeight.leading);
return height;
}
}
TTZDisplay::TTZDisplay(BRect frame, const char *name, const char *label)
: BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW),
fLabel(label),
fText(""),
fTime("")
{
f_label = new BString(label);
f_text = new BString(text);
f_time = new BString();
SetTo(hour, minute);
}
@ -35,117 +46,88 @@ TTZDisplay::AttachedToWindow()
}
void
TTZDisplay::MessageReceived(BMessage *message)
{
switch(message->what) {
default:
BView::MessageReceived(message);
break;
}
}
static float
fontheight()
{
font_height finfo;
be_plain_font->GetHeight(&finfo);
float height = ceil(finfo.descent) +ceil(finfo.ascent) +ceil(finfo.leading);
return height;
}
void
TTZDisplay::ResizeToPreferred()
{
float height = fontheight();
float height = _FontHeight();
ResizeTo(Bounds().Width(), height *2);
}
void
TTZDisplay::Draw(BRect updaterect)
TTZDisplay::Draw(BRect /* updateRect */)
{
BRect bounds(Bounds());
SetLowColor(ViewColor());
FillRect(bounds, B_SOLID_LOW);
float height = fontheight();
float height = _FontHeight();
BPoint drawpt(bounds.left +2, height/2.0 +1);
DrawString(f_label->String(), drawpt);
BPoint drawpt(bounds.left +2, height /2.0 +1);
DrawString(fLabel.String(), drawpt);
drawpt.y += fontheight() +2;
DrawString(f_text->String(), drawpt);
drawpt.y += height +2;
DrawString(fText.String(), drawpt);
drawpt.x = bounds.right -be_plain_font->StringWidth(f_time->String()) - 2;
DrawString(f_time->String(), drawpt);
drawpt.x = bounds.right -be_plain_font->StringWidth(fTime.String()) - 2;
DrawString(fTime.String(), drawpt);
}
const char*
TTZDisplay::Label() const
{
return fLabel.String();
}
void
TTZDisplay::SetLabel(const char *label)
{
f_label->SetTo(label);
fLabel.SetTo(label);
Draw(Bounds());
}
const char*
TTZDisplay::Text() const
{
return fText.String();
}
void
TTZDisplay::SetText(const char *text)
{
f_text->SetTo(text);
fText.SetTo(text);
Draw(Bounds());
}
void
TTZDisplay::SetTo(int32 hour, int32 minute)
const char*
TTZDisplay::Time() const
{
return fTime.String();
}
void
TTZDisplay::SetTime(int32 hour, int32 minute)
{
// format time into f_time
if (f_time == NULL)
f_time = new BString();
else
f_time->SetTo("");
int32 ahour = hour;
if (hour> 12)
if (hour > 12)
ahour = hour -12;
if (ahour == 0)
ahour = 12;
char *ap;
if (hour> 11)
char *ap = "AM";
if (hour > 11)
ap = "PM";
else
ap = "AM";
char *time = f_time->LockBuffer(8);
sprintf(time, "%02lu:%02lu %s", ahour, minute, ap);
f_time->UnlockBuffer(8);
fTime.SetTo("");
fTime << ahour << ":" << minute << ":" << ap;
Invalidate();
}
const char *
TTZDisplay::Text() const
{
return f_text->String();
}
const char *
TTZDisplay::Label() const
{
return f_label->String();
}
const char *
TTZDisplay::Time() const
{
return f_time->String();
}

View File

@ -1,34 +1,45 @@
/*
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* probably Mike Berg <mike@agamemnon.homelinux.net>
* and/or Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*
*/
#ifndef TTZDISPLAY_H
#define TTZDISPLAY_H
#include <View.h>
#include <String.h>
class TTZDisplay: public BView
{
class TTZDisplay : public BView {
public:
TTZDisplay(BRect frame, const char *name, uint32 resizing, uint32 flags,
const char *label = B_EMPTY_STRING,
const char *name = B_EMPTY_STRING,
int32 hour = 0, int32 minute = 0);
~TTZDisplay();
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *message);
virtual void ResizeToPreferred();
virtual void Draw(BRect);
TTZDisplay(BRect frame, const char *name, const char *label);
virtual ~TTZDisplay();
virtual void AttachedToWindow();
virtual void ResizeToPreferred();
virtual void Draw(BRect updateRect);
const char* Label() const;
void SetLabel(const char *label);
const char* Text() const;
void SetText(const char *text);
const char* Time() const;
void SetTime(int32 hour, int32 minute);
virtual void SetLabel(const char *label);
virtual void SetText(const char *text);
virtual void SetTo(int32 hour, int32 minute);
virtual const char *Label() const;
virtual const char *Text() const;
virtual const char *Time() const;
private:
BString *f_label;
BString *f_text;
BString *f_time;
BString fLabel;
BString fText;
BString fTime;
};
#endif //TTZDISPLAY_H
#endif // TTZDISPLAY_H

View File

@ -3,8 +3,8 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Andrew McCall, mccall@digitalparadise.co.uk
* Mike Berg (inseculous)
* Andrew McCall <mccall@digitalparadise.co.uk>
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/

View File

@ -4,7 +4,7 @@
*
* Authors:
* Andrew McCall, mccall@digitalparadise.co.uk
* Mike Berg (inseculous)
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/
#ifndef TIME_H

View File

@ -4,7 +4,7 @@
*
* Authors:
* Andrew McCall, mccall@digitalparadise.co.uk
* Mike Berg (inseculous)
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/
#ifndef TIME_MESSAGES_H

View File

@ -4,7 +4,7 @@
*
* Authors:
* Andrew McCall, mccall@digitalparadise.co.uk
* Mike Berg (inseculous)
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/

View File

@ -4,7 +4,7 @@
*
* Authors:
* Andrew McCall, mccall@digitalparadise.co.uk
* Mike Berg (inseculous)
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/
#ifndef TIME_SETTINGS_H

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* mccall@@digitalparadise.co.uk
* Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* mccall@@digitalparadise.co.uk
* Andrew McCall <mccall@@digitalparadise.co.uk>
* Julun <host.haiku@gmx.de>
*/
#ifndef TIME_WINDOW_H

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Mike Berg (inseculous)
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/
@ -43,7 +43,7 @@
#include <stdlib.h>
class TZoneItem: public BStringItem {
class TZoneItem : public BStringItem {
public:
TZoneItem(const char *text, const char *zone)
: BStringItem(text), fZone(new BPath(zone)) { }
@ -154,7 +154,7 @@ TZoneView::UpdateDateTime(BMessage *message)
if (fHour != hour || fMinute != minute) {
fHour = hour;
fMinute = minute;
fCurrent->SetTo(hour, minute);
fCurrent->SetTime(hour, minute);
// do calc to get other zone time
if (fCityList->CurrentSelection() > -1)
@ -205,14 +205,12 @@ TZoneView::InitView()
frameRight.top = frameLeft.top;
// Time Displays
fCurrent = new TTZDisplay(frameRight, "current",
B_FOLLOW_NONE, B_WILL_DRAW, "Current time zone:", B_EMPTY_STRING);
fCurrent = new TTZDisplay(frameRight, "current", "Current time:");
AddChild(fCurrent);
fCurrent->ResizeToPreferred();
frameRight.OffsetBy(0, (textHeight) * 3 +10.0);
fPreview = new TTZDisplay(frameRight, "preview",
B_FOLLOW_NONE, B_WILL_DRAW, "Time in: ", B_EMPTY_STRING);
fPreview = new TTZDisplay(frameRight, "preview", "Preview time:");
AddChild(fPreview);
fPreview->ResizeToPreferred();
@ -391,27 +389,25 @@ TZoneView::ReadTimeZoneLink()
void
TZoneView::SetPreview()
{
// calc and display time based on users selection in city list
int32 selection = fCityList->CurrentSelection();
if (selection>= 0) {
if (selection >= 0) {
TZoneItem *item = (TZoneItem *)fCityList->ItemAt(selection);
BString text;
text = item->Text();
time_t current;
struct tm *ltime;
// calc time to display and update
// set timezone to selection
SetTimeZone(item->Path());
current = time(0);
ltime = localtime(&current);
// calc preview time
time_t current = time(0);
struct tm *ltime = localtime(&current);
// update prview
fPreview->SetText(item->Text());
fPreview->SetTime(ltime->tm_hour, ltime->tm_min);
// set timezone back to current
SetTimeZone(fCurrentZone.Path());
fPreview->SetTo(ltime->tm_hour, ltime->tm_min);
fPreview->SetText(text.String());
fSetZone->SetEnabled((strcmp(fCurrent->Text(), text.String()) != 0));
fSetZone->SetEnabled((strcmp(fCurrent->Text(), item->Text()) != 0));
}
}
@ -420,11 +416,12 @@ void
TZoneView::SetCurrent(const char *text)
{
SetTimeZone(fCurrentZone.Path());
time_t current = time(0);
struct tm *ltime = localtime(&current);
fCurrent->SetTo(ltime->tm_hour, ltime->tm_min);
fCurrent->SetText(text);
fCurrent->SetTime(ltime->tm_hour, ltime->tm_min);
}

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Mike Berg (inseculous)
* Mike Berg <mike@agamemnon.homelinux.net>
* Julun <host.haiku@gmx.de>
*/
#ifndef ZONE_VIEW_H