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 FXDIRLIST_H
00025
#define FXDIRLIST_H
00026
00027
#ifndef FXTREELIST_H
00028
#include "FXTreeList.h"
00029
#endif
00030
00031
namespace FX {
00032
00033
00034
struct FXFileAssoc;
00035
class FXFileDict;
00036
class FXIcon;
00037
class FXDirList;
00038
00039
00040
00041
enum {
00042
DIRLIST_SHOWFILES = 0x08000000,
00043
DIRLIST_SHOWHIDDEN = 0x10000000,
00044
DIRLIST_NO_OWN_ASSOC = 0x20000000
00045 };
00046
00047
00048
00049
class FXAPI FXDirItem :
public FXTreeItem {
00050 FXDECLARE(FXDirItem)
00051 friend class FXDirList;
00052 protected:
00053 FXFileAssoc *assoc;
00054 FXDirItem *link;
00055 FXDirItem *list;
00056 FXlong size;
00057 FXTime date;
00058 protected:
00059 FXDirItem():assoc(NULL),link(NULL),list(NULL),size(0L),date(0){}
00060
public:
00061
enum {
00062 FOLDER = 512,
00063 EXECUTABLE = 1024,
00064 SYMLINK = 2048,
00065 CHARDEV = 4096,
00066 BLOCKDEV = 8192,
00067 FIFO = 16384,
00068 SOCK = 32768
00069 };
00070
public:
00071
00072
00073 FXDirItem(
const FXString& text,
FXIcon* oi=NULL,
FXIcon* ci=NULL,
void* ptr=NULL):
FXTreeItem(text,oi,ci,ptr),assoc(NULL),link(NULL),list(NULL),size(0),date(0){state=HASITEMS;}
00074
00075
00076 FXbool isFile()
const {
return (state&(FOLDER|BLOCKDEV|CHARDEV|FIFO|SOCK))==0; }
00077
00078
00079 FXbool isDirectory()
const {
return (state&FOLDER)!=0; }
00080
00081
00082 FXbool isExecutable()
const {
return (state&EXECUTABLE)!=0; }
00083
00084
00085 FXbool isSymlink()
const {
return (state&SYMLINK)!=0; }
00086
00087
00088 FXbool isChardev()
const {
return (state&CHARDEV)!=0; }
00089
00090
00091 FXbool isBlockdev()
const {
return (state&BLOCKDEV)!=0; }
00092
00093
00094 FXbool isFifo()
const {
return (state&FIFO)!=0; }
00095
00096
00097 FXbool isSocket()
const {
return (state&SOCK)!=0; }
00098
00099
00100 FXFileAssoc* getAssoc()
const {
return assoc; }
00101
00102
00103 FXlong getSize()
const {
return size; }
00104
00105
00106 FXTime getDate()
const {
return date; }
00107 };
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
class FXAPI FXDirList :
public FXTreeList {
00119 FXDECLARE(FXDirList)
00120 protected:
00121 FXFileDict *associations;
00122 FXDirItem *list;
00123
FXString dropdirectory;
00124 FXDragAction dropaction;
00125
FXString dragfiles;
00126
FXString pattern;
00127 FXuint matchmode;
00128 FXuint counter;
00129
FXIcon *open_folder;
00130
FXIcon *closed_folder;
00131
FXIcon *mini_doc;
00132
FXIcon *mini_app;
00133
FXIcon *cdromicon;
00134
FXIcon *harddiskicon;
00135
FXIcon *networkicon;
00136
FXIcon *floppyicon;
00137
FXIcon *zipdiskicon;
00138 protected:
00139 FXDirList();
00140
void listRootItems();
00141
void listChildItems(FXDirItem *par);
00142 virtual
FXTreeItem* createItem(const
FXString& text,
FXIcon* oi,
FXIcon* ci,
void* ptr);
00143 private:
00144 FXDirList(const FXDirList&);
00145 FXDirList &operator=(const FXDirList&);
00146 public:
00147
long onRefreshTimer(
FXObject*,FXSelector,
void*);
00148
long onBeginDrag(FXObject*,FXSelector,
void*);
00149
long onEndDrag(FXObject*,FXSelector,
void*);
00150
long onDragged(FXObject*,FXSelector,
void*);
00151
long onDNDEnter(FXObject*,FXSelector,
void*);
00152
long onDNDLeave(FXObject*,FXSelector,
void*);
00153
long onDNDMotion(FXObject*,FXSelector,
void*);
00154
long onDNDDrop(FXObject*,FXSelector,
void*);
00155
long onDNDRequest(FXObject*,FXSelector,
void*);
00156
long onCmdSetValue(FXObject*,FXSelector,
void*);
00157
long onCmdSetStringValue(FXObject*,FXSelector,
void*);
00158
long onCmdGetStringValue(FXObject*,FXSelector,
void*);
00159
long onCmdToggleHidden(FXObject*,FXSelector,
void*);
00160
long onUpdToggleHidden(FXObject*,FXSelector,
void*);
00161
long onCmdShowHidden(FXObject*,FXSelector,
void*);
00162
long onUpdShowHidden(FXObject*,FXSelector,
void*);
00163
long onCmdHideHidden(FXObject*,FXSelector,
void*);
00164
long onUpdHideHidden(FXObject*,FXSelector,
void*);
00165
long onCmdToggleFiles(FXObject*,FXSelector,
void*);
00166
long onUpdToggleFiles(FXObject*,FXSelector,
void*);
00167
long onCmdShowFiles(FXObject*,FXSelector,
void*);
00168
long onUpdShowFiles(FXObject*,FXSelector,
void*);
00169
long onCmdHideFiles(FXObject*,FXSelector,
void*);
00170
long onUpdHideFiles(FXObject*,FXSelector,
void*);
00171
long onCmdSetPattern(FXObject*,FXSelector,
void*);
00172
long onUpdSetPattern(FXObject*,FXSelector,
void*);
00173
long onCmdSortReverse(FXObject*,FXSelector,
void*);
00174
long onUpdSortReverse(FXObject*,FXSelector,
void*);
00175
long onCmdSortCase(FXObject*,FXSelector,
void*);
00176
long onUpdSortCase(FXObject*,FXSelector,
void*);
00177
long onCmdRefresh(FXObject*,FXSelector,
void*);
00178 public:
00179 static FXint ascending(const
FXTreeItem* a,const
FXTreeItem* b);
00180 static FXint descending(const
FXTreeItem* a,const
FXTreeItem* b);
00181 static FXint ascendingCase(const
FXTreeItem* a,const
FXTreeItem* b);
00182 static FXint descendingCase(const
FXTreeItem* a,const
FXTreeItem* b);
00183 public:
00184 enum {
00185 ID_REFRESHTIMER=FXTreeList::ID_LAST,
00186 ID_SHOW_FILES,
00187 ID_HIDE_FILES,
00188 ID_TOGGLE_FILES,
00189 ID_SHOW_HIDDEN,
00190 ID_HIDE_HIDDEN,
00191 ID_TOGGLE_HIDDEN,
00192 ID_SET_PATTERN,
00193 ID_SORT_REVERSE,
00194 ID_SORT_CASE,
00195 ID_REFRESH,
00196 ID_LAST
00197 };
00198
public:
00199
00200
00201 FXDirList(
FXComposite *p,
FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00202
00203
00204
virtual void create();
00205
00206
00207
virtual void detach();
00208
00209
00210
virtual void destroy();
00211
00212
00213
void scan(FXbool force=TRUE);
00214
00215
00216 FXbool isItemDirectory(
const FXTreeItem* item)
const;
00217
00218
00219 FXbool isItemFile(
const FXTreeItem* item)
const;
00220
00221
00222 FXbool isItemExecutable(
const FXTreeItem* item)
const;
00223
00224
00225
virtual FXbool collapseTree(
FXTreeItem* tree,FXbool notify=FALSE);
00226
00227
00228
virtual FXbool expandTree(
FXTreeItem* tree,FXbool notify=FALSE);
00229
00230
00231
void setCurrentFile(
const FXString& file,FXbool notify=FALSE);
00232
00233
00234
FXString getCurrentFile() const;
00235
00236
00237
void setDirectory(const
FXString& path,FXbool notify=FALSE);
00238
00239
00240
FXString getDirectory() const;
00241
00242
00243
FXString getItemPathname(const
FXTreeItem* item) const;
00244
00245
00246
FXTreeItem* getPathnameItem(const
FXString& path);
00247
00248
00249
void setPattern(const
FXString& ptrn);
00250
00251
00252
FXString getPattern()
const {
return pattern; }
00253
00254
00255 FXuint getMatchMode()
const {
return matchmode; }
00256
00257
00258
void setMatchMode(FXuint mode);
00259
00260
00261 FXbool showFiles() const;
00262
00263
00264
void showFiles(FXbool showing);
00265
00266
00267 FXbool showHiddenFiles() const;
00268
00269
00270
void showHiddenFiles(FXbool showing);
00271
00272
00273
void setAssociations(FXFileDict* assoc);
00274
00275
00276 FXFileDict* getAssociations()
const {
return associations; }
00277
00278
00279
virtual void save(FXStream& store)
const;
00280
00281
00282
virtual void load(FXStream& store);
00283
00284
00285
virtual ~FXDirList();
00286 };
00287
00288 }
00289
00290
#endif