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

FXFileList.h

00001 /******************************************************************************** 00002 * * 00003 * F i l e L i s t W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2005 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.50 2005/02/08 03:23:28 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXFILELIST_H 00025 #define FXFILELIST_H 00026 00027 #ifndef FXICONLIST_H 00028 #include "FXIconList.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 struct FXFileAssoc; 00034 class FXFileDict; 00035 class FXFileList; 00036 class FXIcon; 00037 class FXIconSource; 00038 class FXIconDict; 00039 00040 00041 /// File List options 00042 enum { 00043 FILELIST_SHOWHIDDEN = 0x04000000, /// Show hidden files or directories 00044 FILELIST_SHOWDIRS = 0x08000000, /// Show only directories 00045 FILELIST_SHOWFILES = 0x10000000, /// Show only files 00046 FILELIST_SHOWIMAGES = 0x20000000, /// Show preview of images 00047 FILELIST_NO_OWN_ASSOC = 0x40000000 /// Do not create associations for files 00048 }; 00049 00050 00051 00052 /// File item 00053 class FXAPI FXFileItem : public FXIconItem { 00054 FXDECLARE(FXFileItem) 00055 friend class FXFileList; 00056 protected: 00057 FXFileAssoc *assoc; // File association record 00058 FXFileItem *link; // Link to next item 00059 FXlong size; // File size 00060 FXTime date; // File time 00061 protected: 00062 FXFileItem():assoc(NULL),link(NULL),size(0),date(0){} 00063 protected: 00064 enum{ 00065 FOLDER = 64, // Directory item 00066 EXECUTABLE = 128, // Executable item 00067 SYMLINK = 256, // Symbolic linked item 00068 CHARDEV = 512, // Character special item 00069 BLOCKDEV = 1024, // Block special item 00070 FIFO = 2048, // FIFO item 00071 SOCK = 4096, // Socket item 00072 SHARE = 8192 // Share 00073 }; 00074 public: 00075 /// Constructor 00076 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(0){} 00077 00078 /// Return true if this is a file item 00079 FXbool isFile() const { return (state&(FOLDER|BLOCKDEV|CHARDEV|FIFO|SOCK|SHARE))==0; } 00080 00081 /// Return true if this is a directory item 00082 FXbool isDirectory() const { return (state&FOLDER)!=0; } 00083 00084 /// Return true if this is a share item 00085 FXbool isShare() const { return (state&SHARE)!=0; } 00086 00087 /// Return true if this is an executable item 00088 FXbool isExecutable() const { return (state&EXECUTABLE)!=0; } 00089 00090 /// Return true if this is a symbolic link item 00091 FXbool isSymlink() const { return (state&SYMLINK)!=0; } 00092 00093 /// Return true if this is a character device item 00094 FXbool isChardev() const { return (state&CHARDEV)!=0; } 00095 00096 /// Return true if this is a block device item 00097 FXbool isBlockdev() const { return (state&BLOCKDEV)!=0; } 00098 00099 /// Return true if this is an FIFO item 00100 FXbool isFifo() const { return (state&FIFO)!=0; } 00101 00102 /// Return true if this is a socket 00103 FXbool isSocket() const { return (state&SOCK)!=0; } 00104 00105 /// Return the file-association object for this item 00106 FXFileAssoc* getAssoc() const { return assoc; } 00107 00108 /// Return the file size for this item 00109 FXlong getSize() const { return size; } 00110 00111 /// Return the date for this item 00112 FXTime getDate() const { return date; } 00113 }; 00114 00115 00116 /** 00117 * A File List widget provides an icon rich view of the file system. 00118 * It automatically updates itself periodically by re-scanning the file system 00119 * for any changes. As it scans the displayed directory, it automatically 00120 * determines the icons to be displayed by consulting the file associations registry 00121 * settings. A number of messages can be sent to the File List to control the 00122 * filter pattern, sort category, sorting order, case sensitivity, and hidden file 00123 * display mode. 00124 */ 00125 class FXAPI FXFileList : public FXIconList { 00126 FXDECLARE(FXFileList) 00127 protected: 00128 FXString directory; // Current directory 00129 FXString orgdirectory; // Original directory 00130 FXString dropdirectory; // Drop directory 00131 FXDragAction dropaction; // Drop action 00132 FXString dragfiles; // Dragged files 00133 FXFileDict *associations; // Association table 00134 FXFileItem *list; // File item list 00135 FXString pattern; // Pattern of file names 00136 FXuint matchmode; // File wildcard match mode 00137 FXuint counter; // Refresh counter 00138 FXint imagesize; // Image size 00139 FXTime timestamp; // Time when last refreshed 00140 FXIcon *big_folder; // Big folder icon 00141 FXIcon *mini_folder; // Mini folder icon 00142 FXIcon *big_doc; // Big document icon 00143 FXIcon *mini_doc; // Mini document icon 00144 FXIcon *big_app; // Big application icon 00145 FXIcon *mini_app; // Mini application icon 00146 protected: 00147 FXFileList(); 00148 virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr); 00149 void listItems(FXbool force); 00150 private: 00151 FXFileList(const FXFileList&); 00152 FXFileList &operator=(const FXFileList&); 00153 public: 00154 long onOpenTimer(FXObject*,FXSelector,void*); 00155 long onRefreshTimer(FXObject*,FXSelector,void*); 00156 long onDNDEnter(FXObject*,FXSelector,void*); 00157 long onDNDLeave(FXObject*,FXSelector,void*); 00158 long onDNDMotion(FXObject*,FXSelector,void*); 00159 long onDNDDrop(FXObject*,FXSelector,void*); 00160 long onDNDRequest(FXObject*,FXSelector,void*); 00161 long onBeginDrag(FXObject*,FXSelector,void*); 00162 long onEndDrag(FXObject*,FXSelector,void*); 00163 long onDragged(FXObject*,FXSelector,void*); 00164 long onCmdSetValue(FXObject*,FXSelector,void*); 00165 long onCmdGetStringValue(FXObject*,FXSelector,void*); 00166 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00167 long onCmdDirectoryUp(FXObject*,FXSelector,void*); 00168 long onUpdDirectoryUp(FXObject*,FXSelector,void*); 00169 long onCmdSortByName(FXObject*,FXSelector,void*); 00170 long onUpdSortByName(FXObject*,FXSelector,void*); 00171 long onCmdSortByType(FXObject*,FXSelector,void*); 00172 long onUpdSortByType(FXObject*,FXSelector,void*); 00173 long onCmdSortBySize(FXObject*,FXSelector,void*); 00174 long onUpdSortBySize(FXObject*,FXSelector,void*); 00175 long onCmdSortByTime(FXObject*,FXSelector,void*); 00176 long onUpdSortByTime(FXObject*,FXSelector,void*); 00177 long onCmdSortByUser(FXObject*,FXSelector,void*); 00178 long onUpdSortByUser(FXObject*,FXSelector,void*); 00179 long onCmdSortByGroup(FXObject*,FXSelector,void*); 00180 long onUpdSortByGroup(FXObject*,FXSelector,void*); 00181 long onCmdSortReverse(FXObject*,FXSelector,void*); 00182 long onUpdSortReverse(FXObject*,FXSelector,void*); 00183 long onCmdSortCase(FXObject*,FXSelector,void*); 00184 long onUpdSortCase(FXObject*,FXSelector,void*); 00185 long onCmdSetPattern(FXObject*,FXSelector,void*); 00186 long onUpdSetPattern(FXObject*,FXSelector,void*); 00187 long onCmdSetDirectory(FXObject*,FXSelector,void*); 00188 long onUpdSetDirectory(FXObject*,FXSelector,void*); 00189 long onCmdToggleHidden(FXObject*,FXSelector,void*); 00190 long onUpdToggleHidden(FXObject*,FXSelector,void*); 00191 long onCmdShowHidden(FXObject*,FXSelector,void*); 00192 long onUpdShowHidden(FXObject*,FXSelector,void*); 00193 long onCmdHideHidden(FXObject*,FXSelector,void*); 00194 long onUpdHideHidden(FXObject*,FXSelector,void*); 00195 long onCmdToggleImages(FXObject*,FXSelector,void*); 00196 long onUpdToggleImages(FXObject*,FXSelector,void*); 00197 long onCmdHeader(FXObject*,FXSelector,void*); 00198 long onUpdHeader(FXObject*,FXSelector,void*); 00199 long onCmdRefresh(FXObject*,FXSelector,void*); 00200 public: 00201 static FXint ascending(const FXIconItem* pa,const FXIconItem* pb); 00202 static FXint descending(const FXIconItem* pa,const FXIconItem* pb); 00203 static FXint ascendingCase(const FXIconItem* pa,const FXIconItem* pb); 00204 static FXint descendingCase(const FXIconItem* pa,const FXIconItem* pb); 00205 static FXint ascendingType(const FXIconItem* pa,const FXIconItem* pb); 00206 static FXint descendingType(const FXIconItem* pa,const FXIconItem* pb); 00207 static FXint ascendingSize(const FXIconItem* pa,const FXIconItem* pb); 00208 static FXint descendingSize(const FXIconItem* pa,const FXIconItem* pb); 00209 static FXint ascendingTime(const FXIconItem* pa,const FXIconItem* pb); 00210 static FXint descendingTime(const FXIconItem* pa,const FXIconItem* pb); 00211 static FXint ascendingUser(const FXIconItem* pa,const FXIconItem* pb); 00212 static FXint descendingUser(const FXIconItem* pa,const FXIconItem* pb); 00213 static FXint ascendingGroup(const FXIconItem* pa,const FXIconItem* pb); 00214 static FXint descendingGroup(const FXIconItem* pa,const FXIconItem* pb); 00215 public: 00216 enum { 00217 ID_REFRESHTIMER=FXIconList::ID_LAST, 00218 ID_OPENTIMER, 00219 ID_SORT_BY_NAME, /// Sort by name 00220 ID_SORT_BY_TYPE, /// Sort by type 00221 ID_SORT_BY_SIZE, /// Sort by size 00222 ID_SORT_BY_TIME, /// Sort by access time 00223 ID_SORT_BY_USER, /// Sort by owner name 00224 ID_SORT_BY_GROUP, /// Sort by group name 00225 ID_SORT_REVERSE, /// Reverse sort order 00226 ID_SORT_CASE, /// Toggle sort case sensitivity 00227 ID_DIRECTORY_UP, /// Move up one directory 00228 ID_SET_PATTERN, /// Set match pattern 00229 ID_SET_DIRECTORY, /// Set directory 00230 ID_SHOW_HIDDEN, /// Show hidden files 00231 ID_HIDE_HIDDEN, /// Hide hidden files 00232 ID_TOGGLE_HIDDEN, /// Toggle display of hidden files 00233 ID_TOGGLE_IMAGES, /// Toggle display of images 00234 ID_REFRESH, /// Refresh immediately 00235 ID_LAST 00236 }; 00237 public: 00238 00239 /// Construct a file list 00240 FXFileList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00241 00242 /// Create server-side resources 00243 virtual void create(); 00244 00245 /// Detach server-side resources 00246 virtual void detach(); 00247 00248 /// Destroy server-side resources 00249 virtual void destroy(); 00250 00251 /// Scan the current directory and update the items if needed, or if force is TRUE 00252 void scan(FXbool force=TRUE); 00253 00254 /// Set current file 00255 void setCurrentFile(const FXString& file); 00256 00257 /// Return current file 00258 FXString getCurrentFile() const; 00259 00260 /// Set current directory 00261 void setDirectory(const FXString& path); 00262 00263 /// Return current directory 00264 FXString getDirectory() const { return directory; } 00265 00266 /// Change wildcard matching pattern 00267 void setPattern(const FXString& ptrn); 00268 00269 /// Return wildcard pattern 00270 FXString getPattern() const { return pattern; } 00271 00272 /// Return TRUE if item is a directory 00273 FXbool isItemDirectory(FXint index) const; 00274 00275 /// Return TRUE if item is a directory 00276 FXbool isItemShare(FXint index) const; 00277 00278 /// Return TRUE if item is a file 00279 FXbool isItemFile(FXint index) const; 00280 00281 /// Return TRUE if item is executable 00282 FXbool isItemExecutable(FXint index) const; 00283 00284 /// Return name of item at index 00285 FXString getItemFilename(FXint index) const; 00286 00287 /// Return full pathname of item at index 00288 FXString getItemPathname(FXint index) const; 00289 00290 /// Return file association of item 00291 FXFileAssoc* getItemAssoc(FXint index) const; 00292 00293 /// Return wildcard matching mode 00294 FXuint getMatchMode() const { return matchmode; } 00295 00296 /// Change wildcard matching mode 00297 void setMatchMode(FXuint mode); 00298 00299 /// Return TRUE if showing hidden files 00300 FXbool showHiddenFiles() const; 00301 00302 /// Show or hide hidden files 00303 void showHiddenFiles(FXbool showing); 00304 00305 /// Return TRUE if showing directories only 00306 FXbool showOnlyDirectories() const; 00307 00308 /// Show directories only 00309 void showOnlyDirectories(FXbool shown); 00310 00311 /// Return TRUE if showing files only 00312 FXbool showOnlyFiles() const; 00313 00314 /// Show files only 00315 void showOnlyFiles(FXbool shown); 00316 00317 /// Return TRUE if image preview on 00318 FXbool showImages() const; 00319 00320 /// Show or hide preview images 00321 void showImages(FXbool showing); 00322 00323 /// Return images preview size 00324 FXint getImageSize() const { return imagesize; } 00325 00326 /// Change images preview size 00327 void setImageSize(FXint size); 00328 00329 /// Change file associations 00330 void setAssociations(FXFileDict* assoc); 00331 00332 /// Return file associations 00333 FXFileDict* getAssociations() const { return associations; } 00334 00335 /// Save to stream 00336 virtual void save(FXStream& store) const; 00337 00338 /// Load from stream 00339 virtual void load(FXStream& store); 00340 00341 /// Destructor 00342 virtual ~FXFileList(); 00343 }; 00344 00345 } 00346 00347 #endif

Copyright © 1997-2005 Jeroen van der Zijp