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 UIxTimeDateControl : UIxComponent
36 BOOL displayTimeControl;
39 - (void)setControlID:(NSString *)_controlID;
40 - (NSString *)controlID;
41 - (void)setLabel:(NSString *)_label;
43 - (void)setDate:(NSCalendarDate *)_date;
44 - (NSCalendarDate *)date;
46 - (void)setHour:(id)_hour;
48 - (void)setMinute:(id)_minute;
50 - (void)setSecond:(id)_second;
52 - (void)setDay:(id)_day;
54 - (void)setMonth:(id)_month;
56 - (void)setYear:(id)_year;
62 - (void)_setDate:(NSCalendarDate *)_date;
68 @implementation UIxTimeDateControl
73 self->displayTimeControl = YES;
79 [self->controlID release];
80 [self->label release];
83 [self->minute release];
84 [self->second release];
86 [self->month release];
93 - (void)setControlID:(NSString *)_controlID {
94 ASSIGNCOPY(self->controlID, _controlID);
96 - (NSString *)controlID {
97 return self->controlID;
99 - (void)setLabel:(NSString *)_label {
100 ASSIGNCOPY(self->label, _label);
102 - (NSString *)label {
105 - (void)setDate:(NSCalendarDate *)_date {
107 _date = [NSCalendarDate date];
108 [self _setDate:_date];
109 [self setHour:[NSNumber numberWithInt:[_date hourOfDay]]];
110 [self setMinute:[NSNumber numberWithInt:[_date minuteOfHour]]];
111 [self setYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]];
112 [self setMonth:[NSNumber numberWithInt:[_date monthOfYear]]];
113 [self setDay:[NSNumber numberWithInt:[_date dayOfMonth]]];
115 - (void)_setDate:(NSCalendarDate *)_date {
116 ASSIGN(self->date, _date);
118 - (NSCalendarDate *)date {
122 - (void)setHour:(id)_hour {
123 ASSIGN(self->hour, _hour);
128 - (void)setMinute:(id)_minute {
129 ASSIGN(self->minute, _minute);
134 - (void)setSecond:(id)_second {
135 ASSIGN(self->second, _second);
141 - (void)setDay:(id)_day {
142 ASSIGN(self->day, _day);
147 - (void)setMonth:(id)_month {
148 ASSIGN(self->month, _month);
153 - (void)setYear:(id)_year {
154 ASSIGN(self->year, _year);
160 - (NSString *)timeID {
161 return [[self controlID] stringByAppendingString:@"_time"];
163 - (NSString *)dateID {
164 return [[self controlID] stringByAppendingString:@"_date"];
167 - (void)setDisplayTimeControl:(BOOL)_displayTimeControl {
168 self->displayTimeControl = _displayTimeControl;
170 - (BOOL)displayTimeControl {
171 return self->displayTimeControl;
175 - (NSString *)timeControlStyle {
176 if (self->displayTimeControl)
177 return @"visibility : visible;";
178 return @"visibility : hidden;";
182 /* processing request */
184 - (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
186 unsigned _year, _month, _day, _hour, _minute, _second;
188 /* call super, so that the form values are applied on the popups */
189 [super takeValuesFromRequest:_rq inContext:_ctx];
191 _year = [[self year] intValue];
195 _month = [[self month] intValue];
196 _day = [[self day] intValue];
197 _hour = [[self hour] intValue];
198 _minute = [[self minute] intValue];
199 _second = [[self second] intValue];
200 d = [NSCalendarDate dateWithYear:_year
206 timeZone:[self viewTimeZone]];
210 @end /* UIxTimeDateControl */