00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FXEXPLORER_H
00023 #define FXEXPLORER_H
00024
00025 #ifndef FXTREELIST_H
00026 #include <fox/FXTreeList.h>
00027 using namespace FX;
00028 #endif
00029 namespace FXEX {
00030
00031
00032 enum {
00033 EXPLORER_SHOWFILES = 0x08000000,
00034 EXPLORER_SHOWHIDDEN = 0x10000000,
00035 EXPLORER_NO_OWN_ASSOC = 0x20000000,
00036 EXPLORER_USER_ROOTS = 0x40000000
00037 };
00038
00039
00040
00041 class FXAPI FXExplorerItem : public FXTreeItem {
00042 FXDECLARE(FXExplorerItem)
00043 friend class FXExplorer;
00044
00045 protected:
00046 FXExplorerItem *iprev;
00047 FXExplorerItem *inext;
00048 FXExplorerItem *list;
00049 FXFileAssoc *assoc;
00050 unsigned long size;
00051 FXTime date;
00052
00053 protected:
00054 FXExplorerItem():iprev(NULL),inext(NULL),list(NULL),assoc(NULL),date(0){}
00055
00056 protected:
00057 enum {
00058 FOLDER = 512,
00059 EXECUTABLE = 1024,
00060 SYMLINK = 2048,
00061 CHARDEV = 4096,
00062 BLOCKDEV = 8192,
00063 FIFO = 16384,
00064 SOCK = 32768
00065 };
00066
00067 public:
00068
00069 FXExplorerItem(const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL):FXTreeItem(text,oi,ci,ptr),iprev(NULL),inext(NULL),list(NULL),assoc(NULL),size(0),date(0){}
00070
00071
00072 FXbool isDirectory() const { return (state&FOLDER)!=0; }
00073
00074
00075 FXbool isExecutable() const { return (state&EXECUTABLE)!=0; }
00076
00077
00078 FXbool isSymlink() const { return (state&SYMLINK)!=0; }
00079
00080
00081 FXbool isChardev() const { return (state&CHARDEV)!=0; }
00082
00083
00084 FXbool isBlockdev() const { return (state&BLOCKDEV)!=0; }
00085
00086
00087 FXbool isFifo() const { return (state&FIFO)!=0; }
00088
00089
00090 FXbool isSocket() const { return (state&SOCK)!=0; }
00091
00092
00093 FXFileAssoc* getAssoc() const { return assoc; }
00094
00095
00096 unsigned long getSize() const { return size; }
00097
00098
00099 FXTime getDate() const { return date; }
00100 };
00101
00102
00103
00104 class FXAPI FXExplorer : public FXTreeList {
00105 FXDECLARE(FXExplorer)
00106
00107 protected:
00108 FXFileDict *associations;
00109 FXString dropdirectory;
00110 FXDragAction dropaction;
00111 FXString dragfiles;
00112 FXString pattern;
00113 FXuint matchmode;
00114 FXIcon *closed_folder;
00115 FXIcon *open_folder;
00116 FXIcon *mini_doc;
00117 FXIcon *mini_app;
00118 FXIcon *cdromicon;
00119 FXIcon *harddiskicon;
00120 FXIcon *networkicon;
00121 FXIcon *floppyicon;
00122 FXIcon *zipdiskicon;
00123 FXuint counter;
00124
00125 protected:
00126
00127 FXExplorer();
00128
00129
00130 virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr);
00131
00132
00133 FXchar *getpath(const FXTreeItem* item,FXchar* pathname) const;
00134
00135
00136 FXTreeItem* getitem(FXchar* pathname);
00137
00138
00139 FXbool scanRootDir(FXbool relist);
00140
00141
00142 FXbool scanSubDir(FXExplorerItem *par,FXchar *pathname,FXbool relist);
00143
00144
00145 FXbool listSubDir(FXExplorerItem *par,FXchar *pathname);
00146
00147
00148 FXbool listRoots();
00149
00150
00151 void createRootItem(const char * path);
00152
00153
00154 FXbool effectiveAddRoot(const FXString & dir);
00155
00156
00157 FXbool effectiveRemoveRoot(const FXString & dir);
00158
00159 private:
00160 FXExplorer(const FXExplorer&);
00161 FXExplorer &operator=(const FXExplorer&);
00162
00163 public:
00164 long onRefresh(FXObject*,FXSelector,void*);
00165 long onBeginDrag(FXObject*,FXSelector,void*);
00166 long onEndDrag(FXObject*,FXSelector,void*);
00167 long onDragged(FXObject*,FXSelector,void*);
00168 long onDNDEnter(FXObject*,FXSelector,void*);
00169 long onDNDLeave(FXObject*,FXSelector,void*);
00170 long onDNDMotion(FXObject*,FXSelector,void*);
00171 long onDNDDrop(FXObject*,FXSelector,void*);
00172 long onDNDRequest(FXObject*,FXSelector,void*);
00173 long onOpened(FXObject*,FXSelector,void*);
00174 long onClosed(FXObject*,FXSelector,void*);
00175 long onExpanded(FXObject*,FXSelector,void*);
00176 long onCollapsed(FXObject*,FXSelector,void*);
00177 long onCmdSetValue(FXObject*,FXSelector,void*);
00178 long onCmdSetStringValue(FXObject*,FXSelector,void*);
00179 long onCmdGetStringValue(FXObject*,FXSelector,void*);
00180 long onCmdToggleHidden(FXObject*,FXSelector,void*);
00181 long onUpdToggleHidden(FXObject*,FXSelector,void*);
00182 long onCmdShowHidden(FXObject*,FXSelector,void*);
00183 long onUpdShowHidden(FXObject*,FXSelector,void*);
00184 long onCmdHideHidden(FXObject*,FXSelector,void*);
00185 long onUpdHideHidden(FXObject*,FXSelector,void*);
00186 long onCmdToggleFiles(FXObject*,FXSelector,void*);
00187 long onUpdToggleFiles(FXObject*,FXSelector,void*);
00188 long onCmdShowFiles(FXObject*,FXSelector,void*);
00189 long onUpdShowFiles(FXObject*,FXSelector,void*);
00190 long onCmdHideFiles(FXObject*,FXSelector,void*);
00191 long onUpdHideFiles(FXObject*,FXSelector,void*);
00192 long onCmdSetPattern(FXObject*,FXSelector,void*);
00193 long onUpdSetPattern(FXObject*,FXSelector,void*);
00194 long onCmdSortReverse(FXObject*,FXSelector,void*);
00195 long onUpdSortReverse(FXObject*,FXSelector,void*);
00196
00197 public:
00198 static FXint cmpFName(const FXTreeItem* a,const FXTreeItem* b);
00199 static FXint cmpRName(const FXTreeItem* pa,const FXTreeItem* pb);
00200
00201 public:
00202 enum {
00203 ID_REFRESH=FXTreeList::ID_LAST,
00204 ID_SHOW_FILES,
00205 ID_HIDE_FILES,
00206 ID_TOGGLE_FILES,
00207 ID_SHOW_HIDDEN,
00208 ID_HIDE_HIDDEN,
00209 ID_TOGGLE_HIDDEN,
00210 ID_SET_PATTERN,
00211 ID_SORT_REVERSE,
00212 ID_LAST
00213 };
00214
00215 public:
00216
00217 FXExplorer(FXComposite *p,FXint nvis,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00218
00219
00220 virtual void create();
00221
00222
00223 virtual void detach();
00224
00225
00226 virtual void destroy();
00227
00228
00229 FXbool addRoot(const FXString & dir);
00230
00231
00232 FXbool removeRoot(const FXString & dir);
00233
00234
00235 FXbool isItemDirectory(const FXTreeItem* item) const;
00236
00237
00238 FXbool isItemFile(const FXTreeItem* item) const;
00239
00240
00241 FXbool isItemExecutable(const FXTreeItem* item) const;
00242
00243
00244 void setCurrentFile(const FXString& file);
00245
00246
00247 FXString getCurrentFile() const;
00248
00249
00250 void setDirectory(const FXString& path);
00251
00252
00253 FXString getDirectory() const;
00254
00255
00256 FXString getItemFilename(const FXTreeItem* item) const;
00257
00258
00259 FXString getItemPathname(const FXTreeItem* item) const;
00260
00261
00262 void setPattern(const FXString& ptrn);
00263
00264
00265 FXString getPattern() const { return pattern; }
00266
00267
00268 FXuint getMatchMode() const { return matchmode; }
00269
00270
00271 void setMatchMode(FXuint mode);
00272
00273
00274 FXbool showFiles() const;
00275
00276
00277 void showFiles(FXbool showing);
00278
00279
00280 FXbool showHiddenFiles() const;
00281
00282
00283 void showHiddenFiles(FXbool showing);
00284
00285
00286 void setAssociations(FXFileDict* assoc);
00287
00288
00289 FXFileDict* getAssociations() const { return associations; }
00290
00291
00292 virtual void save(FXStream& store) const;
00293
00294
00295 virtual void load(FXStream& store);
00296
00297
00298 virtual ~FXExplorer();
00299 };
00300
00301 }
00302 #endif // FXEXPLORER_H