1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filehistory.h
3 // Purpose: wxFileHistory class
4 // Author: Julian Smart, Vaclav Slavik
6 // Copyright: (c) Julian Smart, Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_FILEHISTORY_H_
11 #define _WX_FILEHISTORY_H_
15 #if wxUSE_FILE_HISTORY
17 #include "wx/windowid.h"
18 #include "wx/object.h"
20 #include "wx/string.h"
21 #include "wx/arrstr.h"
23 class WXDLLIMPEXP_FWD_CORE wxMenu
;
24 class WXDLLIMPEXP_FWD_BASE wxConfigBase
;
25 class WXDLLIMPEXP_FWD_BASE wxFileName
;
27 // ----------------------------------------------------------------------------
28 // File history management
29 // ----------------------------------------------------------------------------
31 class WXDLLIMPEXP_CORE wxFileHistoryBase
: public wxObject
34 wxFileHistoryBase(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 // Normalize a file name to canonical form. We have a special function for
83 // this to ensure the same normalization is used everywhere.
84 static wxString
NormalizeFileName(const wxFileName
& filename
);
86 wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase
);
89 #if WXWIN_COMPATIBILITY_2_6
90 inline size_t wxFileHistoryBase::GetNoHistoryFiles() const
92 return m_fileHistory
.GetCount();
94 #endif // WXWIN_COMPATIBILITY_2_6
97 #if defined(__WXGTK20__)
98 #include "wx/gtk/filehistory.h"
100 // no platform-specific implementation of wxFileHistory yet
101 class WXDLLIMPEXP_CORE wxFileHistory
: public wxFileHistoryBase
104 wxFileHistory(size_t maxFiles
= 9, wxWindowID idBase
= wxID_FILE1
)
105 : wxFileHistoryBase(maxFiles
, idBase
) {}
107 DECLARE_DYNAMIC_CLASS(wxFileHistory
)
111 #endif // wxUSE_FILE_HISTORY
113 #endif // _WX_FILEHISTORY_H_