2001-06-14 08:20:41 +00:00
|
|
|
// -*- C++ -*-
|
2001-03-07 14:25:31 +00:00
|
|
|
/**
|
|
|
|
* \file FileDialog.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-07 14:25:31 +00:00
|
|
|
*
|
|
|
|
* \author unknown
|
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FILEDIALOG_H
|
|
|
|
#define FILEDIALOG_H
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
#include "lfuns.h"
|
2006-10-09 16:33:20 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#include <utility>
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace support { class FileFilterList; }
|
2004-01-08 10:59:51 +00:00
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
/**
|
|
|
|
* \class FileDialog
|
|
|
|
* \brief GUI-I definition of file dialog interface
|
|
|
|
*/
|
|
|
|
class FileDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// label, directory path button
|
2006-10-21 00:16:43 +00:00
|
|
|
typedef std::pair<docstring, docstring> Button;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/// result type
|
|
|
|
enum ResultType {
|
|
|
|
Later, /**< modeless chooser, no result */
|
|
|
|
Chosen /**< string contains filename */
|
|
|
|
};
|
|
|
|
|
|
|
|
/// result return
|
2006-10-21 00:16:43 +00:00
|
|
|
typedef std::pair<FileDialog::ResultType, docstring> Result;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/**
|
2003-02-21 12:22:25 +00:00
|
|
|
* Constructs a file dialog with title \param title.
|
|
|
|
* If \param a is \const LFUN_SELECT_FILE_SYNC then a value
|
|
|
|
* will be returned immediately upon performing a open(),
|
2001-03-07 14:25:31 +00:00
|
|
|
* otherwise a callback Dispatch() will be invoked with the filename as
|
|
|
|
* argument, of action \param a.
|
|
|
|
*
|
2002-01-10 10:05:45 +00:00
|
|
|
* Up to two optional extra buttons are allowed for specifying
|
|
|
|
* additional directories in the navigation (an empty
|
|
|
|
* directory is interpreted as getcwd())
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
2006-10-21 00:16:43 +00:00
|
|
|
FileDialog(docstring const & title,
|
2002-01-10 10:05:45 +00:00
|
|
|
kb_action a = LFUN_SELECT_FILE_SYNC,
|
2006-10-21 00:16:43 +00:00
|
|
|
Button b1 = Button(docstring(), docstring()),
|
|
|
|
Button b2 = Button(docstring(), docstring()));
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
~FileDialog();
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
/// Choose a file for opening, starting in directory \c path.
|
2006-10-21 00:16:43 +00:00
|
|
|
Result const open(docstring const & path,
|
|
|
|
support::FileFilterList const & filters,
|
|
|
|
docstring const & suggested);
|
2003-02-25 13:17:01 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
/// Choose a directory, starting in directory \c path.
|
2006-10-21 00:16:43 +00:00
|
|
|
Result const opendir(docstring const & path = docstring(),
|
|
|
|
docstring const & suggested = docstring());
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
/// Choose a file for saving, starting in directory \c path.
|
2006-10-21 00:16:43 +00:00
|
|
|
Result const save(docstring const & path,
|
|
|
|
support::FileFilterList const & filters,
|
|
|
|
docstring const & suggested);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2006-07-09 17:27:17 +00:00
|
|
|
private:
|
2001-03-07 14:25:31 +00:00
|
|
|
class Private;
|
|
|
|
friend class Private;
|
|
|
|
Private * private_;
|
|
|
|
|
|
|
|
/// the dialog title
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring title_;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/// success action to perform if not synchronous
|
|
|
|
kb_action success_;
|
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#endif // FILEDIALOG_H
|