From 4fc80701bd80bc4f5b2397cd0f4b169f65bc4d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 24 Jun 2005 16:15:27 +0000 Subject: [PATCH] Fixed warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13264 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/time/CalendarView.cpp | 66 +++++++++++++++++---------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/preferences/time/CalendarView.cpp b/src/preferences/time/CalendarView.cpp index 193e266a1e..653db197e2 100644 --- a/src/preferences/time/CalendarView.cpp +++ b/src/preferences/time/CalendarView.cpp @@ -1,3 +1,12 @@ +/* + * Copyright 2004-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Berg + */ + + #include #include @@ -7,9 +16,31 @@ #include + #define SEGMENT_CHANGE 'ostd' +// ToDo: read these out of the locale +static const char kDays[7] = { 'S', 'M', 'T', 'W', 'T', 'F', 'S' }; + + +static float +FontHeight(BView* target, bool full) +{ + font_height finfo; + target->GetFontHeight(&finfo); + float h = ceil(finfo.ascent) + ceil(finfo.descent); + + if (full) + h += ceil(finfo.leading); + + return h; +} + + +// #pragma mark - + + TDay::TDay(BRect frame, int day) : BControl(frame, B_EMPTY_STRING, NULL, NULL, B_FOLLOW_NONE, B_WILL_DRAW) , f_day(day) @@ -185,7 +216,8 @@ TDay::SetTo(int day, bool selected = false) } -/*=====> TCalendarView <=====*/ +// #pragma mark - + TCalendarView::TCalendarView(BRect frame, const char *name, uint32 resizingmode, uint32 flags) @@ -288,34 +320,20 @@ TCalendarView::KeyDown(const char *bytes, int32 numbytes) } - int32 TCalendarView::IndexOf(BView *child) const { BView *test; - for (int32 idx = 0; idx < CountChildren(); idx++) { - test = ChildAt(idx); + for (int32 index = 0; index < CountChildren(); index++) { + test = ChildAt(index); if (test == child) - return idx; + return index; } + + return -1; } -static const char days[7] = { 'S', 'M', 'T', 'W', 'T', 'F', 'S' }; - -static float -FontHeight(BView* target, bool full) -{ - font_height finfo; - target->GetFontHeight(&finfo); - float h = ceil(finfo.ascent) + ceil(finfo.descent); - - if (full) - h += ceil(finfo.leading); - - return h; -} - void TCalendarView::Draw(BRect updaterect) { @@ -331,12 +349,12 @@ TCalendarView::Draw(BRect updaterect) float offset = FontHeight(this, true); for (int i = 0; i < 7; i++) { - day = days[i]; + day = kDays[i]; width = be_plain_font->StringWidth(day.String()); - drawpt.x = bounds.left +(x -width/2.0 +2); - drawpt.y = bounds.bottom -offset/2.0; + 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); + bounds.OffsetBy(bounds.Width() + 1, 0); } }