]> err.no Git - scalable-opengroupware.org/blob - UI/Scheduler/UIxCalMonthPrintview.m
some more work on the Kolab viewers
[scalable-opengroupware.org] / UI / Scheduler / UIxCalMonthPrintview.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
24 #include "UIxCalMonthOverview.h"
25
26 @interface UIxCalMonthPrintview : UIxCalMonthOverview
27 {
28 }
29
30 @end
31
32 #include "common.h"
33
34 @implementation UIxCalMonthPrintview
35
36 - (NSString *)shortTextForApt {
37   NSCalendarDate  *startDate, *endDate;
38   NSMutableString *aptDescr;
39   NSString        *s;
40   BOOL            isMyApt;
41   BOOL            canAccessApt;
42   BOOL            spansRange;
43   id              apt;
44   
45   apt          = [self appointment];
46   isMyApt      = [self isMyApt];
47   canAccessApt = [self canAccessApt];
48   spansRange   = NO;
49   startDate    = [apt valueForKey:@"startDate"];
50   [startDate setTimeZone:[self viewTimeZone]];
51   endDate      = [apt valueForKey:@"endDate"];
52   if(endDate != nil) {
53     [endDate setTimeZone:[self viewTimeZone]];
54     spansRange = ![endDate isEqualToDate:startDate];
55   }
56
57   aptDescr = [[NSMutableString alloc] init];
58   [aptDescr appendFormat:@"<span class=\"%@\">%02i:%02i",
59                            isMyApt ? @"monthprintview_apt_time" :
60                                      @"monthprintview_apt_time_other",
61                            [startDate hourOfDay],
62                            [startDate minuteOfHour]];
63   if(spansRange) {
64     [aptDescr appendFormat:@" - %02i:%02i",
65                              [endDate hourOfDay],
66                              [endDate minuteOfHour]];
67   }
68   [aptDescr appendFormat:@"</span>,"];
69   if (!isMyApt)
70     [aptDescr appendFormat:@"<span class=\"%@\">", [self aptStyle]];
71   if (canAccessApt) {
72     s = [apt valueForKey:@"title"];
73     if(s) {
74       [aptDescr appendFormat:@"<br />%@", s];
75     }
76     s = [apt valueForKey:@"location"];
77     if(s) {
78       [aptDescr appendFormat:@"<br />%@", s];
79     }
80   }
81   else {
82     [aptDescr appendFormat:@"<br />%@",
83       [self labelForKey:@"private appointment"]];
84   }
85   if(!isMyApt)
86     [aptDescr appendString:@"</span>"];
87   return [aptDescr autorelease];
88 }
89
90 - (NSString *)title {
91   NSCalendarDate *date;
92   
93   date = [self startOfMonth];
94   return [NSString stringWithFormat:@"%@ %d",
95     [self localizedNameForMonthOfYear:[date monthOfYear]],
96     [date yearOfCommonEra]];
97 }
98
99
100 /* style sheet */
101
102
103 - (NSString *)contentStyle {
104   if([self->currentDay monthOfYear] != [[self startOfMonth] monthOfYear])
105     return @"monthprintview_content_dimmed";
106   return @"monthprintview_content";
107 }
108
109 - (NSString *)aptStyle {
110   if (![self isMyApt])
111     return @"monthprintview_apt_other";
112   return nil;
113 }
114
115 @end