2 Copyright (C) 2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include <SOGoUI/UIxComponent.h>
25 @interface UIxCalYearOverview : UIxComponent
28 NSCalendarDate *month;
31 - (NSCalendarDate *)startDate;
33 - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date;
35 - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate
36 inDictionary:(NSMutableDictionary *)_qp;
42 @implementation UIxCalYearOverview
46 [self->month release];
52 - (void)setRow:(NSArray *)_row {
53 ASSIGN(self->row, _row);
59 - (void)setMonth:(NSCalendarDate *)_date {
60 ASSIGN(self->month, _date);
62 - (NSCalendarDate *)month {
67 return [[self selectedDate] yearOfCommonEra];
70 - (NSArray *)arrayOfDateArrays {
71 NSCalendarDate *startDate;
72 NSMutableArray *result, *tmp;
73 unsigned rowIdx, columnIdx;
76 startDate = [self startDate];
77 result = [NSMutableArray arrayWithCapacity:3];
79 for (rowIdx = 0; rowIdx < 3; rowIdx++) {
80 tmp = [[NSMutableArray alloc] initWithCapacity:4];
82 for (columnIdx = 0; columnIdx < 4; columnIdx++) {
85 date = [startDate dateByAddingYears:0 months:monthOffset days:0];
89 [result addObject:tmp];
98 - (NSCalendarDate *)startDate {
99 return [[[NSCalendarDate alloc] initWithYear:[self year] month:1 day:1
100 hour:0 minute:0 second:0
101 timeZone:[[self clientObject] userTimeZone]] autorelease];
103 - (NSCalendarDate *)endDate {
109 - (NSDictionary *)todayQueryParameters {
110 NSCalendarDate *date;
112 date = [NSCalendarDate date]; /* today */
113 return [self queryParametersBySettingSelectedDate:date];
116 - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date{
117 NSMutableDictionary *qp;
119 qp = [[self queryParameters] mutableCopy];
120 [self setSelectedDateQueryParameter:_date inDictionary:qp];
121 return [qp autorelease];
124 - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate
125 inDictionary:(NSMutableDictionary *)_qp;
128 [_qp setObject:[self dateStringForDate:_newDate] forKey:@"day"];
130 [_qp removeObjectForKey:@"day"];
133 - (NSDictionary *)prevYearQueryParameters {
134 NSCalendarDate *date;
136 date = [[self startDate] dateByAddingYears:-1 months:0 days:0
137 hours:0 minutes:0 seconds:0];
138 return [self queryParametersBySettingSelectedDate:date];
141 - (NSDictionary *)nextYearQueryParameters {
142 NSCalendarDate *date;
144 date = [[self startDate] dateByAddingYears:1 months:0 days:0
145 hours:0 minutes:0 seconds:0];
146 return [self queryParametersBySettingSelectedDate:date];
149 @end /* UIxCalYearOverview */