diff --git a/ChangeLog b/ChangeLog index 8294cc5d5..ea28631d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-08-18 Wolfgang Sourdeau + * UI/Scheduler/UIxCalDateSelector.[hm]: new class designed to + display a calendar as a dynamic widget from where one can select + the current visible day. + * UI/Scheduler/NSCalendarDate+Scheduler.[hm]: category code extracted from UIxCalInlineMonthOverview.m. diff --git a/UI/Scheduler/UIxCalDateSelector.h b/UI/Scheduler/UIxCalDateSelector.h new file mode 100644 index 000000000..113d26701 --- /dev/null +++ b/UI/Scheduler/UIxCalDateSelector.h @@ -0,0 +1,47 @@ +/* UIxCalDateSelector.h - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef UIXCALDATESELECTOR_H +#define UIXCALDATESELECTOR_H + +#include "UIxCalMonthOverview.h" + +@interface UIxCalDateSelector : UIxCalMonthOverview +{ + NSCalendarDate *selectedDate; + NSString *style; + NSString *headerStyle; + NSString *weekStyle; + NSString *todayWeekStyle; + NSString *dayHeaderStyle; + NSString *dayBodyStyle; + NSString *todayBodyStyle; + NSString *inactiveDayBodyStyle; + NSString *selectedDayExtraStyle; + NSString *daySelectionHref; + NSString *weekSelectionHref; + NSString *monthSelectionHref; +} + +@end + +#endif /* UIXCALDATESELECTOR_H */ diff --git a/UI/Scheduler/UIxCalDateSelector.m b/UI/Scheduler/UIxCalDateSelector.m new file mode 100644 index 000000000..b80f8aada --- /dev/null +++ b/UI/Scheduler/UIxCalDateSelector.m @@ -0,0 +1,156 @@ +/* UIxCalDateSelector.m - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import + +#import "NSCalendarDate+Scheduler.h" + +#import "UIxCalDateSelector.h" + +@implementation UIxCalDateSelector + +/* binding accessors */ + +- (void) setSelectedDate: (NSCalendarDate *) _date +{ + ASSIGN (selectedDate, _date); + [selectedDate setTimeZone: [self viewTimeZone]]; +} + +- (NSCalendarDate *) selectedDate +{ + if (!selectedDate) + selectedDate = [super selectedDate]; + + return selectedDate; +} + +- (NSString *) style +{ + return style; +} + +- (NSString *) headerStyle +{ + return headerStyle; +} + +- (NSString *) weekStyle +{ + return weekStyle; +} + +- (void) setTodayWeekStyle: (NSString *) _style +{ + ASSIGN (todayWeekStyle, _style); +} + +- (NSString *) todayWeekStyle +{ + return ((todayWeekStyle) + ? todayWeekStyle + : [self weekStyle]); +} + +- (NSString *) dayHeaderStyle +{ + return dayHeaderStyle; +} + +- (void) setSelectedDayExtraStyle: (NSString *) _style +{ + ASSIGN(selectedDayExtraStyle, _style); +} + +- (NSString *) selectedDayExtraStyle +{ + return selectedDayExtraStyle; +} + +/* date ranges */ + +- (NSCalendarDate *) startDate +{ + return [[self selectedDate] firstDayOfMonth]; +} + +/* labels */ + +- (NSString *) headerString +{ + NSCalendarDate *date; + + date = [self startDate]; + + return [NSString stringWithFormat:@"%@ %d", + [self localizedNameForMonthOfYear: [date monthOfYear]], + [date yearOfCommonEra]]; +} + +- (NSString *) localizedDayOfWeekName +{ + return [self localizedAbbreviatedNameForDayOfWeek: [self dayOfWeek]]; +} + + +/* stylesheets */ + +- (NSString *) currentWeekStyle +{ + return (([currentWeekStart isDateInSameWeek:[NSCalendarDate date]] && + [currentWeekStart isDateInSameMonth:[self selectedDate]]) + ? [self todayWeekStyle] + : [self weekStyle]); +} + +- (NSString *) contentStyle +{ + return (([currentDay isToday] + && [currentDay isDateInSameMonth:[self selectedDate]]) + ? @"dayOfToday" + : (([currentDay monthOfYear] != [[self startDate] monthOfYear]) + ? @"inactiveDay" + : @"activeDay")); +} + +- (NSString *) extraStyle +{ + return (([[self selectedDate] isDateOnSameDay: currentDay]) + ? [self selectedDayExtraStyle] + : nil); +} + +/* URLs */ + +- (NSDictionary *) currentMonthQueryParameters +{ + return [self queryParametersBySettingSelectedDate: [self startDate]]; +} + +/* overriding */ + +- (NSArray *) fetchCoreInfos +{ + return nil; +} + +@end