gwenhywfar
4.3.3
|
00001 /*************************************************************************** 00002 begin : Fri Jan 22 2010 00003 copyright : (C) 2010 by Martin Preuss 00004 email : martin@libchipcard.de 00005 00006 *************************************************************************** 00007 * Please see toplevel file COPYING for license details * 00008 ***************************************************************************/ 00009 00010 00011 #ifdef HAVE_CONFIG_H 00012 # include <config.h> 00013 #endif 00014 00015 #include "fox16_gui_sortinglist_l.hpp" 00016 00017 #include <gwenhywfar/debug.h> 00018 00019 00020 00021 00022 00023 FXDEFMAP(FOX16_GuiSortingList) FOX16_GuiSortingListMap[]={ 00024 FXMAPFUNC(SEL_COMMAND, FXFoldingList::ID_HEADER_CHANGE, FOX16_GuiSortingList::onHeaderClicked) 00025 }; 00026 00027 00028 00029 FXIMPLEMENT(FOX16_GuiSortingList, FXFoldingList, 00030 FOX16_GuiSortingListMap, ARRAYNUMBER(FOX16_GuiSortingListMap)) 00031 00032 00033 FOX16_GuiSortingList::FOX16_GuiSortingList(FXComposite *p, FXObject* tgt, FXSelector sel, FXuint opts, 00034 FXint x, FXint y, FXint w, FXint h) 00035 :FXFoldingList(p, tgt, sel, opts, x, y, w, h) 00036 { 00037 00038 } 00039 00040 00041 00042 FOX16_GuiSortingList::FOX16_GuiSortingList() 00043 :FXFoldingList() { 00044 } 00045 00046 00047 00048 FOX16_GuiSortingList::~FOX16_GuiSortingList() { 00049 } 00050 00051 00052 00053 FXFoldingItem *FOX16_GuiSortingList::getItem(int index) { 00054 FXFoldingItem *ti; 00055 int i=index; 00056 00057 ti=getFirstItem(); 00058 while(ti && i) { 00059 ti=ti->getNext(); 00060 i--; 00061 } 00062 00063 return ti; 00064 } 00065 00066 00067 00068 FXbool FOX16_GuiSortingList::getHeaderArrowDir(int c) const { 00069 return header->getArrowDir(c); 00070 } 00071 00072 00073 00074 void FOX16_GuiSortingList::setHeaderArrowDir(int c, FXbool b) { 00075 header->setArrowDir(c, b); 00076 } 00077 00078 00079 00080 long FOX16_GuiSortingList::onHeaderClicked(FXObject*, FXSelector, void* ptr) { 00081 FXint idx=(FXint)(FXival)ptr; 00082 FXbool b; 00083 int i; 00084 00085 b=header->getArrowDir(idx); 00086 for (i=0; i<header->getNumItems(); i++) 00087 header->setArrowDir(i, MAYBE); 00088 00089 if (b==TRUE) { 00090 /* was up, becomes down */ 00091 header->setArrowDir(idx, FALSE); 00092 sortByColumn(idx, false); 00093 } 00094 else if (b==FALSE) { 00095 /* was down, becomes MAYBE */ 00096 header->setArrowDir(idx, MAYBE); 00097 } 00098 else { 00099 /* was MAYBE, becomes up */ 00100 header->setArrowDir(idx, TRUE); 00101 sortByColumn(idx, true); 00102 } 00103 return 1; 00104 } 00105 00106 00107 00108 void FOX16_GuiSortingList::sortByColumn(int c, bool up) { 00109 switch(c) { 00110 case 0: 00111 if (up) setSortFunc(sortFuncCol0a); 00112 else setSortFunc(sortFuncCol0d); 00113 break; 00114 case 1: 00115 if (up) setSortFunc(sortFuncCol1a); 00116 else setSortFunc(sortFuncCol1d); 00117 break; 00118 00119 case 2: 00120 if (up) setSortFunc(sortFuncCol2a); 00121 else setSortFunc(sortFuncCol2d); 00122 break; 00123 00124 case 3: 00125 if (up) setSortFunc(sortFuncCol3a); 00126 else setSortFunc(sortFuncCol3d); 00127 break; 00128 00129 case 4: 00130 if (up) setSortFunc(sortFuncCol4a); 00131 else setSortFunc(sortFuncCol4d); 00132 break; 00133 00134 case 5: 00135 if (up) setSortFunc(sortFuncCol5a); 00136 else setSortFunc(sortFuncCol5d); 00137 break; 00138 00139 case 6: 00140 if (up) setSortFunc(sortFuncCol6a); 00141 else setSortFunc(sortFuncCol6d); 00142 break; 00143 00144 case 7: 00145 if (up) setSortFunc(sortFuncCol7a); 00146 else setSortFunc(sortFuncCol7d); 00147 break; 00148 00149 case 8: 00150 if (up) setSortFunc(sortFuncCol8a); 00151 else setSortFunc(sortFuncCol8d); 00152 break; 00153 00154 case 9: 00155 if (up) setSortFunc(sortFuncCol9a); 00156 else setSortFunc(sortFuncCol9d); 00157 break; 00158 00159 default: 00160 DBG_ERROR(GWEN_LOGDOMAIN, "Column %d is out of range (no more functions)", c); 00161 return; 00162 } 00163 00164 sortItems(); 00165 } 00166 00167 00168 00169 00170 FXint FOX16_GuiSortingList::sortFuncCol0a(const FXFoldingItem *a, const FXFoldingItem *b) { 00171 return compareSectionCase(a->getText().text(),b->getText().text(), 0); 00172 } 00173 00174 00175 00176 FXint FOX16_GuiSortingList::sortFuncCol0d(const FXFoldingItem *a, const FXFoldingItem *b) { 00177 return compareSectionCase(b->getText().text(),a->getText().text(), 0); 00178 } 00179 00180 00181 00182 FXint FOX16_GuiSortingList::sortFuncCol1a(const FXFoldingItem *a, const FXFoldingItem *b) { 00183 return compareSectionCase(a->getText().text(),b->getText().text(), 1); 00184 } 00185 00186 00187 00188 FXint FOX16_GuiSortingList::sortFuncCol1d(const FXFoldingItem *a, const FXFoldingItem *b) { 00189 return compareSectionCase(b->getText().text(),a->getText().text(), 1); 00190 } 00191 00192 00193 00194 FXint FOX16_GuiSortingList::sortFuncCol2a(const FXFoldingItem *a, const FXFoldingItem *b) { 00195 return compareSectionCase(a->getText().text(),b->getText().text(), 2); 00196 } 00197 00198 00199 00200 FXint FOX16_GuiSortingList::sortFuncCol2d(const FXFoldingItem *a, const FXFoldingItem *b) { 00201 return compareSectionCase(b->getText().text(),a->getText().text(), 2); 00202 } 00203 00204 00205 00206 FXint FOX16_GuiSortingList::sortFuncCol3a(const FXFoldingItem *a, const FXFoldingItem *b) { 00207 return compareSectionCase(a->getText().text(),b->getText().text(), 3); 00208 } 00209 00210 00211 00212 FXint FOX16_GuiSortingList::sortFuncCol3d(const FXFoldingItem *a, const FXFoldingItem *b) { 00213 return compareSectionCase(b->getText().text(),a->getText().text(), 3); 00214 } 00215 00216 00217 00218 FXint FOX16_GuiSortingList::sortFuncCol4a(const FXFoldingItem *a, const FXFoldingItem *b) { 00219 return compareSectionCase(a->getText().text(),b->getText().text(), 4); 00220 } 00221 00222 00223 00224 FXint FOX16_GuiSortingList::sortFuncCol4d(const FXFoldingItem *a, const FXFoldingItem *b) { 00225 return compareSectionCase(b->getText().text(),a->getText().text(), 4); 00226 } 00227 00228 00229 00230 FXint FOX16_GuiSortingList::sortFuncCol5a(const FXFoldingItem *a, const FXFoldingItem *b) { 00231 return compareSectionCase(a->getText().text(),b->getText().text(), 5); 00232 } 00233 00234 00235 00236 FXint FOX16_GuiSortingList::sortFuncCol5d(const FXFoldingItem *a, const FXFoldingItem *b) { 00237 return compareSectionCase(b->getText().text(),a->getText().text(), 5); 00238 } 00239 00240 00241 00242 FXint FOX16_GuiSortingList::sortFuncCol6a(const FXFoldingItem *a, const FXFoldingItem *b) { 00243 return compareSectionCase(a->getText().text(),b->getText().text(), 6); 00244 } 00245 00246 00247 00248 FXint FOX16_GuiSortingList::sortFuncCol6d(const FXFoldingItem *a, const FXFoldingItem *b) { 00249 return compareSectionCase(b->getText().text(),a->getText().text(), 6); 00250 } 00251 00252 00253 00254 FXint FOX16_GuiSortingList::sortFuncCol7a(const FXFoldingItem *a, const FXFoldingItem *b) { 00255 return compareSectionCase(a->getText().text(),b->getText().text(), 7); 00256 } 00257 00258 00259 00260 FXint FOX16_GuiSortingList::sortFuncCol7d(const FXFoldingItem *a, const FXFoldingItem *b) { 00261 return compareSectionCase(b->getText().text(),a->getText().text(), 7); 00262 } 00263 00264 00265 00266 FXint FOX16_GuiSortingList::sortFuncCol8a(const FXFoldingItem *a, const FXFoldingItem *b) { 00267 return compareSectionCase(a->getText().text(),b->getText().text(), 8); 00268 } 00269 00270 00271 00272 FXint FOX16_GuiSortingList::sortFuncCol8d(const FXFoldingItem *a, const FXFoldingItem *b) { 00273 return compareSectionCase(b->getText().text(),a->getText().text(), 8); 00274 } 00275 00276 00277 00278 FXint FOX16_GuiSortingList::sortFuncCol9a(const FXFoldingItem *a, const FXFoldingItem *b) { 00279 return compareSectionCase(a->getText().text(),b->getText().text(), 9); 00280 } 00281 00282 00283 00284 FXint FOX16_GuiSortingList::sortFuncCol9d(const FXFoldingItem *a, const FXFoldingItem *b) { 00285 return compareSectionCase(b->getText().text(),a->getText().text(), 9); 00286 } 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297