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
;
26 class WXDLLIMPEXP_FWD_BASE wxFileName
;
28 // ----------------------------------------------------------------------------
29 // File history management
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_CORE wxFileHistoryBase
: public wxObject
35 wxFileHistoryBase(size_t maxFiles
= 9, wxWindowID idBase
= wxID_FILE1
);
38 virtual void AddFileToHistory(const wxString
& file
);
39 virtual void RemoveFileFromHistory(size_t i
);
40 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles
; }
41 virtual void UseMenu(wxMenu
*menu
);
43 // Remove menu from the list (MDI child may be closing)
44 virtual void RemoveMenu(wxMenu
*menu
);
47 virtual void Load(const wxConfigBase
& config
);
48 virtual void Save(wxConfigBase
& config
);
49 #endif // wxUSE_CONFIG
51 virtual void AddFilesToMenu();
52 virtual void AddFilesToMenu(wxMenu
* menu
); // Single menu
55 virtual wxString
GetHistoryFile(size_t i
) const { return m_fileHistory
[i
]; }
56 virtual size_t GetCount() const { return m_fileHistory
.GetCount(); }
58 const wxList
& GetMenus() const { return m_fileMenus
; }
61 void SetBaseId(wxWindowID baseId
) { m_idBase
= baseId
; }
62 wxWindowID
GetBaseId() const { return m_idBase
; }
64 #if WXWIN_COMPATIBILITY_2_6
65 // deprecated, use GetCount() instead
66 wxDEPRECATED( size_t GetNoHistoryFiles() const );
67 #endif // WXWIN_COMPATIBILITY_2_6
71 wxArrayString m_fileHistory
;
73 // Menus to maintain (may need several for an MDI app)
76 // Max files to maintain
77 size_t m_fileMaxFiles
;
80 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
83 // Normalize a file name to canonical form. We have a special function for
84 // this to ensure the same normalization is used everywhere.
85 static wxString
NormalizeFileName(const wxFileName
& filename
);
87 wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase
);
90 #if WXWIN_COMPATIBILITY_2_6
91 inline size_t wxFileHistoryBase::GetNoHistoryFiles() const
93 return m_fileHistory
.GetCount();
95 #endif // WXWIN_COMPATIBILITY_2_6
98 #if defined(__WXGTK20__)
99 #include "wx/gtk/filehistory.h"
101 // no platform-specific implementation of wxFileHistory yet
102 class WXDLLIMPEXP_CORE wxFileHistory
: public wxFileHistoryBase
105 wxFileHistory(size_t maxFiles
= 9, wxWindowID idBase
= wxID_FILE1
)
106 : wxFileHistoryBase(maxFiles
, idBase
) {}
108 DECLARE_DYNAMIC_CLASS(wxFileHistory
)
112 #endif // wxUSE_FILE_HISTORY
114 #endif // _WX_FILEHISTORY_H_