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"
|
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 {
|
|
|
|
namespace support {
|
|
|
|
|
|
|
|
class FileFilterList;
|
|
|
|
|
|
|
|
} // namespace support
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::pair<std::string, std::string> Button;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/// result type
|
|
|
|
enum ResultType {
|
|
|
|
Later, /**< modeless chooser, no result */
|
|
|
|
Chosen /**< string contains filename */
|
|
|
|
};
|
|
|
|
|
|
|
|
/// result return
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::pair<FileDialog::ResultType, std::string> 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
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
FileDialog(std::string const & title,
|
2002-01-10 10:05:45 +00:00
|
|
|
kb_action a = LFUN_SELECT_FILE_SYNC,
|
2003-10-06 15:43:21 +00:00
|
|
|
Button b1 = Button(std::string(), std::string()),
|
|
|
|
Button b2 = Button(std::string(), std::string()));
|
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.
|
|
|
|
Result const open(std::string const & path,
|
|
|
|
lyx::support::FileFilterList const & filters,
|
|
|
|
std::string 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.
|
2003-10-06 15:43:21 +00:00
|
|
|
Result const opendir(std::string const & path = std::string(),
|
2004-01-08 10:59:51 +00:00
|
|
|
std::string const & suggested = std::string());
|
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.
|
|
|
|
Result const save(std::string const & path,
|
|
|
|
lyx::support::FileFilterList const & filters,
|
|
|
|
std::string 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
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string title_;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/// success action to perform if not synchronous
|
|
|
|
kb_action success_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FILEDIALOG_H
|