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

FXRecentFiles.h

00001 /******************************************************************************** 00002 * * 00003 * R e c e n t F i l e s L i s 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: FXRecentFiles.h,v 1.21 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXRECENTFILES_H 00025 #define FXRECENTFILES_H 00026 00027 #ifndef FXOBJECT_H 00028 #include "FXObject.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /** 00035 * The recent files object manages a most recently used (MRU) file list by 00036 * means of the standard system registry. 00037 * When connected to a widget, like a menu command, the recent files object 00038 * updates the menu commands label to the associated recent file name; when 00039 * the menu command is invoked, the recent file object sends its target a 00040 * SEL_COMMAND message with the message data set to the associated file name, 00041 * of the type const char*. 00042 * When adding or removing file names, the recent files object automatically 00043 * updates the system registry to record these changes. 00044 */ 00045 class FXAPI FXRecentFiles : public FXObject { 00046 FXDECLARE(FXRecentFiles) 00047 protected: 00048 FXString group; // MRU File group 00049 FXObject *target; // Target object to send message 00050 FXSelector message; // Message to send 00051 FXint maxfiles; // Maximum number of files to track 00052 private: 00053 FXRecentFiles(const FXRecentFiles&); 00054 FXRecentFiles &operator=(const FXRecentFiles&); 00055 public: 00056 long onCmdClear(FXObject*,FXSelector,void*); 00057 long onCmdFile(FXObject*,FXSelector,void*); 00058 long onUpdFile(FXObject*,FXSelector,void*); 00059 long onUpdAnyFiles(FXObject*,FXSelector,void*); 00060 public: 00061 enum{ 00062 ID_CLEAR, 00063 ID_ANYFILES, 00064 ID_FILE_1, 00065 ID_FILE_2, 00066 ID_FILE_3, 00067 ID_FILE_4, 00068 ID_FILE_5, 00069 ID_FILE_6, 00070 ID_FILE_7, 00071 ID_FILE_8, 00072 ID_FILE_9, 00073 ID_FILE_10 00074 }; 00075 public: 00076 00077 /// Make new Recent Files Group with default groupname 00078 FXRecentFiles(); 00079 00080 /// Make new Recent Files Group with groupname gp 00081 FXRecentFiles(const FXString& gp,FXObject *tgt=NULL,FXSelector sel=0); 00082 00083 /// Change number of files we're tracking 00084 void setMaxFiles(FXint mx){ maxfiles=mx; } 00085 00086 /// Return the maximum number of files being tracked 00087 FXint getMaxFiles() const { return maxfiles; } 00088 00089 /// Set group name 00090 void setGroupName(const FXString& name){ group=name; } 00091 00092 /// Return group name 00093 FXString getGroupName() const { return group; } 00094 00095 /// Change the target 00096 void setTarget(FXObject *t){ target=t; } 00097 00098 /// Get the target 00099 FXObject *getTarget() const { return target; } 00100 00101 /// Change the message 00102 void setSelector(FXSelector sel){ message=sel; } 00103 00104 /// Return the message id 00105 FXSelector getSelector() const { return message; } 00106 00107 /// Obtain the filename at index 00108 FXString getFile(FXint index) const; 00109 00110 /// Change the filename at index 00111 void setFile(FXint index,const FXString& filename); 00112 00113 /// Append a file 00114 void appendFile(const FXString& filename); 00115 00116 /// Remove a file 00117 void removeFile(const FXString& filename); 00118 00119 /// Clear the list of files 00120 void clear(); 00121 00122 /// Save to a stream 00123 virtual void save(FXStream& store) const; 00124 00125 /// Load from a stream 00126 virtual void load(FXStream& store); 00127 00128 /// Destructor 00129 virtual ~FXRecentFiles(); 00130 }; 00131 00132 } 00133 00134 #endif

Copyright © 1997-2005 Jeroen van der Zijp