summaryrefslogtreecommitdiff
path: root/public/toolutils/recentfilelist.h
blob: 307ee543fe425f2587f4487644852de2dcc69c58 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Class that contains a list of recent files
//
//=============================================================================

#ifndef RECENTFILELIST_H
#define RECENTFILELIST_H

#ifdef _WIN32
#pragma once
#endif


#include "tier1/utlvector.h"
#include "tier1/utlstring.h"


//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
namespace vgui
{
	class Menu;
	class Panel;
}


//-----------------------------------------------------------------------------
// Max # of recent files
//-----------------------------------------------------------------------------
#define MAX_RECENT_FILES	20


//-----------------------------------------------------------------------------
// Class that contains a list of recent files
//-----------------------------------------------------------------------------
class CRecentFileList
{
public:
	// Adds a file to the list
	void		Add( const char *pFileName, const char *pFileFormat );

	// Gets the file in a particular slot
	const char	*GetFile( int slot ) const;
	const char	*GetFileFormat( int slot ) const;

	// Removes all files from the list
	void		Clear();

	// Load, store to registry
	void		LoadFromRegistry( const char *pToolKeyName );
	void		SaveToRegistry( const char *pToolKeyName ) const;

	// Adds all files in a list to a menu.
	// Will generate the commands '<pCommandName>01', '<pCommandName>02', etc.
	// depending on which one is selected
	void		AddToMenu( vgui::Menu *menu, vgui::Panel *actionTarget, const char *pCommandName ) const;

	// Returns true if there's no files in the file list
	bool		IsEmpty() const;

private:
	struct RecentFileInfo_t
	{
		CUtlString m_pFileName;
		CUtlString m_pFileFormat;

		bool operator==( const RecentFileInfo_t& src ) const
		{
			return m_pFileName == src.m_pFileName;
		}
	};

	CUtlVector< RecentFileInfo_t >	m_RecentFiles;
};


#endif // RECENTFILELIST_H