Apply patch by Hamish, closing #7947 - thanks!

* determine first day of week and draw calendarview accordingly
* some cleanup: drop superfluous DateTimeView::Draw()
* automatic whitespace cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42697 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2011-08-27 21:19:56 +00:00
parent 6041c9cd56
commit 1e07062b40
4 changed files with 29 additions and 30 deletions

View File

@ -36,10 +36,13 @@ class BCalendarView : public BView, public BInvoker {
BCalendarView(BRect frame, const char *name, week_start start,
uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
BCalendarView(const char* name,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
BCalendarView(const char* name, week_start start,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
virtual ~BCalendarView();
BCalendarView(BMessage *archive);
@ -91,7 +94,7 @@ class BCalendarView : public BView, public BInvoker {
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height);
virtual BSize MaxSize();
virtual BSize MinSize();
virtual BSize PreferredSize();

View File

@ -91,6 +91,25 @@ BCalendarView::BCalendarView(const char* name, uint32 flags)
}
BCalendarView::BCalendarView(const char* name, week_start start,
uint32 flags)
:
BView(name, flags),
BInvoker(),
fSelectionMessage(NULL),
fDay(0),
fYear(0),
fMonth(0),
fFocusChanged(false),
fSelectionChanged(false),
fWeekStart(start),
fDayNameHeaderVisible(true),
fWeekNumberHeaderVisible(true)
{
_InitObject();
}
BCalendarView::~BCalendarView()
{
SetSelectionMessage(NULL);

View File

@ -46,7 +46,7 @@ using BPrivate::B_LOCAL_TIME;
DateTimeView::DateTimeView(const char* name)
:
:
BGroupView(name, B_HORIZONTAL, 5),
fGmtTime(NULL),
fUseGmtTime(false),
@ -81,30 +81,6 @@ DateTimeView::AttachedToWindow()
}
void
DateTimeView::Draw(BRect /*updateRect*/)
{
rgb_color viewcolor = ViewColor();
rgb_color dark = tint_color(viewcolor, B_DARKEN_4_TINT);
rgb_color light = tint_color(viewcolor, B_LIGHTEN_MAX_TINT);
// draw a separator line
BRect bounds(Bounds());
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);
start.x++;
end.x++;
AddLine(start, end, light);
EndLineArray();
fTimeEdit->Draw(bounds);
fDateEdit->Draw(bounds);
}
void
DateTimeView::MessageReceived(BMessage* message)
{
@ -211,7 +187,9 @@ DateTimeView::_PrefletUptime() const
void
DateTimeView::_InitView()
{
fCalendarView = new BCalendarView("calendar");
BPrivate::week_start weekStart = (BPrivate::week_start)
BLocale::Default()->StartOfWeek();
fCalendarView = new BCalendarView("calendar", weekStart);
fCalendarView->SetWeekNumberHeaderVisible(false);
fCalendarView->SetSelectionMessage(new BMessage(kDayChanged));
fCalendarView->SetInvocationMessage(new BMessage(kDayChanged));
@ -219,7 +197,7 @@ DateTimeView::_InitView()
fDateEdit = new TDateEdit("dateEdit", 3);
fTimeEdit = new TTimeEdit("timeEdit", 4);
fClock = new TAnalogClock("analogClock");
BTime time(BTime::CurrentTime(B_LOCAL_TIME));
fClock->SetTime(time.Hour(), time.Minute(), time.Second());

View File

@ -34,7 +34,6 @@ public:
virtual ~DateTimeView();
virtual void AttachedToWindow();
virtual void Draw(BRect updaterect);
virtual void MessageReceived(BMessage* message);
bool CheckCanRevert();