/* Copyright (C) 2000-2004 SKYRIX Software AG This file is part of OGo OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OGo 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with OGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id$ #include #include #include @interface UIxCalYearOverview : UIxComponent { NSArray *row; NSCalendarDate *month; } - (NSCalendarDate *)startDate; - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date; - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate inDictionary:(NSMutableDictionary *)_qp; @end @implementation UIxCalYearOverview /* init & dealloc */ - (void)dealloc { [self->row release]; [self->month release]; [super dealloc]; } /* accessors */ - (void)setRow:(NSArray *)_row { ASSIGN(self->row, _row); } - (NSArray *)row { return self->row; } - (void)setMonth:(NSCalendarDate *)_date { ASSIGN(self->month, _date); } - (NSCalendarDate *)month { return self->month; } - (int)year { return [[self selectedDate] yearOfCommonEra]; } - (NSArray *)arrayOfDateArrays { NSCalendarDate *startDate; NSMutableArray *result, *tmp; unsigned rowIdx, columnIdx; int monthOffset = 0; startDate = [self startDate]; result = [[NSMutableArray alloc] initWithCapacity:3]; for(rowIdx = 0; rowIdx < 3; rowIdx++) { tmp = [[NSMutableArray alloc] initWithCapacity:4]; for(columnIdx = 0; columnIdx < 4; columnIdx++) { NSCalendarDate *date; date = [startDate dateByAddingYears:0 months:monthOffset days:0]; [tmp addObject:date]; monthOffset++; } [result addObject:tmp]; [tmp release]; } return [result autorelease]; } /* date ranges */ - (NSCalendarDate *)startDate { return [[[NSCalendarDate alloc] initWithYear:[self year] month:1 day:1 hour:0 minute:0 second:0 timeZone:[self viewTimeZone]] autorelease]; } - (NSCalendarDate *)endDate { return nil; } /* URLs */ - (NSDictionary *)todayQueryParameters { NSCalendarDate *date; date = [NSCalendarDate date]; /* today */ return [self queryParametersBySettingSelectedDate:date]; } - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date { NSMutableDictionary *qp; qp = [[self queryParameters] mutableCopy]; [self setSelectedDateQueryParameter:_date inDictionary:qp]; return [qp autorelease]; } - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate inDictionary:(NSMutableDictionary *)_qp; { if(_newDate != nil) [_qp setObject:[self dateStringForDate:_newDate] forKey:@"day"]; else [_qp removeObjectForKey:@"day"]; } - (NSDictionary *)prevYearQueryParameters { NSCalendarDate *date; date = [[self startDate] dateByAddingYears:-1 months:0 days:0 hours:0 minutes:0 seconds:0]; return [self queryParametersBySettingSelectedDate:date]; } - (NSDictionary *)nextYearQueryParameters { NSCalendarDate *date; date = [[self startDate] dateByAddingYears:1 months:0 days:0 hours:0 minutes:0 seconds:0]; return [self queryParametersBySettingSelectedDate:date]; } @end