]> err.no Git - scalable-opengroupware.org/blob - UI/Scheduler/UIxTimeDateControl.m
moved partstat modification from UI to SoObject
[scalable-opengroupware.org] / UI / Scheduler / UIxTimeDateControl.m
1 /*
2   Copyright (C) 2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include <SOGoUI/UIxComponent.h>
24
25 @interface UIxTimeDateControl : UIxComponent
26 {
27   NSString *controlID;
28   NSString *label;
29   NSCalendarDate *date;
30   id       hour;
31   id       minute;
32   id       second;
33   id       day;
34   id       month;
35   id       year;
36   BOOL     displayTimeControl;
37 }
38
39 - (void)setControlID:(NSString *)_controlID;
40 - (NSString *)controlID;
41 - (void)setLabel:(NSString *)_label;
42 - (NSString *)label;
43 - (void)setDate:(NSCalendarDate *)_date;
44 - (NSCalendarDate *)date;
45
46 - (void)setHour:(id)_hour;
47 - (id)hour;
48 - (void)setMinute:(id)_minute;
49 - (id)minute;
50 - (void)setSecond:(id)_second;
51 - (id)second;
52 - (void)setDay:(id)_day;
53 - (id)day;
54 - (void)setMonth:(id)_month;
55 - (id)month;
56 - (void)setYear:(id)_year;
57 - (id)year;
58
59 - (NSString *)timeID;
60 - (NSString *)dateID;
61
62 - (void)_setDate:(NSCalendarDate *)_date;
63
64 @end
65
66 #include "common.h"
67
68 @implementation UIxTimeDateControl
69
70 - (id)init {
71   self = [super init];
72   if (self) {
73     self->displayTimeControl = YES;
74   }
75   return self;
76 }
77
78 - (void)dealloc {
79   [self->controlID release];
80   [self->label     release];
81   [self->date      release];
82   [self->hour      release];
83   [self->minute    release];
84   [self->second    release];
85   [self->day       release];
86   [self->month     release];
87   [self->year      release];
88   [super dealloc];
89 }
90
91 /* accessors */
92
93 - (void)setControlID:(NSString *)_controlID {
94   ASSIGNCOPY(self->controlID, _controlID);
95 }
96 - (NSString *)controlID {
97   return self->controlID;
98 }
99 - (void)setLabel:(NSString *)_label {
100   ASSIGNCOPY(self->label, _label);
101 }
102 - (NSString *)label {
103   return self->label;
104 }
105 - (void)setDate:(NSCalendarDate *)_date {
106   if (!_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]]];
114 }
115 - (void)_setDate:(NSCalendarDate *)_date {
116   ASSIGN(self->date, _date);
117 }
118 - (NSCalendarDate *)date {
119   return self->date;
120 }
121
122 - (void)setHour:(id)_hour {
123   ASSIGN(self->hour, _hour);
124 }
125 - (id)hour {
126   return self->hour;
127 }
128 - (void)setMinute:(id)_minute {
129   ASSIGN(self->minute, _minute);
130 }
131 - (id)minute {
132   return self->minute;
133 }
134 - (void)setSecond:(id)_second {
135   ASSIGN(self->second, _second);
136 }
137 - (id)second {
138   return self->second;
139 }
140
141 - (void)setDay:(id)_day {
142   ASSIGN(self->day, _day);
143 }
144 - (id)day {
145   return self->day;
146 }
147 - (void)setMonth:(id)_month {
148   ASSIGN(self->month, _month);
149 }
150 - (id)month {
151   return self->month;
152 }
153 - (void)setYear:(id)_year {
154   ASSIGN(self->year, _year);
155 }
156 - (id)year {
157   return self->year;
158 }
159
160 - (NSString *)timeID {
161   return [[self controlID] stringByAppendingString:@"_time"];
162 }
163 - (NSString *)dateID {
164   return [[self controlID] stringByAppendingString:@"_date"];
165 }
166
167 - (void)setDisplayTimeControl:(BOOL)_displayTimeControl {
168   self->displayTimeControl = _displayTimeControl;
169 }
170 - (BOOL)displayTimeControl {
171   return self->displayTimeControl;
172 }
173
174 #if 0
175 - (NSString *)timeControlStyle {
176   if (self->displayTimeControl)
177     return @"visibility : visible;";
178   return @"visibility : hidden;";
179 }
180 #endif
181
182 /* processing request */
183
184 - (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
185   NSCalendarDate *d;
186   unsigned _year, _month, _day, _hour, _minute, _second;
187
188   /* call super, so that the form values are applied on the popups */
189   [super takeValuesFromRequest:_rq inContext:_ctx];
190
191   _year  = [[self year] intValue];
192   if(_year == 0)
193       return;
194
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
201                             month:_month
202                             day:_day
203                             hour:_hour
204                             minute:_minute
205                             second:_second
206                             timeZone:[self viewTimeZone]];
207   [self _setDate:d];
208 }
209
210 @end /* UIxTimeDateControl */