00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXFILELIST_H
00025 #define FXFILELIST_H
00026
00027 #ifndef FXICONLIST_H
00028 #include "FXIconList.h"
00029 #endif
00030
00031 namespace FX {
00032
00033 struct FXFileAssoc;
00034 class FXFileDict;
00035 class FXFileList;
00036 class FXIcon;
00037 class FXIconSource;
00038 class FXIconDict;
00039
00040
00041
00042 enum {
00043 FILELIST_SHOWHIDDEN = 0x04000000,
00044 FILELIST_SHOWDIRS = 0x08000000,
00045 FILELIST_SHOWFILES = 0x10000000,
00046 FILELIST_SHOWIMAGES = 0x20000000,
00047 FILELIST_NO_OWN_ASSOC = 0x40000000,
00048 FILELIST_NO_PARENT = 0x80000000
00049 };
00050
00051
00052
00053
00054 class FXAPI FXFileItem : public FXIconItem {
00055 FXDECLARE(FXFileItem)
00056 friend class FXFileList;
00057 protected:
00058 FXFileAssoc *assoc;
00059 FXFileItem *link;
00060 FXlong size;
00061 FXTime date;
00062 private:
00063 FXFileItem(const FXFileItem&);
00064 FXFileItem& operator=(const FXFileItem&);
00065 protected:
00066 FXFileItem():assoc(NULL),link(NULL),size(0),date(0){}
00067 protected:
00068 enum{
00069 FOLDER = 64,
00070 EXECUTABLE = 128,
00071 SYMLINK = 256,
00072 CHARDEV = 512,
00073 BLOCKDEV = 1024,
00074 FIFO = 2048,
00075 SOCK = 4096,
00076 SHARE = 8192
00077 };
00078 public:
00079
00080 FXFileItem(const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,void* ptr=NULL):FXIconItem(text,bi,mi,ptr),assoc(NULL),link(NULL),size(0L),date(0){}
00081
00082
00083 FXbool isFile() const { return (state&(FOLDER|BLOCKDEV|CHARDEV|FIFO|SOCK|SHARE))==0; }
00084
00085
00086 FXbool isDirectory() const { return (state&FOLDER)!=0; }
00087
00088
00089 FXbool isShare() const { return (state&SHARE)!=0; }
00090
00091
00092 FXbool isExecutable() const { return (state&EXECUTABLE)!=0; }
00093
00094
00095 FXbool isSymlink() const { return (state&SYMLINK)!=0; }
00096
00097
00098 FXbool isChardev() const { return (state&CHARDEV)!=0; }
00099
00100
00101 FXbool isBlockdev() const { return (state&BLOCKDEV)!=0; }
00102
00103
00104 FXbool isFifo() const { return (state&FIFO)!=0; }
00105
00106
00107 FXbool isSocket() const { return (state&SOCK)!=0; }
00108
00109
00110 FXFileAssoc* getAssoc() const { return assoc; }
00111
00112
00113 FXlong getSize() const { return size; }
00114
00115
00116 FXTime getDate() const { return date; }
00117 };
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 class FXAPI FXFileList : public FXIconList {
00131 FXDECLARE(FXFileList)
00132 protected:
00133 FXString directory;
00134 FXString orgdirectory;
00135 FXString dropdirectory;
00136 FXDragAction dropaction;
00137 FXString dragfiles;
00138 FXFileDict *associations;
00139 FXFileItem *list;
00140 FXString pattern;
00141 FXuint matchmode;
00142 FXuint counter;
00143 FXint imagesize;
00144 FXTime timestamp;
00145 FXIcon *big_folder;
00146 FXIcon *mini_folder;
00147 FXIcon *big_doc;
00148 FXIcon *mini_doc;
00149 FXIcon *big_app;
00150 FXIcon *mini_app;
00151 protected:
00152 FXFileList();
00153 virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr);
00154 void listItems(FXbool force);
00155 private:
00156 FXFileList(const FXFileList&);
00157 FXFileList &operator=(const FXFileList&);
00158 public:
00159 long onOpenTimer(FXObject*,FXSelector,void*);
00160 long onRefreshTimer(FXObject*,FXSelector,void*);
00161 long onDNDEnter(FXObject*,FXSelector,void*);
00162 long onDNDLeave(FXObject*,FXSelector,void*);
00163 long onDNDMotion(FXObject*,FXSelector,void*);
00164 long onDNDDrop(FXObject*,FXSelector,void*);
00165 long onDNDRequest(FXObject*,FXSelector,void*);
00166 long onBeginDrag(FXObject*,FXSelector,void*);
00167 long onEndDrag(FXObject*,FXSelector,void*);
00168 long onDragged(FXObject*,FXSelector,void*);
00169 long onCmdSetValue(FXObject*,FXSelector,void*);
00170 long onCmdGetStringValue(FXObject*,FXSelector,void*);
00171 long onCmdSetStringValue(FXObject*,FXSelector,void*);
00172 long onCmdDirectoryUp(FXObject*,FXSelector,void*);
00173 long onUpdDirectoryUp(FXObject*,FXSelector,void*);
00174 long onCmdSortByName(FXObject*,FXSelector,void*);
00175 long onUpdSortByName(FXObject*,FXSelector,void*);
00176 long onCmdSortByType(FXObject*,FXSelector,void*);
00177 long onUpdSortByType(FXObject*,FXSelector,void*);
00178 long onCmdSortBySize(FXObject*,FXSelector,void*);
00179 long onUpdSortBySize(FXObject*,FXSelector,void*);
00180 long onCmdSortByTime(FXObject*,FXSelector,void*);
00181 long onUpdSortByTime(FXObject*,FXSelector,void*);
00182 long onCmdSortByUser(FXObject*,FXSelector,void*);
00183 long onUpdSortByUser(FXObject*,FXSelector,void*);
00184 long onCmdSortByGroup(FXObject*,FXSelector,void*);
00185 long onUpdSortByGroup(FXObject*,FXSelector,void*);
00186 long onCmdSortReverse(FXObject*,FXSelector,void*);
00187 long onUpdSortReverse(FXObject*,FXSelector,void*);
00188 long onCmdSortCase(FXObject*,FXSelector,void*);
00189 long onUpdSortCase(FXObject*,FXSelector,void*);
00190 long onCmdSetPattern(FXObject*,FXSelector,void*);
00191 long onUpdSetPattern(FXObject*,FXSelector,void*);
00192 long onCmdSetDirectory(FXObject*,FXSelector,void*);
00193 long onUpdSetDirectory(FXObject*,FXSelector,void*);
00194 long onCmdToggleHidden(FXObject*,FXSelector,void*);
00195 long onUpdToggleHidden(FXObject*,FXSelector,void*);
00196 long onCmdShowHidden(FXObject*,FXSelector,void*);
00197 long onUpdShowHidden(FXObject*,FXSelector,void*);
00198 long onCmdHideHidden(FXObject*,FXSelector,void*);
00199 long onUpdHideHidden(FXObject*,FXSelector,void*);
00200 long onCmdToggleImages(FXObject*,FXSelector,void*);
00201 long onUpdToggleImages(FXObject*,FXSelector,void*);
00202 long onCmdHeader(FXObject*,FXSelector,void*);
00203 long onUpdHeader(FXObject*,FXSelector,void*);
00204 long onCmdRefresh(FXObject*,FXSelector,void*);
00205 public:
00206 static FXint ascending(const FXIconItem* a,const FXIconItem* b);
00207 static FXint descending(const FXIconItem* a,const FXIconItem* b);
00208 static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
00209 static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
00210 static FXint ascendingType(const FXIconItem* a,const FXIconItem* b);
00211 static FXint descendingType(const FXIconItem* a,const FXIconItem* b);
00212 static FXint ascendingSize(const FXIconItem* a,const FXIconItem* b);
00213 static FXint descendingSize(const FXIconItem* a,const FXIconItem* b);
00214 static FXint ascendingTime(const FXIconItem* a,const FXIconItem* b);
00215 static FXint descendingTime(const FXIconItem* a,const FXIconItem* b);
00216 static FXint ascendingUser(const FXIconItem* a,const FXIconItem* b);
00217 static FXint descendingUser(const FXIconItem* a,const FXIconItem* b);
00218 static FXint ascendingGroup(const FXIconItem* a,const FXIconItem* b);
00219 static FXint descendingGroup(const FXIconItem* a,const FXIconItem* b);
00220 public:
00221 enum {
00222 ID_REFRESHTIMER=FXIconList::ID_LAST,
00223 ID_OPENTIMER,
00224 ID_SORT_BY_NAME,
00225 ID_SORT_BY_TYPE,
00226 ID_SORT_BY_SIZE,
00227 ID_SORT_BY_TIME,
00228 ID_SORT_BY_USER,
00229 ID_SORT_BY_GROUP,
00230 ID_SORT_REVERSE,
00231 ID_SORT_CASE,
00232 ID_DIRECTORY_UP,
00233 ID_SET_PATTERN,
00234 ID_SET_DIRECTORY,
00235 ID_SHOW_HIDDEN,
00236 ID_HIDE_HIDDEN,
00237 ID_TOGGLE_HIDDEN,
00238 ID_TOGGLE_IMAGES,
00239 ID_REFRESH,
00240 ID_LAST
00241 };
00242 public:
00243
00244
00245 FXFileList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00246
00247
00248 virtual void create();
00249
00250
00251 virtual void detach();
00252
00253
00254 virtual void destroy();
00255
00256
00257 void scan(FXbool force=TRUE);
00258
00259
00260 void setCurrentFile(const FXString& file,FXbool notify=FALSE);
00261
00262
00263 FXString getCurrentFile() const;
00264
00265
00266 void setDirectory(const FXString& path);
00267
00268
00269 FXString getDirectory() const { return directory; }
00270
00271
00272 void setPattern(const FXString& ptrn);
00273
00274
00275 FXString getPattern() const { return pattern; }
00276
00277
00278 FXbool isItemDirectory(FXint index) const;
00279
00280
00281 FXbool isItemShare(FXint index) const;
00282
00283
00284 FXbool isItemFile(FXint index) const;
00285
00286
00287 FXbool isItemExecutable(FXint index) const;
00288
00289
00290 FXString getItemFilename(FXint index) const;
00291
00292
00293 FXString getItemPathname(FXint index) const;
00294
00295
00296 FXFileAssoc* getItemAssoc(FXint index) const;
00297
00298
00299 FXuint getMatchMode() const { return matchmode; }
00300
00301
00302 void setMatchMode(FXuint mode);
00303
00304
00305 FXbool showHiddenFiles() const;
00306
00307
00308 void showHiddenFiles(FXbool showing);
00309
00310
00311 FXbool showOnlyDirectories() const;
00312
00313
00314 void showOnlyDirectories(FXbool shown);
00315
00316
00317 FXbool showOnlyFiles() const;
00318
00319
00320 void showOnlyFiles(FXbool shown);
00321
00322
00323 FXbool showImages() const;
00324
00325
00326 void showImages(FXbool showing);
00327
00328
00329 FXint getImageSize() const { return imagesize; }
00330
00331
00332 void setImageSize(FXint size);
00333
00334
00335 FXbool showParents() const;
00336
00337
00338 void showParents(FXbool shown);
00339
00340
00341 void setAssociations(FXFileDict* assoc);
00342
00343
00344 FXFileDict* getAssociations() const { return associations; }
00345
00346
00347 virtual void save(FXStream& store) const;
00348
00349
00350 virtual void load(FXStream& store);
00351
00352
00353 virtual ~FXFileList();
00354 };
00355
00356 }
00357
00358 #endif