Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXFileSelector.h

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,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: FXFileSelector.h,v 1.48 2004/03/18 15:25:20 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 00051 SELECTFILE_DIRECTORY /// Existing directory 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 *bookmarks; // 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 *newdiricon; // New 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 *deleteicon; // Delete file icon 00082 FXIcon *moveicon; // Rename file icon 00083 FXIcon *copyicon; // Copy file icon 00084 FXIcon *linkicon; // Link file icon 00085 FXRecentFiles mrufiles; // Recently visited places 00086 FXuint selectmode; // Select mode 00087 protected: 00088 FXFileSelector(){} 00089 private: 00090 FXFileSelector(const FXFileSelector&); 00091 FXFileSelector &operator=(const FXFileSelector&); 00092 public: 00093 long onCmdAccept(FXObject*,FXSelector,void*); 00094 long onCmdFilter(FXObject*,FXSelector,void*); 00095 long onCmdItemDblClicked(FXObject*,FXSelector,void*); 00096 long onCmdItemSelected(FXObject*,FXSelector,void*); 00097 long onCmdItemDeselected(FXObject*,FXSelector,void*); 00098 long onCmdDirectoryUp(FXObject*,FXSelector,void*); 00099 long onUpdDirectoryUp(FXObject*,FXSelector,void*); 00100 long onCmdDirTree(FXObject*,FXSelector,void*); 00101 long onCmdHome(FXObject*,FXSelector,void*); 00102 long onCmdWork(FXObject*,FXSelector,void*); 00103 long onCmdBookmark(FXObject*,FXSelector,void*); 00104 long onCmdVisit(FXObject*,FXSelector,void*); 00105 long onCmdNew(FXObject*,FXSelector,void*); 00106 long onUpdNew(FXObject*,FXSelector,void*); 00107 long onCmdMove(FXObject*,FXSelector,void*); 00108 long onCmdCopy(FXObject*,FXSelector,void*); 00109 long onCmdLink(FXObject*,FXSelector,void*); 00110 long onCmdDelete(FXObject*,FXSelector,void*); 00111 long onUpdSelected(FXObject*,FXSelector,void*); 00112 long onPopupMenu(FXObject*,FXSelector,void*); 00113 public: 00114 enum { 00115 ID_FILEFILTER=FXPacker::ID_LAST, 00116 ID_ACCEPT, 00117 ID_FILELIST, 00118 ID_DIRECTORY_UP, 00119 ID_DIRTREE, 00120 ID_HOME, 00121 ID_WORK, 00122 ID_BOOKMARK, 00123 ID_VISIT, 00124 ID_NEW, 00125 ID_DELETE, 00126 ID_MOVE, 00127 ID_COPY, 00128 ID_LINK, 00129 ID_LAST 00130 }; 00131 public: 00132 00133 /// Constructor 00134 FXFileSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00135 00136 /// Return a pointer to the "Accept" button 00137 FXButton *acceptButton() const { return accept; } 00138 00139 /// Return a pointer to the "Cancel" button 00140 FXButton *cancelButton() const { return cancel; } 00141 00142 /// Change file name 00143 void setFilename(const FXString& path); 00144 00145 /// Return file name, if any 00146 FXString getFilename() const; 00147 00148 /** 00149 * Return array of strings containing the selected file names, terminated 00150 * by an empty string. This string array must be freed using delete []. 00151 * If no files were selected, a NULL is returned. 00152 */ 00153 FXString* getFilenames() const; 00154 00155 /// Change file pattern 00156 void setPattern(const FXString& ptrn); 00157 00158 /// Return file pattern 00159 FXString getPattern() const; 00160 00161 /** 00162 * Change the list of file patterns shown in the file dialog. 00163 * Each pattern comprises an optional name, followed by a pattern in 00164 * parentheses. The patterns are separated by newlines. 00165 * For example, 00166 * 00167 * "*\n*.cpp,*.cc\n*.hpp,*.hh,*.h" 00168 * 00169 * and 00170 * 00171 * "All Files (*)\nC++ Sources (*.cpp,*.cc)\nC++ Headers (*.hpp,*.hh,*.h)" 00172 * 00173 * will set the same three patterns, but the former shows no pattern names. 00174 */ 00175 void setPatternList(const FXString& patterns); 00176 00177 /// Return list of patterns 00178 FXString getPatternList() const; 00179 00180 /** 00181 * After setting the list of patterns, this call will 00182 * initially select pattern n as the active one. 00183 */ 00184 void setCurrentPattern(FXint n); 00185 00186 /// Return current pattern number 00187 FXint getCurrentPattern() const; 00188 00189 /// Get pattern text for given pattern number 00190 FXString getPatternText(FXint patno) const; 00191 00192 /// Change pattern text for pattern number 00193 void setPatternText(FXint patno,const FXString& text); 00194 00195 /** 00196 * Given filename pattern of the form "GIF Format (*.gif)", 00197 * returns the pattern only, i.e. "*.gif" in this case. 00198 * If the parentheses are not found then returns the entire 00199 * input pattern. 00200 */ 00201 static FXString patternFromText(const FXString& pattern); 00202 00203 /** 00204 * Given a pattern of the form "*.gif,*.GIF", return 00205 * the first extension of the pattern, i.e. "gif" in this 00206 * example. Returns empty string if it doesn't work out. 00207 */ 00208 static FXString extensionFromPattern(const FXString& pattern); 00209 00210 /// Change directory 00211 void setDirectory(const FXString& path); 00212 00213 /// Return directory 00214 FXString getDirectory() const; 00215 00216 /// Set the inter-item spacing (in pixels) 00217 void setItemSpace(FXint s); 00218 00219 /// Return the inter-item spacing (in pixels) 00220 FXint getItemSpace() const; 00221 00222 /// Change file list style 00223 void setFileBoxStyle(FXuint style); 00224 00225 /// Return file list style 00226 FXuint getFileBoxStyle() const; 00227 00228 /// Change file selection mode 00229 void setSelectMode(FXuint mode); 00230 00231 /// Return file selection mode 00232 FXuint getSelectMode() const { return selectmode; } 00233 00234 /// Change wildcard matching mode 00235 void setMatchMode(FXuint mode); 00236 00237 /// Return wildcard matching mode 00238 FXuint getMatchMode() const; 00239 00240 /// Show readonly button 00241 void showReadOnly(FXbool show); 00242 00243 /// Return TRUE if readonly is shown 00244 FXbool shownReadOnly() const; 00245 00246 /// Set initial state of readonly button 00247 void setReadOnly(FXbool state); 00248 00249 /// Get readonly state 00250 FXbool getReadOnly() const; 00251 00252 /// Save object to a stream 00253 virtual void save(FXStream& store) const; 00254 00255 /// Load object from a stream 00256 virtual void load(FXStream& store); 00257 00258 /// Destructor 00259 virtual ~FXFileSelector(); 00260 }; 00261 00262 } 00263 00264 #endif

Copyright © 1997-2004 Jeroen van der Zijp