]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filehistory.h
When wxPGProperty is un-attached from wxPropertyGrid, keep its 'default' cell referen...
[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
27 // ----------------------------------------------------------------------------
28 // File history management
29 // ----------------------------------------------------------------------------
30
31 class WXDLLIMPEXP_CORE wxFileHistoryBase : public wxObject
32 {
33 public:
34 wxFileHistoryBase(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);
35
36 // Operations
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);
41
42 // Remove menu from the list (MDI child may be closing)
43 virtual void RemoveMenu(wxMenu *menu);
44
45 #if wxUSE_CONFIG
46 virtual void Load(const wxConfigBase& config);
47 virtual void Save(wxConfigBase& config);
48 #endif // wxUSE_CONFIG
49
50 virtual void AddFilesToMenu();
51 virtual void AddFilesToMenu(wxMenu* menu); // Single menu
52
53 // Accessors
54 virtual wxString GetHistoryFile(size_t i) const { return m_fileHistory[i]; }
55 virtual size_t GetCount() const { return m_fileHistory.GetCount(); }
56
57 const wxList& GetMenus() const { return m_fileMenus; }
58
59 // Set/get base id
60 void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
61 wxWindowID GetBaseId() const { return m_idBase; }
62
63 #if WXWIN_COMPATIBILITY_2_6
64 // deprecated, use GetCount() instead
65 wxDEPRECATED( size_t GetNoHistoryFiles() const );
66 #endif // WXWIN_COMPATIBILITY_2_6
67
68 protected:
69 // Last n files
70 wxArrayString m_fileHistory;
71
72 // Menus to maintain (may need several for an MDI app)
73 wxList m_fileMenus;
74
75 // Max files to maintain
76 size_t m_fileMaxFiles;
77
78 private:
79 // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
80 wxWindowID m_idBase;
81
82 wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase);
83 };
84
85 #if WXWIN_COMPATIBILITY_2_6
86 inline size_t wxFileHistoryBase::GetNoHistoryFiles() const
87 {
88 return m_fileHistory.GetCount();
89 }
90 #endif // WXWIN_COMPATIBILITY_2_6
91
92
93 #if defined(__WXGTK20__)
94 #include "wx/gtk/filehistory.h"
95 #else
96 // no platform-specific implementation of wxFileHistory yet
97 class WXDLLIMPEXP_CORE wxFileHistory : public wxFileHistoryBase
98 {
99 public:
100 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1)
101 : wxFileHistoryBase(maxFiles, idBase) {}
102
103 DECLARE_DYNAMIC_CLASS(wxFileHistory)
104 };
105 #endif
106
107 #endif // wxUSE_FILE_HISTORY
108
109 #endif // _WX_FILEHISTORY_H_