1 | #import "PrefTable.h"
|
---|
2 |
|
---|
3 | @implementation PrefTable
|
---|
4 |
|
---|
5 | - (id)initWithFrame:(CGRect)rect {
|
---|
6 | if ((self == [ super initWithFrame: rect ]) != nil) {
|
---|
7 | int i, j;
|
---|
8 |
|
---|
9 | for(i=0;i<NUM_GROUPS;i++) {
|
---|
10 | groupcell[i] = NULL;
|
---|
11 | for(j=0;j<CELLS_PER_GROUP;j++)
|
---|
12 | cells[i][j] = NULL;
|
---|
13 | }
|
---|
14 |
|
---|
15 | [ self setDataSource: self ];
|
---|
16 | [ self setDelegate: self ];
|
---|
17 | }
|
---|
18 |
|
---|
19 | return self;
|
---|
20 | }
|
---|
21 |
|
---|
22 | - (int)numberOfGroupsInPreferencesTable:(UIPreferencesTable *)aTable {
|
---|
23 |
|
---|
24 | /* Number of logical groups, including labels */
|
---|
25 | return NUM_GROUPS;
|
---|
26 | }
|
---|
27 |
|
---|
28 | - (int)preferencesTable:(UIPreferencesTable *)aTable
|
---|
29 | numberOfRowsInGroup:(int)group
|
---|
30 | {
|
---|
31 | switch (group) {
|
---|
32 | case 0:
|
---|
33 | return 1;
|
---|
34 | break;
|
---|
35 | case 1:
|
---|
36 | return 2;
|
---|
37 | break;
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | - (UIPreferencesTableCell *)preferencesTable:
|
---|
42 | (UIPreferencesTable *)aTable
|
---|
43 | cellForGroup:(int)group
|
---|
44 | {
|
---|
45 | if (groupcell[group] != NULL)
|
---|
46 | return groupcell[group];
|
---|
47 |
|
---|
48 | groupcell[group] = [ [ UIPreferencesTableCell alloc ] init ];
|
---|
49 | switch (group) {
|
---|
50 | case 0:
|
---|
51 | [ groupcell[group] setTitle: @"Presentation" ];
|
---|
52 | break;
|
---|
53 | case 1:
|
---|
54 | [ groupcell[group] setTitle: @"Search" ];
|
---|
55 | break;
|
---|
56 | }
|
---|
57 | return groupcell[group];
|
---|
58 | }
|
---|
59 |
|
---|
60 | - (float)preferencesTable:(UIPreferencesTable *)aTable
|
---|
61 | heightForRow:(int)row
|
---|
62 | inGroup:(int)group
|
---|
63 | withProposedHeight:(float)proposed
|
---|
64 | {
|
---|
65 | /* Return height for group titles */
|
---|
66 | if (row == -1) {
|
---|
67 | if (group < 2)
|
---|
68 | return 40;
|
---|
69 | }
|
---|
70 |
|
---|
71 | if (group == 0 && row == 0) {
|
---|
72 | return 55.0;
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | return proposed;
|
---|
77 | }
|
---|
78 |
|
---|
79 | - (BOOL)preferencesTable:(UIPreferencesTable *)aTable
|
---|
80 | isLabelGroup:(int)group
|
---|
81 | {
|
---|
82 | return NO;
|
---|
83 | }
|
---|
84 |
|
---|
85 | -(UIPreferencesTableCell*) preferencesTable:
|
---|
86 | (UIPreferencesTable *)aTable
|
---|
87 | cellForRow:(int)row
|
---|
88 | inGroup:(int)group
|
---|
89 | {
|
---|
90 | UIPreferencesTableCell *cell;
|
---|
91 |
|
---|
92 | if (cells[group][row] != NULL)
|
---|
93 | return cells[group][row];
|
---|
94 |
|
---|
95 | cell = [ [ UIPreferencesTableCell alloc ] init ];
|
---|
96 | [ cell setEnabled: YES ];
|
---|
97 |
|
---|
98 | switch (group) {
|
---|
99 | case (0):
|
---|
100 | switch (row) {
|
---|
101 | case (0):
|
---|
102 | [ cell setTitle:@"Language" ];
|
---|
103 | langControl = [ [ UISegmentedControl alloc ]
|
---|
104 | initWithFrame:CGRectMake(170, 5, 135, 50)
|
---|
105 | ];
|
---|
106 | [ langControl insertSegment:0
|
---|
107 | withTitle:@"English" animated: NO ];
|
---|
108 | [ langControl insertSegment:1
|
---|
109 | withTitle:@"French" animated: NO ];
|
---|
110 | [ langControl selectSegment: 0 ];
|
---|
111 | [ cell addSubview: langControl ];
|
---|
112 | break;
|
---|
113 | }
|
---|
114 | break;
|
---|
115 | case (1):
|
---|
116 | switch (row) {
|
---|
117 | case (0):
|
---|
118 | [ cell setTitle:@"Stemming" ];
|
---|
119 | stemmingControl = [ [ UISwitchControl alloc ]
|
---|
120 | initWithFrame:CGRectMake(170, 5, 120, 55)
|
---|
121 | ];
|
---|
122 | [ stemmingControl setValue: 0.0 ];
|
---|
123 | [ cell addSubview: stemmingControl ];
|
---|
124 | break;
|
---|
125 | case (1):
|
---|
126 | [ cell setTitle:@"Case matching" ];
|
---|
127 | caseControl = [ [ UISwitchControl alloc ]
|
---|
128 | initWithFrame:CGRectMake(170, 5, 120, 30)
|
---|
129 | ];
|
---|
130 | [ caseControl setValue: 0.0 ];
|
---|
131 | [ caseControl setAlternateColors: NO ];
|
---|
132 | [ cell addSubview: caseControl ];
|
---|
133 | break;
|
---|
134 | case (2):
|
---|
135 | [ cell setTitle:@"Case matching" ];
|
---|
136 | caseControl = [ [ UISwitchControl alloc ]
|
---|
137 | initWithFrame:CGRectMake(170, 5, 120, 30)
|
---|
138 | ];
|
---|
139 | [ caseControl setValue: 0.0 ];
|
---|
140 | [ caseControl setAlternateColors: NO ];
|
---|
141 | [ cell addSubview: caseControl ];
|
---|
142 | break;
|
---|
143 | }
|
---|
144 | break;
|
---|
145 |
|
---|
146 | }
|
---|
147 |
|
---|
148 | [ cell setShowSelection: NO ];
|
---|
149 | cells[group][row] = cell;
|
---|
150 | return cell;
|
---|
151 | }
|
---|
152 |
|
---|
153 | -(NSString*) languagePref
|
---|
154 | {
|
---|
155 | NSString* lang = [NSString alloc];
|
---|
156 |
|
---|
157 | lang = [lang initWithString:@"en"];
|
---|
158 |
|
---|
159 | NSLog(@"Not checking value. Defaulting to English");
|
---|
160 |
|
---|
161 | /*
|
---|
162 | if (langControl.selectedSegment==0) {
|
---|
163 | lang = [lang initWithString:@"en"];
|
---|
164 | }
|
---|
165 | else {
|
---|
166 | lang = [lang initWithString:@"fr"];
|
---|
167 | }
|
---|
168 | */
|
---|
169 |
|
---|
170 | return lang;
|
---|
171 | }
|
---|
172 |
|
---|
173 | @end
|
---|