gwenhywfar  4.7.0beta
fox16_gui_sortinglist.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Fri Jan 22 2010
3  copyright : (C) 2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 
11 #ifdef HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14 
16 
17 #include <gwenhywfar/debug.h>
18 
19 
20 
21 
22 
23 FXDEFMAP(FOX16_GuiSortingList) FOX16_GuiSortingListMap[]={
24  FXMAPFUNC(SEL_COMMAND, FXFoldingList::ID_HEADER_CHANGE, FOX16_GuiSortingList::onHeaderClicked)
25 };
26 
27 
28 
30  FOX16_GuiSortingListMap, ARRAYNUMBER(FOX16_GuiSortingListMap))
31 
32 
33 FOX16_GuiSortingList::FOX16_GuiSortingList(FXComposite *p, FXObject* tgt, FXSelector sel, FXuint opts,
34  FXint x, FXint y, FXint w, FXint h)
35 :FXFoldingList(p, tgt, sel, opts, x, y, w, h)
36 {
37 
38 }
39 
40 
41 
43 :FXFoldingList() {
44 }
45 
46 
47 
49 }
50 
51 
52 
53 FXFoldingItem *FOX16_GuiSortingList::getItem(int index) {
54  FXFoldingItem *ti;
55  int i=index;
56 
57  ti=getFirstItem();
58  while(ti && i) {
59  ti=ti->getNext();
60  i--;
61  }
62 
63  return ti;
64 }
65 
66 
67 
69  return header->getArrowDir(c);
70 }
71 
72 
73 
75  header->setArrowDir(c, b);
76 }
77 
78 
79 
80 long FOX16_GuiSortingList::onHeaderClicked(FXObject*, FXSelector, void* ptr) {
81  FXint idx=(FXint)(FXival)ptr;
82  FXbool b;
83  int i;
84 
85  b=header->getArrowDir(idx);
86  for (i=0; i<header->getNumItems(); i++)
87  header->setArrowDir(i, MAYBE);
88 
89  if (b==TRUE) {
90  /* was up, becomes down */
91  header->setArrowDir(idx, FALSE);
92  sortByColumn(idx, false);
93  }
94  else if (b==FALSE) {
95  /* was down, becomes MAYBE */
96  header->setArrowDir(idx, MAYBE);
97  }
98  else {
99  /* was MAYBE, becomes up */
100  header->setArrowDir(idx, TRUE);
101  sortByColumn(idx, true);
102  }
103  return 1;
104 }
105 
106 
107 
109  switch(c) {
110  case 0:
111  if (up) setSortFunc(sortFuncCol0a);
112  else setSortFunc(sortFuncCol0d);
113  break;
114  case 1:
115  if (up) setSortFunc(sortFuncCol1a);
116  else setSortFunc(sortFuncCol1d);
117  break;
118 
119  case 2:
120  if (up) setSortFunc(sortFuncCol2a);
121  else setSortFunc(sortFuncCol2d);
122  break;
123 
124  case 3:
125  if (up) setSortFunc(sortFuncCol3a);
126  else setSortFunc(sortFuncCol3d);
127  break;
128 
129  case 4:
130  if (up) setSortFunc(sortFuncCol4a);
131  else setSortFunc(sortFuncCol4d);
132  break;
133 
134  case 5:
135  if (up) setSortFunc(sortFuncCol5a);
136  else setSortFunc(sortFuncCol5d);
137  break;
138 
139  case 6:
140  if (up) setSortFunc(sortFuncCol6a);
141  else setSortFunc(sortFuncCol6d);
142  break;
143 
144  case 7:
145  if (up) setSortFunc(sortFuncCol7a);
146  else setSortFunc(sortFuncCol7d);
147  break;
148 
149  case 8:
150  if (up) setSortFunc(sortFuncCol8a);
151  else setSortFunc(sortFuncCol8d);
152  break;
153 
154  case 9:
155  if (up) setSortFunc(sortFuncCol9a);
156  else setSortFunc(sortFuncCol9d);
157  break;
158 
159  default:
160  DBG_ERROR(GWEN_LOGDOMAIN, "Column %d is out of range (no more functions)", c);
161  return;
162  }
163 
164  sortItems();
165 }
166 
167 
168 
169 
170 FXint FOX16_GuiSortingList::sortFuncCol0a(const FXFoldingItem *a, const FXFoldingItem *b) {
171  return compareSectionCase(a->getText().text(),b->getText().text(), 0);
172 }
173 
174 
175 
176 FXint FOX16_GuiSortingList::sortFuncCol0d(const FXFoldingItem *a, const FXFoldingItem *b) {
177  return compareSectionCase(b->getText().text(),a->getText().text(), 0);
178 }
179 
180 
181 
182 FXint FOX16_GuiSortingList::sortFuncCol1a(const FXFoldingItem *a, const FXFoldingItem *b) {
183  return compareSectionCase(a->getText().text(),b->getText().text(), 1);
184 }
185 
186 
187 
188 FXint FOX16_GuiSortingList::sortFuncCol1d(const FXFoldingItem *a, const FXFoldingItem *b) {
189  return compareSectionCase(b->getText().text(),a->getText().text(), 1);
190 }
191 
192 
193 
194 FXint FOX16_GuiSortingList::sortFuncCol2a(const FXFoldingItem *a, const FXFoldingItem *b) {
195  return compareSectionCase(a->getText().text(),b->getText().text(), 2);
196 }
197 
198 
199 
200 FXint FOX16_GuiSortingList::sortFuncCol2d(const FXFoldingItem *a, const FXFoldingItem *b) {
201  return compareSectionCase(b->getText().text(),a->getText().text(), 2);
202 }
203 
204 
205 
206 FXint FOX16_GuiSortingList::sortFuncCol3a(const FXFoldingItem *a, const FXFoldingItem *b) {
207  return compareSectionCase(a->getText().text(),b->getText().text(), 3);
208 }
209 
210 
211 
212 FXint FOX16_GuiSortingList::sortFuncCol3d(const FXFoldingItem *a, const FXFoldingItem *b) {
213  return compareSectionCase(b->getText().text(),a->getText().text(), 3);
214 }
215 
216 
217 
218 FXint FOX16_GuiSortingList::sortFuncCol4a(const FXFoldingItem *a, const FXFoldingItem *b) {
219  return compareSectionCase(a->getText().text(),b->getText().text(), 4);
220 }
221 
222 
223 
224 FXint FOX16_GuiSortingList::sortFuncCol4d(const FXFoldingItem *a, const FXFoldingItem *b) {
225  return compareSectionCase(b->getText().text(),a->getText().text(), 4);
226 }
227 
228 
229 
230 FXint FOX16_GuiSortingList::sortFuncCol5a(const FXFoldingItem *a, const FXFoldingItem *b) {
231  return compareSectionCase(a->getText().text(),b->getText().text(), 5);
232 }
233 
234 
235 
236 FXint FOX16_GuiSortingList::sortFuncCol5d(const FXFoldingItem *a, const FXFoldingItem *b) {
237  return compareSectionCase(b->getText().text(),a->getText().text(), 5);
238 }
239 
240 
241 
242 FXint FOX16_GuiSortingList::sortFuncCol6a(const FXFoldingItem *a, const FXFoldingItem *b) {
243  return compareSectionCase(a->getText().text(),b->getText().text(), 6);
244 }
245 
246 
247 
248 FXint FOX16_GuiSortingList::sortFuncCol6d(const FXFoldingItem *a, const FXFoldingItem *b) {
249  return compareSectionCase(b->getText().text(),a->getText().text(), 6);
250 }
251 
252 
253 
254 FXint FOX16_GuiSortingList::sortFuncCol7a(const FXFoldingItem *a, const FXFoldingItem *b) {
255  return compareSectionCase(a->getText().text(),b->getText().text(), 7);
256 }
257 
258 
259 
260 FXint FOX16_GuiSortingList::sortFuncCol7d(const FXFoldingItem *a, const FXFoldingItem *b) {
261  return compareSectionCase(b->getText().text(),a->getText().text(), 7);
262 }
263 
264 
265 
266 FXint FOX16_GuiSortingList::sortFuncCol8a(const FXFoldingItem *a, const FXFoldingItem *b) {
267  return compareSectionCase(a->getText().text(),b->getText().text(), 8);
268 }
269 
270 
271 
272 FXint FOX16_GuiSortingList::sortFuncCol8d(const FXFoldingItem *a, const FXFoldingItem *b) {
273  return compareSectionCase(b->getText().text(),a->getText().text(), 8);
274 }
275 
276 
277 
278 FXint FOX16_GuiSortingList::sortFuncCol9a(const FXFoldingItem *a, const FXFoldingItem *b) {
279  return compareSectionCase(a->getText().text(),b->getText().text(), 9);
280 }
281 
282 
283 
284 FXint FOX16_GuiSortingList::sortFuncCol9d(const FXFoldingItem *a, const FXFoldingItem *b) {
285  return compareSectionCase(b->getText().text(),a->getText().text(), 9);
286 }
287 
288 
289 
290 
291 
292 
293 
294 
295 
296 
297