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

FXFileList.h
1 /********************************************************************************
2 * *
3 * F i l e L i s t W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,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 FXFILELIST_H
22 #define FXFILELIST_H
23 
24 #ifndef FXICONLIST_H
25 #include "FXIconList.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 struct FXFileAssoc;
32 class FXFileList;
33 class FXIconSource;
34 class FXFileAssociations;
35 
36 
38 enum {
39  FILELIST_SHOWHIDDEN = 0x04000000,
40  FILELIST_SHOWDIRS = 0x08000000,
41  FILELIST_SHOWFILES = 0x10000000,
42  FILELIST_SHOWIMAGES = 0x20000000,
43  FILELIST_NO_OWN_ASSOC = 0x40000000,
44  FILELIST_NO_PARENT = 0x80000000
45  };
46 
47 
49 class FXAPI FXFileItem : public FXIconItem {
50  FXDECLARE(FXFileItem)
51  friend class FXFileList;
52 protected:
53  FXFileAssoc *assoc; // File association record
54  FXFileItem *link; // Link to next item
55  FXlong size; // File size
56  FXTime date; // File time
57  FXuint mode; // Mode flags
58 private:
59  FXFileItem(const FXFileItem&);
60  FXFileItem& operator=(const FXFileItem&);
61 protected:
62  FXFileItem():assoc(NULL),link(NULL),size(0),date(0){}
63 public:
64 
66  FXFileItem(const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,void* ptr=NULL):FXIconItem(text,bi,mi,ptr),assoc(NULL),link(NULL),size(0L),date(0L),mode(0){}
67 
69  FXbool isFile() const { return (mode&(FXIO::File))!=0; }
70 
72  FXbool isDirectory() const { return (mode&FXIO::Directory)!=0; }
73 
75  FXbool isExecutable() const { return (mode&FXIO::File)!=0 && (mode&FXIO::AllExec)!=0; }
76 
78  FXbool isSymlink() const { return (mode&FXIO::SymLink)!=0; }
79 
81  FXbool isChardev() const { return (mode&FXIO::Character)!=0; }
82 
84  FXbool isBlockdev() const { return (mode&FXIO::Block)!=0; }
85 
87  FXbool isFifo() const { return (mode&FXIO::Fifo)!=0; }
88 
90  FXbool isSocket() const { return (mode&FXIO::Socket)!=0; }
91 
93  FXbool isNavigational() const { return (label[0]=='.' && (label[1]=='\t' || (label[1]=='.' && label[2]=='\t'))); }
94 
96  void setAssoc(FXFileAssoc* a){ assoc=a; }
97 
99  FXFileAssoc* getAssoc() const { return assoc; }
100 
102  void setSize(FXlong s){ size=s; }
103 
105  FXlong getSize() const { return size; }
106 
108  void setDate(FXTime d){ date=d; }
109 
111  FXTime getDate() const { return date; }
112 
114  void setMode(FXuint m){ mode=m; }
115 
117  FXuint getMode() const { return mode; }
118  };
119 
120 
131 class FXAPI FXFileList : public FXIconList {
132  FXDECLARE(FXFileList)
133 protected:
134  FXFileAssociations *associations; // Association table
135  FXIconSource *iconloader; // Icon loader
136  FXFileItem *list; // File item list
137  FXIcon *big_folder; // Big folder icon
138  FXIcon *mini_folder; // Mini folder icon
139  FXIcon *big_doc; // Big document icon
140  FXIcon *mini_doc; // Mini document icon
141  FXIcon *big_app; // Big application icon
142  FXIcon *mini_app; // Mini application icon
143  FXString directory; // Current directory
144  FXString pattern; // Pattern of file names
145  FXString timeformat; // File time formatting
146  FXString startdirectory; // Start directory
147  FXString dropdirectory; // Drop directory
148  FXString clipfiles; // Clipped files
149  FXString dragfiles; // Dragged files
150  FXString dropfiles; // Dropped files
151  FXDragAction dropaction; // Drop action
152  FXuint matchmode; // File wildcard match mode
153  FXint imagesize; // Image size
154  FXTime timestamp; // Time when last refreshed
155  FXuint counter; // Refresh counter
156  FXbool clipcut; // Cut or copy
157  FXbool draggable; // Dragable files
158 protected:
159  FXFileList();
160  FXbool listItems(FXbool force,FXbool notify);
161  FXString getSelectedFiles() const;
162  virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr);
163  void delete_files(const FXString& files);
164  void copy_files(const FXString& directory,const FXString& files);
165  void move_files(const FXString& directory,const FXString& files);
166 private:
167  FXFileList(const FXFileList&);
168  FXFileList &operator=(const FXFileList&);
169 public:
170  long onOpenTimer(FXObject*,FXSelector,void*);
171  long onRefreshTimer(FXObject*,FXSelector,void*);
172  long onPreviewChore(FXObject*,FXSelector,void*);
173  long onDNDEnter(FXObject*,FXSelector,void*);
174  long onDNDLeave(FXObject*,FXSelector,void*);
175  long onDNDMotion(FXObject*,FXSelector,void*);
176  long onDNDDrop(FXObject*,FXSelector,void*);
177  long onDNDRequest(FXObject*,FXSelector,void*);
178  long onBeginDrag(FXObject*,FXSelector,void*);
179  long onEndDrag(FXObject*,FXSelector,void*);
180  long onDragged(FXObject*,FXSelector,void*);
181  long onClipboardLost(FXObject*,FXSelector,void*);
182  long onClipboardRequest(FXObject*,FXSelector,void*);
183  long onCmdSetValue(FXObject*,FXSelector,void*);
184  long onCmdGetStringValue(FXObject*,FXSelector,void*);
185  long onCmdSetStringValue(FXObject*,FXSelector,void*);
186  long onCmdDirectoryUp(FXObject*,FXSelector,void*);
187  long onUpdDirectoryUp(FXObject*,FXSelector,void*);
188  long onCmdSortByName(FXObject*,FXSelector,void*);
189  long onUpdSortByName(FXObject*,FXSelector,void*);
190  long onCmdSortByType(FXObject*,FXSelector,void*);
191  long onUpdSortByType(FXObject*,FXSelector,void*);
192  long onCmdSortBySize(FXObject*,FXSelector,void*);
193  long onUpdSortBySize(FXObject*,FXSelector,void*);
194  long onCmdSortByTime(FXObject*,FXSelector,void*);
195  long onUpdSortByTime(FXObject*,FXSelector,void*);
196  long onCmdSortByUser(FXObject*,FXSelector,void*);
197  long onUpdSortByUser(FXObject*,FXSelector,void*);
198  long onCmdSortByGroup(FXObject*,FXSelector,void*);
199  long onUpdSortByGroup(FXObject*,FXSelector,void*);
200  long onCmdSortReverse(FXObject*,FXSelector,void*);
201  long onUpdSortReverse(FXObject*,FXSelector,void*);
202  long onCmdSortCase(FXObject*,FXSelector,void*);
203  long onUpdSortCase(FXObject*,FXSelector,void*);
204  long onCmdSetPattern(FXObject*,FXSelector,void*);
205  long onUpdSetPattern(FXObject*,FXSelector,void*);
206  long onCmdSetDirectory(FXObject*,FXSelector,void*);
207  long onUpdSetDirectory(FXObject*,FXSelector,void*);
208  long onCmdToggleHidden(FXObject*,FXSelector,void*);
209  long onUpdToggleHidden(FXObject*,FXSelector,void*);
210  long onCmdShowHidden(FXObject*,FXSelector,void*);
211  long onUpdShowHidden(FXObject*,FXSelector,void*);
212  long onCmdHideHidden(FXObject*,FXSelector,void*);
213  long onUpdHideHidden(FXObject*,FXSelector,void*);
214  long onCmdToggleImages(FXObject*,FXSelector,void*);
215  long onUpdToggleImages(FXObject*,FXSelector,void*);
216  long onCmdHeader(FXObject*,FXSelector,void*);
217  long onUpdHeader(FXObject*,FXSelector,void*);
218  long onCmdRefresh(FXObject*,FXSelector,void*);
219  long onUpdHaveSel(FXObject*,FXSelector,void*);
220  long onCmdCutSel(FXObject*,FXSelector,void*);
221  long onCmdCopySel(FXObject*,FXSelector,void*);
222  long onCmdPasteSel(FXObject*,FXSelector,void*);
223  long onCmdDeleteSel(FXObject*,FXSelector,void*);
224  long onCmdDropAsk(FXObject*,FXSelector,void*);
225  long onCmdDropCopy(FXObject*,FXSelector,void*);
226  long onCmdDropMove(FXObject*,FXSelector,void*);
227  long onCmdDropLink(FXObject*,FXSelector,void*);
228 public:
229  static FXint ascending(const FXIconItem* a,const FXIconItem* b);
230  static FXint descending(const FXIconItem* a,const FXIconItem* b);
231  static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
232  static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
233  static FXint ascendingType(const FXIconItem* a,const FXIconItem* b);
234  static FXint descendingType(const FXIconItem* a,const FXIconItem* b);
235  static FXint ascendingSize(const FXIconItem* a,const FXIconItem* b);
236  static FXint descendingSize(const FXIconItem* a,const FXIconItem* b);
237  static FXint ascendingTime(const FXIconItem* a,const FXIconItem* b);
238  static FXint descendingTime(const FXIconItem* a,const FXIconItem* b);
239  static FXint ascendingUser(const FXIconItem* a,const FXIconItem* b);
240  static FXint descendingUser(const FXIconItem* a,const FXIconItem* b);
241  static FXint ascendingGroup(const FXIconItem* a,const FXIconItem* b);
242  static FXint descendingGroup(const FXIconItem* a,const FXIconItem* b);
243 public:
244  enum {
245  ID_OPENTIMER=FXIconList::ID_LAST,
246  ID_REFRESHTIMER,
247  ID_DROPASK,
248  ID_DROPCOPY,
249  ID_DROPMOVE,
250  ID_DROPLINK,
251  ID_PREVIEWCHORE,
252  ID_SORT_BY_NAME,
272  ID_LAST
273  };
274 public:
275 
277  FXFileList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
278 
280  virtual void create();
281 
283  virtual void detach();
284 
286  virtual void destroy();
287 
289  FXbool setCurrentFile(const FXString& file,FXbool notify=false);
290 
292  FXString getCurrentFile() const;
293 
295  FXbool setDirectory(const FXString& path,FXbool notify=false);
296 
298  FXString getDirectory() const { return directory; }
299 
301  FXString getItemFilename(FXint index) const;
302 
304  FXString getItemPathname(FXint index) const;
305 
307  FXbool isItemFile(FXint index) const;
308 
310  FXbool isItemDirectory(FXint index) const;
311 
313  FXbool isItemExecutable(FXint index) const;
314 
316  FXbool isItemSymlink(FXint index) const;
317 
319  FXbool isItemNavigational(FXint index) const;
320 
322  FXFileAssoc* getItemAssoc(FXint index) const;
323 
325  FXlong getItemSize(FXint index) const;
326 
328  FXTime getItemDate(FXint index) const;
329 
331  FXuint getItemMode(FXint index) const;
332 
334  void setPattern(const FXString& ptrn,FXbool notify=false);
335 
337  FXString getPattern() const { return pattern; }
338 
340  void setMatchMode(FXuint mode,FXbool notify=false);
341 
343  FXuint getMatchMode() const { return matchmode; }
344 
346  void showHiddenFiles(FXbool flag,FXbool notify=false);
347 
349  FXbool showHiddenFiles() const;
350 
352  void showOnlyDirectories(FXbool flag,FXbool notify=false);
353 
355  FXbool showOnlyDirectories() const;
356 
358  void showOnlyFiles(FXbool flag,FXbool notify=false);
359 
361  FXbool showOnlyFiles() const;
362 
364  void showParents(FXbool flag,FXbool notify=false);
365 
367  FXbool showParents() const;
368 
370  void showImages(FXbool flag,FXbool notify=false);
371 
373  FXbool showImages() const;
374 
376  void setImageSize(FXint size,FXbool notify=false);
377 
379  FXint getImageSize() const { return imagesize; }
380 
382  void setDraggableFiles(FXbool flag,FXbool notify=false);
383 
385  FXbool getDraggableFiles() const { return draggable; }
386 
388  void setTimeFormat(const FXString& fmt,FXbool notify=false);
389 
391  const FXString& getTimeFormat() const { return timeformat; }
392 
394  void setAssociations(FXFileAssociations* assoc,FXbool owned=false,FXbool notify=false);
395 
397  FXFileAssociations* getAssociations() const { return associations; }
398 
400  void setIconSource(FXIconSource* src){ iconloader=src; }
401 
403  FXIconSource* getIconSource() const { return iconloader; }
404 
406  virtual void save(FXStream& store) const;
407 
409  virtual void load(FXStream& store);
410 
412  virtual ~FXFileList();
413  };
414 
415 }
416 
417 #endif

Copyright © 1997-2016 Jeroen van der Zijp