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

FXRecentFiles.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * R e c e n t F i l e s L i s t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXRecentFiles.h,v 1.24 2006/01/22 17:58:08 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXRECENTFILES_H
25 #define FXRECENTFILES_H
26 
27 #ifndef FXOBJECT_H
28 #include "FXObject.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXApp;
35 
36 
37 /**
38 * The recent files object manages a most recently used (MRU) file list by
39 * means of the standard system registry.
40 * When connected to a widget, like a menu command, the recent files object
41 * updates the menu commands label to the associated recent file name; when
42 * the menu command is invoked, the recent file object sends its target a
43 * SEL_COMMAND message with the message data set to the associated file name,
44 * of the type const char*.
45 * When adding or removing file names, the recent files object automatically
46 * updates the system registry to record these changes.
47 */
48 class FXAPI FXRecentFiles : public FXObject {
50 private:
51  FXApp *app; // Backlink to application
52  FXObject *target; // Target object to send message
53  FXSelector message; // Message to send
54  FXString group; // MRU File group
55  FXint maxfiles; // Maximum number of files to track
56 private:
58  FXRecentFiles &operator=(const FXRecentFiles&);
59 public:
60  long onCmdClear(FXObject*,FXSelector,void*);
61  long onCmdFile(FXObject*,FXSelector,void*);
62  long onUpdFile(FXObject*,FXSelector,void*);
63  long onUpdAnyFiles(FXObject*,FXSelector,void*);
64 public:
65  enum{
66  ID_CLEAR,
67  ID_ANYFILES,
68  ID_FILE_1,
69  ID_FILE_2,
70  ID_FILE_3,
71  ID_FILE_4,
72  ID_FILE_5,
73  ID_FILE_6,
74  ID_FILE_7,
75  ID_FILE_8,
76  ID_FILE_9,
77  ID_FILE_10,
78  ID_LAST
79  };
80 public:
81 
82  /// Make new recent files group, using global application instance
84 
85  /// Make new recent files group with default groupname
87 
88  /// Make new recent files group with groupname gp
89  FXRecentFiles(FXApp* a,const FXString& gp,FXObject *tgt=NULL,FXSelector sel=0);
90 
91  /// Get application
92  FXApp* getApp() const { return app; }
93 
94  /// Change number of files we're tracking
95  void setMaxFiles(FXint mx){ maxfiles=mx; }
96 
97  /// Return the maximum number of files being tracked
98  FXint getMaxFiles() const { return maxfiles; }
99 
100  /// Set group name
101  void setGroupName(const FXString& name){ group=name; }
102 
103  /// Return group name
104  FXString getGroupName() const { return group; }
105 
106  /// Change the target
107  void setTarget(FXObject *t){ target=t; }
108 
109  /// Get the target
110  FXObject *getTarget() const { return target; }
111 
112  /// Change the message
113  void setSelector(FXSelector sel){ message=sel; }
114 
115  /// Return the message id
116  FXSelector getSelector() const { return message; }
117 
118  /// Obtain the filename at index
119  FXString getFile(FXint index) const;
120 
121  /// Change the filename at index
122  void setFile(FXint index,const FXString& filename);
123 
124  /// Append a file
125  void appendFile(const FXString& filename);
126 
127  /// Remove a file
128  void removeFile(const FXString& filename);
129 
130  /// Clear the list of files
131  void clear();
132 
133  /// Save to a stream
134  virtual void save(FXStream& store) const;
135 
136  /// Load from a stream
137  virtual void load(FXStream& store);
138 
139  /// Destructor
140  virtual ~FXRecentFiles();
141  };
142 
143 }
144 
145 #endif
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
FXuint group()
Get effective group id.
Application Object.
Definition: FXApp.h:158
#define NULL
Definition: fxdefs.h:41
FXString name(const FXString &file)
Return name and extension part of the path name.
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
The recent files object manages a most recently used (MRU) file list by means of the standard system ...
Definition: FXRecentFiles.h:48
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp