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