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,2018 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 listItems(FXbool force,FXbool notify);
149  void listRootItems(FXbool force,FXbool notify);
150  FXbool listChildItems(FXDirItem *par,FXbool force,FXbool notify);
151  FXString getSelectedFiles() const;
152  virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr);
153  FXTreeItem* expandPath(const FXString& path,FXbool notify);
154 private:
155  FXDirList(const FXDirList&);
156  FXDirList &operator=(const FXDirList&);
157 public:
158  long onRefreshTimer(FXObject*,FXSelector,void*);
159  long onBeginDrag(FXObject*,FXSelector,void*);
160  long onEndDrag(FXObject*,FXSelector,void*);
161  long onDragged(FXObject*,FXSelector,void*);
162  long onDNDEnter(FXObject*,FXSelector,void*);
163  long onDNDLeave(FXObject*,FXSelector,void*);
164  long onDNDMotion(FXObject*,FXSelector,void*);
165  long onDNDDrop(FXObject*,FXSelector,void*);
166  long onDNDRequest(FXObject*,FXSelector,void*);
167  long onCmdSetValue(FXObject*,FXSelector,void*);
168  long onCmdSetStringValue(FXObject*,FXSelector,void*);
169  long onCmdGetStringValue(FXObject*,FXSelector,void*);
170  long onCmdToggleHidden(FXObject*,FXSelector,void*);
171  long onUpdToggleHidden(FXObject*,FXSelector,void*);
172  long onCmdShowHidden(FXObject*,FXSelector,void*);
173  long onUpdShowHidden(FXObject*,FXSelector,void*);
174  long onCmdHideHidden(FXObject*,FXSelector,void*);
175  long onUpdHideHidden(FXObject*,FXSelector,void*);
176  long onCmdToggleFiles(FXObject*,FXSelector,void*);
177  long onUpdToggleFiles(FXObject*,FXSelector,void*);
178  long onCmdShowFiles(FXObject*,FXSelector,void*);
179  long onUpdShowFiles(FXObject*,FXSelector,void*);
180  long onCmdHideFiles(FXObject*,FXSelector,void*);
181  long onUpdHideFiles(FXObject*,FXSelector,void*);
182  long onCmdSetPattern(FXObject*,FXSelector,void*);
183  long onUpdSetPattern(FXObject*,FXSelector,void*);
184  long onCmdSortReverse(FXObject*,FXSelector,void*);
185  long onUpdSortReverse(FXObject*,FXSelector,void*);
186  long onCmdSortCase(FXObject*,FXSelector,void*);
187  long onUpdSortCase(FXObject*,FXSelector,void*);
188  long onCmdRefresh(FXObject*,FXSelector,void*);
189  long onUpdHaveSel(FXObject*,FXSelector,void*);
190  long onCmdDeleteSel(FXObject*,FXSelector,void*);
191  long onCmdDropAsk(FXObject*,FXSelector,void*);
192  long onCmdDropCopy(FXObject*,FXSelector,void*);
193  long onCmdDropMove(FXObject*,FXSelector,void*);
194  long onCmdDropLink(FXObject*,FXSelector,void*);
195 public:
196  static FXint ascending(const FXTreeItem* a,const FXTreeItem* b);
197  static FXint descending(const FXTreeItem* a,const FXTreeItem* b);
198  static FXint ascendingCase(const FXTreeItem* a,const FXTreeItem* b);
199  static FXint descendingCase(const FXTreeItem* a,const FXTreeItem* b);
200 public:
201  enum {
202  ID_REFRESHTIMER=FXTreeList::ID_LAST,
203  ID_DROPASK,
204  ID_DROPCOPY,
205  ID_DROPMOVE,
206  ID_DROPLINK,
207  ID_SHOW_FILES,
218  ID_LAST
219  };
220 public:
221 
223  FXDirList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
224 
226  virtual void create();
227 
229  virtual void detach();
230 
232  virtual void destroy();
233 
235  FXbool setCurrentFile(const FXString& file,FXbool notify=false);
236 
238  FXString getCurrentFile() const;
239 
241  FXbool setDirectory(const FXString& path,FXbool notify=false);
242 
244  FXString getDirectory() const;
245 
247  FXString getItemPathname(const FXTreeItem* item) const;
248 
250  FXTreeItem* getPathnameItem(const FXString& path) const;
251 
253  FXbool isItemFile(const FXTreeItem* item) const;
254 
256  FXbool isItemDirectory(const FXTreeItem* item) const;
257 
259  FXbool isItemExecutable(const FXTreeItem* item) const;
260 
262  FXbool isItemSymlink(const FXTreeItem* item) const;
263 
265  FXFileAssoc* getItemAssoc(const FXTreeItem* item) const;
266 
268  FXlong getItemSize(const FXTreeItem* item) const;
269 
271  FXTime getItemDate(const FXTreeItem* item) const;
272 
274  FXuint getItemMode(const FXTreeItem* item) const;
275 
277  virtual FXbool collapseTree(FXTreeItem* tree,FXbool notify=false);
278 
280  virtual FXbool expandTree(FXTreeItem* tree,FXbool notify=false);
281 
283  void setPattern(const FXString& ptrn,FXbool notify=false);
284 
286  FXString getPattern() const { return pattern; }
287 
289  void setMatchMode(FXuint mode,FXbool notify=false);
290 
292  FXuint getMatchMode() const { return matchmode; }
293 
295  void showFiles(FXbool flag,FXbool notify=false);
296 
298  FXbool showFiles() const;
299 
301  void showHiddenFiles(FXbool flag,FXbool notify=false);
302 
304  FXbool showHiddenFiles() const;
305 
307  void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false);
308 
310  FXFileAssociations* getAssociations() const { return associations; }
311 
313  void setDraggableFiles(FXbool flag,FXbool notify=false);
314 
316  FXbool getDraggableFiles() const { return draggable; }
317 
319  virtual void save(FXStream& store) const;
320 
322  virtual void load(FXStream& store);
323 
325  virtual ~FXDirList();
326  };
327 
328 }
329 
330 #endif
FXString getPattern() const
Return wildcard pattern.
Definition: FXDirList.h:286
Refresh immediately.
Definition: FXDirList.h:217
FXbool getDraggableFiles() const
Are files draggable.
Definition: FXDirList.h:316
Show hidden files.
Definition: FXDirList.h:211
Show files.
Definition: FXDirList.h:208
Tree list Item.
Definition: FXTreeList.h:52
Registers stuff to know about the extension.
Definition: FXFileAssociations.h:36
FXbool isSymlink() const
Return true if this is a symbolic link item.
Definition: FXDirList.h:75
void setAssoc(FXFileAssoc *a)
Set the file-association object for this item.
Definition: FXDirList.h:90
FXbool isChardev() const
Return true if this is a character device item.
Definition: FXDirList.h:78
Hide files.
Definition: FXDirList.h:209
FXbool isFifo() const
Return true if this is an FIFO item.
Definition: FXDirList.h:84
A Tree List Widget organizes items in a hierarchical, tree-like fashion.
Definition: FXTreeList.h:243
FXFileAssoc * getAssoc() const
Return the file-association object for this item.
Definition: FXDirList.h:93
FXTime getDate() const
Return the date for this item, in nanoseconds.
Definition: FXDirList.h:105
Socket device.
Definition: FXIO.h:118
Is regular file.
Definition: FXIO.h:107
Is directory.
Definition: FXIO.h:106
Base composite.
Definition: FXComposite.h:32
Block device.
Definition: FXIO.h:117
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:78
Reverse sort order.
Definition: FXDirList.h:215
FXbool isBlockdev() const
Return true if this is a block device item.
Definition: FXDirList.h:81
FXbool isFile() const
Return true if this is a file item.
Definition: FXDirList.h:66
Hidden file.
Definition: FXIO.h:105
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
Toggle sort case sensitivity.
Definition: FXDirList.h:216
Directory item.
Definition: FXDirList.h:45
FXuint getMatchMode() const
Return wildcard matching mode.
Definition: FXDirList.h:292
Hide hidden files.
Definition: FXDirList.h:212
The FileAssociations object manages file associations between a file extension and a FileAssoc record...
Definition: FXFileAssociations.h:101
FXbool isSocket() const
Return true if this is a socket.
Definition: FXDirList.h:87
FXbool isExecutable() const
Return true if this is an executable item.
Definition: FXDirList.h:72
void setSize(FXlong s)
Set the file size for this item.
Definition: FXDirList.h:96
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:99
Toggle show files.
Definition: FXDirList.h:210
Toggle display of hidden files.
Definition: FXDirList.h:213
Character device.
Definition: FXIO.h:116
Write permisson for all.
Definition: FXIO.h:99
void setMode(FXuint m)
Set file mode bits.
Definition: FXDirList.h:108
FXDirItem(const FXString &text, FXIcon *oi=NULL, FXIcon *ci=NULL, void *ptr=NULL)
Constructor.
Definition: FXDirList.h:63
A Directory List widget provides a tree-structured view of the file system.
Definition: FXDirList.h:124
FXbool isDirectory() const
Return true if this is a directory item.
Definition: FXDirList.h:69
FXFileAssociations * getAssociations() const
Return file associations.
Definition: FXDirList.h:310
Sticky bit.
Definition: FXIO.h:115
FXuint getMode() const
Return file mode flags.
Definition: FXDirList.h:111
Set match pattern.
Definition: FXDirList.h:214
FXlong getSize() const
Return the file size for this item.
Definition: FXDirList.h:99
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42
void setDate(FXTime d)
Set the date for this item, in nanoseconds.
Definition: FXDirList.h:102

Copyright © 1997-2018 Jeroen van der Zijp