2003-02-25 14:51:38 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file Dialog.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*
|
|
|
|
* The dialogs use a Model-Controller-View split, instantiated here
|
|
|
|
* by class Dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DIALOG_H
|
|
|
|
#define DIALOG_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "Kernel.h"
|
|
|
|
#include "LString.h"
|
|
|
|
#include <boost/utility.hpp>
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
class LyXView;
|
2003-03-10 03:13:28 +00:00
|
|
|
class ButtonController;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Dialog : boost::noncopyable {
|
|
|
|
public:
|
|
|
|
/** the Dialog's "name" is the means with which a dialog identifies
|
|
|
|
* itself to the kernel.
|
|
|
|
*/
|
|
|
|
Dialog(LyXView &, string const & name);
|
2003-03-10 03:13:28 +00:00
|
|
|
///
|
|
|
|
~Dialog();
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
string const & name() const { return name_; }
|
|
|
|
|
|
|
|
/** These methods are publicly accessible because they are invoked
|
|
|
|
by the View.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
///
|
|
|
|
void ApplyButton();
|
|
|
|
///
|
|
|
|
void OKButton();
|
|
|
|
///
|
|
|
|
void CancelButton();
|
|
|
|
///
|
|
|
|
void RestoreButton();
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** These methods are publicly accessible because they are invoked
|
|
|
|
* by the Dialogs class.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
/** Some dialogs, eg the Tabular or Preferences dialog, can extract
|
|
|
|
the information they require from the kernel. These dialogs will
|
|
|
|
probably be passed an empty string by the calling Dialogs class.
|
|
|
|
The inset dialogs, however, require information specific to
|
|
|
|
an individual inset. This information will be encoded in "data"
|
|
|
|
and must be translated into a set of parameters that can be
|
|
|
|
updated from the dialog.
|
|
|
|
*/
|
|
|
|
void show(string const & data = string());
|
|
|
|
///
|
|
|
|
void update(string const & data = string());
|
|
|
|
///
|
|
|
|
void hide();
|
|
|
|
///
|
|
|
|
bool isVisible() const;
|
|
|
|
/// (Eg, the GUI colours have been changed.)
|
|
|
|
void redraw();
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** When Applying it's useful to know whether the dialog is about
|
|
|
|
* to close or not (no point refreshing the display for example).
|
|
|
|
*/
|
|
|
|
bool isClosing() const { return is_closing_; }
|
|
|
|
|
|
|
|
/// The LyX kernel is made available through this.
|
|
|
|
Kernel & kernel() { return kernel_; }
|
|
|
|
|
|
|
|
/** Different dialogs will have different
|
|
|
|
Controllers, Views and ButtonControllers.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
///
|
|
|
|
class Controller;
|
|
|
|
///
|
|
|
|
class View;
|
|
|
|
|
|
|
|
///
|
|
|
|
void setController(Controller *);
|
|
|
|
///
|
|
|
|
void setView(View *);
|
|
|
|
|
|
|
|
///
|
|
|
|
Controller & controller() const;
|
|
|
|
///
|
2003-03-10 03:13:28 +00:00
|
|
|
ButtonController & bc() const;
|
2003-02-25 14:51:38 +00:00
|
|
|
///
|
|
|
|
View & view() const;
|
|
|
|
//@}
|
|
|
|
|
2003-03-05 11:30:35 +00:00
|
|
|
private:
|
2003-02-25 14:51:38 +00:00
|
|
|
///
|
|
|
|
void apply();
|
|
|
|
|
|
|
|
///
|
|
|
|
bool is_closing_;
|
|
|
|
///
|
|
|
|
Kernel kernel_;
|
|
|
|
///
|
|
|
|
string name_;
|
|
|
|
///
|
2003-03-10 03:13:28 +00:00
|
|
|
boost::scoped_ptr<ButtonController> bc_ptr_;
|
2003-02-25 14:51:38 +00:00
|
|
|
///
|
|
|
|
boost::scoped_ptr<Controller> controller_ptr_;
|
|
|
|
///
|
|
|
|
boost::scoped_ptr<View> view_ptr_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Dialog::Controller : boost::noncopyable {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
Controller(Dialog & parent) : parent_(parent) {}
|
|
|
|
///
|
|
|
|
virtual ~Controller() {}
|
|
|
|
///
|
|
|
|
virtual void initialiseParams(string const & data) = 0;
|
|
|
|
///
|
|
|
|
virtual void clearParams() = 0;
|
|
|
|
///
|
|
|
|
virtual void dispatchParams() = 0;
|
|
|
|
///
|
|
|
|
virtual bool isBufferDependent() const = 0;
|
|
|
|
///
|
|
|
|
virtual bool disconnectOnApply() const { return false; }
|
|
|
|
///
|
2003-03-05 11:30:35 +00:00
|
|
|
Dialog & dialog() { return parent_; }
|
|
|
|
///
|
|
|
|
Dialog const & dialog() const { return parent_; }
|
|
|
|
///
|
2003-02-25 14:51:38 +00:00
|
|
|
Kernel & kernel() { return parent_.kernel(); }
|
|
|
|
///
|
|
|
|
Kernel const & kernel() const { return parent_.kernel(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
Dialog & parent_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Dialog::View : boost::noncopyable {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
View(Dialog & parent) : p_(parent) {}
|
|
|
|
///
|
|
|
|
virtual ~View() {}
|
|
|
|
|
|
|
|
/// Apply changes to LyX data from dialog.
|
|
|
|
virtual void apply() = 0;
|
|
|
|
/// Hide the dialog.
|
|
|
|
virtual void hide() = 0;
|
|
|
|
/// Redraw the dialog (e.g. if the colors have been remapped).
|
|
|
|
virtual void redraw() {}
|
|
|
|
/// Create the dialog if necessary, update it and display it.
|
|
|
|
virtual void show() = 0;
|
|
|
|
/// Update dialog before/whilst showing it.
|
|
|
|
virtual void update() = 0;
|
|
|
|
///
|
|
|
|
virtual bool isVisible() const = 0;
|
|
|
|
|
|
|
|
/** Defaults to nothing. Can be used by the controller, however, to
|
|
|
|
* indicate to the view that something has changed and that the
|
|
|
|
* dialog therefore needs updating.
|
|
|
|
*/
|
|
|
|
virtual void partialUpdate(int) {}
|
|
|
|
|
|
|
|
///
|
|
|
|
Dialog & dialog() { return p_; }
|
|
|
|
///
|
|
|
|
Dialog const & dialog() const { return p_; }
|
|
|
|
|
|
|
|
///
|
|
|
|
Kernel & kernel() { return p_.kernel(); }
|
|
|
|
///
|
|
|
|
Kernel const & kernel() const { return p_.kernel(); }
|
|
|
|
|
|
|
|
///
|
|
|
|
Controller & getController() { return p_.controller(); }
|
|
|
|
///
|
|
|
|
Controller const & getController() const { return p_.controller(); }
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
///
|
|
|
|
ButtonController & bc() { return p_.bc(); }
|
|
|
|
///
|
|
|
|
ButtonController const & bc() const { return p_.bc(); }
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
protected:
|
|
|
|
///
|
|
|
|
Dialog & p_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DIALOG_H
|