1 //
2 // "$Id$"
3 //
4 // FileBrowser definitions.
5 //
6 // Copyright 1999-2010 by Michael Sweet.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file.  If this
10 // file is missing or damaged, see the license at:
11 //
12 //     http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 //     http://www.fltk.org/str.php
17 //
18 
19 /* \file
20    Fl_File_Browser widget . */
21 
22 //
23 // Include necessary header files...
24 //
25 
26 #ifndef _Fl_File_Browser_H_
27 #  define _Fl_File_Browser_H_
28 
29 #  include "Fl_Browser.H"
30 #  include "Fl_File_Icon.H"
31 #  include "filename.H"
32 
33 
34 //
35 // Fl_File_Browser class...
36 //
37 
38 /** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */
39 class FL_EXPORT Fl_File_Browser : public Fl_Browser {
40 
41   int		filetype_;
42   const char	*directory_;
43   uchar		iconsize_;
44   const char	*pattern_;
45 
46   int		full_height() const;
47   int		item_height(void *) const;
48   int		item_width(void *) const;
49   void		item_draw(void *, int, int, int, int) const;
incr_height()50   int		incr_height() const { return (item_height(0)); }
51 
52 public:
53   enum { FILES, DIRECTORIES };
54 
55   /**
56     The constructor creates the Fl_File_Browser widget at the specified position and size.
57     The destructor destroys the widget and frees all memory that has been allocated.
58   */
59   Fl_File_Browser(int, int, int, int, const char * = 0);
60 
61   /**    Sets or gets the size of the icons. The default size is 20 pixels.  */
iconsize()62   uchar		iconsize() const { return (iconsize_); };
63   /**    Sets or gets the size of the icons. The default size is 20 pixels.  */
iconsize(uchar s)64   void		iconsize(uchar s) { iconsize_ = s; redraw(); };
65 
66   /**
67     Sets or gets the filename filter. The pattern matching uses
68     the fl_filename_match()
69     function in FLTK.
70   */
71   void	filter(const char *pattern);
72   /**
73     Sets or gets the filename filter. The pattern matching uses
74     the fl_filename_match()
75     function in FLTK.
76   */
filter()77   const char	*filter() const { return (pattern_); };
78 
79   /**
80     Loads the specified directory into the browser. If icons have been
81     loaded then the correct icon is associated with each file in the list.
82 
83     <P>The sort argument specifies a sort function to be used with
84     fl_filename_list().
85   */
86   int		load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort);
87 
textsize()88   Fl_Fontsize  textsize() const { return Fl_Browser::textsize(); };
textsize(Fl_Fontsize s)89   void		textsize(Fl_Fontsize s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); };
90 
91   /**
92     Sets or gets the file browser type, FILES or
93     DIRECTORIES. When set to FILES, both
94     files and directories are shown. Otherwise only directories are
95     shown.
96   */
filetype()97   int		filetype() const { return (filetype_); };
98   /**
99     Sets or gets the file browser type, FILES or
100     DIRECTORIES. When set to FILES, both
101     files and directories are shown. Otherwise only directories are
102     shown.
103   */
filetype(int t)104   void		filetype(int t) { filetype_ = t; };
105 };
106 
107 #endif // !_Fl_File_Browser_H_
108 
109 //
110 // End of "$Id$".
111 //
112