File: filedialog.cpp

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 (156 lines) | stat: -rw-r--r-- 3,432 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
	$Id: filedialog.cpp,v 1.12 2001/12/27 23:14:03 sphair Exp $
	
	ClanGUI, copyrights by various people. Have a look in the CREDITS file.
	
	This sourcecode is distributed using the Library GNU Public Licence,
	version 2 or (at your option) any later version. Please read LICENSE
	for details.
*/

#include "precomp.h"
#include "API/GUI/filedialog.h"
#include "API/GUI/component_options.h"
#include "API/GUI/stylemanager.h"
#include "filedialog_generic.h"

/////////////////////////////////////////////////////////////////////////////
// Construction:

CL_FileDialog::CL_FileDialog(
	CL_Component *parent,
	CL_StyleManager *style)
: CL_Window(parent, style), impl(NULL)
{
	impl = new CL_FileDialog_Generic(this, "", "", "");
}

CL_FileDialog::CL_FileDialog(
	const std::string &title,
	const std::string &file,
	const std::string &filter,
	CL_Component *parent,
	CL_StyleManager *style)
: CL_Window(parent, style), impl(NULL)
{
	impl = new CL_FileDialog_Generic(this, title, file, filter);
}

CL_FileDialog::~CL_FileDialog()
{
	delete impl;
}

const std::string CL_FileDialog::open(
	CL_Component *parent)
{
	CL_FileDialog filedialog("Open File", "", "*.*", NULL, parent->get_style_manager());
	filedialog.run(parent);

	return filedialog.get_file();
}

const std::string CL_FileDialog::open(
	const std::string &file,
	const std::string &filter,
	CL_Component *parent)
{
	CL_FileDialog filedialog("Open File", file, filter, NULL, parent->get_style_manager());
	filedialog.run(parent);

	return filedialog.get_file();
}

const std::string CL_FileDialog::save(
	CL_Component *parent)
{
	CL_FileDialog filedialog("Save File", "", "*.*", NULL, parent->get_style_manager());
	filedialog.run(parent);

	return filedialog.get_file();
}

const std::string CL_FileDialog::save(
	const std::string &file,
	const std::string &filter,
	CL_Component *parent)
{
	CL_FileDialog filedialog("Save File", file, filter, NULL, parent->get_style_manager());
	filedialog.run(parent);

	return filedialog.get_file();
}

/////////////////////////////////////////////////////////////////////////////
// Attributes:

const std::string &CL_FileDialog::get_file() const
{
	return impl->get_file();
}

const std::string &CL_FileDialog::get_filter() const
{
	return impl->get_filter();
}

const std::string &CL_FileDialog::get_dir() const
{
	return impl->get_dir();
}

const std::string &CL_FileDialog::get_path() const
{
	return impl->get_path();
}

bool CL_FileDialog::is_hidden_files_visible() const
{
	return impl->is_hidden_files_visible();
}

/////////////////////////////////////////////////////////////////////////////
// Operations:

void CL_FileDialog::set_file(const std::string &filename)
{
	impl->set_file(filename);
}

void CL_FileDialog::set_dir(const std::string &dir)
{
	impl->set_dir(dir);
}

void CL_FileDialog::set_filter(const std::string &filter)
{
	impl->set_filter(filter);
}

void CL_FileDialog::show_hidden_files(bool enable)
{
	impl->show_hidden_files(enable);
}

void CL_FileDialog::refresh()
{
	impl->refresh();
}

/////////////////////////////////////////////////////////////////////////////
// Signals:

CL_Signal_v1<const std::string &> &CL_FileDialog::sig_file_highlighted()
{
	return impl->sig_file_highlighted;
}

CL_Signal_v1<const std::string &> &CL_FileDialog::sig_file_selected()
{
	return impl->sig_file_selected;
}

CL_Signal_v1<const std::string &> &CL_FileDialog::sig_dir_entered()
{
	return impl->sig_dir_entered;
}