-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFileBrowser.h
121 lines (102 loc) · 3.87 KB
/
FileBrowser.h
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
//
// "$Id$"
//
// FileBrowser definitions.
//
// Copyright 1999-2006 by Michael Sweet.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
//
// Include necessary header files...
//
#ifndef fltk_FileBrowser_h
#define fltk_FileBrowser_h
#include <fltk/Browser.h>
#include <fltk/FileIcon.h>
#include <fltk/filename.h>
namespace fltk {
//
// FileBrowser class...
//
class FL_API FileBrowser : public Browser
{
int filetype_; /**< Paramted based on FileBrowser::FILES or FileBrowser::DIRECTORIES */
const char *directory_; /**< The current directory */
float icon_size_; /**< The FileBrowser's icon sizes */
const char *pattern_; /**< The filename glob pattern \todo regex! */
public:
/** The types of items this browser can show */
enum {
FILES, /**< Show all files */
DIRECTORIES /**< Show only directories */
};
FileBrowser(int, int, int, int, const char * = 0);
/** \returns The icon size as a float */
float icon_size() const {
return (icon_size_ <0? (2.0f* textsize()) : icon_size_);
}
/** Sets the icon size and redraws the browser
\param f The new icon size
*/
void icon_size(float f) { icon_size_ = f; redraw(); };
void filter(const char *pattern);
/** \returns The filter pattern */
const char *filter() const { return (pattern_); };
int load(const char *directory, FileSortF *sort = (FileSortF*) fltk::numericsort);
/** \returns the current Browser's textsize */
float textsize() const { return (Browser::textsize()); };
/** Sets the current Browser's textsize and scales the icon size accordingly
\param s The new text size
*/
void textsize(float s) { Browser::textsize(s); icon_size_ = (uchar)(3 * s / 2); };
/** \returns The browser's current filetype */
int filetype() const { return (filetype_); };
/** Sets the filetype
\param t The new filetype. Can be either FileBrowser::DIRECTORIES or FileBrowser::FILES
*/
void filetype(int t) { filetype_ = t; };
/** \return The current directory */
const char * directory() const {return directory_;}
// adding or inserting a line into the fileBrowser
void insert(int n, const char* label, FileIcon* icon);
/** Inserts a line at the 'n'th position with Callback data set. This will not attempt to split the label at '/' characters
\param n The position to insert \a at. This will append if necessary
\param label The label of the widget
\param data The callback data of the widget
*/
void insert(int n, const char* label, void* data){Menu::insert(n, label,data);}
void add(const char * line, FileIcon* icon);
// Showing or not showing the hidden files, that's the question:
public:
/** Set this flag if you want to see the hidden files in the browser
\param show A flag to determine whether or not to show hidden files
*/
void show_hidden(bool show) { show_hidden_= show; }
/** \return Whether or not we're currently showing hidden files */
bool show_hidden() const {return show_hidden_;}
private:
bool show_hidden_; /**< Used to determine whether to show hidden files or not */
};
}
#endif // !_Fl_File_Browser_H_
//
// End of "$Id$".
//