Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDirList.h
1 /********************************************************************************
2 * *
3 * D i r e c t o r y L i s t W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2013 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXDIRLIST_H
22 #define FXDIRLIST_H
23 
24 #ifndef FXTREELIST_H
25 #include "FXTreeList.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 struct FXFileAssoc;
32 class FXFileDict;
33 class FXIcon;
34 class FXDirList;
35 
36 
38 enum {
39  DIRLIST_SHOWFILES = 0x08000000,
40  DIRLIST_SHOWHIDDEN = 0x10000000,
41  DIRLIST_NO_OWN_ASSOC = 0x20000000
42  };
43 
44 
46 class FXAPI FXDirItem : public FXTreeItem {
47  FXDECLARE(FXDirItem)
48  friend class FXDirList;
49 protected:
50  FXFileAssoc *assoc; // File association
51  FXDirItem *link; // Link to next item
52  FXDirItem *list; // List of child items
53  FXlong size; // File size (if a file)
54  FXTime date; // Time of item
55  FXuint mode; // Mode flags
56 private:
57  FXDirItem(const FXDirItem&);
58  FXDirItem& operator=(const FXDirItem&);
59 protected:
60  FXDirItem():assoc(NULL),link(NULL),list(NULL),size(0L),date(0),mode(0){}
61 public:
62 
64  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),mode(0){}
65 
67  FXbool isFile() const { return (mode&(FXIO::File))!=0; }
68 
70  FXbool isDirectory() const { return (mode&FXIO::Directory)!=0; }
71 
73  FXbool isExecutable() const { return (mode&FXIO::File)!=0 && (mode&FXIO::AllExec)!=0; }
74 
76  FXbool isSymlink() const { return (mode&FXIO::SymLink)!=0; }
77 
79  FXbool isChardev() const { return (mode&FXIO::Character)!=0; }
80 
82  FXbool isBlockdev() const { return (mode&FXIO::Block)!=0; }
83 
85  FXbool isFifo() const { return (mode&FXIO::Fifo)!=0; }
86 
88  FXbool isSocket() const { return (mode&FXIO::Socket)!=0; }
89 
91  void setAssoc(FXFileAssoc* a){ assoc=a; }
92 
94  FXFileAssoc* getAssoc() const { return assoc; }
95 
97  void setSize(FXlong s){ size=s; }
98 
100  FXlong getSize() const { return size; }
101 
103  void setDate(FXTime d){ date=d; }
104 
106  FXTime getDate() const { return date; }
107 
109  void setMode(FXuint m){ mode=m; }
110 
112  FXuint getMode() const { return mode; }
113  };
114 
115 
125 class FXAPI FXDirList : public FXTreeList {
126  FXDECLARE(FXDirList)
127 protected:
128  FXFileDict *associations; // Association table
129  FXDirItem *list; // Root item list
130  FXIcon *opendiricon; // Open folder icon
131  FXIcon *closeddiricon; // Closed folder icon
132  FXIcon *documenticon; // Document icon
133  FXIcon *applicationicon; // Application icon
134  FXIcon *cdromicon; // CDROM icon
135  FXIcon *harddiskicon; // Hard drive icon
136  FXIcon *networkicon; // Network icon
137  FXIcon *floppyicon; // Floppy icon
138  FXIcon *zipdiskicon; // Zip disk icon
139  FXString pattern; // Pattern of file names
140  FXString dropdirectory; // Drop directory
141  FXString dragfiles; // Dragged file names
142  FXString dropfiles; // Dropped file names
143  FXDragAction dropaction; // Drop action
144  FXuint matchmode; // File wildcard match mode
145  FXuint counter; // Refresh counter
146  FXbool draggable; // Dragable files
147 protected:
148  FXDirList();
149  void listRootItems();
150  void listChildItems(FXDirItem *par);
151  FXString getSelectedFiles() const;
152  virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr);
153 private:
154  FXDirList(const FXDirList&);
155  FXDirList &operator=(const FXDirList&);
156 public:
157  long onRefreshTimer(FXObject*,FXSelector,void*);
158  long onBeginDrag(FXObject*,FXSelector,void*);
159  long onEndDrag(FXObject*,FXSelector,void*);
160  long onDragged(FXObject*,FXSelector,void*);
161  long onDNDEnter(FXObject*,FXSelector,void*);
162  long onDNDLeave(FXObject*,FXSelector,void*);
163  long onDNDMotion(FXObject*,FXSelector,void*);
164  long onDNDDrop(FXObject*,FXSelector,void*);
165  long onDNDRequest(FXObject*,FXSelector,void*);
166  long onCmdSetValue(FXObject*,FXSelector,void*);
167  long onCmdSetStringValue(FXObject*,FXSelector,void*);
168  long onCmdGetStringValue(FXObject*,FXSelector,void*);
169  long onCmdToggleHidden(FXObject*,FXSelector,void*);
170  long onUpdToggleHidden(FXObject*,FXSelector,void*);
171  long onCmdShowHidden(FXObject*,FXSelector,void*);
172  long onUpdShowHidden(FXObject*,FXSelector,void*);
173  long onCmdHideHidden(FXObject*,FXSelector,void*);
174  long onUpdHideHidden(FXObject*,FXSelector,void*);
175  long onCmdToggleFiles(FXObject*,FXSelector,void*);
176  long onUpdToggleFiles(FXObject*,FXSelector,void*);
177  long onCmdShowFiles(FXObject*,FXSelector,void*);
178  long onUpdShowFiles(FXObject*,FXSelector,void*);
179  long onCmdHideFiles(FXObject*,FXSelector,void*);
180  long onUpdHideFiles(FXObject*,FXSelector,void*);
181  long onCmdSetPattern(FXObject*,FXSelector,void*);
182  long onUpdSetPattern(FXObject*,FXSelector,void*);
183  long onCmdSortReverse(FXObject*,FXSelector,void*);
184  long onUpdSortReverse(FXObject*,FXSelector,void*);
185  long onCmdSortCase(FXObject*,FXSelector,void*);
186  long onUpdSortCase(FXObject*,FXSelector,void*);
187  long onCmdRefresh(FXObject*,FXSelector,void*);
188  long onCmdDropAsk(FXObject*,FXSelector,void*);
189  long onCmdDropCopy(FXObject*,FXSelector,void*);
190  long onCmdDropMove(FXObject*,FXSelector,void*);
191  long onCmdDropLink(FXObject*,FXSelector,void*);
192 public:
193  static FXint ascending(const FXTreeItem* a,const FXTreeItem* b);
194  static FXint descending(const FXTreeItem* a,const FXTreeItem* b);
195  static FXint ascendingCase(const FXTreeItem* a,const FXTreeItem* b);
196  static FXint descendingCase(const FXTreeItem* a,const FXTreeItem* b);
197 public:
198  enum {
199  ID_REFRESHTIMER=FXTreeList::ID_LAST,
200  ID_DROPASK,
201  ID_DROPCOPY,
202  ID_DROPMOVE,
203  ID_DROPLINK,
204  ID_SHOW_FILES,
205  ID_HIDE_FILES,
206  ID_TOGGLE_FILES,
207  ID_SHOW_HIDDEN,
208  ID_HIDE_HIDDEN,
209  ID_TOGGLE_HIDDEN,
210  ID_SET_PATTERN,
211  ID_SORT_REVERSE,
212  ID_SORT_CASE,
213  ID_REFRESH,
214  ID_LAST
215  };
216 public:
217 
219  FXDirList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
220 
222  virtual void create();
223 
225  virtual void detach();
226 
228  virtual void destroy();
229 
231  void scan(FXbool force=true);
232 
234  void setCurrentFile(const FXString& file,FXbool notify=false);
235 
237  FXString getCurrentFile() const;
238 
240  void setDirectory(const FXString& path,FXbool notify=false);
241 
243  FXString getDirectory() const;
244 
246  void setPattern(const FXString& ptrn);
247 
249  FXString getPattern() const { return pattern; }
250 
252  FXString getItemPathname(const FXTreeItem* item) const;
253 
255  FXTreeItem* getPathnameItem(const FXString& path);
256 
258  FXbool isItemFile(const FXTreeItem* item) const;
259 
261  FXbool isItemDirectory(const FXTreeItem* item) const;
262 
264  FXbool isItemExecutable(const FXTreeItem* item) const;
265 
267  FXbool isItemSymlink(const FXTreeItem* item) const;
268 
270  FXFileAssoc* getItemAssoc(const FXTreeItem* item) const;
271 
273  FXlong getItemSize(const FXTreeItem* item) const;
274 
276  FXTime getItemDate(const FXTreeItem* item) const;
277 
279  FXuint getItemMode(const FXTreeItem* item) const;
280 
282  virtual FXbool collapseTree(FXTreeItem* tree,FXbool notify=false);
283 
285  virtual FXbool expandTree(FXTreeItem* tree,FXbool notify=false);
286 
288  void setMatchMode(FXuint mode);
289 
291  FXuint getMatchMode() const { return matchmode; }
292 
294  void showFiles(FXbool flag);
295 
297  FXbool showFiles() const;
298 
300  void showHiddenFiles(FXbool flag);
301 
303  FXbool showHiddenFiles() const;
304 
306  void setAssociations(FXFileDict* assoc,FXbool owned=false);
307 
309  FXFileDict* getAssociations() const { return associations; }
310 
312  void setDraggableFiles(FXbool flag);
313 
315  FXbool getDraggableFiles() const { return draggable; }
316 
318  virtual void save(FXStream& store) const;
319 
321  virtual void load(FXStream& store);
322 
324  virtual ~FXDirList();
325  };
326 
327 }
328 
329 #endif

Copyright © 1997-2013 Jeroen van der Zijp