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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXDirList.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                     D i r e c t o r y   L i s t   W i d g e t                 *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXDIRLIST_H
00022 #define FXDIRLIST_H
00023 
00024 #ifndef FXTREELIST_H
00025 #include "FXTreeList.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 struct FXFileAssoc;
00032 class  FXFileDict;
00033 class  FXIcon;
00034 class  FXDirList;
00035 
00036 
00038 enum {
00039   DIRLIST_SHOWFILES     = 0x08000000, 
00040   DIRLIST_SHOWHIDDEN    = 0x10000000, 
00041   DIRLIST_NO_OWN_ASSOC  = 0x20000000  
00042   };
00043 
00044 
00046 class FXAPI FXDirItem : public FXTreeItem {
00047   FXDECLARE(FXDirItem)
00048   friend class FXDirList;
00049 protected:
00050   FXFileAssoc *assoc;           // File association
00051   FXDirItem   *link;            // Link to next item
00052   FXDirItem   *list;            // List of child items
00053   FXlong       size;            // File size (if a file)
00054   FXTime       date;            // Time of item
00055   FXuint       mode;            // Mode flags
00056 private:
00057   FXDirItem(const FXDirItem&);
00058   FXDirItem& operator=(const FXDirItem&);
00059 protected:
00060   FXDirItem():assoc(NULL),link(NULL),list(NULL),size(0L),date(0),mode(0){}
00061 public:
00062 
00064   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){}
00065 
00067   FXbool isFile() const { return (mode&(FXIO::File))!=0; }
00068 
00070   FXbool isDirectory() const { return (mode&FXIO::Directory)!=0; }
00071 
00073   FXbool isExecutable() const { return (mode&FXIO::File)!=0 && (mode&FXIO::AllExec)!=0; }
00074 
00076   FXbool isSymlink() const { return (mode&FXIO::SymLink)!=0; }
00077 
00079   FXbool isChardev() const { return (mode&FXIO::Character)!=0; }
00080 
00082   FXbool isBlockdev() const { return (mode&FXIO::Block)!=0; }
00083 
00085   FXbool isFifo() const { return (mode&FXIO::Fifo)!=0; }
00086 
00088   FXbool isSocket() const { return (mode&FXIO::Socket)!=0; }
00089 
00091   void setAssoc(FXFileAssoc* a){ assoc=a; }
00092 
00094   FXFileAssoc* getAssoc() const { return assoc; }
00095 
00097   void setSize(FXlong s){ size=s; }
00098 
00100   FXlong getSize() const { return size; }
00101 
00103   void setDate(FXTime d){ date=d; }
00104 
00106   FXTime getDate() const { return date; }
00107 
00109   void setMode(FXuint m){ mode=m; }
00110 
00112   FXuint getMode() const { return mode; }
00113   };
00114 
00115 
00125 class FXAPI FXDirList : public FXTreeList {
00126   FXDECLARE(FXDirList)
00127 protected:
00128   FXFileDict   *associations;           // Association table
00129   FXDirItem    *list;                   // Root item list
00130   FXIcon       *opendiricon;            // Open folder icon
00131   FXIcon       *closeddiricon;          // Closed folder icon
00132   FXIcon       *documenticon;           // Document icon
00133   FXIcon       *applicationicon;        // Application icon
00134   FXIcon       *cdromicon;              // CDROM icon
00135   FXIcon       *harddiskicon;           // Hard drive icon
00136   FXIcon       *networkicon;            // Network icon
00137   FXIcon       *floppyicon;             // Floppy icon
00138   FXIcon       *zipdiskicon;            // Zip disk icon
00139   FXString      pattern;                // Pattern of file names
00140   FXString      dropdirectory;          // Drop directory
00141   FXString      dragfiles;              // Dragged file names
00142   FXString      dropfiles;              // Dropped file names
00143   FXDragAction  dropaction;             // Drop action
00144   FXuint        matchmode;              // File wildcard match mode
00145   FXuint        counter;                // Refresh counter
00146   FXbool        draggable;              // Dragable files
00147 protected:
00148   FXDirList();
00149   void listRootItems();
00150   void listChildItems(FXDirItem *par);
00151   FXString getSelectedFiles() const;
00152   virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr);
00153 private:
00154   FXDirList(const FXDirList&);
00155   FXDirList &operator=(const FXDirList&);
00156 public:
00157   long onRefreshTimer(FXObject*,FXSelector,void*);
00158   long onBeginDrag(FXObject*,FXSelector,void*);
00159   long onEndDrag(FXObject*,FXSelector,void*);
00160   long onDragged(FXObject*,FXSelector,void*);
00161   long onDNDEnter(FXObject*,FXSelector,void*);
00162   long onDNDLeave(FXObject*,FXSelector,void*);
00163   long onDNDMotion(FXObject*,FXSelector,void*);
00164   long onDNDDrop(FXObject*,FXSelector,void*);
00165   long onDNDRequest(FXObject*,FXSelector,void*);
00166   long onCmdSetValue(FXObject*,FXSelector,void*);
00167   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00168   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00169   long onCmdToggleHidden(FXObject*,FXSelector,void*);
00170   long onUpdToggleHidden(FXObject*,FXSelector,void*);
00171   long onCmdShowHidden(FXObject*,FXSelector,void*);
00172   long onUpdShowHidden(FXObject*,FXSelector,void*);
00173   long onCmdHideHidden(FXObject*,FXSelector,void*);
00174   long onUpdHideHidden(FXObject*,FXSelector,void*);
00175   long onCmdToggleFiles(FXObject*,FXSelector,void*);
00176   long onUpdToggleFiles(FXObject*,FXSelector,void*);
00177   long onCmdShowFiles(FXObject*,FXSelector,void*);
00178   long onUpdShowFiles(FXObject*,FXSelector,void*);
00179   long onCmdHideFiles(FXObject*,FXSelector,void*);
00180   long onUpdHideFiles(FXObject*,FXSelector,void*);
00181   long onCmdSetPattern(FXObject*,FXSelector,void*);
00182   long onUpdSetPattern(FXObject*,FXSelector,void*);
00183   long onCmdSortReverse(FXObject*,FXSelector,void*);
00184   long onUpdSortReverse(FXObject*,FXSelector,void*);
00185   long onCmdSortCase(FXObject*,FXSelector,void*);
00186   long onUpdSortCase(FXObject*,FXSelector,void*);
00187   long onCmdRefresh(FXObject*,FXSelector,void*);
00188   long onCmdDropAsk(FXObject*,FXSelector,void*);
00189   long onCmdDropCopy(FXObject*,FXSelector,void*);
00190   long onCmdDropMove(FXObject*,FXSelector,void*);
00191   long onCmdDropLink(FXObject*,FXSelector,void*);
00192 public:
00193   static FXint ascending(const FXTreeItem* a,const FXTreeItem* b);
00194   static FXint descending(const FXTreeItem* a,const FXTreeItem* b);
00195   static FXint ascendingCase(const FXTreeItem* a,const FXTreeItem* b);
00196   static FXint descendingCase(const FXTreeItem* a,const FXTreeItem* b);
00197 public:
00198   enum {
00199     ID_REFRESHTIMER=FXTreeList::ID_LAST,
00200     ID_DROPASK,
00201     ID_DROPCOPY,
00202     ID_DROPMOVE,
00203     ID_DROPLINK,
00204     ID_SHOW_FILES,
00205     ID_HIDE_FILES,
00206     ID_TOGGLE_FILES,
00207     ID_SHOW_HIDDEN,
00208     ID_HIDE_HIDDEN,
00209     ID_TOGGLE_HIDDEN,
00210     ID_SET_PATTERN,
00211     ID_SORT_REVERSE,
00212     ID_SORT_CASE,
00213     ID_REFRESH,
00214     ID_LAST
00215     };
00216 public:
00217 
00219   FXDirList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00220 
00222   virtual void create();
00223 
00225   virtual void detach();
00226 
00228   virtual void destroy();
00229 
00231   void scan(FXbool force=true);
00232 
00234   void setCurrentFile(const FXString& file,FXbool notify=false);
00235 
00237   FXString getCurrentFile() const;
00238 
00240   void setDirectory(const FXString& path,FXbool notify=false);
00241 
00243   FXString getDirectory() const;
00244 
00246   void setPattern(const FXString& ptrn);
00247 
00249   FXString getPattern() const { return pattern; }
00250 
00252   FXString getItemPathname(const FXTreeItem* item) const;
00253 
00255   FXTreeItem* getPathnameItem(const FXString& path);
00256 
00258   FXbool isItemFile(const FXTreeItem* item) const;
00259 
00261   FXbool isItemDirectory(const FXTreeItem* item) const;
00262 
00264   FXbool isItemExecutable(const FXTreeItem* item) const;
00265 
00267   FXbool isItemSymlink(const FXTreeItem* item) const;
00268 
00270   FXFileAssoc* getItemAssoc(const FXTreeItem* item) const;
00271 
00273   FXlong getItemSize(const FXTreeItem* item) const;
00274 
00276   FXTime getItemDate(const FXTreeItem* item) const;
00277 
00279   FXuint getItemMode(const FXTreeItem* item) const;
00280 
00282   virtual FXbool collapseTree(FXTreeItem* tree,FXbool notify=false);
00283 
00285   virtual FXbool expandTree(FXTreeItem* tree,FXbool notify=false);
00286 
00288   void setMatchMode(FXuint mode);
00289 
00291   FXuint getMatchMode() const { return matchmode; }
00292 
00294   void showFiles(FXbool flag);
00295 
00297   FXbool showFiles() const;
00298 
00300   void showHiddenFiles(FXbool flag);
00301 
00303   FXbool showHiddenFiles() const;
00304 
00306   void setAssociations(FXFileDict* assoc,FXbool owned=false);
00307 
00309   FXFileDict* getAssociations() const { return associations; }
00310 
00312   void setDraggableFiles(FXbool flag);
00313 
00315   FXbool getDraggableFiles() const { return draggable; }
00316 
00318   virtual void save(FXStream& store) const;
00319 
00321   virtual void load(FXStream& store);
00322 
00324   virtual ~FXDirList();
00325   };
00326 
00327 }
00328 
00329 #endif

Copyright © 1997-2011 Jeroen van der Zijp