gwenhywfar  5.10.1
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 
42  :FXFoldingList() {
43 }
44 
45 
46 
48 }
49 
50 
51 
52 FXFoldingItem *FOX16_GuiSortingList::getItem(int index) {
53  FXFoldingItem *ti;
54  int i=index;
55 
56  ti=getFirstItem();
57  while(ti && i) {
58  ti=ti->getNext();
59  i--;
60  }
61 
62  return ti;
63 }
64 
65 
66 
68  return header->getArrowDir(c);
69 }
70 
71 
72 
74  header->setArrowDir(c, b);
75 }
76 
77 
78 
79 long FOX16_GuiSortingList::onHeaderClicked(FXObject*, FXSelector, void* ptr) {
80  FXint idx=(FXint)(FXival)ptr;
81  FXbool b;
82  int i;
83 
84  b=header->getArrowDir(idx);
85  for (i=0; i<header->getNumItems(); i++)
86  header->setArrowDir(i, MAYBE);
87 
88  if (b==TRUE) {
89  /* was up, becomes down */
90  header->setArrowDir(idx, FALSE);
91  sortByColumn(idx, false);
92  }
93  else if (b==FALSE) {
94  /* was down, becomes MAYBE */
95  header->setArrowDir(idx, MAYBE);
96  }
97  else {
98  /* was MAYBE, becomes up */
99  header->setArrowDir(idx, TRUE);
100  sortByColumn(idx, true);
101  }
102  return 1;
103 }
104 
105 
106 
108  switch(c) {
109  case 0:
110  if (up) setSortFunc(sortFuncCol0a);
111  else setSortFunc(sortFuncCol0d);
112  break;
113  case 1:
114  if (up) setSortFunc(sortFuncCol1a);
115  else setSortFunc(sortFuncCol1d);
116  break;
117 
118  case 2:
119  if (up) setSortFunc(sortFuncCol2a);
120  else setSortFunc(sortFuncCol2d);
121  break;
122 
123  case 3:
124  if (up) setSortFunc(sortFuncCol3a);
125  else setSortFunc(sortFuncCol3d);
126  break;
127 
128  case 4:
129  if (up) setSortFunc(sortFuncCol4a);
130  else setSortFunc(sortFuncCol4d);
131  break;
132 
133  case 5:
134  if (up) setSortFunc(sortFuncCol5a);
135  else setSortFunc(sortFuncCol5d);
136  break;
137 
138  case 6:
139  if (up) setSortFunc(sortFuncCol6a);
140  else setSortFunc(sortFuncCol6d);
141  break;
142 
143  case 7:
144  if (up) setSortFunc(sortFuncCol7a);
145  else setSortFunc(sortFuncCol7d);
146  break;
147 
148  case 8:
149  if (up) setSortFunc(sortFuncCol8a);
150  else setSortFunc(sortFuncCol8d);
151  break;
152 
153  case 9:
154  if (up) setSortFunc(sortFuncCol9a);
155  else setSortFunc(sortFuncCol9d);
156  break;
157 
158  default:
159  DBG_ERROR(GWEN_LOGDOMAIN, "Column %d is out of range (no more functions)", c);
160  return;
161  }
162 
163  sortItems();
164 }
165 
166 
167 
168 
169 FXint FOX16_GuiSortingList::sortFuncCol0a(const FXFoldingItem *a, const FXFoldingItem *b) {
170  return compareSectionCase(a->getText().text(),b->getText().text(), 0);
171 }
172 
173 
174 
175 FXint FOX16_GuiSortingList::sortFuncCol0d(const FXFoldingItem *a, const FXFoldingItem *b) {
176  return compareSectionCase(b->getText().text(),a->getText().text(), 0);
177 }
178 
179 
180 
181 FXint FOX16_GuiSortingList::sortFuncCol1a(const FXFoldingItem *a, const FXFoldingItem *b) {
182  return compareSectionCase(a->getText().text(),b->getText().text(), 1);
183 }
184 
185 
186 
187 FXint FOX16_GuiSortingList::sortFuncCol1d(const FXFoldingItem *a, const FXFoldingItem *b) {
188  return compareSectionCase(b->getText().text(),a->getText().text(), 1);
189 }
190 
191 
192 
193 FXint FOX16_GuiSortingList::sortFuncCol2a(const FXFoldingItem *a, const FXFoldingItem *b) {
194  return compareSectionCase(a->getText().text(),b->getText().text(), 2);
195 }
196 
197 
198 
199 FXint FOX16_GuiSortingList::sortFuncCol2d(const FXFoldingItem *a, const FXFoldingItem *b) {
200  return compareSectionCase(b->getText().text(),a->getText().text(), 2);
201 }
202 
203 
204 
205 FXint FOX16_GuiSortingList::sortFuncCol3a(const FXFoldingItem *a, const FXFoldingItem *b) {
206  return compareSectionCase(a->getText().text(),b->getText().text(), 3);
207 }
208 
209 
210 
211 FXint FOX16_GuiSortingList::sortFuncCol3d(const FXFoldingItem *a, const FXFoldingItem *b) {
212  return compareSectionCase(b->getText().text(),a->getText().text(), 3);
213 }
214 
215 
216 
217 FXint FOX16_GuiSortingList::sortFuncCol4a(const FXFoldingItem *a, const FXFoldingItem *b) {
218  return compareSectionCase(a->getText().text(),b->getText().text(), 4);
219 }
220 
221 
222 
223 FXint FOX16_GuiSortingList::sortFuncCol4d(const FXFoldingItem *a, const FXFoldingItem *b) {
224  return compareSectionCase(b->getText().text(),a->getText().text(), 4);
225 }
226 
227 
228 
229 FXint FOX16_GuiSortingList::sortFuncCol5a(const FXFoldingItem *a, const FXFoldingItem *b) {
230  return compareSectionCase(a->getText().text(),b->getText().text(), 5);
231 }
232 
233 
234 
235 FXint FOX16_GuiSortingList::sortFuncCol5d(const FXFoldingItem *a, const FXFoldingItem *b) {
236  return compareSectionCase(b->getText().text(),a->getText().text(), 5);
237 }
238 
239 
240 
241 FXint FOX16_GuiSortingList::sortFuncCol6a(const FXFoldingItem *a, const FXFoldingItem *b) {
242  return compareSectionCase(a->getText().text(),b->getText().text(), 6);
243 }
244 
245 
246 
247 FXint FOX16_GuiSortingList::sortFuncCol6d(const FXFoldingItem *a, const FXFoldingItem *b) {
248  return compareSectionCase(b->getText().text(),a->getText().text(), 6);
249 }
250 
251 
252 
253 FXint FOX16_GuiSortingList::sortFuncCol7a(const FXFoldingItem *a, const FXFoldingItem *b) {
254  return compareSectionCase(a->getText().text(),b->getText().text(), 7);
255 }
256 
257 
258 
259 FXint FOX16_GuiSortingList::sortFuncCol7d(const FXFoldingItem *a, const FXFoldingItem *b) {
260  return compareSectionCase(b->getText().text(),a->getText().text(), 7);
261 }
262 
263 
264 
265 FXint FOX16_GuiSortingList::sortFuncCol8a(const FXFoldingItem *a, const FXFoldingItem *b) {
266  return compareSectionCase(a->getText().text(),b->getText().text(), 8);
267 }
268 
269 
270 
271 FXint FOX16_GuiSortingList::sortFuncCol8d(const FXFoldingItem *a, const FXFoldingItem *b) {
272  return compareSectionCase(b->getText().text(),a->getText().text(), 8);
273 }
274 
275 
276 
277 FXint FOX16_GuiSortingList::sortFuncCol9a(const FXFoldingItem *a, const FXFoldingItem *b) {
278  return compareSectionCase(a->getText().text(),b->getText().text(), 9);
279 }
280 
281 
282 
283 FXint FOX16_GuiSortingList::sortFuncCol9d(const FXFoldingItem *a, const FXFoldingItem *b) {
284  return compareSectionCase(b->getText().text(),a->getText().text(), 9);
285 }
286 
287 
288 
289 
290 
291 
292 
293 
294 
295 
296 
static FXint sortFuncCol3d(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol9d(const FXFoldingItem *, const FXFoldingItem *)
long onHeaderClicked(FXObject *, FXSelector, void *ptr)
static FXint sortFuncCol4a(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol5d(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol6d(const FXFoldingItem *, const FXFoldingItem *)
#define GWEN_LOGDOMAIN
Definition: logger.h:35
FXbool getHeaderArrowDir(int c) const
static FXint sortFuncCol9a(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol6a(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol1a(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol1d(const FXFoldingItem *, const FXFoldingItem *)
FXDEFMAP(FOX16_GuiSortingList) FOX16_GuiSortingListMap[]
static FXint sortFuncCol3a(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol8d(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol2d(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol2a(const FXFoldingItem *, const FXFoldingItem *)
FXIMPLEMENT(FOX16_GuiSortingList, FXFoldingList, FOX16_GuiSortingListMap, ARRAYNUMBER(FOX16_GuiSortingListMap)) FOX16_GuiSortingList
static FXint sortFuncCol7d(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol5a(const FXFoldingItem *, const FXFoldingItem *)
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
static FXint sortFuncCol0d(const FXFoldingItem *, const FXFoldingItem *)
void setHeaderArrowDir(int c, FXbool b)
static FXint sortFuncCol4d(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol0a(const FXFoldingItem *, const FXFoldingItem *)
static FXint sortFuncCol7a(const FXFoldingItem *, const FXFoldingItem *)
virtual void sortByColumn(int c, bool up)
FXFoldingItem * getItem(int idx)
static FXint sortFuncCol8a(const FXFoldingItem *, const FXFoldingItem *)