File: filedialog.h

package info (click to toggle)
clanlib 0.5.4-1-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,320 kB
  • ctags: 10,893
  • sloc: cpp: 76,056; xml: 3,281; sh: 2,961; perl: 1,204; asm: 837; makefile: 775
file content (122 lines) | stat: -rw-r--r-- 3,269 bytes parent folder | download
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
114
115
116
117
118
119
120
121
122
/*
	$Id: filedialog.h,v 1.19 2001/12/27 23:14:03 sphair Exp $

	------------------------------------------------------------------------
	ClanLib, the platform independent game SDK.

	This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
	version 2. See COPYING for details.

	For a total list of contributers see CREDITS.

	See http://www.clanlib.org
	------------------------------------------------------------------------
*/

//! clanGUI="Controls"
//! header=gui.h

#ifndef header_file_dialog
#define header_file_dialog

#include "window.h"

class CL_FileDialog_Generic;

//: File dialog component
class CL_FileDialog : public CL_Window
{
//! Construction:
public:
	//: File dialog constructor
	CL_FileDialog(
		CL_Component *parent,
		CL_StyleManager *style = NULL);

	//: File dialog constructor
	CL_FileDialog(
		const std::string &title,
		const std::string &file,
		const std::string &filter,
		CL_Component *parent,
		CL_StyleManager *style = NULL);

	//: File dialog destructor
	virtual ~CL_FileDialog();

	//: Open
	static const std::string open(
		CL_Component *parent);

	//: Open
	static const std::string open(
		const std::string &file,
		const std::string &filter,
		CL_Component *parent);

	//: Save
	static const std::string save(
		CL_Component *parent);

	//: Save
	static const std::string save(
		const std::string &file,
		const std::string &filter,
		CL_Component *parent);

//! Attributes:
public:
	//: Returns the selected file name. 
	const std::string &get_file() const;

	//: Returns the filter which the user has chosen in the file dialog.
	const std::string &get_filter() const;

	//: Returns the active directory in the file dialog.
	const std::string &get_dir() const;

	//: Returns the active directory path in the file dialog. 
	const std::string &get_path() const;

	//: Returns true if hidden files are shown in the filedialog, else false.
	bool is_hidden_files_visible() const;

//! Operations:
public:
	//: Sets the default selection to filename.
	//: If filename is absolute, set_dir() is also called. 
	void set_file(const std::string &filename);

	//: Sets a directory path for the file dialog. 
	void set_dir(const std::string &dir);

	//: Sets the filter to filter.
	void set_filter(const std::string &filter);

	//: If enable is true, hidden files are shown in the filedialog, else no hidden files are shown. 
	void show_hidden_files(bool enable = true);

	//: Re-reads the active directory in the file dialog. 
	//: <p>It is seldom necessary to call this function.
	//: It is provided in case the directory contents change and you want to refresh the directory listbox.</p>
	void refresh();

//! Signals:
public:
	//: This signal is emitted when the user highlights a file. 
	CL_Signal_v1<const std::string &> &sig_file_highlighted();

	//: This signal is emitted when the user selects a file. 
	CL_Signal_v1<const std::string &> &sig_file_selected();

	//: This signal is emitted when the user has selected a new directory. 
	CL_Signal_v1<const std::string &> &sig_dir_entered();

//! Implementation:
private:
// TODO: Fix this copy constructor
//	CL_FileDialog(const CL_FileDialog &copy) : CL_Component(NULL, NULL) { return; } // disallow copy construction.
	CL_FileDialog_Generic *impl;
};

#endif