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

FXRecentFiles.h

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

Copyright © 1997-2005 Jeroen van der Zijp