]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filehistory.h
Somehow, setting a tint color makes gauge work :/.
[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 // Copyright: (c) Julian Smart, Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_FILEHISTORY_H_
11 #define _WX_FILEHISTORY_H_
12
13 #include "wx/defs.h"
14
15 #if wxUSE_FILE_HISTORY
16
17 #include "wx/windowid.h"
18 #include "wx/object.h"
19 #include "wx/list.h"
20 #include "wx/string.h"
21 #include "wx/arrstr.h"
22
23 class WXDLLIMPEXP_FWD_CORE wxMenu;
24 class WXDLLIMPEXP_FWD_BASE wxConfigBase;
25 class WXDLLIMPEXP_FWD_BASE wxFileName;
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 // 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);
85
86 wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase);
87 };
88
89 #if WXWIN_COMPATIBILITY_2_6
90 inline size_t wxFileHistoryBase::GetNoHistoryFiles() const
91 {
92 return m_fileHistory.GetCount();
93 }
94 #endif // WXWIN_COMPATIBILITY_2_6
95
96
97 #if defined(__WXGTK20__)
98 #include "wx/gtk/filehistory.h"
99 #else
100 // no platform-specific implementation of wxFileHistory yet
101 class WXDLLIMPEXP_CORE wxFileHistory : public wxFileHistoryBase
102 {
103 public:
104 wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1)
105 : wxFileHistoryBase(maxFiles, idBase) {}
106
107 DECLARE_DYNAMIC_CLASS(wxFileHistory)
108 };
109 #endif
110
111 #endif // wxUSE_FILE_HISTORY
112
113 #endif // _WX_FILEHISTORY_H_