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,2022 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(nullptr),link(nullptr),list(nullptr),size(0L),date(0),mode(0){}
60 public:
61 
63  FXDirItem(const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,void* ptr=nullptr):FXTreeItem(text,oi,ci,ptr),assoc(nullptr),link(nullptr),list(nullptr),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=nullptr,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  FXbool selectMatching(const FXString& ptrn="*",FXuint mode=FXPath::PathName|FXPath::NoEscape,FXbool notify=false);
284 
286  void setPattern(const FXString& ptrn="*",FXbool notify=false);
287 
289  FXString getPattern() const { return pattern; }
290 
292  void setMatchMode(FXuint mode=FXPath::PathName|FXPath::NoEscape,FXbool notify=false);
293 
295  FXuint getMatchMode() const { return matchmode; }
296 
298  void showFiles(FXbool flag,FXbool notify=false);
299 
301  FXbool showFiles() const;
302 
304  void showHiddenFiles(FXbool flag,FXbool notify=false);
305 
307  FXbool showHiddenFiles() const;
308 
310  void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false);
311 
313  FXFileAssociations* getAssociations() const { return associations; }
314 
316  void setDraggableFiles(FXbool flag,FXbool notify=false);
317 
319  FXbool getDraggableFiles() const { return draggable; }
320 
322  virtual void save(FXStream& store) const;
323 
325  virtual void load(FXStream& store);
326 
328  virtual ~FXDirList();
329  };
330 
331 }
332 
333 #endif
Sticky bit.
Definition: FXIO.h:107
FXString getPattern() const
Return wildcard pattern.
Definition: FXDirList.h:289
Refresh immediately.
Definition: FXDirList.h:217
Is directory.
Definition: FXIO.h:98
Write permisson for all.
Definition: FXIO.h:91
FXbool getDraggableFiles() const
Are files draggable.
Definition: FXDirList.h:319
Show hidden files.
Definition: FXDirList.h:211
Is regular file.
Definition: FXIO.h:99
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
Base composite.
Definition: FXComposite.h:32
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
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
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:295
FXDirItem(const FXString &text, FXIcon *oi=nullptr, FXIcon *ci=nullptr, void *ptr=nullptr)
Constructor.
Definition: FXDirList.h:63
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
Block device.
Definition: FXIO.h:109
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
Toggle show files.
Definition: FXDirList.h:210
Toggle display of hidden files.
Definition: FXDirList.h:213
Hidden file.
Definition: FXIO.h:97
void setMode(FXuint m)
Set file mode bits.
Definition: FXDirList.h:108
A Directory List widget provides a tree-structured view of the file system.
Definition: FXDirList.h:124
Socket device.
Definition: FXIO.h:110
Character device.
Definition: FXIO.h:108
FXbool isDirectory() const
Return true if this is a directory item.
Definition: FXDirList.h:69
FXFileAssociations * getAssociations() const
Return file associations.
Definition: FXDirList.h:313
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-2022 Jeroen van der Zijp