![]() |
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,2002 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.38 2002/02/26 17:20:12 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXFILESELECTOR_H 00025 #define FXFILESELECTOR_H 00026 00027 #ifndef FXPACKER_H 00028 #include "FXPacker.h" 00029 #endif 00030 00031 00032 class FXFileList; 00033 class FXTextField; 00034 class FXComboBox; 00035 class FXDirBox; 00036 class FXButton; 00037 class FXIcon; 00038 class FXMenuPane; 00039 class FXCheckButton; 00040 00041 00042 /// File selection modes 00043 enum { 00044 SELECTFILE_ANY, /// A single file, existing or not (to save to) 00045 SELECTFILE_EXISTING, /// An existing file (to load) 00046 SELECTFILE_MULTIPLE, /// Multiple existing files 00047 SELECTFILE_MULTIPLE_ALL, /// Multiple existing files or directories 00048 SELECTFILE_DIRECTORY /// Existing directory 00049 }; 00050 00051 00052 /// File selection widget 00053 class FXAPI FXFileSelector : public FXPacker { 00054 FXDECLARE(FXFileSelector) 00055 protected: 00056 FXFileList *filebox; // File list widget 00057 FXTextField *filename; // File name entry field 00058 FXComboBox *filefilter; // Combobox for pattern list 00059 FXMenuPane *bookmarks; // Menu for bookmarks 00060 FXCheckButton *readonly; // Open file as read only 00061 FXDirBox *dirbox; // Directory hierarchy list 00062 FXButton *accept; // Accept button 00063 FXButton *cancel; // Cancel button 00064 FXIcon *updiricon; // Up directory icon 00065 FXIcon *newdiricon; // New directory icon 00066 FXIcon *listicon; // List mode icon 00067 FXIcon *detailicon; // Detail mode icon 00068 FXIcon *iconsicon; // Icon mode icon 00069 FXIcon *homeicon; // Go home icon 00070 FXIcon *workicon; // Go home icon 00071 FXIcon *shownicon; // Files shown icon 00072 FXIcon *hiddenicon; // Files hidden icon 00073 FXIcon *markicon; // Book mark icon 00074 FXIcon *clearicon; // Book clear icon 00075 FXIcon *deleteicon; // Delete file icon 00076 FXIcon *moveicon; // Rename file icon 00077 FXIcon *copyicon; // Copy file icon 00078 FXIcon *linkicon; // Link file icon 00079 FXRecentFiles mrufiles; // Recently visited places 00080 FXuint selectmode; // Select mode 00081 protected: 00082 FXFileSelector(){} 00083 static FXString patternFromText(const FXString& pattern); 00084 static FXString extensionFromPattern(const FXString& pattern); 00085 private: 00086 FXFileSelector(const FXFileSelector&); 00087 FXFileSelector &operator=(const FXFileSelector&); 00088 public: 00089 long onCmdAccept(FXObject*,FXSelector,void*); 00090 long onCmdFilter(FXObject*,FXSelector,void*); 00091 long onCmdItemDblClicked(FXObject*,FXSelector,void*); 00092 long onCmdItemSelected(FXObject*,FXSelector,void*); 00093 long onCmdItemDeselected(FXObject*,FXSelector,void*); 00094 long onCmdDirectoryUp(FXObject*,FXSelector,void*); 00095 long onUpdDirectoryUp(FXObject*,FXSelector,void*); 00096 long onCmdDirTree(FXObject*,FXSelector,void*); 00097 long onCmdHome(FXObject*,FXSelector,void*); 00098 long onCmdWork(FXObject*,FXSelector,void*); 00099 long onCmdBookmark(FXObject*,FXSelector,void*); 00100 long onCmdVisit(FXObject*,FXSelector,void*); 00101 long onCmdNew(FXObject*,FXSelector,void*); 00102 long onUpdNew(FXObject*,FXSelector,void*); 00103 long onCmdMove(FXObject*,FXSelector,void*); 00104 long onCmdCopy(FXObject*,FXSelector,void*); 00105 long onCmdLink(FXObject*,FXSelector,void*); 00106 long onCmdDelete(FXObject*,FXSelector,void*); 00107 long onUpdSelected(FXObject*,FXSelector,void*); 00108 long onPopupMenu(FXObject*,FXSelector,void*); 00109 public: 00110 enum { 00111 ID_FILEFILTER=FXPacker::ID_LAST, 00112 ID_ACCEPT, 00113 ID_FILELIST, 00114 ID_DIRECTORY_UP, 00115 ID_DIRTREE, 00116 ID_HOME, 00117 ID_WORK, 00118 ID_BOOKMARK, 00119 ID_VISIT, 00120 ID_NEW, 00121 ID_DELETE, 00122 ID_MOVE, 00123 ID_COPY, 00124 ID_LINK, 00125 ID_LAST 00126 }; 00127 public: 00128 00129 /// Constructor 00130 FXFileSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00131 00132 /// Return a pointer to the "Accept" button 00133 FXButton *acceptButton() const { return accept; } 00134 00135 /// Return a pointer to the "Cancel" button 00136 FXButton *cancelButton() const { return cancel; } 00137 00138 /// Change file name 00139 void setFilename(const FXString& path); 00140 00141 /// Return file name, if any 00142 FXString getFilename() const; 00143 00144 /** 00145 * Return array of strings containing the selected file names, terminated 00146 * by an empty string. This string array must be freed using delete []. 00147 * If no files were selected, a NULL is returned. 00148 */ 00149 FXString* getFilenames() const; 00150 00151 /// Change file pattern 00152 void setPattern(const FXString& ptrn); 00153 00154 /// Return file pattern 00155 FXString getPattern() const; 00156 00157 /** 00158 * Change the list of file patterns shown in the file dialog. 00159 * Each pattern comprises an optional name, followed by a pattern in 00160 * parentheses. The patterns are separated by newlines. 00161 * For example, 00162 * 00163 * "*\n*.cpp,*.cc\n*.hpp,*.hh,*.h" 00164 * 00165 * and 00166 * 00167 * "All Files (*)\nC++ Sources (*.cpp,*.cc)\nC++ Headers (*.hpp,*.hh,*.h)" 00168 * 00169 * will set the same three patterns, but the former shows no pattern names. 00170 */ 00171 void setPatternList(const FXString& patterns); 00172 00173 /** 00174 * Set list of patterns as name,pattern pairs. 00175 * The list should be terminated with a final NULL string. 00176 * (DEPRECATED) 00177 */ 00178 void setPatternList(const FXchar **ptrns); 00179 00180 /// Return list of patterns 00181 FXString getPatternList() const; 00182 00183 /** 00184 * After setting the list of patterns, this call will 00185 * initially select pattern n as the active one. 00186 */ 00187 void setCurrentPattern(FXint n); 00188 00189 /// Return current pattern number 00190 FXint getCurrentPattern() const; 00191 00192 /// Get pattern text for given pattern number 00193 FXString getPatternText(FXint patno) const; 00194 00195 /// Change pattern text for pattern number 00196 void setPatternText(FXint patno,const FXString& text); 00197 00198 /// Change directory 00199 void setDirectory(const FXString& path); 00200 00201 /// Return directory 00202 FXString getDirectory() const; 00203 00204 /// Set the inter-item spacing (in pixels) 00205 void setItemSpace(FXint s); 00206 00207 /// Return the inter-item spacing (in pixels) 00208 FXint getItemSpace() const; 00209 00210 /// Change file list style 00211 void setFileBoxStyle(FXuint style); 00212 00213 /// Return file list style 00214 FXuint getFileBoxStyle() const; 00215 00216 /// Change file selection mode 00217 void setSelectMode(FXuint mode); 00218 00219 /// Return file selection mode 00220 FXuint getSelectMode() const { return selectmode; } 00221 00222 /// Show readonly button 00223 void showReadOnly(FXbool show); 00224 00225 /// Return TRUE if readonly is shown 00226 FXbool shownReadOnly() const; 00227 00228 /// Set initial state of readonly button 00229 void setReadOnly(FXbool state); 00230 00231 /// Get readonly state 00232 FXbool getReadOnly() const; 00233 00234 /// Save object to a stream 00235 virtual void save(FXStream& store) const; 00236 00237 /// Load object from a stream 00238 virtual void load(FXStream& store); 00239 00240 /// Destructor 00241 virtual ~FXFileSelector(); 00242 }; 00243 00244 00245 #endif