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