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