]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filehistory.h
export wxRichTextObjectPtrArrayArray since it is used in the public API.
[wxWidgets.git] / include / wx / filehistory.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filehistory.h
3 // Purpose: wxFileHistory class
4 // Author: Julian Smart, Vaclav Slavik
5 // Created: 2010-05-03
6 // RCS-ID: $Id$
7 // Copyright: (c) Julian Smart, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_FILEHISTORY_H_
12 #define _WX_FILEHISTORY_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_FILE_HISTORY
17
18 #include "wx/windowid.h"
19 #include "wx/object.h"
20 #include "wx/list.h"
21 #include "wx/string.h"
22 #include "wx/arrstr.h"
23
24 class WXDLLIMPEXP_FWD_CORE wxMenu;
25 class WXDLLIMPEXP_FWD_BASE wxConfigBase;
26 class WXDLLIMPEXP_FWD_BASE wxFileName;
27
28 // ----------------------------------------------------------------------------
29 // File history management
30 // ----------------------------------------------------------------------------
31
32 class WXDLLIMPEXP_CORE wxFileHistoryBase : public wxObject
33 {
34 public:
35 wxFileHistoryBase(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
36
37 // Operations
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);
42
43 // Remove menu from the list (MDI child may be closing)
44 virtual void RemoveMenu(wxMenu *menu);
45
46 #if wxUSE_CONFIG
47 virtual void Load(const wxConfigBase& config);
48 virtual void Save(wxConfigBase& config);
49 #endif // wxUSE_CONFIG
50
51 virtual void AddFilesToMenu();
52 virtual void AddFilesToMenu(wxMenu* menu); // Single menu
53
54 // Accessors
55 virtual wxString GetHistoryFile(size_t i) const { return m_fileHistory[i]; }
56 virtual size_t GetCount() const { return m_fileHistory.GetCount(); }
57
58 const wxList& GetMenus() const { return m_fileMenus; }
59
60 // Set/get base id
61 void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
62 wxWindowID GetBaseId() const { return m_idBase; }
63
64 #if WXWIN_COMPATIBILITY_2_6
65 // deprecated, use GetCount() instead
66 wxDEPRECATED( size_t GetNoHistoryFiles() const );
67 #endif // WXWIN_COMPATIBILITY_2_6
68
69 protected:
70 // Last n files
71 wxArrayString m_fileHistory;
72
73 // Menus to maintain (may need several for an MDI app)
74 wxList m_fileMenus;
75
76 // Max files to maintain
77 size_t m_fileMaxFiles;
78
79 private:
80 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
81 wxWindowID m_idBase;
82
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);
86
87 wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase);
88 };
89
90 #if WXWIN_COMPATIBILITY_2_6
91 inline size_t wxFileHistoryBase::GetNoHistoryFiles() const
92 {
93 return m_fileHistory.GetCount();
94 }
95 #endif // WXWIN_COMPATIBILITY_2_6
96
97
98 #if defined(__WXGTK20__)
99 #include "wx/gtk/filehistory.h"
100 #else
101 // no platform-specific implementation of wxFileHistory yet
102 class WXDLLIMPEXP_CORE wxFileHistory : public wxFileHistoryBase
103 {
104 public:
105 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1)
106 : wxFileHistoryBase(maxFiles, idBase) {}
107
108 DECLARE_DYNAMIC_CLASS(wxFileHistory)
109 };
110 #endif
111
112 #endif // wxUSE_FILE_HISTORY
113
114 #endif // _WX_FILEHISTORY_H_