FXFileList.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                        F i l e    L i s t   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXFileList.h,v 1.57 2006/01/22 17:58:01 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FX_DISABLEFILEDIRDIALOGS
00025 
00026 #ifndef FXFILELIST_H
00027 #define FXFILELIST_H
00028 
00029 #include "FXTime.h"
00030 #ifndef FXICONLIST_H
00031 #include "FXIconList.h"
00032 #endif
00033 
00034 namespace FX {
00035 
00036 struct FXFileAssoc;
00037 class FXFileDict;
00038 class FXFileList;
00039 class FXIcon;
00040 class FXIconSource;
00041 class FXIconDict;
00042 
00043 
00045 enum {
00046   FILELIST_SHOWHIDDEN   = 0x04000000, 
00047   FILELIST_SHOWDIRS     = 0x08000000, 
00048   FILELIST_SHOWFILES    = 0x10000000, 
00049   FILELIST_SHOWIMAGES   = 0x20000000, 
00050   FILELIST_NO_OWN_ASSOC = 0x40000000, 
00051   FILELIST_NO_PARENT    = 0x80000000  
00052   };
00053 
00054 
00055 
00057 class FXAPI FXFileItem : public FXIconItem {
00058   FXDECLARE(FXFileItem)
00059   friend class FXFileList;
00060 protected:
00061   FXFileAssoc  *assoc;                  // File association record
00062   FXFileItem   *link;                   // Link to next item
00063   FXlong        size;                   // File size
00064   FXTime        date;                   // File time
00065 private:
00066   FXFileItem(const FXFileItem&);
00067   FXFileItem& operator=(const FXFileItem&);
00068 protected:
00069   FXFileItem():assoc(NULL),link(NULL),size(0){}
00070 protected:
00071   enum{
00072     FOLDER     = 64,                    // Directory item
00073     EXECUTABLE = 128,                   // Executable item
00074     SYMLINK    = 256,                   // Symbolic linked item
00075     CHARDEV    = 512,                   // Character special item
00076     BLOCKDEV   = 1024,                  // Block special item
00077     FIFO       = 2048,                  // FIFO item
00078     SOCK       = 4096,                  // Socket item
00079     SHARE      = 8192                   // Share
00080     };
00081 public:
00083   FXFileItem(const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,void* ptr=NULL):FXIconItem(text,bi,mi,ptr),assoc(NULL),link(NULL),size(0L){}
00084 
00086   FXbool isFile() const { return (state&(FOLDER|BLOCKDEV|CHARDEV|FIFO|SOCK|SHARE))==0; }
00087 
00089   FXbool isDirectory() const { return (state&FOLDER)!=0; }
00090 
00092   FXbool isShare() const { return (state&SHARE)!=0; }
00093 
00095   FXbool isExecutable() const { return (state&EXECUTABLE)!=0; }
00096 
00098   FXbool isSymlink() const { return (state&SYMLINK)!=0; }
00099 
00101   FXbool isChardev() const { return (state&CHARDEV)!=0; }
00102 
00104   FXbool isBlockdev() const { return (state&BLOCKDEV)!=0; }
00105 
00107   FXbool isFifo() const { return (state&FIFO)!=0; }
00108 
00110   FXbool isSocket() const { return (state&SOCK)!=0; }
00111 
00113   FXFileAssoc* getAssoc() const { return assoc; }
00114 
00116   FXlong getSize() const { return size; }
00117 
00119   FXTime getDate() const { return date; }
00120   };
00121 
00122 
00133 class FXAPI FXFileList : public FXIconList {
00134   FXDECLARE(FXFileList)
00135 protected:
00136   FXString      directory;      // Current directory
00137   FXString      orgdirectory;   // Original directory
00138   FXString      dropdirectory;  // Drop directory
00139   FXDragAction  dropaction;     // Drop action
00140   FXString      dragfiles;      // Dragged files
00141   FXFileDict   *associations;   // Association table
00142   FXFileItem   *list;           // File item list
00143   FXString      pattern;        // Pattern of file names
00144   FXuint        matchmode;      // File wildcard match mode
00145   FXuint        counter;        // Refresh counter
00146   FXint         imagesize;      // Image size
00147   FXTime        timestamp;      // Time when last refreshed
00148   FXIcon       *big_folder;     // Big folder icon
00149   FXIcon       *mini_folder;    // Mini folder icon
00150   FXIcon       *big_doc;        // Big document icon
00151   FXIcon       *mini_doc;       // Mini document icon
00152   FXIcon       *big_app;        // Big application icon
00153   FXIcon       *mini_app;       // Mini application icon
00154 protected:
00155   FXFileList();
00156   virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr);
00157   void listItems(FXbool force);
00158 private:
00159   FXFileList(const FXFileList&);
00160   FXFileList &operator=(const FXFileList&);
00161 public:
00162   long onOpenTimer(FXObject*,FXSelector,void*);
00163   long onRefreshTimer(FXObject*,FXSelector,void*);
00164   long onDNDEnter(FXObject*,FXSelector,void*);
00165   long onDNDLeave(FXObject*,FXSelector,void*);
00166   long onDNDMotion(FXObject*,FXSelector,void*);
00167   long onDNDDrop(FXObject*,FXSelector,void*);
00168   long onDNDRequest(FXObject*,FXSelector,void*);
00169   long onBeginDrag(FXObject*,FXSelector,void*);
00170   long onEndDrag(FXObject*,FXSelector,void*);
00171   long onDragged(FXObject*,FXSelector,void*);
00172   long onCmdSetValue(FXObject*,FXSelector,void*);
00173   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00174   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00175   long onCmdDirectoryUp(FXObject*,FXSelector,void*);
00176   long onUpdDirectoryUp(FXObject*,FXSelector,void*);
00177   long onCmdSortByName(FXObject*,FXSelector,void*);
00178   long onUpdSortByName(FXObject*,FXSelector,void*);
00179   long onCmdSortByType(FXObject*,FXSelector,void*);
00180   long onUpdSortByType(FXObject*,FXSelector,void*);
00181   long onCmdSortBySize(FXObject*,FXSelector,void*);
00182   long onUpdSortBySize(FXObject*,FXSelector,void*);
00183   long onCmdSortByTime(FXObject*,FXSelector,void*);
00184   long onUpdSortByTime(FXObject*,FXSelector,void*);
00185   long onCmdSortByUser(FXObject*,FXSelector,void*);
00186   long onUpdSortByUser(FXObject*,FXSelector,void*);
00187   long onCmdSortByGroup(FXObject*,FXSelector,void*);
00188   long onUpdSortByGroup(FXObject*,FXSelector,void*);
00189   long onCmdSortReverse(FXObject*,FXSelector,void*);
00190   long onUpdSortReverse(FXObject*,FXSelector,void*);
00191   long onCmdSortCase(FXObject*,FXSelector,void*);
00192   long onUpdSortCase(FXObject*,FXSelector,void*);
00193   long onCmdSetPattern(FXObject*,FXSelector,void*);
00194   long onUpdSetPattern(FXObject*,FXSelector,void*);
00195   long onCmdSetDirectory(FXObject*,FXSelector,void*);
00196   long onUpdSetDirectory(FXObject*,FXSelector,void*);
00197   long onCmdToggleHidden(FXObject*,FXSelector,void*);
00198   long onUpdToggleHidden(FXObject*,FXSelector,void*);
00199   long onCmdShowHidden(FXObject*,FXSelector,void*);
00200   long onUpdShowHidden(FXObject*,FXSelector,void*);
00201   long onCmdHideHidden(FXObject*,FXSelector,void*);
00202   long onUpdHideHidden(FXObject*,FXSelector,void*);
00203   long onCmdToggleImages(FXObject*,FXSelector,void*);
00204   long onUpdToggleImages(FXObject*,FXSelector,void*);
00205   long onCmdHeader(FXObject*,FXSelector,void*);
00206   long onUpdHeader(FXObject*,FXSelector,void*);
00207   long onCmdRefresh(FXObject*,FXSelector,void*);
00208 public:
00209   static FXint ascending(const FXIconItem* a,const FXIconItem* b);
00210   static FXint descending(const FXIconItem* a,const FXIconItem* b);
00211   static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
00212   static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
00213   static FXint ascendingType(const FXIconItem* a,const FXIconItem* b);
00214   static FXint descendingType(const FXIconItem* a,const FXIconItem* b);
00215   static FXint ascendingSize(const FXIconItem* a,const FXIconItem* b);
00216   static FXint descendingSize(const FXIconItem* a,const FXIconItem* b);
00217   static FXint ascendingTime(const FXIconItem* a,const FXIconItem* b);
00218   static FXint descendingTime(const FXIconItem* a,const FXIconItem* b);
00219   static FXint ascendingUser(const FXIconItem* a,const FXIconItem* b);
00220   static FXint descendingUser(const FXIconItem* a,const FXIconItem* b);
00221   static FXint ascendingGroup(const FXIconItem* a,const FXIconItem* b);
00222   static FXint descendingGroup(const FXIconItem* a,const FXIconItem* b);
00223 public:
00224   enum {
00225     ID_REFRESHTIMER=FXIconList::ID_LAST,
00226     ID_OPENTIMER,
00227     ID_SORT_BY_NAME,    
00228     ID_SORT_BY_TYPE,    
00229     ID_SORT_BY_SIZE,    
00230     ID_SORT_BY_TIME,    
00231     ID_SORT_BY_USER,    
00232     ID_SORT_BY_GROUP,   
00233     ID_SORT_REVERSE,    
00234     ID_SORT_CASE,       
00235     ID_DIRECTORY_UP,    
00236     ID_SET_PATTERN,     
00237     ID_SET_DIRECTORY,   
00238     ID_SHOW_HIDDEN,     
00239     ID_HIDE_HIDDEN,     
00240     ID_TOGGLE_HIDDEN,   
00241     ID_TOGGLE_IMAGES,   
00242     ID_REFRESH,         
00243     ID_LAST
00244     };
00245 public:
00246 
00248   FXFileList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00249 
00251   virtual void create();
00252 
00254   virtual void detach();
00255 
00257   virtual void destroy();
00258 
00260   void scan(FXbool force=TRUE);
00261 
00263   void setCurrentFile(const FXString& file,FXbool notify=FALSE);
00264 
00266   FXString getCurrentFile() const;
00267 
00269   void setDirectory(const FXString& path);
00270 
00272   FXString getDirectory() const { return directory; }
00273 
00275   void setPattern(const FXString& ptrn);
00276 
00278   FXString getPattern() const { return pattern; }
00279 
00281   FXbool isItemDirectory(FXint index) const;
00282 
00284   FXbool isItemShare(FXint index) const;
00285 
00287   FXbool isItemFile(FXint index) const;
00288 
00290   FXbool isItemExecutable(FXint index) const;
00291 
00293   FXString getItemFilename(FXint index) const;
00294 
00296   FXString getItemPathname(FXint index) const;
00297 
00299   FXFileAssoc* getItemAssoc(FXint index) const;
00300 
00302   FXuint getMatchMode() const { return matchmode; }
00303 
00305   void setMatchMode(FXuint mode);
00306 
00308   FXbool showHiddenFiles() const;
00309 
00311   void showHiddenFiles(FXbool showing);
00312 
00314   FXbool showOnlyDirectories() const;
00315 
00317   void showOnlyDirectories(FXbool shown);
00318 
00320   FXbool showOnlyFiles() const;
00321 
00323   void showOnlyFiles(FXbool shown);
00324 
00326   FXbool showImages() const;
00327 
00329   void showImages(FXbool showing);
00330 
00332   FXint getImageSize() const { return imagesize; }
00333 
00335   void setImageSize(FXint size);
00336 
00338   FXbool showParents() const;
00339 
00341   void showParents(FXbool shown);
00342 
00344   void setAssociations(FXFileDict* assoc);
00345 
00347   FXFileDict* getAssociations() const { return associations; }
00348 
00350   virtual void save(FXStream& store) const;
00351 
00353   virtual void load(FXStream& store);
00354 
00356   virtual ~FXFileList();
00357   };
00358 
00359 }
00360 
00361 #endif
00362 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:21 2009 for TnFOX by doxygen v1.4.7