* 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:
Karsten Heimrich
2008-08-29 19:26:58 +00:00
parent 1d059a02b9
commit 78092ae789
11 changed files with 142 additions and 96 deletions
@@ -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.
*/
#ifndef _CALENDAR_VIEW_H_
@@ -18,6 +18,9 @@
class BMessage;
namespace BPrivate {
enum week_start {
B_WEEK_START_MONDAY,
B_WEEK_START_SUNDAY
@@ -129,6 +132,7 @@ class BCalendarView : public BView, public BInvoker {
BRect _FirstCalendarItemFrame() const;
BRect _SetNewSelectedDay(const BPoint &where);
BCalendarView(const BCalendarView &view);
BCalendarView& operator=(const BCalendarView &view);
private:
@@ -176,4 +180,8 @@ class BCalendarView : public BView, public BInvoker {
BString fDayNumbers[6][7];
};
} // namespace BPrivate
#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.
*/
#ifndef _DATE_TIME_H_
@@ -9,6 +9,9 @@
#include <String.h>
namespace BPrivate {
enum time_type {
B_GMT_TIME,
B_LOCAL_TIME
@@ -97,4 +100,8 @@ class BDateTime {
BTime fTime;
};
} // namespace BPrivate
#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.
*
* Authors:
@@ -15,6 +15,9 @@
#include <stdlib.h>
namespace BPrivate {
namespace {
float
FontHeight(const BView *view)
@@ -225,7 +228,6 @@ BCalendarView::Draw(BRect updateRect)
_UpdateSelection();
UnlockLooper();
return;
}
_DrawDays();
@@ -637,7 +639,7 @@ BCalendarView::SetDate(int32 year, int32 month, int32 day)
if (fWeekNumberHeaderVisible)
frame.left += frame.Width() / 8 - 1.0;
Invalidate(frame.InsetBySelf(4.0, 4.0));
Draw(frame.InsetBySelf(4.0, 4.0));
}
return true;
@@ -913,22 +915,22 @@ BCalendarView::_SetupWeekNumbers()
return;
date.SetDate(fYear, fMonth, 1);
int32 firstDay = date.DayOfWeek();
if (fWeekStart == B_WEEK_START_MONDAY)
firstDay -= 1;
fWeekNumbers[0].SetTo("");
fWeekNumbers[0] << date.WeekNumber();
const int32 kWeekNumber = date.WeekNumber();
int32 dateWeekNumber = kWeekNumber;
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;
for (int32 row = 1; row < 5; ++row) {
date.SetDate(fYear, fMonth, date.Day() + 7);
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&
BCalendarView::operator=(const BCalendarView &view)
{
return *this;
}
} // namespace BPrivate
@@ -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.
*
* Authors:
@@ -13,6 +13,9 @@
#include <time.h>
namespace BPrivate {
BTime::BTime()
: fHour(-1),
fMinute(-1),
@@ -481,3 +484,5 @@ BDateTime::Time_t() const
// return secs_since_jan1_1970 or -1 on error
return uint32(mktime(&tm_struct));
}
} //namespace BPrivate
+2
View File
@@ -7,7 +7,9 @@ UsePrivateHeaders shared ;
StaticLibrary libshared.a :
AboutWindow.cpp
CalendarView.cpp
ColorQuantizer.cpp
CommandPipe.cpp
DateTime.cpp
HashString.cpp
;
+7 -1
View File
@@ -8,13 +8,19 @@
*/
#include "BaseView.h"
#include "DateTime.h"
#include "TimeMessages.h"
#include <DateTime.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)
: BView(frame, name, B_FOLLOW_NONE, B_PULSE_NEEDED),
fMessage(H_TIME_UPDATE)
+3
View File
@@ -16,6 +16,9 @@
#include <String.h>
using BPrivate::B_LOCAL_TIME;
TTimeEdit::TTimeEdit(BRect frame, const char *name, uint32 sections)
: TSectionEdit(frame, name, sections)
{
+7 -1
View File
@@ -12,10 +12,16 @@
#define DATETIME_H
#include "DateTime.h"
#include "SectionEdit.h"
#include <DateTime.h>
using BPrivate::BDate;
using BPrivate::BTime;
class TTimeEdit : public TSectionEdit {
public:
TTimeEdit(BRect frame, const char *name, uint32 sections);
+9 -2
View File
@@ -11,14 +11,14 @@
#include "DateTimeView.h"
#include "AnalogClock.h"
#include "CalendarView.h"
#include "DateTimeEdit.h"
#include "TimeMessages.h"
#include "DateTime.h"
#include "TimeWindow.h"
#include <CalendarView.h>
#include <CheckBox.h>
#include <DateTime.h>
#include <Entry.h>
#include <File.h>
#include <FindDirectory.h>
@@ -31,6 +31,11 @@
#include <time.h>
using BPrivate::BCalendarView;
using BPrivate::BDateTime;
using BPrivate::B_LOCAL_TIME;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
# include <syscalls.h>
#else
@@ -232,6 +237,8 @@ DateTimeView::_InitView()
fClock = new TAnalogClock(bounds, "analogClock");
AddChild(fClock);
BTime time(BTime::CurrentTime(B_LOCAL_TIME));
fClock->SetTime(time.Hour(), time.Minute(), time.Second());
// clock radio buttons
bounds.top = fClock->Frame().bottom + 10.0;
+6 -1
View File
@@ -17,11 +17,16 @@
class TDateEdit;
class TTimeEdit;
class BCalendarView;
class BRadioButton;
class TAnalogClock;
namespace BPrivate {
class BCalendarView;
}
using BPrivate::BCalendarView;
class DateTimeView : public BView {
public:
DateTimeView(BRect frame);
+2 -3
View File
@@ -2,13 +2,13 @@ SubDir HAIKU_TOP src preferences time ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders shared ;
UsePrivateSystemHeaders ;
Preference Time :
AnalogClock.cpp
BaseView.cpp
Bitmaps.cpp
CalendarView.cpp
DateTimeEdit.cpp
SectionEdit.cpp
DateTimeView.cpp
@@ -17,8 +17,7 @@ Preference Time :
TimeWindow.cpp
TZDisplay.cpp
ZoneView.cpp
DateTime.cpp
: be
: be libshared.a
: Time.rdef
;