2001-08-02 01:24:49 +04:00
|
|
|
//
|
2001-08-02 20:17:04 +04:00
|
|
|
// FileBrowser definitions.
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
2010-11-29 00:06:39 +03:00
|
|
|
// Copyright 1999-2010 by Michael Sweet.
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2005-04-16 04:13:17 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_File_Browser widget . */
|
|
|
|
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
// Include necessary header files...
|
|
|
|
//
|
|
|
|
|
2001-09-29 18:38:59 +04:00
|
|
|
#ifndef _Fl_File_Browser_H_
|
|
|
|
# define _Fl_File_Browser_H_
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2001-08-02 20:17:04 +04:00
|
|
|
# include "Fl_Browser.H"
|
2001-09-29 18:38:59 +04:00
|
|
|
# include "Fl_File_Icon.H"
|
2002-05-02 18:31:10 +04:00
|
|
|
# include "filename.H"
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2001-09-29 18:38:59 +04:00
|
|
|
// Fl_File_Browser class...
|
2001-08-02 01:24:49 +04:00
|
|
|
//
|
|
|
|
|
2008-09-14 16:45:42 +04:00
|
|
|
/** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */
|
2011-01-24 20:04:22 +03:00
|
|
|
class FL_EXPORT Fl_File_Browser : public Fl_Browser {
|
2020-07-01 19:03:10 +03:00
|
|
|
|
|
|
|
int filetype_;
|
|
|
|
const char *directory_;
|
|
|
|
uchar iconsize_;
|
|
|
|
const char *pattern_;
|
2020-07-11 07:49:00 +03:00
|
|
|
const char *errmsg_;
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
int full_height() const FL_OVERRIDE;
|
|
|
|
int item_height(void *) const FL_OVERRIDE;
|
|
|
|
int item_width(void *) const FL_OVERRIDE;
|
|
|
|
void item_draw(void *, int, int, int, int) const FL_OVERRIDE;
|
|
|
|
int incr_height() const FL_OVERRIDE { return (item_height(0)); }
|
2001-08-02 01:24:49 +04:00
|
|
|
|
|
|
|
public:
|
2001-09-29 18:38:59 +04:00
|
|
|
enum { FILES, DIRECTORIES };
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
Fl_File_Browser(int, int, int, int, const char * = 0);
|
2020-07-11 07:49:00 +03:00
|
|
|
~Fl_File_Browser();
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-09-14 16:45:42 +04:00
|
|
|
/** Sets or gets the size of the icons. The default size is 20 pixels. */
|
2021-08-27 15:52:43 +03:00
|
|
|
uchar iconsize() const { return (iconsize_); }
|
2008-09-14 16:45:42 +04:00
|
|
|
/** Sets or gets the size of the icons. The default size is 20 pixels. */
|
2021-08-27 15:52:43 +03:00
|
|
|
void iconsize(uchar s) { iconsize_ = s; redraw(); }
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-09-14 16:45:42 +04:00
|
|
|
/**
|
|
|
|
Sets or gets the filename filter. The pattern matching uses
|
|
|
|
the fl_filename_match()
|
|
|
|
function in FLTK.
|
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void filter(const char *pattern);
|
2008-09-14 16:45:42 +04:00
|
|
|
/**
|
|
|
|
Sets or gets the filename filter. The pattern matching uses
|
|
|
|
the fl_filename_match()
|
|
|
|
function in FLTK.
|
|
|
|
*/
|
2021-08-27 15:52:43 +03:00
|
|
|
const char *filter() const { return (pattern_); }
|
2020-07-01 19:03:10 +03:00
|
|
|
int load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort);
|
2021-08-27 15:52:43 +03:00
|
|
|
Fl_Fontsize textsize() const { return Fl_Browser::textsize(); }
|
|
|
|
void textsize(Fl_Fontsize s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); }
|
2001-09-04 17:13:29 +04:00
|
|
|
|
2008-09-14 16:45:42 +04:00
|
|
|
/**
|
|
|
|
Sets or gets the file browser type, FILES or
|
|
|
|
DIRECTORIES. When set to FILES, both
|
|
|
|
files and directories are shown. Otherwise only directories are
|
|
|
|
shown.
|
|
|
|
*/
|
2021-08-27 15:52:43 +03:00
|
|
|
int filetype() const { return (filetype_); }
|
2008-09-14 16:45:42 +04:00
|
|
|
/**
|
|
|
|
Sets or gets the file browser type, FILES or
|
|
|
|
DIRECTORIES. When set to FILES, both
|
|
|
|
files and directories are shown. Otherwise only directories are
|
|
|
|
shown.
|
|
|
|
*/
|
2021-08-27 15:52:43 +03:00
|
|
|
void filetype(int t) { filetype_ = t; }
|
2020-07-11 07:49:00 +03:00
|
|
|
void errmsg(const char *emsg);
|
|
|
|
/**
|
|
|
|
Returns OS error messages, or NULL if none. Use when advised.
|
|
|
|
*/
|
|
|
|
const char* errmsg() const { return errmsg_; }
|
2001-08-02 01:24:49 +04:00
|
|
|
};
|
|
|
|
|
2001-09-29 18:38:59 +04:00
|
|
|
#endif // !_Fl_File_Browser_H_
|