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
|
|
|
|
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
2003-03-19 17:15:32 +00:00
|
|
|
#include "lfuns.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class FileDialog
|
|
|
|
* \brief GUI-I definition of file dialog interface
|
|
|
|
*/
|
|
|
|
class FileDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// label, directory path button
|
|
|
|
typedef std::pair<string, string> Button;
|
|
|
|
|
|
|
|
/// result type
|
|
|
|
enum ResultType {
|
|
|
|
Later, /**< modeless chooser, no result */
|
|
|
|
Chosen /**< string contains filename */
|
|
|
|
};
|
|
|
|
|
|
|
|
/// result return
|
|
|
|
typedef std::pair<FileDialog::ResultType, string> Result;
|
|
|
|
|
|
|
|
/**
|
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-02-21 12:22:25 +00:00
|
|
|
FileDialog(string const & title,
|
2002-01-10 10:05:45 +00:00
|
|
|
kb_action a = LFUN_SELECT_FILE_SYNC,
|
|
|
|
Button b1 = Button(string(), string()),
|
|
|
|
Button b2 = Button(string(), string()));
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
~FileDialog();
|
|
|
|
|
|
|
|
/**
|
2002-11-17 08:32:09 +00:00
|
|
|
* Choose a file for opening, starting in directory \param
|
2002-01-10 10:05:45 +00:00
|
|
|
* path, with the file selection \param mask. The \param mask
|
2002-03-21 21:21:28 +00:00
|
|
|
* string is of the form :
|
2001-03-07 14:25:31 +00:00
|
|
|
*
|
2002-06-18 20:47:49 +00:00
|
|
|
* <glob to match> | <description>
|
2001-03-07 14:25:31 +00:00
|
|
|
*
|
|
|
|
* for example, "*.ps | PostScript files (*.ps)".
|
|
|
|
*
|
|
|
|
* FIXME: should support multiple lines of these for different file types.
|
|
|
|
*/
|
2002-11-17 08:32:09 +00:00
|
|
|
Result const open(string const & path = string(),
|
|
|
|
string const & mask = string(),
|
|
|
|
string const & suggested = string());
|
2003-02-25 13:17:01 +00:00
|
|
|
|
2003-01-14 21:51:34 +00:00
|
|
|
/**
|
|
|
|
* Choose a directory, starting in directory \param
|
|
|
|
* path.
|
|
|
|
*/
|
|
|
|
Result const opendir(string const & path = string(),
|
|
|
|
string const & suggested = string());
|
2002-11-17 08:32:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Choose a file for saving, starting in directory \param
|
|
|
|
* path, with the file selection \param mask. The \param mask
|
|
|
|
* string is of the form :
|
|
|
|
*
|
|
|
|
* <glob to match> | <description>
|
|
|
|
*
|
|
|
|
* for example, "*.ps | PostScript files (*.ps)".
|
|
|
|
*/
|
|
|
|
Result const save(string const & path = string(),
|
2001-03-07 14:25:31 +00:00
|
|
|
string const & mask = string(),
|
|
|
|
string const & suggested = string());
|
|
|
|
|
|
|
|
|
|
|
|
/* This *has* to be public because there is no way to specify extern "C" functions
|
|
|
|
* as friends of Private implementation for the xforms implementation ... grr
|
|
|
|
*/
|
|
|
|
class Private;
|
|
|
|
friend class Private;
|
|
|
|
Private * private_;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// the dialog title
|
|
|
|
string title_;
|
|
|
|
|
|
|
|
/// success action to perform if not synchronous
|
|
|
|
kb_action success_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FILEDIALOG_H
|