1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filehistory.h
3 // Purpose: wxFileHistory class
4 // Author: Julian Smart, Vaclav Slavik
7 // Copyright: (c) Julian Smart, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_FILEHISTORY_H_
12 #define _WX_FILEHISTORY_H_
16 #if wxUSE_FILE_HISTORY
18 #include "wx/windowid.h"
19 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/arrstr.h"
24 class WXDLLIMPEXP_FWD_CORE wxMenu
;
25 class WXDLLIMPEXP_FWD_BASE wxConfigBase
;
27 // ----------------------------------------------------------------------------
28 // File history management
29 // ----------------------------------------------------------------------------
31 class WXDLLIMPEXP_CORE wxFileHistory
: public wxObject
34 wxFileHistory(size_t maxFiles
= 9, wxWindowID idBase
= wxID_FILE1
);
37 virtual void AddFileToHistory(const wxString
& file
);
38 virtual void RemoveFileFromHistory(size_t i
);
39 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles
; }
40 virtual void UseMenu(wxMenu
*menu
);
42 // Remove menu from the list (MDI child may be closing)
43 virtual void RemoveMenu(wxMenu
*menu
);
46 virtual void Load(const wxConfigBase
& config
);
47 virtual void Save(wxConfigBase
& config
);
48 #endif // wxUSE_CONFIG
50 virtual void AddFilesToMenu();
51 virtual void AddFilesToMenu(wxMenu
* menu
); // Single menu
54 virtual wxString
GetHistoryFile(size_t i
) const { return m_fileHistory
[i
]; }
55 virtual size_t GetCount() const { return m_fileHistory
.GetCount(); }
57 const wxList
& GetMenus() const { return m_fileMenus
; }
60 void SetBaseId(wxWindowID baseId
) { m_idBase
= baseId
; }
61 wxWindowID
GetBaseId() const { return m_idBase
; }
63 #if WXWIN_COMPATIBILITY_2_6
64 // deprecated, use GetCount() instead
65 wxDEPRECATED( size_t GetNoHistoryFiles() const );
66 #endif // WXWIN_COMPATIBILITY_2_6
70 wxArrayString m_fileHistory
;
72 // Menus to maintain (may need several for an MDI app)
75 // Max files to maintain
76 size_t m_fileMaxFiles
;
79 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
82 DECLARE_DYNAMIC_CLASS(wxFileHistory
)
83 wxDECLARE_NO_COPY_CLASS(wxFileHistory
);
86 #if WXWIN_COMPATIBILITY_2_6
87 inline size_t wxFileHistory::GetNoHistoryFiles() const
89 return m_fileHistory
.GetCount();
91 #endif // WXWIN_COMPATIBILITY_2_6
93 #endif // wxUSE_FILE_HISTORY
95 #endif // _WX_FILEHISTORY_H_