2001-03-15 18:21:56 +00:00
|
|
|
// -*- C++ -*-
|
2001-03-07 14:25:31 +00:00
|
|
|
/**
|
|
|
|
* \file FormFiledialog.h
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
1999-10-07 18:44:17 +00:00
|
|
|
*
|
2001-03-07 14:25:31 +00:00
|
|
|
* \author unknown
|
|
|
|
* \author John Levon
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#ifndef FORMFILEDIALOG_H
|
|
|
|
#define FORMFILEDIALOG_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <sigc++/signal_system.h>
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
#include "LString.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include FORMS_H_LOCATION
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "form_filedialog.h"
|
|
|
|
|
|
|
|
#include "frontends/FileDialog.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
/// DirEntry internal structure definition
|
|
|
|
class DirEntry {
|
1999-11-22 16:19:48 +00:00
|
|
|
public:
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszName;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszDisplayed;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszLsEntry;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data);
|
|
|
|
extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data);
|
|
|
|
extern "C" int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-15 18:21:56 +00:00
|
|
|
class FileDialog::Private : public SigC::Object
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
2001-03-07 14:25:31 +00:00
|
|
|
Private();
|
2000-11-28 06:46:06 +00:00
|
|
|
///
|
2001-03-07 14:25:31 +00:00
|
|
|
~Private();
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// sets file selector user button action
|
2001-03-07 14:25:31 +00:00
|
|
|
void SetButton(int iIndex, string const & pszName = string(),
|
1999-10-02 16:21:10 +00:00
|
|
|
string const & pszPath = string());
|
1999-09-27 18:44:28 +00:00
|
|
|
/// gets last dialog directory
|
2000-09-14 17:53:12 +00:00
|
|
|
string const GetDirectory() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// launches dialog and returns selected file
|
2000-09-14 17:53:12 +00:00
|
|
|
string const Select(string const & pszTitle = string(),
|
1999-10-02 16:21:10 +00:00
|
|
|
string const & pszPath = string(),
|
2001-03-07 14:25:31 +00:00
|
|
|
string const & pszMask = string(),
|
1999-10-02 16:21:10 +00:00
|
|
|
string const & pszSuggested = string());
|
1999-09-27 18:44:28 +00:00
|
|
|
/// XForms objects callback (static)
|
|
|
|
static void FileDlgCB(FL_OBJECT *, long);
|
|
|
|
/// Callback for double click in list
|
|
|
|
static void DoubleClickCB(FL_OBJECT *, long);
|
1999-10-25 14:18:30 +00:00
|
|
|
/// Handle Cancel CB from WM close
|
|
|
|
static int CancelCB(FL_FORM *, void *);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
1999-11-22 16:19:48 +00:00
|
|
|
/// data
|
2001-03-07 14:25:31 +00:00
|
|
|
static FD_form_filedialog * pFileDlgForm;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
2001-03-07 14:25:31 +00:00
|
|
|
static FileDialog::Private * pCurrentDlg;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszUserPath1;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszUserPath2;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszDirectory;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszMask;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszFileName;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
int iDepth;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
int iLastSel;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
long lLastTime;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string pszInfoLine;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
2001-03-07 14:25:31 +00:00
|
|
|
typedef std::vector<DirEntry> DirEntries;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
|
|
|
DirEntries direntries;
|
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
bool force_cancel;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
bool force_ok;
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
/// build the dialog
|
|
|
|
FD_form_filedialog * build_filedialog();
|
|
|
|
|
2000-11-28 06:46:06 +00:00
|
|
|
/** Redraw the form (on receipt of a Signal indicating, for example,
|
|
|
|
that the xform colors have been re-mapped).
|
|
|
|
*/
|
|
|
|
void redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
/// updates dialog list to match class directory
|
|
|
|
void Reread();
|
|
|
|
/// sets dialog current directory
|
1999-10-02 16:21:10 +00:00
|
|
|
void SetDirectory(string const & pszPath);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// sets dialog file mask
|
1999-10-02 16:21:10 +00:00
|
|
|
void SetMask(string const & pszNewMask);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// sets dialog information line
|
1999-10-02 16:21:10 +00:00
|
|
|
void SetInfoLine(string const & pszLine);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// handle dialog during file selection
|
|
|
|
bool RunDialog();
|
|
|
|
/// Handle callback from list
|
|
|
|
void HandleListHit();
|
|
|
|
/// Handle double click from list
|
|
|
|
bool HandleDoubleClick();
|
|
|
|
/// Handle OK button call
|
|
|
|
bool HandleOK();
|
|
|
|
/// Simulates a click on OK/Cancel
|
|
|
|
void Force(bool);
|
2000-11-28 06:46:06 +00:00
|
|
|
/// Redraw connection.
|
2001-03-15 18:21:56 +00:00
|
|
|
SigC::Connection r_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#endif // FORMFILEDIALOG_H
|