Audacity 3.2.0
FileHistory.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FileHistory.h
6
7 Leland Lucius
8
9**********************************************************************/
10
11#ifndef __AUDACITY_WIDGETS_FILEHISTORY__
12#define __AUDACITY_WIDGETS_FILEHISTORY__
13
14#include <vector>
15#include <algorithm>
16#include <wx/defs.h>
17#include <wx/weakref.h> // member variable
18
19#include "Identifier.h"
20#include "wxArrayStringEx.h"
21
22class wxConfigBase;
23class wxMenu;
24
25class AUDACITY_DLL_API FileHistory
26{
27 public:
28 FileHistory(size_t maxfiles = 12, wxWindowID idbase = wxID_FILE);
29 virtual ~FileHistory();
30 FileHistory( const FileHistory& ) = delete;
31 FileHistory &operator =( const FileHistory & ) = delete;
32
33 // These constants define the range of IDs reserved by the global file history
34 enum {
35 ID_RECENT_CLEAR = 6100,
36 ID_RECENT_FIRST = 6101,
37 ID_RECENT_LAST = 6112
38 };
39
40 static FileHistory &Global();
41
42 void Append( const FilePath &file )
43 { AddFileToHistory( file, true ); }
44 void Remove( size_t i );
45 void Clear();
46
47 // Causes this menu to reflect the contents of this FileHistory, now and
48 // also whenever the history changes.
49 void UseMenu(wxMenu *menu);
50
51 void Load(wxConfigBase& config, const wxString & group = wxEmptyString);
52 void Save(wxConfigBase& config);
53
54 // stl-style accessors
55 using const_iterator = FilePaths::const_iterator;
56 const_iterator begin() const { return mHistory.begin(); }
57 const_iterator end() const { return mHistory.end(); }
58 const FilePath &operator[] ( size_t ii ) const { return mHistory[ ii ]; }
59 bool empty() const { return mHistory.empty(); }
60
61 private:
62 void AddFileToHistory(const FilePath & file, bool update);
63 void NotifyMenus();
64 void NotifyMenu(wxMenu *menu);
65
66 void Compress();
67
68 size_t mMaxFiles;
69 wxWindowID mIDBase;
70
71 std::vector< wxWeakRef< wxMenu > > mMenus;
73
74 wxString mGroup;
75};
76
77#endif
wxString FilePath
Definition: Project.h:21
Similar to wxFileHistory, but customized to our needs.
Definition: FileHistory.h:26
const_iterator begin() const
Definition: FileHistory.h:56
FileHistory(const FileHistory &)=delete
wxString mGroup
Definition: FileHistory.h:74
FilePaths mHistory
Definition: FileHistory.h:72
bool empty() const
Definition: FileHistory.h:59
wxWindowID mIDBase
Definition: FileHistory.h:69
FilePaths::const_iterator const_iterator
Definition: FileHistory.h:55
void Append(const FilePath &file)
Definition: FileHistory.h:42
size_t mMaxFiles
Definition: FileHistory.h:68
const_iterator end() const
Definition: FileHistory.h:57
std::vector< wxWeakRef< wxMenu > > mMenus
Definition: FileHistory.h:71
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
PROJECT_FILE_IO_API void Remove(const FilePath &path)
THEME_RESOURCES_API void Load()