1 /* 2 Copyright (C) 2000-2005 SKYRIX Software AG 3 4 This file is part of SOPE. 5 6 SOPE 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 SOPE 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 SOPE; 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 22 #ifndef __WETableCalcMatrix_H__ 23 #define __WETableCalcMatrix_H__ 24 25 #import <Foundation/NSObject.h> 26 #import <Foundation/NSMapTable.h> 27 #import <Foundation/NSRange.h> 28 29 @class NSArray; 30 31 /* 32 Object to calculate HTML Table based charts, eg the 33 Appointment week-overview. 34 */ 35 36 @interface WETableCalcMatrixSpan : NSObject 37 { 38 id object; 39 NSRange range; 40 } 41 42 + (id)spanWithObject:(id)_obj range:(NSRange *)_range; 43 - (id)initWithObject:(id)_obj range:(NSRange *)_range; 44 45 /* accessors */ 46 47 - (id)object; 48 - (NSRange)range; 49 50 /* calculates accessors */ 51 52 - (BOOL)startsAtIndex:(unsigned)_idx; 53 - (BOOL)occupiesIndex:(unsigned)_idx; 54 - (unsigned)size; 55 56 @end 57 58 @interface WETableCalcMatrix : NSObject 59 { 60 void *matrix; 61 unsigned short width; 62 unsigned short height; 63 NSMapTable *objToPos; 64 id delegate; /* non-retained */ 65 BOOL columnCheck; 66 BOOL rowCheck; 67 } 68 69 - (id)initWithSize:(unsigned)_width :(unsigned)_height; 70 71 /* static accessors */ 72 73 - (unsigned)width; 74 - (unsigned)height; 75 76 - (void)setDelegate:(id)_delegate; 77 - (id)delegate; 78 79 /* clearing the structure */ 80 81 - (void)removeAllObjects; 82 83 /* adding objects */ 84 85 - (void)placeObjects:(NSArray *)_objects; 86 - (void)placeObject:(id)_object; 87 88 /* calculating */ 89 90 - (NSArray *)objectsInColumn:(unsigned)_x; 91 - (NSArray *)objectsInRow:(unsigned)_y; 92 - (NSArray *)spansOfColumn:(unsigned)_x; 93 - (NSArray *)spansOfRow:(unsigned)_y; 94 - (NSArray *)columnSpans; 95 - (NSArray *)rowSpans; 96 97 @end 98 99 @interface NSObject(WETableCalcMatrixDelegate) 100 101 /* method for optimizing matrix scan (not required) */ 102 103 - (BOOL)tableCalcMatrix:(WETableCalcMatrix *)_matrix 104 shouldProcessColumn:(unsigned)_x 105 forObject:(id)_object; 106 - (BOOL)tableCalcMatrix:(WETableCalcMatrix *)_matrix 107 shouldProcessRow:(unsigned)_y 108 forObject:(id)_object; 109 110 /* shall the object be placed at the specified coordinate ? */ 111 112 - (BOOL)tableCalcMatrix:(WETableCalcMatrix *)_matrix 113 shouldPlaceObject:(id)_object 114 atPosition:(unsigned)_x :(unsigned)_y; 115 116 /* define if you want to create own span objects */ 117 118 - (id)tableCalcMatrix:(WETableCalcMatrix *)_matrix 119 spanForObject:(id)_object 120 range:(NSRange)_range; 121 122 @end 123 124 #endif /* __WETableCalcMatrix_H__ */ 125