File: filehistory.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (113 lines) | stat: -rw-r--r-- 3,386 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/filehistory.h
// Purpose:     wxFileHistory class
// Author:      Julian Smart, Vaclav Slavik
// Created:     2010-05-03
// Copyright:   (c) Julian Smart, Vaclav Slavik
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_FILEHISTORY_H_
#define _WX_FILEHISTORY_H_

#include "wx/defs.h"

#if wxUSE_FILE_HISTORY

#include "wx/windowid.h"
#include "wx/object.h"
#include "wx/list.h"
#include "wx/string.h"
#include "wx/arrstr.h"

class WXDLLIMPEXP_FWD_CORE wxMenu;
class WXDLLIMPEXP_FWD_BASE wxConfigBase;
class WXDLLIMPEXP_FWD_BASE wxFileName;

// ----------------------------------------------------------------------------
// File history management
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxFileHistoryBase : public wxObject
{
public:
    wxFileHistoryBase(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1);

    // Operations
    virtual void AddFileToHistory(const wxString& file);
    virtual void RemoveFileFromHistory(size_t i);
    virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; }
    virtual void UseMenu(wxMenu *menu);

    // Remove menu from the list (MDI child may be closing)
    virtual void RemoveMenu(wxMenu *menu);

#if wxUSE_CONFIG
    virtual void Load(const wxConfigBase& config);
    virtual void Save(wxConfigBase& config);
#endif // wxUSE_CONFIG

    virtual void AddFilesToMenu();
    virtual void AddFilesToMenu(wxMenu* menu); // Single menu

    // Accessors
    virtual wxString GetHistoryFile(size_t i) const { return m_fileHistory[i]; }
    virtual size_t GetCount() const { return m_fileHistory.GetCount(); }

    const wxList& GetMenus() const { return m_fileMenus; }

    // Set/get base id
    void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
    wxWindowID GetBaseId() const { return m_idBase; }

#if WXWIN_COMPATIBILITY_2_6
    // deprecated, use GetCount() instead
    wxDEPRECATED( size_t GetNoHistoryFiles() const );
#endif // WXWIN_COMPATIBILITY_2_6

protected:
    // Last n files
    wxArrayString     m_fileHistory;

    // Menus to maintain (may need several for an MDI app)
    wxList            m_fileMenus;

    // Max files to maintain
    size_t            m_fileMaxFiles;

private:
    // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
    wxWindowID m_idBase;

    // Normalize a file name to canonical form. We have a special function for
    // this to ensure the same normalization is used everywhere.
    static wxString NormalizeFileName(const wxFileName& filename);

    wxDECLARE_NO_COPY_CLASS(wxFileHistoryBase);
};

#if WXWIN_COMPATIBILITY_2_6
inline size_t wxFileHistoryBase::GetNoHistoryFiles() const
{
    return m_fileHistory.GetCount();
}
#endif // WXWIN_COMPATIBILITY_2_6


#if defined(__WXGTK20__)
    #include "wx/gtk/filehistory.h"
#else
    // no platform-specific implementation of wxFileHistory yet
    class WXDLLIMPEXP_CORE wxFileHistory : public wxFileHistoryBase
    {
    public:
        wxFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1)
            : wxFileHistoryBase(maxFiles, idBase) {}

        DECLARE_DYNAMIC_CLASS(wxFileHistory)
    };
#endif

#endif // wxUSE_FILE_HISTORY

#endif // _WX_FILEHISTORY_H_