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