Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * F i l e S e l e c t i o n W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,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: FXFileSelector.h,v 1.61 2006/01/23 15:51:05 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXFILESELECTOR_H 00025 #define FXFILESELECTOR_H 00026 00027 #ifndef FXPACKER_H 00028 #include "FXPacker.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 class FXFileList; 00034 class FXTextField; 00035 class FXComboBox; 00036 class FXDirBox; 00037 class FXButton; 00038 class FXMenuButton; 00039 class FXIcon; 00040 class FXMenuPane; 00041 class FXCheckButton; 00042 class FXMatrix; 00043 class FXHorizontalFrame; 00044 00045 00046 /// File selection modes 00047 enum { 00048 SELECTFILE_ANY, /// A single file, existing or not (to save to) 00049 SELECTFILE_EXISTING, /// An existing file (to load) 00050 SELECTFILE_MULTIPLE, /// Multiple existing files 00051 SELECTFILE_MULTIPLE_ALL, /// Multiple existing files or directories, but not '.' and '..' 00052 SELECTFILE_DIRECTORY /// Existing directory, including '.' or '..' 00053 }; 00054 00055 00056 /// File selection widget 00057 class FXAPI FXFileSelector : public FXPacker { 00058 FXDECLARE(FXFileSelector) 00059 protected: 00060 FXFileList *filebox; // File list widget 00061 FXTextField *filename; // File name entry field 00062 FXComboBox *filefilter; // Combobox for pattern list 00063 FXMenuPane *bookmarkmenu; // Menu for bookmarks 00064 FXHorizontalFrame *navbuttons; // Navigation buttons 00065 FXHorizontalFrame *fileboxframe; // Frame around file list 00066 FXMatrix *entryblock; // Entry block 00067 FXCheckButton *readonly; // Open file as read only 00068 FXDirBox *dirbox; // Directory hierarchy list 00069 FXButton *accept; // Accept button 00070 FXButton *cancel; // Cancel button 00071 FXIcon *updiricon; // Up directory icon 00072 FXIcon *listicon; // List mode icon 00073 FXIcon *detailicon; // Detail mode icon 00074 FXIcon *iconsicon; // Icon mode icon 00075 FXIcon *homeicon; // Go home icon 00076 FXIcon *workicon; // Go home icon 00077 FXIcon *shownicon; // Files shown icon 00078 FXIcon *hiddenicon; // Files hidden icon 00079 FXIcon *markicon; // Book mark icon 00080 FXIcon *clearicon; // Book clear icon 00081 FXIcon *newicon; // New directory icon 00082 FXIcon *deleteicon; // Delete file icon 00083 FXIcon *moveicon; // Rename file icon 00084 FXIcon *copyicon; // Copy file icon 00085 FXIcon *linkicon; // Link file icon 00086 FXRecentFiles bookmarks; // Bookmarked places 00087 FXuint selectmode; // Select mode 00088 FXbool navigable; // May navigate 00089 protected: 00090 FXFileSelector(){} 00091 FXString *getSelectedFiles() const; 00092 FXString *getSelectedFilesOnly() const; 00093 private: 00094 FXFileSelector(const FXFileSelector&); 00095 FXFileSelector &operator=(const FXFileSelector&); 00096 public: 00097 long onCmdAccept(FXObject*,FXSelector,void*); 00098 long onCmdFilter(FXObject*,FXSelector,void*); 00099 long onCmdItemDblClicked(FXObject*,FXSelector,void*); 00100 long onCmdItemSelected(FXObject*,FXSelector,void*); 00101 long onCmdItemDeselected(FXObject*,FXSelector,void*); 00102 long onCmdDirectoryUp(FXObject*,FXSelector,void*); 00103 long onUpdDirectoryUp(FXObject*,FXSelector,void*); 00104 long onCmdDirTree(FXObject*,FXSelector,void*); 00105 long onCmdHome(FXObject*,FXSelector,void*); 00106 long onCmdWork(FXObject*,FXSelector,void*); 00107 long onCmdBookmark(FXObject*,FXSelector,void*); 00108 long onCmdVisit(FXObject*,FXSelector,void*); 00109 long onCmdNew(FXObject*,FXSelector,void*); 00110 long onUpdNew(FXObject*,FXSelector,void*); 00111 long onCmdMove(FXObject*,FXSelector,void*); 00112 long onCmdCopy(FXObject*,FXSelector,void*); 00113 long onCmdLink(FXObject*,FXSelector,void*); 00114 long onCmdDelete(FXObject*,FXSelector,void*); 00115 long onUpdSelected(FXObject*,FXSelector,void*); 00116 long onPopupMenu(FXObject*,FXSelector,void*); 00117 long onCmdImageSize(FXObject*,FXSelector,void*); 00118 long onUpdImageSize(FXObject*,FXSelector,void*); 00119 long onUpdNavigable(FXObject*,FXSelector,void*); 00120 public: 00121 enum { 00122 ID_FILEFILTER=FXPacker::ID_LAST, 00123 ID_ACCEPT, 00124 ID_FILELIST, 00125 ID_DIRECTORY_UP, 00126 ID_DIRTREE, 00127 ID_NORMAL_SIZE, 00128 ID_MEDIUM_SIZE, 00129 ID_GIANT_SIZE, 00130 ID_HOME, 00131 ID_WORK, 00132 ID_BOOKMARK, 00133 ID_BOOKMENU, 00134 ID_VISIT, 00135 ID_NEW, 00136 ID_DELETE, 00137 ID_MOVE, 00138 ID_COPY, 00139 ID_LINK, 00140 ID_LAST 00141 }; 00142 public: 00143 00144 /// Constructor 00145 FXFileSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00146 00147 /// Return a pointer to the "Accept" button 00148 FXButton *acceptButton() const { return accept; } 00149 00150 /// Return a pointer to the "Cancel" button 00151 FXButton *cancelButton() const { return cancel; } 00152 00153 /// Change file name 00154 void setFilename(const FXString& path); 00155 00156 /// Return file name, if any 00157 FXString getFilename() const; 00158 00159 /** 00160 * Return array of strings containing the selected file names, terminated 00161 * by an empty string. This string array must be freed using delete []. 00162 * If no files were selected, a NULL is returned. 00163 */ 00164 FXString* getFilenames() const; 00165 00166 /// Change file pattern 00167 void setPattern(const FXString& ptrn); 00168 00169 /// Return file pattern 00170 FXString getPattern() const; 00171 00172 /** 00173 * Change the list of file patterns shown in the file dialog. 00174 * Each pattern comprises an optional name, followed by a pattern in 00175 * parentheses. The patterns are separated by newlines. 00176 * For example, 00177 * 00178 * "*\n*.cpp,*.cc\n*.hpp,*.hh,*.h" 00179 * 00180 * and 00181 * 00182 * "All Files (*)\nC++ Sources (*.cpp,*.cc)\nC++ Headers (*.hpp,*.hh,*.h)" 00183 * 00184 * will set the same three patterns, but the former shows no pattern names. 00185 */ 00186 void setPatternList(const FXString& patterns); 00187 00188 /// Return list of patterns 00189 FXString getPatternList() const; 00190 00191 /** 00192 * After setting the list of patterns, this call will 00193 * initially select pattern n as the active one. 00194 */ 00195 void setCurrentPattern(FXint n); 00196 00197 /// Return current pattern number 00198 FXint getCurrentPattern() const; 00199 00200 /// Get pattern text for given pattern number 00201 FXString getPatternText(FXint patno) const; 00202 00203 /// Change pattern text for pattern number 00204 void setPatternText(FXint patno,const FXString& text); 00205 00206 /// Return number of patterns 00207 FXint getNumPatterns() const; 00208 00209 /// Allow pattern entry 00210 void allowPatternEntry(FXbool allow); 00211 00212 /// Return TRUE if pattern entry is allowed 00213 FXbool allowPatternEntry() const; 00214 00215 /** 00216 * Given filename pattern of the form "GIF Format (*.gif)", 00217 * returns the pattern only, i.e. "*.gif" in this case. 00218 * If the parentheses are not found then returns the entire 00219 * input pattern. 00220 */ 00221 static FXString patternFromText(const FXString& pattern); 00222 00223 /** 00224 * Given a pattern of the form "*.gif,*.GIF", return 00225 * the first extension of the pattern, i.e. "gif" in this 00226 * example. Returns empty string if it doesn't work out. 00227 */ 00228 static FXString extensionFromPattern(const FXString& pattern); 00229 00230 /// Change directory 00231 void setDirectory(const FXString& path); 00232 00233 /// Return directory 00234 FXString getDirectory() const; 00235 00236 /// Set the inter-item spacing (in pixels) 00237 void setItemSpace(FXint s); 00238 00239 /// Return the inter-item spacing (in pixels) 00240 FXint getItemSpace() const; 00241 00242 /// Change file list style 00243 void setFileBoxStyle(FXuint style); 00244 00245 /// Return file list style 00246 FXuint getFileBoxStyle() const; 00247 00248 /// Change file selection mode 00249 void setSelectMode(FXuint mode); 00250 00251 /// Return file selection mode 00252 FXuint getSelectMode() const { return selectmode; } 00253 00254 /// Change wildcard matching mode 00255 void setMatchMode(FXuint mode); 00256 00257 /// Return wildcard matching mode 00258 FXuint getMatchMode() const; 00259 00260 /// Return TRUE if showing hidden files 00261 FXbool showHiddenFiles() const; 00262 00263 /// Show or hide hidden files 00264 void showHiddenFiles(FXbool showing); 00265 00266 /// Return TRUE if image preview on 00267 FXbool showImages() const; 00268 00269 /// Show or hide preview images 00270 void showImages(FXbool showing); 00271 00272 /// Return images preview size 00273 FXint getImageSize() const; 00274 00275 /// Change images preview size 00276 void setImageSize(FXint size); 00277 00278 /// Show readonly button 00279 void showReadOnly(FXbool show); 00280 00281 /// Return TRUE if readonly is shown 00282 FXbool shownReadOnly() const; 00283 00284 /// Set initial state of readonly button 00285 void setReadOnly(FXbool state); 00286 00287 /// Get readonly state 00288 FXbool getReadOnly() const; 00289 00290 /// Allow or disallow navigation 00291 void allowNavigation(FXbool flag){ navigable=flag; } 00292 00293 /// Is navigation allowed? 00294 FXbool allowNavigation() const { return navigable; } 00295 00296 /// Save object to a stream 00297 virtual void save(FXStream& store) const; 00298 00299 /// Load object from a stream 00300 virtual void load(FXStream& store); 00301 00302 /// Destructor 00303 virtual ~FXFileSelector(); 00304 }; 00305 00306 } 00307 00308 #endif
Copyright © 1997-2005 Jeroen van der Zijp |