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,2017 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 class FXDirList;
32 class FXFileAssociations;
33 struct FXFileAssoc;
34 
35 
37 enum {
38  DIRLIST_SHOWFILES = 0x08000000,
39  DIRLIST_SHOWHIDDEN = 0x10000000,
40  DIRLIST_NO_OWN_ASSOC = 0x20000000
41  };
42 
43 
45 class FXAPI FXDirItem : public FXTreeItem {
46  FXDECLARE(FXDirItem)
47  friend class FXDirList;
48 protected:
49  FXFileAssoc *assoc; // File association
50  FXDirItem *link; // Link to next item
51  FXDirItem *list; // List of child items
52  FXlong size; // File size (if a file)
53  FXTime date; // Time of item
54  FXuint mode; // Mode flags
55 private:
56  FXDirItem(const FXDirItem&);
57  FXDirItem& operator=(const FXDirItem&);
58 protected:
59  FXDirItem():assoc(NULL),link(NULL),list(NULL),size(0L),date(0),mode(0){}
60 public:
61 
63  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){}
64 
66  FXbool isFile() const { return (mode&(FXIO::File))!=0; }
67 
69  FXbool isDirectory() const { return (mode&FXIO::Directory)!=0; }
70 
72  FXbool isExecutable() const { return (mode&FXIO::File)!=0 && (mode&FXIO::AllExec)!=0; }
73 
75  FXbool isSymlink() const { return (mode&FXIO::SymLink)!=0; }
76 
78  FXbool isChardev() const { return (mode&FXIO::Character)!=0; }
79 
81  FXbool isBlockdev() const { return (mode&FXIO::Block)!=0; }
82 
84  FXbool isFifo() const { return (mode&FXIO::Fifo)!=0; }
85 
87  FXbool isSocket() const { return (mode&FXIO::Socket)!=0; }
88 
90  void setAssoc(FXFileAssoc* a){ assoc=a; }
91 
93  FXFileAssoc* getAssoc() const { return assoc; }
94 
96  void setSize(FXlong s){ size=s; }
97 
99  FXlong getSize() const { return size; }
100 
102  void setDate(FXTime d){ date=d; }
103 
105  FXTime getDate() const { return date; }
106 
108  void setMode(FXuint m){ mode=m; }
109 
111  FXuint getMode() const { return mode; }
112  };
113 
114 
124 class FXAPI FXDirList : public FXTreeList {
125  FXDECLARE(FXDirList)
126 protected:
127  FXFileAssociations *associations; // Association table
128  FXDirItem *list; // Root item list
129  FXIcon *opendiricon; // Open folder icon
130  FXIcon *closeddiricon; // Closed folder icon
131  FXIcon *documenticon; // Document icon
132  FXIcon *applicationicon; // Application icon
133  FXIcon *cdromicon; // CDROM icon
134  FXIcon *harddiskicon; // Hard drive icon
135  FXIcon *networkicon; // Network icon
136  FXIcon *floppyicon; // Floppy icon
137  FXIcon *zipdiskicon; // Zip disk icon
138  FXString pattern; // Pattern of file names
139  FXString dropdirectory; // Drop directory
140  FXString dragfiles; // Dragged file names
141  FXString dropfiles; // Dropped file names
142  FXDragAction dropaction; // Drop action
143  FXuint matchmode; // File wildcard match mode
144  FXuint counter; // Refresh counter
145  FXbool draggable; // Dragable files
146 protected:
147  FXDirList();
148  void listRootItems();
149  void listChildItems(FXDirItem *par,FXbool force,FXbool notify);
150  FXString getSelectedFiles() const;
151  virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr);
152  FXTreeItem* getPathnameItem__(const FXString& path);
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 onUpdHaveSel(FXObject*,FXSelector,void*);
189  long onCmdDeleteSel(FXObject*,FXSelector,void*);
190  long onCmdDropAsk(FXObject*,FXSelector,void*);
191  long onCmdDropCopy(FXObject*,FXSelector,void*);
192  long onCmdDropMove(FXObject*,FXSelector,void*);
193  long onCmdDropLink(FXObject*,FXSelector,void*);
194 public:
195  static FXint ascending(const FXTreeItem* a,const FXTreeItem* b);
196  static FXint descending(const FXTreeItem* a,const FXTreeItem* b);
197  static FXint ascendingCase(const FXTreeItem* a,const FXTreeItem* b);
198  static FXint descendingCase(const FXTreeItem* a,const FXTreeItem* b);
199 public:
200  enum {
201  ID_REFRESHTIMER=FXTreeList::ID_LAST,
202  ID_DROPASK,
203  ID_DROPCOPY,
204  ID_DROPMOVE,
205  ID_DROPLINK,
206  ID_SHOW_FILES,
217  ID_LAST
218  };
219 public:
220 
222  FXDirList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
223 
225  virtual void create();
226 
228  virtual void detach();
229 
231  virtual void destroy();
232 
234  void scan(FXbool force=true);
235 
237  FXbool setCurrentFile(const FXString& file,FXbool notify=false);
238 
240  FXString getCurrentFile() const;
241 
243  FXbool setDirectory(const FXString& path,FXbool notify=false);
244 
246  FXString getDirectory() const;
247 
249  FXString getItemPathname(const FXTreeItem* item) const;
250 
252  FXTreeItem* getPathnameItem(const FXString& path);
253 
255  FXbool isItemFile(const FXTreeItem* item) const;
256 
258  FXbool isItemDirectory(const FXTreeItem* item) const;
259 
261  FXbool isItemExecutable(const FXTreeItem* item) const;
262 
264  FXbool isItemSymlink(const FXTreeItem* item) const;
265 
267  FXFileAssoc* getItemAssoc(const FXTreeItem* item) const;
268 
270  FXlong getItemSize(const FXTreeItem* item) const;
271 
273  FXTime getItemDate(const FXTreeItem* item) const;
274 
276  FXuint getItemMode(const FXTreeItem* item) const;
277 
279  virtual FXbool collapseTree(FXTreeItem* tree,FXbool notify=false);
280 
282  virtual FXbool expandTree(FXTreeItem* tree,FXbool notify=false);
283 
285  void setPattern(const FXString& ptrn,FXbool notify=false);
286 
288  FXString getPattern() const { return pattern; }
289 
291  void setMatchMode(FXuint mode,FXbool notify=false);
292 
294  FXuint getMatchMode() const { return matchmode; }
295 
297  void showFiles(FXbool flag,FXbool notify=false);
298 
300  FXbool showFiles() const;
301 
303  void showHiddenFiles(FXbool flag,FXbool notify=false);
304 
306  FXbool showHiddenFiles() const;
307 
309  void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false);
310 
312  FXFileAssociations* getAssociations() const { return associations; }
313 
315  void setDraggableFiles(FXbool flag,FXbool notify=false);
316 
318  FXbool getDraggableFiles() const { return draggable; }
319 
321  virtual void save(FXStream& store) const;
322 
324  virtual void load(FXStream& store);
325 
327  virtual ~FXDirList();
328  };
329 
330 }
331 
332 #endif

Copyright © 1997-2016 Jeroen van der Zijp