* move DateTime and CalendarView into shared
* adjust Time preflet to take that into account git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27235 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2007-2008, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _CALENDAR_VIEW_H_
|
#ifndef _CALENDAR_VIEW_H_
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
class BMessage;
|
class BMessage;
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
enum week_start {
|
enum week_start {
|
||||||
B_WEEK_START_MONDAY,
|
B_WEEK_START_MONDAY,
|
||||||
B_WEEK_START_SUNDAY
|
B_WEEK_START_SUNDAY
|
||||||
@@ -129,6 +132,7 @@ class BCalendarView : public BView, public BInvoker {
|
|||||||
BRect _FirstCalendarItemFrame() const;
|
BRect _FirstCalendarItemFrame() const;
|
||||||
BRect _SetNewSelectedDay(const BPoint &where);
|
BRect _SetNewSelectedDay(const BPoint &where);
|
||||||
|
|
||||||
|
BCalendarView(const BCalendarView &view);
|
||||||
BCalendarView& operator=(const BCalendarView &view);
|
BCalendarView& operator=(const BCalendarView &view);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -176,4 +180,8 @@ class BCalendarView : public BView, public BInvoker {
|
|||||||
BString fDayNumbers[6][7];
|
BString fDayNumbers[6][7];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
#endif // _CALENDAR_VIEW_H_
|
#endif // _CALENDAR_VIEW_H_
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2007-2008, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _DATE_TIME_H_
|
#ifndef _DATE_TIME_H_
|
||||||
@@ -9,6 +9,9 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
enum time_type {
|
enum time_type {
|
||||||
B_GMT_TIME,
|
B_GMT_TIME,
|
||||||
B_LOCAL_TIME
|
B_LOCAL_TIME
|
||||||
@@ -97,4 +100,8 @@ class BDateTime {
|
|||||||
BTime fTime;
|
BTime fTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
#endif // _DATE_TIME_H_
|
#endif // _DATE_TIME_H_
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2007-2008, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
float
|
float
|
||||||
FontHeight(const BView *view)
|
FontHeight(const BView *view)
|
||||||
@@ -225,7 +228,6 @@ BCalendarView::Draw(BRect updateRect)
|
|||||||
_UpdateSelection();
|
_UpdateSelection();
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_DrawDays();
|
_DrawDays();
|
||||||
@@ -637,7 +639,7 @@ BCalendarView::SetDate(int32 year, int32 month, int32 day)
|
|||||||
if (fWeekNumberHeaderVisible)
|
if (fWeekNumberHeaderVisible)
|
||||||
frame.left += frame.Width() / 8 - 1.0;
|
frame.left += frame.Width() / 8 - 1.0;
|
||||||
|
|
||||||
Invalidate(frame.InsetBySelf(4.0, 4.0));
|
Draw(frame.InsetBySelf(4.0, 4.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -913,22 +915,22 @@ BCalendarView::_SetupWeekNumbers()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
date.SetDate(fYear, fMonth, 1);
|
date.SetDate(fYear, fMonth, 1);
|
||||||
int32 firstDay = date.DayOfWeek();
|
fWeekNumbers[0].SetTo("");
|
||||||
if (fWeekStart == B_WEEK_START_MONDAY)
|
fWeekNumbers[0] << date.WeekNumber();
|
||||||
firstDay -= 1;
|
|
||||||
|
|
||||||
const int32 kWeekNumber = date.WeekNumber();
|
for (int32 row = 1; row < 5; ++row) {
|
||||||
int32 dateWeekNumber = kWeekNumber;
|
date.SetDate(fYear, fMonth, date.Day() + 7);
|
||||||
if (kWeekNumber == 52 && firstDay == 0)
|
|
||||||
dateWeekNumber = 1;
|
|
||||||
|
|
||||||
for (int32 row = 0; row < 6; ++row) {
|
|
||||||
int32 weekNumber = dateWeekNumber + row;
|
|
||||||
if (kWeekNumber == 52 && firstDay != 0 || kWeekNumber == 53)
|
|
||||||
dateWeekNumber = 0;
|
|
||||||
fWeekNumbers[row].SetTo("");
|
fWeekNumbers[row].SetTo("");
|
||||||
fWeekNumbers[row] << weekNumber;
|
fWeekNumbers[row] << date.WeekNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fMonth == 12)
|
||||||
|
date.SetDate(fYear + 1, 1, 5);
|
||||||
|
else
|
||||||
|
date.SetDate(fYear, fMonth + 1, 7);
|
||||||
|
|
||||||
|
fWeekNumbers[5].SetTo("");
|
||||||
|
fWeekNumbers[5] << date.WeekNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1227,8 +1229,4 @@ BCalendarView::_RectOfDay(const Selection &selection) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BCalendarView&
|
} // namespace BPrivate
|
||||||
BCalendarView::operator=(const BCalendarView &view)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2008, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
BTime::BTime()
|
BTime::BTime()
|
||||||
: fHour(-1),
|
: fHour(-1),
|
||||||
fMinute(-1),
|
fMinute(-1),
|
||||||
@@ -199,7 +202,7 @@ BDate::WeekNumber() const
|
|||||||
/*
|
/*
|
||||||
This algorithm is taken from:
|
This algorithm is taken from:
|
||||||
Frequently Asked Questions about Calendars
|
Frequently Asked Questions about Calendars
|
||||||
Version 2.8 Claus Tøndering 15 December 2005
|
Version 2.8 Claus Tøndering 15 December 2005
|
||||||
|
|
||||||
Note: it will work only within the Gregorian Calendar
|
Note: it will work only within the Gregorian Calendar
|
||||||
*/
|
*/
|
||||||
@@ -207,40 +210,40 @@ BDate::WeekNumber() const
|
|||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32 a;
|
int32 a;
|
||||||
int32 b;
|
int32 b;
|
||||||
int32 s;
|
int32 s;
|
||||||
int32 e;
|
int32 e;
|
||||||
int32 f;
|
int32 f;
|
||||||
|
|
||||||
if (fMonth > 0 && fMonth < 3) {
|
if (fMonth > 0 && fMonth < 3) {
|
||||||
a = fYear - 1;
|
a = fYear - 1;
|
||||||
b = (a / 4) - (a / 100) + (a / 400);
|
b = (a / 4) - (a / 100) + (a / 400);
|
||||||
int32 c = ((a - 1) / 4) - ((a - 1) / 100) + ((a -1) / 400);
|
int32 c = ((a - 1) / 4) - ((a - 1) / 100) + ((a -1) / 400);
|
||||||
s = b - c;
|
s = b - c;
|
||||||
e = 0;
|
e = 0;
|
||||||
f = fDay - 1 + 31 * (fMonth - 1);
|
f = fDay - 1 + 31 * (fMonth - 1);
|
||||||
} else if (fMonth >= 3 && fMonth <= 12) {
|
} else if (fMonth >= 3 && fMonth <= 12) {
|
||||||
a = fYear;
|
a = fYear;
|
||||||
b = (a / 4) - (a / 100) + (a / 400);
|
b = (a / 4) - (a / 100) + (a / 400);
|
||||||
int32 c = ((a - 1) / 4) - ((a - 1) / 100) + ((a -1) / 400);
|
int32 c = ((a - 1) / 4) - ((a - 1) / 100) + ((a -1) / 400);
|
||||||
s = b - c;
|
s = b - c;
|
||||||
e = s + 1;
|
e = s + 1;
|
||||||
f = fDay + ((153 * (fMonth - 3) + 2) / 5) + 58 + s;
|
f = fDay + ((153 * (fMonth - 3) + 2) / 5) + 58 + s;
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32 g = (a + b) % 7;
|
int32 g = (a + b) % 7;
|
||||||
int32 d = (f + g - e) % 7;
|
int32 d = (f + g - e) % 7;
|
||||||
int32 n = f + 3 - d;
|
int32 n = f + 3 - d;
|
||||||
|
|
||||||
int32 weekNumber;
|
int32 weekNumber;
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
weekNumber = 53 - (g -s) / 5;
|
weekNumber = 53 - (g -s) / 5;
|
||||||
else if (n > 364 + s)
|
else if (n > 364 + s)
|
||||||
weekNumber = 1;
|
weekNumber = 1;
|
||||||
else
|
else
|
||||||
weekNumber = n / 7 + 1;
|
weekNumber = n / 7 + 1;
|
||||||
|
|
||||||
return weekNumber;
|
return weekNumber;
|
||||||
}
|
}
|
||||||
@@ -252,7 +255,7 @@ BDate::DayOfWeek() const
|
|||||||
/*
|
/*
|
||||||
This algorithm is taken from:
|
This algorithm is taken from:
|
||||||
Frequently Asked Questions about Calendars
|
Frequently Asked Questions about Calendars
|
||||||
Version 2.8 Claus Tøndering 15 December 2005
|
Version 2.8 Claus Tøndering 15 December 2005
|
||||||
|
|
||||||
Note: it will work only within the Gregorian Calendar
|
Note: it will work only within the Gregorian Calendar
|
||||||
*/
|
*/
|
||||||
@@ -282,9 +285,9 @@ BDate::DayOfYear() const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
const int kFirstDayOfMonth[2][12] = {
|
const int kFirstDayOfMonth[2][12] = {
|
||||||
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
|
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
|
||||||
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
|
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
|
||||||
};
|
};
|
||||||
@@ -292,7 +295,7 @@ BDate::DayOfYear() const
|
|||||||
if (IsLeapYear(fYear))
|
if (IsLeapYear(fYear))
|
||||||
return kFirstDayOfMonth[1][fMonth -1] + fDay;
|
return kFirstDayOfMonth[1][fMonth -1] + fDay;
|
||||||
|
|
||||||
return kFirstDayOfMonth[0][fMonth -1] + fDay;
|
return kFirstDayOfMonth[0][fMonth -1] + fDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -481,3 +484,5 @@ BDateTime::Time_t() const
|
|||||||
// return secs_since_jan1_1970 or -1 on error
|
// return secs_since_jan1_1970 or -1 on error
|
||||||
return uint32(mktime(&tm_struct));
|
return uint32(mktime(&tm_struct));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} //namespace BPrivate
|
||||||
@@ -7,7 +7,9 @@ UsePrivateHeaders shared ;
|
|||||||
|
|
||||||
StaticLibrary libshared.a :
|
StaticLibrary libshared.a :
|
||||||
AboutWindow.cpp
|
AboutWindow.cpp
|
||||||
|
CalendarView.cpp
|
||||||
ColorQuantizer.cpp
|
ColorQuantizer.cpp
|
||||||
CommandPipe.cpp
|
CommandPipe.cpp
|
||||||
|
DateTime.cpp
|
||||||
HashString.cpp
|
HashString.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -8,13 +8,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BaseView.h"
|
#include "BaseView.h"
|
||||||
#include "DateTime.h"
|
|
||||||
#include "TimeMessages.h"
|
#include "TimeMessages.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <DateTime.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::BDate;
|
||||||
|
using BPrivate::BTime;
|
||||||
|
using BPrivate::BDateTime;
|
||||||
|
using BPrivate::B_LOCAL_TIME;
|
||||||
|
|
||||||
|
|
||||||
TTimeBaseView::TTimeBaseView(BRect frame, const char *name)
|
TTimeBaseView::TTimeBaseView(BRect frame, const char *name)
|
||||||
: BView(frame, name, B_FOLLOW_NONE, B_PULSE_NEEDED),
|
: BView(frame, name, B_FOLLOW_NONE, B_PULSE_NEEDED),
|
||||||
fMessage(H_TIME_UPDATE)
|
fMessage(H_TIME_UPDATE)
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::B_LOCAL_TIME;
|
||||||
|
|
||||||
|
|
||||||
TTimeEdit::TTimeEdit(BRect frame, const char *name, uint32 sections)
|
TTimeEdit::TTimeEdit(BRect frame, const char *name, uint32 sections)
|
||||||
: TSectionEdit(frame, name, sections)
|
: TSectionEdit(frame, name, sections)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,10 +12,16 @@
|
|||||||
#define DATETIME_H
|
#define DATETIME_H
|
||||||
|
|
||||||
|
|
||||||
#include "DateTime.h"
|
|
||||||
#include "SectionEdit.h"
|
#include "SectionEdit.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <DateTime.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::BDate;
|
||||||
|
using BPrivate::BTime;
|
||||||
|
|
||||||
|
|
||||||
class TTimeEdit : public TSectionEdit {
|
class TTimeEdit : public TSectionEdit {
|
||||||
public:
|
public:
|
||||||
TTimeEdit(BRect frame, const char *name, uint32 sections);
|
TTimeEdit(BRect frame, const char *name, uint32 sections);
|
||||||
|
|||||||
@@ -11,14 +11,14 @@
|
|||||||
|
|
||||||
#include "DateTimeView.h"
|
#include "DateTimeView.h"
|
||||||
#include "AnalogClock.h"
|
#include "AnalogClock.h"
|
||||||
#include "CalendarView.h"
|
|
||||||
#include "DateTimeEdit.h"
|
#include "DateTimeEdit.h"
|
||||||
#include "TimeMessages.h"
|
#include "TimeMessages.h"
|
||||||
#include "DateTime.h"
|
|
||||||
#include "TimeWindow.h"
|
#include "TimeWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <CalendarView.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
|
#include <DateTime.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -31,6 +31,11 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::BCalendarView;
|
||||||
|
using BPrivate::BDateTime;
|
||||||
|
using BPrivate::B_LOCAL_TIME;
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
# include <syscalls.h>
|
# include <syscalls.h>
|
||||||
#else
|
#else
|
||||||
@@ -232,6 +237,8 @@ DateTimeView::_InitView()
|
|||||||
|
|
||||||
fClock = new TAnalogClock(bounds, "analogClock");
|
fClock = new TAnalogClock(bounds, "analogClock");
|
||||||
AddChild(fClock);
|
AddChild(fClock);
|
||||||
|
BTime time(BTime::CurrentTime(B_LOCAL_TIME));
|
||||||
|
fClock->SetTime(time.Hour(), time.Minute(), time.Second());
|
||||||
|
|
||||||
// clock radio buttons
|
// clock radio buttons
|
||||||
bounds.top = fClock->Frame().bottom + 10.0;
|
bounds.top = fClock->Frame().bottom + 10.0;
|
||||||
|
|||||||
@@ -17,11 +17,16 @@
|
|||||||
|
|
||||||
class TDateEdit;
|
class TDateEdit;
|
||||||
class TTimeEdit;
|
class TTimeEdit;
|
||||||
class BCalendarView;
|
|
||||||
class BRadioButton;
|
class BRadioButton;
|
||||||
class TAnalogClock;
|
class TAnalogClock;
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
class BCalendarView;
|
||||||
|
}
|
||||||
|
using BPrivate::BCalendarView;
|
||||||
|
|
||||||
|
|
||||||
class DateTimeView : public BView {
|
class DateTimeView : public BView {
|
||||||
public:
|
public:
|
||||||
DateTimeView(BRect frame);
|
DateTimeView(BRect frame);
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ SubDir HAIKU_TOP src preferences time ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
|
UsePrivateHeaders shared ;
|
||||||
UsePrivateSystemHeaders ;
|
UsePrivateSystemHeaders ;
|
||||||
|
|
||||||
Preference Time :
|
Preference Time :
|
||||||
AnalogClock.cpp
|
AnalogClock.cpp
|
||||||
BaseView.cpp
|
BaseView.cpp
|
||||||
Bitmaps.cpp
|
Bitmaps.cpp
|
||||||
CalendarView.cpp
|
|
||||||
DateTimeEdit.cpp
|
DateTimeEdit.cpp
|
||||||
SectionEdit.cpp
|
SectionEdit.cpp
|
||||||
DateTimeView.cpp
|
DateTimeView.cpp
|
||||||
@@ -17,8 +17,7 @@ Preference Time :
|
|||||||
TimeWindow.cpp
|
TimeWindow.cpp
|
||||||
TZDisplay.cpp
|
TZDisplay.cpp
|
||||||
ZoneView.cpp
|
ZoneView.cpp
|
||||||
DateTime.cpp
|
: be libshared.a
|
||||||
: be
|
|
||||||
: Time.rdef
|
: Time.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user