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